pub struct MessageHub { /* private fields */ }Expand description
The central message hub
Implementations§
Source§impl MessageHub
impl MessageHub
pub fn new() -> Arc<Self>
Sourcepub fn clone_inner(&self) -> Self
pub fn clone_inner(&self) -> Self
Get a clone of this hub that shares the same connection map. Used by NatsBus to give its delivery listener access to connected devices.
Sourcepub fn connect(&self, uuid: Uuid) -> Receiver<DeviceEvent>
pub fn connect(&self, uuid: Uuid) -> Receiver<DeviceEvent>
Register a new connection, returns a receiver
Sourcepub fn disconnect(&self, uuid: &Uuid)
pub fn disconnect(&self, uuid: &Uuid)
Disconnect a device
Sourcepub fn deliver(&self, uuid: &Uuid, event: DeviceEvent)
pub fn deliver(&self, uuid: &Uuid, event: DeviceEvent)
Deliver an event to a specific device
Sourcepub fn deliver_many(&self, uuids: &[Uuid], event: DeviceEvent)
pub fn deliver_many(&self, uuids: &[Uuid], event: DeviceEvent)
Deliver an event to multiple devices
Sourcepub fn is_online(&self, uuid: &Uuid) -> bool
pub fn is_online(&self, uuid: &Uuid) -> bool
Check if a device is currently online (has an active connection)
Sourcepub fn online_count(&self) -> usize
pub fn online_count(&self) -> usize
Get count of online devices
Sourcepub fn online_devices(&self) -> Vec<Uuid>
pub fn online_devices(&self) -> Vec<Uuid>
Get all online device UUIDs
Trait Implementations§
Source§impl Clone for MessageHub
impl Clone for MessageHub
Source§fn clone(&self) -> MessageHub
fn clone(&self) -> MessageHub
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MessageHub
impl !RefUnwindSafe for MessageHub
impl Send for MessageHub
impl Sync for MessageHub
impl Unpin for MessageHub
impl UnsafeUnpin for MessageHub
impl !UnwindSafe for MessageHub
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> 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>
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