Skip to main content

PushVariadic

Trait PushVariadic 

Source
pub trait PushVariadic<Item, Meta>: Variadic + Sealed<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>, idx: usize, 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>)); }
Available on crate feature variadics only.
Expand description

A variadic of Pushes for use with DemuxVar.

This sealed trait is implemented recursively for variadic tuples (P, Rest) where P: Push and Rest: PushVariadic, with the base case ().

The Ctx GAT is built by recursively merging each push’s context type: for (P0, (P1, (P2, ()))), the merged context is <P0::Ctx as Context>::Merged<<P1::Ctx as Context>::Merged<P2::Ctx>>.

The CanPend type is built by recursively OR-ing each push’s CanPend via Toggle::Or.

Required Associated Types§

Source

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

The merged context type for all pushes in this variadic.

Built recursively via Context::Merged so that each downstream push’s context can be extracted with Context::unmerge_self and Context::unmerge_other.

Source

type CanPend: Toggle

Whether any downstream push can return PushStep::Pending.

Built recursively via Toggle::Or: if any downstream push has CanPend = Yes, then the variadic also has CanPend = Yes.

Required Methods§

Source

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

Poll readiness of all downstream pushes.

Calls Push::poll_ready on each push, passing the appropriate unmerged context slice. All pushes are polled even if one returns pending, so that all wakers are registered.

Source

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

Send an item to the push at index idx.

§Panics

Panics if idx is out of bounds (greater than or equal to the number of pushes).

Source

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

Flush all downstream pushes.

Calls Push::poll_flush on each push, passing the appropriate unmerged context slice. All pushes are flushed even if one returns pending, so that all wakers are registered.

Source

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

Inform all downstream pushes that approximately hint items are about to be sent.

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<Item, Meta> PushVariadic<Item, Meta> for ()
where Meta: Copy,

Base case: the empty variadic. Always ready, panics on send.

Source§

type Ctx<'ctx> = ()

Source§

type CanPend = Infallible

Source§

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

Source§

fn start_send(self: Pin<&mut Self>, idx: usize, _item: Item, _meta: Meta)

Source§

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

Source§

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

Source§

impl<P, Item, Meta: Copy, Rest> PushVariadic<Item, Meta> for (P, Rest)
where P: Push<Item, Meta>, Rest: PushVariadic<Item, Meta>,

Recursive case: a push P followed by the rest of the variadic Rest.

Source§

type Ctx<'ctx> = <<P as Push<Item, Meta>>::Ctx<'ctx> as Context<'ctx>>::Merged<<Rest as PushVariadic<Item, Meta>>::Ctx<'ctx>>

Source§

type CanPend = <<P as Push<Item, Meta>>::CanPend as Toggle>::Or<<Rest as PushVariadic<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>, idx: usize, 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§