use std::path::PathBuf;
use std::sync::Arc;
use anyhow::Result;
use super::keys::{ProtectedLocalKeyStore, ProtectedStorage, StoreResult};
use crate::db::Database;
pub trait ClientHost: Send + Sync {
fn ensure_sync_allowed(&self) -> Result<()>;
fn protected_storage(&self) -> StoreResult<Arc<dyn ProtectedStorage>>;
fn blob_dir(&self, database: &Database) -> Result<PathBuf>;
fn attachment_lifecycle_policy(&self) -> crate::attachments::LifecyclePolicy;
fn device_label(&self) -> Option<String>;
}
pub(crate) async fn key_store(
host: &dyn ClientHost,
database: &Database,
) -> Result<ProtectedLocalKeyStore> {
Ok(ProtectedLocalKeyStore::open(database, host.protected_storage()?).await?)
}