hoprd_inbox::inbox

Trait InboxBackend

Source
pub trait InboxBackend<T: Copy + Default + Send, M: Clone + Send> {
    // Required methods
    fn new_with_capacity(cap: usize, ts: TimestampFn) -> Self;
    fn push<'life0, 'async_trait>(
        &'life0 mut self,
        tag: Option<T>,
        payload: M,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count<'life0, 'async_trait>(
        &'life0 self,
        tag: Option<T>,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pop<'life0, 'async_trait>(
        &'life0 mut self,
        tag: Option<T>,
    ) -> Pin<Box<dyn Future<Output = Option<(M, Duration)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pop_all<'life0, 'async_trait>(
        &'life0 mut self,
        tag: Option<T>,
    ) -> Pin<Box<dyn Future<Output = Vec<(M, Duration)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn peek<'life0, 'async_trait>(
        &'life0 mut self,
        tag: Option<T>,
    ) -> Pin<Box<dyn Future<Output = Option<(M, Duration)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn peek_all<'life0, 'async_trait>(
        &'life0 mut self,
        tag: Option<T>,
        timestamp: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = Vec<(M, Duration)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn purge<'life0, 'async_trait>(
        &'life0 mut self,
        older_than_ts: Duration,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Represents a generic backend trait for the message inbox. Messages M can be tagged or untagged via the type T

Required Methods§

Source

fn new_with_capacity(cap: usize, ts: TimestampFn) -> Self

Create new storage with the given capacity and the timestamping function

Source

fn push<'life0, 'async_trait>( &'life0 mut self, tag: Option<T>, payload: M, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Push a new entry with an optional tag.

Source

fn count<'life0, 'async_trait>( &'life0 self, tag: Option<T>, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Count number of entries with the given tag.

If no tag is given, returns the total count of all tagged and untagged entries.

Source

fn pop<'life0, 'async_trait>( &'life0 mut self, tag: Option<T>, ) -> Pin<Box<dyn Future<Output = Option<(M, Duration)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Pops oldest entry with the given tag or oldest entry in general, if no tag was given.

Returns None if queue with the given tag is empty, or the entire store is empty (if no tag was given).

Source

fn pop_all<'life0, 'async_trait>( &'life0 mut self, tag: Option<T>, ) -> Pin<Box<dyn Future<Output = Vec<(M, Duration)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Pops all entries of the given tag, or all entries (tagged and untagged) and returns them.

Source

fn peek<'life0, 'async_trait>( &'life0 mut self, tag: Option<T>, ) -> Pin<Box<dyn Future<Output = Option<(M, Duration)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Peeks the oldest entry with the given tag or oldest entry in general, if no tag was given.

Returns None if queue with the given tag is empty, or the entire store is empty (if no tag was given).

Source

fn peek_all<'life0, 'async_trait>( &'life0 mut self, tag: Option<T>, timestamp: Option<Duration>, ) -> Pin<Box<dyn Future<Output = Vec<(M, Duration)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Peeks all entries of the given tag, or all entries (tagged and untagged) and returns them.

If the optional parameter timestamp is provided, only entries more recent than this are returned. NOTE: the timestamp comparison precision should be at most up to milliseconds.

Source

fn purge<'life0, 'async_trait>( &'life0 mut self, older_than_ts: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Purges all entries strictly older than the given timestamp.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, M> InboxBackend<T, M> for RingBufferInboxBackend<T, M>
where T: Copy + Default + PartialEq + Eq + Hash + Send + Sync, M: Clone + Send + Sync,