Struct PostOffice

Source
pub struct PostOffice<T> { /* private fields */ }

Implementations§

Source§

impl<T> PostOffice<T>
where T: Send + 'static,

Source

pub fn new(cleanup: Duration) -> Self

Creates a new post office that delivers to mailboxes, cleaning up orphaned mailboxes waiting cleanup time inbetween attempts

Source

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

Source

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

Source

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.

Source

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.

Source

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.

Source

pub async fn cancel(&self, id: &Id)

Cancels delivery to the mailbox with the specified id.

Source

pub async fn cancel_many(&self, ids: impl Iterator<Item = &Id>)

Cancels delivery to the mailboxes with the specified ids.

Source

pub async fn cancel_all(&self)

Cancels delivery to all mailboxes.

Source§

impl<T> PostOffice<Response<T>>
where T: Send + 'static,

Source

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>>

Source

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>

Source§

fn clone(&self) -> PostOffice<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for PostOffice<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for PostOffice<T>
where T: Send + 'static,

Source§

fn default() -> Self

Creates a new postoffice with a cleanup interval of 60s

Auto Trait Implementations§

§

impl<T> Freeze for PostOffice<T>

§

impl<T> !RefUnwindSafe for PostOffice<T>

§

impl<T> Send for PostOffice<T>
where T: Send,

§

impl<T> Sync for PostOffice<T>
where T: Send,

§

impl<T> Unpin for PostOffice<T>

§

impl<T> !UnwindSafe for PostOffice<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Converts mutable reference to Any
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Consumes and produces Box<dyn Any>
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V