use std::path::PathBuf;
use amplify::Getters;
use tor_basic_utils::PathExt;
use tor_key_forge::KeystoreItemType;
use crate::{ArtiPath, KeystoreId, UnrecognizedEntry};
#[cfg_attr(feature = "onion-service-cli-extra", visibility::make(pub))]
#[derive(Debug, Clone, PartialEq, derive_more::From, Getters)]
pub(crate) struct RawKeystoreEntry {
#[getter(skip)]
raw_id: RawEntryId,
#[getter(skip)]
keystore_id: KeystoreId,
}
impl RawKeystoreEntry {
#[cfg(feature = "onion-service-cli-extra")]
pub fn raw_id(&self) -> &RawEntryId {
&self.raw_id
}
#[cfg(feature = "onion-service-cli-extra")]
pub fn keystore_id(&self) -> &KeystoreId {
&self.keystore_id
}
}
impl From<&UnrecognizedEntry> for RawKeystoreEntry {
fn from(value: &UnrecognizedEntry) -> Self {
value.clone().into()
}
}
impl RawKeystoreEntry {
pub(crate) fn new(raw_id: RawEntryId, keystore_id: KeystoreId) -> Self {
Self {
raw_id,
keystore_id,
}
}
}
#[cfg_attr(feature = "onion-service-cli-extra", visibility::make(pub))]
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, derive_more::Display)]
pub(crate) enum RawEntryId {
#[display("{}", _0.display_lossy())]
Path(PathBuf),
#[display("{} {:?}", _0.0, _0.1)]
Ephemeral((ArtiPath, KeystoreItemType)),
}