[−][src]Trait tokio_buf::util::FromBufStream
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.
Associated Types
type Builder
Type that is used to build Self
while the BufStream
is being
consumed.
type Error
Error that might happen on conversion.
Required methods
fn builder(hint: &SizeHint) -> Self::Builder
Create a new, empty, builder. The provided hint
can be used to inform
reserving capacity.
fn extend(
builder: &mut Self::Builder,
buf: &mut T,
hint: &SizeHint
) -> Result<(), Self::Error>
builder: &mut Self::Builder,
buf: &mut T,
hint: &SizeHint
) -> Result<(), Self::Error>
Extend the builder with the Buf
.
This method is called whenever a new Buf
value is obtained from the
buf stream.
The provided size hint represents the state of the stream after
buf
has been yielded. The lower bound represents the minimum amount of
data that will be provided after this call to extend
returns.
fn build(builder: Self::Builder) -> Result<Self, Self::Error>
Finalize the building of Self
.
Called once the buf stream is fully consumed.
Implementations on Foreign Types
impl<T: Buf> FromBufStream<T> for Vec<u8>
[src]
type Builder = Vec<u8>
type Error = CollectVecError
fn builder(hint: &SizeHint) -> Vec<u8>
[src]
fn extend(
builder: &mut Self,
buf: &mut T,
hint: &SizeHint
) -> Result<(), Self::Error>
[src]
builder: &mut Self,
buf: &mut T,
hint: &SizeHint
) -> Result<(), Self::Error>
fn build(builder: Self) -> Result<Self, Self::Error>
[src]
impl<T: Buf> FromBufStream<T> for Bytes
[src]
type Builder = Vec<u8>
type Error = CollectBytesError
fn builder(hint: &SizeHint) -> Vec<u8>
[src]
fn extend(
builder: &mut Vec<u8>,
buf: &mut T,
hint: &SizeHint
) -> Result<(), Self::Error>
[src]
builder: &mut Vec<u8>,
buf: &mut T,
hint: &SizeHint
) -> Result<(), Self::Error>