miniscript/
blanket_traits.rs1use core::str::FromStr;
16use core::{fmt, hash};
17
18use crate::MiniscriptKey;
19
20pub trait StaticDebugAndDisplay: fmt::Debug + fmt::Display + Send + Sync + 'static {}
23
24impl<T: fmt::Debug + fmt::Display + Send + Sync + 'static> StaticDebugAndDisplay for T {}
25
26pub trait FromStrKey:
29 MiniscriptKey<
30 Sha256 = Self::_Sha256,
31 Hash256 = Self::_Hash256,
32 Ripemd160 = Self::_Ripemd160,
33 Hash160 = Self::_Hash160,
34 > + FromStr<Err = Self::_FromStrErr>
35{
36 type _Sha256: FromStr<Err = Self::_Sha256FromStrErr>
38 + Clone
39 + Eq
40 + Ord
41 + fmt::Display
42 + fmt::Debug
43 + hash::Hash;
44 type _Sha256FromStrErr: StaticDebugAndDisplay;
46 type _Hash256: FromStr<Err = Self::_Hash256FromStrErr>
48 + Clone
49 + Eq
50 + Ord
51 + fmt::Display
52 + fmt::Debug
53 + hash::Hash;
54 type _Hash256FromStrErr: StaticDebugAndDisplay;
56 type _Ripemd160: FromStr<Err = Self::_Ripemd160FromStrErr>
58 + Clone
59 + Eq
60 + Ord
61 + fmt::Display
62 + fmt::Debug
63 + hash::Hash;
64 type _Ripemd160FromStrErr: StaticDebugAndDisplay;
66 type _Hash160: FromStr<Err = Self::_Hash160FromStrErr>
68 + Clone
69 + Eq
70 + Ord
71 + fmt::Display
72 + fmt::Debug
73 + hash::Hash;
74 type _Hash160FromStrErr: StaticDebugAndDisplay;
76 type _FromStrErr: StaticDebugAndDisplay;
78}
79
80impl<T> FromStrKey for T
81where
82 Self: MiniscriptKey + FromStr,
83 <Self as MiniscriptKey>::Sha256: FromStr,
84 Self::Hash256: FromStr,
85 Self::Ripemd160: FromStr,
86 Self::Hash160: FromStr,
87 <Self as FromStr>::Err: StaticDebugAndDisplay,
88 <<Self as MiniscriptKey>::Sha256 as FromStr>::Err: StaticDebugAndDisplay,
89 <Self::Hash256 as FromStr>::Err: StaticDebugAndDisplay,
90 <Self::Ripemd160 as FromStr>::Err: StaticDebugAndDisplay,
91 <Self::Hash160 as FromStr>::Err: StaticDebugAndDisplay,
92{
93 type _Sha256 = <T as MiniscriptKey>::Sha256;
94 type _Sha256FromStrErr = <<T as MiniscriptKey>::Sha256 as FromStr>::Err;
95 type _Hash256 = <T as MiniscriptKey>::Hash256;
96 type _Hash256FromStrErr = <<T as MiniscriptKey>::Hash256 as FromStr>::Err;
97 type _Ripemd160 = <T as MiniscriptKey>::Ripemd160;
98 type _Ripemd160FromStrErr = <<T as MiniscriptKey>::Ripemd160 as FromStr>::Err;
99 type _Hash160 = <T as MiniscriptKey>::Hash160;
100 type _Hash160FromStrErr = <<T as MiniscriptKey>::Hash160 as FromStr>::Err;
101 type _FromStrErr = <T as FromStr>::Err;
102}