pub struct TlvReader { /* private fields */ }Expand description
Zero-copy TLV reader over a Bytes buffer.
Every slice returned by this reader is a sub-slice of the original Bytes,
sharing the same reference-counted allocation — no copies.
Implementations§
Source§impl TlvReader
impl TlvReader
pub fn new(buf: Bytes) -> Self
pub fn remaining(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn read_length(&mut self) -> Result<usize, TlvError>
pub fn read_length(&mut self) -> Result<usize, TlvError>
Read the next TLV length field.
Sourcepub fn read_bytes(&mut self, len: usize) -> Result<Bytes, TlvError>
pub fn read_bytes(&mut self, len: usize) -> Result<Bytes, TlvError>
Read exactly len bytes as a zero-copy Bytes slice.
Sourcepub fn read_tlv(&mut self) -> Result<(u64, Bytes), TlvError>
pub fn read_tlv(&mut self) -> Result<(u64, Bytes), TlvError>
Read a complete TLV element: returns (type, value_bytes).
Sourcepub fn peek_type(&self) -> Result<u64, TlvError>
pub fn peek_type(&self) -> Result<u64, TlvError>
Peek at the next TLV type without advancing the position.
Sourcepub fn skip_unknown(&mut self, typ: u64) -> Result<(), TlvError>
pub fn skip_unknown(&mut self, typ: u64) -> Result<(), TlvError>
Skip an unknown TLV element, respecting the critical-bit rule.
Types 0–31 are always critical (grandfathered, NDN Packet Format v0.3 §1.3). For types >= 32, odd numbers are critical and even are non-critical.
Auto Trait Implementations§
impl !Freeze for TlvReader
impl RefUnwindSafe for TlvReader
impl Send for TlvReader
impl Sync for TlvReader
impl Unpin for TlvReader
impl UnwindSafe for TlvReader
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