#[repr(C)]pub struct Timespec {
pub tv_sec: Secs,
pub tv_nsec: Nsecs,
}Available on crate feature
event only.Expand description
struct timespec—A quantity of time in seconds plus nanoseconds.
Fields§
§tv_sec: SecsSeconds.
tv_nsec: NsecsNanoseconds. Must be less than 1_000_000_000.
When passed to rustix::fs::utimensat, this field may instead be
assigned the values UTIME_NOW or UTIME_OMIT.
Implementations§
Source§impl Timespec
impl Timespec
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
pub const fn checked_add(self, rhs: Self) -> Option<Self>
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Checked Timespec addition. Returns None if overflow occurred.
§Panics
If 0 <= .tv_nsec < 1_000_000_000 doesn’t hold, this function may
panic or return unexpected results.
§Example
use rustix::event::Timespec;
assert_eq!(
Timespec {
tv_sec: 1,
tv_nsec: 2
}
.checked_add(Timespec {
tv_sec: 30,
tv_nsec: 40
}),
Some(Timespec {
tv_sec: 31,
tv_nsec: 42
})
);
assert_eq!(
Timespec {
tv_sec: 0,
tv_nsec: 999_999_999
}
.checked_add(Timespec {
tv_sec: 0,
tv_nsec: 2
}),
Some(Timespec {
tv_sec: 1,
tv_nsec: 1
})
);
assert_eq!(
Timespec {
tv_sec: i64::MAX,
tv_nsec: 999_999_999
}
.checked_add(Timespec {
tv_sec: 0,
tv_nsec: 1
}),
None
);Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Checked Timespec subtraction. Returns None if overflow occurred.
§Panics
If 0 <= .tv_nsec < 1_000_000_000 doesn’t hold, this function may
panic or return unexpected results.
§Example
use rustix::event::Timespec;
assert_eq!(
Timespec {
tv_sec: 31,
tv_nsec: 42
}
.checked_sub(Timespec {
tv_sec: 30,
tv_nsec: 40
}),
Some(Timespec {
tv_sec: 1,
tv_nsec: 2
})
);
assert_eq!(
Timespec {
tv_sec: 1,
tv_nsec: 1
}
.checked_sub(Timespec {
tv_sec: 0,
tv_nsec: 2
}),
Some(Timespec {
tv_sec: 0,
tv_nsec: 999_999_999
})
);
assert_eq!(
Timespec {
tv_sec: i64::MIN,
tv_nsec: 0
}
.checked_sub(Timespec {
tv_sec: 0,
tv_nsec: 1
}),
None
);Trait Implementations§
Source§impl Add for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl Add for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl AddAssign for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl AddAssign for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl Clone for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl Clone for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl Debug for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl Debug for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl Default for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl Default for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl Neg for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl Neg for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl Ord for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl Ord for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl PartialEq for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl PartialEq for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl PartialOrd for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl PartialOrd for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl Sub for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl Sub for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl SubAssign for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl SubAssign for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreSource§impl TryFrom<Duration> for Timespec
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl TryFrom<Duration> for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Source§impl TryFrom<Timespec> for Duration
Available on crate feature fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.
impl TryFrom<Timespec> for Duration
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.impl Copy for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.impl Eq for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.impl StructuralPartialEq for Timespec
Available on crate feature
fs, or crate feature event, or crate feature process, or crate feature runtime, or crate feature thread, or crate feature time, or crate feature event and (bsd or linux_kernel or Windows or WASI), or linux_raw and non-crate feature use-libc-auxv and non-crate feature use-explicitly-provided-auxv and (crate feature param or crate feature process or crate feature runtime or crate feature time or x86) only.Auto Trait Implementations§
impl Freeze for Timespec
impl RefUnwindSafe for Timespec
impl Send for Timespec
impl Sync for Timespec
impl Unpin for Timespec
impl UnsafeUnpin for Timespec
impl UnwindSafe for Timespec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more