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)
| 54 | /// the end of the map or array. |
| 55 | fn 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 |
no test coverage detected