MessageStore

Trait MessageStore 

Source
pub trait MessageStore {
    // Required methods
    fn store_message<'life0, 'async_trait>(
        &'life0 self,
        msg: Message,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_message_by_id<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Message>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_history<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        own_id: &'life1 PeerId,
        peer: &'life2 PeerId,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_recent_messages<'life0, 'life1, 'async_trait>(
        &'life0 self,
        own_id: &'life1 PeerId,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_messages_before<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        own_id: &'life1 PeerId,
        peer: &'life2 PeerId,
        before_id: &'life3 Uuid,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn get_messages_after<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        own_id: &'life1 PeerId,
        peer: &'life2 PeerId,
        after_id: &'life3 Uuid,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn update_delivery_status<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg_id: &'life1 Uuid,
        status: DeliveryStatus,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A trait for storing and retrieving messages.

Required Methods§

Source

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

Stores a message in the history.

§Arguments
  • msg - The Message to store.
§Errors

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

Source

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

Retrieves a message by its ID.

§Arguments
  • msg_id - The Uuid of the message to retrieve.
§Returns

An Option containing the Message if found, otherwise None.

§Errors

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

Source

fn get_history<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, own_id: &'life1 PeerId, peer: &'life2 PeerId, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieves the message history for a conversation.

Messages are returned in chronological order.

§Arguments
  • own_id - The PeerId of the local user.
  • peer - The PeerId of the other participant in the conversation.
  • limit - The maximum number of messages to retrieve.
§Returns

A Vec of Messages representing the conversation history.

§Errors

This function will return an error if the history cannot be retrieved.

Source

fn get_recent_messages<'life0, 'life1, 'async_trait>( &'life0 self, own_id: &'life1 PeerId, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a limited number of the most recent messages from all conversations.

Messages are returned in chronological order, up to the specified limit.

§Arguments
  • own_id - The PeerId of the local user (used for filtering relevant messages).
  • limit - The maximum number of recent messages to retrieve.
§Returns

A Vec of Messages, sorted chronologically.

§Errors

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

Source

fn get_messages_before<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, own_id: &'life1 PeerId, peer: &'life2 PeerId, before_id: &'life3 Uuid, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Retrieves messages before a specific message in a conversation.

Messages are returned in chronological order.

§Arguments
  • own_id - The PeerId of the local user.
  • peer - The PeerId of the other participant in the conversation.
  • before_id - The Uuid of the message to retrieve messages before.
  • limit - The maximum number of messages to retrieve.
§Returns

A Vec of Messages.

§Errors

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

Source

fn get_messages_after<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, own_id: &'life1 PeerId, peer: &'life2 PeerId, after_id: &'life3 Uuid, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Retrieves messages after a specific message in a conversation.

Messages are returned in chronological order.

§Arguments
  • own_id - The PeerId of the local user.
  • peer - The PeerId of the other participant in the conversation.
  • after_id - The Uuid of the message to retrieve messages after.
  • limit - The maximum number of messages to retrieve.
§Returns

A Vec of Messages.

§Errors

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

Source

fn update_delivery_status<'life0, 'life1, 'async_trait>( &'life0 self, msg_id: &'life1 Uuid, status: DeliveryStatus, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Updates the delivery status of a message.

§Arguments
  • msg_id - The Uuid of the message to update.
  • status - The new DeliveryStatus for the message.
§Errors

This function will return an error if the status cannot be updated.

Implementors§