MailboxStore

Trait MailboxStore 

Source
pub trait MailboxStore {
    // Required methods
    fn store_message<'life0, 'async_trait>(
        &'life0 self,
        recipient_hash: [u8; 32],
        msg: EncryptedMessage,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_messages<'life0, 'async_trait>(
        &'life0 self,
        recipient_hash: [u8; 32],
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<EncryptedMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_messages<'life0, 'async_trait>(
        &'life0 self,
        recipient_hash: [u8; 32],
        msg_ids: Vec<Uuid>,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cleanup_expired<'life0, 'async_trait>(
        &'life0 self,
        max_age: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A trait for managing mailbox operations.

Required Methods§

Source

fn store_message<'life0, 'async_trait>( &'life0 self, recipient_hash: [u8; 32], msg: EncryptedMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores an encrypted message for a recipient.

§Arguments
  • recipient_hash - The hash of the recipient’s public key.
  • msg - The EncryptedMessage to store.
§Errors

This function will return an error if the message cannot be stored.

Source

fn fetch_messages<'life0, 'async_trait>( &'life0 self, recipient_hash: [u8; 32], limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<EncryptedMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches messages for a recipient.

§Arguments
  • recipient_hash - The hash of the recipient’s public key.
  • limit - The maximum number of messages to fetch.
§Returns

A Vec of EncryptedMessages for the recipient.

§Errors

This function will return an error if the messages cannot be fetched.

Source

fn delete_messages<'life0, 'async_trait>( &'life0 self, recipient_hash: [u8; 32], msg_ids: Vec<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Deletes messages for a recipient.

§Arguments
  • recipient_hash - The hash of the recipient’s public key.
  • msg_ids - A Vec of message IDs to delete.
§Returns

The number of messages that were deleted.

§Errors

This function will return an error if the messages cannot be deleted.

Source

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

Cleans up expired messages from the mailbox.

§Arguments
  • max_age - The maximum age for messages to be retained.
§Errors

This function will return an error if cleanup fails.

Implementors§