pub(crate) mod arti;
#[cfg(feature = "ctor-keystore")]
pub(crate) mod ctor;
pub(crate) mod fs_utils;
#[cfg(feature = "ephemeral-keystore")]
pub(crate) mod ephemeral;
use tor_key_forge::{EncodableItem, ErasedKey, KeystoreItemType};
use crate::raw::RawEntryId;
use crate::{KeySpecifier, KeystoreEntry, KeystoreId, Result, UnrecognizedEntryError};
pub type KeystoreEntryResult<T> = std::result::Result<T, UnrecognizedEntryError>;
impl<'a> From<UnrecognizedEntryError> for KeystoreEntryResult<KeystoreEntry<'a>> {
fn from(val: UnrecognizedEntryError) -> Self {
Err(val)
}
}
pub trait Keystore: Send + Sync + 'static {
fn id(&self) -> &KeystoreId;
fn contains(&self, key_spec: &dyn KeySpecifier, item_type: &KeystoreItemType) -> Result<bool>;
fn get(
&self,
key_spec: &dyn KeySpecifier,
item_type: &KeystoreItemType,
) -> Result<Option<ErasedKey>>;
#[cfg(feature = "onion-service-cli-extra")]
fn raw_entry_id(&self, raw_id: &str) -> Result<RawEntryId>;
fn insert(&self, key: &dyn EncodableItem, key_spec: &dyn KeySpecifier) -> Result<()>;
fn remove(
&self,
key_spec: &dyn KeySpecifier,
item_type: &KeystoreItemType,
) -> Result<Option<()>>;
#[cfg(feature = "onion-service-cli-extra")]
fn remove_unchecked(&self, entry_id: &RawEntryId) -> Result<()>;
fn list(&self) -> Result<Vec<KeystoreEntryResult<KeystoreEntry>>>;
}