pub struct SwarmHub { /* private fields */ }Expand description
Shared mailbox for one swarm run.
Implementations§
Source§impl SwarmHub
impl SwarmHub
pub fn new() -> Self
Sourcepub fn ensure(&self, id: &str)
pub fn ensure(&self, id: &str)
Register a participant so broadcasts reach them even before they send.
pub fn set_listener(&self, listener: Option<SwarmMessageListener>)
Sourcepub fn send(&self, from: &str, to: &str, text: &str) -> Result<(), String>
pub fn send(&self, from: &str, to: &str, text: &str) -> Result<(), String>
Deliver text from from to to (all broadcasts to every known inbox
plus parent). A direct message to an unregistered id is refused with
the known ids, so a typo is not silently queued where nobody reads.
Sourcepub fn drain(&self, id: &str) -> Vec<SwarmMessage>
pub fn drain(&self, id: &str) -> Vec<SwarmMessage>
Take every pending message for id. The inbox stays registered so
later broadcasts still reach it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SwarmHub
impl RefUnwindSafe for SwarmHub
impl Send for SwarmHub
impl Sync for SwarmHub
impl Unpin for SwarmHub
impl UnsafeUnpin for SwarmHub
impl UnwindSafe for SwarmHub
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