AtomicBus

Struct AtomicBus 

Source
pub struct AtomicBus<T> { /* private fields */ }
Expand description

A bus, which can send data to a set of active subscriptions.

§Data Lifetime

All underlying data is wrapped in an Arc which will be dropped immediately after all active subscribers have dropped their respective references.

§Sync

AtomicBus is Sync, so it can be wrapped in an Arc to safely share between threads.

Implementations§

Source§

impl<T> AtomicBus<T>

Source

pub fn new() -> Self

Create a new AtomicBus

Source

pub fn send<A: Into<Arc<T>>>(&self, data: A)

Send an event to the AtomicBus which will be received by all current subscribers.

§Alternatives

If you wish to limit code to be publish-only, see [AtomicBus::sender] to create a send-only struct for this bus.

Source

pub fn create_sender(&self) -> AtomicSender<T>

Create a send-only structure to produce messages to this bus.

Source

pub fn subscribe(&self) -> AtomicSubscription<T>

Create an atomic subscription to this bus, which is Sync and can be shared between threads.

Source

pub fn subscribe_mut(&self) -> MutSubscription<T>

Create a mutable subscription to this bus, which is slightly faster than the atomic variant but is not Sync.

Trait Implementations§

Source§

impl<T> Default for AtomicBus<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for AtomicBus<T>

§

impl<T> RefUnwindSafe for AtomicBus<T>
where T: RefUnwindSafe,

§

impl<T> Send for AtomicBus<T>
where T: Sync + Send,

§

impl<T> Sync for AtomicBus<T>
where T: Sync + Send,

§

impl<T> Unpin for AtomicBus<T>

§

impl<T> UnwindSafe for AtomicBus<T>
where T: RefUnwindSafe,

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.