spawn

Function spawn 

Source
pub fn spawn<M, E, Fun, Fut>(
    config: Config,
    fun: Fun,
) -> (Child<E, Channel<M>>, Address<Channel<M>>)
where Fun: FnOnce(Inbox<M>) -> Fut + Send + 'static, Fut: Future<Output = E> + Send + 'static, E: Send + 'static, M: Send + 'static,
Expand description

Spawn a new actor with a single process, this returns a Child and an Address.

ยงExample

let (child, address) =
    spawn(Config::default(), |mut inbox: Inbox<u32>| async move {
        loop {
            let msg = inbox.recv().await;
            println!("Received message: {msg:?}");
        }
    });