Skip to main content

ClockSource

Trait ClockSource 

Source
pub unsafe trait ClockSource {
    const ID: clockid_t;

    // Required method
    fn ktime_get() -> ktime_t;
}
Expand description

Trait for clock sources.

Selection of the clock source depends on the use case. In some cases the usage of a particular clock is mandatory, e.g. in network protocols, filesystems. In other cases the user of the clock has to decide which clock is best suited for the purpose. In most scenarios clock Monotonic is the best choice as it provides a accurate monotonic notion of time (leap second smearing ignored).

§Safety

Implementers must ensure that ktime_get() returns a value in the inclusive range 0..=KTIME_MAX (i.e., greater than or equal to 0 and less than or equal to KTIME_MAX, where KTIME_MAX equals i64::MAX).

Required Associated Constants§

Source

const ID: clockid_t

The kernel clock ID associated with this clock source.

This constant corresponds to the C side clockid_t value.

Required Methods§

Source

fn ktime_get() -> ktime_t

Get the current time from the clock source.

The function must return a value in the range 0..=KTIME_MAX.

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.

Implementors§

Source§

impl ClockSource for BootTime

Source§

const ID: clockid_t

Source§

impl ClockSource for Monotonic

Source§

const ID: clockid_t

Source§

impl ClockSource for RealTime

Source§

const ID: clockid_t

Source§

impl ClockSource for Tai

Source§

const ID: clockid_t