pub struct TakeUntil<St: Stream, Fut: Future> { /* private fields */ }
Expand description

Stream for the take_until method.

Implementations

Acquires a reference to the underlying sink or stream that this combinator is pulling from.

Acquires a mutable reference to the underlying sink or stream that this combinator is pulling from.

Note that care must be taken to avoid tampering with the state of the sink or stream which may otherwise confuse this combinator.

Acquires a pinned mutable reference to the underlying sink or stream that this combinator is pulling from.

Note that care must be taken to avoid tampering with the state of the sink or stream which may otherwise confuse this combinator.

Consumes this combinator, returning the underlying sink or stream.

Note that this may discard intermediate state of this combinator, so care should be taken to avoid losing resources when this is called.

Extract the stopping future out of the combinator. The future is returned only if it isn’t resolved yet, ie. if the stream isn’t stopped yet. Taking out the future means the combinator will be yielding elements from the wrapped stream without ever stopping it.

Once the stopping future is resolved, this method can be used to extract the value returned by the stopping future.

This may be used to retrieve arbitrary data from the stopping future, for example a reason why the stream was stopped.

This method will return None if the future isn’t resolved yet, or if the result was already taken out.

Examples
use futures::future;
use futures::stream::{self, StreamExt};
use futures::task::Poll;

let stream = stream::iter(1..=10);

let mut i = 0;
let stop_fut = future::poll_fn(|_cx| {
    i += 1;
    if i <= 5 {
        Poll::Pending
    } else {
        Poll::Ready("reason")
    }
});

let mut stream = stream.take_until(stop_fut);
let _ = stream.by_ref().collect::<Vec<_>>().await;

let result = stream.take_result().unwrap();
assert_eq!(result, "reason");

Whether the stream was stopped yet by the stopping future being resolved.

Trait Implementations

Formats the value using the given formatter. Read more
Returns true if the stream should no longer be polled.
Values yielded by the stream.
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
Returns the bounds on the remaining length of the stream. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type of successful values yielded by this future
The type of failures yielded by this future
Poll this TryStream as if it were a Stream. Read more