pub struct TlvCodec;Expand description
tokio_util::codec implementation for NDN TLV framing over byte streams.
NDN uses length-prefix framing: each frame is a complete TLV element
[type | length | value] where both type and length are varu64-encoded.
This codec reassembles frames from the byte stream and passes complete
TLV buffers up to the face.
§Wire format
┌──────────┬──────────┬─────────────────┐
│ type │ length │ value │
│ (varu64) │ (varu64) │ (length bytes) │
└──────────┴──────────┴─────────────────┘Both TcpFace and SerialFace (over COBS) use this codec for framing.
Trait Implementations§
Source§impl Decoder for TlvCodec
impl Decoder for TlvCodec
Source§fn decode(
&mut self,
src: &mut BytesMut,
) -> Result<Option<Self::Item>, Self::Error>
fn decode( &mut self, src: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
§fn decode_eof(
&mut self,
buf: &mut BytesMut,
) -> Result<Option<Self::Item>, Self::Error>
fn decode_eof( &mut self, buf: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>
A default method available to be called when there are no more bytes
available to be read from the underlying I/O. Read more
impl Copy for TlvCodec
Auto Trait Implementations§
impl Freeze for TlvCodec
impl RefUnwindSafe for TlvCodec
impl Send for TlvCodec
impl Sync for TlvCodec
impl Unpin for TlvCodec
impl UnwindSafe for TlvCodec
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