pub struct Channel { /* private fields */ }Expand description
A pub/sub channel for event distribution.
Implementations§
Source§impl Channel
impl Channel
Sourcepub fn with_config(id: impl Into<ChannelId>, config: ChannelConfig) -> Self
pub fn with_config(id: impl Into<ChannelId>, config: ChannelConfig) -> Self
Create a channel with custom configuration.
Sourcepub fn publish(&self, event: Event) -> Result<usize, ChannelError>
pub fn publish(&self, event: Event) -> Result<usize, ChannelError>
Publish an event to the channel.
Sourcepub fn subscribe(
&self,
subscriber_id: SubscriberId,
) -> Result<ChannelReceiver, ChannelError>
pub fn subscribe( &self, subscriber_id: SubscriberId, ) -> Result<ChannelReceiver, ChannelError>
Subscribe to the channel.
Sourcepub fn subscribe_with_filter(
&self,
subscriber_id: SubscriberId,
filter: EventFilter,
) -> Result<ChannelReceiver, ChannelError>
pub fn subscribe_with_filter( &self, subscriber_id: SubscriberId, filter: EventFilter, ) -> Result<ChannelReceiver, ChannelError>
Subscribe with a filter.
Sourcepub fn subscribe_with_ack_mode(
&self,
subscriber_id: SubscriberId,
filter: Option<EventFilter>,
ack_mode: AckMode,
) -> Result<ChannelReceiver, ChannelError>
pub fn subscribe_with_ack_mode( &self, subscriber_id: SubscriberId, filter: Option<EventFilter>, ack_mode: AckMode, ) -> Result<ChannelReceiver, ChannelError>
Subscribe with a specific ack mode.
Sourcepub fn unsubscribe(&self, subscriber_id: &SubscriberId)
pub fn unsubscribe(&self, subscriber_id: &SubscriberId)
Unsubscribe from the channel.
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Get the number of subscribers.
Sourcepub fn get_history(&self, count: usize) -> Vec<Event>
pub fn get_history(&self, count: usize) -> Vec<Event>
Get recent events from history.
Sourcepub fn get_history_after(&self, timestamp: u64) -> Vec<Event>
pub fn get_history_after(&self, timestamp: u64) -> Vec<Event>
Get events from history after a timestamp.
Sourcepub fn stats(&self) -> ChannelStats
pub fn stats(&self) -> ChannelStats
Get channel statistics.
Sourcepub fn clear_history(&self)
pub fn clear_history(&self)
Clear history.
Auto Trait Implementations§
impl !Freeze for Channel
impl !RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl UnsafeUnpin for Channel
impl !UnwindSafe for Channel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more