Skip to main content

TimedContext

Struct TimedContext 

Source
pub struct TimedContext<M>(/* private fields */);
Expand description

A Context variant available to actors wrapped by the Timed actor wrapper. Wraps and dereferences to BareContext with the message wrapped in TimedMessage.

Implementations§

Source§

impl<M: 'static> TimedContext<M>

Source

pub fn subscribe<E: Event + Into<M>>(&self)

Subscribe current actor to event of type E. Events will be delivered as instant messages. A variant of BareContext::subscribe() that performs one extra message conversion: E -> M -> TimedMessage<M>.

Source

pub fn subscribe_and_receive_latest<E: Event + Into<M>>( &self, ) -> Result<(), SendError>

Subscribe current actor to event of type E and send the last cached event to it. Events will be delivered as instant messages. A variant of BareContext::subscribe_and_receive_latest() that performs one extra message conversion: E -> M -> TimedMessage<M>.

Methods from Deref<Target = BareContext<TimedMessage<M>>>§

Source

pub fn subscribe<E: Event + Into<M>>(&self)

Subscribe current actor to event of type E. This is part of the event system. You don’t need to call this method to receive direct messages sent using Addr and Recipient.

Note that subscribing twice to the same event would result in duplicate events – no de-duplication of subscriptions is performed.

Source

pub fn subscribe_and_receive_latest<E: Event + Into<M>>( &self, ) -> Result<(), SendError>

Subscribe current actor to event of type E and send the last cached event to it. This is part of the event system. You don’t need to call this method to receive direct messages sent using Addr and Recipient.

Note that subscribing twice to the same event would result in duplicate events – no de-duplication of subscriptions is performed.

This method may fail if it is not possible to send the latest event. In this case it is guaranteed that the subscription did not take place. You can safely try again.

Trait Implementations§

Source§

impl<M> Deref for TimedContext<M>

Source§

type Target = BareContext<TimedMessage<M>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &BareContext<TimedMessage<M>>

Dereferences the value.

Auto Trait Implementations§

§

impl<M> Freeze for TimedContext<M>

§

impl<M> !RefUnwindSafe for TimedContext<M>

§

impl<M> Send for TimedContext<M>

§

impl<M> Sync for TimedContext<M>

§

impl<M> Unpin for TimedContext<M>

§

impl<M> !UnwindSafe for TimedContext<M>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.