MessagesManagerTrait

Trait MessagesManagerTrait 

Source
pub trait MessagesManagerTrait: Send + Sync {
    // Required methods
    fn message_events_stream(&self) -> Receiver<MessageEvent>;
    fn get_subscription_state_updates<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Subscriber<SubscriptionState, AsyncLock>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn publish<'life0, 'async_trait>(
        &'life0 self,
        message: MessageFull,
    ) -> Pin<Box<dyn Future<Output = Result<PublishResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn ensure_contains_filter<'life0, 'async_trait>(
        &'life0 self,
        filter: Filter,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn messages_stream(&self) -> Receiver<StreamMessage>;
    fn catch_up_stream(&self) -> Receiver<CatchUpResponse>;
    fn filtered_messages_stream(
        &self,
        filter: Filter,
    ) -> Pin<Box<dyn Stream<Item = Box<MessageFull>> + Send>>;
    fn catch_up_and_subscribe<'life0, 'async_trait>(
        &'life0 self,
        filter: Filter,
        since: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Box<MessageFull>> + Send>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn user_data<'life0, 'async_trait>(
        &'life0 self,
        author: KeyId,
        storage_key: StoreKey,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MessageFull>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn check_messages<'life0, 'async_trait>(
        &'life0 self,
        message_ids: Vec<MessageId>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<String>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait abstraction for MessagesManager to enable mocking in tests

Required Methods§

Source

fn message_events_stream(&self) -> Receiver<MessageEvent>

Get a stream of all message events for persistence and monitoring

Source

fn get_subscription_state_updates<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Subscriber<SubscriptionState, AsyncLock>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to subscription state changes for reactive programming

This returns an eyeball::Subscriber that can be used to observe changes to the subscription state reactively. The subscriber will be notified whenever:

  • Stream height is updated
  • Filters are added or removed
  • Any other subscription state changes occur
§Example
let subscriber = manager.subscribe_to_subscription_state();
let current_state = subscriber.get();
println!("Current stream height: {:?}", current_state.latest_stream_height);
Source

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

Subscribe to messages with current filters

Source

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

Publish a message

Source

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

Ensure a filter is included in the subscription

Source

fn messages_stream(&self) -> Receiver<StreamMessage>

Get a stream of incoming messages

Source

fn catch_up_stream(&self) -> Receiver<CatchUpResponse>

Get a stream of catch-up responses

Source

fn filtered_messages_stream( &self, filter: Filter, ) -> Pin<Box<dyn Stream<Item = Box<MessageFull>> + Send>>

Get a filtered stream of messages matching the given filter

Source

fn catch_up_and_subscribe<'life0, 'async_trait>( &'life0 self, filter: Filter, since: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Box<MessageFull>> + Send>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Catch up to historical messages and subscribe to new ones for a filter

Source

fn user_data<'life0, 'async_trait>( &'life0 self, author: KeyId, storage_key: StoreKey, ) -> Pin<Box<dyn Future<Output = Result<Option<MessageFull>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get user data by author and storage key (for PQXDH inbox fetching)

Source

fn check_messages<'life0, 'async_trait>( &'life0 self, message_ids: Vec<MessageId>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<String>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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

Implementors§