Struct tokio_util::time::DelayQueue

source ·
pub struct DelayQueue<T> { /* private fields */ }
Available on crate feature time only.
Expand description

A queue of delayed elements.

Once an element is inserted into the DelayQueue, it is yielded once the specified deadline has been reached.

§Usage

Elements are inserted into DelayQueue using the insert or insert_at methods. A deadline is provided with the item and a Key is returned. The key is used to remove the entry or to change the deadline at which it should be yielded back.

Once delays have been configured, the DelayQueue is used via its Stream implementation. poll_expired is called. If an entry has reached its deadline, it is returned. If not, Poll::Pending is returned indicating that the current task will be notified once the deadline has been reached.

§Stream implementation

Items are retrieved from the queue via DelayQueue::poll_expired. If no delays have expired, no items are returned. In this case, Poll::Pending is returned and the current task is registered to be notified once the next item’s delay has expired.

If no items are in the queue, i.e. is_empty() returns true, then poll returns Poll::Ready(None). This indicates that the stream has reached an end. However, if a new item is inserted after, poll will once again start returning items or Poll::Pending.

Items are returned ordered by their expirations. Items that are configured to expire first will be returned first. There are no ordering guarantees for items configured to expire at the same instant. Also note that delays are rounded to the closest millisecond.

§Implementation

The DelayQueue is backed by a separate instance of a timer wheel similar to that used internally by Tokio’s standalone timer utilities such as sleep. Because of this, it offers the same performance and scalability benefits.

State associated with each entry is stored in a slab. This amortizes the cost of allocation, and allows reuse of the memory allocated for expired entries.

Capacity can be checked using capacity and allocated preemptively by using the reserve method.

§Usage

Using DelayQueue to manage cache entries.

use tokio_util::time::{DelayQueue, delay_queue};

use std::collections::HashMap;
use std::task::{ready, Context, Poll};
use std::time::Duration;

struct Cache {
    entries: HashMap<CacheKey, (Value, delay_queue::Key)>,
    expirations: DelayQueue<CacheKey>,
}

const TTL_SECS: u64 = 30;

impl Cache {
    fn insert(&mut self, key: CacheKey, value: Value) {
        let delay = self.expirations
            .insert(key.clone(), Duration::from_secs(TTL_SECS));

        self.entries.insert(key, (value, delay));
    }

    fn get(&self, key: &CacheKey) -> Option<&Value> {
        self.entries.get(key)
            .map(|&(ref v, _)| v)
    }

    fn remove(&mut self, key: &CacheKey) {
        if let Some((_, cache_key)) = self.entries.remove(key) {
            self.expirations.remove(&cache_key);
        }
    }

    fn poll_purge(&mut self, cx: &mut Context<'_>) -> Poll<()> {
        while let Some(entry) = ready!(self.expirations.poll_expired(cx)) {
            self.entries.remove(entry.get_ref());
        }

        Poll::Ready(())
    }
}

Implementations§

source§

impl<T> DelayQueue<T>

source

pub fn new() -> DelayQueue<T>

Creates a new, empty, DelayQueue.

The queue will not allocate storage until items are inserted into it.

§Examples
let delay_queue: DelayQueue<u32> = DelayQueue::new();
source

pub fn with_capacity(capacity: usize) -> DelayQueue<T>

Creates a new, empty, DelayQueue with the specified capacity.

The queue will be able to hold at least capacity elements without reallocating. If capacity is 0, the queue will not allocate for storage.

§Examples

let mut delay_queue = DelayQueue::with_capacity(10);

// These insertions are done without further allocation
for i in 0..10 {
    delay_queue.insert(i, Duration::from_secs(i));
}

// This will make the queue allocate additional storage
delay_queue.insert(11, Duration::from_secs(11));
source

pub fn insert_at(&mut self, value: T, when: Instant) -> Key

Inserts value into the queue set to expire at a specific instant in time.

This function is identical to insert, but takes an Instant instead of a Duration.

value is stored in the queue until when is reached. At which point, value will be returned from poll_expired. If when has already been reached, then value is immediately made available to poll.

The return value represents the insertion and is used as an argument to remove and reset. Note that Key is a token and is reused once value is removed from the queue either by calling poll_expired after when is reached or by calling remove. At this point, the caller must take care to not use the returned Key again as it may reference a different item in the queue.

See type level documentation for more details.

§Panics

This function panics if when is too far in the future.

§Examples

Basic usage

use tokio::time::{Duration, Instant};
use tokio_util::time::DelayQueue;

let mut delay_queue = DelayQueue::new();
let key = delay_queue.insert_at(
    "foo", Instant::now() + Duration::from_secs(5));

// Remove the entry
let item = delay_queue.remove(&key);
assert_eq!(*item.get_ref(), "foo");
source

pub fn poll_expired(&mut self, cx: &mut Context<'_>) -> Poll<Option<Expired<T>>>

Attempts to pull out the next value of the delay queue, registering the current task for wakeup if the value is not yet available, and returning None if the queue is exhausted.

source

pub fn insert(&mut self, value: T, timeout: Duration) -> Key

Inserts value into the queue set to expire after the requested duration elapses.

This function is identical to insert_at, but takes a Duration instead of an Instant.

value is stored in the queue until timeout duration has elapsed after insert was called. At that point, value will be returned from poll_expired. If timeout is a Duration of zero, then value is immediately made available to poll.

The return value represents the insertion and is used as an argument to remove and reset. Note that Key is a token and is reused once value is removed from the queue either by calling poll_expired after timeout has elapsed or by calling remove. At this point, the caller must not use the returned Key again as it may reference a different item in the queue.

See type level documentation for more details.

§Panics

This function panics if timeout is greater than the maximum duration supported by the timer in the current Runtime.

§Examples

Basic usage

use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();
let key = delay_queue.insert("foo", Duration::from_secs(5));

// Remove the entry
let item = delay_queue.remove(&key);
assert_eq!(*item.get_ref(), "foo");
source

pub fn deadline(&self, key: &Key) -> Instant

Returns the deadline of the item associated with key.

Since the queue operates at millisecond granularity, the returned deadline may not exactly match the value that was given when initially inserting the item into the queue.

§Panics

This function panics if key is not contained by the queue.

§Examples

Basic usage

use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();

let key1 = delay_queue.insert("foo", Duration::from_secs(5));
let key2 = delay_queue.insert("bar", Duration::from_secs(10));

assert!(delay_queue.deadline(&key1) < delay_queue.deadline(&key2));
source

pub fn remove(&mut self, key: &Key) -> Expired<T>

Removes the item associated with key from the queue.

There must be an item associated with key. The function returns the removed item as well as the Instant at which it will the delay will have expired.

§Panics

The function panics if key is not contained by the queue.

§Examples

Basic usage

use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();
let key = delay_queue.insert("foo", Duration::from_secs(5));

// Remove the entry
let item = delay_queue.remove(&key);
assert_eq!(*item.get_ref(), "foo");
source

pub fn try_remove(&mut self, key: &Key) -> Option<Expired<T>>

Attempts to remove the item associated with key from the queue.

Removes the item associated with key, and returns it along with the Instant at which it would have expired, if it exists.

Returns None if key is not in the queue.

§Examples

Basic usage

use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();
let key = delay_queue.insert("foo", Duration::from_secs(5));

// The item is in the queue, `try_remove` returns `Some(Expired("foo"))`.
let item = delay_queue.try_remove(&key);
assert_eq!(item.unwrap().into_inner(), "foo");

// The item is not in the queue anymore, `try_remove` returns `None`.
let item = delay_queue.try_remove(&key);
assert!(item.is_none());
source

pub fn reset_at(&mut self, key: &Key, when: Instant)

Sets the delay of the item associated with key to expire at when.

This function is identical to reset but takes an Instant instead of a Duration.

The item remains in the queue but the delay is set to expire at when. If when is in the past, then the item is immediately made available to the caller.

§Panics

This function panics if when is too far in the future or if key is not contained by the queue.

§Examples

Basic usage

use tokio::time::{Duration, Instant};
use tokio_util::time::DelayQueue;

let mut delay_queue = DelayQueue::new();
let key = delay_queue.insert("foo", Duration::from_secs(5));

// "foo" is scheduled to be returned in 5 seconds

delay_queue.reset_at(&key, Instant::now() + Duration::from_secs(10));

// "foo" is now scheduled to be returned in 10 seconds
source

pub fn shrink_to_fit(&mut self)

Shrink the capacity of the slab, which DelayQueue uses internally for storage allocation. This function is not guaranteed to, and in most cases, won’t decrease the capacity of the slab to the number of elements still contained in it, because elements cannot be moved to a different index. To decrease the capacity to the size of the slab use compact.

This function can take O(n) time even when the capacity cannot be reduced or the allocation is shrunk in place. Repeated calls run in O(1) though.

source

pub fn compact(&mut self)

Shrink the capacity of the slab, which DelayQueue uses internally for storage allocation, to the number of elements that are contained in it.

This methods runs in O(n).

§Examples

Basic usage

use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::with_capacity(10);

let key1 = delay_queue.insert(5, Duration::from_secs(5));
let key2 = delay_queue.insert(10, Duration::from_secs(10));
let key3 = delay_queue.insert(15, Duration::from_secs(15));

delay_queue.remove(&key2);

delay_queue.compact();
assert_eq!(delay_queue.capacity(), 2);
source

pub fn peek(&self) -> Option<Key>

Gets the Key that poll_expired will pull out of the queue next, without pulling it out or waiting for the deadline to expire.

Entries that have already expired may be returned in any order, but it is guaranteed that this method returns them in the same order as when items are popped from the DelayQueue.

§Examples

Basic usage

use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();

let key1 = delay_queue.insert("foo", Duration::from_secs(10));
let key2 = delay_queue.insert("bar", Duration::from_secs(5));
let key3 = delay_queue.insert("baz", Duration::from_secs(15));

assert_eq!(delay_queue.peek().unwrap(), key2);
source

pub fn reset(&mut self, key: &Key, timeout: Duration)

Sets the delay of the item associated with key to expire after timeout.

This function is identical to reset_at but takes a Duration instead of an Instant.

The item remains in the queue but the delay is set to expire after timeout. If timeout is zero, then the item is immediately made available to the caller.

§Panics

This function panics if timeout is greater than the maximum supported duration or if key is not contained by the queue.

§Examples

Basic usage

use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();
let key = delay_queue.insert("foo", Duration::from_secs(5));

// "foo" is scheduled to be returned in 5 seconds

delay_queue.reset(&key, Duration::from_secs(10));

// "foo"is now scheduled to be returned in 10 seconds
source

pub fn clear(&mut self)

Clears the queue, removing all items.

After calling clear, poll_expired will return Ok(Ready(None)).

Note that this method has no effect on the allocated capacity.

§Examples
use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();

delay_queue.insert("foo", Duration::from_secs(5));

assert!(!delay_queue.is_empty());

delay_queue.clear();

assert!(delay_queue.is_empty());
source

pub fn capacity(&self) -> usize

Returns the number of elements the queue can hold without reallocating.

§Examples
use tokio_util::time::DelayQueue;

let delay_queue: DelayQueue<i32> = DelayQueue::with_capacity(10);
assert_eq!(delay_queue.capacity(), 10);
source

pub fn len(&self) -> usize

Returns the number of elements currently in the queue.

§Examples
use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue: DelayQueue<i32> = DelayQueue::with_capacity(10);
assert_eq!(delay_queue.len(), 0);
delay_queue.insert(3, Duration::from_secs(5));
assert_eq!(delay_queue.len(), 1);
source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more items to be queued without allocating.

reserve does nothing if the queue already has sufficient capacity for additional more values. If more capacity is required, a new segment of memory will be allocated and all existing values will be copied into it. As such, if the queue is already very large, a call to reserve can end up being expensive.

The queue may reserve more than additional extra space in order to avoid frequent reallocations.

§Panics

Panics if the new capacity exceeds the maximum number of entries the queue can contain.

§Examples
use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();

delay_queue.insert("hello", Duration::from_secs(10));
delay_queue.reserve(10);

assert!(delay_queue.capacity() >= 11);
source

pub fn is_empty(&self) -> bool

Returns true if there are no items in the queue.

Note that this function returns false even if all items have not yet expired and a call to poll will return Poll::Pending.

§Examples
use tokio_util::time::DelayQueue;
use std::time::Duration;

let mut delay_queue = DelayQueue::new();
assert!(delay_queue.is_empty());

delay_queue.insert("hello", Duration::from_secs(5));
assert!(!delay_queue.is_empty());

Trait Implementations§

source§

impl<T: Debug> Debug for DelayQueue<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T> Default for DelayQueue<T>

source§

fn default() -> DelayQueue<T>

Returns the “default value” for a type. Read more
source§

impl<T> Stream for DelayQueue<T>

source§

type Item = Expired<T>

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<T> Unpin for DelayQueue<T>

Auto Trait Implementations§

§

impl<T> Freeze for DelayQueue<T>

§

impl<T> !RefUnwindSafe for DelayQueue<T>

§

impl<T> Send for DelayQueue<T>
where T: Send,

§

impl<T> Sync for DelayQueue<T>
where T: Sync,

§

impl<T> !UnwindSafe for DelayQueue<T>

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<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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> StreamExt for T
where T: Stream + ?Sized,

source§

fn next(&mut self) -> Next<'_, Self>
where Self: Unpin,

Creates a future that resolves to the next item in the stream. Read more
source§

fn into_future(self) -> StreamFuture<Self>
where Self: Sized + Unpin,

Converts this stream into a future of (next_item, tail_of_stream). If the stream terminates, then the next item is None. Read more
source§

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

Maps this stream’s items to a different type, returning a new stream of the resulting type. Read more
source§

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

Creates a stream which gives the current iteration count as well as the next value. Read more
source§

fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>
where F: FnMut(&Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,

Filters the values produced by this stream according to the provided asynchronous predicate. Read more
source§

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

Filters the values produced by this stream while simultaneously mapping them to a different type according to the provided asynchronous closure. Read more
source§

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

Computes from this stream’s items new items of a different type using an asynchronous closure. Read more
source§

fn collect<C>(self) -> Collect<Self, C>
where C: Default + Extend<Self::Item>, Self: Sized,

Transforms a stream into a collection, returning a future representing the result of that computation. Read more
source§

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

Converts a stream of pairs into a future, which resolves to pair of containers. Read more
source§

fn concat(self) -> Concat<Self>
where Self: Sized, Self::Item: Extend<<Self::Item as IntoIterator>::Item> + IntoIterator + Default,

Concatenate all items of a stream into a single extendable destination, returning a future representing the end result. Read more
source§

fn count(self) -> Count<Self>
where Self: Sized,

Drives the stream to completion, counting the number of items. Read more
source§

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

Repeats a stream endlessly. Read more
source§

fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>
where F: FnMut(T, Self::Item) -> Fut, Fut: Future<Output = T>, Self: Sized,

Execute an accumulating asynchronous computation over a stream, collecting all the values into one final result. Read more
source§

fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>
where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,

Execute predicate over asynchronous stream, and return true if any element in stream satisfied a predicate. Read more
source§

fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>
where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,

Execute predicate over asynchronous stream, and return true if all element in stream satisfied a predicate. Read more
source§

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

Flattens a stream of streams into just one continuous stream. Read more
source§

fn flatten_unordered( self, limit: impl Into<Option<usize>>, ) -> FlattenUnorderedWithFlowController<Self, ()>
where Self::Item: Stream + Unpin, Self: Sized,

Flattens a stream of streams into just one continuous stream. Polls inner streams produced by the base stream concurrently. Read more
source§

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

Maps a stream like StreamExt::map but flattens nested Streams. Read more
source§

fn flat_map_unordered<U, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> FlatMapUnordered<Self, U, F>
where U: Stream + Unpin, F: FnMut(Self::Item) -> U, Self: Sized,

Maps a stream like StreamExt::map but flattens nested Streams and polls them concurrently, yielding items in any order, as they made available. Read more
source§

fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>
where F: FnMut(&mut S, Self::Item) -> Fut, Fut: Future<Output = Option<B>>, Self: Sized,

Combinator similar to StreamExt::fold that holds internal state and produces a new stream. Read more
source§

fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>
where F: FnMut(&Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,

Skip elements on this stream while the provided asynchronous predicate resolves to true. Read more
source§

fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
where F: FnMut(&Self::Item) -> Fut, Fut: Future<Output = bool>, Self: Sized,

Take elements from this stream while the provided asynchronous predicate resolves to true. Read more
source§

fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>
where Fut: Future, Self: Sized,

Take elements from this stream until the provided future resolves. Read more
source§

fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>
where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = ()>, Self: Sized,

Runs this stream to completion, executing the provided asynchronous closure for each element on the stream. Read more
source§

fn for_each_concurrent<Fut, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> ForEachConcurrent<Self, Fut, F>
where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = ()>, Self: Sized,

Runs this stream to completion, executing the provided asynchronous closure for each element on the stream concurrently as elements become available. Read more
source§

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

Creates a new stream of at most n items of the underlying stream. Read more
source§

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

Creates a new stream which skips n items of the underlying stream. Read more
source§

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

Fuse a stream such that poll_next will never again be called once it has finished. This method can be used to turn any Stream into a FusedStream. Read more
source§

fn by_ref(&mut self) -> &mut Self

Borrows a stream, rather than consuming it. Read more
source§

fn catch_unwind(self) -> CatchUnwind<Self>
where Self: Sized + UnwindSafe,

Catches unwinding panics while polling the stream. Read more
source§

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

Wrap the stream in a Box, pinning it. Read more
source§

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

Wrap the stream in a Box, pinning it. Read more
source§

fn buffered(self, n: usize) -> Buffered<Self>
where Self::Item: Future, Self: Sized,

An adaptor for creating a buffered list of pending futures. Read more
source§

fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
where Self::Item: Future, Self: Sized,

An adaptor for creating a buffered list of pending futures (unordered). Read more
source§

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

An adapter for zipping two streams together. Read more
source§

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

Adapter for chaining two streams. Read more
source§

fn peekable(self) -> Peekable<Self>
where Self: Sized,

Creates a new stream which exposes a peek method. Read more
source§

fn chunks(self, capacity: usize) -> Chunks<Self>
where Self: Sized,

An adaptor for chunking up items of the stream inside a vector. Read more
source§

fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>
where Self: Sized,

An adaptor for chunking up ready items of the stream inside a vector. Read more
source§

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

Do something with each item of this stream, afterwards passing it on. Read more
source§

fn left_stream<B>(self) -> Either<Self, B>
where B: Stream<Item = Self::Item>, Self: Sized,

Wrap this stream in an Either stream, making it the left-hand variant of that Either. Read more
source§

fn right_stream<B>(self) -> Either<B, Self>
where B: Stream<Item = Self::Item>, Self: Sized,

Wrap this stream in an Either stream, making it the right-hand variant of that Either. Read more
source§

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

A convenience method for calling Stream::poll_next on Unpin stream types.
source§

fn select_next_some(&mut self) -> SelectNextSome<'_, Self>
where Self: Unpin + FusedStream,

Returns a Future that resolves when the next item in this stream is ready. 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<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more