Struct tiny_actor::actor::Address
source · [−]pub struct Address<C = dyn AnyChannel> where
C: DynChannel + ?Sized, { /* private fields */ }Expand description
An address is a reference to the actor, used to send messages.
Addresses can be of two forms:
Address<Channel<M>>: This is the default form, which can be used to send messages of typeM. It can be transformed into anAddressusing Address::into_dyn.Address: This form is a dynamic address, which can do everything a normal address can do, except for sending messages. It can be transformed back into anAddress<Channel<M>>using Address::downcast::.
An address can be awaited which returns once the actor exits.
Implementations
sourceimpl<C> Address<C> where
C: DynChannel + ?Sized,
impl<C> Address<C> where
C: DynChannel + ?Sized,
sourcepub fn downcast<M: Send + 'static>(self) -> Result<Address<Channel<M>>, Self> where
C: AnyChannel,
pub fn downcast<M: Send + 'static>(self) -> Result<Address<Channel<M>>, Self> where
C: AnyChannel,
Attempt to the downcast the Address into an Address<Channel<M>>.
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
pub fn is_bounded(&self) -> bool
sourcepub fn has_exited(&self) -> bool
pub fn has_exited(&self) -> bool
Whether all processes have exited.
sourceimpl<M> Address<Channel<M>>
impl<M> Address<Channel<M>>
sourcepub fn into_dyn(self) -> AddressⓘNotable traits for Address<C>impl<C: DynChannel + ?Sized> Future for Address<C> type Output = (); where
M: Send + 'static,
pub fn into_dyn(self) -> AddressⓘNotable traits for Address<C>impl<C: DynChannel + ?Sized> Future for Address<C> type Output = (); where
M: Send + 'static,
Convert the Address<Channel<M>> into an Address.
sourcepub fn try_send(&self, msg: M) -> Result<(), TrySendError<M>>
pub fn try_send(&self, msg: M) -> Result<(), TrySendError<M>>
Attempt to send a message to the actor.
- In the case of an
unboundedChannel, when BackPressure returns a timeout this fails. - In the case of a
boundedChannel, when it is full this fails.
For bounded channels, this method is the same as send_now.
sourcepub fn send_now(&self, msg: M) -> Result<(), TrySendError<M>>
pub fn send_now(&self, msg: M) -> Result<(), TrySendError<M>>
Attempt to send a message to the actor.
- In the case of an
unboundedChannel, any BackPressure is ignored. - In the case of a
boundedChannel, when it is full this fails.
For bounded channels, this method is the same as try_send.
sourcepub fn send(&self, msg: M) -> Snd<'_, M>ⓘNotable traits for Snd<'a, M>impl<'a, M> Future for Snd<'a, M> type Output = Result<(), SendError<M>>;
pub fn send(&self, msg: M) -> Snd<'_, M>ⓘNotable traits for Snd<'a, M>impl<'a, M> Future for Snd<'a, M> type Output = Result<(), SendError<M>>;
Attempt to send a message to the actor.
- In the case of an
unboundedChannel, when BackPressure returns a timeout this waits untill the timeout is over. - In the case of a
boundedChannel, when it is full this waits untill space is available.
Trait Implementations
sourceimpl<C: DynChannel + ?Sized> Clone for Address<C>
impl<C: DynChannel + ?Sized> Clone for Address<C>
sourceimpl<C: DynChannel + ?Sized> Drop for Address<C>
impl<C: DynChannel + ?Sized> Drop for Address<C>
sourceimpl<C: DynChannel + ?Sized> Future for Address<C>
impl<C: DynChannel + ?Sized> Future for Address<C>
impl<C: DynChannel + ?Sized> Unpin for Address<C>
Auto Trait Implementations
impl<C: ?Sized> RefUnwindSafe for Address<C> where
C: RefUnwindSafe,
impl<C: ?Sized> Send for Address<C> where
C: Send + Sync,
impl<C: ?Sized> Sync for Address<C> where
C: Send + Sync,
impl<C: ?Sized> UnwindSafe for Address<C> where
C: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> FutureExt for T where
T: Future + ?Sized,
impl<T> FutureExt for T where
T: Future + ?Sized,
fn map<U, F>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Output) -> U,
fn map<U, F>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Output) -> U,
Map this future’s output to a different type, returning a new future of the resulting type. Read more
fn map_into<U>(self) -> MapInto<Self, U> where
Self::Output: Into<U>,
fn map_into<U>(self) -> MapInto<Self, U> where
Self::Output: Into<U>,
Map this future’s output to a different type, returning a new future of the resulting type. Read more
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> where
F: FnOnce(Self::Output) -> Fut,
Fut: Future,
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> where
F: FnOnce(Self::Output) -> Fut,
Fut: Future,
Chain on a computation for when a future finished, passing the result of
the future to the provided closure f. Read more
fn left_future<B>(self) -> Either<Self, B> where
B: Future<Output = Self::Output>,
fn left_future<B>(self) -> Either<Self, B> where
B: Future<Output = Self::Output>,
Wrap this future in an Either future, making it the left-hand variant
of that Either. Read more
fn right_future<A>(self) -> Either<A, Self> where
A: Future<Output = Self::Output>,
fn right_future<A>(self) -> Either<A, Self> where
A: Future<Output = Self::Output>,
Wrap this future in an Either future, making it the right-hand variant
of that Either. Read more
fn into_stream(self) -> IntoStream<Self>
fn into_stream(self) -> IntoStream<Self>
Convert this future into a single element stream. Read more
fn flatten(self) -> Flatten<Self> where
Self::Output: Future,
fn flatten(self) -> Flatten<Self> where
Self::Output: Future,
Flatten the execution of this future when the output of this future is itself another future. Read more
fn flatten_stream(self) -> FlattenStream<Self> where
Self::Output: Stream,
fn flatten_stream(self) -> FlattenStream<Self> where
Self::Output: Stream,
Flatten the execution of this future when the successful result of this future is a stream. Read more
fn fuse(self) -> Fuse<Self>
fn fuse(self) -> Fuse<Self>
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
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnOnce(&Self::Output),
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnOnce(&Self::Output),
Do something with the output of a future before passing it on. Read more
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
Catches unwinding panics while polling the future. Read more
Create a cloneable handle to this future where all handles will resolve to the same result. Read more
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)
Turn this future into a future that yields () on completion and sends
its output to another future on a separate task. Read more
fn boxed<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a, Global>> where
Self: 'a + Send,
fn boxed<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a, Global>> where
Self: 'a + Send,
Wrap the future in a Box, pinning it. Read more
fn boxed_local<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + 'a, Global>> where
Self: 'a,
fn boxed_local<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + 'a, Global>> where
Self: 'a,
Wrap the future in a Box, pinning it. Read more
fn unit_error(self) -> UnitError<Self>
fn unit_error(self) -> UnitError<Self>
Turns a Future<Output = T> into a
TryFuture<Ok = T, Error = ()>. Read more
fn never_error(self) -> NeverError<Self>
fn never_error(self) -> NeverError<Self>
Turns a Future<Output = T> into a
TryFuture<Ok = T, Error = Never>. Read more
fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output> where
Self: Unpin,
fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output> where
Self: Unpin,
A convenience for calling Future::poll on Unpin future types.
fn now_or_never(self) -> Option<Self::Output>
fn now_or_never(self) -> Option<Self::Output>
Evaluates and consumes the future, returning the resulting output if
the future is ready after the first call to Future::poll. Read more
sourceimpl<F> IntoFuture for F where
F: Future,
impl<F> IntoFuture for F where
F: Future,
type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
sourcefn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more