pub struct Address<T: ActorType = Dyn<dyn AcceptsNone>> { /* private fields */ }
Expand description
§Types
An Address
can be of two basic types: Dynamic or static.
§Static
A static address is typed the Protocol of the actor: Address<P>
. Any
messages the protocol accepts can be sent to this address.
§Dynamic
A dynamic address is typed by the messages it accepts: DynAddress![u32, u64, ...]
. Any messages
that appear can be sent to this address.
§For more information, please read the module documentation.
Implementations§
Source§impl<T: ActorType> Address<T>
impl<T: ActorType> Address<T>
Sourcepub fn process_count(&self) -> usize
pub fn process_count(&self) -> usize
Get the amount of processes.
Sourcepub fn address_count(&self) -> usize
pub fn address_count(&self) -> usize
Get the amount of addresses of the actor.
Sourcepub fn has_exited(&self) -> bool
pub fn has_exited(&self) -> bool
Whether the actor has exited.
Sourcepub fn is_bounded(&self) -> bool
pub fn is_bounded(&self) -> bool
Whether the channel is bounded.
Sourcepub fn try_send<M>(&self, msg: M) -> Result<ReturnPart<M>, TrySendError<M>>
pub fn try_send<M>(&self, msg: M) -> Result<ReturnPart<M>, TrySendError<M>>
Attempts to send a message to an actor. If the mailbox is full or if a timeout is returned this method will fail.
Sourcepub fn send_now<M>(&self, msg: M) -> Result<ReturnPart<M>, TrySendError<M>>
pub fn send_now<M>(&self, msg: M) -> Result<ReturnPart<M>, TrySendError<M>>
Attempts to send a message to an actor. If the mailbox is full this will fail, but if a timeout is returned then this will succeed.
Sourcepub fn send_blocking<M>(&self, msg: M) -> Result<ReturnPart<M>, SendError<M>>
pub fn send_blocking<M>(&self, msg: M) -> Result<ReturnPart<M>, SendError<M>>
Same as send
, but blocks the thread instead.
Source§impl<P> Address<P>
impl<P> Address<P>
Source§impl<D> Address<D>where
D: ActorType<Channel = dyn BoxChannel>,
impl<D> Address<D>where
D: ActorType<Channel = dyn BoxChannel>,
Sourcepub fn try_send_unchecked<M>(
&self,
msg: M,
) -> Result<ReturnPart<M>, TrySendUncheckedError<M>>
pub fn try_send_unchecked<M>( &self, msg: M, ) -> Result<ReturnPart<M>, TrySendUncheckedError<M>>
Send a message to an actor without checking whether this actor accepts the message.
If the actor does not accept the message, then nothing is sent and an error is returned.
Sourcepub fn send_now_unchecked<M>(
&self,
msg: M,
) -> Result<ReturnPart<M>, TrySendUncheckedError<M>>
pub fn send_now_unchecked<M>( &self, msg: M, ) -> Result<ReturnPart<M>, TrySendUncheckedError<M>>
Send a message to an actor without checking whether this actor accepts the message.
If the actor does not accept the message, then nothing is sent and an error is returned.
Sourcepub fn send_blocking_unchecked<M>(
&self,
msg: M,
) -> Result<ReturnPart<M>, SendUncheckedError<M>>
pub fn send_blocking_unchecked<M>( &self, msg: M, ) -> Result<ReturnPart<M>, SendUncheckedError<M>>
Send a message to an actor without checking whether this actor accepts the message.
If the actor does not accept the message, then nothing is sent and an error is returned.
Sourcepub async fn send_unchecked<M>(
&self,
msg: M,
) -> Result<ReturnPart<M>, SendUncheckedError<M>>
pub async fn send_unchecked<M>( &self, msg: M, ) -> Result<ReturnPart<M>, SendUncheckedError<M>>
Send a message to an actor without checking whether this actor accepts the message.
If the actor does not accept the message, then nothing is sent and an error is returned.
Sourcepub fn transform_unchecked<T>(self) -> Address<T> ⓘwhere
T: ActorType<Channel = dyn BoxChannel>,
pub fn transform_unchecked<T>(self) -> Address<T> ⓘwhere
T: ActorType<Channel = dyn BoxChannel>,
Transform a dynamic-actor of one type into another type without checking if the actor accepts the messages.
In most cases it is recomended to use transform
and try_transform
instead.
Sourcepub fn transform<T>(self) -> Address<T> ⓘ
pub fn transform<T>(self) -> Address<T> ⓘ
Transfor a dynamic actor of one type into another type, while checking at compile time if the actor accepts all messages.
Sourcepub fn try_transform<T>(self) -> Result<Address<T>, Self>
pub fn try_transform<T>(self) -> Result<Address<T>, Self>
Transfor a dynamic actor of one type into another type, while checking at runtime if the actor accepts all messages.
Wherever possible use transform
instead.
Trait Implementations§
Source§impl<P, T> IntoAddress<Dyn<T>> for Address<P>
impl<P, T> IntoAddress<Dyn<T>> for Address<P>
impl<T: ActorType> Unpin for Address<T>
Auto Trait Implementations§
impl<T> Freeze for Address<T>
impl<T> RefUnwindSafe for Address<T>
impl<T> Send for Address<T>
impl<T> Sync for Address<T>
impl<T> UnwindSafe for Address<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read moreSource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read moreSource§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.Source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.