Skip to main content

TransportPort

Trait TransportPort 

Source
pub trait TransportPort: Send + Sync {
    // Required methods
    fn publish<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message: &'life1 Message,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn subscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        owner: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn claim<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        owner: &'life1 str,
        message_id: &'life2 Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn mailbox<'life0, 'life1, 'async_trait>(
        &'life0 self,
        owner: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Mailbox>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A message bus / mailbox transport.

§Atomic claim contract

claim MUST be atomic: at most one caller may successfully claim a given message. Implementations realize this via a compare-and-swap on a state/lease field (e.g. a lockfile + CAS), so that concurrent workers never double-process. A failed claim returns crate::error::SubstrateError::ClaimConflict.

Required Methods§

Source

fn publish<'life0, 'life1, 'async_trait>( &'life0 self, message: &'life1 Message, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Publish message to its recipient’s mailbox.

Source

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, owner: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return all messages currently addressed to owner.

Source

fn claim<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, owner: &'life1 str, message_id: &'life2 Uuid, ) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Atomically claim message_id for exclusive processing (CAS-lease). Returns the claimed message, or ClaimConflict if already held.

Source

fn mailbox<'life0, 'life1, 'async_trait>( &'life0 self, owner: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Mailbox>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Snapshot the full mailbox for owner.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§