// file: kb-app-demo-desktop/src/demo_sql_pg_raw.rs // version: 7 //! PostgreSQL canonical acquisition store demo commands. use ts_rs::TS; // rust-rules: derive-import /// PostgreSQL canonical acquisition payload shown by `demo_sql_pg_raw`. #[derive(Clone, Debug, serde::Serialize, TS)] #[serde(rename_all = "camelCase")] #[ts( export, export_to = "../frontend/ts/bindings/kb_app_demo_desktop/demo_sql_pg_raw/DemoSqlPgRawPayload.ts" )] pub(crate) struct DemoSqlPgRawPayload { /// Active profile name. pub(crate) active_profile_name: std::string::String, /// Masked PostgreSQL DSN. pub(crate) masked_dsn: std::string::String, /// Raw table diagnostics. pub(crate) tables: std::vec::Vec, } /// Loads read-only raw table diagnostics from PostgreSQL. pub(crate) async fn load_demo_sql_pg_raw( state: tauri::State<'_, crate::AppState>, ) -> std::result::Result { let profile = state.active_profile().clone(); let store_result = crate::connect_postgres_store(&profile).await; let store = match store_result { std::result::Result::Ok(value) => value, std::result::Result::Err(error) => return std::result::Result::Err(error), }; let tables_result = store.raw_table_diagnostics().await; let tables = match tables_result { std::result::Result::Ok(value) => value, std::result::Result::Err(error) => return std::result::Result::Err(error.to_string()), }; return std::result::Result::Ok(crate::DemoSqlPgRawPayload { active_profile_name: profile.name.clone(), masked_dsn: store.options().masked_dsn(), tables: crate::table_snapshots_from_pg(tables.as_slice()), }); }