pub(crate) mod client;
pub(crate) mod err;
pub(crate) mod service;
use crate::keystore::fs_utils::{FilesystemAction, FilesystemError, RelKeyPath};
use crate::{KeystoreId, Result};
use fs_mistrust::{CheckedDir, Mistrust};
use std::path::{Path, PathBuf};
use err::CTorKeystoreError;
pub use client::CTorClientKeystore;
pub use service::CTorServiceKeystore;
struct CTorKeystore {
keystore_dir: CheckedDir,
id: KeystoreId,
}
impl CTorKeystore {
fn from_path_and_mistrust(
keystore_dir: impl AsRef<Path>,
mistrust: &Mistrust,
id: KeystoreId,
) -> Result<Self> {
let keystore_dir = mistrust
.verifier()
.check_content()
.secure_dir(&keystore_dir)
.map_err(|e| FilesystemError::FsMistrust {
action: FilesystemAction::Init,
path: keystore_dir.as_ref().into(),
err: e.into(),
})
.map_err(CTorKeystoreError::Filesystem)?;
Ok(Self { keystore_dir, id })
}
fn rel_path(&self, rel_path: PathBuf) -> RelKeyPath {
RelKeyPath::from_parts(&self.keystore_dir, rel_path)
}
}