Trait embedded_controls::ElapsedTimer
source · pub trait ElapsedTimer {
type Error: Debug;
type Timestamp: Clone;
fn is_timeout(
&self,
from: &Self::Timestamp,
to: &Self::Timestamp
) -> Result<bool, Self::Error>;
}Expand description
Represents an elapsed timer that used for configs.
Example
pub struct MyElapsedTimer {
duration: u32,
}
impl ElapsedTimer for MyElapsedTimer {
type Error = ();
type Timestamp = u32;
fn is_timeout(
&self,
from: &Self::Timestamp,
to: &Self::Timestamp,
) -> Result<bool, Self::Error> {
if to >= from {
Ok((to - from) >= self.duration)
} else {
Err(())
}
}
}Required Associated Types
Required Methods
sourcefn is_timeout(
&self,
from: &Self::Timestamp,
to: &Self::Timestamp
) -> Result<bool, Self::Error>
fn is_timeout(
&self,
from: &Self::Timestamp,
to: &Self::Timestamp
) -> Result<bool, Self::Error>
Returns true if a timer duration is more(equal) then duration between from-to timestamps, otherwise false.
Errors
This function will return an error if duration between from-to timestamps is negative.