Struct Address

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

Source

pub fn close(&self) -> bool

Close the Channel.

Source

pub fn halt_some(&self, n: u32)

Halt n processes of the actor.

Source

pub fn halt(&self)

Halt the actor.

This also closes the Inbox.

Source

pub fn process_count(&self) -> usize

Get the amount of processes.

Source

pub fn msg_count(&self) -> usize

Get the amount of messages in the channel.

Source

pub fn address_count(&self) -> usize

Get the amount of addresses of the actor.

Source

pub fn is_closed(&self) -> bool

Whether the channel is closed.

Source

pub fn capacity(&self) -> &Capacity

Get the capacity of the channel.

Source

pub fn has_exited(&self) -> bool

Whether the actor has exited.

Source

pub fn actor_id(&self) -> u64

Get the actor id.

Source

pub fn is_bounded(&self) -> bool

Whether the channel is bounded.

Source

pub fn try_send<M>(&self, msg: M) -> Result<ReturnPart<M>, TrySendError<M>>
where M: Message, T: Accepts<M>,

Attempts to send a message to an actor. If the mailbox is full or if a timeout is returned this method will fail.

Source

pub fn send_now<M>(&self, msg: M) -> Result<ReturnPart<M>, TrySendError<M>>
where M: Message, T: Accepts<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.

Source

pub fn send_blocking<M>(&self, msg: M) -> Result<ReturnPart<M>, SendError<M>>
where M: Message, T: Accepts<M>,

Same as send, but blocks the thread instead.

Source

pub fn send<M>(&self, msg: M) -> SendFut<'_, M>
where M: Message, T: Accepts<M>,

Send a message to the actor. If the inbox is full or returns a timeout, wait for this and then send it.

Source§

impl<P> Address<P>
where P: ActorType<Channel = Channel<P>>,

Source

pub fn into_dyn<T>(self) -> Address<T>
where P: Protocol + IntoDynamic<T>, T: ActorType<Channel = dyn BoxChannel>,

Convert the static actor into a dynamic one, checked at compile-time.

Source§

impl<D> Address<D>
where D: ActorType<Channel = dyn BoxChannel>,

Source

pub fn try_send_unchecked<M>( &self, msg: M, ) -> Result<ReturnPart<M>, TrySendUncheckedError<M>>
where M: Message + Send + 'static, SendPart<M>: Send + 'static,

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.

Source

pub fn send_now_unchecked<M>( &self, msg: M, ) -> Result<ReturnPart<M>, TrySendUncheckedError<M>>
where M: Message + Send + 'static, SendPart<M>: Send + 'static,

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.

Source

pub fn send_blocking_unchecked<M>( &self, msg: M, ) -> Result<ReturnPart<M>, SendUncheckedError<M>>
where M: Message + Send + 'static, SendPart<M>: Send + 'static,

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.

Source

pub async fn send_unchecked<M>( &self, msg: M, ) -> Result<ReturnPart<M>, SendUncheckedError<M>>
where M: Message + Send + 'static, SendPart<M>: Send + 'static,

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.

Source

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.

Source

pub fn transform<T>(self) -> Address<T>
where D: IntoDynamic<T>, T: ActorType<Channel = dyn BoxChannel>,

Transfor a dynamic actor of one type into another type, while checking at compile time if the actor accepts all messages.

Source

pub fn try_transform<T>(self) -> Result<Address<T>, Self>
where T: IsDynamic + ActorType<Channel = dyn BoxChannel>,

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.

Source

pub fn accepts(&self, id: &TypeId) -> bool

Whether the actor accepts a message of the given type-id.

Source

pub fn downcast<T>(self) -> Result<Address<T>, Self>
where T: Protocol,

Downcast the dynamic actor back into the static actor given a protocol T.

Trait Implementations§

Source§

impl<T: ActorType> Clone for Address<T>

Source§

fn clone(&self) -> Self

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<T: ActorType> Debug for Address<T>

Source§

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

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

impl<T: ActorType> Future for Address<T>

Source§

type Output = ()

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Source§

impl<R: ?Sized, T: ?Sized> IntoAddress<Dyn<T>> for Address<Dyn<R>>
where Dyn<R>: ActorType<Channel = dyn BoxChannel> + IntoDynamic<Dyn<T>>,

Source§

impl<P, T> IntoAddress<Dyn<T>> for Address<P>
where P: Protocol + IntoDynamic<Dyn<T>>, T: ?Sized,

Source§

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> 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> FutureExt for T
where T: Future + ?Sized,

Source§

fn map<U, F>(self, f: F) -> Map<Self, F>
where F: FnOnce(Self::Output) -> U, Self: Sized,

Map this future’s output to a different type, returning a new future of the resulting type. Read more
Source§

fn map_into<U>(self) -> MapInto<Self, U>
where Self::Output: Into<U>, Self: Sized,

Map this future’s output to a different type, returning a new future of the resulting type. Read more
Source§

fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
where F: FnOnce(Self::Output) -> Fut, Fut: Future, Self: Sized,

Chain on a computation for when a future finished, passing the result of the future to the provided closure f. Read more
Source§

fn left_future<B>(self) -> Either<Self, B>
where B: Future<Output = Self::Output>, Self: Sized,

Wrap this future in an Either future, making it the left-hand variant of that Either. Read more
Source§

fn right_future<A>(self) -> Either<A, Self>
where A: Future<Output = Self::Output>, Self: Sized,

Wrap this future in an Either future, making it the right-hand variant of that Either. Read more
Source§

fn into_stream(self) -> IntoStream<Self>
where Self: Sized,

Convert this future into a single element stream. Read more
Source§

fn flatten(self) -> Flatten<Self>
where Self::Output: Future, Self: Sized,

Flatten the execution of this future when the output of this future is itself another future. Read more
Source§

fn flatten_stream(self) -> FlattenStream<Self>
where Self::Output: Stream, Self: Sized,

Flatten the execution of this future when the successful result of this future is a stream. Read more
Source§

fn fuse(self) -> Fuse<Self>
where Self: Sized,

Fuse a future such that poll will never again be called once it has completed. This method can be used to turn any Future into a FusedFuture. Read more
Source§

fn inspect<F>(self, f: F) -> Inspect<Self, F>
where F: FnOnce(&Self::Output), Self: Sized,

Do something with the output of a future before passing it on. Read more
Source§

fn catch_unwind(self) -> CatchUnwind<Self>
where Self: Sized + UnwindSafe,

Catches unwinding panics while polling the future. Read more
Source§

fn shared(self) -> Shared<Self>
where Self: Sized, Self::Output: Clone,

Create a cloneable handle to this future where all handles will resolve to the same result. Read more
Source§

fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)
where Self: Sized,

Turn this future into a future that yields () on completion and sends its output to another future on a separate task. Read more
Source§

fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
where Self: Sized + Send + 'a,

Wrap the future in a Box, pinning it. Read more
Source§

fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>
where Self: Sized + 'a,

Wrap the future in a Box, pinning it. Read more
Source§

fn unit_error(self) -> UnitError<Self>
where Self: Sized,

Source§

fn never_error(self) -> NeverError<Self>
where Self: Sized,

Source§

fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output>
where Self: Unpin,

A convenience for calling Future::poll on Unpin future types.
Source§

fn now_or_never(self) -> Option<Self::Output>
where Self: Sized,

Evaluates and consumes the future, returning the resulting output if the future is ready after the first call to Future::poll. 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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
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, 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.