pub struct Child<E, C = dyn AnyChannel>{ /* private fields */ }Expand description
A child is the non clone-able reference to an actor with a single process.
Children can be of two forms:
Child<E, Channel<M>>: This is the default form, it can be transformed into aChild<E>using Child::into_dyn.Child<E>: This form is a dynamic child, it can be transformed back into aChild<E, Channel<M>>using Child::downcast::.
A child can be transformed into a ChildPool using Child::into_pool().
A child can be awaited which returns the parameter E once the actor exits.
Implementations§
Source§impl<E, C> Child<E, C>
impl<E, C> Child<E, C>
Sourcepub fn into_joinhandle(self) -> JoinHandle<E>
pub fn into_joinhandle(self) -> JoinHandle<E>
Get the underlying JoinHandle.
This will not run the drop, and therefore the actor will not be halted/aborted.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the task is finished.
Sourcepub fn downcast<M: Send + 'static>(self) -> Result<Child<E, Channel<M>>, Self>where
C: AnyChannel,
pub fn downcast<M: Send + 'static>(self) -> Result<Child<E, Channel<M>>, Self>where
C: AnyChannel,
Downcast the Child<E> to a Child<E, Channel<M>>.
Sourcepub fn shutdown(&mut self, timeout: Duration) -> ShutdownFut<'_, E, C> ⓘ
pub fn shutdown(&mut self, timeout: Duration) -> ShutdownFut<'_, E, C> ⓘ
Halts the actor, and then waits for it to exit. This always returns with the result of the task, and closes the channel.
If the timeout expires before the actor has exited, the actor will be aborted.
Sourcepub fn attach(&mut self, duration: Duration) -> Option<Duration>
pub fn attach(&mut self, duration: Duration) -> Option<Duration>
Attach the actor.
Returns the old abort-timeout if it was already attached.
Sourcepub fn detach(&mut self) -> Option<Duration>
pub fn detach(&mut self) -> Option<Duration>
Detach the actor.
Returns the old abort-timeout if it was attached before.
Sourcepub fn is_aborted(&self) -> bool
pub fn is_aborted(&self) -> bool
Whether the actor is aborted.
Sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Whether the actor is attached.
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.
Source§impl<E, M> Child<E, Channel<M>>
impl<E, M> Child<E, Channel<M>>
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.
Trait Implementations§
impl<E: Send + 'static, C: DynChannel + ?Sized> Unpin for Child<E, C>
Auto Trait Implementations§
impl<E, C> Freeze for Child<E, C>where
C: ?Sized,
impl<E, C> RefUnwindSafe for Child<E, C>where
C: RefUnwindSafe + ?Sized,
impl<E, C> Send for Child<E, C>
impl<E, C> Sync for Child<E, C>
impl<E, C> UnwindSafe for Child<E, C>where
C: RefUnwindSafe + ?Sized,
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> 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>.