7
7
//! unable to run on platforms without allocator. We implement a special type to encapsulate
8
8
//! serialized signatures and since it's a bit more complicated it has its own module.
9
9
10
+ use core:: borrow:: Borrow ;
11
+ use core:: convert:: TryFrom ;
10
12
use core:: { fmt, ops} ;
11
13
12
14
pub use into_iter:: IntoIter ;
@@ -41,11 +43,30 @@ impl PartialEq for SerializedSignature {
41
43
fn eq ( & self , other : & SerializedSignature ) -> bool { * * self == * * other }
42
44
}
43
45
46
+ impl PartialEq < [ u8 ] > for SerializedSignature {
47
+ #[ inline]
48
+ fn eq ( & self , other : & [ u8 ] ) -> bool { * * self == * other }
49
+ }
50
+
51
+ impl PartialEq < SerializedSignature > for [ u8 ] {
52
+ #[ inline]
53
+ fn eq ( & self , other : & SerializedSignature ) -> bool { * self == * * other }
54
+ }
55
+
56
+ impl core:: hash:: Hash for SerializedSignature {
57
+ fn hash < H : core:: hash:: Hasher > ( & self , state : & mut H ) { ( * * self ) . hash ( state) }
58
+ }
59
+
44
60
impl AsRef < [ u8 ] > for SerializedSignature {
45
61
#[ inline]
46
62
fn as_ref ( & self ) -> & [ u8 ] { self }
47
63
}
48
64
65
+ impl Borrow < [ u8 ] > for SerializedSignature {
66
+ #[ inline]
67
+ fn borrow ( & self ) -> & [ u8 ] { self }
68
+ }
69
+
49
70
impl ops:: Deref for SerializedSignature {
50
71
type Target = [ u8 ] ;
51
72
@@ -71,6 +92,28 @@ impl<'a> IntoIterator for &'a SerializedSignature {
71
92
fn into_iter ( self ) -> Self :: IntoIter { self . iter ( ) }
72
93
}
73
94
95
+ impl From < Signature > for SerializedSignature {
96
+ fn from ( value : Signature ) -> Self { Self :: from_signature ( & value) }
97
+ }
98
+
99
+ impl < ' a > From < & ' a Signature > for SerializedSignature {
100
+ fn from ( value : & ' a Signature ) -> Self { Self :: from_signature ( value) }
101
+ }
102
+
103
+ impl TryFrom < SerializedSignature > for Signature {
104
+ type Error = Error ;
105
+
106
+ fn try_from ( value : SerializedSignature ) -> Result < Self , Self :: Error > { value. to_signature ( ) }
107
+ }
108
+
109
+ impl < ' a > TryFrom < & ' a SerializedSignature > for Signature {
110
+ type Error = Error ;
111
+
112
+ fn try_from ( value : & ' a SerializedSignature ) -> Result < Self , Self :: Error > {
113
+ value. to_signature ( )
114
+ }
115
+ }
116
+
74
117
impl SerializedSignature {
75
118
/// Creates `SerializedSignature` from data and length.
76
119
///
@@ -84,6 +127,7 @@ impl SerializedSignature {
84
127
}
85
128
86
129
/// Get the capacity of the underlying data buffer.
130
+ #[ deprecated = "This always returns 72" ]
87
131
#[ inline]
88
132
pub fn capacity ( & self ) -> usize { self . data . len ( ) }
89
133
@@ -106,6 +150,7 @@ impl SerializedSignature {
106
150
pub fn from_signature ( sig : & Signature ) -> SerializedSignature { sig. serialize_der ( ) }
107
151
108
152
/// Check if the space is zero.
153
+ #[ deprecated = "This always returns false" ]
109
154
#[ inline]
110
155
pub fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
111
156
}
0 commit comments