@@ -336,6 +336,20 @@ pub struct DirectDestination<'a, D: 'static> {
336336 store : StoreContextMut < ' a , D > ,
337337}
338338
339+ impl < D : ' static > std:: io:: Write for DirectDestination < ' _ , D > {
340+ fn write ( & mut self , buf : & [ u8 ] ) -> std:: io:: Result < usize > {
341+ let rem = self . remaining ( ) ;
342+ let n = rem. len ( ) . min ( buf. len ( ) ) ;
343+ rem[ ..n] . copy_from_slice ( & buf[ ..n] ) ;
344+ self . mark_written ( n) ;
345+ Ok ( n)
346+ }
347+
348+ fn flush ( & mut self ) -> std:: io:: Result < ( ) > {
349+ Ok ( ( ) )
350+ }
351+ }
352+
339353impl < D : ' static > DirectDestination < ' _ , D > {
340354 /// Provide direct access to the writer's buffer.
341355 pub fn remaining ( & mut self ) -> & mut [ u8 ] {
@@ -836,6 +850,16 @@ pub struct DirectSource<'a, D: 'static> {
836850 store : StoreContextMut < ' a , D > ,
837851}
838852
853+ impl < D : ' static > std:: io:: Read for DirectSource < ' _ , D > {
854+ fn read ( & mut self , buf : & mut [ u8 ] ) -> std:: io:: Result < usize > {
855+ let rem = self . remaining ( ) ;
856+ let n = rem. len ( ) . min ( buf. len ( ) ) ;
857+ buf[ ..n] . copy_from_slice ( & rem[ ..n] ) ;
858+ self . mark_read ( n) ;
859+ Ok ( n)
860+ }
861+ }
862+
839863impl < D : ' static > DirectSource < ' _ , D > {
840864 /// Provide direct access to the writer's buffer.
841865 pub fn remaining ( & mut self ) -> & [ u8 ] {
0 commit comments