aven_core/sync/client/
host.rs1use std::path::PathBuf;
3use std::sync::Arc;
4
5use anyhow::Result;
6
7use super::keys::{ProtectedLocalKeyStore, ProtectedStorage, StoreResult};
8use crate::db::Database;
9
10pub trait ClientHost: Send + Sync {
11 fn ensure_sync_allowed(&self) -> Result<()>;
13
14 fn protected_storage(&self) -> StoreResult<Arc<dyn ProtectedStorage>>;
17
18 fn blob_dir(&self, database: &Database) -> Result<PathBuf>;
20
21 fn attachment_lifecycle_policy(&self) -> crate::attachments::LifecyclePolicy;
23
24 fn device_label(&self) -> Option<String>;
28}
29
30pub(crate) async fn key_store(
31 host: &dyn ClientHost,
32 database: &Database,
33) -> Result<ProtectedLocalKeyStore> {
34 Ok(ProtectedLocalKeyStore::open(database, host.protected_storage()?).await?)
35}