qualia_client_core/wellfair/
snapshot.rs1use super::accessibility_prefs;
4use super::host_state::{NetworkExposure, SyncQueueState, VaultLifecycle, WellfairHostSnapshot};
5use qualia_core_db::key_vault::KeyVault;
6use std::path::Path;
7
8pub fn build_host_snapshot(
10 key_vault: &KeyVault,
11 host_api_ready: bool,
12 owner_label: &str,
13 demo_mode: bool,
14) -> WellfairHostSnapshot {
15 build_host_snapshot_with_storage(key_vault, host_api_ready, owner_label, demo_mode, None)
16}
17
18pub fn build_host_snapshot_with_storage(
19 key_vault: &KeyVault,
20 host_api_ready: bool,
21 owner_label: &str,
22 demo_mode: bool,
23 storage_root: Option<&Path>,
24) -> WellfairHostSnapshot {
25 let vault = if demo_mode {
26 VaultLifecycle::Unlocked
27 } else if key_vault.is_locked() {
28 VaultLifecycle::Locked
29 } else if host_api_ready {
30 VaultLifecycle::Unlocked
31 } else {
32 VaultLifecycle::Unconfigured
33 };
34
35 WellfairHostSnapshot {
36 vault,
37 network: NetworkExposure::LocalOnly,
38 sync_state: SyncQueueState::Idle,
39 demo_mode,
40 owner_label: if owner_label.is_empty() {
41 "Owner vault".to_string()
42 } else {
43 owner_label.to_string()
44 },
45 accessibility: storage_root
46 .map(accessibility_prefs::load)
47 .unwrap_or_default(),
48 pending_jobs: 0,
49 health_record_count: 0,
50 graph_quin_count: 0,
51 last_checkpoint_prefix: None,
52 capabilities_ready: host_api_ready && !key_vault.is_locked(),
53 host_api_version: crate::qapp_install::SUPPORTED_HOST_API_VERSION.to_string(),
54 }
55}