pub struct OclaBus { /* private fields */ }Expand description
The OCLA event bus. Zero-cost when disabled.
Global usage: ocla_bus::emit(event) — checks the global enable flag first.
Test usage: OclaBus::scoped(cap) — isolated instance, no global state.
Implementations§
Source§impl OclaBus
impl OclaBus
Sourcepub fn scoped(capacity: usize) -> Self
pub fn scoped(capacity: usize) -> Self
Create a scoped (isolated) bus for testing. Does NOT affect the global bus.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the bus is enabled.
Sourcepub fn emit_if_enabled(&self, event: OclaEvent) -> u64
pub fn emit_if_enabled(&self, event: OclaEvent) -> u64
Emit an event if the bus is enabled. Returns the event ID, or 0 if disabled.
Sourcepub fn drain(&self) -> Vec<OclaBusRecord>
pub fn drain(&self) -> Vec<OclaBusRecord>
Drain all events from the ring (consumes them). Useful for test assertions.
Sourcepub fn events_since(&self, after_id: u64) -> Vec<OclaBusRecord>
pub fn events_since(&self, after_id: u64) -> Vec<OclaBusRecord>
Read events since a given ID (non-consuming).
Sourcepub fn latest(&self, n: usize) -> Vec<OclaBusRecord>
pub fn latest(&self, n: usize) -> Vec<OclaBusRecord>
Read the last N events.
Sourcepub fn total_emitted(&self) -> u64
pub fn total_emitted(&self) -> u64
Total events emitted (including those evicted from the ring).
Sourcepub fn overflow_count(&self) -> usize
pub fn overflow_count(&self) -> usize
Total queue overflows observed by this bus since creation.
Sourcepub fn overflow_policy(&self) -> OverflowPolicy
pub fn overflow_policy(&self) -> OverflowPolicy
Overflow policy active for this bus.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OclaBus
impl RefUnwindSafe for OclaBus
impl Send for OclaBus
impl Sync for OclaBus
impl Unpin for OclaBus
impl UnsafeUnpin for OclaBus
impl UnwindSafe for OclaBus
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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>
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 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>
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