pub trait Lockable: Sized {
type Deadline: Sized + Codec + Clone;
// Required methods
fn deadline(&self) -> Self::Deadline;
fn has_expired(deadline: &Self::Deadline) -> bool;
// Provided method
fn snooze(_deadline: &Self::Deadline) { ... }
}
Expand description
Lockable item for use with a persisted storage lock.
Bound for an item that has a stateful ordered meaning
without explicitly requiring Ord
trait in general.
Required Associated Types§
Required Methods§
Sourcefn deadline(&self) -> Self::Deadline
fn deadline(&self) -> Self::Deadline
Calculate the deadline based on a current state such as time or block number and derives the deadline.
Sourcefn has_expired(deadline: &Self::Deadline) -> bool
fn has_expired(deadline: &Self::Deadline) -> bool
Verify the deadline has not expired compared to the current state, i.e. time or block number.
Provided Methods§
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.