pub struct MessageBus { /* private fields */ }Expand description
The host-side message bus connecting execution contexts.
Messages are queued and delivered when the receiving context runs its next execution pass. The bus records all messages for the observation stream, up to a configurable cap.
Implementations§
Source§impl MessageBus
impl MessageBus
pub fn new() -> Self
Sourcepub fn send(&mut self, message: ContextMessage)
pub fn send(&mut self, message: ContextMessage)
Queue a message for delivery to the target context.
Messages beyond the history or per-queue cap are silently discarded to prevent memory exhaustion from adversarial scripts.
Sourcepub fn receive(&mut self, context: &ContextId) -> Vec<ContextMessage>
pub fn receive(&mut self, context: &ContextId) -> Vec<ContextMessage>
Drain all pending messages for a context. Called when the context starts its next execution pass.
Sourcepub fn history(&self) -> &[ContextMessage]
pub fn history(&self) -> &[ContextMessage]
Return the full message history for observation.
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Whether any context has pending messages.
Sourcepub fn history_len(&self) -> usize
pub fn history_len(&self) -> usize
Number of messages recorded in the history.
Trait Implementations§
Source§impl Debug for MessageBus
impl Debug for MessageBus
Source§impl Default for MessageBus
impl Default for MessageBus
Source§fn default() -> MessageBus
fn default() -> MessageBus
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MessageBus
impl RefUnwindSafe for MessageBus
impl Send for MessageBus
impl Sync for MessageBus
impl Unpin for MessageBus
impl UnsafeUnpin for MessageBus
impl UnwindSafe for MessageBus
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
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