-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathsigner.rs
36 lines (33 loc) Β· 897 Bytes
/
signer.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use super::*;
#[derive(Debug, PartialEq, Clone, DeserializeFromStr)]
pub(crate) enum Signer {
Address(Address<NetworkUnchecked>),
Inscription(InscriptionId),
Output(OutPoint),
}
impl FromStr for Signer {
type Err = SnafuError;
fn from_str(input: &str) -> Result<Self, Self::Err> {
if re::ADDRESS.is_match(input) {
Ok(Signer::Address(
input.parse().snafu_context(error::AddressParse { input })?,
))
} else if re::OUTPOINT.is_match(input) {
Ok(Signer::Output(
input
.parse()
.snafu_context(error::OutPointParse { input })?,
))
} else if re::INSCRIPTION_ID.is_match(input) {
Ok(Signer::Inscription(
input
.parse()
.snafu_context(error::InscriptionIdParse { input })?,
))
} else {
Err(SnafuError::SignerParse {
input: input.to_string(),
})
}
}
}