pub struct EmbassyInstant(/* private fields */);Available on crate feature
embassy-time only.Expand description
A PkInstant adapter for embassy_time::Instant.
This type bridges the PK Command timing abstraction with the
embassy-time crate, enabling timeout handling in no_std/embedded
environments that use Embassy.
§Availability
Enabled when the embassy feature is active (it also enables embassy-time).
§Why this wrapper exists
embassy_time::Instant is tied to embassy_time::Duration, while
PK Command uses core::time::Duration. These durations can be converted,
but their types are not directly compatible with the PkCommand signature,
so a newtype adapter keeps the API consistent without large generic changes.
§Notes
- Implements
Add<Duration>with millisecond precision. elapsed()guards against clock rollback by returning0if the current instant is earlier than the stored instant.
§Example
use pk_command::{
EmbassyInstant, PkCommand, PkCommandConfig, PkHashmapMethod, PkHashmapVariable,
};
// embassy_timer::Instant must be constructed within an Embassy context
// otherwise the code would not compile.
#[embassy_executor::task]
async fn example() {
let pk = PkCommand::<_, _, EmbassyInstant>::new(
PkCommandConfig::default(64),
PkHashmapVariable::new(vec![]),
PkHashmapMethod::new(vec![]),
);
}§See also
To use PK Command within an Embassy context, you might also want to have a
look at embassy_adapter.
Trait Implementations§
Source§impl Add<Duration> for EmbassyInstant
impl Add<Duration> for EmbassyInstant
Source§impl Clone for EmbassyInstant
impl Clone for EmbassyInstant
Source§fn clone(&self) -> EmbassyInstant
fn clone(&self) -> EmbassyInstant
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl From<Instant> for EmbassyInstant
impl From<Instant> for EmbassyInstant
Source§impl Ord for EmbassyInstant
impl Ord for EmbassyInstant
Source§fn cmp(&self, other: &EmbassyInstant) -> Ordering
fn cmp(&self, other: &EmbassyInstant) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for EmbassyInstant
impl PartialEq for EmbassyInstant
Source§impl PartialOrd for EmbassyInstant
impl PartialOrd for EmbassyInstant
Source§impl PkInstant for EmbassyInstant
impl PkInstant for EmbassyInstant
impl Copy for EmbassyInstant
impl Eq for EmbassyInstant
impl StructuralPartialEq for EmbassyInstant
Auto Trait Implementations§
impl Freeze for EmbassyInstant
impl RefUnwindSafe for EmbassyInstant
impl Send for EmbassyInstant
impl Sync for EmbassyInstant
impl Unpin for EmbassyInstant
impl UnwindSafe for EmbassyInstant
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
Mutably borrows from an owned value. Read more