Struct Bytes

Source
pub struct Bytes<R> { /* private fields */ }
Expand description

Reader for the AsyncReadExt::bytes() method.

Trait Implementationsยง

Sourceยง

impl<R: AsyncRead> AsyncRead for Bytes<R>

Sourceยง

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<usize>>

Attempt to read from the AsyncRead into buf. Read more
Sourceยง

fn poll_read_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], ) -> Poll<Result<usize>>

Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more
Sourceยง

impl<R: Debug> Debug for Bytes<R>

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl<R: AsyncRead + Unpin> Stream for Bytes<R>

Sourceยง

type Item = Result<u8, Error>

Values yielded by the stream.
Sourceยง

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Sourceยง

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more
Sourceยง

impl<'__pin, R> Unpin for Bytes<R>
where PinnedFieldsOf<__Origin<'__pin, R>>: Unpin,

Auto Trait Implementationsยง

ยง

impl<R> Freeze for Bytes<R>
where R: Freeze,

ยง

impl<R> RefUnwindSafe for Bytes<R>
where R: RefUnwindSafe,

ยง

impl<R> Send for Bytes<R>
where R: Send,

ยง

impl<R> Sync for Bytes<R>
where R: Sync,

ยง

impl<R> UnwindSafe for Bytes<R>
where R: 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<R> AsyncReadExt for R
where R: AsyncRead + ?Sized,

Sourceยง

fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> โ“˜
where Self: Unpin,

Reads some bytes from the byte stream. Read more
Sourceยง

fn read_vectored<'a>( &'a mut self, bufs: &'a mut [IoSliceMut<'a>], ) -> ReadVectoredFuture<'a, Self> โ“˜
where Self: Unpin,

Like read(), except it reads into a slice of buffers. Read more
Sourceยง

fn read_to_end<'a>( &'a mut self, buf: &'a mut Vec<u8>, ) -> ReadToEndFuture<'a, Self> โ“˜
where Self: Unpin,

Reads the entire contents and appends them to a Vec. Read more
Sourceยง

fn read_to_string<'a>( &'a mut self, buf: &'a mut String, ) -> ReadToStringFuture<'a, Self> โ“˜
where Self: Unpin,

Reads the entire contents and appends them to a String. Read more
Sourceยง

fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> โ“˜
where Self: Unpin,

Reads the exact number of bytes required to fill buf. Read more
Sourceยง

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Sourceยง

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Converts this AsyncRead into a Stream of bytes. Read more
Sourceยง

fn chain<R: AsyncRead>(self, next: R) -> Chain<Self, R>
where Self: Sized,

Creates an adapter which will chain this stream with another. Read more
Sourceยง

fn boxed_reader<'a>(self) -> Pin<Box<dyn AsyncRead + Send + 'a>>
where Self: Sized + Send + 'a,

Boxes the reader and changes its type to dyn AsyncRead + Send + 'a. 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<S> StreamExt for S
where S: Stream + ?Sized,

Sourceยง

fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>
where Self: Unpin,

A convenience for calling Stream::poll_next() on !Unpin types.
Sourceยง

fn next(&mut self) -> NextFuture<'_, Self> โ“˜
where Self: Unpin,

Retrieves the next item in the stream. Read more
Sourceยง

fn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self> โ“˜
where Self: Stream<Item = Result<T, E>> + Unpin,

Retrieves the next item in the stream. Read more
Sourceยง

fn count(self) -> CountFuture<Self> โ“˜
where Self: Sized,

Counts the number of items in the stream. Read more
Sourceยง

fn map<T, F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> T,

Maps items of the stream to new values using a closure. Read more
Sourceยง

fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
where Self: Sized, U: Stream, F: FnMut(Self::Item) -> U,

Maps items to streams and then concatenates them. Read more
Sourceยง

fn flatten(self) -> Flatten<Self>
where Self: Sized, Self::Item: Stream,

Concatenates inner streams. Read more
Sourceยง

fn then<F, Fut>(self, f: F) -> Then<Self, F, Fut>
where Self: Sized, F: FnMut(Self::Item) -> Fut, Fut: Future,

Maps items of the stream to new values using an async closure. Read more
Sourceยง

fn filter<P>(self, predicate: P) -> Filter<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Keeps items of the stream for which predicate returns true. Read more
Sourceยง

fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> Option<T>,

Filters and maps items of the stream using a closure. Read more
Sourceยง

fn take(self, n: usize) -> Take<Self>
where Self: Sized,

Takes only the first n items of the stream. Read more
Sourceยง

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Takes items while predicate returns true. Read more
Sourceยง

fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
where Self: Sized, P: FnMut(Self::Item) -> Option<B>,

Maps items while predicate returns Some. Read more
Sourceยง

fn skip(self, n: usize) -> Skip<Self>
where Self: Sized,

Skips the first n items of the stream. Read more
Sourceยง

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Skips items while predicate returns true. Read more
Sourceยง

fn step_by(self, step: usize) -> StepBy<Self>
where Self: Sized,

Yields every stepth item. Read more
Sourceยง

fn chain<U>(self, other: U) -> Chain<Self, U>
where Self: Sized, U: Stream<Item = Self::Item> + Sized,

Appends another stream to the end of this one. Read more
Sourceยง

fn cloned<'a, T>(self) -> Cloned<Self>
where Self: Stream<Item = &'a T> + Sized, T: Clone + 'a,

Clones all items. Read more
Sourceยง

fn copied<'a, T>(self) -> Copied<Self>
where Self: Stream<Item = &'a T> + Sized, T: Copy + 'a,

Copies all items. Read more
Sourceยง

fn collect<C>(self) -> CollectFuture<Self, C> โ“˜
where Self: Sized, C: Default + Extend<Self::Item>,

Collects all items in the stream into a collection. Read more
Sourceยง

fn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C> โ“˜
where Self: Stream<Item = Result<T, E>> + Sized, C: Default + Extend<T>,

Collects all items in the fallible stream into a collection. Read more
Sourceยง

fn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B> โ“˜
where Self: Sized, B: Default + Extend<Self::Item>, P: FnMut(&Self::Item) -> bool,

Partitions items into those for which predicate is true and those for which it is false, and then collects them into two collections. Read more
Sourceยง

fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T> โ“˜
where Self: Sized, F: FnMut(T, Self::Item) -> T,

Accumulates a computation over the stream. Read more
Sourceยง

fn try_fold<T, E, F, B>( &mut self, init: B, f: F, ) -> TryFoldFuture<'_, Self, F, B> โ“˜
where Self: Stream<Item = Result<T, E>> + Unpin + Sized, F: FnMut(B, T) -> Result<B, E>,

Accumulates a fallible computation over the stream. Read more
Sourceยง

fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,

Maps items of the stream to new values using a state value and a closure. Read more
Sourceยง

fn fuse(self) -> Fuse<Self>
where Self: Sized,

Fuses the stream so that it stops yielding items after the first None. Read more
Sourceยง

fn cycle(self) -> Cycle<Self>
where Self: Clone + Sized,

Repeats the stream from beginning to end, forever. Read more
Sourceยง

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

Enumerates items, mapping them to (index, item). Read more
Sourceยง

fn inspect<F>(self, f: F) -> Inspect<Self, F>
where Self: Sized, F: FnMut(&Self::Item),

Calls a closure on each item and passes it on. Read more
Sourceยง

fn nth(&mut self, n: usize) -> NthFuture<'_, Self> โ“˜
where Self: Unpin,

Gets the nth item of the stream. Read more
Sourceยง

fn last(self) -> LastFuture<Self> โ“˜
where Self: Sized,

Returns the last item in the stream. Read more
Sourceยง

fn find<P>(&mut self, predicate: P) -> FindFuture<'_, Self, P> โ“˜
where Self: Unpin, P: FnMut(&Self::Item) -> bool,

Finds the first item of the stream for which predicate returns true. Read more
Sourceยง

fn find_map<F, B>(&mut self, f: F) -> FindMapFuture<'_, Self, F> โ“˜
where Self: Unpin, F: FnMut(Self::Item) -> Option<B>,

Applies a closure to items in the stream and returns the first Some result. Read more
Sourceยง

fn position<P>(&mut self, predicate: P) -> PositionFuture<'_, Self, P> โ“˜
where Self: Unpin, P: FnMut(Self::Item) -> bool,

Finds the index of the first item of the stream for which predicate returns true. Read more
Sourceยง

fn all<P>(&mut self, predicate: P) -> AllFuture<'_, Self, P> โ“˜
where Self: Unpin, P: FnMut(Self::Item) -> bool,

Tests if predicate returns true for all items in the stream. Read more
Sourceยง

fn any<P>(&mut self, predicate: P) -> AnyFuture<'_, Self, P> โ“˜
where Self: Unpin, P: FnMut(Self::Item) -> bool,

Tests if predicate returns true for any item in the stream. Read more
Sourceยง

fn for_each<F>(self, f: F) -> ForEachFuture<Self, F> โ“˜
where Self: Sized, F: FnMut(Self::Item),

Calls a closure on each item of the stream. Read more
Sourceยง

fn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F> โ“˜
where Self: Unpin, F: FnMut(Self::Item) -> Result<(), E>,

Calls a fallible closure on each item of the stream, stopping on first error. Read more
Sourceยง

fn zip<U>(self, other: U) -> Zip<Self, U>
where Self: Sized, U: Stream,

Zips up two streams into a single stream of pairs. Read more
Sourceยง

fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB> โ“˜
where FromA: Default + Extend<A>, FromB: Default + Extend<B>, Self: Stream<Item = (A, B)> + Sized,

Collects a stream of pairs into a pair of collections. Read more
Sourceยง

fn or<S>(self, other: S) -> Or<Self, S>
where Self: Sized, S: Stream<Item = Self::Item>,

Merges with other stream, preferring items from self whenever both streams are ready. Read more
Sourceยง

fn race<S>(self, other: S) -> Race<Self, S>
where Self: Sized, S: Stream<Item = Self::Item>,

Merges with other stream, with no preference for either stream when both are ready. Read more
Sourceยง

fn drain(&mut self) -> Drain<'_, Self>

Yields all immediately available values from a stream. Read more
Sourceยง

fn boxed<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a>>
where Self: Send + Sized + 'a,

Boxes the stream and changes its type to dyn Stream + Send + 'a. Read more
Sourceยง

fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a>>
where Self: Sized + 'a,

Boxes the stream and changes its type to dyn Stream + 'a. Read more
Sourceยง

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

Sourceยง

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Sourceยง

impl<S, T, E> TryStream for S
where S: Stream<Item = Result<T, E>> + ?Sized,

Sourceยง

type Ok = T

The type of successful values yielded by this future
Sourceยง

type Error = E

The type of failures yielded by this future
Sourceยง

fn try_poll_next( self: Pin<&mut S>, cx: &mut Context<'_>, ) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>

Poll this TryStream as if it were a Stream. Read more