miniscript/
blanket_traits.rs1use core::str::FromStr;
16use core::{fmt, hash};
17
18use crate::MiniscriptKey;
19
20pub trait FromStrKey:
23 MiniscriptKey<
24 Sha256 = Self::_Sha256,
25 Hash256 = Self::_Hash256,
26 Ripemd160 = Self::_Ripemd160,
27 Hash160 = Self::_Hash160,
28 > + FromStr<Err = Self::_FromStrErr>
29{
30 type _Sha256: FromStr<Err = Self::_Sha256FromStrErr>
32 + Clone
33 + Eq
34 + Ord
35 + fmt::Display
36 + fmt::Debug
37 + hash::Hash;
38 type _Sha256FromStrErr: fmt::Debug + fmt::Display;
40 type _Hash256: FromStr<Err = Self::_Hash256FromStrErr>
42 + Clone
43 + Eq
44 + Ord
45 + fmt::Display
46 + fmt::Debug
47 + hash::Hash;
48 type _Hash256FromStrErr: fmt::Debug + fmt::Display;
50 type _Ripemd160: FromStr<Err = Self::_Ripemd160FromStrErr>
52 + Clone
53 + Eq
54 + Ord
55 + fmt::Display
56 + fmt::Debug
57 + hash::Hash;
58 type _Ripemd160FromStrErr: fmt::Debug + fmt::Display;
60 type _Hash160: FromStr<Err = Self::_Hash160FromStrErr>
62 + Clone
63 + Eq
64 + Ord
65 + fmt::Display
66 + fmt::Debug
67 + hash::Hash;
68 type _Hash160FromStrErr: fmt::Debug + fmt::Display;
70 type _FromStrErr: fmt::Debug + fmt::Display;
72}
73
74impl<T> FromStrKey for T
75where
76 Self: MiniscriptKey + FromStr,
77 <Self as MiniscriptKey>::Sha256: FromStr,
78 Self::Hash256: FromStr,
79 Self::Ripemd160: FromStr,
80 Self::Hash160: FromStr,
81 <Self as FromStr>::Err: fmt::Debug + fmt::Display,
82 <<Self as MiniscriptKey>::Sha256 as FromStr>::Err: fmt::Debug + fmt::Display,
83 <Self::Hash256 as FromStr>::Err: fmt::Debug + fmt::Display,
84 <Self::Ripemd160 as FromStr>::Err: fmt::Debug + fmt::Display,
85 <Self::Hash160 as FromStr>::Err: fmt::Debug + fmt::Display,
86{
87 type _Sha256 = <T as MiniscriptKey>::Sha256;
88 type _Sha256FromStrErr = <<T as MiniscriptKey>::Sha256 as FromStr>::Err;
89 type _Hash256 = <T as MiniscriptKey>::Hash256;
90 type _Hash256FromStrErr = <<T as MiniscriptKey>::Hash256 as FromStr>::Err;
91 type _Ripemd160 = <T as MiniscriptKey>::Ripemd160;
92 type _Ripemd160FromStrErr = <<T as MiniscriptKey>::Ripemd160 as FromStr>::Err;
93 type _Hash160 = <T as MiniscriptKey>::Hash160;
94 type _Hash160FromStrErr = <<T as MiniscriptKey>::Hash160 as FromStr>::Err;
95 type _FromStrErr = <T as FromStr>::Err;
96}