pub struct Split<R> { /* private fields */ }
Expand description
Splitter for the split
method.
A Split
can be turned into a Stream
with SplitStream
.
Implementations§
Source§impl<R> Split<R>where
R: AsyncBufRead + Unpin,
impl<R> Split<R>where
R: AsyncBufRead + Unpin,
Sourcepub async fn next_segment(&mut self) -> Result<Option<Vec<u8>>, Error>
pub async fn next_segment(&mut self) -> Result<Option<Vec<u8>>, Error>
Returns the next segment in the stream.
§Examples
use tokio::io::AsyncBufReadExt;
let mut segments = my_buf_read.split(b'f');
while let Some(segment) = segments.next_segment().await? {
println!("length = {}", segment.len())
}
Source§impl<R> Split<R>where
R: AsyncBufRead,
impl<R> Split<R>where
R: AsyncBufRead,
Sourcepub fn poll_next_segment(
self: Pin<&mut Split<R>>,
cx: &mut Context<'_>,
) -> Poll<Result<Option<Vec<u8>>, Error>>
pub fn poll_next_segment( self: Pin<&mut Split<R>>, cx: &mut Context<'_>, ) -> Poll<Result<Option<Vec<u8>>, Error>>
Polls for the next segment in the stream.
This method returns:
Poll::Pending
if the next segment is not yet available.Poll::Ready(Ok(Some(segment)))
if the next segment is available.Poll::Ready(Ok(None))
if there are no more segments in this stream.Poll::Ready(Err(err))
if an IO error occurred while reading the next segment.
When the method returns Poll::Pending
, the Waker
in the provided
Context
is scheduled to receive a wakeup when more bytes become
available on the underlying IO resource.
Note that on multiple calls to poll_next_segment
, only the Waker
from the Context
passed to the most recent call is scheduled to
receive a wakeup.
Trait Implementations§
impl<'__pin, R> Unpin for Split<R>where
<PinnedFieldsOfHelperStruct<__Origin<'__pin, R>> as PinnedFieldsOfHelperTrait>::Actual: Unpin,
Auto Trait Implementations§
impl<R> Freeze for Split<R>where
R: Freeze,
impl<R> RefUnwindSafe for Split<R>where
R: RefUnwindSafe,
impl<R> Send for Split<R>where
R: Send,
impl<R> Sync for Split<R>where
R: Sync,
impl<R> UnwindSafe for Split<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more