@@ -21,7 +21,6 @@ impl<'a> BinarySerializer<'a> {
21
21
}
22
22
23
23
impl < ' a > Serializer for BinarySerializer < ' a > {
24
- type Error = Error ;
25
24
26
25
fn serialize_bool ( & mut self , val : bool ) -> Result < ( ) , Error > {
27
26
if val {
@@ -91,9 +90,7 @@ impl<'a> Serializer for BinarySerializer<'a> {
91
90
}
92
91
93
92
impl < ' a > ThriftSerializer for BinarySerializer < ' a > {
94
- type TError = Error ;
95
-
96
- fn write_message_begin ( & mut self , name : & str , message_type : ThriftMessageType ) -> Result < ( ) , Self :: TError > {
93
+ fn write_message_begin ( & mut self , name : & str , message_type : ThriftMessageType ) -> Result < ( ) , Error > {
97
94
let version = THRIFT_VERSION_1 | message_type as i32 ;
98
95
99
96
try!( self . serialize_i32 ( version) ) ;
@@ -103,30 +100,30 @@ impl<'a> ThriftSerializer for BinarySerializer<'a> {
103
100
Ok ( ( ) )
104
101
}
105
102
106
- fn write_struct_begin ( & mut self , name : & str ) -> Result < ( ) , Self :: TError > {
103
+ fn write_struct_begin ( & mut self , name : & str ) -> Result < ( ) , Error > {
107
104
Ok ( ( ) )
108
105
}
109
106
110
- fn write_struct_end ( & mut self ) -> Result < ( ) , Self :: TError > {
107
+ fn write_struct_end ( & mut self ) -> Result < ( ) , Error > {
111
108
Ok ( ( ) )
112
109
}
113
110
114
- fn write_field_begin ( & mut self , name : & str , ty : ThriftType , id : i16 ) -> Result < ( ) , Self :: TError > {
111
+ fn write_field_begin ( & mut self , name : & str , ty : ThriftType , id : i16 ) -> Result < ( ) , Error > {
115
112
try!( self . serialize_i8 ( ty as i8 ) ) ;
116
113
try!( self . serialize_i16 ( id) ) ;
117
114
Ok ( ( ) )
118
115
}
119
116
120
- fn write_field_end ( & mut self ) -> Result < ( ) , Self :: TError > {
117
+ fn write_field_end ( & mut self ) -> Result < ( ) , Error > {
121
118
Ok ( ( ) )
122
119
}
123
120
124
- fn write_field_stop ( & mut self ) -> Result < ( ) , Self :: TError > {
121
+ fn write_field_stop ( & mut self ) -> Result < ( ) , Error > {
125
122
try!( self . serialize_i8 ( ThriftType :: Stop as i8 ) ) ;
126
123
Ok ( ( ) )
127
124
}
128
125
129
- fn write_message_end ( & mut self ) -> Result < ( ) , Self :: TError > {
126
+ fn write_message_end ( & mut self ) -> Result < ( ) , Error > {
130
127
Ok ( ( ) )
131
128
}
132
129
}
@@ -135,9 +132,15 @@ pub struct BinaryDeserializer<R: Read + ReadBytesExt> {
135
132
rd : R
136
133
}
137
134
138
- impl < R : Read + ReadBytesExt > Deserializer for BinaryDeserializer < R > {
139
- type Error = Error ;
135
+ impl < R : Read + ReadBytesExt > BinaryDeserializer < R > {
136
+ pub fn new ( rd : R ) -> BinaryDeserializer < R > {
137
+ BinaryDeserializer {
138
+ rd : rd
139
+ }
140
+ }
141
+ }
140
142
143
+ impl < R : Read + ReadBytesExt > Deserializer for BinaryDeserializer < R > {
141
144
fn deserialize_bool ( & mut self ) -> Result < bool , Error > {
142
145
Ok ( try!( self . rd . read_i8 ( ) ) != 0 )
143
146
}
@@ -199,9 +202,7 @@ impl<R: Read + ReadBytesExt> Deserializer for BinaryDeserializer<R> {
199
202
}
200
203
201
204
impl < R : Read + ReadBytesExt > ThriftDeserializer for BinaryDeserializer < R > {
202
- type TError = Error ;
203
-
204
- fn read_message_begin ( & mut self ) -> Result < ThriftMessage , Self :: TError > {
205
+ fn read_message_begin ( & mut self ) -> Result < ThriftMessage , Error > {
205
206
let size: i32 = try!( self . deserialize_i32 ( ) ) ;
206
207
207
208
if size < 0 {
@@ -220,19 +221,19 @@ impl<R: Read + ReadBytesExt> ThriftDeserializer for BinaryDeserializer<R> {
220
221
}
221
222
}
222
223
223
- fn read_message_end ( & mut self ) -> Result < ( ) , Self :: TError > {
224
+ fn read_message_end ( & mut self ) -> Result < ( ) , Error > {
224
225
Ok ( ( ) )
225
226
}
226
227
227
- fn read_struct_begin ( & mut self ) -> Result < String , Self :: TError > {
228
+ fn read_struct_begin ( & mut self ) -> Result < String , Error > {
228
229
Ok ( "" . to_string ( ) )
229
230
}
230
231
231
- fn read_struct_end ( & mut self ) -> Result < ( ) , Self :: TError > {
232
+ fn read_struct_end ( & mut self ) -> Result < ( ) , Error > {
232
233
Ok ( ( ) )
233
234
}
234
235
235
- fn read_field_begin ( & mut self ) -> Result < ThriftField , Self :: TError > {
236
+ fn read_field_begin ( & mut self ) -> Result < ThriftField , Error > {
236
237
let mut field = ThriftField {
237
238
name : None ,
238
239
ty : ThriftType :: from ( try!( self . deserialize_i8 ( ) ) ) ,
@@ -247,7 +248,7 @@ impl<R: Read + ReadBytesExt> ThriftDeserializer for BinaryDeserializer<R> {
247
248
}
248
249
}
249
250
250
- fn read_field_end ( & mut self ) -> Result < ( ) , Self :: TError > {
251
+ fn read_field_end ( & mut self ) -> Result < ( ) , Error > {
251
252
Ok ( ( ) )
252
253
}
253
254
}
0 commit comments