/// Read the header of the packed format.
///
/// This does not consume any padding after the header that is used to round up
/// to the nearest page size.
Read the header of the packed format.
This does not consume any padding after the header that is used to round up
to the nearest page size.
Read the header of the packed format . This does not consume any padding after the header that is used to round up to the nearest page size .
fn read_packed_header(input: &mut dyn io::Read) -> io::Result<PackedHeader> {
    let mut buffer = [0_u8; 16];
    input.read_exact(&mut buffer[..])?;
    // TODO: Add a custom error type, and report an error, instead of panicing.
    // Byte [0..12): The signature magic bytes.
    assert_eq!(&buffer[0..12], &SIGNATURE[..]);
    // Byte [12..14): The 16-bit format version.
    assert_eq!(u16_from_le_bytes(slice_2(&buffer[12..14])), 1);
    // Byte [14..16): The 8-bit format type. 0 indicates the packed format.
    // Then an unused padding byte.
    assert_eq!(buffer[14], 0); // Format type.
    assert_eq!(buffer[15], 0); // Padding.
    // Byte [16..56): The 40-byte head.
    let mut buffer = [0_u8; 40];
    input.read_exact(&mut buffer[..])?;
    let head = Head::from_bytes(&buffer);
    let mut buffer = [0_u8; 24];
    input.read_exact(&mut buffer[..])?;
    // Byte [56..64): The page size, in bytes.
    let page_size_in_bytes = u64_from_le_bytes(slice_8(&buffer[0..8]));
    // Byte [64..72): The size of the store, in bytes.
    let store_size_in_bytes = u64_from_le_bytes(slice_8(&buffer[8..16]));
    // Byte [72..80): The size of the heap, in bytes.
    let heap_size_in_bytes = u64_from_le_bytes(slice_8(&buffer[16..24]));
    let result = PackedHeader {
        head,
        page_size_in_bytes,
        store_size_in_bytes,
        heap_size_in_bytes,
    };
    Ok(result)
}
fn read_packed_header ( input : & mut dyn io :: Read ) -> io :: Result < PackedHeader > { let mut buffer = [ 0_u8 ; 16 ] ; input . read_exact ( & mut buffer [ .. ] ) ? ; // TODO: Add a custom error type, and report an error, instead of panicing. // Byte [0..12): The signature magic bytes. assert_eq ! ( buffer [ 0 12 ] SIGNATURE [ ] ) ; // Byte [12..14): The 16-bit format version. assert_eq ! ( u16_from_le_bytes ( slice_2 ( buffer [ 12 14 ] ) ) 1 ) ; // Byte [14..16): The 8-bit format type. 0 indicates the packed format. // Then an unused padding byte. assert_eq ! ( buffer [ 14 ] 0 ) ; // Format type. assert_eq ! ( buffer [ 15 ] 0 ) ; // Padding. // Byte [16..56): The 40-byte head. let mut buffer = [ 0_u8 ; 40 ] ; input . read_exact ( & mut buffer [ .. ] ) ? ; let head = Head :: from_bytes ( & buffer ) ; let mut buffer = [ 0_u8 ; 24 ] ; input . read_exact ( & mut buffer [ .. ] ) ? ; // Byte [56..64): The page size, in bytes. let page_size_in_bytes = u64_from_le_bytes ( slice_8 ( & buffer [ 0 .. 8 ] ) ) ; // Byte [64..72): The size of the store, in bytes. let store_size_in_bytes = u64_from_le_bytes ( slice_8 ( & buffer [ 8 .. 16 ] ) ) ; // Byte [72..80): The size of the heap, in bytes. let heap_size_in_bytes = u64_from_le_bytes ( slice_8 ( & buffer [ 16 .. 24 ] ) ) ; let result = PackedHeader { head , page_size_in_bytes , store_size_in_bytes , heap_size_in_bytes , } ; Ok ( result ) }
Read the header of the packed format.
Read the header of the packed format .
input
&mut dyn io::Read