MessageService

Trait MessageService 

Source
pub trait MessageService: Sized {
    // Required methods
    async fn publish(
        self,
        context: Context,
        message: MessageFull,
    ) -> Result<PublishResult, MessageError>;
    async fn message(
        self,
        context: Context,
        id: MessageId,
    ) -> Result<Option<MessageFull>, MessageError>;
    async fn user_data(
        self,
        context: Context,
        author: KeyId,
        storage_key: StoreKey,
    ) -> Result<Option<MessageFull>, MessageError>;
    async fn check_messages(
        self,
        context: Context,
        message_ids: Vec<MessageId>,
    ) -> Result<Vec<Option<String>>, MessageError>;
    async fn subscribe(
        self,
        context: Context,
        config: SubscriptionConfig,
    ) -> Result<(), MessageError>;
    async fn update_filters(
        self,
        context: Context,
        request: FilterUpdateRequest,
    ) -> Result<SubscriptionConfig, MessageError>;
    async fn catch_up(
        self,
        context: Context,
        request: CatchUpRequest,
    ) -> Result<SubscriptionConfig, MessageError>;

    // Provided method
    fn serve(self) -> ServeMessageService<Self> { ... }
}
Expand description

Message store service for message interaction operations

Required Methods§

Source

async fn publish( self, context: Context, message: MessageFull, ) -> Result<PublishResult, MessageError>

Source

async fn message( self, context: Context, id: MessageId, ) -> Result<Option<MessageFull>, MessageError>

Retrieve a specific message by its ID

Source

async fn user_data( self, context: Context, author: KeyId, storage_key: StoreKey, ) -> Result<Option<MessageFull>, MessageError>

Retrieve a specific user’s data by their key and storage key

Source

async fn check_messages( self, context: Context, message_ids: Vec<MessageId>, ) -> Result<Vec<Option<String>>, MessageError>

Check which messages the server already has and return their global stream IDs. Returns a vec of Option<String> in the same order as the input, where:

  • Some(stream_id) means the server has the message with that global stream ID
  • None means the server doesn’t have this message yet
Source

async fn subscribe( self, context: Context, config: SubscriptionConfig, ) -> Result<(), MessageError>

Start the subscription

Source

async fn update_filters( self, context: Context, request: FilterUpdateRequest, ) -> Result<SubscriptionConfig, MessageError>

Update the running subscription filters with the actions. Returns the now final subscription config.

Source

async fn catch_up( self, context: Context, request: CatchUpRequest, ) -> Result<SubscriptionConfig, MessageError>

Update the internal subscription and catch up to the latest stream height for the given filter

Provided Methods§

Source

fn serve(self) -> ServeMessageService<Self>

Returns a serving function to use with InFlightRequest::execute.

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§