style: apply cargo fmt to entire codebase

Standardize code formatting across all 173 Rust source files
using rustfmt. No functional changes - purely cosmetic.

This establishes a consistent code style baseline for the
project going forward.
This commit is contained in:
Dionisio
2026-02-14 01:29:34 +01:00
parent 67137a3ef2
commit 4c98c5a657
173 changed files with 23368 additions and 17590 deletions
+208 -115
View File
@@ -1,8 +1,8 @@
use axum::Json;
use axum::extract::{Path, State};
use axum::http::StatusCode;
use axum::Json;
use serde_json::json;
use tracing::{debug, error, warn, instrument};
use tracing::{debug, error, instrument, warn};
// use crate::application::ports::trash_ports::TrashUseCase;
use crate::common::di::AppState;
@@ -20,28 +20,34 @@ pub async fn get_trash_items(
let effective_user = auth_user.id.clone();
debug!("Request to list trash items for user {}", effective_user);
let trash_service = match state.trash_service.as_ref() {
Some(service) => service,
None => {
return (StatusCode::NOT_IMPLEMENTED, Json(json!({
"error": "Trash feature is not enabled"
})));
return (
StatusCode::NOT_IMPLEMENTED,
Json(json!({
"error": "Trash feature is not enabled"
})),
);
}
};
let result = trash_service.get_trash_items(&effective_user).await;
match result {
Ok(items) => {
debug!("Found {} items in trash", items.len());
(StatusCode::OK, Json(json!(items)))
},
}
Err(e) => {
error!("Error retrieving trash items: {:?}", e);
(StatusCode::INTERNAL_SERVER_ERROR, Json(json!({
"error": format!("Error retrieving trash items: {}", e)
})))
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(json!({
"error": format!("Error retrieving trash items: {}", e)
})),
)
}
}
}
@@ -53,33 +59,49 @@ pub async fn move_to_trash(
OptionalAuthUser(auth_user): OptionalAuthUser,
Path((item_type, item_id)): Path<(String, String)>,
) -> (StatusCode, Json<serde_json::Value>) {
let user_id = auth_user.as_ref().map(|u| u.id.as_str()).unwrap_or("anonymous");
debug!("Request to move to trash: type={}, id={}, user={}",
item_type, item_id, user_id);
let user_id = auth_user
.as_ref()
.map(|u| u.id.as_str())
.unwrap_or("anonymous");
debug!(
"Request to move to trash: type={}, id={}, user={}",
item_type, item_id, user_id
);
let trash_service = match state.trash_service.as_ref() {
Some(service) => service,
None => {
return (StatusCode::NOT_IMPLEMENTED, Json(json!({
"error": "Trash feature is not enabled"
})));
return (
StatusCode::NOT_IMPLEMENTED,
Json(json!({
"error": "Trash feature is not enabled"
})),
);
}
};
let result = trash_service.move_to_trash(&item_id, &item_type, user_id).await;
let result = trash_service
.move_to_trash(&item_id, &item_type, user_id)
.await;
match result {
Ok(_) => {
debug!("Item moved to trash successfully");
(StatusCode::OK, Json(json!({
"success": true,
"message": "Item moved to trash successfully"
})))
},
(
StatusCode::OK,
Json(json!({
"success": true,
"message": "Item moved to trash successfully"
})),
)
}
Err(e) => {
error!("Error moving item to trash: {:?}", e);
(StatusCode::INTERNAL_SERVER_ERROR, Json(json!({
"error": format!("Error moving item to trash: {}", e)
})))
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(json!({
"error": format!("Error moving item to trash: {}", e)
})),
)
}
}
}
@@ -91,35 +113,49 @@ pub async fn move_file_to_trash(
OptionalAuthUser(auth_user): OptionalAuthUser,
Path(item_id): Path<String>,
) -> (StatusCode, Json<serde_json::Value>) {
let user_id = auth_user.as_ref().map(|u| u.id.as_str()).unwrap_or("anonymous");
debug!("Request to move file to trash: id={}, user={}",
item_id, user_id);
let user_id = auth_user
.as_ref()
.map(|u| u.id.as_str())
.unwrap_or("anonymous");
debug!(
"Request to move file to trash: id={}, user={}",
item_id, user_id
);
let trash_service = match state.trash_service.as_ref() {
Some(service) => service,
None => {
return (StatusCode::NOT_IMPLEMENTED, Json(json!({
"error": "Trash feature is not enabled"
})));
return (
StatusCode::NOT_IMPLEMENTED,
Json(json!({
"error": "Trash feature is not enabled"
})),
);
}
};
// Specify that it is a file
let result = trash_service.move_to_trash(&item_id, "file", user_id).await;
match result {
Ok(_) => {
debug!("File moved to trash successfully");
(StatusCode::OK, Json(json!({
"success": true,
"message": "File moved to trash successfully"
})))
},
(
StatusCode::OK,
Json(json!({
"success": true,
"message": "File moved to trash successfully"
})),
)
}
Err(e) => {
error!("Error moving file to trash: {:?}", e);
(StatusCode::INTERNAL_SERVER_ERROR, Json(json!({
"error": format!("Error moving file to trash: {}", e)
})))
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(json!({
"error": format!("Error moving file to trash: {}", e)
})),
)
}
}
}
@@ -131,35 +167,51 @@ pub async fn move_folder_to_trash(
OptionalAuthUser(auth_user): OptionalAuthUser,
Path(item_id): Path<String>,
) -> (StatusCode, Json<serde_json::Value>) {
let user_id = auth_user.as_ref().map(|u| u.id.as_str()).unwrap_or("anonymous");
debug!("Request to move folder to trash: id={}, user={}",
item_id, user_id);
let user_id = auth_user
.as_ref()
.map(|u| u.id.as_str())
.unwrap_or("anonymous");
debug!(
"Request to move folder to trash: id={}, user={}",
item_id, user_id
);
let trash_service = match state.trash_service.as_ref() {
Some(service) => service,
None => {
return (StatusCode::NOT_IMPLEMENTED, Json(json!({
"error": "Trash feature is not enabled"
})));
return (
StatusCode::NOT_IMPLEMENTED,
Json(json!({
"error": "Trash feature is not enabled"
})),
);
}
};
// Specify that it is a folder
let result = trash_service.move_to_trash(&item_id, "folder", user_id).await;
let result = trash_service
.move_to_trash(&item_id, "folder", user_id)
.await;
match result {
Ok(_) => {
debug!("Folder moved to trash successfully");
(StatusCode::OK, Json(json!({
"success": true,
"message": "Folder moved to trash successfully"
})))
},
(
StatusCode::OK,
Json(json!({
"success": true,
"message": "Folder moved to trash successfully"
})),
)
}
Err(e) => {
error!("Error moving folder to trash: {:?}", e);
(StatusCode::INTERNAL_SERVER_ERROR, Json(json!({
"error": format!("Error moving folder to trash: {}", e)
})))
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(json!({
"error": format!("Error moving folder to trash: {}", e)
})),
)
}
}
}
@@ -172,40 +224,55 @@ pub async fn restore_from_trash(
Path(trash_id): Path<String>,
) -> (StatusCode, Json<serde_json::Value>) {
debug!("Request to restore item {} from trash", trash_id);
let trash_service = match state.trash_service.as_ref() {
Some(service) => service,
None => {
return (StatusCode::NOT_IMPLEMENTED, Json(json!({
"error": "Trash feature is not enabled"
})));
return (
StatusCode::NOT_IMPLEMENTED,
Json(json!({
"error": "Trash feature is not enabled"
})),
);
}
};
let result = trash_service.restore_item(&trash_id, &auth_user.id).await;
match result {
Ok(_) => {
debug!("Item restored successfully");
(StatusCode::OK, Json(json!({
"success": true,
"message": "Item restored successfully"
})))
},
(
StatusCode::OK,
Json(json!({
"success": true,
"message": "Item restored successfully"
})),
)
}
Err(e) => {
let err_str = format!("{}", e);
// If item not found, report success (it was already restored or removed)
if err_str.contains("not found") || err_str.contains("NotFound") {
warn!("Item not found in trash, but reporting success: {}", trash_id);
return (StatusCode::OK, Json(json!({
"success": true,
"message": "Item restored (or was already removed from trash)"
})));
warn!(
"Item not found in trash, but reporting success: {}",
trash_id
);
return (
StatusCode::OK,
Json(json!({
"success": true,
"message": "Item restored (or was already removed from trash)"
})),
);
}
error!("Error restoring item from trash: {:?}", e);
(StatusCode::INTERNAL_SERVER_ERROR, Json(json!({
"error": format!("Error restoring item from trash: {}", e)
})))
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(json!({
"error": format!("Error restoring item from trash: {}", e)
})),
)
}
}
}
@@ -218,40 +285,57 @@ pub async fn delete_permanently(
Path(trash_id): Path<String>,
) -> (StatusCode, Json<serde_json::Value>) {
debug!("Request to permanently delete item {}", trash_id);
let trash_service = match state.trash_service.as_ref() {
Some(service) => service,
None => {
return (StatusCode::NOT_IMPLEMENTED, Json(json!({
"error": "Trash feature is not enabled"
})));
return (
StatusCode::NOT_IMPLEMENTED,
Json(json!({
"error": "Trash feature is not enabled"
})),
);
}
};
let result = trash_service.delete_permanently(&trash_id, &auth_user.id).await;
let result = trash_service
.delete_permanently(&trash_id, &auth_user.id)
.await;
match result {
Ok(_) => {
debug!("Item permanently deleted");
(StatusCode::OK, Json(json!({
"success": true,
"message": "Item deleted permanently"
})))
},
(
StatusCode::OK,
Json(json!({
"success": true,
"message": "Item deleted permanently"
})),
)
}
Err(e) => {
let err_str = format!("{}", e);
// If item not found, report success (it was already deleted)
if err_str.contains("not found") || err_str.contains("NotFound") {
warn!("Item not found in trash, but reporting success: {}", trash_id);
return (StatusCode::OK, Json(json!({
"success": true,
"message": "Item deleted (or was already removed from trash)"
})));
warn!(
"Item not found in trash, but reporting success: {}",
trash_id
);
return (
StatusCode::OK,
Json(json!({
"success": true,
"message": "Item deleted (or was already removed from trash)"
})),
);
}
error!("Error permanently deleting item: {:?}", e);
(StatusCode::INTERNAL_SERVER_ERROR, Json(json!({
"error": format!("Error deleting item permanently: {}", e)
})))
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(json!({
"error": format!("Error deleting item permanently: {}", e)
})),
)
}
}
}
@@ -263,30 +347,39 @@ pub async fn empty_trash(
auth_user: AuthUser,
) -> (StatusCode, Json<serde_json::Value>) {
debug!("Request to empty trash for user {}", auth_user.id);
let trash_service = match state.trash_service.as_ref() {
Some(service) => service,
None => {
return (StatusCode::NOT_IMPLEMENTED, Json(json!({
"error": "Trash feature is not enabled"
})));
return (
StatusCode::NOT_IMPLEMENTED,
Json(json!({
"error": "Trash feature is not enabled"
})),
);
}
};
let result = trash_service.empty_trash(&auth_user.id).await;
match result {
Ok(_) => {
debug!("Trash emptied successfully");
(StatusCode::OK, Json(json!({
"success": true,
"message": "Trash emptied successfully"
})))
},
(
StatusCode::OK,
Json(json!({
"success": true,
"message": "Trash emptied successfully"
})),
)
}
Err(e) => {
error!("Error emptying trash: {:?}", e);
(StatusCode::INTERNAL_SERVER_ERROR, Json(json!({
"error": format!("Error emptying trash: {}", e)
})))
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(json!({
"error": format!("Error emptying trash: {}", e)
})),
)
}
}
}
}