pub struct Event { /* private fields */ }Expand description
An immutable outward event; loop-owned variants have no public constructors.
Implementations§
Source§impl Event
impl Event
Sourcepub fn from_audit(audit: Event) -> Result<Self, ValidationError>
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.
Sourcepub fn from_error(error: Arc<dyn Error + Send + Sync>) -> Self
pub fn from_error(error: Arc<dyn Error + Send + Sync>) -> Self
Constructs a validated extension-produced non-fatal error event.
Sourcepub const fn coord(&self) -> Option<&Coord>
pub const fn coord(&self) -> Option<&Coord>
Returns the runtime-stamped coordinate, when applicable.
Sourcepub fn item_id(&self) -> Option<&str>
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.
Sourcepub const fn tool_result(&self) -> Option<&ToolResult>
pub const fn tool_result(&self) -> Option<&ToolResult>
Returns a tool-result payload.
Sourcepub const fn admitted_input(&self) -> Option<&AdmittedInput>
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.
Sourcepub fn rejection_reason(&self) -> Option<&str>
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.