Trait embassy_sync::pubsub::PubSubBehavior
source · 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§
sourcefn get_message_with_context(
&self,
next_message_id: &mut u64,
cx: Option<&mut Context<'_>>
) -> Poll<WaitResult<T>>
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.
sourcefn available(&self, next_message_id: u64) -> u64
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.
sourcefn publish_with_context(
&self,
message: T,
cx: Option<&mut Context<'_>>
) -> Result<(), T>
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.
sourcefn publish_immediate(&self, message: T)
fn publish_immediate(&self, message: T)
Publish a message immediately
sourcefn space(&self) -> usize
fn space(&self) -> usize
The amount of messages that can still be published without having to wait or without having to lag the subscribers
sourcefn unregister_subscriber(&self, subscriber_next_message_id: u64)
fn unregister_subscriber(&self, subscriber_next_message_id: u64)
Let the channel know that a subscriber has dropped
sourcefn unregister_publisher(&self)
fn unregister_publisher(&self)
Let the channel know that a publisher has dropped