77//! unable to run on platforms without allocator. We implement a special type to encapsulate
88//! serialized signatures and since it's a bit more complicated it has its own module.
99
10+ use core:: borrow:: Borrow ;
11+ use core:: convert:: TryFrom ;
1012use core:: { fmt, ops} ;
1113
1214pub use into_iter:: IntoIter ;
@@ -41,11 +43,30 @@ impl PartialEq for SerializedSignature {
4143 fn eq ( & self , other : & SerializedSignature ) -> bool { * * self == * * other }
4244}
4345
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+
4460impl AsRef < [ u8 ] > for SerializedSignature {
4561 #[ inline]
4662 fn as_ref ( & self ) -> & [ u8 ] { self }
4763}
4864
65+ impl Borrow < [ u8 ] > for SerializedSignature {
66+ #[ inline]
67+ fn borrow ( & self ) -> & [ u8 ] { self }
68+ }
69+
4970impl ops:: Deref for SerializedSignature {
5071 type Target = [ u8 ] ;
5172
@@ -71,6 +92,28 @@ impl<'a> IntoIterator for &'a SerializedSignature {
7192 fn into_iter ( self ) -> Self :: IntoIter { self . iter ( ) }
7293}
7394
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+
74117impl SerializedSignature {
75118 /// Creates `SerializedSignature` from data and length.
76119 ///
@@ -84,6 +127,7 @@ impl SerializedSignature {
84127 }
85128
86129 /// Get the capacity of the underlying data buffer.
130+ #[ deprecated = "This always returns 72" ]
87131 #[ inline]
88132 pub fn capacity ( & self ) -> usize { self . data . len ( ) }
89133
@@ -106,6 +150,7 @@ impl SerializedSignature {
106150 pub fn from_signature ( sig : & Signature ) -> SerializedSignature { sig. serialize_der ( ) }
107151
108152 /// Check if the space is zero.
153+ #[ deprecated = "This always returns false" ]
109154 #[ inline]
110155 pub fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
111156}
0 commit comments