pub struct FieldNumber(/* private fields */);Expand description
A validated Protocol Buffers field number.
Field numbers must be in the range [1, 2^29 - 1].
Implementations§
Source§impl FieldNumber
impl FieldNumber
Sourcepub const MAX_SINGLE_BYTE_TAG: u32 = 15u32
pub const MAX_SINGLE_BYTE_TAG: u32 = 15u32
Maximum field number that can be encoded as a single-byte tag (15). Field numbers 1-15 result in tags that fit in 1 byte.
Sourcepub const RESERVED_RANGE_START: u32 = 19_000u32
pub const RESERVED_RANGE_START: u32 = 19_000u32
Start of reserved field number range (19000). Protobuf reserves field numbers 19000-19999.
Sourcepub const RESERVED_RANGE_END: u32 = 19_999u32
pub const RESERVED_RANGE_END: u32 = 19_999u32
End of reserved field number range (19999). Protobuf reserves field numbers 19000-19999.
Sourcepub fn try_new(value: u32) -> Result<Self, ProtobufError>
pub fn try_new(value: u32) -> Result<Self, ProtobufError>
Creates a new field number, validating the range.
Sourcepub fn is_tag_single_byte(&self) -> bool
pub fn is_tag_single_byte(&self) -> bool
Checks if the field number can be encoded as a single-byte tag. Field numbers 1-15 result in tags that fit in 1 byte.
Sourcepub fn is_reserved(&self) -> bool
pub fn is_reserved(&self) -> bool
Checks if the field number is in a reserved range. Protobuf reserves field numbers 19000-19999, inclusive.
Sourcepub fn is_in_range(&self, min: u32, max: u32) -> bool
pub fn is_in_range(&self, min: u32, max: u32) -> bool
Checks if the field number is in a specific range, inclusive.
Sourcepub fn encoded_size(&self) -> usize
pub fn encoded_size(&self) -> usize
Returns the minimum number of bytes needed to encode the tag (field_number + wire_type) as a varint.
The tag is encoded as: (field_number << 3) | wire_type Since wire_type is 0-7, the maximum tag value is (field_number * 8) + 7
Trait Implementations§
Source§impl Clone for FieldNumber
impl Clone for FieldNumber
Source§fn clone(&self) -> FieldNumber
fn clone(&self) -> FieldNumber
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more