pub trait EventListener: Send + Sync {
// Required methods
fn on_event(&self, event_json: String);
fn on_answer_chunk(&self, text: String);
fn on_finish(&self, result_json: String);
}Expand description
Receives the events of one run. Implemented in the host language.
Callbacks run on a background thread; marshal to your UI thread yourself. Exceptions thrown by a callback are swallowed so they cannot break the run.
Required Methods§
Sourcefn on_event(&self, event_json: String)
fn on_event(&self, event_json: String)
Every raw engine event, as JSON ({"type": "node_started", ...}).
Sourcefn on_answer_chunk(&self, text: String)
fn on_answer_chunk(&self, text: String)
Ordered user-facing answer text (answer nodes), streamed as it is produced.
Sourcefn on_finish(&self, result_json: String)
fn on_finish(&self, result_json: String)
Called exactly once with the final result (see RunHandle::wait_json).
Trait Implementations§
Source§impl<T> FfiConverterArc<T> for dyn EventListener
impl<T> FfiConverterArc<T> for dyn EventListener
Source§impl<T> LiftRef<T> for dyn EventListener
impl<T> LiftRef<T> for dyn EventListener
type LiftType = Arc<dyn EventListener>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".