pub unsafe trait HasHrTimer<T> {
type TimerMode: HrTimerMode;
// Required methods
unsafe fn raw_get_timer(this: *const Self) -> *const HrTimer<T>;
unsafe fn timer_container_of(ptr: *mut HrTimer<T>) -> *mut Self
where Self: Sized;
// Provided methods
unsafe fn c_timer_ptr(this: *const Self) -> *const hrtimer { ... }
unsafe fn start(
this: *const Self,
expires: <Self::TimerMode as HrTimerMode>::Expires,
) { ... }
}
Expand description
Implemented by structs that contain timer nodes.
Clients of the timer API would usually safely implement this trait by using
the crate::impl_has_hr_timer
macro.
§Safety
Implementers of this trait must ensure that the implementer has a
HrTimer
field and that all trait methods are implemented according to
their documentation. All the methods of this trait must operate on the same
field.
Required Associated Types§
Sourcetype TimerMode: HrTimerMode
type TimerMode: HrTimerMode
The operational mode associated with this timer.
This defines how the expiration value is interpreted.
Required Methods§
Sourceunsafe fn raw_get_timer(this: *const Self) -> *const HrTimer<T>
unsafe fn raw_get_timer(this: *const Self) -> *const HrTimer<T>
Sourceunsafe fn timer_container_of(ptr: *mut HrTimer<T>) -> *mut Selfwhere
Self: Sized,
unsafe fn timer_container_of(ptr: *mut HrTimer<T>) -> *mut Selfwhere
Self: Sized,
Return a pointer to the struct that is containing the HrTimer
pointed
to by ptr
.
This function is useful to get access to the value without creating intermediate references.
§Safety
ptr
must point to a HrTimer<T>
field in a struct of type Self
.
Provided Methods§
Sourceunsafe fn c_timer_ptr(this: *const Self) -> *const hrtimer
unsafe fn c_timer_ptr(this: *const Self) -> *const hrtimer
Get pointer to the contained bindings::hrtimer
struct.
This function is useful to get access to the value without creating intermediate references.
§Safety
this
must be a valid pointer.
Sourceunsafe fn start(
this: *const Self,
expires: <Self::TimerMode as HrTimerMode>::Expires,
)
unsafe fn start( this: *const Self, expires: <Self::TimerMode as HrTimerMode>::Expires, )
Start the timer contained in the Self
pointed to by self_ptr
. If
it is already running it is removed and inserted.
§Safety
this
must point to a validSelf
.- Caller must ensure that the pointee of
this
lives until the timer fires or is canceled.
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.