pub struct AutoDropTimer(/* private fields */);Implementations§
Source§impl AutoDropTimer
impl AutoDropTimer
Sourcepub fn from_timer(t: Timer) -> Self
pub fn from_timer(t: Timer) -> Self
Sourcepub fn new<F>(
clk: Clock,
duration: Duration,
f: F,
name: String,
) -> AnyResult<Self>
pub fn new<F>( clk: Clock, duration: Duration, f: F, name: String, ) -> AnyResult<Self>
Creates an instance of AutoDropTimer on the clock indicated by the clk parameter.
§Arguments
clk: The clock instance on which to create the timer.duration: Specifies the expiration duration of the timer.f: Callback function invoked after the timer expires.name: Name of the timer, used for logging purposes.
§Returns
Returns Ok(AutoDropTimer) if successful, or an error if creation fails.
Sourcepub fn cancel(&mut self) -> AnyResult<()>
pub fn cancel(&mut self) -> AnyResult<()>
Cancels the timer before it expires.
Returns Ok(()) if it is successfully canceled, or an error if the timer has already expired.
Applications should handle the race condition where a timer may expire after cancel is invoked.
§Returns
Returns Ok(()) if the timer is successfully canceled, or an error otherwise.