Trait appliance::Message[][src]

pub trait Message: Send {
    type Result: Send;
}

Message must be implemented for any type which is intended for sending to appliances.

Example

type Counter = Appliance<'static, usize>;

struct Ping;

impl Message for Ping { type Result = usize; }

impl Handler<Ping> for Counter {
    fn handle(&mut self, _msg: &Ping) -> usize {
        *self.state() += 1;
        *self.state()
    }
}

fn do_ping(descriptor: Descriptor<Counter>) {
    match descriptor.send_and_wait_with_timeout(Ping, Duration::from_secs(10)) {
        Ok(cnt) => println!("Appliance was pinged successfully {} times", *cnt),
        Err(err) => panic!("Ping to appliance has failed: {}", err),
    }
}

Associated Types

type Result: Send[src]

The type of replies generated by handling this message.

Loading content...

Implementors

Loading content...