pub struct MessageBus { /* private fields */ }Expand description
The kernel-internal message bus.
MessageBus is cheaply cloneable; clones share the same underlying state and
can be handed out to modules and subsystems freely.
Implementations§
Source§impl MessageBus
impl MessageBus
Sourcepub async fn grant_capability(&self, cap: Capability)
pub async fn grant_capability(&self, cap: Capability)
Grant a capability token. After this call, any source holding cap
may call Self::publish_with_capability successfully.
Sourcepub async fn revoke_capability(&self, cap: &Capability)
pub async fn revoke_capability(&self, cap: &Capability)
Revoke a previously granted capability.
Sourcepub async fn publish_with_capability(
&self,
envelope: Envelope,
cap: &Capability,
) -> Result<()>
pub async fn publish_with_capability( &self, envelope: Envelope, cap: &Capability, ) -> Result<()>
Publish an Envelope only if cap has been granted.
Returns KernelError::Denied if the capability is not in the grant
set. On success, routes the envelope identically to Self::publish.
Sourcepub async fn subscribe(&self) -> Subscription
pub async fn subscribe(&self) -> Subscription
Register a new subscriber and return a Subscription handle.
Sourcepub async fn publish(&self, envelope: Envelope) -> Result<()>
pub async fn publish(&self, envelope: Envelope) -> Result<()>
Publish an Envelope to every subscriber.
Subscribers whose channels are closed are silently dropped. If a subscriber’s channel is full the message is dropped for that subscriber only and a warning is traced; this prevents one slow subscriber from blocking the whole bus.
Sourcepub async fn send_command(
&self,
source: impl Into<String>,
command: Command,
) -> Result<Uuid>
pub async fn send_command( &self, source: impl Into<String>, command: Command, ) -> Result<Uuid>
Sourcepub async fn subscriber_count(&self) -> usize
pub async fn subscriber_count(&self) -> usize
Returns the number of live subscribers (best-effort).
Trait Implementations§
Source§impl Clone for MessageBus
impl Clone for MessageBus
Source§fn clone(&self) -> MessageBus
fn clone(&self) -> MessageBus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessageBus
impl Debug for MessageBus
Source§impl Default for MessageBus
impl Default for MessageBus
Source§fn default() -> MessageBus
fn default() -> MessageBus
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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