unsafe fn read_datum<'a>(data: &'a [u8], offset: &mut usize) -> Datum<'a> {
    let tag = Tag::try_from_primitive(read_byte(data, offset)).expect("unknown row tag");
    match tag {
        Tag::Null => Datum::Null,
        Tag::False => Datum::False,
        Tag::True => Datum::True,
        Tag::Int16 => {
            let i = i16::from_le_bytes(read_byte_array(data, offset));
            Datum::Int16(i)
        }
        Tag::Int32 => {
            let i = i32::from_le_bytes(read_byte_array(data, offset));
            Datum::Int32(i)
        }
        Tag::Int64 => {
            let i = i64::from_le_bytes(read_byte_array(data, offset));
            Datum::Int64(i)
        }
        Tag::Float32 => {
            let f = f32::from_bits(u32::from_le_bytes(read_byte_array(data, offset)));
            Datum::Float32(OrderedFloat::from(f))
        }
        Tag::Float64 => {
            let f = f64::from_bits(u64::from_le_bytes(read_byte_array(data, offset)));
            Datum::Float64(OrderedFloat::from(f))
        }
        Tag::Date => Datum::Date(read_date(data, offset)),
        Tag::Time => Datum::Time(read_time(data, offset)),
        Tag::Timestamp => {
            let date = read_date(data, offset);
            let time = read_time(data, offset);
            Datum::Timestamp(date.and_time(time))
        }
        Tag::TimestampTz => {
            let date = read_date(data, offset);
            let time = read_time(data, offset);
            Datum::TimestampTz(DateTime::from_utc(date.and_time(time), Utc))
        }
        Tag::Interval => {
            let months = i32::from_le_bytes(read_byte_array(data, offset));
            let duration = i128::from_le_bytes(read_byte_array(data, offset));
            Datum::Interval(Interval { months, duration })
        }
        Tag::BytesTiny
        | Tag::BytesShort
        | Tag::BytesLong
        | Tag::BytesHuge
        | Tag::StringTiny
        | Tag::StringShort
        | Tag::StringLong
        | Tag::StringHuge => read_lengthed_datum(data, offset, tag),
        Tag::Uuid => Datum::Uuid(Uuid::from_bytes(read_byte_array(data, offset))),
        Tag::Array => {
            // See the comment in `Row::push_array` for details on the encoding
            // of arrays.
            let ndims = read_byte(data, offset);
            let dims_size = usize::from(ndims) * size_of::<u64>() * 2;
            let dims = &data[*offset..*offset + dims_size];
            *offset += dims_size;
            let data = read_untagged_bytes(data, offset);
            Datum::Array(Array {
                dims: ArrayDimensions { data: dims },
                elements: DatumList { data },
            })
        }
        Tag::List => {
            let bytes = read_untagged_bytes(data, offset);
            Datum::List(DatumList { data: bytes })
        }
        Tag::Dict => {
            let bytes = read_untagged_bytes(data, offset);
            Datum::Map(DatumMap { data: bytes })
        }
        Tag::JsonNull => Datum::JsonNull,
        Tag::Dummy => Datum::Dummy,
        Tag::Numeric => {
            let digits = read_byte(data, offset);
            let exponent = read_byte(data, offset) as i8;
            let bits = read_byte(data, offset);
            let lsu_u8_len = Numeric::digits_to_lsu_elements_len(digits.into()) * 2;
            let lsu_u8 = &data[*offset..(*offset + lsu_u8_len)];
            *offset += lsu_u8_len;
            let d = Numeric::from_raw_parts(digits.into(), exponent.into(), bits, lsu_u8);
            Datum::from(d)
        }
    }
}
/// Read a datum starting at byte `offset`.
///
/// Updates `offset` to point to the first byte after the end of the read region.
///
/// # Safety
///
/// This function is safe if a `Datum` was previously written at this offset by `push_datum`.
/// Otherwise it could return invalid values, which is Undefined Behavior.
Read a datum starting at byte `offset`.
Updates `offset` to point to the first byte after the end of the read region.
Read a datum starting at byte ` offset ` . Updates ` offset ` to point to the first byte after the end of the read region .
unsafe fn read_datum<'a>(data: &'a [u8], offset: &mut usize) -> Datum<'a> {
    let tag = Tag::try_from_primitive(read_byte(data, offset)).expect("unknown row tag");
    match tag {
        Tag::Null => Datum::Null,
        Tag::False => Datum::False,
        Tag::True => Datum::True,
        Tag::Int16 => {
            let i = i16::from_le_bytes(read_byte_array(data, offset));
            Datum::Int16(i)
        }
        Tag::Int32 => {
            let i = i32::from_le_bytes(read_byte_array(data, offset));
            Datum::Int32(i)
        }
        Tag::Int64 => {
            let i = i64::from_le_bytes(read_byte_array(data, offset));
            Datum::Int64(i)
        }
        Tag::Float32 => {
            let f = f32::from_bits(u32::from_le_bytes(read_byte_array(data, offset)));
            Datum::Float32(OrderedFloat::from(f))
        }
        Tag::Float64 => {
            let f = f64::from_bits(u64::from_le_bytes(read_byte_array(data, offset)));
            Datum::Float64(OrderedFloat::from(f))
        }
        Tag::Date => Datum::Date(read_date(data, offset)),
        Tag::Time => Datum::Time(read_time(data, offset)),
        Tag::Timestamp => {
            let date = read_date(data, offset);
            let time = read_time(data, offset);
            Datum::Timestamp(date.and_time(time))
        }
        Tag::TimestampTz => {
            let date = read_date(data, offset);
            let time = read_time(data, offset);
            Datum::TimestampTz(DateTime::from_utc(date.and_time(time), Utc))
        }
        Tag::Interval => {
            let months = i32::from_le_bytes(read_byte_array(data, offset));
            let duration = i128::from_le_bytes(read_byte_array(data, offset));
            Datum::Interval(Interval { months, duration })
        }
        Tag::BytesTiny
        | Tag::BytesShort
        | Tag::BytesLong
        | Tag::BytesHuge
        | Tag::StringTiny
        | Tag::StringShort
        | Tag::StringLong
        | Tag::StringHuge => read_lengthed_datum(data, offset, tag),
        Tag::Uuid => Datum::Uuid(Uuid::from_bytes(read_byte_array(data, offset))),
        Tag::Array => {
            // See the comment in `Row::push_array` for details on the encoding
            // of arrays.
            let ndims = read_byte(data, offset);
            let dims_size = usize::from(ndims) * size_of::<u64>() * 2;
            let dims = &data[*offset..*offset + dims_size];
            *offset += dims_size;
            let data = read_untagged_bytes(data, offset);
            Datum::Array(Array {
                dims: ArrayDimensions { data: dims },
                elements: DatumList { data },
            })
        }
        Tag::List => {
            let bytes = read_untagged_bytes(data, offset);
            Datum::List(DatumList { data: bytes })
        }
        Tag::Dict => {
            let bytes = read_untagged_bytes(data, offset);
            Datum::Map(DatumMap { data: bytes })
        }
        Tag::JsonNull => Datum::JsonNull,
        Tag::Dummy => Datum::Dummy,
        Tag::Numeric => {
            let digits = read_byte(data, offset);
            let exponent = read_byte(data, offset) as i8;
            let bits = read_byte(data, offset);
            let lsu_u8_len = Numeric::digits_to_lsu_elements_len(digits.into()) * 2;
            let lsu_u8 = &data[*offset..(*offset + lsu_u8_len)];
            *offset += lsu_u8_len;
            let d = Numeric::from_raw_parts(digits.into(), exponent.into(), bits, lsu_u8);
            Datum::from(d)
        }
    }
}
unsafe fn read_datum < ' a > ( data : & ' a [ u8 ] , offset : & mut usize ) -> Datum < ' a > { let tag = Tag :: try_from_primitive ( read_byte ( data , offset ) ) . expect ( " " ) ; match tag { Tag :: Null => Datum :: Null , Tag :: False => Datum :: False , Tag :: True => Datum :: True , Tag :: Int16 => { let i = i16 :: from_le_bytes ( read_byte_array ( data , offset ) ) ; Datum :: Int16 ( i ) } Tag :: Int32 => { let i = i32 :: from_le_bytes ( read_byte_array ( data , offset ) ) ; Datum :: Int32 ( i ) } Tag :: Int64 => { let i = i64 :: from_le_bytes ( read_byte_array ( data , offset ) ) ; Datum :: Int64 ( i ) } Tag :: Float32 => { let f = f32 :: from_bits ( u32 :: from_le_bytes ( read_byte_array ( data , offset ) ) ) ; Datum :: Float32 ( OrderedFloat :: from ( f ) ) } Tag :: Float64 => { let f = f64 :: from_bits ( u64 :: from_le_bytes ( read_byte_array ( data , offset ) ) ) ; Datum :: Float64 ( OrderedFloat :: from ( f ) ) } Tag :: Date => Datum :: Date ( read_date ( data , offset ) ) , Tag :: Time => Datum :: Time ( read_time ( data , offset ) ) , Tag :: Timestamp => { let date = read_date ( data , offset ) ; let time = read_time ( data , offset ) ; Datum :: Timestamp ( date . and_time ( time ) ) } Tag :: TimestampTz => { let date = read_date ( data , offset ) ; let time = read_time ( data , offset ) ; Datum :: TimestampTz ( DateTime :: from_utc ( date . and_time ( time ) , Utc ) ) } Tag :: Interval => { let months = i32 :: from_le_bytes ( read_byte_array ( data , offset ) ) ; let duration = i128 :: from_le_bytes ( read_byte_array ( data , offset ) ) ; Datum :: Interval ( Interval { months , duration } ) } Tag :: BytesTiny | Tag :: BytesShort | Tag :: BytesLong | Tag :: BytesHuge | Tag :: StringTiny | Tag :: StringShort | Tag :: StringLong | Tag :: StringHuge => read_lengthed_datum ( data , offset , tag ) , Tag :: Uuid => Datum :: Uuid ( Uuid :: from_bytes ( read_byte_array ( data , offset ) ) ) , Tag :: Array => { // See the comment in `Row::push_array` for details on the encoding // of arrays. let ndims = read_byte ( data , offset ) ; let dims_size = usize :: from ( ndims ) * size_of :: < u64 > ( ) * 2 ; let dims = & data [ * offset .. * offset + dims_size ] ; * offset += dims_size ; let data = read_untagged_bytes ( data , offset ) ; Datum :: Array ( Array { dims : ArrayDimensions { data : dims } , elements : DatumList { data } , } ) } Tag :: List => { let bytes = read_untagged_bytes ( data , offset ) ; Datum :: List ( DatumList { data : bytes } ) } Tag :: Dict => { let bytes = read_untagged_bytes ( data , offset ) ; Datum :: Map ( DatumMap { data : bytes } ) } Tag :: JsonNull => Datum :: JsonNull , Tag :: Dummy => Datum :: Dummy , Tag :: Numeric => { let digits = read_byte ( data , offset ) ; let exponent = read_byte ( data , offset ) as i8 ; let bits = read_byte ( data , offset ) ; let lsu_u8_len = Numeric :: digits_to_lsu_elements_len ( digits . into ( ) ) * 2 ; let lsu_u8 = & data [ * offset .. ( * offset + lsu_u8_len ) ] ; * offset += lsu_u8_len ; let d = Numeric :: from_raw_parts ( digits . into ( ) , exponent . into ( ) , bits , lsu_u8 ) ; Datum :: from ( d ) } } }
Read a datum starting at byte `offset`.
Read a datum starting at byte ` offset ` .
data
&'a [u8]
offset
&mut usize
data
&'a [u8]
offset
&mut usize
safety
This function is safe if a `Datum` was previously written at this offset by `push_datum`.
Otherwise it could return invalid values, which is Undefined Behavior.
This function is safe if a ` Datum ` was previously written at this offset by ` push_datum ` . Otherwise it could return invalid values which is Undefined Behavior .