pub trait Push<Item, Meta>where
Meta: Copy,{
type Ctx<'ctx>: Context<'ctx>;
type CanPend: Toggle;
// Required methods
fn poll_ready(
self: Pin<&mut Self>,
ctx: &mut Self::Ctx<'_>,
) -> PushStep<Self::CanPend>;
fn start_send(self: Pin<&mut Self>, item: Item, meta: Meta);
fn poll_flush(
self: Pin<&mut Self>,
ctx: &mut Self::Ctx<'_>,
) -> PushStep<Self::CanPend>;
fn size_hint(self: Pin<&mut Self>, hint: (usize, Option<usize>));
}Expand description
The Push trait represents a push-based pipeline that items can be sent into.
This is the dual of crate::pull::Pull: where Pull allows you to request items from
a source, Push allows you to send items into a sink. Push operators form
chains where each operator transforms items and passes them downstream.
The protocol mirrors futures_sink::Sink:
- Call
Push::poll_readyto check if the push can accept an item. - If ready, call
Push::start_sendto send the item. - Call
Push::poll_flushto flush buffered items.
Required Associated Types§
Sourcetype CanPend: Toggle
type CanPend: Toggle
Whether this push can return PushStep::Pending.
Required Methods§
Sourcefn poll_ready(
self: Pin<&mut Self>,
ctx: &mut Self::Ctx<'_>,
) -> PushStep<Self::CanPend>
fn poll_ready( self: Pin<&mut Self>, ctx: &mut Self::Ctx<'_>, ) -> PushStep<Self::CanPend>
Check if this push is ready to accept an item.
Sourcefn start_send(self: Pin<&mut Self>, item: Item, meta: Meta)
fn start_send(self: Pin<&mut Self>, item: Item, meta: Meta)
Send an item into this push pipeline.
Must only be called after Push::poll_ready returns PushStep::Done.
Sourcefn poll_flush(
self: Pin<&mut Self>,
ctx: &mut Self::Ctx<'_>,
) -> PushStep<Self::CanPend>
fn poll_flush( self: Pin<&mut Self>, ctx: &mut Self::Ctx<'_>, ) -> PushStep<Self::CanPend>
Flushes any buffered items in this push pipeline.
Sourcefn size_hint(self: Pin<&mut Self>, hint: (usize, Option<usize>))
fn size_hint(self: Pin<&mut Self>, hint: (usize, Option<usize>))
Informs this push how many items are about to be sent.
The semantics match crate::pull::Pull::size_hint / Iterator::size_hint:
the first element is a lower bound, the second is an optional upper bound.
Combinators should propagate this downstream, adjusting bounds where
appropriate (e.g. Filter sets the lower bound to 0).
Under normal usage expect this to be called once before items are pushed. However this may be called multiple times or never at all. It is an error to call this multiple times with size hints that conflict–each size hint should match or narrow the estimated range (after accounting for already-sent items).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<P, Item, Meta> Push<Item, Meta> for &mut P
impl<P, Item, Meta> Push<Item, Meta> for &mut P
type Ctx<'ctx> = <P as Push<Item, Meta>>::Ctx<'ctx>
type CanPend = <P as Push<Item, Meta>>::CanPend
fn poll_ready( self: Pin<&mut Self>, ctx: &mut Self::Ctx<'_>, ) -> PushStep<Self::CanPend>
fn start_send(self: Pin<&mut Self>, item: Item, meta: Meta)
fn poll_flush( self: Pin<&mut Self>, ctx: &mut Self::Ctx<'_>, ) -> PushStep<Self::CanPend>
fn size_hint(self: Pin<&mut Self>, hint: (usize, Option<usize>))
Implementors§
Source§impl<Buf, Item, Meta> Push<Item, Meta> for VecPush<Buf>
Available on crate feature alloc only.
impl<Buf, Item, Meta> Push<Item, Meta> for VecPush<Buf>
alloc only.Source§impl<Next, Func, IntoIter, In, Meta> Push<In, Meta> for FlatMap<Next, Func, IntoIter, Meta>where
Next: Push<IntoIter::Item, Meta>,
Func: FnMut(In) -> IntoIter,
IntoIter: IntoIterator,
Meta: Copy,
impl<Next, Func, IntoIter, In, Meta> Push<In, Meta> for FlatMap<Next, Func, IntoIter, Meta>where
Next: Push<IntoIter::Item, Meta>,
Func: FnMut(In) -> IntoIter,
IntoIter: IntoIterator,
Meta: Copy,
Source§impl<Next, Func, St, In, Meta> Push<In, Meta> for FlatMapStream<Next, Func, St, Meta>
impl<Next, Func, St, In, Meta> Push<In, Meta> for FlatMapStream<Next, Func, St, Meta>
Source§impl<Next, St, Meta> Push<St, Meta> for FlattenStream<Next, St, Meta>
impl<Next, St, Meta> Push<St, Meta> for FlattenStream<Next, St, Meta>
Source§impl<P0, P1, Item0, Item1, Meta> Push<(Item0, Item1), Meta> for Unzip<P0, P1>
impl<P0, P1, Item0, Item1, Meta> Push<(Item0, Item1), Meta> for Unzip<P0, P1>
Source§impl<Psh, Item, Buf> Push<Item, ()> for Persist<Psh, Buf>
Available on crate feature alloc only.
impl<Psh, Item, Buf> Push<Item, ()> for Persist<Psh, Buf>
alloc only.Source§impl<Psh, Queue, QueueInner, Fut> Push<Fut, ()> for ResolveFutures<Psh, Queue, QueueInner>
impl<Psh, Queue, QueueInner, Fut> Push<Fut, ()> for ResolveFutures<Psh, Queue, QueueInner>
Source§impl<Pushes, Item, Meta> Push<(usize, Item), Meta> for DemuxVar<Pushes>where
Pushes: PushVariadic<Item, Meta>,
Meta: Copy,
Available on crate feature variadics only.
impl<Pushes, Item, Meta> Push<(usize, Item), Meta> for DemuxVar<Pushes>where
Pushes: PushVariadic<Item, Meta>,
Meta: Copy,
variadics only.