Trait Will

Source
pub trait Will<T>:
    Send
    + Sync
    + 'static {
    // Required methods
    fn is_started(&mut self) -> bool;
    fn is_alive(&mut self) -> bool;
    fn start(&mut self);
    fn stop(&mut self);
    fn add_callback(&mut self, subscription: Arc<SubscriptionFunc<T>>);
    fn remove_callback(&mut self, subscription: Arc<SubscriptionFunc<T>>);
    fn result(&mut self) -> Option<T>;
}
Expand description

Will trait defines the interface which could do actions in its Handler.

§Remarks

This is highly inspired by Java Future concepts.

Required Methods§

Source

fn is_started(&mut self) -> bool

Did this Will start? Return true when it did started (no matter it has stopped or not)

Source

fn is_alive(&mut self) -> bool

Is this Will alive? Return true when it has started and not stopped yet.

Source

fn start(&mut self)

Start Will.

Source

fn stop(&mut self)

Stop Will.

Source

fn add_callback(&mut self, subscription: Arc<SubscriptionFunc<T>>)

Add a callback called when it has completed.

§Arguments
  • subscription - The callback. ``
Source

fn remove_callback(&mut self, subscription: Arc<SubscriptionFunc<T>>)

Remove a callback called when it has completed.

§Arguments
  • subscription - The callback. ``
Source

fn result(&mut self) -> Option<T>

Get the result.

Implementors§

Source§

impl<T> Will<T> for WillAsync<T>
where T: Clone + Send + Sync + 'static,