pub struct Event {
pub kind: String,
pub id: String,
pub payload: Value,
pub meta: Value,
pub ack_tx: Option<AckSender>,
}Expand description
A normalized event flowing through the bus.
Ownership: produced by a Source, moved through a
bounded mpsc::Sender<Event> into the single dispatcher loop. The
dispatcher consumes the ack_tx (via Option::take) to send the
handler’s return value back to the source.
Fields§
§kind: StringDispatch key. Matched against bus.on(kind, fn) registrations.
id: StringCorrelation id (source-assigned). Used in tracing/logging.
payload: ValueSource-defined payload. Converted to Lua table at dispatch time.
meta: ValueSource-defined metadata (e.g. mesh from, timestamps). Converted to
Lua table at dispatch time.
ack_tx: Option<AckSender>Optional one-shot channel used to return the Lua handler’s result.
None for fire-and-forget sources.
Implementations§
Source§impl Event
impl Event
Sourcepub fn fire_and_forget(
kind: impl Into<String>,
id: impl Into<String>,
payload: Value,
) -> Self
pub fn fire_and_forget( kind: impl Into<String>, id: impl Into<String>, payload: Value, ) -> Self
Construct a new event without an ack channel (fire-and-forget).
Intended for ST4 adapters (webhook broadcast / timer). Not used by the ST3 mesh path (which needs the ack round-trip).
Sourcepub fn with_ack(
kind: impl Into<String>,
id: impl Into<String>,
payload: Value,
meta: Value,
) -> (Self, AckReceiver)
pub fn with_ack( kind: impl Into<String>, id: impl Into<String>, payload: Value, meta: Value, ) -> (Self, AckReceiver)
Construct a new event paired with a fresh ack channel. Returns the event (to be pushed to the bus) and the receiver half (to be awaited by the source).
Used by the dispatcher’s in-crate tests and by forthcoming ST4
adapters. The ST3 mesh adapter constructs Event directly to keep
control over the meta map and ack sender lifetime.
Sourcepub fn deliver_ack(&mut self, result: AckResult) -> Result<(), BlockError>
pub fn deliver_ack(&mut self, result: AckResult) -> Result<(), BlockError>
Send result on ack_tx if it is still present. Logs a warning when
the receiver has been dropped (tracing-missing-on-err policy).
Returns Ok(()) when the ack was delivered or the event was
fire-and-forget. Returns Err(BlockError::Bus) only when the
receiver had been dropped — the caller can decide whether to treat
that as fatal.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more