| 1 |
use craterust-analyzer cargo clock-steering 0.2.1 crate/::{Clockrust-analyzer cargo clock-steering 0.2.1 Clock#, LeapIndicatorrust-analyzer cargo clock-steering 0.2.1 LeapIndicator#, TimeOffsetrust-analyzer cargo clock-steering 0.2.1 TimeOffset#, Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#}; |
| 2 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#; |
| 3 |
#[cfg(target_os = "linux")] |
| 4 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 5 |
osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/io/::{IntoRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/IntoRawFd#, RawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/RawFd#}, |
| 6 |
pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, |
| 7 |
}; |
| 8 |
|
| 9 |
/// A Unix OS clock |
| 10 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 11 |
pub struct UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock# { |
| 12 |
clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock.: libcrust-analyzer cargo libc 0.2.189 crate/::clockid_trust-analyzer cargo libc 0.2.189 unix/linux_like/clockid_t#, |
| 13 |
#[cfg(target_os = "linux")] |
| 14 |
fdrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#fd.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<RawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/RawFd#>, |
| 15 |
} |
| 16 |
|
| 17 |
impl UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock# { |
| 18 |
/// The standard realtime clock on unix systems. |
| 19 |
/// |
| 20 |
/// ```no_run |
| 21 |
/// use clock_steering::{Clock, unix::UnixClock}; |
| 22 |
/// |
| 23 |
/// fn main() -> std::io::Result<()> { |
| 24 |
/// let clock = UnixClock::CLOCK_REALTIME; |
| 25 |
/// let now = clock.now()?; |
| 26 |
/// |
| 27 |
/// println!("{now:?}"); |
| 28 |
/// |
| 29 |
/// Ok(()) |
| 30 |
/// } |
| 31 |
/// ``` |
| 32 |
pub const CLOCK_REALTIMErust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_REALTIME.: Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock] = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock# { |
| 33 |
clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock.: libcrust-analyzer cargo libc 0.2.189 crate/::CLOCK_REALTIMErust-analyzer cargo libc 0.2.189 unix/linux_like/CLOCK_REALTIME., |
| 34 |
#[cfg(target_os = "linux")] |
| 35 |
fdrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#fd.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 36 |
}; |
| 37 |
|
| 38 |
/// TAI time on linux systems. |
| 39 |
/// |
| 40 |
/// ```no_run |
| 41 |
/// use clock_steering::{Clock, unix::UnixClock}; |
| 42 |
/// |
| 43 |
/// fn main() -> std::io::Result<()> { |
| 44 |
/// let clock = UnixClock::CLOCK_TAI; |
| 45 |
/// let now = clock.now()?; |
| 46 |
/// |
| 47 |
/// println!("{now:?}"); |
| 48 |
/// |
| 49 |
/// Ok(()) |
| 50 |
/// } |
| 51 |
/// ``` |
| 52 |
#[cfg(target_os = "linux")] |
| 53 |
pub const CLOCK_TAIrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_TAI.: Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock] = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock# { |
| 54 |
clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock.: libcrust-analyzer cargo libc 0.2.189 crate/::CLOCK_TAIrust-analyzer cargo libc 0.2.189 unix/linux_like/CLOCK_TAI., |
| 55 |
fdrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#fd.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 56 |
}; |
| 57 |
|
| 58 |
/// Open a clock device. |
| 59 |
/// |
| 60 |
/// ```no_run |
| 61 |
/// use clock_steering::{Clock, unix::UnixClock}; |
| 62 |
/// |
| 63 |
/// fn main() -> std::io::Result<()> { |
| 64 |
/// let clock = UnixClock::open("/dev/ptp0")?; |
| 65 |
/// let now = clock.now()?; |
| 66 |
/// |
| 67 |
/// println!("{now:?}"); |
| 68 |
/// |
| 69 |
/// Ok(()) |
| 70 |
/// } |
| 71 |
/// ``` |
| 72 |
#[cfg(target_os = "linux")] |
| 73 |
pub fn openrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]open().(path: impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]> { |
| 74 |
let file = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::OpenOptionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/OpenOptions#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[OpenOptions]new().() |
| 75 |
.writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[OpenOptions]write().(true) |
| 76 |
.readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[OpenOptions]read().(true) |
| 77 |
.openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[OpenOptions]open().(path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 78 |
|
| 79 |
// we need an owned fd. the file will be closed when the process exits. |
| 80 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]::safe_from_raw_fdrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]safe_from_raw_fd().(file.into_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/impl#[`fs::File`][IntoRawFd]into_raw_fd().())) |
| 81 |
} |
| 82 |
|
| 83 |
// Consume an fd and produce a clock id. Clock id is only valid |
| 84 |
// so long as the fd is open, so the RawFd here should |
| 85 |
// not be borrowed. |
| 86 |
#[cfg(target_os = "linux")] |
| 87 |
fn safe_from_raw_fdrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]safe_from_raw_fd().(fd: RawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/RawFd#) -> Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock] { |
| 88 |
let clock = ((!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][Not]not().(fd as libcrust-analyzer cargo libc 0.2.189 crate/::clockid_trust-analyzer cargo libc 0.2.189 unix/linux_like/clockid_t#)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl().3) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().3; |
| 89 |
|
| 90 |
Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock] { |
| 91 |
clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock., |
| 92 |
fdrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#fd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(fd), |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
/// Determine offset between file clock and TAI clock (if any) |
| 97 |
/// Returns two system timestamps sandwhiching a timestamp from the |
| 98 |
/// hardware clock. |
| 99 |
#[cfg(target_os = "linux")] |
| 100 |
pub fn system_offsetrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]system_offset().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 101 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(fd) = self.fdrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#fd. else { |
| 102 |
return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::Invalidrust-analyzer cargo clock-steering 0.2.1 unix/Error#Invalid#); |
| 103 |
}; |
| 104 |
|
| 105 |
// TODO: remove type and constant definitions once libc updates |
| 106 |
#[repr(C)] |
| 107 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 108 |
#[allow(non_camel_case_types)] |
| 109 |
struct ptp_clock_timerust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time# { |
| 110 |
secrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#sec.: libcrust-analyzer cargo libc 0.2.189 crate/::__s64rust-analyzer cargo libc 0.2.189 new/linux_uapi/linux/types/__s64#, |
| 111 |
nsecrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#nsec.: libcrust-analyzer cargo libc 0.2.189 crate/::__u32rust-analyzer cargo libc 0.2.189 new/linux_uapi/linux/types/__u32#, |
| 112 |
reservedrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#reserved.: libcrust-analyzer cargo libc 0.2.189 crate/::__u32rust-analyzer cargo libc 0.2.189 new/linux_uapi/linux/types/__u32#, |
| 113 |
} |
| 114 |
|
| 115 |
#[repr(C)] |
| 116 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 117 |
#[allow(non_camel_case_types)] |
| 118 |
struct ptp_sys_offsetrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset# { |
| 119 |
n_samplesrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#n_samples.: libcrust-analyzer cargo libc 0.2.189 crate/::c_uintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_uint#, |
| 120 |
rsvrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#rsv.: [libcrust-analyzer cargo libc 0.2.189 crate/::c_uintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_uint#; 3], |
| 121 |
tsrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#ts.: [ptp_clock_timerust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#; 51], |
| 122 |
} |
| 123 |
|
| 124 |
// Needed as arrays larger than 32 elements don't implement default. |
| 125 |
impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for ptp_sys_offsetrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset# { |
| 126 |
fn defaultrust-analyzer cargo clock-steering 0.2.1 unix/impl#[ptp_sys_offset][Default]default().() -> Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[ptp_sys_offset][Default] { |
| 127 |
Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[ptp_sys_offset][Default] { |
| 128 |
n_samplesrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#n_samples.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/impl#[u32][Default]default().(), |
| 129 |
rsvrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#rsv.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; _]`][Default]default().(), |
| 130 |
tsrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#ts.: [Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo clock-steering 0.2.1 unix/impl#[ptp_clock_time][Default]default().(); 51], |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
const PTP_SYS_OFFSETrust-analyzer cargo clock-steering 0.2.1 unix/PTP_SYS_OFFSET.: libcrust-analyzer cargo libc 0.2.189 crate/::c_uintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_uint# = 0x43403d05; |
| 136 |
|
| 137 |
let mut offset = ptp_sys_offsetrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset# { |
| 138 |
n_samplesrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#n_samples.: 1, |
| 139 |
..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo clock-steering 0.2.1 unix/impl#[ptp_sys_offset][Default]default().() |
| 140 |
}; |
| 141 |
|
| 142 |
// # Safety |
| 143 |
// Safe since PTP_SYS_OFFSET expects as argument a mutable pointer to |
| 144 |
// ptp_sys_offset and offset is valid during the call |
| 145 |
if unsafe { libcrust-analyzer cargo libc 0.2.189 crate/::ioctlrust-analyzer cargo libc 0.2.189 ioctl().(fd, PTP_SYS_OFFSETrust-analyzer cargo clock-steering 0.2.1 unix/PTP_SYS_OFFSET. as _, &mut offset as *mut ptp_sys_offsetrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#) } rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0 |
| 146 |
{ |
| 147 |
let t1 = Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]::CLOCK_TAIrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_TAI..nowrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]now().(); |
| 148 |
let tp = self.nowrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]now().(); |
| 149 |
let t2 = Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]::CLOCK_TAIrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_TAI..nowrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]now().(); |
| 150 |
|
| 151 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((t1?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., tp?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., t2?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)) |
| 152 |
} else { |
| 153 |
let tai_offset = Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]::CLOCK_TAIrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_TAI..get_tairust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]get_tai().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 154 |
|
| 155 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(( |
| 156 |
Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp# { |
| 157 |
secondsrust-analyzer cargo clock-steering 0.2.1 Timestamp#seconds.: (offset.tsrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#ts.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..secrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#sec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().tai_offset as i64) as _, |
| 158 |
nanosrust-analyzer cargo clock-steering 0.2.1 Timestamp#nanos.: offset.tsrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#ts.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..nsecrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#nsec. as _, |
| 159 |
}, |
| 160 |
Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp# { |
| 161 |
secondsrust-analyzer cargo clock-steering 0.2.1 Timestamp#seconds.: offset.tsrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#ts.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..secrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#sec. as _, |
| 162 |
nanosrust-analyzer cargo clock-steering 0.2.1 Timestamp#nanos.: offset.tsrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#ts.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..nsecrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#nsec. as _, |
| 163 |
}, |
| 164 |
Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp# { |
| 165 |
secondsrust-analyzer cargo clock-steering 0.2.1 Timestamp#seconds.: (offset.tsrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#ts.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..secrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#sec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().tai_offset as i64) as _, |
| 166 |
nanosrust-analyzer cargo clock-steering 0.2.1 Timestamp#nanos.: offset.tsrust-analyzer cargo clock-steering 0.2.1 unix/ptp_sys_offset#ts.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..nsecrust-analyzer cargo clock-steering 0.2.1 unix/ptp_clock_time#nsec. as _, |
| 167 |
}, |
| 168 |
)) |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
fn clock_adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_adjtime().(&self, timex: &mut libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 173 |
// We don't care about the time status, so the non-error |
| 174 |
// information in the return value of clock_adjtime can be ignored. |
| 175 |
// |
| 176 |
// # Safety |
| 177 |
// |
| 178 |
// The clock_adjtime call is safe because the reference always |
| 179 |
// points to a valid libc::timex. |
| 180 |
// |
| 181 |
// using an invalid clock id is safe. `clock_adjtime` will return an EINVAL |
| 182 |
// error https://man.archlinux.org/man/clock_adjtime.2.en#EINVAL~4 |
| 183 |
#[cfg(target_os = "linux")] |
| 184 |
use libcrust-analyzer cargo libc 0.2.189 crate/::clock_adjtimerust-analyzer cargo libc 0.2.189 clock_adjtime(). as adjtimerust-analyzer cargo libc 0.2.189 clock_adjtime().; |
| 185 |
|
| 186 |
#[cfg(any(target_os = "freebsd", target_os = "macos"))] |
| 187 |
unsafe fn adjtime(clk_id: libcrust-analyzer cargo libc 0.2.189 crate/::clockid_trust-analyzer cargo libc 0.2.189 unix/linux_like/clockid_t#, buf: *mut libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#) -> libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int# { |
| 188 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 189 |
clk_id, |
| 190 |
libc::CLOCK_REALTIME, |
| 191 |
"only the REALTIME clock is supported" |
| 192 |
); |
| 193 |
|
| 194 |
libcrust-analyzer cargo libc 0.2.189 crate/::ntp_adjtimerust-analyzer cargo libc 0.2.189 ntp_adjtime().(buf) |
| 195 |
} |
| 196 |
|
| 197 |
if unsafe { adjtimerust-analyzer cargo libc 0.2.189 clock_adjtime().(self.clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock., timex) } rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1 { |
| 198 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(convert_errnorust-analyzer cargo clock-steering 0.2.1 unix/convert_errno().()) |
| 199 |
} else { |
| 200 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 201 |
} |
| 202 |
} |
| 203 |
|
| 204 |
fn ntp_adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]ntp_adjtime().(timex: &mut libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 205 |
#[cfg(any(target_os = "freebsd", target_os = "macos", target_env = "gnu"))] |
| 206 |
use libcrust-analyzer cargo libc 0.2.189 crate/::ntp_adjtimerust-analyzer cargo libc 0.2.189 ntp_adjtime(). as adjtimerust-analyzer cargo libc 0.2.189 ntp_adjtime().; |
| 207 |
|
| 208 |
// ntp_adjtime is equivalent to adjtimex for our purposes |
| 209 |
// |
| 210 |
// https://man7.org/linux/man-pages/man2/adjtimex.2.html |
| 211 |
#[cfg(all(target_os = "linux", target_env = "musl"))] |
| 212 |
use libcrust-analyzer cargo libc 0.2.189 crate/::adjtimexrust-analyzer cargo libc 0.2.189 adjtimex(). as adjtimerust-analyzer cargo libc 0.2.189 adjtimex().; |
| 213 |
|
| 214 |
// We don't care about the time status, so the non-error |
| 215 |
// information in the return value of ntp_adjtime can be ignored. |
| 216 |
// The ntp_adjtime call is safe because the reference always |
| 217 |
// points to a valid libc::timex. |
| 218 |
if unsafe { adjtimerust-analyzer cargo libc 0.2.189 ntp_adjtime().(timex) } rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1 { |
| 219 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(convert_errnorust-analyzer cargo clock-steering 0.2.1 unix/convert_errno().()) |
| 220 |
} else { |
| 221 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
/// Adjust the clock state with a [`libc::timex`] specifying the desired changes. |
| 226 |
/// |
| 227 |
/// This is a lowlevel function. If possible, use more specialized (trait) methods. |
| 228 |
/// |
| 229 |
/// Note that [`libc::timex`] has a different layout between different operating systems, and |
| 230 |
/// not all fields are available on all operating systems. Keep this in mind when writing |
| 231 |
/// platform-independent code. |
| 232 |
fn adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&self, timex: &mut libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 233 |
if self.clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().libcrust-analyzer cargo libc 0.2.189 crate/::CLOCK_REALTIMErust-analyzer cargo libc 0.2.189 unix/linux_like/CLOCK_REALTIME. { |
| 234 |
Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]::ntp_adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]ntp_adjtime().(timex) |
| 235 |
} else { |
| 236 |
self.clock_adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_adjtime().(timex) |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
#[cfg_attr(target_os = "linux", allow(unused))] |
| 241 |
fn clock_gettimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_gettime().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<libcrust-analyzer cargo libc 0.2.189 crate/::timespecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#, Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 242 |
let mut timespec = EMPTY_TIMESPECrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMESPEC.; |
| 243 |
|
| 244 |
// # Safety |
| 245 |
// |
| 246 |
// using an invalid clock id is safe. `clock_adjtime` will return an EINVAL |
| 247 |
// error https://linux.die.net/man/3/clock_gettime |
| 248 |
// |
| 249 |
// The timespec pointer is valid. |
| 250 |
cerrrust-analyzer cargo clock-steering 0.2.1 unix/cerr().(unsafe { libcrust-analyzer cargo libc 0.2.189 crate/::clock_gettimerust-analyzer cargo libc 0.2.189 clock_gettime().(self.clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock., &mut timespec) })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 251 |
|
| 252 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(timespec) |
| 253 |
} |
| 254 |
|
| 255 |
#[cfg_attr(target_os = "linux", allow(unused))] |
| 256 |
fn clock_settimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_settime().(&self, mut timespec: libcrust-analyzer cargo libc 0.2.189 crate/::timespecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 257 |
while timespec.tv_nsecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_nsec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]gt().1_000_000_000 { |
| 258 |
timespec.tv_secrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_sec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().1; |
| 259 |
timespec.tv_nsecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_nsec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign().1_000_000_000; |
| 260 |
} |
| 261 |
|
| 262 |
// # Safety |
| 263 |
// |
| 264 |
// using an invalid clock id is safe. `clock_adjtime` will return an EINVAL |
| 265 |
// error https://linux.die.net/man/3/clock_settime |
| 266 |
// |
| 267 |
// The timespec pointer is valid. |
| 268 |
unsafe { cerrrust-analyzer cargo clock-steering 0.2.1 unix/cerr().(libcrust-analyzer cargo libc 0.2.189 crate/::clock_settimerust-analyzer cargo libc 0.2.189 clock_settime().(self.clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock., ×pec))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). }; |
| 269 |
|
| 270 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 271 |
} |
| 272 |
|
| 273 |
#[cfg_attr(target_os = "linux", allow(unused))] |
| 274 |
fn step_clock_by_timespecrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]step_clock_by_timespec().(&self, offset: TimeOffsetrust-analyzer cargo clock-steering 0.2.1 TimeOffset#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 275 |
let mut timespec = self.clock_gettimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_gettime().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 276 |
|
| 277 |
// see https://github.com/rust-lang/libc/issues/1848 |
| 278 |
#[cfg_attr(target_env = "musl", allow(deprecated))] |
| 279 |
{ |
| 280 |
timespec.tv_secrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_sec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().offset.secondsrust-analyzer cargo clock-steering 0.2.1 TimeOffset#seconds. as libcrust-analyzer cargo libc 0.2.189 crate/::time_trust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/time_t#; |
| 281 |
timespec.tv_nsecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_nsec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().offset.nanosrust-analyzer cargo clock-steering 0.2.1 TimeOffset#nanos. as libcrust-analyzer cargo libc 0.2.189 crate/::c_longrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_long#; |
| 282 |
} |
| 283 |
|
| 284 |
self.clock_settimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_settime().(timespec)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 285 |
|
| 286 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(current_time_timespecrust-analyzer cargo clock-steering 0.2.1 unix/current_time_timespec().(timespec, Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Nanorust-analyzer cargo clock-steering 0.2.1 unix/Precision#Nano#)) |
| 287 |
} |
| 288 |
|
| 289 |
fn error_estimate_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]error_estimate_timex().(est_error: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, max_error: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#) -> libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex# { |
| 290 |
let modes = libcrust-analyzer cargo libc 0.2.189 crate/::MOD_ESTERRORrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/MOD_ESTERROR. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.189 crate/::MOD_MAXERRORrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/MOD_MAXERROR.; |
| 291 |
|
| 292 |
// these fields are always in microseconds |
| 293 |
let esterror = est_error.as_nanosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_nanos().() as libcrust-analyzer cargo libc 0.2.189 crate/::c_longrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_long# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().1000; |
| 294 |
let maxerror = max_error.as_nanosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_nanos().() as libcrust-analyzer cargo libc 0.2.189 crate/::c_longrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_long# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().1000; |
| 295 |
|
| •296 |
let mut result = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 297 |
result.modesrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#modes. = modes; |
| 298 |
result.esterrorrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#esterror. = esterror.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 299 |
result.maxerrorrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#maxerror. = maxerror.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 300 |
result |
| 301 |
} |
| 302 |
|
| 303 |
#[cfg(target_os = "linux")] |
| 304 |
fn step_clock_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]step_clock_timex().(offset: TimeOffsetrust-analyzer cargo clock-steering 0.2.1 TimeOffset#) -> libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex# { |
| 305 |
// we provide the offset in nanoseconds |
| 306 |
let modes = libcrust-analyzer cargo libc 0.2.189 crate/::ADJ_SETOFFSETrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/ADJ_SETOFFSET. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.189 crate/::ADJ_NANOrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/ADJ_NANO.; |
| 307 |
|
| 308 |
let time = libcrust-analyzer cargo libc 0.2.189 crate/::timevalrust-analyzer cargo libc 0.2.189 unix/timeval# { |
| 309 |
tv_secrust-analyzer cargo libc 0.2.189 unix/timeval#tv_sec.: offset.secondsrust-analyzer cargo clock-steering 0.2.1 TimeOffset#seconds., |
| •310 |
tv_usecrust-analyzer cargo libc 0.2.189 unix/timeval#tv_usec.: offset.nanosrust-analyzer cargo clock-steering 0.2.1 TimeOffset#nanos. as _, |
| 311 |
}; |
| 312 |
|
| •313 |
let mut result = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 314 |
result.modesrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#modes. = modes; |
| 315 |
result.timerust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#time. = time; |
| 316 |
result |
| 317 |
} |
| 318 |
|
| 319 |
#[cfg(target_os = "linux")] |
| 320 |
fn step_clock_by_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]step_clock_by_timex().(&self, offset: TimeOffsetrust-analyzer cargo clock-steering 0.2.1 TimeOffset#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 321 |
let mut timex = Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]::step_clock_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]step_clock_timex().(offset); |
| 322 |
self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut timex)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 323 |
self.extract_current_timerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]extract_current_time().(&timex) |
| 324 |
} |
| 325 |
|
| 326 |
fn extract_current_timerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]extract_current_time().(&self, _timex: &libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 327 |
#[cfg(target_os = "linux")] |
| 328 |
// hardware clocks may not report the timestamp |
| 329 |
if _timex.timerust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#time..tv_secrust-analyzer cargo libc 0.2.189 unix/timeval#tv_sec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 && _timex.timerust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#time..tv_usecrust-analyzer cargo libc 0.2.189 unix/timeval#tv_usec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 { |
| 330 |
// in a timex, the status flag determines precision |
| 331 |
let precision = match _timex.statusrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#status. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand().libcrust-analyzer cargo libc 0.2.189 crate/::STA_NANOrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_NANO. { |
| 332 |
0 => Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Microrust-analyzer cargo clock-steering 0.2.1 unix/Precision#Micro#, |
| 333 |
_ => Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Nanorust-analyzer cargo clock-steering 0.2.1 unix/Precision#Nano#, |
| 334 |
}; |
| 335 |
|
| 336 |
return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(current_time_timevalrust-analyzer cargo clock-steering 0.2.1 unix/current_time_timeval().(_timex.timerust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#time., precision)); |
| 337 |
} |
| 338 |
|
| 339 |
// clock_gettime always gives nanoseconds |
| 340 |
let timespec = self.clock_gettimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_gettime().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 341 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(current_time_timespecrust-analyzer cargo clock-steering 0.2.1 unix/current_time_timespec().(timespec, Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Nanorust-analyzer cargo clock-steering 0.2.1 unix/Precision#Nano#)) |
| 342 |
} |
| 343 |
|
| 344 |
#[inline(always)] |
| 345 |
fn update_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]update_timex().<F>(&self, f: F) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> |
| 346 |
where |
| 347 |
F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#) -> libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#, |
| 348 |
{ |
| 349 |
let mut timex = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 350 |
self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut timex)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 351 |
|
| 352 |
timex = f(timex); |
| 353 |
|
| 354 |
self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut timex) |
| 355 |
} |
| 356 |
|
| 357 |
#[inline(always)] |
| 358 |
fn update_statusrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]update_status().<F>(&self, f: F) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> |
| 359 |
where |
| 360 |
F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int#) -> libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int#, |
| 361 |
{ |
| 362 |
self.update_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]update_timex().(|mut timex| { |
| 363 |
// We are setting the status bits |
| 364 |
timex.modesrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#modes. = libcrust-analyzer cargo libc 0.2.189 crate/::MOD_STATUSrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/MOD_STATUS.; |
| 365 |
|
| 366 |
// update the status flags |
| 367 |
timex.statusrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#status. = f(timex.statusrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#status.); |
| 368 |
|
| 369 |
timex |
| 370 |
}) |
| 371 |
} |
| 372 |
|
| 373 |
fn set_frequency_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]set_frequency_timex().(ppm: f64) -> libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex# { |
| 374 |
// We do an offset with precision |
| 375 |
let mut timex = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 376 |
|
| 377 |
// set the frequency (MOD_FREQUENCY is an alias for ADJ_FREQUENCY on linux) |
| 378 |
timex.modesrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#modes. = libcrust-analyzer cargo libc 0.2.189 crate/::MOD_FREQUENCYrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/MOD_FREQUENCY.; |
| 379 |
|
| 380 |
// NTP Kapi expects frequency adjustment in units of 2^-16 ppm |
| 381 |
// but our input is in units of seconds drift per second, so convert. |
| 382 |
let frequency = (ppm rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().65536.0).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as libcrust-analyzer cargo libc 0.2.189 crate/::c_longrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_long#; |
| 383 |
|
| 384 |
// Since Linux 2.6.26, the supplied value is clamped to the range (-32768000, |
| 385 |
// +32768000). In older kernels, an EINVAL error occurs if the supplied value is |
| 386 |
// out of range. (32768000 is 500 << 16) |
| •387 |
timex.freqrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#freq. = frequency.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][Ord]clamp().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().32_768_000 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().1, 32_768_000 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().1).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 388 |
|
| 389 |
timex |
| 390 |
} |
| 391 |
} |
| 392 |
|
| 393 |
impl Clockrust-analyzer cargo clock-steering 0.2.1 Clock# for UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock# { |
| 394 |
type Errorrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]Error# = Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#; |
| 395 |
|
| 396 |
fn nowrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]now().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 397 |
let mut ntp_kapi_timex = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 398 |
|
| 399 |
if self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut ntp_kapi_timex).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() { |
| 400 |
self.extract_current_timerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]extract_current_time().(&ntp_kapi_timex) |
| 401 |
} else { |
| 402 |
self.clock_gettimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_gettime().() |
| 403 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|ts| current_time_timespecrust-analyzer cargo clock-steering 0.2.1 unix/current_time_timespec().(ts, Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Nanorust-analyzer cargo clock-steering 0.2.1 unix/Precision#Nano#)) |
| 404 |
} |
| 405 |
} |
| 406 |
|
| 407 |
fn resolutionrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]resolution().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 408 |
let mut timespec = EMPTY_TIMESPECrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMESPEC.; |
| 409 |
|
| 410 |
cerrrust-analyzer cargo clock-steering 0.2.1 unix/cerr().(unsafe { libcrust-analyzer cargo libc 0.2.189 crate/::clock_getresrust-analyzer cargo libc 0.2.189 clock_getres().(self.clockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#clock., &mut timespec) })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 411 |
|
| 412 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(current_time_timespecrust-analyzer cargo clock-steering 0.2.1 unix/current_time_timespec().(timespec, Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Nanorust-analyzer cargo clock-steering 0.2.1 unix/Precision#Nano#)) |
| 413 |
} |
| 414 |
|
| 415 |
fn get_frequencyrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]get_frequency().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<f64, Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 416 |
let mut timex = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 417 |
self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut timex)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 418 |
|
| 419 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((timex.freqrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#freq. as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().65536.0) |
| 420 |
} |
| 421 |
|
| 422 |
fn set_frequencyrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]set_frequency().(&self, frequency: f64) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 423 |
let mut timex = Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::set_frequency_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]set_frequency_timex().(frequency); |
| 424 |
self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut timex)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 425 |
self.extract_current_timerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]extract_current_time().(&timex) |
| 426 |
} |
| 427 |
|
| 428 |
#[cfg(target_os = "linux")] |
| 429 |
fn step_clockrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]step_clock().(&self, offset: TimeOffsetrust-analyzer cargo clock-steering 0.2.1 TimeOffset#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 430 |
self.step_clock_by_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]step_clock_by_timex().(offset) |
| 431 |
} |
| 432 |
|
| 433 |
#[cfg(any(target_os = "freebsd", target_os = "macos"))] |
| 434 |
fn step_clock(&self, offset: TimeOffsetrust-analyzer cargo clock-steering 0.2.1 TimeOffset#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#, Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 435 |
selfrust-analyzer cargo clock-steering 0.2.1 unix/.step_clock_by_timespec(offset) |
| 436 |
} |
| 437 |
|
| 438 |
fn set_leap_secondsrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]set_leap_seconds().(&self, leap_status: LeapIndicatorrust-analyzer cargo clock-steering 0.2.1 LeapIndicator#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 439 |
self.update_statusrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]update_status().(|status| { |
| 440 |
(status rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand().!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][Not]not().(libcrust-analyzer cargo libc 0.2.189 crate/::STA_UNSYNCrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_UNSYNC. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.189 crate/::STA_INSrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_INS. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.189 crate/::STA_DELrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_DEL.)) |
| 441 |
|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().leap_status.as_status_bitrust-analyzer cargo clock-steering 0.2.1 unix/impl#[LeapIndicator]as_status_bit().() |
| 442 |
}) |
| 443 |
} |
| 444 |
|
| 445 |
fn error_estimate_updaterust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]error_estimate_update().( |
| 446 |
&self, |
| 447 |
est_error: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, |
| 448 |
max_error: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, |
| 449 |
) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 450 |
let mut timex = Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::error_estimate_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]error_estimate_timex().(est_error, max_error); |
| 451 |
Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::ignore_not_supportedrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]ignore_not_supported().(self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut timex)) |
| 452 |
} |
| 453 |
|
| 454 |
fn disable_kernel_ntp_algorithmrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]disable_kernel_ntp_algorithm().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]::Errorrust-analyzer cargo clock-steering 0.2.1 Clock#Error#> { |
| 455 |
let mut timex = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 456 |
self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut timex)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 457 |
|
| 458 |
// We are setting the status bits |
| 459 |
timex.modesrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#modes. = libcrust-analyzer cargo libc 0.2.189 crate/::MOD_STATUSrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/MOD_STATUS.; |
| 460 |
|
| 461 |
// Disable all kernel time control loops (phase lock, frequency lock, pps time and pps frequency). |
| 462 |
timex.statusrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#status. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().&=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][Not]not().(libcrust-analyzer cargo libc 0.2.189 crate/::STA_PLLrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_PLL. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.189 crate/::STA_FLLrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_FLL. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.189 crate/::STA_PPSTIMErust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_PPSTIME. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.189 crate/::STA_PPSFREQrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_PPSFREQ.); |
| 463 |
|
| 464 |
// ignore if we cannot disable the kernel time control loops (e.g. external clocks) |
| 465 |
Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::ignore_not_supportedrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]ignore_not_supported().(self.adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]adjtime().(&mut timex)) |
| 466 |
} |
| 467 |
|
| 468 |
#[cfg(target_os = "linux")] |
| 469 |
fn set_tairust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]set_tai().(&self, tai_offset: i32) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| •470 |
let mut timex = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 471 |
timex.modesrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#modes. = libcrust-analyzer cargo libc 0.2.189 crate/::ADJ_TAIrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/ADJ_TAI.; |
| 472 |
timex.constantrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#constant. = tai_offset as _; |
| 473 |
|
| 474 |
self.clock_adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_adjtime().(&mut timex) |
| 475 |
} |
| 476 |
|
| 477 |
#[cfg(not(target_os = "linux"))] |
| 478 |
fn set_tai(&self, _tai_offset: i32) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 479 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::NotSupportedrust-analyzer cargo clock-steering 0.2.1 unix/Error#NotSupported#) |
| 480 |
} |
| 481 |
|
| 482 |
#[cfg(target_os = "linux")] |
| 483 |
fn get_tairust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]get_tai().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i32, Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 484 |
let mut timex = EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.; |
| 485 |
if self.clock_adjtimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_adjtime().(&mut timex).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() { |
| 486 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(timex.tairust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#tai.) |
| 487 |
} else { |
| 488 |
// hardware clock which doesn't have an offset anyway |
| 489 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0) |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
#[cfg(not(target_os = "linux"))] |
| 494 |
fn get_tai(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i32, Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 495 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::NotSupportedrust-analyzer cargo clock-steering 0.2.1 unix/Error#NotSupported#) |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
/// Errors that can be thrown by modifying a unix clock |
| 500 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 501 |
pub enum Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error# { |
| 502 |
/// Insufficient permissions to interact with the clock. |
| 503 |
NoPermissionrust-analyzer cargo clock-steering 0.2.1 unix/Error#NoPermission#, |
| 504 |
/// No access to the clock. |
| 505 |
NoAccessrust-analyzer cargo clock-steering 0.2.1 unix/Error#NoAccess#, |
| 506 |
/// Invalid operation requested |
| 507 |
Invalidrust-analyzer cargo clock-steering 0.2.1 unix/Error#Invalid#, |
| 508 |
/// Clock device has gone away |
| 509 |
NoDevicerust-analyzer cargo clock-steering 0.2.1 unix/Error#NoDevice#, |
| 510 |
/// Clock operation requested is not supported by operating system. |
| 511 |
NotSupportedrust-analyzer cargo clock-steering 0.2.1 unix/Error#NotSupported#, |
| 512 |
} |
| 513 |
|
| 514 |
impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error# { |
| 515 |
fn fmtrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error][Display]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 516 |
use Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::*; |
| 517 |
|
| 518 |
let msg = match self { |
| 519 |
NoPermissionrust-analyzer cargo clock-steering 0.2.1 unix/Error#NoPermission# => "Insufficient permissions to interact with the clock.", |
| 520 |
NoAccessrust-analyzer cargo clock-steering 0.2.1 unix/Error#NoAccess# => "No access to the clock.", |
| 521 |
Invalidrust-analyzer cargo clock-steering 0.2.1 unix/Error#Invalid# => "Invalid operation requested", |
| 522 |
NoDevicerust-analyzer cargo clock-steering 0.2.1 unix/Error#NoDevice# => "Clock device has gone away", |
| 523 |
NotSupportedrust-analyzer cargo clock-steering 0.2.1 unix/Error#NotSupported# => "Clock operation requested is not supported by operating system.", |
| 524 |
}; |
| 525 |
|
| 526 |
f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(msg) |
| 527 |
} |
| 528 |
} |
| 529 |
|
| 530 |
impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error# {} |
| 531 |
|
| 532 |
impl Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error# { |
| 533 |
/// Turn the `Error::NotSupported` error variant into `Ok(())`, to silently |
| 534 |
/// ignore operations that are not supported by the current clock. All |
| 535 |
/// other input values are untouched. |
| 536 |
pub fn ignore_not_supportedrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]ignore_not_supported().(res: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 537 |
match res { |
| 538 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::NotSupportedrust-analyzer cargo clock-steering 0.2.1 unix/Error#NotSupported#) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 539 |
other => other, |
| 540 |
} |
| 541 |
} |
| 542 |
|
| 543 |
// TODO: use https://doc.rust-lang.org/std/io/type.RawOsError.html when stable |
| 544 |
fn into_raw_os_errorrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]into_raw_os_error().(self) -> i32 { |
| 545 |
match self { |
| 546 |
Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]::NoPermissionrust-analyzer cargo clock-steering 0.2.1 unix/Error#NoPermission# => libcrust-analyzer cargo libc 0.2.189 crate/::EPERMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EPERM., |
| 547 |
Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]::NoAccessrust-analyzer cargo clock-steering 0.2.1 unix/Error#NoAccess# => libcrust-analyzer cargo libc 0.2.189 crate/::EACCESrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EACCES., |
| 548 |
Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]::Invalidrust-analyzer cargo clock-steering 0.2.1 unix/Error#Invalid# => libcrust-analyzer cargo libc 0.2.189 crate/::EINVALrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EINVAL., |
| 549 |
Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]::NoDevicerust-analyzer cargo clock-steering 0.2.1 unix/Error#NoDevice# => libcrust-analyzer cargo libc 0.2.189 crate/::ENODEVrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENODEV., |
| 550 |
Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]::NotSupportedrust-analyzer cargo clock-steering 0.2.1 unix/Error#NotSupported# => libcrust-analyzer cargo libc 0.2.189 crate/::EOPNOTSUPPrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/EOPNOTSUPP., |
| 551 |
} |
| 552 |
} |
| 553 |
} |
| 554 |
|
| 555 |
impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> for stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error# { |
| 556 |
fn fromrust-analyzer cargo clock-steering 0.2.1 unix/impl#[`std::io::Error`][`From<Error>`]from().(value: Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#) -> Selfrust-analyzer cargo clock-steering 0.2.1 unix/impl#[`std::io::Error`][`From<Error>`] { |
| 557 |
stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::from_raw_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]from_raw_os_error().(value.into_raw_os_errorrust-analyzer cargo clock-steering 0.2.1 unix/impl#[Error]into_raw_os_error().()) |
| 558 |
} |
| 559 |
} |
| 560 |
|
| 561 |
fn error_numberrust-analyzer cargo clock-steering 0.2.1 unix/error_number().() -> libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int# { |
| 562 |
#[cfg(target_os = "linux")] |
| 563 |
unsafe { |
| 564 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().libcrust-analyzer cargo libc 0.2.189 crate/::__errno_locationrust-analyzer cargo libc 0.2.189 __errno_location().() |
| 565 |
} |
| 566 |
|
| 567 |
#[cfg(not(target_os = "linux"))] |
| 568 |
unsafe { |
| 569 |
*libcrust-analyzer cargo libc 0.2.189 crate/::__error() |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
// Convert those error numbers that can occur for calls to the following |
| 574 |
// functions |
| 575 |
// - ntp_adjtimex https://man7.org/linux/man-pages/man3/ntp_adjtime.3.html |
| 576 |
// - clock_gettime & clock_settime https://man7.org/linux/man-pages/man3/clock_gettime.3.html |
| 577 |
fn convert_errnorust-analyzer cargo clock-steering 0.2.1 unix/convert_errno().() -> Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error# { |
| 578 |
match error_numberrust-analyzer cargo clock-steering 0.2.1 unix/error_number().() { |
| 579 |
libcrust-analyzer cargo libc 0.2.189 crate/::EINVALrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EINVAL. => Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::Invalidrust-analyzer cargo clock-steering 0.2.1 unix/Error#Invalid#, |
| 580 |
// The documentation is a bit unclear if this can happen with |
| 581 |
// non-dynamic clocks like the ntp kapi clock, however deal with it just in case. |
| 582 |
libcrust-analyzer cargo libc 0.2.189 crate/::ENODEVrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENODEV. => Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::NoDevicerust-analyzer cargo clock-steering 0.2.1 unix/Error#NoDevice#, |
| 583 |
libcrust-analyzer cargo libc 0.2.189 crate/::EOPNOTSUPPrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/EOPNOTSUPP. => Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::NotSupportedrust-analyzer cargo clock-steering 0.2.1 unix/Error#NotSupported#, |
| 584 |
libcrust-analyzer cargo libc 0.2.189 crate/::EPERMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EPERM. => Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::NoPermissionrust-analyzer cargo clock-steering 0.2.1 unix/Error#NoPermission#, |
| 585 |
libcrust-analyzer cargo libc 0.2.189 crate/::EACCESrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EACCES. => Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#::NoAccessrust-analyzer cargo clock-steering 0.2.1 unix/Error#NoAccess#, |
| 586 |
libcrust-analyzer cargo libc 0.2.189 crate/::EFAULTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EFAULT. => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("we always pass in valid (accessible) buffers"), |
| 587 |
// No other errors should occur |
| 588 |
other => { |
| 589 |
let error = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::from_raw_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]from_raw_os_error().(other); |
| 590 |
unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("error code `{other}` ({error:?}) should not occur") |
| 591 |
} |
| 592 |
} |
| 593 |
} |
| 594 |
|
| 595 |
fn cerrrust-analyzer cargo clock-steering 0.2.1 unix/cerr().(c_int: libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo clock-steering 0.2.1 unix/Error#> { |
| 596 |
if c_int rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1 { |
| 597 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(convert_errnorust-analyzer cargo clock-steering 0.2.1 unix/convert_errno().()) |
| 598 |
} else { |
| 599 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 600 |
} |
| 601 |
} |
| 602 |
|
| 603 |
pub(craterust-analyzer cargo clock-steering 0.2.1 crate/) enum Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision# { |
| 604 |
Nanorust-analyzer cargo clock-steering 0.2.1 unix/Precision#Nano#, |
| 605 |
#[cfg_attr(any(target_os = "freebsd", target_os = "macos"), allow(unused))] |
| 606 |
Microrust-analyzer cargo clock-steering 0.2.1 unix/Precision#Micro#, |
| 607 |
} |
| 608 |
|
| 609 |
#[cfg_attr(target_os = "linux", allow(unused))] |
| 610 |
fn current_time_timespecrust-analyzer cargo clock-steering 0.2.1 unix/current_time_timespec().(timespec: libcrust-analyzer cargo libc 0.2.189 crate/::timespecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#, precision: Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#) -> Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp# { |
| 611 |
let mut seconds = timespec.tv_secrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_sec.; |
| 612 |
|
| 613 |
let nanos: i32 = timespec.tv_nsecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_nsec. as _; |
| 614 |
|
| 615 |
let mut nanos = match precision { |
| 616 |
Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Nanorust-analyzer cargo clock-steering 0.2.1 unix/Precision#Nano# => nanos, |
| 617 |
Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Microrust-analyzer cargo clock-steering 0.2.1 unix/Precision#Micro# => nanos.checked_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]checked_mul().(1000).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 618 |
}; |
| 619 |
|
| 620 |
// on macOS (at least) we've observed higher nanosecond counts than appear valid |
| 621 |
while nanos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().1_000_000_000 { |
| 622 |
seconds = seconds.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]wrapping_add().(1); |
| 623 |
nanos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1_000_000_000; |
| 624 |
} |
| 625 |
|
| 626 |
// we disallow negative nanoseconds |
| 627 |
while nanos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 { |
| 628 |
seconds = seconds.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]wrapping_sub().(1); |
| 629 |
nanos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1_000_000_000; |
| 630 |
} |
| 631 |
|
| 632 |
Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp# { |
| 633 |
secondsrust-analyzer cargo clock-steering 0.2.1 Timestamp#seconds., |
| 634 |
nanosrust-analyzer cargo clock-steering 0.2.1 Timestamp#nanos.: nanos as u32, |
| 635 |
} |
| 636 |
} |
| 637 |
|
| 638 |
#[cfg_attr(not(target_os = "linux"), allow(unused))] |
| 639 |
fn current_time_timevalrust-analyzer cargo clock-steering 0.2.1 unix/current_time_timeval().(timespec: libcrust-analyzer cargo libc 0.2.189 crate/::timevalrust-analyzer cargo libc 0.2.189 unix/timeval#, precision: Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#) -> Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp# { |
| 640 |
let seconds = timespec.tv_secrust-analyzer cargo libc 0.2.189 unix/timeval#tv_sec.; |
| 641 |
let nanos = match precision { |
| 642 |
Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Nanorust-analyzer cargo clock-steering 0.2.1 unix/Precision#Nano# => timespec.tv_usecrust-analyzer cargo libc 0.2.189 unix/timeval#tv_usec. as u32, |
| 643 |
Precisionrust-analyzer cargo clock-steering 0.2.1 unix/Precision#::Microrust-analyzer cargo clock-steering 0.2.1 unix/Precision#Micro# => (timespec.tv_usecrust-analyzer cargo libc 0.2.189 unix/timeval#tv_usec. as u32) |
| 644 |
.checked_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]checked_mul().(1000) |
| 645 |
.unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 646 |
}; |
| 647 |
|
| 648 |
Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp# { secondsrust-analyzer cargo clock-steering 0.2.1 Timestamp#seconds., nanosrust-analyzer cargo clock-steering 0.2.1 Timestamp#nanos. } |
| 649 |
} |
| 650 |
|
| •651 |
const EMPTY_TIMESPECrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMESPEC.: libcrust-analyzer cargo libc 0.2.189 crate/::timespecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec# = unsafe { corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::zeroedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/zeroed().() }; |
| 652 |
|
| 653 |
// Libc has no good other way of obtaining this, so let's at least make our |
| 654 |
// functions more readable. |
| 655 |
#[cfg(all(target_os = "linux", target_env = "gnu"))] |
| •656 |
pub const EMPTY_TIMEXrust-analyzer cargo clock-steering 0.2.1 unix/EMPTY_TIMEX.: libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex# = unsafe { corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::zeroedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/zeroed().() }; |
| 657 |
|
| 658 |
#[cfg(all(target_os = "linux", target_env = "musl"))] |
| 659 |
pub const EMPTY_TIMEX: libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex# = libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex# { |
| 660 |
modes: 0, |
| 661 |
offset: 0, |
| 662 |
freq: 0, |
| 663 |
maxerror: 0, |
| 664 |
esterror: 0, |
| 665 |
status: 0, |
| 666 |
constant: 0, |
| 667 |
precision: 0, |
| 668 |
tolerance: 0, |
| 669 |
time: libcrust-analyzer cargo libc 0.2.189 crate/::timevalrust-analyzer cargo libc 0.2.189 unix/timeval# { |
| 670 |
tv_sec: 0, |
| 671 |
tv_usec: 0, |
| 672 |
}, |
| 673 |
tick: 0, |
| 674 |
ppsfreq: 0, |
| 675 |
jitter: 0, |
| 676 |
shift: 0, |
| 677 |
stabil: 0, |
| 678 |
jitcnt: 0, |
| 679 |
calcnt: 0, |
| 680 |
errcnt: 0, |
| 681 |
stbcnt: 0, |
| 682 |
tai: 0, |
| 683 |
__padding: [0; 11], |
| 684 |
}; |
| 685 |
|
| 686 |
#[cfg(any(target_os = "freebsd", target_os = "macos"))] |
| 687 |
pub const EMPTY_TIMEX: libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex# = libcrust-analyzer cargo libc 0.2.189 crate/::timexrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex# { |
| 688 |
modes: 0, |
| 689 |
offset: 0, |
| 690 |
freq: 0, |
| 691 |
maxerror: 0, |
| 692 |
esterror: 0, |
| 693 |
status: 0, |
| 694 |
constant: 0, |
| 695 |
precision: 0, |
| 696 |
tolerance: 0, |
| 697 |
ppsfreq: 0, |
| 698 |
jitter: 0, |
| 699 |
shift: 0, |
| 700 |
stabil: 0, |
| 701 |
jitcnt: 0, |
| 702 |
calcnt: 0, |
| 703 |
errcnt: 0, |
| 704 |
stbcnt: 0, |
| 705 |
}; |
| 706 |
|
| 707 |
impl LeapIndicatorrust-analyzer cargo clock-steering 0.2.1 LeapIndicator# { |
| 708 |
fn as_status_bitrust-analyzer cargo clock-steering 0.2.1 unix/impl#[LeapIndicator]as_status_bit().(self) -> libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int# { |
| 709 |
match self { |
| 710 |
LeapIndicatorrust-analyzer cargo clock-steering 0.2.1 LeapIndicator#::NoWarningrust-analyzer cargo clock-steering 0.2.1 LeapIndicator#NoWarning# => 0, |
| 711 |
LeapIndicatorrust-analyzer cargo clock-steering 0.2.1 LeapIndicator#::Leap61rust-analyzer cargo clock-steering 0.2.1 LeapIndicator#Leap61# => libcrust-analyzer cargo libc 0.2.189 crate/::STA_INSrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_INS., |
| 712 |
LeapIndicatorrust-analyzer cargo clock-steering 0.2.1 LeapIndicator#::Leap59rust-analyzer cargo clock-steering 0.2.1 LeapIndicator#Leap59# => libcrust-analyzer cargo libc 0.2.189 crate/::STA_DELrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_DEL., |
| 713 |
LeapIndicatorrust-analyzer cargo clock-steering 0.2.1 LeapIndicator#::Unknownrust-analyzer cargo clock-steering 0.2.1 LeapIndicator#Unknown# => libcrust-analyzer cargo libc 0.2.189 crate/::STA_UNSYNCrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/STA_UNSYNC., |
| 714 |
} |
| 715 |
} |
| 716 |
} |
| 717 |
|
| 718 |
#[cfg(test)] |
| 719 |
mod testsrust-analyzer cargo clock-steering 0.2.1 unix/tests/ { |
| 720 |
use superrust-analyzer cargo clock-steering 0.2.1 unix/::*; |
| 721 |
|
| 722 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 723 |
fn test_time_now_does_not_crashrust-analyzer cargo clock-steering 0.2.1 unix/tests/test_time_now_does_not_crash().() { |
| 724 |
let clock = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#::CLOCK_REALTIMErust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_REALTIME.; |
| 725 |
assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(clock.nowrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]now().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#::defaultrust-analyzer cargo clock-steering 0.2.1 impl#[Timestamp][Default]default().(),); |
| 726 |
} |
| 727 |
|
| 728 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 729 |
fn realtime_gettimerust-analyzer cargo clock-steering 0.2.1 unix/tests/realtime_gettime().() { |
| 730 |
let clock = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#::CLOCK_REALTIMErust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_REALTIME.; |
| 731 |
let time = clock.clock_gettimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_gettime().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 732 |
|
| 733 |
assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!((time.tv_secrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_sec., time.tv_nsecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_nsec.), (0, 0)) |
| 734 |
} |
| 735 |
|
| 736 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 737 |
#[ignore = "requires permissions, useful for testing permissions"] |
| 738 |
fn ptp0_gettimerust-analyzer cargo clock-steering 0.2.1 unix/tests/ptp0_gettime().() { |
| 739 |
let clock = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#::CLOCK_REALTIMErust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_REALTIME.; |
| 740 |
let time = clock.clock_gettimerust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]clock_gettime().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 741 |
|
| 742 |
assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!((time.tv_secrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_sec., time.tv_nsecrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/timespec#tv_nsec.), (0, 0)) |
| 743 |
} |
| 744 |
|
| 745 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 746 |
#[ignore = "requires permissions, useful for testing permissions"] |
| 747 |
fn step_clockrust-analyzer cargo clock-steering 0.2.1 unix/tests/step_clock().() { |
| 748 |
UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#::CLOCK_REALTIMErust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_REALTIME. |
| 749 |
.step_clockrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]step_clock().(TimeOffsetrust-analyzer cargo clock-steering 0.2.1 TimeOffset# { |
| 750 |
secondsrust-analyzer cargo clock-steering 0.2.1 TimeOffset#seconds.: 0, |
| 751 |
nanosrust-analyzer cargo clock-steering 0.2.1 TimeOffset#nanos.: 0, |
| 752 |
}) |
| 753 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 754 |
} |
| 755 |
|
| 756 |
#[cfg(target_os = "linux")] |
| 757 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 758 |
fn test_step_clockrust-analyzer cargo clock-steering 0.2.1 unix/tests/test_step_clock().() { |
| 759 |
let offset = TimeOffsetrust-analyzer cargo clock-steering 0.2.1 TimeOffset# { |
| 760 |
secondsrust-analyzer cargo clock-steering 0.2.1 TimeOffset#seconds.: 1, |
| 761 |
nanosrust-analyzer cargo clock-steering 0.2.1 TimeOffset#nanos.: 200000000, |
| 762 |
}; |
| 763 |
let timex = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#::step_clock_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]step_clock_timex().(offset); |
| 764 |
|
| 765 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(timex.modesrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#modes., libcrust-analyzer cargo libc 0.2.189 crate/::ADJ_SETOFFSETrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/ADJ_SETOFFSET. |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). libcrust-analyzer cargo libc 0.2.189 crate/::ADJ_NANOrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/ADJ_NANO.); |
| 766 |
|
| 767 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(timex.timerust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#time..tv_secrust-analyzer cargo libc 0.2.189 unix/timeval#tv_sec., 1); |
| 768 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(timex.timerust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#time..tv_usecrust-analyzer cargo libc 0.2.189 unix/timeval#tv_usec., 200_000_000); |
| 769 |
} |
| 770 |
|
| 771 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 772 |
fn test_error_estimaterust-analyzer cargo clock-steering 0.2.1 unix/tests/test_error_estimate().() { |
| 773 |
let est_error = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secs_f64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs_f64().(0.5); |
| 774 |
let max_error = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secs_f64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs_f64().(1.2); |
| 775 |
let timex = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#::error_estimate_timexrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]error_estimate_timex().(est_error, max_error); |
| 776 |
|
| 777 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(timex.modesrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#modes., libcrust-analyzer cargo libc 0.2.189 crate/::MOD_ESTERRORrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/MOD_ESTERROR. |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). libcrust-analyzer cargo libc 0.2.189 crate/::MOD_MAXERRORrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/MOD_MAXERROR.); |
| 778 |
|
| 779 |
// these fields are always in microseconds |
| 780 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(timex.esterrorrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#esterror., 500_000); |
| 781 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(timex.maxerrorrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/timex#maxerror., 1_200_000); |
| 782 |
} |
| 783 |
|
| 784 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 785 |
fn test_nowrust-analyzer cargo clock-steering 0.2.1 unix/tests/test_now().() { |
| 786 |
let resolution = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#::CLOCK_REALTIMErust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_REALTIME..nowrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]now().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 787 |
|
| 788 |
assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(resolution, Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#::defaultrust-analyzer cargo clock-steering 0.2.1 impl#[Timestamp][Default]default().()); |
| 789 |
} |
| 790 |
|
| 791 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 792 |
fn test_resolutionrust-analyzer cargo clock-steering 0.2.1 unix/tests/test_resolution().() { |
| 793 |
let resolution = UnixClockrust-analyzer cargo clock-steering 0.2.1 unix/UnixClock#::CLOCK_REALTIMErust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock]CLOCK_REALTIME..resolutionrust-analyzer cargo clock-steering 0.2.1 unix/impl#[UnixClock][Clock]resolution().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 794 |
|
| 795 |
assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(resolution, Timestamprust-analyzer cargo clock-steering 0.2.1 Timestamp#::defaultrust-analyzer cargo clock-steering 0.2.1 impl#[Timestamp][Default]default().()); |
| 796 |
} |
| 797 |
} |