@@ -36,9 +36,9 @@ impl<W: ::std::io::Write> Writer for W {
36
36
}
37
37
38
38
/// A trait that various rust-lightning types implement allowing them to be written out to a Writer
39
- pub trait Writeable < W : Writer > {
39
+ pub trait Writeable {
40
40
/// Writes self out to the given Writer
41
- fn write ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > ;
41
+ fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > ;
42
42
}
43
43
44
44
/// A trait that various rust-lightning types implement allowing them to be read in from a Read
@@ -52,9 +52,9 @@ pub trait Readable<R>
52
52
53
53
macro_rules! impl_writeable_primitive {
54
54
( $val_type: ty, $meth_write: ident, $len: expr, $meth_read: ident) => {
55
- impl < W : Writer > Writeable < W > for $val_type {
55
+ impl Writeable for $val_type {
56
56
#[ inline]
57
- fn write( & self , writer: & mut W ) -> Result <( ) , :: std:: io:: Error > {
57
+ fn write< W : Writer > ( & self , writer: & mut W ) -> Result <( ) , :: std:: io:: Error > {
58
58
writer. write_all( & $meth_write( * self ) )
59
59
}
60
60
}
@@ -73,9 +73,9 @@ impl_writeable_primitive!(u64, be64_to_array, 8, slice_to_be64);
73
73
impl_writeable_primitive ! ( u32 , be32_to_array, 4 , slice_to_be32) ;
74
74
impl_writeable_primitive ! ( u16 , be16_to_array, 2 , slice_to_be16) ;
75
75
76
- impl < W : Writer > Writeable < W > for u8 {
76
+ impl Writeable for u8 {
77
77
#[ inline]
78
- fn write ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
78
+ fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
79
79
writer. write_all ( & [ * self ] )
80
80
}
81
81
}
@@ -88,9 +88,9 @@ impl<R: Read> Readable<R> for u8 {
88
88
}
89
89
}
90
90
91
- impl < W : Writer > Writeable < W > for bool {
91
+ impl Writeable for bool {
92
92
#[ inline]
93
- fn write ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
93
+ fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
94
94
writer. write_all ( & [ if * self { 1 } else { 0 } ] )
95
95
}
96
96
}
@@ -109,10 +109,10 @@ impl<R: Read> Readable<R> for bool {
109
109
// u8 arrays
110
110
macro_rules! impl_array {
111
111
( $size: expr ) => (
112
- impl < W : Writer > Writeable < W > for [ u8 ; $size]
112
+ impl Writeable for [ u8 ; $size]
113
113
{
114
114
#[ inline]
115
- fn write( & self , w: & mut W ) -> Result <( ) , :: std:: io:: Error > {
115
+ fn write< W : Writer > ( & self , w: & mut W ) -> Result <( ) , :: std:: io:: Error > {
116
116
w. write_all( self )
117
117
}
118
118
}
@@ -136,13 +136,12 @@ impl_array!(64); // for Signature
136
136
impl_array ! ( 1300 ) ; // for OnionPacket.hop_data
137
137
138
138
// HashMap
139
- impl < W , K , V > Writeable < W > for HashMap < K , V >
140
- where W : Writer ,
141
- K : Writeable < W > + Eq + Hash ,
142
- V : Writeable < W >
139
+ impl < K , V > Writeable for HashMap < K , V >
140
+ where K : Writeable + Eq + Hash ,
141
+ V : Writeable
143
142
{
144
143
#[ inline]
145
- fn write ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
144
+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
146
145
( self . len ( ) as u16 ) . write ( w) ?;
147
146
for ( key, value) in self . iter ( ) {
148
147
key. write ( w) ?;
@@ -169,9 +168,9 @@ impl<R, K, V> Readable<R> for HashMap<K, V>
169
168
}
170
169
171
170
// Vectors
172
- impl < W : Writer > Writeable < W > for Vec < u8 > {
171
+ impl Writeable for Vec < u8 > {
173
172
#[ inline]
174
- fn write ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
173
+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
175
174
( self . len ( ) as u16 ) . write ( w) ?;
176
175
w. write_all ( & self )
177
176
}
@@ -187,9 +186,9 @@ impl<R: Read> Readable<R> for Vec<u8> {
187
186
Ok ( ret)
188
187
}
189
188
}
190
- impl < W : Writer > Writeable < W > for Vec < Signature > {
189
+ impl Writeable for Vec < Signature > {
191
190
#[ inline]
192
- fn write ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
191
+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
193
192
( self . len ( ) as u16 ) . write ( w) ?;
194
193
for e in self . iter ( ) {
195
194
e. write ( w) ?;
@@ -214,8 +213,8 @@ impl<R: Read> Readable<R> for Vec<Signature> {
214
213
}
215
214
}
216
215
217
- impl < W : Writer > Writeable < W > for Script {
218
- fn write ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
216
+ impl Writeable for Script {
217
+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
219
218
( self . len ( ) as u16 ) . write ( w) ?;
220
219
w. write_all ( self . as_bytes ( ) )
221
220
}
@@ -230,8 +229,8 @@ impl<R: Read> Readable<R> for Script {
230
229
}
231
230
}
232
231
233
- impl < W : Writer > Writeable < W > for Option < Script > {
234
- fn write ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
232
+ impl Writeable for Option < Script > {
233
+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
235
234
if let & Some ( ref script) = self {
236
235
script. write ( w) ?;
237
236
}
@@ -253,8 +252,8 @@ impl<R: Read> Readable<R> for Option<Script> {
253
252
}
254
253
}
255
254
256
- impl < W : Writer > Writeable < W > for PublicKey {
257
- fn write ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
255
+ impl Writeable for PublicKey {
256
+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
258
257
self . serialize ( ) . write ( w)
259
258
}
260
259
}
@@ -269,8 +268,8 @@ impl<R: Read> Readable<R> for PublicKey {
269
268
}
270
269
}
271
270
272
- impl < W : Writer > Writeable < W > for Sha256dHash {
273
- fn write ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
271
+ impl Writeable for Sha256dHash {
272
+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
274
273
self . as_bytes ( ) . write ( w)
275
274
}
276
275
}
@@ -282,8 +281,8 @@ impl<R: Read> Readable<R> for Sha256dHash {
282
281
}
283
282
}
284
283
285
- impl < W : Writer > Writeable < W > for Signature {
286
- fn write ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
284
+ impl Writeable for Signature {
285
+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
287
286
self . serialize_compact ( & Secp256k1 :: without_caps ( ) ) . write ( w)
288
287
}
289
288
}
0 commit comments