Struct MultiTopicReceiver

Source
pub struct MultiTopicReceiver<T: Eq + Hash + Clone, M: Clone> { /* private fields */ }
Expand description

A multi-topic receiver that listens to messages from multiple topics.

§Type Parameters

  • T: The type representing a topic.
  • M: The message type being received.

Implementations§

Source§

impl<T: Eq + Hash + Clone, M: Clone> MultiTopicReceiver<T, M>

Source

pub fn new(subscribers: Arc<DashMap<T, Sender<M>>>) -> Self

Creates a new MultiTopicReceiver for the given TopicStream.

§Arguments
  • subscribers: A reference to the DashMap containing the active subscribers.
§Returns

A new MultiTopicReceiver instance.

Source

pub fn subscribe(&mut self, topics: &[T])

Subscribes to the given list of topics. If already subscribed to a topic, it is ignored.

§Arguments
  • topics: A slice of topics to subscribe to.
Source

pub async fn recv(&mut self) -> Option<M>

An Option containing the received message, or None if all receivers are closed.

Trait Implementations§

Source§

impl<T: Debug + Eq + Hash + Clone, M: Debug + Clone> Debug for MultiTopicReceiver<T, M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq + Hash + Clone, M: Clone> Drop for MultiTopicReceiver<T, M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T, M> Freeze for MultiTopicReceiver<T, M>

§

impl<T, M> !RefUnwindSafe for MultiTopicReceiver<T, M>

§

impl<T, M> Send for MultiTopicReceiver<T, M>
where T: Send + Sync, M: Send,

§

impl<T, M> Sync for MultiTopicReceiver<T, M>
where T: Sync + Send, M: Send,

§

impl<T, M> Unpin for MultiTopicReceiver<T, M>
where T: Unpin,

§

impl<T, M> !UnwindSafe for MultiTopicReceiver<T, M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.