pub trait PubSubBehavior<T> {
    // Required methods
    fn get_message_with_context(
        &self,
        next_message_id: &mut u64,
        cx: Option<&mut Context<'_>>
    ) -> Poll<WaitResult<T>>;
    fn available(&self, next_message_id: u64) -> u64;
    fn publish_with_context(
        &self,
        message: T,
        cx: Option<&mut Context<'_>>
    ) -> Result<(), T>;
    fn publish_immediate(&self, message: T);
    fn space(&self) -> usize;
    fn unregister_subscriber(&self, subscriber_next_message_id: u64);
    fn unregister_publisher(&self);
}
Expand description

‘Middle level’ behaviour of the pubsub channel. This trait is used so that Sub and Pub can be generic over the channel.

Required Methods§

source

fn get_message_with_context( &self, next_message_id: &mut u64, cx: Option<&mut Context<'_>> ) -> Poll<WaitResult<T>>

Try to get a message from the queue with the given message id.

If the message is not yet present and a context is given, then its waker is registered in the subsriber wakers.

source

fn available(&self, next_message_id: u64) -> u64

Get the amount of messages that are between the given the next_message_id and the most recent message. This is not necessarily the amount of messages a subscriber can still received as it may have lagged.

source

fn publish_with_context( &self, message: T, cx: Option<&mut Context<'_>> ) -> Result<(), T>

Try to publish a message to the queue.

If the queue is full and a context is given, then its waker is registered in the publisher wakers.

source

fn publish_immediate(&self, message: T)

Publish a message immediately

source

fn space(&self) -> usize

The amount of messages that can still be published without having to wait or without having to lag the subscribers

source

fn unregister_subscriber(&self, subscriber_next_message_id: u64)

Let the channel know that a subscriber has dropped

source

fn unregister_publisher(&self)

Let the channel know that a publisher has dropped

Implementors§

source§

impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> PubSubBehavior<T> for PubSubChannel<M, T, CAP, SUBS, PUBS>