Skip to main content

MessageCallback

Type Alias MessageCallback 

Source
pub type MessageCallback = Arc<dyn Fn(Message) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>;
Expand description

Callback invoked for each message received from the agent.

Used for side effects (logging, UI updates, persistence) while the primary message stream is consumed by the caller.

§Thread Safety

MessageCallback is Send + Sync, so it can be safely shared across threads and tasks via Arc::clone.

§Creating Callbacks

Use sync_callback for synchronous side effects, or construct directly with Arc::new(|msg| Box::pin(async move { ... })) for async work.

Aliased Type§

pub struct MessageCallback { /* private fields */ }