unsafe fn read_lengthed_datum<'a>(data: &'a [u8], offset: &mut usize, tag: Tag) -> Datum<'a> {
    let len = match tag {
        Tag::BytesTiny | Tag::StringTiny => usize::from(read_byte(data, offset)),
        Tag::BytesShort | Tag::StringShort => {
            usize::from(u16::from_le_bytes(read_byte_array(data, offset)))
        }
        Tag::BytesLong | Tag::StringLong => {
            usize::cast_from(u32::from_le_bytes(read_byte_array(data, offset)))
        }
        Tag::BytesHuge | Tag::StringHuge => {
            usize::cast_from(u64::from_le_bytes(read_byte_array(data, offset)))
        }
        _ => unreachable!(),
    };
    let bytes = &data[*offset..(*offset + len)];
    *offset += len;
    match tag {
        Tag::BytesTiny | Tag::BytesShort | Tag::BytesLong | Tag::BytesHuge => Datum::Bytes(bytes),
        Tag::StringTiny | Tag::StringShort | Tag::StringLong | Tag::StringHuge => {
            Datum::String(str::from_utf8_unchecked(bytes))
        }
        _ => unreachable!(),
    }
}
/// Read a data whose length is encoded in the row before its contents.
///
/// Updates `offset` to point to the first byte after the end of the read region.
///
/// # Safety
///
/// This function is safe if the datum's length and contents were previously written by `push_lengthed_bytes`,
/// and it was only written with a `String` tag if it was indeed UTF-8.
Read a data whose length is encoded in the row before its contents.
Updates `offset` to point to the first byte after the end of the read region.
Read a data whose length is encoded in the row before its contents . Updates ` offset ` to point to the first byte after the end of the read region .
unsafe fn read_lengthed_datum<'a>(data: &'a [u8], offset: &mut usize, tag: Tag) -> Datum<'a> {
    let len = match tag {
        Tag::BytesTiny | Tag::StringTiny => usize::from(read_byte(data, offset)),
        Tag::BytesShort | Tag::StringShort => {
            usize::from(u16::from_le_bytes(read_byte_array(data, offset)))
        }
        Tag::BytesLong | Tag::StringLong => {
            usize::cast_from(u32::from_le_bytes(read_byte_array(data, offset)))
        }
        Tag::BytesHuge | Tag::StringHuge => {
            usize::cast_from(u64::from_le_bytes(read_byte_array(data, offset)))
        }
        _ => unreachable!(),
    };
    let bytes = &data[*offset..(*offset + len)];
    *offset += len;
    match tag {
        Tag::BytesTiny | Tag::BytesShort | Tag::BytesLong | Tag::BytesHuge => Datum::Bytes(bytes),
        Tag::StringTiny | Tag::StringShort | Tag::StringLong | Tag::StringHuge => {
            Datum::String(str::from_utf8_unchecked(bytes))
        }
        _ => unreachable!(),
    }
}
unsafe fn read_lengthed_datum < ' a > ( data : & ' a [ u8 ] , offset : & mut usize , tag : Tag ) -> Datum < ' a > { let len = match tag { Tag :: BytesTiny | Tag :: StringTiny => usize :: from ( read_byte ( data , offset ) ) , Tag :: BytesShort | Tag :: StringShort => { usize :: from ( u16 :: from_le_bytes ( read_byte_array ( data , offset ) ) ) } Tag :: BytesLong | Tag :: StringLong => { usize :: cast_from ( u32 :: from_le_bytes ( read_byte_array ( data , offset ) ) ) } Tag :: BytesHuge | Tag :: StringHuge => { usize :: cast_from ( u64 :: from_le_bytes ( read_byte_array ( data , offset ) ) ) } _ => unreachable ! ( ) , } ; let bytes = & data [ * offset .. ( * offset + len ) ] ; * offset += len ; match tag { Tag :: BytesTiny | Tag :: BytesShort | Tag :: BytesLong | Tag :: BytesHuge => Datum :: Bytes ( bytes ) , Tag :: StringTiny | Tag :: StringShort | Tag :: StringLong | Tag :: StringHuge => { Datum :: String ( str :: from_utf8_unchecked ( bytes ) ) } _ => unreachable ! ( ) , } }
Read a data whose length is encoded in the row before its contents.
Read a data whose length is encoded in the row before its contents .
data
&'a [u8]
offset
&mut usize
tag
Tag
data
&'a [u8]
offset
&mut usize
tag
Tag
safety
This function is safe if the datum's length and contents were previously written by `push_lengthed_bytes`,
and it was only written with a `String` tag if it was indeed UTF-8.
This function is safe if the datum ' s length and contents were previously written by ` push_lengthed_bytes ` and it was only written with a ` String ` tag if it was indeed UTF - 8 .