/rust/registry/src/index.crates.io-6f17d22bba15001f/protobuf-3.2.0/src/rt/map.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use crate::error::WireError; |
2 | | use crate::wire_format::WireType; |
3 | | use crate::CodedInputStream; |
4 | | |
5 | 0 | pub(crate) fn read_map_template_new( |
6 | 0 | is: &mut CodedInputStream, |
7 | 0 | mut key: impl FnMut(WireType, &mut CodedInputStream) -> crate::Result<()>, |
8 | 0 | mut value: impl FnMut(WireType, &mut CodedInputStream) -> crate::Result<()>, |
9 | 0 | ) -> crate::Result<()> { |
10 | 0 | let len = is.read_raw_varint32()?; |
11 | 0 | let old_limit = is.push_limit(len as u64)?; |
12 | 0 | while !is.eof()? { |
13 | 0 | let (field_number, wire_type) = is.read_tag_unpack()?; |
14 | 0 | match field_number { |
15 | 0 | 1 => key(wire_type, is)?, |
16 | 0 | 2 => value(wire_type, is)?, |
17 | 0 | _ => is.skip_field(wire_type)?, |
18 | | } |
19 | | } |
20 | 0 | is.pop_limit(old_limit); |
21 | 0 | Ok(()) |
22 | 0 | } |
23 | | |
24 | 0 | pub(crate) fn read_map_template( |
25 | 0 | wire_type: WireType, |
26 | 0 | is: &mut CodedInputStream, |
27 | 0 | key: impl FnMut(WireType, &mut CodedInputStream) -> crate::Result<()>, |
28 | 0 | value: impl FnMut(WireType, &mut CodedInputStream) -> crate::Result<()>, |
29 | 0 | ) -> crate::Result<()> { |
30 | 0 | if wire_type != WireType::LengthDelimited { |
31 | 0 | return Err(WireError::UnexpectedWireType(wire_type).into()); |
32 | 0 | } |
33 | 0 |
|
34 | 0 | read_map_template_new(is, key, value) |
35 | 0 | } |