use crate::{BoxedKeystore, Result};
use fs_mistrust::Mistrust;
use std::any::Any;
use std::path::Path;
#[derive(derive_builder::Builder)]
#[builder(pattern = "owned")]
#[non_exhaustive]
pub struct KeyMgr {
#[allow(unused)] primary_store: BoxedKeystore,
#[allow(unused)] #[builder(default, setter(custom))]
secondary_stores: Vec<BoxedKeystore>,
}
impl KeyMgrBuilder {
pub fn secondary_stores(&mut self) -> &mut Vec<BoxedKeystore> {
self.secondary_stores.get_or_insert(Default::default())
}
pub fn set_secondary_stores(mut self, list: Vec<BoxedKeystore>) -> Self {
self.secondary_stores = Some(list);
self
}
pub fn opt_secondary_stores(&self) -> &Option<Vec<BoxedKeystore>> {
&self.secondary_stores
}
pub fn opt_secondary_stores_mut(&mut self) -> &mut Option<Vec<BoxedKeystore>> {
&mut self.secondary_stores
}
}
pub trait Keystore: Send + Sync + 'static {
}
#[non_exhaustive]
pub struct ArtiNativeKeystore;
impl ArtiNativeKeystore {
#[allow(clippy::unnecessary_wraps)]
pub fn from_path_and_mistrust(_: impl AsRef<Path>, _: &Mistrust) -> Result<Self> {
Ok(Self)
}
}
impl Keystore for ArtiNativeKeystore {}
#[non_exhaustive]
pub struct ArtiEphemeralKeystore;
impl Keystore for ArtiEphemeralKeystore {}
impl ArtiEphemeralKeystore {
#[allow(clippy::unnecessary_wraps)]
pub fn new(_: String) -> Self {
Self
}
}
impl KeyMgr {
pub fn get<K>(&self, _: &dyn Any) -> Result<Option<K>> {
Ok(None)
}
}
inventory::collect!(&'static dyn crate::KeyPathInfoExtractor);