Trait FutureConsumer

Source
pub trait FutureConsumer<D>: Send + 'static {
    type Item;

    // Required method
    fn poll_consume(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        store: StoreContextMut<'_, D>,
        source: Source<'_, Self::Item>,
        finish: bool,
    ) -> Poll<Result<()>>;
}
Available on crate features runtime and component-model and component-model-async only.
Expand description

Represents a host-owned read end of a future.

Required Associated Types§

Source

type Item

The payload type of this future.

Required Methods§

Source

fn poll_consume( self: Pin<&mut Self>, cx: &mut Context<'_>, store: StoreContextMut<'_, D>, source: Source<'_, Self::Item>, finish: bool, ) -> Poll<Result<()>>

Handle a host- or guest-initiated write by consuming a value.

This is equivalent to StreamProducer::poll_produce, but with a simplified interface for futures.

If finish is true, the implementation may return Poll::Ready(Ok(())) without taking the item from source, which indicates the operation was canceled before it could consume the value. Otherwise, it must either take the item from source and return Poll::Ready(Ok(())), or else return Poll::Ready(Err(_)) or Poll::Pending (with or without taking the item).

Implementors§