Enum plumbum::ConduitM
[−]
[src]
pub enum ConduitM<'a, I, O, A> { Pure(Box<A>), Defer(Kleisli<'a, (), I, O, A>), Await(Kleisli<'a, Option<I>, I, O, A>), Yield(Box<O>, Kleisli<'a, (), I, O, A>), Leftover(Box<I>, Kleisli<'a, (), I, O, A>), }
Represents a conduit, i.e. a sequence of await/yield actions.
I
is the type of values the conduit consumes from upstream.O
is the type of values the conduit passes downstream.A
is the return type of the conduit.
Variants
Pure(Box<A>)
The case Pure(a)
means that the conduit contains no further actions and just returns the result a
.
Defer(Kleisli<'a, (), I, O, A>)
The case Defer(k)
means that the conduit needs another iteration to make progress,
and the remaining (suspended) program is given by the kleisli arrow k
Await(Kleisli<'a, Option<I>, I, O, A>)
The case Await(k)
means that the conduit waits for a value of type I
,
and the remaining (suspended) program is given by the kleisli arrow k
.
Yield(Box<O>, Kleisli<'a, (), I, O, A>)
The case Yield(o, k)
means that the conduit yields a value of type O
,
and the remaining (suspended) program is given by the kleisli arrow k
.
Leftover(Box<I>, Kleisli<'a, (), I, O, A>)
The case Leftover(i, k)
means that the conduit has a leftover value of type I
,
and the remaining (suspended) program is given by the kleisli arrow k
.
Methods
impl<'a, O> ConduitM<'a, (), O, ()>
[src]
fn to_producer<I>(self) -> ConduitM<'a, I, O, ()> where O: 'static
Generalize a Source
by universally quantifying the input type.
fn connect<A>(self, sink: Sink<'a, O, A>) -> A where O: 'static
Pulls data from the source and pushes it into the sink.
Example
use std::iter::FromIterator; use plumbum::{Source, Sink, produce}; let src = Source::from_iter(vec![42, 43]); let sink = Sink::fold(0, |x, y| x + y); assert_eq!(src.connect(sink), 85);
impl<'a, I, O> ConduitM<'a, I, O, ()>
[src]
fn fuse<P, A>(self, other: ConduitM<'a, O, P, A>) -> ConduitM<'a, I, P, A> where I: 'static, O: 'static, P: 'static, A: 'a
Combines two conduits together into a new conduit.
Example
use std::iter::FromIterator; use plumbum::{Conduit, Source, Sink}; let src = Source::from_iter(vec![42, 43]); let conduit = Conduit::transform(|x| 1 + x); let sink = Sink::fold(0, |x, y| x + y); assert_eq!(src.fuse(conduit).connect(sink), 87);
fn transform<F>(f: F) -> Self where F: 'a + Fn(I) -> O
Apply a transformation to all values in a stream.
impl<'a, I, A> ConduitM<'a, I, Void, A>
[src]
fn to_consumer<O>(self) -> ConduitM<'a, I, O, A>
Generalize a Sink
by universally quantifying the output type.
fn fold<F>(a: A, f: F) -> Self where A: 'a, F: 'a + Fn(A, I) -> A
Fold all values from upstream into a final value.
impl<'a, I, O, A> ConduitM<'a, I, O, A>
[src]
fn and_then<B, F>(self, js: F) -> ConduitM<'a, I, O, B> where F: 'a + FnOnce(A) -> ConduitM<'a, I, O, B>
Appends a continuation to a conduit. Which means,
given a function from A
to ConduitM<I, O, B>
,
passes the return value of the conduit to the function,
and returns the resulting program.
fn and<B: 'a>(self, other: ConduitM<'a, I, O, B>) -> ConduitM<'a, I, O, B> where I: 'a, O: 'a
Appends two conduits together, which means, it returns a new conduit that executes both conduits sequentially, and forwards the return value of the second.
fn zip<B: 'a>(self, other: ConduitM<'a, I, O, B>) -> ConduitM<'a, I, O, (A, B)> where A: 'a, I: 'a, O: 'a
Zips two conduits together, which means, it returns a new conduit that executes both conduits sequentially, and forwards both return values.
fn map<B, F>(self, f: F) -> ConduitM<'a, I, O, B> where F: 'a + FnOnce(A) -> B
Modifies the return value of the conduit.
Seen differently, it lifts a function from
A
to B
into a function from ConduitM<I, O, A>
to ConduitM<I, O, B>
.
Trait Implementations
impl<'a, I, O: 'a> FromIterator<O> for ConduitM<'a, I, O, ()>
[src]
fn from_iter<T: IntoIterator<Item=O>>(iterator: T) -> Self
Creates a value from an iterator. Read more
impl<'a, I, O, A: PartialEq> PartialEq for ConduitM<'a, I, O, A>
[src]
fn eq(&self, other: &ConduitM<'a, I, O, A>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.