Struct completion::stream::Peekable [−][src]
Stream for CompletionStreamExt::peekable
.
Implementations
impl<S: CompletionStream> Peekable<S>
[src]
#[must_use]pub fn peek(self: Pin<&mut Self>) -> Peek<'_, S>ⓘNotable traits for Peek<'a, S>
impl<'a, S> Future for Peek<'a, S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Self::Output;
[src]
Notable traits for Peek<'a, S>
impl<'a, S> Future for Peek<'a, S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Self::Output;
Peek the next value in the stream.
Cancellation
If the returned future is cancelled and the next value in the stream has not been peeked yet, the entire stream is cancelled, otherwise nothing happens.
Examples
use completion::{CompletionStreamExt, StreamExt}; use futures_lite::{stream, pin}; let stream = stream::once(5).into_completion().peekable(); pin!(stream); assert_eq!(stream.as_mut().peek().await, Some(&5)); assert_eq!(stream.as_mut().peek().await, Some(&5)); assert_eq!(stream.next().await, Some(5)); assert_eq!(stream.as_mut().peek().await, None); assert_eq!(stream.next().await, None);
#[must_use]pub fn peek_unpin(&mut self) -> Peek<'_, S>ⓘNotable traits for Peek<'a, S>
impl<'a, S> Future for Peek<'a, S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Self::Output;
where
Self: Unpin,
[src]
Notable traits for Peek<'a, S>
impl<'a, S> Future for Peek<'a, S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Self::Output;
Self: Unpin,
Peek the next value in the stream if the underlying type implements Unpin
.
stream.peek_unpin()
is equivalent to Pin::new(&mut stream).peek()
. See
peek
for more information.
Examples
use completion::{CompletionStreamExt, StreamExt}; use futures_lite::stream; let mut stream = stream::once(8).into_completion().peekable(); assert_eq!(stream.peek_unpin().await, Some(&8)); assert_eq!(stream.peek_unpin().await, Some(&8)); assert_eq!(stream.next().await, Some(8)); assert_eq!(stream.peek_unpin().await, None); assert_eq!(stream.next().await, None);
pub unsafe fn poll_peek(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<&S::Item>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<&S::Item>>
Attempt to peek the next value in the stream.
This function is quite low level, use peek
or
peek_unpin
for a higher-level equivalent.
Safety
pub unsafe fn poll_peek_cancel(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<()>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<()>
Attempt to cancel peeking the next value in the stream.
This will cancel the underlying stream if the next value in the stream has not already been peeked.
This function is quite low level, use peek
or
peek_unpin
for a higher-level equivalent.
Safety
Trait Implementations
impl<S: Clone + CompletionStream> Clone for Peekable<S> where
S::Item: Clone,
[src]
S::Item: Clone,
impl<S: CompletionStream> CompletionStream for Peekable<S>
[src]
type Item = S::Item
Values yielded by the stream.
unsafe fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<S: Debug + CompletionStream> Debug for Peekable<S> where
S::Item: Debug,
[src]
S::Item: Debug,
impl<S> Stream for Peekable<S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
[src]
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
type Item = <S as CompletionStream>::Item
Values yielded by the stream.
fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<'__pin, S: CompletionStream> Unpin for Peekable<S> where
__Origin<'__pin, S>: Unpin,
[src]
__Origin<'__pin, S>: Unpin,
Auto Trait Implementations
impl<S> RefUnwindSafe for Peekable<S> where
S: RefUnwindSafe,
<S as CompletionStream>::Item: RefUnwindSafe,
S: RefUnwindSafe,
<S as CompletionStream>::Item: RefUnwindSafe,
impl<S> Send for Peekable<S> where
S: Send,
<S as CompletionStream>::Item: Send,
S: Send,
<S as CompletionStream>::Item: Send,
impl<S> Sync for Peekable<S> where
S: Sync,
<S as CompletionStream>::Item: Sync,
S: Sync,
<S as CompletionStream>::Item: Sync,
impl<S> UnwindSafe for Peekable<S> where
S: UnwindSafe,
<S as CompletionStream>::Item: UnwindSafe,
S: UnwindSafe,
<S as CompletionStream>::Item: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CompletionStreamExt for T where
T: CompletionStream + ?Sized,
[src]
T: CompletionStream + ?Sized,
unsafe fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> where
Self: Unpin,
[src]
Self: Unpin,
unsafe fn poll_cancel(&mut self, cx: &mut Context<'_>) -> Poll<()> where
Self: Unpin,
[src]
Self: Unpin,
fn must_complete(self) -> MustComplete<Self> where
Self: Sized,
[src]
Self: Sized,
fn next(&mut self) -> Next<'_, Self>ⓘNotable traits for Next<'_, S>
impl<S: Unpin + ?Sized> Future for Next<'_, S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Option<<S as CompletionStream>::Item>;
where
Self: Unpin,
[src]
Notable traits for Next<'_, S>
impl<S: Unpin + ?Sized> Future for Next<'_, S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Option<<S as CompletionStream>::Item>;
Self: Unpin,
fn count(self) -> Count<Self>ⓘNotable traits for Count<S>
impl<S> Future for Count<S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = usize;
where
Self: Sized,
[src]
Notable traits for Count<S>
impl<S> Future for Count<S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = usize;
Self: Sized,
fn last(self) -> Last<Self>ⓘNotable traits for Last<S>
impl<S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>> Future for Last<S> type Output = Option<<S as CompletionStream>::Item>;
where
Self: Sized,
[src]
Notable traits for Last<S>
impl<S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>> Future for Last<S> type Output = Option<<S as CompletionStream>::Item>;
Self: Sized,
fn nth(&mut self, n: usize) -> Nth<'_, Self>ⓘNotable traits for Nth<'_, S>
impl<S: Unpin + ?Sized> Future for Nth<'_, S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Option<<S as CompletionStream>::Item>;
where
Self: Unpin,
[src]
Notable traits for Nth<'_, S>
impl<S: Unpin + ?Sized> Future for Nth<'_, S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Option<<S as CompletionStream>::Item>;
Self: Unpin,
fn step_by(self, step: usize) -> StepBy<Self> where
Self: Sized,
[src]
Self: Sized,
fn chain<U: CompletionStream<Item = Self::Item>>(
self,
other: U
) -> Chain<Self, U> where
Self: Sized,
[src]
self,
other: U
) -> Chain<Self, U> where
Self: Sized,
fn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F> where
Self: Sized,
[src]
Self: Sized,
fn then<F: FnMut(Self::Item) -> Fut, Fut: CompletionFuture>(
self,
f: F
) -> Then<Self, F, Fut> where
Self: Sized,
[src]
self,
f: F
) -> Then<Self, F, Fut> where
Self: Sized,
fn for_each<F: FnMut(Self::Item)>(self, f: F) -> ForEach<Self, F>ⓘNotable traits for ForEach<S, F>
impl<S, F> Future for ForEach<S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(<S as CompletionStream>::Item), type Output = ();
where
Self: Sized,
[src]
Notable traits for ForEach<S, F>
impl<S, F> Future for ForEach<S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(<S as CompletionStream>::Item), type Output = ();
Self: Sized,
fn filter<F>(self, f: F) -> Filter<Self, F> where
F: FnMut(&Self::Item) -> bool,
Self: Sized,
[src]
F: FnMut(&Self::Item) -> bool,
Self: Sized,
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<T>,
Self: Sized,
[src]
F: FnMut(Self::Item) -> Option<T>,
Self: Sized,
fn enumerate(self) -> Enumerate<Self> where
Self: Sized,
[src]
Self: Sized,
fn peekable(self) -> Peekable<Self> where
Self: Sized,
[src]
Self: Sized,
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
Self: Sized,
[src]
P: FnMut(&Self::Item) -> bool,
Self: Sized,
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
Self: Sized,
[src]
P: FnMut(&Self::Item) -> bool,
Self: Sized,
fn skip(self, n: usize) -> Skip<Self> where
Self: Sized,
[src]
Self: Sized,
fn take(self, n: usize) -> Take<Self> where
Self: Sized,
[src]
Self: Sized,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
Self: Sized,
U: CompletionStream,
F: FnMut(Self::Item) -> U,
[src]
Self: Sized,
U: CompletionStream,
F: FnMut(Self::Item) -> U,
fn flatten(self) -> Flatten<Self> where
Self: Sized,
Self::Item: CompletionStream,
[src]
Self: Sized,
Self::Item: CompletionStream,
fn fuse(self) -> Fuse<Self> where
Self: Sized,
[src]
Self: Sized,
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
Self: Sized,
F: FnMut(&Self::Item),
[src]
Self: Sized,
F: FnMut(&Self::Item),
fn collect<C: FromCompletionStream<Self::Item>>(self) -> Collect<Self, C>ⓘNotable traits for Collect<S, C>
impl<S, C> Future for Collect<S, C> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
C: FromCompletionStream<<S as CompletionStream>::Item>, type Output = C;
where
Self: Sized,
[src]
Notable traits for Collect<S, C>
impl<S, C> Future for Collect<S, C> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
C: FromCompletionStream<<S as CompletionStream>::Item>, type Output = C;
Self: Sized,
fn fold<T, F>(self, init: T, f: F) -> Fold<Self, F, T>ⓘNotable traits for Fold<S, F, T>
impl<S, F, T> Future for Fold<S, F, T> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(T, <S as CompletionStream>::Item) -> T, type Output = Self::Output;
where
F: FnMut(T, Self::Item) -> T,
Self: Sized,
[src]
Notable traits for Fold<S, F, T>
impl<S, F, T> Future for Fold<S, F, T> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(T, <S as CompletionStream>::Item) -> T, type Output = Self::Output;
F: FnMut(T, Self::Item) -> T,
Self: Sized,
fn all<F: FnMut(Self::Item) -> bool>(&mut self, f: F) -> All<'_, Self, F>ⓘNotable traits for All<'_, S, F>
impl<S: Unpin + ?Sized, F> Future for All<'_, S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(<S as CompletionStream>::Item) -> bool, type Output = bool;
where
Self: Unpin,
[src]
Notable traits for All<'_, S, F>
impl<S: Unpin + ?Sized, F> Future for All<'_, S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(<S as CompletionStream>::Item) -> bool, type Output = bool;
Self: Unpin,
fn any<F: FnMut(Self::Item) -> bool>(&mut self, f: F) -> Any<'_, Self, F>ⓘNotable traits for Any<'_, S, F>
impl<S: Unpin + ?Sized, F> Future for Any<'_, S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(<S as CompletionStream>::Item) -> bool, type Output = bool;
where
Self: Unpin,
[src]
Notable traits for Any<'_, S, F>
impl<S: Unpin + ?Sized, F> Future for Any<'_, S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(<S as CompletionStream>::Item) -> bool, type Output = bool;
Self: Unpin,
fn find<P>(&mut self, predicate: P) -> Find<'_, Self, P>ⓘNotable traits for Find<'_, S, P>
impl<S: Unpin + ?Sized, P> Future for Find<'_, S, P> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
P: FnMut(&<S as CompletionStream>::Item) -> bool, type Output = Self::Output;
where
Self: Unpin,
P: FnMut(&Self::Item) -> bool,
[src]
Notable traits for Find<'_, S, P>
impl<S: Unpin + ?Sized, P> Future for Find<'_, S, P> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
P: FnMut(&<S as CompletionStream>::Item) -> bool, type Output = Self::Output;
Self: Unpin,
P: FnMut(&Self::Item) -> bool,
fn find_map<B, F>(&mut self, f: F) -> FindMap<'_, Self, F>ⓘNotable traits for FindMap<'_, S, F>
impl<S: Unpin + ?Sized, F, B> Future for FindMap<'_, S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(<S as CompletionStream>::Item) -> Option<B>, type Output = Self::Output;
where
Self: Unpin,
F: FnMut(Self::Item) -> Option<B>,
[src]
Notable traits for FindMap<'_, S, F>
impl<S: Unpin + ?Sized, F, B> Future for FindMap<'_, S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(<S as CompletionStream>::Item) -> Option<B>, type Output = Self::Output;
Self: Unpin,
F: FnMut(Self::Item) -> Option<B>,
fn position<P>(&mut self, predicate: P) -> Position<'_, Self, P>ⓘNotable traits for Position<'_, S, P>
impl<S: Unpin + ?Sized, P> Future for Position<'_, S, P> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
P: FnMut(<S as CompletionStream>::Item) -> bool, type Output = Self::Output;
where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
[src]
Notable traits for Position<'_, S, P>
impl<S: Unpin + ?Sized, P> Future for Position<'_, S, P> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
P: FnMut(<S as CompletionStream>::Item) -> bool, type Output = Self::Output;
Self: Unpin,
P: FnMut(Self::Item) -> bool,
fn max(self) -> Max<Self>ⓘNotable traits for Max<S>
impl<S> Future for Max<S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Self::Output;
where
Self: Sized,
Self::Item: Ord,
[src]
Notable traits for Max<S>
impl<S> Future for Max<S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Self::Output;
Self: Sized,
Self::Item: Ord,
fn max_by<F>(self, compare: F) -> MaxBy<Self, F>ⓘNotable traits for MaxBy<S, F>
impl<S, F> Future for MaxBy<S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(&<S as CompletionStream>::Item, &<S as CompletionStream>::Item) -> Ordering, type Output = Self::Output;
where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
[src]
Notable traits for MaxBy<S, F>
impl<S, F> Future for MaxBy<S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(&<S as CompletionStream>::Item, &<S as CompletionStream>::Item) -> Ordering, type Output = Self::Output;
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
fn max_by_key<B, F>(self, f: F) -> MaxByKey<Self, B, F>ⓘNotable traits for MaxByKey<S, B, F>
impl<S, B, F> Future for MaxByKey<S, B, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(&<S as CompletionStream>::Item) -> B,
B: Ord, type Output = Self::Output;
where
Self: Sized,
B: Ord,
F: FnMut(&Self::Item) -> B,
[src]
Notable traits for MaxByKey<S, B, F>
impl<S, B, F> Future for MaxByKey<S, B, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(&<S as CompletionStream>::Item) -> B,
B: Ord, type Output = Self::Output;
Self: Sized,
B: Ord,
F: FnMut(&Self::Item) -> B,
fn min(self) -> Min<Self>ⓘNotable traits for Min<S>
impl<S> Future for Min<S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Self::Output;
where
Self: Sized,
Self::Item: Ord,
[src]
Notable traits for Min<S>
impl<S> Future for Min<S> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>, type Output = Self::Output;
Self: Sized,
Self::Item: Ord,
fn min_by<F>(self, compare: F) -> MinBy<Self, F>ⓘNotable traits for MinBy<S, F>
impl<S, F> Future for MinBy<S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(&<S as CompletionStream>::Item, &<S as CompletionStream>::Item) -> Ordering, type Output = Self::Output;
where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
[src]
Notable traits for MinBy<S, F>
impl<S, F> Future for MinBy<S, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(&<S as CompletionStream>::Item, &<S as CompletionStream>::Item) -> Ordering, type Output = Self::Output;
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
fn min_by_key<B, F>(self, f: F) -> MinByKey<Self, B, F>ⓘNotable traits for MinByKey<S, B, F>
impl<S, B, F> Future for MinByKey<S, B, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(&<S as CompletionStream>::Item) -> B,
B: Ord, type Output = Self::Output;
where
Self: Sized,
B: Ord,
F: FnMut(&Self::Item) -> B,
[src]
Notable traits for MinByKey<S, B, F>
impl<S, B, F> Future for MinByKey<S, B, F> where
S: CompletionStream + Stream<Item = <S as CompletionStream>::Item>,
F: FnMut(&<S as CompletionStream>::Item) -> B,
B: Ord, type Output = Self::Output;
Self: Sized,
B: Ord,
F: FnMut(&Self::Item) -> B,
fn copied<'a, T: Copy + 'a>(self) -> Copied<Self> where
Self: CompletionStream<Item = &'a T> + Sized,
[src]
Self: CompletionStream<Item = &'a T> + Sized,
fn cloned<'a, T: Clone + 'a>(self) -> Cloned<Self> where
Self: CompletionStream<Item = &'a T> + Sized,
[src]
Self: CompletionStream<Item = &'a T> + Sized,
fn cycle(self) -> Cycle<Self> where
Self: Sized + Clone,
[src]
Self: Sized + Clone,
fn boxed<'a>(self) -> BoxCompletionStream<'a, Self::Item> where
Self: Sized + Send + 'a,
[src]
Self: Sized + Send + 'a,
fn boxed_local<'a>(self) -> LocalBoxCompletionStream<'a, Self::Item> where
Self: Sized + 'a,
[src]
Self: Sized + 'a,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> StreamExt for T where
T: Stream,
[src]
T: Stream,
fn into_completion(self) -> Adapter<Self>ⓘ
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<S, T, E> TryStream for S where
S: Stream<Item = Result<T, E>> + ?Sized,
[src]
S: Stream<Item = Result<T, E>> + ?Sized,