Skip to main content

sync_callback

Function sync_callback 

Source
pub fn sync_callback<F>(f: F) -> MessageCallback
where F: Fn(Message) + Send + Sync + 'static,
Expand description

Wrap a synchronous closure in a MessageCallback.

This is the ergonomic constructor for callbacks that perform only synchronous work. The closure receives ownership of each Message and returns immediately; the resulting future resolves in a single poll.

ยงExample

use gemini_cli_sdk::callback::sync_callback;

let cb = sync_callback(|msg| {
    println!("message for session {:?}", msg.session_id());
});