Trait FromBufStream

Source
pub trait FromBufStream {
    type Builder;

    // Required methods
    fn builder(hint: &SizeHint) -> Self::Builder;
    fn extend<T: Buf>(builder: &mut Self::Builder, buf: &mut T);
    fn build(builder: Self::Builder) -> Self;
}
Expand description

Conversion from a BufStream.

By implementing FromBufStream for a type, you define how it will be created from a buf stream. This is common for types which describe byte storage of some kind.

FromBufStream is rarely called explicitly, and it is instead used through BufStream’s collect method.

Required Associated Types§

Source

type Builder

Type that is used to build Self while the BufStream is being consumed.

Required Methods§

Source

fn builder(hint: &SizeHint) -> Self::Builder

Create a new, empty, builder. The provided hint can be used to inform reserving capacity.

Source

fn extend<T: Buf>(builder: &mut Self::Builder, buf: &mut T)

Extend the builder with the Buf.

This method is called whenever a new Buf value is obtained from the buf stream.

Source

fn build(builder: Self::Builder) -> Self

Finalize the building of Self.

Called once the buf stream is fully consumed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromBufStream for Vec<u8>

Source§

type Builder = Vec<u8>

Source§

fn builder(hint: &SizeHint) -> Vec<u8>

Source§

fn extend<T: Buf>(builder: &mut Self, buf: &mut T)

Source§

fn build(builder: Self) -> Self

Source§

impl FromBufStream for Bytes

Source§

type Builder = BytesMut

Source§

fn builder(hint: &SizeHint) -> BytesMut

Source§

fn extend<T: Buf>(builder: &mut Self::Builder, buf: &mut T)

Source§

fn build(builder: Self::Builder) -> Self

Implementors§