Trait asyncplify::ParallelStream [] [src]

pub trait ParallelStream {
    type Item: Send;
    fn consume<C>(self, C) where C: ParallelConsumer<Self::Item>;

    fn filter<F>(self, predicate: F) -> ParallelFilter<Self, F> where Self: Sized, F: Send + Fn(&mut Self::Item) -> bool { ... }
    fn inspect<F>(self, func: F) -> ParallelInspect<Self, F> where F: Send + Sync + Fn(&mut Self::Item), Self: Sized { ... }
    fn max(self) -> ParallelMax<Self> where Self: Sized { ... }
    fn max_by_key<F, K>(self, f: F) -> ParallelMaxByKey<Self, F> where Self: Sized, F: Send + Sync + Fn(&Self::Item) -> K, K: PartialOrd + Send { ... }
    fn min_by_key<F, K>(self, f: F) -> ParallelMinByKey<Self, F> where Self: Sized, F: Send + Sync + Fn(&Self::Item) -> K, K: PartialOrd + Send { ... }
    fn observe_on<SC>(self, scheduler: SC) -> ParallelObserveOn<Self, SC> where SC: ParallelScheduler, Self: Sized { ... }
    fn subscribe(self) where Self: Sized { ... }
    fn subscribe_action<F>(self, action: F) where Self: Sized, F: Fn(Self::Item) + Send + Sync { ... }
    fn subscribe_func<F>(self, predicate: F) where Self: Sized, F: Send + Sync + Fn(Self::Item) -> bool { ... }
}

Associated Types

type Item: Send

Required Methods

fn consume<C>(self, C) where C: ParallelConsumer<Self::Item>

Provided Methods

fn filter<F>(self, predicate: F) -> ParallelFilter<Self, F> where Self: Sized, F: Send + Fn(&mut Self::Item) -> bool

Creates a stream which uses a closure to determine if an element should be emitted. The closure must return true or false. filter() creates a stream which calls this closure on each element. If the closure returns true, then the element is returned. If the closure returns false, it will try again, and call the closure on the next element, seeing if it passes the test.

Examples

use asyncplify::*;
use asyncplify::schedulers::*;

(0..4)
    .into_stream()
    .observe_on_parallel(EventLoop::new())
    .filter(|v| *v > 2)
    .subscribe_action(|v| assert!(v == 3, "v = {:?}", v))

fn inspect<F>(self, func: F) -> ParallelInspect<Self, F> where F: Send + Sync + Fn(&mut Self::Item), Self: Sized

Do something with each element of a stream, passing the value on. This is usefull to debug an item.

fn max(self) -> ParallelMax<Self> where Self: Sized

Returns the maximum element of a stream. Returns the lastest element if the comparison determines two elements to be equally maximum.

Examples

use asyncplify::*;
use asyncplify::schedulers::*;

(0..10)
    .into_stream()
    .observe_on_parallel(EventLoop::new())
    .max()
    .subscribe_action(|v| assert!(v == 9, "v = {}", v));

fn max_by_key<F, K>(self, f: F) -> ParallelMaxByKey<Self, F> where Self: Sized, F: Send + Sync + Fn(&Self::Item) -> K, K: PartialOrd + Send

Returns the element that gives the maximum value from the specified function. Returns the lastest element if the comparison determines two elements to be equally maximum.

Examples

use asyncplify::*;
use asyncplify::schedulers::*;

(0..10)
    .into_stream()
    .observe_on_parallel(EventLoop::new())
    .max_by_key(|v| *v)
    .subscribe_action(|v| assert!(v == 9, "v = {}", v));

fn min_by_key<F, K>(self, f: F) -> ParallelMinByKey<Self, F> where Self: Sized, F: Send + Sync + Fn(&Self::Item) -> K, K: PartialOrd + Send

Returns the element that gives the minimum value from the specified function. Returns the lastest element if the comparison determines two elements to be equally minimum.

Examples

use asyncplify::*;
use asyncplify::schedulers::*;

(0..10)
    .into_stream()
    .observe_on_parallel(EventLoop::new())
    .min_by_key(|v| 10 - *v)
    .subscribe_action(|v| assert!(v == 9, "v = {}", v));

fn observe_on<SC>(self, scheduler: SC) -> ParallelObserveOn<Self, SC> where SC: ParallelScheduler, Self: Sized

fn subscribe(self) where Self: Sized

fn subscribe_action<F>(self, action: F) where Self: Sized, F: Fn(Self::Item) + Send + Sync

fn subscribe_func<F>(self, predicate: F) where Self: Sized, F: Send + Sync + Fn(Self::Item) -> bool

Implementors