MCPcopy Create free account
hub / github.com/apache/avro-rs / decode_seq_len

Function decode_seq_len

avro/src/decode.rs:56–69  ·  view source on GitHub ↗

Decode the length of a sequence. Maps and arrays are 0-terminated, 0i64 is also encoded as 0 in Avro reading a length of 0 means the end of the map or array.

(reader: &mut R)

Source from the content-addressed store, hash-verified

54/// the end of the map or array.
55fn decode_seq_len<R: Read>(reader: &mut R) -> AvroResult<usize> {
56 let raw_len = zag_i64(reader)?;
57 safe_len(
58 usize::try_from(match raw_len.cmp(&0) {
59 std::cmp::Ordering::Equal => return Ok(0),
60 std::cmp::Ordering::Less => {
61 let _size = zag_i64(reader)?;
62 raw_len.checked_neg().ok_or(Details::IntegerOverflow)?
63 }
64 std::cmp::Ordering::Greater => raw_len,
65 })
66 .map_err(|e| Details::ConvertI64ToUsize(e, raw_len))?,
67 )
68}
69
70/// Per-datum decoding state.
71///
72/// Tracks the cumulative number of bytes allocated on behalf of a single

Callers 1

decode_internalFunction · 0.85

Calls 2

zag_i64Function · 0.85
safe_lenFunction · 0.85

Tested by

no test coverage detected