Broker

Struct Broker 

Source
pub struct Broker<T>
where T: Message<Result = ()> + Clone,
{ /* private fields */ }

Implementations§

Source§

impl<T> Broker<T>
where T: Message<Result = ()> + Clone,

Source

pub fn new() -> Self

Source

pub async fn subscribe<A: Actor + Handler<T>>( subscriber: Address<A>, ) -> Result<Subscription<T>, ()>

Source

pub async fn publish(message: T) -> Result<(), Disconnected>

Trait Implementations§

Source§

impl<T> Actor for Broker<T>
where T: Message<Result = ()> + Clone,

Source§

fn started<'life0, 'life1, 'async_trait>( &'life0 mut self, ctx: &'life1 mut Context<Self>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Called as soon as the actor has been started.
Source§

fn stopping<'life0, 'life1, 'async_trait>( &'life0 mut self, ctx: &'life1 mut Context<Self>, ) -> Pin<Box<dyn Future<Output = KeepRunning> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Called when the actor calls the Context::stop. This method can prevent the actor from stopping by returning KeepRunning::Yes. If this method returns KeepRunning::StopSelf, this actor will be stopped. If it returns KeepRunning::StopAll, then all actors on the same address as this actor will be stopped. This can take a little bit of time to propagate. Read more
Source§

fn stopped<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Called when the actor is in the process of stopping. This could be because KeepRunning::StopAll or KeepRunning::StopSelf was returned from the Actor::stopping method, or because there are no more strong addresses (Address, as opposed to WeakAddress. This should be used for any final cleanup before the actor is dropped.
Source§

fn create(self, message_cap: Option<usize>) -> ActorManager<Self>

Returns the actor’s address and manager in a ready-to-start state, given the cap for the actor’s mailbox. If None is passed, it will be of unbounded size. To spawn the actor, the ActorManager::spawn must be called, or the ActorManager::run method must be called and the future it returns spawned onto an executor. Read more
Source§

impl<T> Default for Broker<T>
where T: Message<Result = ()> + Clone,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Freeze for Broker<T>

§

impl<T> !RefUnwindSafe for Broker<T>

§

impl<T> Send for Broker<T>

§

impl<T> Sync for Broker<T>

§

impl<T> Unpin for Broker<T>

§

impl<T> !UnwindSafe for Broker<T>

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<A> FromRegistryExt for A
where A: Actor + Default,

Source§

fn from_registry<'async_trait>() -> Pin<Box<dyn Future<Output = Address<A>> + Send + 'async_trait>>
where A: 'async_trait,

Source§

impl<A> FromRegistryExtOpt for A
where A: Actor,

Source§

fn from_registry_opt<'async_trait>() -> Pin<Box<dyn Future<Output = Option<Address<A>>> + Send + 'async_trait>>
where A: 'async_trait,

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.