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

The case Pure(a) means that the conduit contains no further actions and just returns the result 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

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.

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.

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]

Generalize a Source by universally quantifying the input type.

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]

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);

Apply a transformation to all values in a stream.

impl<'a, I, A> ConduitM<'a, I, Void, A>
[src]

Generalize a Sink by universally quantifying the output type.

Fold all values from upstream into a final value.

impl<'a, I, O, A> ConduitM<'a, I, O, A>
[src]

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.

Appends two conduits together, which means, it returns a new conduit that executes both conduits sequentially, and forwards the return value of the second.

Zips two conduits together, which means, it returns a new conduit that executes both conduits sequentially, and forwards both return values.

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> Extend<O> for ConduitM<'a, I, O, ()>
[src]

Extends a collection with the contents of an iterator. Read more

impl<'a, I, O: 'a> FromIterator<O> for ConduitM<'a, I, O, ()>
[src]

Creates a value from an iterator. Read more

impl<'a, I, O, A: PartialEq> PartialEq for ConduitM<'a, I, O, A>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a, I, O, A: Debug> Debug for ConduitM<'a, I, O, A>
[src]

Formats the value using the given formatter.

impl<'a, I, O, A> From<A> for ConduitM<'a, I, O, A>
[src]

Performs the conversion.