Struct ActorSelection

Source
pub struct ActorSelection { /* private fields */ }
Expand description

A selection represents part of the actor heirarchy, allowing messages to be sent to all actors in the selection.

There are several use cases where you would interact with actors via a selection instead of actor references:

  • You know the path of an actor but you don’t have its ActorRef
  • You want to broadcast a message to all actors within a path

ActorRef is almost always the better choice for actor interaction, since messages are directly sent to the actor’s mailbox without any preprocessing or cloning.

ActorSelection provides flexibility for the cases where at runtime the ActorRefs can’t be known. This comes at the cost of traversing part of the actor heirarchy and cloning messages.

A selection is anchored to an ActorRef and the path is relative to that actor’s path.

selection.try_tell() is used to message actors in the selection. Since a selection is a collection of BasicActorRefs messaging is un-typed. Messages not supported by any actor in the selection will be dropped.

Implementations§

Source§

impl ActorSelection

Source

pub fn new(anchor: BasicActorRef, path: String) -> Result<Self, InvalidPath>

Source

pub fn try_tell<Msg>(&self, msg: Msg, sender: impl Into<Option<BasicActorRef>>)
where Msg: Message,

Source

pub fn sys_tell(&self, msg: SystemMsg, sender: impl Into<Option<BasicActorRef>>)

Trait Implementations§

Source§

impl Debug for ActorSelection

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V