pub struct Tag { /* private fields */ }Expand description
A parsed field tag (field number + wire type).
Implementations§
Source§impl Tag
impl Tag
Sourcepub fn new(field_number: u32, wire_type: WireType) -> Self
pub fn new(field_number: u32, wire_type: WireType) -> Self
Create a new tag.
§Panics
Panics if field_number is not in the valid range [1, 2^29 – 1].
This is a programming error (generated code always uses valid field
numbers); the panic fires in all build profiles.
Sourcepub fn field_number(&self) -> u32
pub fn field_number(&self) -> u32
Returns the field number carried by this tag.
Sourcepub fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>
pub fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>
Decode a tag from a buffer.
Single-byte tags (field numbers 1–15, any wire type) are handled
inline without a call into decode_varint. With plain #[inline],
LLVM often declines to inline decode_varint (three code paths:
single-byte, unrolled-slice, slow-fallback) into per-field decode
loops, so handling the one-byte case here avoids the out-of-line
call for the overwhelmingly common case.
Trait Implementations§
impl Copy for Tag
impl Eq for Tag
impl StructuralPartialEq for Tag
Auto Trait Implementations§
impl Freeze for Tag
impl RefUnwindSafe for Tag
impl Send for Tag
impl Sync for Tag
impl Unpin for Tag
impl UnsafeUnpin for Tag
impl UnwindSafe for Tag
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more