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§
async fn publish( self, context: Context, message: MessageFull, ) -> Result<PublishResult, MessageError>
Sourceasync fn message(
self,
context: Context,
id: MessageId,
) -> Result<Option<MessageFull>, MessageError>
async fn message( self, context: Context, id: MessageId, ) -> Result<Option<MessageFull>, MessageError>
Retrieve a specific message by its ID
Sourceasync fn user_data(
self,
context: Context,
author: KeyId,
storage_key: StoreKey,
) -> Result<Option<MessageFull>, MessageError>
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
Sourceasync fn check_messages(
self,
context: Context,
message_ids: Vec<MessageId>,
) -> Result<Vec<Option<String>>, MessageError>
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 IDNonemeans the server doesn’t have this message yet
Sourceasync fn subscribe(
self,
context: Context,
config: SubscriptionConfig,
) -> Result<(), MessageError>
async fn subscribe( self, context: Context, config: SubscriptionConfig, ) -> Result<(), MessageError>
Start the subscription
Sourceasync fn update_filters(
self,
context: Context,
request: FilterUpdateRequest,
) -> Result<SubscriptionConfig, MessageError>
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.
Sourceasync fn catch_up(
self,
context: Context,
request: CatchUpRequest,
) -> Result<SubscriptionConfig, MessageError>
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§
Sourcefn serve(self) -> ServeMessageService<Self>
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.