pub struct MemoryAdapter { /* private fields */ }Expand description
Memory-based message broker
Implementations§
Source§impl MemoryAdapter
impl MemoryAdapter
pub fn new(buffer_size: usize) -> Self
Sourcepub async fn publish(
&self,
topic: impl Into<String>,
payload: Value,
) -> Result<()>
pub async fn publish( &self, topic: impl Into<String>, payload: Value, ) -> Result<()>
Publish a message to a topic
Sourcepub async fn subscribe<H>(
&self,
topic: impl Into<String>,
handler: Arc<H>,
) -> Result<()>where
H: MessageHandler + 'static,
pub async fn subscribe<H>(
&self,
topic: impl Into<String>,
handler: Arc<H>,
) -> Result<()>where
H: MessageHandler + 'static,
Subscribe to a topic with a handler
Sourcepub async fn subscribe_fn<F, Fut>(
&self,
topic: impl Into<String>,
handler: F,
) -> Result<()>
pub async fn subscribe_fn<F, Fut>( &self, topic: impl Into<String>, handler: F, ) -> Result<()>
Subscribe with a closure
Sourcepub async fn list_topics(&self) -> Vec<String>
pub async fn list_topics(&self) -> Vec<String>
Get list of all topics
Sourcepub async fn subscriber_count(&self, topic: &str) -> usize
pub async fn subscriber_count(&self, topic: &str) -> usize
Get subscriber count for a topic
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryAdapter
impl !RefUnwindSafe for MemoryAdapter
impl Send for MemoryAdapter
impl Sync for MemoryAdapter
impl Unpin for MemoryAdapter
impl !UnwindSafe for MemoryAdapter
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