@@ -4,7 +4,7 @@ use std::mem::size_of;
44use zerocopy:: little_endian:: { U128 as lu128, U16 as lu16, U32 as lu32, U64 as lu64} ;
55use zerocopy:: { AsBytes , FromBytes , FromZeroes } ;
66
7- use crate :: io:: buf:: { ZeroCopyBoxIoBuf , ZeroCopyBuf } ;
7+ use crate :: io:: buf:: { IoBufMut , ZeroCopyBuf } ;
88use crate :: io:: FileExt ;
99use crate :: { LIBSQL_MAGIC , LIBSQL_PAGE_SIZE , LIBSQL_WAL_VERSION } ;
1010
@@ -82,14 +82,16 @@ impl<F: FileExt> CompactedSegment<F> {
8282 Ok ( Self { file, header } )
8383 }
8484
85- pub ( crate ) async fn read_frame (
85+ pub ( crate ) async fn read_frame < B : IoBufMut + Send + ' static > (
8686 & self ,
87- frame : Box < Frame > ,
87+ buf : B ,
8888 offset : u32 ,
89- ) -> ( Box < Frame > , io:: Result < ( ) > ) {
89+ ) -> ( B , io:: Result < ( ) > ) {
90+ assert_eq ! ( buf. bytes_init( ) , 0 ) ;
91+ assert_eq ! ( buf. bytes_total( ) , size_of:: <Frame >( ) ) ;
9092 let offset = size_of :: < CompactedSegmentDataHeader > ( ) + size_of :: < Frame > ( ) * offset as usize ;
91- let buf = ZeroCopyBoxIoBuf :: new ( frame) ;
9293 let ( buf, ret) = self . file . read_exact_at_async ( buf, offset as u64 ) . await ;
93- ( buf. into_inner ( ) , ret)
94+ ( buf, ret)
95+ }
9496 }
9597}
0 commit comments