Skip to main content

Command

Trait Command 

Source
pub trait Command: Send + Sync {
    // Required methods
    fn execute<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn status(&self) -> CommandStatus;

    // Provided methods
    fn timeout(&self) -> Option<Duration> { ... }
    fn started_at(&self) -> Option<Instant> { ... }
    fn set_started_at(&mut self, _instant: Instant) { ... }
}

Required Methods§

Source

fn execute<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn status(&self) -> CommandStatus

Provided Methods§

Source

fn timeout(&self) -> Option<Duration>

Source

fn started_at(&self) -> Option<Instant>

Returns the instant at which this command started executing, if the engine has informed the command via [set_started_at].

The default implementation reports None; commands that wish to self-report elapsed time (e.g. for status() queries) may override this together with [set_started_at].

Source

fn set_started_at(&mut self, _instant: Instant)

Called by the engine immediately before the command is spawned onto a background task. The default implementation is a no-op; commands that store the instant can expose it through [started_at].

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§