ActorSync

Trait ActorSync 

Source
pub trait ActorSync<E>: Send + 'static {
    // Required method
    fn run_blocking(&mut self) -> Result<(), E>;
}
Expand description

Blocking actor trait. Loop receiving actions with recv() and executing them with block_on().

§Example

impl ActorSync<io::Error> for MyActor {
    fn run_blocking(&mut self) -> io::Result<()> {
        while let Ok(action) = self.rx.recv() {
            block_on(action(self));
        }
        Err(io::Error::new(io::ErrorKind::Other, "Actor stopped"))
    }
}

Required Methods§

Source

fn run_blocking(&mut self) -> Result<(), E>

Implementors§