Skip to main content

Push

Trait Push 

Source
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:

  1. Call Push::poll_ready to check if the push can accept an item.
  2. If ready, call Push::start_send to send the item.
  3. Call Push::poll_flush to flush buffered items.

Required Associated Types§

Source

type Ctx<'ctx>: Context<'ctx>

The context type required to push into this pipeline.

Source

type CanPend: Toggle

Whether this push can return PushStep::Pending.

Required Methods§

Source

fn poll_ready( self: Pin<&mut Self>, ctx: &mut Self::Ctx<'_>, ) -> PushStep<Self::CanPend>

Check if this push is ready to accept an item.

Source

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.

Source

fn poll_flush( self: Pin<&mut Self>, ctx: &mut Self::Ctx<'_>, ) -> PushStep<Self::CanPend>

Flushes any buffered items in this push pipeline.

Source

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
where P: Push<Item, Meta> + Unpin + ?Sized, Meta: Copy,

Source§

type Ctx<'ctx> = <P as Push<Item, Meta>>::Ctx<'ctx>

Source§

type CanPend = <P as Push<Item, Meta>>::CanPend

Source§

fn poll_ready( self: Pin<&mut Self>, ctx: &mut Self::Ctx<'_>, ) -> PushStep<Self::CanPend>

Source§

fn start_send(self: Pin<&mut Self>, item: Item, meta: Meta)

Source§

fn poll_flush( self: Pin<&mut Self>, ctx: &mut Self::Ctx<'_>, ) -> PushStep<Self::CanPend>

Source§

fn size_hint(self: Pin<&mut Self>, hint: (usize, Option<usize>))

Implementors§

Source§

impl<Buf, Item, Meta> Push<Item, Meta> for VecPush<Buf>
where Buf: BorrowMut<Vec<Item>>, Meta: Copy,

Available on crate feature alloc only.
Source§

impl<Func, Item, Meta> Push<Item, Meta> for ForEach<Func>
where Func: FnMut(Item), Meta: Copy,

Source§

impl<Next, Func, In, Out, Meta> Push<In, Meta> for FilterMap<Next, Func>
where Next: Push<Out, Meta>, Func: FnMut(In) -> Option<Out>, Meta: Copy,

Source§

type Ctx<'ctx> = <Next as Push<Out, Meta>>::Ctx<'ctx>

Source§

type CanPend = <Next as Push<Out, Meta>>::CanPend

Source§

impl<Next, Func, In, Out, Meta> Push<In, Meta> for Map<Next, Func>
where Next: Push<Out, Meta>, Func: FnMut(In) -> Out, Meta: Copy,

Source§

type Ctx<'ctx> = <Next as Push<Out, Meta>>::Ctx<'ctx>

Source§

type CanPend = <Next as Push<Out, Meta>>::CanPend

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,

Source§

type Ctx<'ctx> = <Next as Push<<IntoIter as IntoIterator>::Item, Meta>>::Ctx<'ctx>

Source§

type CanPend = <Next as Push<<IntoIter as IntoIterator>::Item, Meta>>::CanPend

Source§

impl<Next, Func, Item, Meta> Push<Item, Meta> for Filter<Next, Func>
where Next: Push<Item, Meta>, Func: FnMut(&Item) -> bool, Meta: Copy,

Source§

type Ctx<'ctx> = <Next as Push<Item, Meta>>::Ctx<'ctx>

Source§

type CanPend = <Next as Push<Item, Meta>>::CanPend

Source§

impl<Next, Func, Item, Meta> Push<Item, Meta> for Inspect<Next, Func>
where Next: Push<Item, Meta>, Func: FnMut(&Item), Meta: Copy,

Source§

type Ctx<'ctx> = <Next as Push<Item, Meta>>::Ctx<'ctx>

Source§

type CanPend = <Next as Push<Item, Meta>>::CanPend

Source§

impl<Next, Func, St, In, Meta> Push<In, Meta> for FlatMapStream<Next, Func, St, Meta>
where Next: Push<St::Item, Meta>, Func: FnMut(In) -> St, St: Stream, Meta: Copy,

Source§

type Ctx<'ctx> = Context<'ctx>

Source§

type CanPend = Yes

Source§

impl<Next, IntoIter, Meta> Push<IntoIter, Meta> for Flatten<Next, IntoIter, Meta>
where Next: Push<IntoIter::Item, Meta>, IntoIter: IntoIterator, Meta: Copy,

Source§

type Ctx<'ctx> = <Next as Push<<IntoIter as IntoIterator>::Item, Meta>>::Ctx<'ctx>

Source§

type CanPend = <Next as Push<<IntoIter as IntoIterator>::Item, Meta>>::CanPend

Source§

impl<Next, St, Meta> Push<St, Meta> for FlattenStream<Next, St, Meta>
where Next: Push<St::Item, Meta>, St: Stream, Meta: Copy,

Source§

type Ctx<'ctx> = Context<'ctx>

Source§

type CanPend = Yes

Source§

impl<P0, P1, Item0, Item1, Meta> Push<(Item0, Item1), Meta> for Unzip<P0, P1>
where P0: Push<Item0, Meta>, P1: Push<Item1, Meta>, Meta: Copy,

Source§

type Ctx<'ctx> = <<P0 as Push<Item0, Meta>>::Ctx<'ctx> as Context<'ctx>>::Merged<<P1 as Push<Item1, Meta>>::Ctx<'ctx>>

Source§

type CanPend = <<P0 as Push<Item0, Meta>>::CanPend as Toggle>::Or<<P1 as Push<Item1, Meta>>::CanPend>

Source§

impl<P0, P1, Item, Meta> Push<Item, Meta> for Fanout<P0, P1>
where P0: Push<Item, Meta>, P1: Push<Item, Meta>, Item: Clone, Meta: Copy,

Source§

type Ctx<'ctx> = <<P0 as Push<Item, Meta>>::Ctx<'ctx> as Context<'ctx>>::Merged<<P1 as Push<Item, Meta>>::Ctx<'ctx>>

Source§

type CanPend = <<P0 as Push<Item, Meta>>::CanPend as Toggle>::Or<<P1 as Push<Item, Meta>>::CanPend>

Source§

impl<Psh, Item, Buf> Push<Item, ()> for Persist<Psh, Buf>
where Psh: Push<Item, ()>, Item: Clone, Buf: BorrowMut<Vec<Item>>,

Available on crate feature alloc only.
Source§

type Ctx<'ctx> = <Psh as Push<Item, ()>>::Ctx<'ctx>

Source§

type CanPend = <Psh as Push<Item, ()>>::CanPend

Source§

impl<Psh, Queue, QueueInner, Fut> Push<Fut, ()> for ResolveFutures<Psh, Queue, QueueInner>
where Psh: Push<Fut::Output, ()>, Queue: BorrowMut<QueueInner>, QueueInner: Extend<Fut> + FusedStream<Item = Fut::Output> + Unpin, Fut: Future, for<'ctx> Psh::Ctx<'ctx>: Context<'ctx>,

Source§

type Ctx<'ctx> = Context<'ctx>

Source§

type CanPend = Yes

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.
Source§

type Ctx<'ctx> = <Pushes as PushVariadic<Item, Meta>>::Ctx<'ctx>

Source§

type CanPend = <Pushes as PushVariadic<Item, Meta>>::CanPend

Source§

impl<Si, Item, Meta> Push<Item, Meta> for Sink<Si>
where Si: Sink<Item>, Si::Error: Debug, Meta: Copy,

Source§

type Ctx<'ctx> = Context<'ctx>

Source§

type CanPend = Yes