tor-keymgr: Improve ArtiPathComponent a bit
And add a TODO about the error type.
This commit is contained in:
parent
36e424f9e5
commit
9df82bb948
|
@ -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<String>
|
||||
ADDED: ArtiPathComponent is AsRef<str>
|
||||
ADDED: ArtiPathComponent is Hash, Eq, PartialEq, Ord, PartialOrd
|
||||
|
|
|
@ -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<Self> {
|
||||
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<String> for ArtiPathComponent {
|
||||
type Error = crate::Error; // TODO HSS should be bespoke error type
|
||||
fn try_from(s: String) -> Result<ArtiPathComponent> {
|
||||
Self::new(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> 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);
|
||||
|
|
Loading…
Reference in New Issue