pub struct EventsService { /* private fields */ }Implementations§
Source§impl EventsService
impl EventsService
pub fn new() -> EventsService
Sourcepub fn listener_count(&self, event: &str) -> usize
pub fn listener_count(&self, event: &str) -> usize
Count of non-cancelled listeners registered on event, across BOTH
registries (flat + waterfall). Read-only — no pruning writes — so the
zero-cost gate for every interception point is one pair of map
lookups.
Sourcepub fn dispatch_snapshot(&self) -> (u64, Vec<(String, u64)>)
pub fn dispatch_snapshot(&self) -> (u64, Vec<(String, u64)>)
Subscribe to the fire-and-forget emit broadcast bus. Snapshot of dispatch counters: (total, per-event sorted ascending).
Sourcepub fn subscribe(&self) -> Receiver<(String, Value)>
pub fn subscribe(&self) -> Receiver<(String, Value)>
Subscribe to the fire-and-forget emit broadcast bus.
Sourcepub fn once<F, Fut>(&self, event: String, handler: F) -> Box<dyn Disposable>
pub fn once<F, Fut>(&self, event: String, handler: F) -> Box<dyn Disposable>
Register a one-shot flat listener.
The returned handle is the same early-cancel subscription Self::on
yields; disposing it before the event ever fires unregisters the
listener. Exactly-once is claimed AT INVOCATION through an atomic
swap, so concurrent dispatches of the same event run the handler on
exactly one task and every later dispatch observes an already-spent
(skipped) slot. Delegates to Self::once_with with default options;
a bail-chain-skipped listener stays registered until it actually runs
(see Self::once_with).
Sourcepub fn once_with<F, Fut>(
&self,
event: String,
options: EventOptions,
handler: F,
) -> Box<dyn Disposable>
pub fn once_with<F, Fut>( &self, event: String, options: EventOptions, handler: F, ) -> Box<dyn Disposable>
Register a one-shot flat listener with explicit EventOptions.
The claim/dispose flag discipline is identical to Self::once;
options.prepend controls the insertion position in the
dispatch-order list, options.global marks the listener as exempt
from context filters in Self::emit_filtered. The historical
Self::once delegates here with default options.
pub fn on<F, Fut>(&self, event: String, handler: F) -> Box<dyn Disposable>
Sourcepub fn on_with<F, Fut>(
&self,
event: String,
options: EventOptions,
handler: F,
) -> Box<dyn Disposable>
pub fn on_with<F, Fut>( &self, event: String, options: EventOptions, handler: F, ) -> Box<dyn Disposable>
Register a flat listener with explicit EventOptions: prepend
inserts at the front of the dispatch-order list, global marks the
listener as realm-agnostic for Self::emit_filtered. The
historical Self::on delegates here with default options.
Sourcepub fn on_waterfall<F, Fut>(
&self,
event: String,
handler: F,
) -> Box<dyn Disposable>
pub fn on_waterfall<F, Fut>( &self, event: String, handler: F, ) -> Box<dyn Disposable>
Register a Cordis waterfall around-middleware handler.
handler receives the current payload and a next continuation. Calling
next(payload) runs the downstream chain and yields its (possibly
transformed) result; NOT calling next short-circuits the chain so later
handlers do not run. Handlers registered here are only invoked by
dispatch with Dispatch::Waterfall; the plain
on registry is used for emit/parallel/serial/bail.
Sourcepub fn emit_filtered(
&self,
event: String,
args: Value,
filter: Box<dyn Fn(&EventOptions) -> bool + Sync + Send>,
) -> Result<Value, CordisError>
pub fn emit_filtered( &self, event: String, args: Value, filter: Box<dyn Fn(&EventOptions) -> bool + Sync + Send>, ) -> Result<Value, CordisError>
Filtered fire-and-forget emit: like Dispatch::Emit via
Self::dispatch, but non-global listeners are offered to filter
first — a false verdict excludes the listener from this dispatch
without unregistering it. Global listeners bypass the filter.
The broadcast bus fan-out is NOT filtered (it has no listener metadata to filter on); only registered handlers participate in filtering. Returns null like every emit path.
Sourcepub async fn bail_from(
&self,
event: String,
payload: Value,
filter: Option<Box<dyn Fn(&EventOptions) -> bool + Sync + Send>>,
) -> Result<Value, CordisError>
pub async fn bail_from( &self, event: String, payload: Value, filter: Option<Box<dyn Fn(&EventOptions) -> bool + Sync + Send>>, ) -> Result<Value, CordisError>
Target-carrying Bail dispatch: like Dispatch::Bail through
Self::dispatch, but non-global flat listeners whose registration
options fail filter do not participate in THIS dispatch (they stay
registered). The filter closure captures the operating context at
the call site, so per-dispatch decisions evaluate against it. Kernel
meta-events ride here for their veto chains.
Sourcepub async fn waterfall_from(
&self,
event: String,
payload: Value,
filter: Option<Box<dyn Fn(&EventOptions) -> bool + Sync + Send>>,
) -> Result<Value, CordisError>
pub async fn waterfall_from( &self, event: String, payload: Value, filter: Option<Box<dyn Fn(&EventOptions) -> bool + Sync + Send>>, ) -> Result<Value, CordisError>
Target-carrying Waterfall dispatch with identity terminal: the same
chain as Dispatch::Waterfall through Self::dispatch, plus
per-dispatch filtering of the waterfall registry.
pub async fn dispatch( &self, event: String, payload: Value, mode: Dispatch, ) -> Result<Value, CordisError>
Sourcepub async fn waterfall_around<F, Fut>(
&self,
event: String,
payload: Value,
core: F,
) -> Result<Value, CordisError>
pub async fn waterfall_around<F, Fut>( &self, event: String, payload: Value, core: F, ) -> Result<Value, CordisError>
Around-middleware waterfall whose terminal next is core rather than identity.
Snapshot active waterfall handlers for event. With none registered, core
runs immediately. Otherwise the same chain as [dispatch] with
Dispatch::Waterfall, except index >= handlers.len() invokes core
instead of returning the payload unchanged. [dispatch] Waterfall stays
identity-at-end.
Sourcepub async fn waterfall_async_from<F, Fut>(
&self,
event: String,
payload: Value,
filter: Option<Box<dyn Fn(&EventOptions) -> bool + Sync + Send>>,
core: F,
) -> Result<Value, CordisError>
pub async fn waterfall_async_from<F, Fut>( &self, event: String, payload: Value, filter: Option<Box<dyn Fn(&EventOptions) -> bool + Sync + Send>>, core: F, ) -> Result<Value, CordisError>
Target-carrying around-middleware waterfall whose terminal next is
core: Self::waterfall_around plus per-dispatch listener
filtering. The operating context rides along through whatever the
caller closes over in filter.
Sourcepub async fn intercept_get(
&self,
service: &str,
ctx_hint: Option<String>,
) -> Result<Option<Value>, CordisError>
pub async fn intercept_get( &self, service: &str, ctx_hint: Option<String>, ) -> Result<Option<Value>, CordisError>
Strict service read interception at the internal/get veto point.
No listeners ⇒ Ok(None) at map-lookup cost (zero-cost gate). A Bail
chain yielding null passes the read through untouched; a non-null
result REPLACES what the consumer sees; a chain error vetoes the read.
Sourcepub async fn intercept_set(
&self,
service: &str,
ctx_hint: Option<String>,
) -> Result<(), CordisError>
pub async fn intercept_set( &self, service: &str, ctx_hint: Option<String>, ) -> Result<(), CordisError>
Service-write interception at the internal/set veto point. A chain
error vetoes the write (the previous value stays); null / pass-through
allows the write unchanged.
Sourcepub async fn intercept_config(&self, raw: Value) -> Result<Value, CordisError>
pub async fn intercept_config(&self, raw: Value) -> Result<Value, CordisError>
Config-resolution interception at the internal/config veto point.
The chain’s non-null terminal IS the effective configuration; null
passes raw through untouched; a chain error fails the activation /
update that was resolving config.
Sourcepub async fn intercept_update(&self, service: &str) -> Result<bool, CordisError>
pub async fn intercept_update(&self, service: &str) -> Result<bool, CordisError>
Restart-schedule interception at the internal/update veto point.
Ok(true) proceeds with the restart; Ok(false) (a bail or an
explicit JSON false) vetoes — the caller stores its pending config
and skips the restart. A chain error propagates to the caller.
Sourcepub async fn intercept_listener(&self, event: &str) -> Result<bool, CordisError>
pub async fn intercept_listener(&self, event: &str) -> Result<bool, CordisError>
Listener-registration interception at the internal/listener veto
point. Ok(true) lets the registration proceed; a bail (non-null
non-true result) or a chain error cancels it — the caller returns an
inert handle without touching either registry.
Sourcepub async fn dispatch_typed<E>(
&self,
payload: &<E as TypedEvent>::Payload,
) -> Result<Value, CordisError>where
E: TypedEvent,
pub async fn dispatch_typed<E>(
&self,
payload: &<E as TypedEvent>::Payload,
) -> Result<Value, CordisError>where
E: TypedEvent,
Typed dispatch: serialize the payload struct for E’s event and
dispatch with the declared mode. Equivalent to
dispatch with a pre-validated name/mode
pair; serialization failure is a CordisError::Configuration.
Sourcepub fn on_typed<E, F, Fut>(&self, handler: F) -> Box<dyn Disposable>where
E: TypedEvent,
F: Fn(<E as TypedEvent>::Payload) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Value, CordisError>> + Send + 'static,
pub fn on_typed<E, F, Fut>(&self, handler: F) -> Box<dyn Disposable>where
E: TypedEvent,
F: Fn(<E as TypedEvent>::Payload) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Value, CordisError>> + Send + 'static,
Typed flat listener: the handler receives the deserialized payload struct instead of raw JSON.
A payload that fails to deserialize is skipped with a warning and the
incoming value passes through unchanged (for Serial/Bail chains this
preserves pass-through semantics). Registration still goes through the
same debug contract enforcement as on.
Sourcepub fn on_typed_waterfall<E, F, Fut>(&self, handler: F) -> Box<dyn Disposable>
pub fn on_typed_waterfall<E, F, Fut>(&self, handler: F) -> Box<dyn Disposable>
Typed around-middleware waterfall: the handler receives the
deserialized payload struct plus the raw-JSON WaterfallNext
continuation. The rest of the chain keeps working on serialized values;
delegating handlers re-parse inside next, mirroring upstream TS where
next carries serialized args.
Trait Implementations§
Source§impl Default for EventsService
impl Default for EventsService
Source§fn default() -> EventsService
fn default() -> EventsService
Source§impl Service for EventsService
impl Service for EventsService
Auto Trait Implementations§
impl !Freeze for EventsService
impl !RefUnwindSafe for EventsService
impl !UnwindSafe for EventsService
impl Send for EventsService
impl Sync for EventsService
impl Unpin for EventsService
impl UnsafeUnpin for EventsService
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreimpl<T> MaybeSendSync for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.