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:
parent
a1e1e04fd9
commit
efe5ff6ddd
|
|
@ -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 {
|
impl From<Did> for String {
|
||||||
fn from(other: Did) -> Self {
|
fn from(other: Did) -> Self {
|
||||||
other.encode()
|
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 {
|
impl TryFrom<String> for Did {
|
||||||
type Error = DidError;
|
type Error = DidError;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue