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

Spawn a new Actor with a single Process. This will return a Child and and Address. The Process is spawned with a single Inbox.

Example

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