[][src]Struct mogwai::txrx::Transmitter

pub struct Transmitter<A> { /* fields omitted */ }

Send messages instantly.

Implementations

impl<A: 'static> Transmitter<A>[src]

pub fn new() -> Transmitter<A>[src]

Create a new transmitter.

pub fn spawn_recv(&mut self) -> Receiver<A>[src]

Spawn a receiver for this transmitter.

pub fn send(&self, a: &A)[src]

Send a message to any and all receivers of this transmitter.

pub fn send_async<FutureA>(&self, fa: FutureA) where
    FutureA: Future<Output = A> + 'static, 
[src]

Execute a future that results in a message, then send it.

pub fn contra_filter_fold_shared<B, T, F>(
    &self,
    var: Rc<RefCell<T>>,
    f: F
) -> Transmitter<B> where
    B: 'static,
    T: 'static,
    F: Fn(&mut T, &B) -> Option<A> + 'static, 
[src]

Extend this transmitter with a new transmitter using a filtering fold function. The given function folds messages of B over a shared state T and optionally sends As down into this transmitter.

pub fn contra_filter_fold<B, X, T, F>(&self, init: X, f: F) -> Transmitter<B> where
    B: 'static,
    T: 'static,
    X: Into<T>,
    F: Fn(&mut T, &B) -> Option<A> + 'static, 
[src]

Extend this transmitter with a new transmitter using a filtering fold function. The given function folds messages of B over a state T and optionally sends As into this transmitter.

pub fn contra_fold<B, X, T, F>(&self, init: X, f: F) -> Transmitter<B> where
    B: 'static,
    T: 'static,
    X: Into<T>,
    F: Fn(&mut T, &B) -> A + 'static, 
[src]

Extend this transmitter with a new transmitter using a fold function. The given function folds messages of B into a state T and sends As into this transmitter.

pub fn contra_filter_map<B, F>(&self, f: F) -> Transmitter<B> where
    B: 'static,
    F: Fn(&B) -> Option<A> + 'static, 
[src]

Extend this transmitter with a new transmitter using a filter function. The given function maps messages of B and optionally sends As into this transmitter.

pub fn contra_map<B, F>(&self, f: F) -> Transmitter<B> where
    B: 'static,
    F: Fn(&B) -> A + 'static, 
[src]

Extend this transmitter with a new transmitter using a map function. The given function maps messages of B into As and sends them all into this transmitter. This is much like Haskell's contramap, hence the contra_ prefix on this family of methods.

pub fn wire_filter_fold_shared<T, B, F>(
    &mut self,
    rb: &Receiver<B>,
    var: Rc<RefCell<T>>,
    f: F
) where
    B: 'static,
    T: 'static,
    F: Fn(&mut T, &A) -> Option<B> + 'static, 
[src]

Wires the transmitter to send to the given receiver using a stateful fold function, where the state is a shared mutex.

The fold function returns an Option<B>. In the case that the value of Option<B> is None, no message will be sent to the receiver.

pub fn wire_filter_fold<T, B, X, F>(&mut self, rb: &Receiver<B>, init: X, f: F) where
    B: 'static,
    T: 'static,
    X: Into<T>,
    F: Fn(&mut T, &A) -> Option<B> + 'static, 
[src]

Wires the transmitter to send to the given receiver using a stateful fold function.

The fold function returns an Option<B>. In the case that the value of Option<B> is None, no message will be sent to the receiver.

pub fn wire_fold<T, B, X, F>(&mut self, rb: &Receiver<B>, init: X, f: F) where
    B: 'static,
    T: 'static,
    X: Into<T>,
    F: Fn(&mut T, &A) -> B + 'static, 
[src]

Wires the transmitter to send to the given receiver using a stateful fold function.

pub fn wire_fold_shared<T, B, F>(
    &mut self,
    rb: &Receiver<B>,
    var: Rc<RefCell<T>>,
    f: F
) where
    B: 'static,
    T: 'static,
    F: Fn(&mut T, &A) -> B + 'static, 
[src]

Wires the transmitter to send to the given receiver using a stateful fold function, where the state is a shared mutex.

pub fn wire_filter_map<B, F>(&mut self, rb: &Receiver<B>, f: F) where
    B: 'static,
    F: Fn(&A) -> Option<B> + 'static, 
[src]

Wires the transmitter to the given receiver using a stateless map function. If the map function returns None for any messages those messages will not be sent to the given transmitter.

pub fn wire_map<B, F>(&mut self, rb: &Receiver<B>, f: F) where
    B: 'static,
    F: Fn(&A) -> B + 'static, 
[src]

Wires the transmitter to the given receiver using a stateless map function.

pub fn wire_filter_fold_async<T, B, X, F, H>(
    &mut self,
    rb: &Receiver<B>,
    init: X,
    f: F,
    h: H
) where
    B: 'static,
    T: 'static,
    X: Into<T>,
    F: Fn(&mut T, &A) -> Option<RecvFuture<B>> + 'static,
    H: Fn(&mut T, &Option<B>) + 'static, 
[src]

Wires the transmitter to the given receiver using a stateful fold function that returns an optional future. The future, if available, results in an Option<B>. In the case that the value of the future's result is None, no message will be sent to the given receiver.

Lastly, a clean up function is ran at the completion of the future with its result.

To aid in returning a viable future in your fold function, use wrap_future.

Trait Implementations

impl<A> Clone for Transmitter<A>[src]

Auto Trait Implementations

impl<A> !RefUnwindSafe for Transmitter<A>

impl<A> !Send for Transmitter<A>

impl<A> !Sync for Transmitter<A>

impl<A> Unpin for Transmitter<A>

impl<A> !UnwindSafe for Transmitter<A>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.