Skip to main content

Event

Struct Event 

Source
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: String

Dispatch key. Matched against bus.on(kind, fn) registrations.

§id: String

Correlation id (source-assigned). Used in tracing/logging.

§payload: Value

Source-defined payload. Converted to Lua table at dispatch time.

§meta: Value

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

Source

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 an adapter that broadcasts without waiting (webhook broadcast / timer). Not used by the mesh path, which needs the ack round-trip.

Source

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 an adapter that wants the ack without assembling the channel itself. The mesh adapter constructs Event directly instead, to keep control over the meta map and the ack sender’s lifetime.

Source

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§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more