@@ -183,6 +183,26 @@ impl<R: AsyncBufRead + Unpin> Reader<TokioAdapter<R>> {
183
183
}
184
184
}
185
185
186
+ /// Converts any synchronous reader to asynchronous one if inner reader supports that
187
+ impl < R : AsyncBufRead + Unpin > From < Reader < R > > for Reader < TokioAdapter < R > > {
188
+ fn from ( reader : Reader < R > ) -> Self {
189
+ Self {
190
+ reader : TokioAdapter ( reader. reader ) ,
191
+ parser : reader. parser ,
192
+ }
193
+ }
194
+ }
195
+
196
+ /// Converts any asynchronous reader to a synchronous one if inner reader supports that
197
+ impl < R > From < Reader < TokioAdapter < R > > > for Reader < R > {
198
+ fn from ( reader : Reader < TokioAdapter < R > > ) -> Self {
199
+ Self {
200
+ reader : reader. reader . 0 ,
201
+ parser : reader. parser ,
202
+ }
203
+ }
204
+ }
205
+
186
206
////////////////////////////////////////////////////////////////////////////////////////////////////
187
207
188
208
impl < R : AsyncBufRead + Unpin > NsReader < TokioAdapter < R > > {
@@ -396,6 +416,30 @@ impl<R: AsyncBufRead + Unpin> NsReader<TokioAdapter<R>> {
396
416
}
397
417
}
398
418
419
+ /// Converts any synchronous reader to asynchronous one if inner reader supports that
420
+ impl < R : AsyncBufRead + Unpin > From < NsReader < R > > for NsReader < TokioAdapter < R > > {
421
+ fn from ( reader : NsReader < R > ) -> Self {
422
+ Self {
423
+ reader : reader. reader . into ( ) ,
424
+ buffer : reader. buffer ,
425
+ ns_resolver : reader. ns_resolver ,
426
+ pending_pop : reader. pending_pop ,
427
+ }
428
+ }
429
+ }
430
+
431
+ /// Converts any asynchronous reader to a synchronous one if inner reader supports that
432
+ impl < R > From < NsReader < TokioAdapter < R > > > for NsReader < R > {
433
+ fn from ( reader : NsReader < TokioAdapter < R > > ) -> Self {
434
+ Self {
435
+ reader : reader. reader . into ( ) ,
436
+ buffer : reader. buffer ,
437
+ ns_resolver : reader. ns_resolver ,
438
+ pending_pop : reader. pending_pop ,
439
+ }
440
+ }
441
+ }
442
+
399
443
#[ cfg( test) ]
400
444
mod test {
401
445
use super :: TokioAdapter ;
0 commit comments