pub unsafe trait HasHrTimer<T> {
// 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: Ktime) { ... }
}
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 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.
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.