pub fn try_write_record<W>(writer: &mut W, bytes: Vec<u8>) -> Result<()>
where
    W: Write,
{
    // write data size
    {
        let len = bytes.len();
        let len_buf = len.to_le_bytes();
        let cksum = crate::utils::checksum(&len_buf);
        let cksum_buf = cksum.to_le_bytes();

        writer.write_all(&len_buf)?;
        writer.write_all(&cksum_buf)?;
    }

    // write data
    {
        let cksum = crate::utils::checksum(&bytes);
        let cksum_buf = cksum.to_le_bytes();

        writer.write_all(bytes.as_slice())?;
        writer.write_all(&cksum_buf)?;
    }
    Ok(())
}
/// Write the raw record bytes to a generic writer.
Write the raw record bytes to a generic writer.
Write the raw record bytes to a generic writer .
pub fn try_write_record<W>(writer: &mut W, bytes: Vec<u8>) -> Result<()>
where
    W: Write,
{
    // write data size
    {
        let len = bytes.len();
        let len_buf = len.to_le_bytes();
        let cksum = crate::utils::checksum(&len_buf);
        let cksum_buf = cksum.to_le_bytes();
        writer.write_all(&len_buf)?;
        writer.write_all(&cksum_buf)?;
    }
    // write data
    {
        let cksum = crate::utils::checksum(&bytes);
        let cksum_buf = cksum.to_le_bytes();
        writer.write_all(bytes.as_slice())?;
        writer.write_all(&cksum_buf)?;
    }
    Ok(())
}
pub fn try_write_record < W > ( writer : & mut W , bytes : Vec < u8 > ) -> Result < ( ) > where W : Write , { // write data size { let len = bytes . len ( ) ; let len_buf = len . to_le_bytes ( ) ; let cksum = crate :: utils :: checksum ( & len_buf ) ; let cksum_buf = cksum . to_le_bytes ( ) ; writer . write_all ( & len_buf ) ? ; writer . write_all ( & cksum_buf ) ? ; } // write data { let cksum = crate :: utils :: checksum ( & bytes ) ; let cksum_buf = cksum . to_le_bytes ( ) ; writer . write_all ( bytes . as_slice ( ) ) ? ; writer . write_all ( & cksum_buf ) ? ; } Ok ( ( ) ) }
Write the raw record bytes to a generic writer.
Write the raw record bytes to a generic writer .
writer
&mut W
bytes
Vec<u8>
writer
&mut W
bytes
Vec<u8>