atomr-core 0.1.0

Actors, supervision, dispatch, mailboxes, scheduler, FSM, event stream, and coordinated shutdown — the core of the atomr actor runtime.
Documentation
//! Re-export of the `ask` pattern. Mirrors akka.net `AskSupport.cs`.
//!
//! The primary API lives on [`crate::actor::ActorRef::ask_with`]; this free
//! function is a convenience wrapper so users can write
//! `ask(&target, |reply| Msg::Query(reply), Duration::from_secs(1)).await`.

use std::time::Duration;

use tokio::sync::oneshot;

use crate::actor::{ActorRef, AskError};

pub async fn ask<M: Send + 'static, R: Send + 'static, F>(
    target: &ActorRef<M>,
    build: F,
    timeout: Duration,
) -> Result<R, AskError>
where
    F: FnOnce(oneshot::Sender<R>) -> M,
{
    target.ask_with(build, timeout).await
}