Skip to main content

EventListener

Trait EventListener 

Source
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§

Source

fn on_event(&self, event_json: String)

Every raw engine event, as JSON ({"type": "node_started", ...}).

Source

fn on_answer_chunk(&self, text: String)

Ordered user-facing answer text (answer nodes), streamed as it is produced.

Source

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

Source§

const TYPE_ID_META: MetadataBuffer

Source§

type FfiType = Handle

Source§

fn lower(obj: Arc<Self>) -> Self::FfiType

Source§

fn try_lift(handle: Self::FfiType) -> Result<Arc<Self>>

Source§

fn write(obj: Arc<Self>, buf: &mut Vec<u8>)

Source§

fn try_read(buf: &mut &[u8]) -> Result<Arc<Self>>

Source§

impl<T> LiftRef<T> for dyn EventListener

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§