chore: migrate to Rust Edition 2024
- Update edition from 2021 to 2024 in Cargo.toml - Remove explicit `ref` bindings in pattern matches (di.rs, carddav_adapter.rs) Edition 2024 uses implicit ref binding modes - Refactor folder_handler.rs: change `impl IntoResponse` return types to concrete `axum::response::Response` to avoid lifetime capture issues (Edition 2024 captures all in-scope lifetimes in `impl Trait`) - All 101 tests pass, zero warnings
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "oxicloud"
|
||||
version = "0.3.5"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
default-run = "oxicloud"
|
||||
|
||||
|
||||
|
||||
@@ -555,15 +555,15 @@ pub fn contact_to_vcard(contact: &ContactDto) -> String {
|
||||
|
||||
vcard.push_str(&format!("UID:{}\r\n", contact.uid));
|
||||
|
||||
if let (Some(ref last), Some(ref first)) = (&contact.last_name, &contact.first_name) {
|
||||
if let (Some(last), Some(first)) = (&contact.last_name, &contact.first_name) {
|
||||
vcard.push_str(&format!("N:{};{};;;\r\n", last, first));
|
||||
} else if let Some(ref last) = &contact.last_name {
|
||||
} else if let Some(last) = &contact.last_name {
|
||||
vcard.push_str(&format!("N:{};;;;\r\n", last));
|
||||
} else if let Some(ref first) = &contact.first_name {
|
||||
} else if let Some(first) = &contact.first_name {
|
||||
vcard.push_str(&format!("N:;{};;;\r\n", first));
|
||||
}
|
||||
|
||||
if let Some(ref fn_name) = contact.full_name {
|
||||
if let Some(fn_name) = &contact.full_name {
|
||||
vcard.push_str(&format!("FN:{}\r\n", fn_name));
|
||||
} else {
|
||||
// FN is mandatory in vCard 3.0
|
||||
@@ -578,7 +578,7 @@ pub fn contact_to_vcard(contact: &ContactDto) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref nickname) = contact.nickname {
|
||||
if let Some(nickname) = &contact.nickname {
|
||||
vcard.push_str(&format!("NICKNAME:{}\r\n", nickname));
|
||||
}
|
||||
|
||||
@@ -601,19 +601,19 @@ pub fn contact_to_vcard(contact: &ContactDto) -> String {
|
||||
vcard.push_str(&format!("ADR;TYPE={}:{}\r\n", addr.r#type.to_uppercase(), adr));
|
||||
}
|
||||
|
||||
if let Some(ref org) = contact.organization {
|
||||
if let Some(org) = &contact.organization {
|
||||
vcard.push_str(&format!("ORG:{}\r\n", org));
|
||||
}
|
||||
if let Some(ref title) = contact.title {
|
||||
if let Some(title) = &contact.title {
|
||||
vcard.push_str(&format!("TITLE:{}\r\n", title));
|
||||
}
|
||||
if let Some(ref notes) = contact.notes {
|
||||
if let Some(notes) = &contact.notes {
|
||||
vcard.push_str(&format!("NOTE:{}\r\n", notes.replace('\n', "\\n")));
|
||||
}
|
||||
if let Some(ref bday) = contact.birthday {
|
||||
if let Some(bday) = &contact.birthday {
|
||||
vcard.push_str(&format!("BDAY:{}\r\n", bday.format("%Y-%m-%d")));
|
||||
}
|
||||
if let Some(ref photo) = contact.photo_url {
|
||||
if let Some(photo) = &contact.photo_url {
|
||||
vcard.push_str(&format!("PHOTO;VALUE=URI:{}\r\n", photo));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -590,7 +590,7 @@ impl AppServiceFactory {
|
||||
};
|
||||
|
||||
// 10b. Wire admin settings service when auth + DB are available
|
||||
if let (Some(ref auth_svc), Some(ref pool)) = (&app_state.auth_service, &db_pool) {
|
||||
if let (Some(auth_svc), Some(pool)) = (&app_state.auth_service, &db_pool) {
|
||||
let settings_repo = Arc::new(
|
||||
crate::infrastructure::repositories::pg::SettingsPgRepository::new(pool.clone())
|
||||
);
|
||||
|
||||
@@ -63,16 +63,16 @@ impl FolderHandler {
|
||||
pub async fn list_root_folders(
|
||||
State(service): State<AppState>,
|
||||
auth_user: AuthUser,
|
||||
) -> impl IntoResponse {
|
||||
Self::list_folders_for_user(State(service), None, &auth_user).await
|
||||
) -> axum::response::Response {
|
||||
Self::list_folders_for_user(service, None, &auth_user).await
|
||||
}
|
||||
|
||||
/// Lists contents of a specific folder by its ID
|
||||
pub async fn list_folder_contents(
|
||||
State(service): State<AppState>,
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
Self::list_folders(State(service), Some(&id)).await
|
||||
) -> axum::response::Response {
|
||||
Self::list_folders_inner(service, Some(&id)).await
|
||||
}
|
||||
|
||||
/// Lists root folders with pagination support
|
||||
@@ -80,10 +80,9 @@ impl FolderHandler {
|
||||
State(service): State<AppState>,
|
||||
auth_user: AuthUser,
|
||||
_pagination: Query<PaginationRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
) -> axum::response::Response {
|
||||
// For paginated root listing, filter by user as well
|
||||
// Delegate to non-paginated user-filtered listing for now
|
||||
Self::list_folders_for_user(State(service), None, &auth_user).await
|
||||
Self::list_folders_for_user(service, None, &auth_user).await
|
||||
}
|
||||
|
||||
/// Lists contents of a specific folder with pagination
|
||||
@@ -91,8 +90,8 @@ impl FolderHandler {
|
||||
State(service): State<AppState>,
|
||||
Path(id): Path<String>,
|
||||
pagination: Query<PaginationRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
Self::list_folders_paginated(State(service), pagination, Some(&id)).await
|
||||
) -> axum::response::Response {
|
||||
Self::list_folders_paginated_inner(service, pagination, Some(&id)).await
|
||||
}
|
||||
|
||||
/// Checks if a folder name matches the user home-folder convention.
|
||||
@@ -106,11 +105,11 @@ impl FolderHandler {
|
||||
folder_name == expected
|
||||
}
|
||||
|
||||
/// Lists folders, optionally filtered by parent ID
|
||||
pub async fn list_folders(
|
||||
State(service): State<AppState>,
|
||||
/// Lists folders, optionally filtered by parent ID (internal helper)
|
||||
async fn list_folders_inner(
|
||||
service: AppState,
|
||||
parent_id: Option<&str>,
|
||||
) -> impl IntoResponse {
|
||||
) -> axum::response::Response {
|
||||
match service.list_folders(parent_id).await {
|
||||
Ok(folders) => {
|
||||
(StatusCode::OK, Json(folders)).into_response()
|
||||
@@ -130,11 +129,11 @@ impl FolderHandler {
|
||||
|
||||
/// Lists folders with user-based filtering for root listings.
|
||||
/// Non-admin users only see their own home folder at the root level.
|
||||
pub async fn list_folders_for_user(
|
||||
State(service): State<AppState>,
|
||||
async fn list_folders_for_user(
|
||||
service: AppState,
|
||||
parent_id: Option<&str>,
|
||||
auth_user: &AuthUser,
|
||||
) -> impl IntoResponse {
|
||||
) -> axum::response::Response {
|
||||
match service.list_folders(parent_id).await {
|
||||
Ok(folders) => {
|
||||
// Only filter at root level (parent_id == None)
|
||||
@@ -168,12 +167,12 @@ impl FolderHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/// Lists folders with pagination support
|
||||
pub async fn list_folders_paginated(
|
||||
State(service): State<AppState>,
|
||||
/// Lists folders with pagination support (internal helper)
|
||||
async fn list_folders_paginated_inner(
|
||||
service: AppState,
|
||||
Query(pagination): Query<PaginationRequestDto>,
|
||||
parent_id: Option<&str>,
|
||||
) -> impl IntoResponse {
|
||||
) -> axum::response::Response {
|
||||
match service.list_folders_paginated(parent_id, &pagination).await {
|
||||
Ok(paginated_result) => {
|
||||
(StatusCode::OK, Json(paginated_result)).into_response()
|
||||
|
||||
Reference in New Issue
Block a user