diff --git a/crates/tor-keymgr/semver.md b/crates/tor-keymgr/semver.md index 85bd805af..b1c29478b 100644 --- a/crates/tor-keymgr/semver.md +++ b/crates/tor-keymgr/semver.md @@ -3,3 +3,6 @@ ADDED: `SshKeypairData` (re-exported from `ssh-key`) REMOVED: `KeyType::to_ssh_format` BREAKING: re-export `ssh_key` rather than just `ssh_key::private::KeypairData` BREAKING: ssh-key is bumped to 0.6.0 (we re-export `ssh_key`) +ADDED: ArtiPathComponent is TryFrom +ADDED: ArtiPathComponent is AsRef +ADDED: ArtiPathComponent is Hash, Eq, PartialEq, Ord, PartialOrd diff --git a/crates/tor-keymgr/src/key_specifier.rs b/crates/tor-keymgr/src/key_specifier.rs index 18bc2bed7..0627470e8 100644 --- a/crates/tor-keymgr/src/key_specifier.rs +++ b/crates/tor-keymgr/src/key_specifier.rs @@ -27,6 +27,7 @@ impl ArtiPath { /// Create a new [`ArtiPath`]. /// /// This function returns an error if `inner` is not a valid `ArtiPath`. + // TODO HSS this function (and validate_str) should have a bespoke error type pub fn new(inner: String) -> Result { if let Some(e) = inner .split(PATH_SEP) @@ -48,6 +49,7 @@ impl ArtiPath { #[derive( Clone, Debug, derive_more::Deref, derive_more::DerefMut, derive_more::Into, derive_more::Display, )] +#[derive(Hash, Eq, PartialEq, Ord, PartialOrd)] pub struct ArtiPathComponent(String); impl ArtiPathComponent { @@ -84,6 +86,19 @@ impl ArtiPathComponent { } } +impl TryFrom for ArtiPathComponent { + type Error = crate::Error; // TODO HSS should be bespoke error type + fn try_from(s: String) -> Result { + Self::new(s) + } +} + +impl AsRef for ArtiPathComponent { + fn as_ref(&self) -> &str { + &self.0 + } +} + /// The path of a key in the C Tor key store. #[derive(Clone, Debug, derive_more::Deref, derive_more::DerefMut)] pub struct CTorPath(String);