Skip to main content

Frames

Struct Frames 

Source
pub struct Frames { /* private fields */ }
Expand description

Frames read from bytes as they arrive, one by one as read_frame reads them from a stream. It holds at most one frame’s bytes within the limit, or a head’s past it: the rest of a frame past the limit is dropped as it arrives, and the frame is read once the last of it has.

Implementations§

Source§

impl Frames

Source

pub fn new(limit: usize) -> Frames

Frames with bodies of at most limit bytes kept.

Source

pub fn feed(&mut self, bytes: &[u8])

Takes bytes, the next the stream gave.

Source

pub fn read(&mut self) -> Result<Option<Frame>>

The next frame the bytes taken complete; None until they do.

§Errors

An io::ErrorKind::InvalidData when a frame’s length is not a number: nothing after it can be read as a frame.

Source

pub fn partial(&self) -> bool

Whether a frame has begun that the bytes taken do not complete.

Trait Implementations§

Source§

impl Debug for Frames

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Frames

§

impl Freeze for Frames
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for Frames

§

impl RefUnwindSafe for Frames

§

impl Send for Frames
where RawVecInner: Send,

§

impl Sync for Frames
where RawVecInner: Sync,

§

impl Unpin for Frames
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Frames

§

impl UnwindSafe for Frames
where RawVecInner: 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> Same for T

Source§

type Output = T

Should always be Self
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.