Skip to main content

Event

Struct Event 

Source
pub struct Event { /* private fields */ }
Expand description

An immutable outward event; loop-owned variants have no public constructors.

Implementations§

Source§

impl Event

Source

pub fn from_audit(audit: Event) -> Result<Self, ValidationError>

Constructs a validated extension-produced audit event.

§Errors

ValidationError::EmptyAuditKind if the audit fact does not name a kind. An audit fact is classified by its kind, and an unclassifiable one cannot be filtered, routed, or counted by whoever consumes the stream.

This is the only construction check on the two event kinds an extension may build. The remaining ValidationError variants describe private producer mistakes and cannot be reached from here.

Source

pub fn from_error(error: Arc<dyn Error + Send + Sync>) -> Self

Constructs a validated extension-produced non-fatal error event.

Source

pub const fn kind(&self) -> Kind

Returns the event category.

Source

pub const fn coord(&self) -> Option<&Coord>

Returns the runtime-stamped coordinate, when applicable.

Source

pub fn item_id(&self) -> Option<&str>

Returns the provider’s identity for the content item this event is part of.

coord says where the event sits in reef’s own Run/Turn/Step structure; this says which of the provider’s items it belongs to. A single generation can produce several — an answer alongside reasoning, or several separate answer items — and they interleave, so a consumer rendering incrementally needs this to put each fragment under the right heading rather than concatenating everything a Step emitted.

Present on all four content kinds, and the same string on both sides: a delta reports the identity of the model::Event::ContentDelta it projects, the consolidated event reports the one the committed Segment kept, and model::StreamGrammar refuses a stream whose final does not close the identity its deltas opened. So grouping deltas by this value and then matching the consolidated event to the same group is sound, and it stays sound for a provider that streams no deltas at all.

None on every other kind, and on a content event whose segment no provider produced — one an OnAfterModel registration composed, for instance. A registration that replaces assistant content decides its identity too, including deciding it has none, and what reaches a consumer here is always the identity of the content it is attached to rather than of the content the provider originally sent.

Source

pub fn text(&self) -> Option<&str>

Returns text carried by a text or thinking event.

Source

pub const fn tool_call(&self) -> Option<&ToolCall>

Returns a tool-call payload.

Source

pub const fn tool_result(&self) -> Option<&ToolResult>

Returns a tool-result payload.

Source

pub const fn admitted_input(&self) -> Option<&AdmittedInput>

Returns the committed batch an InputAdmitted event projects.

Never empty: an empty batch is refused before it can be recorded, because recording one would assert that somebody said nothing.

Source

pub fn rejection_reason(&self) -> Option<&str>

Returns why an InputRejected event refused a batch.

Never empty: a rejection with no reason is a hook defect that fails the Run, because the reason is the only thing the refusal leaves behind.

Source

pub const fn outcome(&self) -> Option<Outcome>

Returns a lifecycle end outcome.

Source

pub const fn as_audit(&self) -> Option<&Event>

Returns an audit payload.

Source

pub fn as_error(&self) -> Option<&(dyn Error + Send + Sync)>

Returns a recoverable error payload.

Source

pub const fn stop_code(&self) -> Option<&StopCode>

Returns the opaque stop classification.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Event

§

impl !UnwindSafe for Event

§

impl Freeze for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.