SinkBuild

Trait SinkBuild 

Source
pub trait SinkBuild {
    type Item;
    type Output<Next: Sink<Self::Item>>;

Show 13 methods // Required method fn send_to<Next>(self, next: Next) -> Self::Output<Next> where Next: Sink<Self::Item>; // Provided methods fn fanout<Si0, Si1>( self, sink0: Si0, sink1: Si1, ) -> Self::Output<Fanout<Si0, Si1>> where Self: Sized, Self::Item: Clone, Si0: Sink<Self::Item>, Si1: Sink<Self::Item, Error = Si0::Error> { ... } fn for_each<Func>(self, func: Func) -> Self::Output<ForEach<Func>> where Self: Sized, Func: FnMut(Self::Item) { ... } fn try_for_each<Func, Error>( self, func: Func, ) -> Self::Output<TryForEach<Func>> where Self: Sized, Func: FnMut(Self::Item) -> Result<(), Error> { ... } fn map<Func, Out>(self, func: Func) -> MapBuilder<Self, Func> where Self: Sized, Func: FnMut(Self::Item) -> Out { ... } fn filter<Func>(self, func: Func) -> FilterBuilder<Self, Func> where Self: Sized, Func: FnMut(&Self::Item) -> bool { ... } fn filter_map<Func, Out>(self, func: Func) -> FilterMapBuilder<Self, Func> where Self: Sized, Func: FnMut(Self::Item) -> Option<Out> { ... } fn flat_map<Func, IntoIter>(self, func: Func) -> FlatMapBuilder<Self, Func> where Self: Sized, Func: FnMut(Self::Item) -> IntoIter, IntoIter: IntoIterator { ... } fn flatten<IntoIter>(self) -> FlattenBuilder<Self> where Self: Sized, Self::Item: IntoIterator { ... } fn inspect<Func>(self, func: Func) -> InspectBuilder<Self, Func> where Self: Sized, Func: FnMut(&Self::Item) { ... } fn unzip<Si0, Si1, Item0, Item1>( self, sink0: Si0, sink1: Si1, ) -> Self::Output<Unzip<Si0, Si1>> where Self: Sized + SinkBuild<Item = (Item0, Item1)>, Si0: Sink<Item0>, Si1: Sink<Item1>, Si0::Error: From<Si1::Error> { ... } fn demux_map<Key, ItemVal, Si>( self, sinks: impl Into<HashMap<Key, Si>>, ) -> Self::Output<DemuxMap<Key, Si>> where Self: Sized + SinkBuild<Item = (Key, ItemVal)>, Key: Eq + Hash + Debug + Unpin, Si: Sink<ItemVal> + Unpin { ... } fn demux_var<Sinks, ItemVal, Error>( self, sinks: Sinks, ) -> Self::Output<DemuxVar<Sinks, Error>> where Self: Sized + SinkBuild<Item = (usize, ItemVal)>, Sinks: SinkVariadic<ItemVal, Error> { ... }
}
Expand description

A helper trait for building Sinks in forward order, unlike with Sinktools.

To start a sink adaptor chain, use SinkBuilder.

Required Associated Types§

Source

type Item

The output item type.

Source

type Output<Next: Sink<Self::Item>>

The output Sink type, if it is prepended to Next.

Required Methods§

Source

fn send_to<Next>(self, next: Next) -> Self::Output<Next>
where Next: Sink<Self::Item>,

Complete this sink adaptor chain by connecting it to next as the output.

This method may be used directly if you’re trying to connect to an existing sink. Otherwise, use methods like Self::for_each directly to complete a chain.

Provided Methods§

Source

fn fanout<Si0, Si1>( self, sink0: Si0, sink1: Si1, ) -> Self::Output<Fanout<Si0, Si1>>
where Self: Sized, Self::Item: Clone, Si0: Sink<Self::Item>, Si1: Sink<Self::Item, Error = Si0::Error>,

Clone each item and send to both sink0 and sink1, completing this sink adaptor chain.

Source

fn for_each<Func>(self, func: Func) -> Self::Output<ForEach<Func>>
where Self: Sized, Func: FnMut(Self::Item),

Appends a function which consumes each element, completing this sink adaptor chain.

Source

fn try_for_each<Func, Error>(self, func: Func) -> Self::Output<TryForEach<Func>>
where Self: Sized, Func: FnMut(Self::Item) -> Result<(), Error>,

Appends a function which consumes each element and returns a result, completing this sink adaptor chain.

Source

fn map<Func, Out>(self, func: Func) -> MapBuilder<Self, Func>
where Self: Sized, Func: FnMut(Self::Item) -> Out,

Appends a function which is called on each element and pases along each output.

Source

fn filter<Func>(self, func: Func) -> FilterBuilder<Self, Func>
where Self: Sized, Func: FnMut(&Self::Item) -> bool,

Appends a predicate function which filters items.

Source

fn filter_map<Func, Out>(self, func: Func) -> FilterMapBuilder<Self, Func>
where Self: Sized, Func: FnMut(Self::Item) -> Option<Out>,

Appends a function which both filters and maps items.

Source

fn flat_map<Func, IntoIter>(self, func: Func) -> FlatMapBuilder<Self, Func>
where Self: Sized, Func: FnMut(Self::Item) -> IntoIter, IntoIter: IntoIterator,

Appends a function which maps each item to an iterator and flattens the results.

Source

fn flatten<IntoIter>(self) -> FlattenBuilder<Self>
where Self: Sized, Self::Item: IntoIterator,

Flattens items that are iterators.

Source

fn inspect<Func>(self, func: Func) -> InspectBuilder<Self, Func>
where Self: Sized, Func: FnMut(&Self::Item),

Appends a function which inspects each item without modifying it.

Source

fn unzip<Si0, Si1, Item0, Item1>( self, sink0: Si0, sink1: Si1, ) -> Self::Output<Unzip<Si0, Si1>>
where Self: Sized + SinkBuild<Item = (Item0, Item1)>, Si0: Sink<Item0>, Si1: Sink<Item1>, Si0::Error: From<Si1::Error>,

Splits items into two sinks based on tuple structure.

Source

fn demux_map<Key, ItemVal, Si>( self, sinks: impl Into<HashMap<Key, Si>>, ) -> Self::Output<DemuxMap<Key, Si>>
where Self: Sized + SinkBuild<Item = (Key, ItemVal)>, Key: Eq + Hash + Debug + Unpin, Si: Sink<ItemVal> + Unpin,

Available on crate feature std only.

Sends each item into one sink depending on the key, where the sinks are in a HashMap.

This requires sinks Si to be Unpin. If your sinks are not Unpin, first wrap them in Box::pin to make them Unpin.

Source

fn demux_var<Sinks, ItemVal, Error>( self, sinks: Sinks, ) -> Self::Output<DemuxVar<Sinks, Error>>
where Self: Sized + SinkBuild<Item = (usize, ItemVal)>, Sinks: SinkVariadic<ItemVal, Error>,

Available on crate feature variadics only.

Sends each item into one sink depending on the index, where the sinks are a variadic.

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.

Implementors§

Source§

impl<Item> SinkBuild for SinkBuilder<Item>

Source§

type Item = Item

Source§

type Output<Next: Sink<Self::Item>> = Next

Source§

impl<Iter> SinkBuild for SendIterBuild<Iter>
where Iter: Iterator,

Source§

type Item = <Iter as Iterator>::Item

Source§

type Output<Next: Sink<Self::Item>> = SendIter<Iter, Next>

Source§

impl<Prev> SinkBuild for FlattenBuilder<Prev>
where Prev: SinkBuild, Prev::Item: IntoIterator,

Source§

type Item = <<Prev as SinkBuild>::Item as IntoIterator>::Item

Source§

type Output<Next: Sink<Self::Item>> = <Prev as SinkBuild>::Output<Flatten<Next, <Prev as SinkBuild>::Item>>

Source§

impl<Prev, Func> SinkBuild for FilterBuilder<Prev, Func>
where Prev: SinkBuild, Func: FnMut(&Prev::Item) -> bool,

Source§

type Item = <Prev as SinkBuild>::Item

Source§

type Output<Next: Sink<Prev::Item>> = <Prev as SinkBuild>::Output<Filter<Next, Func>>

Source§

impl<Prev, Func> SinkBuild for InspectBuilder<Prev, Func>
where Prev: SinkBuild, Func: FnMut(&Prev::Item),

Source§

type Item = <Prev as SinkBuild>::Item

Source§

type Output<Next: Sink<Prev::Item>> = <Prev as SinkBuild>::Output<Inspect<Next, Func>>

Source§

impl<Prev, Func, IntoIter> SinkBuild for FlatMapBuilder<Prev, Func>
where Prev: SinkBuild, Func: FnMut(Prev::Item) -> IntoIter, IntoIter: IntoIterator,

Source§

type Item = <IntoIter as IntoIterator>::Item

Source§

type Output<Next: Sink<IntoIter::Item>> = <Prev as SinkBuild>::Output<FlatMap<Next, Func, IntoIter>>

Source§

impl<Prev, ItemOut, Func> SinkBuild for FilterMapBuilder<Prev, Func>
where Prev: SinkBuild, Func: FnMut(Prev::Item) -> Option<ItemOut>,

Source§

type Item = ItemOut

Source§

type Output<Next: Sink<ItemOut>> = <Prev as SinkBuild>::Output<FilterMap<Next, Func>>

Source§

impl<Prev, ItemOut, Func> SinkBuild for MapBuilder<Prev, Func>
where Prev: SinkBuild, Func: FnMut(Prev::Item) -> ItemOut,

Source§

type Item = ItemOut

Source§

type Output<Next: Sink<ItemOut>> = <Prev as SinkBuild>::Output<Map<Next, Func>>

Source§

impl<St> SinkBuild for SendStreamBuild<St>
where St: Stream,

Source§

type Item = <St as Stream>::Item

Source§

type Output<Next: Sink<Self::Item>> = SendStream<St, Next>