/rust/registry/src/index.crates.io-6f17d22bba15001f/protobuf-3.2.0/src/rt/singular.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use crate::rt::compute_raw_varint64_size; |
2 | | use crate::rt::tag_size; |
3 | | use crate::varint::generic::ProtobufVarint; |
4 | | use crate::zigzag::ProtobufVarintZigzag; |
5 | | |
6 | | /// Integer value size when encoded. |
7 | | #[inline] |
8 | 0 | fn varint_size<T: ProtobufVarint>(field_number: u32, value: T) -> u64 { |
9 | 0 | tag_size(field_number) + value.len_varint() |
10 | 0 | } Unexecuted instantiation: protobuf::rt::singular::varint_size::<u32> Unexecuted instantiation: protobuf::rt::singular::varint_size::<u64> Unexecuted instantiation: protobuf::rt::singular::varint_size::<u32> Unexecuted instantiation: protobuf::rt::singular::varint_size::<i64> Unexecuted instantiation: protobuf::rt::singular::varint_size::<i32> |
11 | | |
12 | | /// Encoded `int32` size. |
13 | | #[inline] |
14 | 0 | pub fn int32_size(field_number: u32, value: i32) -> u64 { |
15 | 0 | varint_size(field_number, value) |
16 | 0 | } |
17 | | |
18 | | /// Encoded `int64` size. |
19 | | #[inline] |
20 | 0 | pub fn int64_size(field_number: u32, value: i64) -> u64 { |
21 | 0 | varint_size(field_number, value) |
22 | 0 | } |
23 | | |
24 | | /// Encoded `uint32` size. |
25 | | #[inline] |
26 | 0 | pub fn uint32_size(field_number: u32, value: u32) -> u64 { |
27 | 0 | varint_size(field_number, value) |
28 | 0 | } |
29 | | |
30 | | /// Encoded `uint64` size. |
31 | | #[inline] |
32 | 0 | pub fn uint64_size(field_number: u32, value: u64) -> u64 { |
33 | 0 | varint_size(field_number, value) |
34 | 0 | } |
35 | | |
36 | | /// Integer value size when encoded as specified wire type. |
37 | 0 | pub(crate) fn value_varint_zigzag_size_no_tag<T: ProtobufVarintZigzag>(value: T) -> u64 { |
38 | 0 | value.len_varint_zigzag() |
39 | 0 | } Unexecuted instantiation: protobuf::rt::singular::value_varint_zigzag_size_no_tag::<i32> Unexecuted instantiation: protobuf::rt::singular::value_varint_zigzag_size_no_tag::<i64> |
40 | | |
41 | | /// Length of value when encoding with zigzag encoding with tag |
42 | | #[inline] |
43 | 0 | fn value_varint_zigzag_size<T: ProtobufVarintZigzag>(field_number: u32, value: T) -> u64 { |
44 | 0 | tag_size(field_number) + value_varint_zigzag_size_no_tag(value) |
45 | 0 | } Unexecuted instantiation: protobuf::rt::singular::value_varint_zigzag_size::<i64> Unexecuted instantiation: protobuf::rt::singular::value_varint_zigzag_size::<i32> |
46 | | |
47 | | /// Size of serialized `sint32` field. |
48 | | #[inline] |
49 | 0 | pub fn sint32_size(field_number: u32, value: i32) -> u64 { |
50 | 0 | value_varint_zigzag_size(field_number, value) |
51 | 0 | } |
52 | | |
53 | | /// Size of serialized `sint64` field. |
54 | | #[inline] |
55 | 0 | pub fn sint64_size(field_number: u32, value: i64) -> u64 { |
56 | 0 | value_varint_zigzag_size(field_number, value) |
57 | 0 | } |
58 | | |
59 | | /// Size of encoded bytes field. |
60 | 0 | pub(crate) fn bytes_size_no_tag(bytes: &[u8]) -> u64 { |
61 | 0 | compute_raw_varint64_size(bytes.len() as u64) + bytes.len() as u64 |
62 | 0 | } |
63 | | |
64 | | /// Size of encoded bytes field. |
65 | | #[inline] |
66 | 0 | pub fn bytes_size(field_number: u32, bytes: &[u8]) -> u64 { |
67 | 0 | tag_size(field_number) + bytes_size_no_tag(bytes) |
68 | 0 | } |
69 | | |
70 | | /// Size of encoded string field. |
71 | 0 | pub(crate) fn string_size_no_tag(s: &str) -> u64 { |
72 | 0 | bytes_size_no_tag(s.as_bytes()) |
73 | 0 | } |
74 | | |
75 | | /// Size of encoded string field. |
76 | | #[inline] |
77 | 0 | pub fn string_size(field_number: u32, s: &str) -> u64 { |
78 | 0 | tag_size(field_number) + string_size_no_tag(s) |
79 | 0 | } |