// file: crates/ksp-app-store-desk/src/dto_common.rs // version: 3 //! Common Tauri DTOs shared by the Store Desk shell and Store runtime Overview. use ts_rs::TS; // rust-rules: trait-import /// Safe command error projection that never serializes arbitrary KSP error context or source values. #[derive(Clone, Debug, serde::Serialize, TS)] #[serde(rename_all = "camelCase")] #[ts(export, export_to = "../frontend/ts/bindings/ksp_app_store_desk/dto_common/CommandErrorDto.ts")] pub(crate) struct CommandErrorDto { /// Stable KSP error domain. pub(crate) domain: String, /// Stable KSP error code within the domain. pub(crate) code: String, /// Human-readable error message without arbitrary context fields. pub(crate) message: String, } impl crate::CommandErrorDto { /// Builds a bounded safe projection from a KSP error. #[must_use] pub(crate) fn from_error(error: &ksp_core_lib::Error) -> Self { return Self { domain: error.code().domain().to_owned(), code: error.code().code().to_owned(), message: error.message().to_owned(), }; } } /// Safe shell/Config/Logging snapshot exposed to Store Desk diagnostics. #[derive(Clone, Debug, serde::Serialize, TS)] #[serde(rename_all = "camelCase")] #[ts(export, export_to = "../frontend/ts/bindings/ksp_app_store_desk/dto_common/ShellStatusDto.ts")] pub(crate) struct ShellStatusDto { /// Active configured Logging profile, or `None` while transient fallback Logging is active. pub(crate) active_logging_profile: std::option::Option, /// Cargo application version. pub(crate) application_version: String, /// Number of logical Config resources registered by the current runtime. pub(crate) config_document_count: u32, /// Whether Store Desk had to install its transient in-memory Logging fallback. pub(crate) fallback_logging_active: bool, /// Current implementation phase exposed by the shell. pub(crate) shell_phase: String, /// Safe startup diagnostic that caused fallback Logging, when applicable. pub(crate) startup_diagnostic: std::option::Option, } /// Backend-neutral Store runtime and health projection used by the Overview screen. #[derive(Clone, Debug, serde::Serialize, TS)] #[serde(rename_all = "camelCase")] #[ts(export, export_to = "../frontend/ts/bindings/ksp_app_store_desk/dto_common/StoreRuntimeStatusDto.ts")] pub(crate) struct StoreRuntimeStatusDto { /// Stable selected Store backend kind, when configuration resolution reached that phase. pub(crate) backend_kind: std::option::Option, /// Safe Store startup/health diagnostic, when present. pub(crate) diagnostic: std::option::Option, /// Portable Store health code (`ready`, `not_ready`, `unavailable`, `closed`, or `unknown`). pub(crate) health_state: String, /// Applied migration version rendered as an exact decimal string. pub(crate) migration_version_decimal: std::option::Option, /// Logical Store network, when configuration resolution reached that phase. pub(crate) network: std::option::Option, /// Number of embedded migrations newer than the applied migration version. pub(crate) pending_migration_count: u32, /// Number of currently available pooled backend objects. pub(crate) pool_available: u32, /// Configured pool capacity. pub(crate) pool_capacity: u32, /// Current pool size. pub(crate) pool_size: u32, /// Number of tasks currently waiting for pool capacity. pub(crate) pool_waiting: u32, /// Store profile selected by the Store Desk composite. pub(crate) profile_id: std::option::Option, /// Whether the application currently retains an opened Store facade. pub(crate) store_open: bool, } #[cfg(test)] #[path = "../unit_tests/dto_common.rs"] mod tests;