Skip to main content

PkInstant

Trait PkInstant 

Source
pub trait PkInstant
where Self: Sized,
{ // Required methods fn now() -> Self; fn elapsed(&self) -> Duration; }
Expand description

Trait representing an instant in time.

This trait abstracts over the std::time::Instant to support no_std environments where a custom timer implementation might be needed. In std environments, using std::time::Instant is recommended.

§Note

If you want to provide a custom implementation to be used in PkCommand, besides implementing this trait, you also need to ensure that Add<Duration, Output = Instant>, PartialOrd, and Copy are implemented for your type.

§Tips

If you are using Embassy on your embedded device, you can use the provided EmbassyInstant adapter, which wraps embassy_time::Instant and implements the necessary traits for compatibility with PkCommand.

Required Methods§

Source

fn now() -> Self

Returns the current instant.

Source

fn elapsed(&self) -> Duration

Returns the duration elapsed since this instant.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl PkInstant for Instant

Available on crate feature std only.
Source§

fn now() -> Self

Source§

fn elapsed(&self) -> Duration

Implementors§

Source§

impl PkInstant for EmbassyInstant

Available on crate feature embassy-time only.