pub struct Subscribe<E: Event, T: Topic<E>>(/* private fields */);Expand description
Specifies which topics an actor subscribes to.
Use the static constructors to create subscriptions:
Subscribe::all()- receive events on all topics (e.g., monitoring actors)Subscribe::none()- receive no events (e.g., pure event producers)Subscribe::to- receive events on specific topics
For convenience, &[T] converts to Subscribe automatically:
ⓘ
// These are equivalent:
sup.add_actor("a", factory, &[Topic::Data])?;
sup.add_actor("a", factory, Subscribe::to([Topic::Data]))?;Implementations§
Source§impl<E: Event, T: Topic<E>> Subscribe<E, T>
impl<E: Event, T: Topic<E>> Subscribe<E, T>
Sourcepub fn all() -> Self
pub fn all() -> Self
Subscribe to all topics.
Useful for monitoring actors that need to observe all events.
Sourcepub fn none() -> Self
pub fn none() -> Self
Subscribe to no topics.
Useful for actors that only produce events and don’t need to receive any.
Sourcepub fn to(topics: impl IntoIterator<Item = T>) -> Self
pub fn to(topics: impl IntoIterator<Item = T>) -> Self
Subscribe to specific topics.
Accepts any iterator of topics:
ⓘ
Subscribe::to([Topic::A, Topic::B])
Subscribe::to(vec![Topic::A])
Subscribe::to(&[Topic::A, Topic::B])Trait Implementations§
Auto Trait Implementations§
impl<E, T> Freeze for Subscribe<E, T>
impl<E, T> RefUnwindSafe for Subscribe<E, T>where
T: RefUnwindSafe,
impl<E, T> Send for Subscribe<E, T>
impl<E, T> Sync for Subscribe<E, T>
impl<E, T> Unpin for Subscribe<E, T>where
T: Unpin,
impl<E, T> UnwindSafe for Subscribe<E, T>where
T: UnwindSafe,
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