keyfork-derive-util: impl FromStr for DerivationAlgorithm
This commit is contained in:
parent
f60b77254a
commit
71261e1323
|
@ -26,6 +26,8 @@ thiserror = "1.0.47"
|
||||||
# Optional, not personally audited
|
# Optional, not personally audited
|
||||||
k256 = { version = "0.13.1", default-features = false, features = ["std", "arithmetic"], optional = true }
|
k256 = { version = "0.13.1", default-features = false, features = ["std", "arithmetic"], optional = true }
|
||||||
ed25519-dalek = { version = "2.0.0", optional = true }
|
ed25519-dalek = { version = "2.0.0", optional = true }
|
||||||
|
|
||||||
|
# Workspace
|
||||||
keyfork-mnemonic-util = { version = "0.1.0", path = "../keyfork-mnemonic-util" }
|
keyfork-mnemonic-util = { version = "0.1.0", path = "../keyfork-mnemonic-util" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -48,6 +48,18 @@ impl DerivationAlgorithm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for DerivationAlgorithm {
|
||||||
|
type Err = DerivationError;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
|
Ok(match s {
|
||||||
|
"ed25519" => Self::Ed25519,
|
||||||
|
"secp256k1" => Self::Secp256k1,
|
||||||
|
_ => return Err(DerivationError::Algorithm),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct DerivationRequest {
|
pub struct DerivationRequest {
|
||||||
algorithm: DerivationAlgorithm,
|
algorithm: DerivationAlgorithm,
|
||||||
|
|
Loading…
Reference in New Issue