pub struct PostOffice<T> { /* private fields */ }
Implementations§
Source§impl<T> PostOffice<T>where
T: Send + 'static,
impl<T> PostOffice<T>where
T: Send + 'static,
Sourcepub fn new(cleanup: Duration) -> Self
pub fn new(cleanup: Duration) -> Self
Creates a new post office that delivers to mailboxes, cleaning up orphaned mailboxes
waiting cleanup
time inbetween attempts
Sourcepub async fn make_mailbox(&self, id: Id, buffer: usize) -> Mailbox<T>
pub async fn make_mailbox(&self, id: Id, buffer: usize) -> Mailbox<T>
Creates a new mailbox using the given id and buffer size for maximum values that can be queued in the mailbox
Sourcepub async fn deliver(&self, id: &Id, value: T) -> bool
pub async fn deliver(&self, id: &Id, value: T) -> bool
Delivers some value to appropriate mailbox, returning false if no mailbox is found for the specified id or if the mailbox is no longer receiving values
Sourcepub async fn assign_default_mailbox(&self, buffer: usize) -> Mailbox<T>
pub async fn assign_default_mailbox(&self, buffer: usize) -> Mailbox<T>
Creates a new default mailbox that will be used whenever no mailbox is found to deliver mail. This will replace any existing default mailbox.
Sourcepub async fn remove_default_mailbox(&self)
pub async fn remove_default_mailbox(&self)
Removes the default mailbox such that any mail without a matching mailbox will be dropped instead of being delivered to a default mailbox.
Sourcepub async fn has_default_mailbox(&self) -> bool
pub async fn has_default_mailbox(&self) -> bool
Returns true if the post office is using a default mailbox for all mail that does not map to another mailbox.
Sourcepub async fn cancel_many(&self, ids: impl Iterator<Item = &Id>)
pub async fn cancel_many(&self, ids: impl Iterator<Item = &Id>)
Cancels delivery to the mailboxes with the specified id
s.
Sourcepub async fn cancel_all(&self)
pub async fn cancel_all(&self)
Cancels delivery to all mailboxes.
Source§impl<T> PostOffice<Response<T>>where
T: Send + 'static,
impl<T> PostOffice<Response<T>>where
T: Send + 'static,
Sourcepub async fn deliver_response(&self, res: Response<T>) -> bool
pub async fn deliver_response(&self, res: Response<T>) -> bool
Delivers some response to appropriate mailbox, returning false if no mailbox is found for the response’s origin or if the mailbox is no longer receiving values
Source§impl PostOffice<UntypedResponse<'static>>
impl PostOffice<UntypedResponse<'static>>
Sourcepub async fn deliver_untyped_response(
&self,
res: UntypedResponse<'static>,
) -> bool
pub async fn deliver_untyped_response( &self, res: UntypedResponse<'static>, ) -> bool
Delivers some response to appropriate mailbox, returning false if no mailbox is found for the response’s origin or if the mailbox is no longer receiving values
Trait Implementations§
Source§impl<T: Clone> Clone for PostOffice<T>
impl<T: Clone> Clone for PostOffice<T>
Source§fn clone(&self) -> PostOffice<T>
fn clone(&self) -> PostOffice<T>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more