Debian Codegraph @

src/system/time.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{
2 iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#},
3 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#,
4 opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#, Subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#},
5 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#,
6 };
7
8 /// A timestamp relative to `CLOCK_BOOTTIME`.
9 #[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:, 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:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)]
10 pub struct SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime# {
11 secsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#secs.: i64,
12 nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#nsecs.: i64,
13 }
14
15 impl SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime# {
16 pub(superrust-analyzer cargo sudo-rs 0.2.14 system/) fn newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(secs: i64, nsecs: i64) -> SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime# {
17 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime# {
18 secsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#secs.: secs 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().nsecs.div_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]div_euclid().(1_000_000_000),
19 nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#nsecs.: nsecs.rem_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]rem_euclid().(1_000_000_000),
20 }
21 }
22
23 pub fn nowrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]now().() -> 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#<SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#> {
24 let mut spec = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::<libcrust-analyzer cargo libc 0.2.186 crate/::timespecrust-analyzer cargo libc 0.2.186 unix/linux_like/linux/gnu/timespec#>::uninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]uninit().();
25 // SAFETY: valid pointer is passed to clock_gettime
26 craterust-analyzer cargo sudo-rs 0.2.14 crate/::cutilsrust-analyzer cargo sudo-rs 0.2.14 cutils/::cerrrust-analyzer cargo sudo-rs 0.2.14 cutils/cerr().(unsafe {
27 libcrust-analyzer cargo libc 0.2.186 crate/::clock_gettimerust-analyzer cargo libc 0.2.186 clock_gettime().(libcrust-analyzer cargo libc 0.2.186 crate/::CLOCK_BOOTTIMErust-analyzer cargo libc 0.2.186 unix/linux_like/CLOCK_BOOTTIME., spec.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]as_mut_ptr().())
28 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
29 // SAFETY: The `libc::clock_gettime` will correctly initialize `spec`,
30 // otherwise it will return early with the `?` operator.
31 let spec = unsafe { spec.assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() };
32 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(spec.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
33 }
34
35 pub(superrust-analyzer cargo sudo-rs 0.2.14 system/) fn encoderust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]encode().(&self, target: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> 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#<()> {
36 let secs = self.secsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#secs..to_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]to_ne_bytes().();
37 let nsecs = self.nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#nsecs..to_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]to_ne_bytes().();
38 target.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&secs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
39 target.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&nsecs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
40 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
41 }
42
43 pub(superrust-analyzer cargo sudo-rs 0.2.14 system/) fn decoderust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]decode().(from: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> 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#<SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#> {
44 let mut sec_bytes = [0; 8];
45 let mut nsec_bytes = [0; 8];
46
47 from.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut sec_bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
48 from.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut nsec_bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
49
50 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(
51 i64::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]from_ne_bytes().(sec_bytes),
52 i64::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]from_ne_bytes().(nsec_bytes),
53 ))
54 }
55
56 #[inline]
57 fn checked_addrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]checked_add().(self, rhs: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#> {
58 let rhs_secs = rhs.as_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs().().try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
59 let rhs_nsecs = rhs.subsec_nanosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]subsec_nanos().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
60
61 let secs = self.secsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#secs..checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]checked_add().(rhs_secs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
62 let nsecs = self.nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#nsecs..checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]checked_add().(rhs_nsecs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
63
64 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(secs, nsecs))
65 }
66
67 #[inline]
68 fn checked_subrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]checked_sub().(self, rhs: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#> {
69 let rhs_secs = rhs.as_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs().().try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
70 let rhs_nsecs = rhs.subsec_nanosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]subsec_nanos().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
71
72 let secs = self.secsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#secs..checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]checked_sub().(rhs_secs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
73 let nsecs = self.nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#nsecs..checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]checked_sub().(rhs_nsecs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
74
75 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(secs, nsecs))
76 }
77 }
78
79 impl Addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#<Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#> for SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime# {
80 type Outputrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Add<Duration>`]Output# = SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#;
81
82 #[inline]
83 fn addrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Add<Duration>`]add().(self, rhs: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#) -> Selfrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Add<Duration>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#Output# {
84 self.checked_addrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]checked_add().(rhs)
85 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("overflow when adding duration")
86 }
87 }
88
89 impl Subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#<Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#> for SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime# {
90 type Outputrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Sub<Duration>`]Output# = SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#;
91
92 #[inline]
93 fn subrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Sub<Duration>`]sub().(self, rhs: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#) -> Selfrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Sub<Duration>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#Output# {
94 self.checked_subrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]checked_sub().(rhs)
95 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("overflow when subtracting duration")
96 }
97 }
98
99 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<libcrust-analyzer cargo libc 0.2.186 crate/::timespecrust-analyzer cargo libc 0.2.186 unix/linux_like/linux/gnu/timespec#> for SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime# {
100 #[allow(clippy::useless_conversion)]
101 fn fromrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`From<libc::timespec>`]from().(value: libcrust-analyzer cargo libc 0.2.186 crate/::timespecrust-analyzer cargo libc 0.2.186 unix/linux_like/linux/gnu/timespec#) -> Selfrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`From<libc::timespec>`] {
102 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(value.tv_secrust-analyzer cargo libc 0.2.186 unix/linux_like/linux/gnu/timespec#tv_sec..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), value.tv_nsecrust-analyzer cargo libc 0.2.186 unix/linux_like/linux/gnu/timespec#tv_nsec..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
103 }
104 }
105
106 /// A timestamp relative to `CLOCK_BOOTTIME` on Linux and relative to `CLOCK_REALTIME` on FreeBSD.
107 #[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:, 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:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)]
108 pub struct ProcessCreateTimerust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime# {
109 secsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#secs.: i64,
110 nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#nsecs.: i64,
111 }
112
113 impl ProcessCreateTimerust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime# {
114 pub fn newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[ProcessCreateTime]new().(secs: i64, nsecs: i64) -> ProcessCreateTimerust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime# {
115 ProcessCreateTimerust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime# {
116 secsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#secs.: secs 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().nsecs.div_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]div_euclid().(1_000_000_000),
117 nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#nsecs.: nsecs.rem_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]rem_euclid().(1_000_000_000),
118 }
119 }
120
121 pub(superrust-analyzer cargo sudo-rs 0.2.14 system/) fn encoderust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[ProcessCreateTime]encode().(&self, target: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> 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#<()> {
122 let secs = self.secsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#secs..to_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]to_ne_bytes().();
123 let nsecs = self.nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#nsecs..to_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]to_ne_bytes().();
124 target.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&secs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
125 target.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&nsecs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
126 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
127 }
128
129 pub(superrust-analyzer cargo sudo-rs 0.2.14 system/) fn decoderust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[ProcessCreateTime]decode().(from: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> 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#<ProcessCreateTimerust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#> {
130 let mut sec_bytes = [0; 8];
131 let mut nsec_bytes = [0; 8];
132
133 from.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut sec_bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
134 from.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut nsec_bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
135
136 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ProcessCreateTimerust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[ProcessCreateTime]new().(
137 i64::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]from_ne_bytes().(sec_bytes),
138 i64::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]from_ne_bytes().(nsec_bytes),
139 ))
140 }
141 }
142
143 #[cfg(test)]
144 mod testsrust-analyzer cargo sudo-rs 0.2.14 system/time/tests/ {
145 use superrust-analyzer cargo sudo-rs 0.2.14 system/time/::*;
146
147 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
148 fn test_new_system_timerust-analyzer cargo sudo-rs 0.2.14 system/time/tests/test_new_system_time().() {
149 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().1, 2_000_000_000), SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(1, 0));
150 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
151 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(2, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().500_000_000),
152 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(1, 500_000_000)
153 );
154 }
155
156 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
157 fn test_time_opsrust-analyzer cargo sudo-rs 0.2.14 system/time/tests/test_time_ops().() {
158 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
159 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(0, 0) +rust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Add<Duration>`]add(). Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(3),
160 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(3, 0)
161 );
162 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
163 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(0, 500_000_000) +rust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Add<Duration>`]add(). Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_nanosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_nanos().(2_500_000_000),
164 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(3, 0)
165 );
166 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
167 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(10, 0) -rust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Sub<Duration>`]sub(). Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(4),
168 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(6, 0)
169 );
170 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
171 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(10, 0) -rust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime][`Sub<Duration>`]sub(). Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_nanosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_nanos().(3_500_000_000),
172 SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::newrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]new().(6, 500_000_000)
173 );
174 }
175
176 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
177 fn get_process_start_timerust-analyzer cargo sudo-rs 0.2.14 system/time/tests/get_process_start_time().() {
178 use craterust-analyzer cargo sudo-rs 0.2.14 crate/::systemrust-analyzer cargo sudo-rs 0.2.14 system/::{Processrust-analyzer cargo sudo-rs 0.2.14 system/Process#, WithProcessrust-analyzer cargo sudo-rs 0.2.14 system/WithProcess#};
179 let time = Processrust-analyzer cargo sudo-rs 0.2.14 system/Process#::starting_timerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Process]starting_time().(WithProcessrust-analyzer cargo sudo-rs 0.2.14 system/WithProcess#::Currentrust-analyzer cargo sudo-rs 0.2.14 system/WithProcess#Current#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
180
181 let now = {
182 let superrust-analyzer cargo sudo-rs 0.2.14 system/time/::SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime# { secsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#secs., nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#nsecs. } = superrust-analyzer cargo sudo-rs 0.2.14 system/time/::SystemTimerust-analyzer cargo sudo-rs 0.2.14 system/time/SystemTime#::nowrust-analyzer cargo sudo-rs 0.2.14 system/time/impl#[SystemTime]now().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
183 superrust-analyzer cargo sudo-rs 0.2.14 system/time/::ProcessCreateTimerust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime# { secsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#secs., nsecsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#nsecs. }
184 };
185
186 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(time.secsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#secs. >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]gt(). now.secsrust-analyzer cargo sudo-rs 0.2.14 system/time/ProcessCreateTime#secs. -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). 24 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). 60);
187 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(time <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). now);
188 }
189 }