radicle: Did improvements

Add conversion from Did to PublicKey through a From implementation.

Add FromStr implementation.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2023-02-16 17:07:14 +01:00
committed by Alexis Sellier
parent a1e1e04fd9
commit efe5ff6ddd
+14
View File
@@ -46,12 +46,26 @@ impl From<crypto::PublicKey> for Did {
}
}
impl From<Did> for crypto::PublicKey {
fn from(Did(key): Did) -> Self {
key
}
}
impl From<Did> for String {
fn from(other: Did) -> Self {
other.encode()
}
}
impl FromStr for Did {
type Err = DidError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::decode(s)
}
}
impl TryFrom<String> for Did {
type Error = DidError;