Struct crossbus::delayer::Delayer

source ·
pub struct Delayer<A: Actor> { /* private fields */ }
Expand description

send a delayed message with condition and get executed once the condition satisfied.

Implementations§

source§

impl<A: Actor> Delayer<A>

source

pub fn handle(&self) -> Handle

get the handle of the Delayer

source

pub fn state(&self) -> DelayerState

get the state

source

pub fn set_state(&mut self, state: DelayerState)

set the state

source

pub fn from_duration<T: Timing + 'static>( message: A::Message, delay: Duration ) -> Self

Available on crate feature time only.

deliver the message with specified delay duration

feature time must be enabled and the Timing implementation is required with which the actor can know the time

NOTE that the delayed duration is NO LESS than delay you specified, and is within minor deviation

source

pub fn instant(message: A::Message) -> Self

instantly deliver the message to its destination, and it nearly takes no time and it can be used as Messager

source

pub unsafe fn repeat<T: Timing + 'static>( message: A::Message, duration: Option<Duration>, repeats: Option<usize> ) -> Self

Available on crate feature time only.

periodically deliver the message to its destination,

feature time must be enabled and the Timing implementation is required with which the actor can know the time

source

pub fn from_fn<F>(message: Option<A::Message>, delay: F) -> Selfwhere F: FnMut(&mut A, &mut Context<A>, &mut CoreContext<'_>) -> Poll<Indicator<A::Message>> + 'static + Unpin,

use a function/Clousre as condition to deliver the message

Trait Implementations§

source§

impl<A> Future<A> for Delayer<A>where A: Actor + Delaying<A>, A::Message: Message, Self: Unpin,

§

type Output = ()

the returned type of value when the future polled successfully
source§

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

source§

fn downcast_ref(&self) -> Option<&dyn Any>

source§

fn downcast_mut(self: Pin<&mut Self>) -> Option<Pin<&mut dyn Any>>

Auto Trait Implementations§

§

impl<A> !RefUnwindSafe for Delayer<A>

§

impl<A> !Send for Delayer<A>

§

impl<A> !Sync for Delayer<A>

§

impl<A> Unpin for Delayer<A>where <A as Actor>::Message: Unpin,

§

impl<A> !UnwindSafe for Delayer<A>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.