Skip to main content

RemoteActorRegistry

Struct RemoteActorRegistry 

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

A registry of actors in the current process which can receive RemoteMessages.

The registry is a cheaply-cloneable concurrent map shared between a Node and all of its sessions. It lets sessions route inbound RemoteMessages to the proper actor in the same process.

An actor which implements the RemoteActor trait will be automatically registered in a Node’s registry when its address is encoded as a RemoteMessage for the first time. Users can also manually register an actor with a Node’s AddActor command.

Implementations§

Source§

impl RemoteActorRegistry

Source

pub fn new() -> Self

Constructs a new empty RemoteActorRegistry.

Source

pub fn with_capacity(capacity: usize) -> Self

Constructs a new empty RemoteActorRegistry with the specified capacity.

Source

pub fn capacity(&self) -> usize

Returns the number of actors the registry can hold without reallocating.

Locking behavior: May deadlock if called when holding a mutable reference into the registry.

Source

pub fn len(&self) -> usize

Returns the number of actors currently in the registry.

Locking behavior: May deadlock if called when holding a mutable reference into the registry.

Source

pub fn is_empty(&self) -> bool

Returns true if the registry contains no actors.

Locking behavior: May deadlock if called when holding a mutable reference into the registry.

Source

pub fn retain<F>(&self, predicate: F)

Retains only the actors for which the predicate returns true.

Locking behavior: May deadlock if called when holding any sort of reference into the registry.

Source

pub fn get(&self, index: u64) -> Option<Recipient<RemoteMessage>>

Returns an actor as a Recipient<RemoteMessage> corresponding to the given index.

If the actor’s mailbox is closed, this method removes it and returns None. This is different from the behavior of get on a normal HashMap.

Locking behavior: May deadlock if called when holding any sort of reference into the registry.

Source

pub fn contains_index(&self, index: u64) -> bool

Returns true if the registry contains an actor for the given index.

Locking behavior: May deadlock if called when holding a mutable reference into the registry.

Source

pub fn remove(&self, index: u64) -> Option<Recipient<RemoteMessage>>

Removes an actor by its index, returning the actor as a Recipient<RemoteMessage> if it was present in the registry.

Locking behavior: May deadlock if called when holding any sort of reference into the registry.

Source

pub fn insert<A>(&self, actor: A) -> bool

Inserts a new actor keyed by its index.

If the registry did not have this actor present, true is returned. If the registry did have this actor present, false is returned and the registry is not modified. This is different from the behavior of insert on a normal HashMap.

Re-registering the same address is a cheap lookup-no-op.

Locking behavior: May deadlock if called when holding any sort of reference into the registry.

Trait Implementations§

Source§

impl Clone for RemoteActorRegistry

Source§

fn clone(&self) -> RemoteActorRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RemoteActorRegistry

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for RemoteActorRegistry

Source§

fn default() -> RemoteActorRegistry

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more