Struct relm_state::Relm
[−]
[src]
pub struct Relm<UPDATE: Update> { /* fields omitted */ }
Handle connection of futures to send messages to the update()
method.
Methods
impl<UPDATE: Update> Relm<UPDATE>
[src]
fn new(executor: Executor, stream: EventStream<UPDATE::Msg>) -> Self
Create a new relm stream handler.
fn connect<CALLBACK, FAILCALLBACK, STREAM, TOSTREAM>(
&self,
to_stream: TOSTREAM,
success_callback: CALLBACK,
failure_callback: FAILCALLBACK
) -> Box<Future<Item = (), Error = ()>> where
CALLBACK: Fn(STREAM::Item) -> UPDATE::Msg + 'static,
FAILCALLBACK: Fn(STREAM::Error) -> UPDATE::Msg + 'static,
STREAM: Stream + 'static,
TOSTREAM: ToStream<STREAM, Item = STREAM::Item, Error = STREAM::Error> + 'static,
UPDATE::Msg: 'static,
&self,
to_stream: TOSTREAM,
success_callback: CALLBACK,
failure_callback: FAILCALLBACK
) -> Box<Future<Item = (), Error = ()>> where
CALLBACK: Fn(STREAM::Item) -> UPDATE::Msg + 'static,
FAILCALLBACK: Fn(STREAM::Error) -> UPDATE::Msg + 'static,
STREAM: Stream + 'static,
TOSTREAM: ToStream<STREAM, Item = STREAM::Item, Error = STREAM::Error> + 'static,
UPDATE::Msg: 'static,
Connect a Future
or a Stream
called to_stream
to send the message success_callback
in case of success and failure_callback
in case of failure.
Note
This function does not spawn the future.
You'll usually want to use Relm::connect_exec()
to both connect and spawn the future.
fn connect_ignore_err<CALLBACK, STREAM, TOSTREAM>(
&self,
to_stream: TOSTREAM,
success_callback: CALLBACK
) -> Box<Future<Item = (), Error = ()>> where
CALLBACK: Fn(STREAM::Item) -> UPDATE::Msg + 'static,
STREAM: Stream + 'static,
TOSTREAM: ToStream<STREAM, Item = STREAM::Item, Error = STREAM::Error> + 'static,
UPDATE::Msg: 'static,
&self,
to_stream: TOSTREAM,
success_callback: CALLBACK
) -> Box<Future<Item = (), Error = ()>> where
CALLBACK: Fn(STREAM::Item) -> UPDATE::Msg + 'static,
STREAM: Stream + 'static,
TOSTREAM: ToStream<STREAM, Item = STREAM::Item, Error = STREAM::Error> + 'static,
UPDATE::Msg: 'static,
This function is the same as Relm::connect()
except it does not take a
failure_callback
; hence, it ignores the errors.
fn connect_exec<CALLBACK, FAILCALLBACK, STREAM, TOSTREAM>(
&self,
to_stream: TOSTREAM,
callback: CALLBACK,
failure_callback: FAILCALLBACK
) where
CALLBACK: Fn(STREAM::Item) -> UPDATE::Msg + 'static,
FAILCALLBACK: Fn(STREAM::Error) -> UPDATE::Msg + 'static,
STREAM: Stream + 'static,
TOSTREAM: ToStream<STREAM, Item = STREAM::Item, Error = STREAM::Error> + 'static,
UPDATE: 'static,
UPDATE::Msg: 'static,
&self,
to_stream: TOSTREAM,
callback: CALLBACK,
failure_callback: FAILCALLBACK
) where
CALLBACK: Fn(STREAM::Item) -> UPDATE::Msg + 'static,
FAILCALLBACK: Fn(STREAM::Error) -> UPDATE::Msg + 'static,
STREAM: Stream + 'static,
TOSTREAM: ToStream<STREAM, Item = STREAM::Item, Error = STREAM::Error> + 'static,
UPDATE: 'static,
UPDATE::Msg: 'static,
Connect the future to_stream
and spawn it on the tokio main loop.
fn connect_exec_ignore_err<CALLBACK, STREAM, TOSTREAM>(
&self,
to_stream: TOSTREAM,
callback: CALLBACK
) where
CALLBACK: Fn(STREAM::Item) -> UPDATE::Msg + 'static,
STREAM: Stream + 'static,
TOSTREAM: ToStream<STREAM, Item = STREAM::Item, Error = STREAM::Error> + 'static,
UPDATE: 'static,
UPDATE::Msg: 'static,
&self,
to_stream: TOSTREAM,
callback: CALLBACK
) where
CALLBACK: Fn(STREAM::Item) -> UPDATE::Msg + 'static,
STREAM: Stream + 'static,
TOSTREAM: ToStream<STREAM, Item = STREAM::Item, Error = STREAM::Error> + 'static,
UPDATE: 'static,
UPDATE::Msg: 'static,
Connect the future to_stream
and spawn it on the tokio main loop, ignoring any error.
fn exec<FUTURE: Future<Item = (), Error = ()> + 'static>(&self, future: FUTURE)
Spawn a future in the tokio event loop.
fn executor(&self) -> &Executor
Get the handle of this stream.
fn stream(&self) -> &EventStream<UPDATE::Msg>
Get the event stream of this stream. This is used internally by the library.
Trait Implementations
impl<UPDATE: Update> Clone for Relm<UPDATE>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more