pub trait LinkFuture {
type Message;
// Required methods
fn callback_future<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>
where M: Into<Self::Message>,
FU: Future<Output = M> + 'static,
FN: Fn(IN) -> FU + 'static;
fn callback_future_once<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>
where M: Into<Self::Message>,
FU: Future<Output = M> + 'static,
FN: FnOnce(IN) -> FU + 'static;
fn send_future<F, M>(&self, future: F)
where M: Into<Self::Message>,
F: Future<Output = M> + 'static;
fn send_future_batch<F>(&self, future: F)
where F: Future<Output = Vec<Self::Message>> + 'static;
}
Expand description
Trait that allows you to use ComponentLink
and AgentLink
to register futures.
Required Associated Types§
Required Methods§
Sourcefn callback_future<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>
fn callback_future<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>
This method creates a Callback
which returns a Future which
returns a message to be sent back to the component’s event
loop.
§Panics
If the future panics, then the promise will not resolve, and will leak.
Sourcefn callback_future_once<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>
fn callback_future_once<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>
This method creates a Callback
from FnOnce
which returns a Future
which returns a message to be sent back to the component’s event
loop.
§Panics
If the future panics, then the promise will not resolve, and will leak.
Sourcefn send_future<F, M>(&self, future: F)
fn send_future<F, M>(&self, future: F)
This method processes a Future that returns a message and sends it back to the component’s loop.
§Panics
If the future panics, then the promise will not resolve, and will leak.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.