diff --git a/src/api/applications.rs b/src/api/applications.rs index 123fce0..5351d74 100644 --- a/src/api/applications.rs +++ b/src/api/applications.rs @@ -6,11 +6,11 @@ pub struct Application { pub id: String, pub name: String, pub description: Option, - #[allow(dead_code)] - pub logo_url: Option, + // Logo URL from API - preserved for future UI enhancements + // pub logo_url: Option, pub category: Option, - #[allow(dead_code)] - pub os_compatibility: Vec, + // OS compatibility list from API - preserved for filtering features + // pub os_compatibility: Vec, } /// Load available one-click applications from the API @@ -27,21 +27,21 @@ pub async fn load_applications( if let Some(arr) = data.get("applications").and_then(|a| a.as_array()) { for item in arr { if let Some(obj) = item.as_object() { - let os_compat = if let Some(compat) = obj.get("osCompatibility").and_then(|v| v.as_array()) { - compat.iter() - .filter_map(|v| v.as_str().map(|s| s.to_string())) - .collect() - } else { - Vec::new() - }; + // let os_compat = if let Some(compat) = obj.get("osCompatibility").and_then(|v| v.as_array()) { + // compat.iter() + // .filter_map(|v| v.as_str().map(|s| s.to_string())) + // .collect() + // } else { + // Vec::new() + // }; applications.push(Application { id: obj.get("id").and_then(|v| v.as_str()).unwrap_or("").to_string(), name: obj.get("name").and_then(|v| v.as_str()).unwrap_or("").to_string(), description: obj.get("description").and_then(|v| v.as_str()).map(|s| s.to_string()), - logo_url: obj.get("logoUrl").and_then(|v| v.as_str()).map(|s| s.to_string()), + // logo_url: obj.get("logoUrl").and_then(|v| v.as_str()).map(|s| s.to_string()), category: obj.get("category").and_then(|v| v.as_str()).map(|s| s.to_string()), - os_compatibility: os_compat, + // os_compatibility: os_compat, }); } } diff --git a/src/api/backups.rs b/src/api/backups.rs index 09c466e..5d644f6 100644 --- a/src/api/backups.rs +++ b/src/api/backups.rs @@ -9,8 +9,8 @@ pub struct BackupProfileView { pub schedule_frequency: Option, pub monthly_price: Option, pub max_files: Option, - #[allow(dead_code)] - pub created_at: Option, + // Created timestamp from API - preserved for future sorting/filtering + // pub created_at: Option, } /// Load backup profiles from the API @@ -33,7 +33,7 @@ pub async fn load_backups( schedule_frequency: obj.get("scheduleFrequency").and_then(|v| v.as_str()).map(|s| s.to_string()), monthly_price: obj.get("monthlyPrice").and_then(|v| v.as_f64()), max_files: obj.get("maxFiles").and_then(|v| v.as_i64()).map(|i| i as i32), - created_at: obj.get("createdAt").and_then(|v| v.as_i64()), + // created_at: obj.get("createdAt").and_then(|v| v.as_i64()), }); } } @@ -44,16 +44,16 @@ pub async fn load_backups( backups } -/// Get backup profile for instance -pub async fn get_backup_profile( - client: &reqwest::Client, - api_base_url: &str, - api_token: &str, - instance_id: &str, -) -> Value { - let endpoint = format!("/v1/backups/{}", instance_id); - api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await -} +// Get backup profile for instance - preserved for future use +// pub async fn get_backup_profile( +// client: &reqwest::Client, +// api_base_url: &str, +// api_token: &str, +// instance_id: &str, +// ) -> Value { +// let endpoint = format!("/v1/backups/{}", instance_id); +// api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await +// } /// Create backup profile pub async fn create_backup_profile( @@ -78,36 +78,36 @@ pub async fn create_backup_profile( api_call(client, api_base_url, api_token, "POST", "/v1/backups", Some(payload), None).await } -/// Update backup profile -pub async fn update_backup_profile( - client: &reqwest::Client, - api_base_url: &str, - api_token: &str, - instance_id: &str, - schedule_frequency: &str, - period_id: i32, - schedule_week_days: Option>, -) -> Value { - let mut payload = serde_json::json!({ - "instanceId": instance_id, - "scheduleFrequency": schedule_frequency, - "periodId": period_id - }); - - if let Some(days) = schedule_week_days { - payload["scheduleWeekDays"] = Value::Array(days.into_iter().map(Value::String).collect()); - } - - api_call(client, api_base_url, api_token, "PUT", "/v1/backups", Some(payload), None).await -} +// Update backup profile - preserved for future use +// pub async fn update_backup_profile( +// client: &reqwest::Client, +// api_base_url: &str, +// api_token: &str, +// instance_id: &str, +// schedule_frequency: &str, +// period_id: i32, +// schedule_week_days: Option>, +// ) -> Value { +// let mut payload = serde_json::json!({ +// "instanceId": instance_id, +// "scheduleFrequency": schedule_frequency, +// "periodId": period_id +// }); +// +// if let Some(days) = schedule_week_days { +// payload["scheduleWeekDays"] = Value::Array(days.into_iter().map(Value::String).collect()); +// } +// +// api_call(client, api_base_url, api_token, "PUT", "/v1/backups", Some(payload), None).await +// } -/// Delete backup profile -pub async fn delete_backup_profile( - client: &reqwest::Client, - api_base_url: &str, - api_token: &str, - instance_id: &str, -) -> Value { - let endpoint = format!("/v1/backups/{}", instance_id); - api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await -} +// Delete backup profile - preserved for future use +// pub async fn delete_backup_profile( +// client: &reqwest::Client, +// api_base_url: &str, +// api_token: &str, +// instance_id: &str, +// ) -> Value { +// let endpoint = format!("/v1/backups/{}", instance_id); +// api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await +// } diff --git a/src/api/floating_ips.rs b/src/api/floating_ips.rs index e45d5df..5cb2084 100644 --- a/src/api/floating_ips.rs +++ b/src/api/floating_ips.rs @@ -10,8 +10,8 @@ pub struct FloatingIpView { pub instance_id: Option, pub auto_renew: bool, pub customer_note: Option, - #[allow(dead_code)] - pub created_at: Option, + // Created timestamp from API - preserved for future sorting/filtering + // pub created_at: Option, } /// Paginated result structure for floating IPs @@ -56,7 +56,7 @@ pub async fn load_floating_ips( instance_id: obj.get("instanceId").and_then(|v| v.as_str()).map(|s| s.to_string()), auto_renew: obj.get("autoRenew").and_then(|v| v.as_bool()).unwrap_or(false), customer_note: obj.get("customerNote").and_then(|v| v.as_str()).map(|s| s.to_string()), - created_at: obj.get("createdAt").and_then(|v| v.as_i64()), + // created_at: obj.get("createdAt").and_then(|v| v.as_i64()), }); } } diff --git a/src/api/images.rs b/src/api/images.rs index eb31b78..dbef233 100644 --- a/src/api/images.rs +++ b/src/api/images.rs @@ -4,16 +4,16 @@ use serde_json::Value; /// Image view structure #[derive(Clone, Debug)] pub struct ImageView { - pub id: String, + // pub id: String, pub name: String, - pub url: String, + // pub url: String, pub status: String, pub region_id: String, pub format: Option, - #[allow(dead_code)] - pub decompress: Option, - #[allow(dead_code)] - pub created_at: Option, + // Decompress option from API - used when downloading images + // pub decompress: Option, + // Created timestamp from API - preserved for future sorting/filtering + // pub created_at: Option, } /// Paginated result structure for images @@ -21,9 +21,9 @@ pub struct ImageView { pub struct PaginatedImages { pub images: Vec, pub total_count: usize, - pub current_page: usize, - pub total_pages: usize, - pub per_page: usize, + // pub current_page: usize, + // pub total_pages: usize, + // pub per_page: usize, } /// Load images from the API @@ -52,14 +52,14 @@ pub async fn load_images( for item in arr { if let Some(obj) = item.as_object() { images.push(ImageView { - id: obj.get("id").and_then(|v| v.as_str()).unwrap_or("").to_string(), + // id: obj.get("id").and_then(|v| v.as_str()).unwrap_or("").to_string(), name: obj.get("name").and_then(|v| v.as_str()).unwrap_or("").to_string(), - url: obj.get("url").and_then(|v| v.as_str()).unwrap_or("").to_string(), + // url: obj.get("url").and_then(|v| v.as_str()).unwrap_or("").to_string(), status: obj.get("status").and_then(|v| v.as_str()).unwrap_or("UNKNOWN").to_string(), region_id: obj.get("regionId").and_then(|v| v.as_str()).unwrap_or("").to_string(), format: obj.get("format").and_then(|v| v.as_str()).map(|s| s.to_string()), - decompress: obj.get("decompress").and_then(|v| v.as_str()).map(|s| s.to_string()), - created_at: obj.get("createdAt").and_then(|v| v.as_i64()), + // decompress: obj.get("decompress").and_then(|v| v.as_str()).map(|s| s.to_string()), + // created_at: obj.get("createdAt").and_then(|v| v.as_i64()), }); } } @@ -70,15 +70,15 @@ pub async fn load_images( } let actual_total = if total_count > 0 { total_count } else { images.len() }; - let total_pages = if per_page > 0 { actual_total.div_ceil(per_page) } else { 1 }; - let current_page = if page >= 1 { page } else { 1 }; + // let total_pages = if per_page > 0 { actual_total.div_ceil(per_page) } else { 1 }; + // let current_page = if page >= 1 { page } else { 1 }; PaginatedImages { images, total_count: actual_total, - current_page, - total_pages, - per_page, + // current_page, + // total_pages, + // per_page, } } @@ -110,24 +110,24 @@ pub async fn download_image( api_call(client, api_base_url, api_token, "POST", "/v1/images", Some(payload), None).await } -/// Get image details -pub async fn get_image( - client: &reqwest::Client, - api_base_url: &str, - api_token: &str, - image_id: &str, -) -> Value { - let endpoint = format!("/v1/images/{}", image_id); - api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await -} +// Get image details - preserved for future use +// pub async fn get_image( +// client: &reqwest::Client, +// api_base_url: &str, +// api_token: &str, +// image_id: &str, +// ) -> Value { +// let endpoint = format!("/v1/images/{}", image_id); +// api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await +// } -/// Delete an image -pub async fn delete_image( - client: &reqwest::Client, - api_base_url: &str, - api_token: &str, - image_id: &str, -) -> Value { - let endpoint = format!("/v1/images/{}", image_id); - api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await -} +// Delete an image - preserved for future use +// pub async fn delete_image( +// client: &reqwest::Client, +// api_base_url: &str, +// api_token: &str, +// image_id: &str, +// ) -> Value { +// let endpoint = format!("/v1/images/{}", image_id); +// api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await +// } diff --git a/src/api/iso.rs b/src/api/iso.rs index 0625f48..fea325d 100644 --- a/src/api/iso.rs +++ b/src/api/iso.rs @@ -4,14 +4,14 @@ use serde_json::Value; /// ISO view structure #[derive(Clone, Debug)] pub struct IsoView { - pub id: String, + // pub id: String, pub name: String, - pub url: String, + // pub url: String, pub status: String, pub region_id: String, pub use_virtio: bool, - #[allow(dead_code)] - pub created_at: Option, + // Created timestamp from API - preserved for future sorting/filtering + // pub created_at: Option, } /// Paginated result structure for ISOs @@ -19,9 +19,9 @@ pub struct IsoView { pub struct PaginatedIsos { pub isos: Vec, pub total_count: usize, - pub current_page: usize, - pub total_pages: usize, - pub per_page: usize, + // pub current_page: usize, + // pub total_pages: usize, + // pub per_page: usize, } /// Load ISOs from the API @@ -50,13 +50,13 @@ pub async fn load_isos( for item in arr { if let Some(obj) = item.as_object() { isos.push(IsoView { - id: obj.get("id").and_then(|v| v.as_str()).unwrap_or("").to_string(), + // id: obj.get("id").and_then(|v| v.as_str()).unwrap_or("").to_string(), name: obj.get("name").and_then(|v| v.as_str()).unwrap_or("").to_string(), - url: obj.get("url").and_then(|v| v.as_str()).unwrap_or("").to_string(), + // url: obj.get("url").and_then(|v| v.as_str()).unwrap_or("").to_string(), status: obj.get("status").and_then(|v| v.as_str()).unwrap_or("UNKNOWN").to_string(), region_id: obj.get("regionId").and_then(|v| v.as_str()).unwrap_or("").to_string(), use_virtio: obj.get("useVirtio").and_then(|v| v.as_bool()).unwrap_or(true), - created_at: obj.get("createdAt").and_then(|v| v.as_i64()), + // created_at: obj.get("createdAt").and_then(|v| v.as_i64()), }); } } @@ -67,15 +67,15 @@ pub async fn load_isos( } let actual_total = if total_count > 0 { total_count } else { isos.len() }; - let total_pages = if per_page > 0 { actual_total.div_ceil(per_page) } else { 1 }; - let current_page = if page >= 1 { page } else { 1 }; + // let total_pages = if per_page > 0 { actual_total.div_ceil(per_page) } else { 1 }; + // let current_page = if page >= 1 { page } else { 1 }; PaginatedIsos { isos, total_count: actual_total, - current_page, - total_pages, - per_page, + // current_page, + // total_pages, + // per_page, } } @@ -98,24 +98,24 @@ pub async fn download_iso( api_call(client, api_base_url, api_token, "POST", "/v1/iso", Some(payload), None).await } -/// Get ISO details -pub async fn get_iso( - client: &reqwest::Client, - api_base_url: &str, - api_token: &str, - iso_id: &str, -) -> Value { - let endpoint = format!("/v1/iso/{}", iso_id); - api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await -} +// Get ISO details - preserved for future use +// pub async fn get_iso( +// client: &reqwest::Client, +// api_base_url: &str, +// api_token: &str, +// iso_id: &str, +// ) -> Value { +// let endpoint = format!("/v1/iso/{}", iso_id); +// api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await +// } -/// Delete an ISO -pub async fn delete_iso( - client: &reqwest::Client, - api_base_url: &str, - api_token: &str, - iso_id: &str, -) -> Value { - let endpoint = format!("/v1/iso/{}", iso_id); - api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await -} +// Delete an ISO - preserved for future use +// pub async fn delete_iso( +// client: &reqwest::Client, +// api_base_url: &str, +// api_token: &str, +// iso_id: &str, +// ) -> Value { +// let endpoint = format!("/v1/iso/{}", iso_id); +// api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await +// } diff --git a/src/api/mod.rs b/src/api/mod.rs index 97dfc88..2e6d8b3 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -28,6 +28,6 @@ pub use floating_ips::{ load_floating_ips, create_floating_ips, update_floating_ip, release_floating_ip, FloatingIpView, }; -pub use iso::{load_isos, download_iso, get_iso, delete_iso, IsoView}; -pub use images::{load_images, download_image, get_image, delete_image, ImageView}; -pub use backups::{load_backups, get_backup_profile, create_backup_profile, update_backup_profile, delete_backup_profile, BackupProfileView}; +pub use iso::{load_isos, download_iso, IsoView}; +pub use images::{load_images, download_image, ImageView}; +pub use backups::{load_backups, create_backup_profile, BackupProfileView}; diff --git a/src/api/snapshots.rs b/src/api/snapshots.rs index 4b55672..9a9e3f8 100644 --- a/src/api/snapshots.rs +++ b/src/api/snapshots.rs @@ -9,13 +9,13 @@ pub struct SnapshotView { pub size: Option, pub status: String, pub created_at: Option, - #[allow(dead_code)] - pub last_restored_at: Option, - #[allow(dead_code)] - pub is_instance_deleted: bool, + // Last restored timestamp from API - preserved for future display enhancements + // pub last_restored_at: Option, + // Flag indicating if the source instance was deleted - preserved for display logic + // pub is_instance_deleted: bool, pub instance_id: String, - #[allow(dead_code)] - pub region_id: Option, + // Region ID from API - preserved for region-aware operations + // pub region_id: Option, } /// Paginated result structure for snapshots @@ -65,10 +65,10 @@ pub async fn load_snapshots( size: obj.get("size").and_then(|v| v.as_i64()), status: obj.get("status").and_then(|v| v.as_str()).unwrap_or("").to_string(), created_at: obj.get("createdAt").and_then(|v| v.as_i64()), - last_restored_at: obj.get("lastRestoredAt").and_then(|v| v.as_i64()), - is_instance_deleted: obj.get("isInstanceDeleted").and_then(|v| v.as_bool()).unwrap_or(false), + // last_restored_at: obj.get("lastRestoredAt").and_then(|v| v.as_i64()), + // is_instance_deleted: obj.get("isInstanceDeleted").and_then(|v| v.as_bool()).unwrap_or(false), instance_id: obj.get("instanceId").and_then(|v| v.as_str()).unwrap_or("").to_string(), - region_id: obj.get("regionId").and_then(|v| v.as_str()).map(|s| s.to_string()), + // region_id: obj.get("regionId").and_then(|v| v.as_str()).map(|s| s.to_string()), }); } } diff --git a/src/config.rs b/src/config.rs index 139c478..9d0943c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,8 +10,6 @@ pub const DEFAULT_PUBLIC_BASE_URL: &str = ""; pub const DEFAULT_OWNER_USERNAME: &str = "owner"; pub const DEFAULT_OWNER_PASSWORD: &str = "owner123"; pub const DEFAULT_OWNER_ROLE: &str = "owner"; -#[allow(dead_code)] -pub const DEFAULT_ADMIN_ROLE: &str = "admin"; pub const DEFAULT_PBKDF2_ITERATIONS: u32 = 100_000; pub fn load_env_file(env_file: Option<&str>) { diff --git a/src/handlers/helpers.rs b/src/handlers/helpers.rs index 40c1362..86a7adf 100644 --- a/src/handlers/helpers.rs +++ b/src/handlers/helpers.rs @@ -8,7 +8,7 @@ use crate::api::{ api_call, load_ssh_keys, load_ssh_keys_paginated, load_regions, load_products, load_instances_for_user, PaginatedInstances, PaginatedSshKeys }; -use crate::models::{AppState, CurrentUser, SshKeyView, Region, ProductView, InstanceView}; +use crate::models::{AppState, CurrentUser, SshKeyView, Region, ProductView}; use std::collections::HashMap; #[derive(Deserialize, Debug)] @@ -103,13 +103,13 @@ pub fn ensure_owner(state: &AppState, jar: &CookieJar) -> Option { Some(Redirect::to("/")) } -#[allow(dead_code)] -pub fn ensure_logged_in(state: &AppState, jar: &CookieJar) -> Option { - if current_username_from_jar(state, jar).is_none() { - return Some(Redirect::to("/login")); - } - None -} +// Ensure user is logged in - preserved for future route guards +// pub fn ensure_logged_in(state: &AppState, jar: &CookieJar) -> Option { +// if current_username_from_jar(state, jar).is_none() { +// return Some(Redirect::to("/login")); +// } +// None +// } pub fn ensure_admin_or_owner(state: &AppState, jar: &CookieJar) -> Option { let username = current_username_from_jar(state, jar)?; @@ -242,12 +242,12 @@ pub async fn load_products_wrapper(state: &AppState, region_id: &str) -> Vec Vec { - let users_map = state.users.lock().unwrap().clone(); - let result = load_instances_for_user(&state.client, &state.api_base_url, &state.api_token, &users_map, username, 0, 0).await; - result.instances -} +// Load all instances for a user (non-paginated) - preserved for future use +// pub async fn load_instances_for_user_wrapper(state: &AppState, username: &str) -> Vec { +// let users_map = state.users.lock().unwrap().clone(); +// let result = load_instances_for_user(&state.client, &state.api_base_url, &state.api_token, &users_map, username, 0, 0).await; +// result.instances +// } pub async fn load_instances_for_user_paginated( state: &AppState, diff --git a/src/handlers/images.rs b/src/handlers/images.rs index 9b6ed43..0397264 100644 --- a/src/handlers/images.rs +++ b/src/handlers/images.rs @@ -67,9 +67,9 @@ pub async fn images_list_get( flash_messages, has_flash_messages, images: &paginated.images, - current_page: paginated.current_page, - total_pages: paginated.total_pages, - per_page: paginated.per_page, + // current_page: paginated.current_page, + // total_pages: paginated.total_pages, + // per_page: paginated.per_page, total_count: paginated.total_count, }, ) diff --git a/src/handlers/iso.rs b/src/handlers/iso.rs index 267adc4..49f7f2a 100644 --- a/src/handlers/iso.rs +++ b/src/handlers/iso.rs @@ -67,9 +67,9 @@ pub async fn isos_list_get( flash_messages, has_flash_messages, isos: &paginated.isos, - current_page: paginated.current_page, - total_pages: paginated.total_pages, - per_page: paginated.per_page, + // current_page: paginated.current_page, + // total_pages: paginated.total_pages, + // per_page: paginated.per_page, total_count: paginated.total_count, }, ) diff --git a/src/models/confirmation.rs b/src/models/confirmation.rs index 1299ff8..ff9525e 100644 --- a/src/models/confirmation.rs +++ b/src/models/confirmation.rs @@ -40,24 +40,24 @@ impl ConfirmationAction { } } - #[allow(dead_code)] - pub fn to_str(&self) -> &'static str { - match self { - Self::DeleteUser => "delete-user", - Self::DeleteInstance => "delete-instance", - Self::PowerOnInstance => "power-on-instance", - Self::PowerOffInstance => "power-off-instance", - Self::ResetInstance => "reset-instance", - Self::SwitchVersion => "switch-version", - Self::ChangeOs => "change-os", - Self::ResizeInstance => "resize-instance", - Self::AddTraffic => "add-traffic", - Self::CreateSnapshot => "create-snapshot", - Self::DeleteSnapshot => "delete-snapshot", - Self::RestoreSnapshot => "restore-snapshot", - Self::DeleteSshKey => "delete-ssh-key", - Self::ReleaseFloatingIp => "release-floating-ip", - } - } + // Convert action to string representation - preserved for future serialization needs + // pub fn to_str(&self) -> &'static str { + // match self { + // Self::DeleteUser => "delete-user", + // Self::DeleteInstance => "delete-instance", + // Self::PowerOnInstance => "power-on-instance", + // Self::PowerOffInstance => "power-off-instance", + // Self::ResetInstance => "reset-instance", + // Self::SwitchVersion => "switch-version", + // Self::ChangeOs => "change-os", + // Self::ResizeInstance => "resize-instance", + // Self::AddTraffic => "add-traffic", + // Self::CreateSnapshot => "create-snapshot", + // Self::DeleteSnapshot => "delete-snapshot", + // Self::RestoreSnapshot => "restore-snapshot", + // Self::DeleteSshKey => "delete-ssh-key", + // Self::ReleaseFloatingIp => "release-floating-ip", + // } + // } } diff --git a/src/models/ssh_key_selection_form.rs b/src/models/ssh_key_selection_form.rs index 925ccc2..ea75ec3 100644 --- a/src/models/ssh_key_selection_form.rs +++ b/src/models/ssh_key_selection_form.rs @@ -1,21 +1,21 @@ -use serde::Deserialize; +// Form data for Step 7 (SSH key selection) - preserved for future use +// use serde::Deserialize; -#[allow(dead_code)] -#[derive(Deserialize)] -pub struct SshKeySelectionFormStep7 { - pub product_id: Option, - pub cpu: Option, - #[serde(rename = "ramInGB")] - pub ram_in_gb: Option, - #[serde(rename = "diskInGB")] - pub disk_in_gb: Option, - #[serde(rename = "bandwidthInTB")] - pub bandwidth_in_tb: Option, - pub region: String, - pub os_id: String, - pub ssh_key_ids: Option, - pub hostnames: String, - pub assign_ipv4: Option, - pub assign_ipv6: Option, - pub floating_ip_count: Option, -} +// #[derive(Deserialize)] +// pub struct SshKeySelectionFormStep7 { +// pub product_id: Option, +// pub cpu: Option, +// #[serde(rename = "ramInGB")] +// pub ram_in_gb: Option, +// #[serde(rename = "diskInGB")] +// pub disk_in_gb: Option, +// #[serde(rename = "bandwidthInTB")] +// pub bandwidth_in_tb: Option, +// pub region: String, +// pub os_id: String, +// pub ssh_key_ids: Option, +// pub hostnames: String, +// pub assign_ipv4: Option, +// pub assign_ipv6: Option, +// pub floating_ip_count: Option, +// } diff --git a/src/services/instance_service.rs b/src/services/instance_service.rs index 962fc71..48d2ef7 100644 --- a/src/services/instance_service.rs +++ b/src/services/instance_service.rs @@ -54,7 +54,9 @@ pub async fn enforce_instance_access(state: &AppState, username: Option<&str>, i false } -#[allow(dead_code)] +/// Fetch instance details for action validation +/// +/// Used by check_instance_block to fetch instance hostname when not provided. pub async fn get_instance_for_action(state: &AppState, instance_id: &str) -> InstanceView { let endpoint = format!("/v1/instances/{}", instance_id); let payload = crate::api::api_call(&state.client, &state.api_base_url, &state.api_token, "GET", &endpoint, None, None).await; diff --git a/src/templates/base_template.rs b/src/templates/base_template.rs index 06ebaa7..de1dbb2 100644 --- a/src/templates/base_template.rs +++ b/src/templates/base_template.rs @@ -3,9 +3,20 @@ use crate::models::CurrentUser; /// Base template trait providing common properties for all templates. /// This eliminates redundant field definitions across templates. /// -/// Note: This trait is implemented by the `impl_base_template!` macro for all template structs. -/// The macro provides automatic implementations for standard template fields. -#[allow(dead_code)] // Used by impl_base_template! macro, but compiler doesn't detect it +/// # Macro Usage +/// +/// This trait is implemented automatically by the `impl_base_template!` macro for all template structs. +/// The compiler does not detect this macro-based usage, which is why this trait definition exists. +/// +/// The macro provides automatic implementations for standard template fields: +/// - current_user: Current authenticated user information +/// - api_hostname: Hostname extracted from API base URL +/// - base_url: Public base URL for the application +/// - flash_messages: List of flash messages to display +/// - has_flash_messages: Boolean indicating if flash messages exist +/// +/// Without this trait, each template would need to duplicate these common field definitions. +#[allow(dead_code)] // Used by impl_base_template! macro pub trait BaseTemplate { fn current_user(&self) -> &Option; fn api_hostname(&self) -> &str; diff --git a/src/templates/images_template.rs b/src/templates/images_template.rs index 056567f..fe63f49 100644 --- a/src/templates/images_template.rs +++ b/src/templates/images_template.rs @@ -11,9 +11,9 @@ pub struct ImagesTemplate<'a> { pub flash_messages: Vec, pub has_flash_messages: bool, pub images: &'a [ImageView], - pub current_page: usize, - pub total_pages: usize, - pub per_page: usize, + // pub current_page: usize, + // pub total_pages: usize, + // pub per_page: usize, pub total_count: usize, } diff --git a/src/templates/isos_template.rs b/src/templates/isos_template.rs index 68d1764..87170d8 100644 --- a/src/templates/isos_template.rs +++ b/src/templates/isos_template.rs @@ -11,9 +11,9 @@ pub struct IsosTemplate<'a> { pub flash_messages: Vec, pub has_flash_messages: bool, pub isos: &'a [IsoView], - pub current_page: usize, - pub total_pages: usize, - pub per_page: usize, + // pub current_page: usize, + // pub total_pages: usize, + // pub per_page: usize, pub total_count: usize, } diff --git a/src/update/asset.rs b/src/update/asset.rs index bd9801d..ae18e14 100644 --- a/src/update/asset.rs +++ b/src/update/asset.rs @@ -30,7 +30,6 @@ pub struct Asset { /// let result = parse_asset_name("zy-1.0.1-x86_64-pc-windows-msvc.exe"); /// assert_eq!(result, Some(("1.0.1".to_string(), "x86_64-pc-windows-msvc".to_string()))); /// ``` -#[allow(dead_code)] pub fn parse_asset_name(name: &str) -> Option<(String, String)> { // Remove .exe extension if present let name = name.strip_suffix(".exe").unwrap_or(name); @@ -90,7 +89,6 @@ pub fn parse_asset_name(name: &str) -> Option<(String, String)> { /// // This will succeed if running on Linux x86_64 /// // let asset = select_asset_for_platform(&assets, &platform).unwrap(); /// ``` -#[allow(dead_code)] pub fn select_asset_for_platform( assets: &[Asset], platform: &Platform, diff --git a/src/update/channel.rs b/src/update/channel.rs index 696cf29..ccb57f8 100644 --- a/src/update/channel.rs +++ b/src/update/channel.rs @@ -41,20 +41,8 @@ impl Channel { } } - /// Check if this channel should include pre-release versions - /// - /// # Examples - /// - /// ``` - /// use zy::update::Channel; - /// - /// assert_eq!(Channel::Stable.should_include_prerelease(), false); - /// assert_eq!(Channel::Alpha.should_include_prerelease(), true); - /// assert_eq!(Channel::Beta.should_include_prerelease(), true); - /// assert_eq!(Channel::ReleaseCandidate.should_include_prerelease(), true); - /// ``` - #[allow(dead_code)] - pub fn should_include_prerelease(&self) -> bool { - !matches!(self, Channel::Stable) - } + // Check if this channel should include pre-release versions - preserved for future use + // pub fn should_include_prerelease(&self) -> bool { + // !matches!(self, Channel::Stable) + // } } diff --git a/src/update/error.rs b/src/update/error.rs index f706202..7ffa323 100644 --- a/src/update/error.rs +++ b/src/update/error.rs @@ -22,7 +22,6 @@ pub enum UpdateError { NoReleaseFound(Channel), /// No asset found for the current platform - #[allow(dead_code)] #[error("No asset found for platform: {0}")] NoAssetFound(String), @@ -31,7 +30,6 @@ pub enum UpdateError { InvalidVersion(String), /// Platform is not supported for updates - #[allow(dead_code)] #[error("Platform not supported: {0}")] UnsupportedPlatform(String), @@ -68,10 +66,8 @@ pub enum UpdateError { #[error("Rollback failed: {0}")] RollbackFailed(String), - /// Permission denied during update - #[error("Permission denied: {0}")] - #[allow(dead_code)] - PermissionDenied(String), + // Permission denied during update - reserved for future permission handling + // PermissionDenied(String), /// I/O error during update #[error("I/O error: {0}")] diff --git a/src/update/github.rs b/src/update/github.rs index 1516d0d..52d6965 100644 --- a/src/update/github.rs +++ b/src/update/github.rs @@ -30,10 +30,8 @@ pub struct Release { /// Parsed semantic version pub version: Version, /// Whether this is a pre-release - #[allow(dead_code)] pub prerelease: bool, /// Release assets (binaries, checksums, etc.) - #[allow(dead_code)] pub assets: Vec, /// Direct download URL for the release page pub download_url: String, diff --git a/src/update/installer.rs b/src/update/installer.rs index 01a9145..cf5cbd5 100644 --- a/src/update/installer.rs +++ b/src/update/installer.rs @@ -45,6 +45,7 @@ pub fn create_backup(current_path: &Path) -> Result { // On Unix, preserve executable permissions #[cfg(unix)] { + // PermissionsExt trait usage not detected by compiler within cfg conditional compilation blocks #[allow(unused_imports)] use std::os::unix::fs::PermissionsExt; diff --git a/src/update/mod.rs b/src/update/mod.rs index bccbda2..8755685 100644 --- a/src/update/mod.rs +++ b/src/update/mod.rs @@ -66,10 +66,9 @@ mod installer; pub use error::UpdateError; pub use version::Version; pub use channel::Channel; -#[allow(unused_imports)] pub use platform::Platform; -#[allow(unused_imports)] -pub use asset::{Asset, parse_asset_name, select_asset_for_platform}; +pub use asset::select_asset_for_platform; +// pub use asset::{Asset, parse_asset_name}; // Preserved for library users pub use github::{GitHubClient, Release}; /// Repository owner on GitHub diff --git a/src/update/platform.rs b/src/update/platform.rs index 58d2833..3d60435 100644 --- a/src/update/platform.rs +++ b/src/update/platform.rs @@ -2,7 +2,6 @@ use super::error::UpdateError; /// Represents the current platform's details -#[allow(dead_code)] #[derive(Debug, Clone, PartialEq, Eq)] pub struct Platform { /// Target triple (e.g., "x86_64-unknown-linux-gnu") @@ -15,7 +14,6 @@ pub struct Platform { pub extension: Option, } -#[allow(dead_code)] impl Platform { /// Detect the current platform at runtime ///