Trait LinkFuture

Source
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§

Source

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,

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.

Source

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,

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.

Source

fn send_future<F, M>(&self, future: F)
where M: Into<Self::Message>, F: Future<Output = M> + 'static,

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.

Source

fn send_future_batch<F>(&self, future: F)
where F: Future<Output = Vec<Self::Message>> + 'static,

Registers a future that resolves to multiple messages.

§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.

Implementations on Foreign Types§

Source§

impl<AGN: Agent> LinkFuture for AgentLink<AGN>

Source§

type Message = <AGN as Agent>::Message

Source§

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,

Source§

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,

Source§

fn send_future<F, M>(&self, future: F)
where M: Into<Self::Message>, F: Future<Output = M> + 'static,

Source§

fn send_future_batch<F>(&self, _future: F)
where F: Future<Output = Vec<Self::Message>> + 'static,

Source§

impl<COMP: Component> LinkFuture for ComponentLink<COMP>

Source§

type Message = <COMP as Component>::Message

Source§

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,

Source§

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,

Source§

fn send_future<F, M>(&self, future: F)
where M: Into<Self::Message>, F: Future<Output = M> + 'static,

Source§

fn send_future_batch<F>(&self, future: F)
where F: Future<Output = Vec<Self::Message>> + 'static,

Implementors§