File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ use postgres::types::Oid;
4242use std:: cmp;
4343use std:: fmt;
4444use std:: i32;
45- use std:: io;
45+ use std:: io:: { self , Write } ;
4646
4747/// An extension trait adding functionality to create and delete large objects.
4848pub trait LargeObjectExt {
@@ -189,16 +189,12 @@ impl<'a> LargeObject<'a> {
189189}
190190
191191impl < ' a > io:: Read for LargeObject < ' a > {
192- fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
192+ fn read ( & mut self , mut buf : & mut [ u8 ] ) -> io:: Result < usize > {
193193 let stmt = try_io ! ( self . trans. prepare_cached( "SELECT pg_catalog.loread($1, $2)" ) ) ;
194194 let cap = cmp:: min ( buf. len ( ) , i32:: MAX as usize ) as i32 ;
195195 let row = try_io ! ( stmt. query( & [ & self . fd, & cap] ) ) . into_iter ( ) . next ( ) . unwrap ( ) ;
196196 let out = row. get_bytes ( 0 ) . unwrap ( ) ;
197-
198- for ( i, o) in out. iter ( ) . zip ( buf. iter_mut ( ) ) {
199- * o = * i;
200- }
201- Ok ( out. len ( ) )
197+ buf. write ( out)
202198 }
203199}
204200
You can’t perform that action at this time.
0 commit comments