pub fn try_read_record_data<R>(reader: &mut R, len: usize, check_integrity: bool) -> Result<Vec<u8>>
where
    R: Read,
{
    let buf = {
        let mut buf = vec![0u8; len];
        reader.read_exact(&mut buf)?;
        buf
    };
    let expect_cksum = {
        let mut buf = [0; std::mem::size_of::<u32>()];
        reader.read_exact(&mut buf)?;
        u32::from_le_bytes(buf)
    };

    if check_integrity {
        crate::utils::verify_checksum(&buf, expect_cksum)?;
    }
    Ok(buf)
}
/// Read the record raw bytes with given length from a generic reader.
///
/// It is internally called by [try_read_record].
Read the record raw bytes with given length from a generic reader.
It is internally called by [try_read_record].
Read the record raw bytes with given length from a generic reader . It is internally called by [ try_read_record ] .
pub fn try_read_record_data<R>(reader: &mut R, len: usize, check_integrity: bool) -> Result<Vec<u8>>
where
    R: Read,
{
    let buf = {
        let mut buf = vec![0u8; len];
        reader.read_exact(&mut buf)?;
        buf
    };
    let expect_cksum = {
        let mut buf = [0; std::mem::size_of::<u32>()];
        reader.read_exact(&mut buf)?;
        u32::from_le_bytes(buf)
    };
    if check_integrity {
        crate::utils::verify_checksum(&buf, expect_cksum)?;
    }
    Ok(buf)
}
pub fn try_read_record_data < R > ( reader : & mut R , len : usize , check_integrity : bool ) -> Result < Vec < u8 > > where R : Read , { let buf = { let mut buf = vec ! [ 0u8 len ] ; reader . read_exact ( & mut buf ) ? ; buf } ; let expect_cksum = { let mut buf = [ 0 ; std :: mem :: size_of :: < u32 > ( ) ] ; reader . read_exact ( & mut buf ) ? ; u32 :: from_le_bytes ( buf ) } ; if check_integrity { crate :: utils :: verify_checksum ( & buf , expect_cksum ) ? ; } Ok ( buf ) }
Read the record raw bytes with given length from a generic reader.
Read the record raw bytes with given length from a generic reader .
reader
&mut R
len
usize
check_integrity
bool
reader
&mut R
len
usize
check_integrity
bool