Skip to main content

Deframer

Struct Deframer 

Source
pub struct Deframer<const N: usize> { /* private fields */ }
Expand description

Splits a byte stream into COBS blocks on 0x00. A block longer than N is discarded up to the next delimiter (resync).

Implementations§

Source§

impl<const N: usize> Deframer<N>

Source

pub const fn new() -> Self

An empty deframer with an N-byte block buffer. Size N to the largest COBS block you expect: MAX_FRAME holds any valid frame.

Source

pub fn push(&mut self, b: u8) -> Push<'_>

Feed one byte from the stream. On a 0x00 delimiter this returns the buffered block as Push::Block, or Push::Overflow if the block outgrew the buffer; an empty block (two delimiters in a row) returns Push::Pending. Every other byte is buffered and returns Push::Pending. The returned block borrows the deframer until the next push.

Trait Implementations§

Source§

impl<const N: usize> Default for Deframer<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Deframer<N>
where [u8; N]: Freeze,

§

impl<const N: usize> RefUnwindSafe for Deframer<N>
where [u8; N]: RefUnwindSafe,

§

impl<const N: usize> Send for Deframer<N>
where [u8; N]: Send,

§

impl<const N: usize> Sync for Deframer<N>
where [u8; N]: Sync,

§

impl<const N: usize> Unpin for Deframer<N>
where [u8; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for Deframer<N>
where [u8; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for Deframer<N>
where [u8; N]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.