Files
khadhroony-solana-project/crates/ksp-app-wallet-desk/src/dto_common.rs
2026-08-21 10:50:36 +02:00

81 lines
3.8 KiB
Rust

// file: crates/ksp-app-wallet-desk/src/dto_common.rs
// version: 4
//! Common Tauri DTOs shared by Wallet Desk shell commands.
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_wallet_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 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 application/runtime snapshot exposed to the Wallet Desk shell.
#[derive(Clone, Debug, serde::Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_wallet_desk/dto_common/RuntimeStatusDto.ts")]
pub(crate) struct RuntimeStatusDto {
/// Cargo application version.
pub(crate) application_version: String,
/// Wallet Desk composite profile selected during bootstrap.
pub(crate) active_composite_profile: String,
/// Active configured Logging profile, or `None` while the transient fallback runtime is active.
pub(crate) active_logging_profile: std::option::Option<String>,
/// Standard Transport profile selected by the active composite.
pub(crate) active_transport_profile: String,
/// Standard Wallet profile selected by the active composite.
pub(crate) active_wallet_profile: String,
/// Number of logical Config resources registered by the current application runtime.
pub(crate) config_document_count: u32,
/// Effective Wallet directory after applying the optional profile subdirectory.
pub(crate) effective_wallets_directory: String,
/// Whether bootstrap created any missing component of the effective Wallet profile directory.
pub(crate) effective_wallets_directory_created_on_startup: bool,
/// Whether Wallet Desk had to install its transient in-memory Logging fallback.
pub(crate) fallback_logging_active: bool,
/// Whether bootstrap created the configured global Wallet root.
pub(crate) root_wallets_directory_created_on_startup: bool,
/// Current implementation phase exposed by the Wallet Desk shell.
pub(crate) shell_phase: String,
/// Safe startup diagnostic that caused fallback Logging, when applicable.
pub(crate) startup_diagnostic: std::option::Option<CommandErrorDto>,
/// Number of Transport endpoints currently eligible for normal routing.
pub(crate) transport_available_endpoint_count: u32,
/// Safe cluster labels configured by the selected Transport profile.
pub(crate) transport_clusters: std::vec::Vec<String>,
/// Total number of configured Transport endpoints.
pub(crate) transport_endpoint_count: u32,
/// Safe provider labels configured by the selected Transport profile.
pub(crate) transport_providers: std::vec::Vec<String>,
/// Logical Transport role used by Wallet Desk balance reads.
pub(crate) transport_role: String,
/// Resolved global Wallet root configured by `cfg.std.wallet`.
pub(crate) wallets_directory: String,
/// Optional profile-relative Wallet subdirectory selected by the active composite.
pub(crate) wallets_subdirectory: std::option::Option<String>,
}
#[cfg(test)]
#[path = "../unit_tests/dto_common.rs"]
mod tests;