pub struct FileTime(_);Expand description
FileTime is a type that represents the Windows NT system
time.
This is a 64-bit unsigned integer value that represents the number of 100-nanosecond intervals that have elapsed since “1601-01-01 00:00:00 UTC”.
Implementations§
source§impl FileTime
impl FileTime
sourcepub const NT_EPOCH: Self = _
pub const NT_EPOCH: Self = _
The NT time epoch.
This is defined as “1601-01-01 00:00:00 UTC”.
Examples
assert_eq!(
OffsetDateTime::try_from(FileTime::NT_EPOCH).unwrap(),
datetime!(1601-01-01 00:00 UTC)
);sourcepub const MAX: Self = _
pub const MAX: Self = _
The largest value that can be represented by the Windows NT system time.
This is “+60056-05-28 05:36:10.955161500 UTC”.
Examples
assert_eq!(
OffsetDateTime::try_from(FileTime::MAX).unwrap(),
datetime!(+60056-05-28 05:36:10.955_161_500 UTC)
);sourcepub const fn new(time: u64) -> Self
pub const fn new(time: u64) -> Self
Creates a new FileTime with the given Windows NT system time.
Examples
assert_eq!(FileTime::new(u64::MIN), FileTime::NT_EPOCH);
assert_eq!(FileTime::new(u64::MAX), FileTime::MAX);sourcepub const fn as_u64(self) -> u64
pub const fn as_u64(self) -> u64
Converts a FileTime to the Windows NT system time.
Examples
assert_eq!(FileTime::NT_EPOCH.as_u64(), u64::MIN);
assert_eq!(FileTime::MAX.as_u64(), u64::MAX);sourcepub fn checked_add(self, duration: Duration) -> Option<Self>
pub fn checked_add(self, duration: Duration) -> Option<Self>
Computes self + duration, returning None if overflow occurred.
Examples
assert_eq!(
FileTime::NT_EPOCH.checked_add(Duration::from_nanos(1)),
Some(FileTime::NT_EPOCH)
);
assert_eq!(
FileTime::NT_EPOCH.checked_add(Duration::from_nanos(100)),
Some(FileTime::new(1))
);
assert_eq!(FileTime::MAX.checked_add(Duration::from_nanos(100)), None);sourcepub fn checked_sub(self, duration: Duration) -> Option<Self>
pub fn checked_sub(self, duration: Duration) -> Option<Self>
Computes self - duration, returning None if the result would be
negative or if overflow occurred.
Examples
assert_eq!(
FileTime::MAX.checked_sub(Duration::from_nanos(1)),
Some(FileTime::MAX)
);
assert_eq!(
FileTime::MAX.checked_sub(Duration::from_nanos(100)),
Some(FileTime::new(u64::MAX - 1))
);
assert_eq!(
FileTime::NT_EPOCH.checked_sub(Duration::from_nanos(100)),
None
);sourcepub fn saturating_add(self, duration: Duration) -> Self
pub fn saturating_add(self, duration: Duration) -> Self
Computes self + duration, returning FileTime::MAX if overflow
occurred.
Examples
assert_eq!(
FileTime::NT_EPOCH.saturating_add(Duration::from_nanos(1)),
FileTime::NT_EPOCH
);
assert_eq!(
FileTime::NT_EPOCH.saturating_add(Duration::from_nanos(100)),
FileTime::new(1)
);
assert_eq!(
FileTime::MAX.saturating_add(Duration::from_nanos(100)),
FileTime::MAX
);sourcepub fn saturating_sub(self, duration: Duration) -> Self
pub fn saturating_sub(self, duration: Duration) -> Self
Computes self - duration, returning FileTime::NT_EPOCH if the
result would be negative or if overflow occurred.
Examples
assert_eq!(
FileTime::MAX.saturating_sub(Duration::from_nanos(1)),
FileTime::MAX
);
assert_eq!(
FileTime::MAX.saturating_sub(Duration::from_nanos(100)),
FileTime::new(u64::MAX - 1)
);
assert_eq!(
FileTime::NT_EPOCH.saturating_sub(Duration::from_nanos(100)),
FileTime::NT_EPOCH
);Trait Implementations§
source§impl AddAssign<Duration> for FileTime
impl AddAssign<Duration> for FileTime
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moresource§impl Ord for FileTime
impl Ord for FileTime
source§impl PartialEq<FileTime> for FileTime
impl PartialEq<FileTime> for FileTime
source§impl PartialOrd<FileTime> for FileTime
impl PartialOrd<FileTime> for FileTime
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl SubAssign<Duration> for FileTime
impl SubAssign<Duration> for FileTime
source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read moresource§impl TryFrom<FileTime> for OffsetDateTime
impl TryFrom<FileTime> for OffsetDateTime
source§fn try_from(time: FileTime) -> Result<Self, Self::Error>
fn try_from(time: FileTime) -> Result<Self, Self::Error>
Converts a FileTime to a OffsetDateTime.
Errors
Returns Err if the large-dates feature is disabled and time is
out of range of OffsetDateTime.
§type Error = OffsetDateTimeRangeError
type Error = OffsetDateTimeRangeError
source§impl TryFrom<FileTime> for SystemTime
Available on crate feature std only.
impl TryFrom<FileTime> for SystemTime
std only.source§fn try_from(time: FileTime) -> Result<Self, Self::Error>
fn try_from(time: FileTime) -> Result<Self, Self::Error>
Converts a FileTime to a SystemTime.
Errors
Returns Err if the large-dates feature is disabled and time is
out of range of OffsetDateTime.
§type Error = OffsetDateTimeRangeError
type Error = OffsetDateTimeRangeError
source§impl TryFrom<OffsetDateTime> for FileTime
impl TryFrom<OffsetDateTime> for FileTime
source§fn try_from(dt: OffsetDateTime) -> Result<Self, Self::Error>
fn try_from(dt: OffsetDateTime) -> Result<Self, Self::Error>
Converts a OffsetDateTime to a FileTime.
Errors
Returns Err if dt is out of range of the Windows NT system time.
§type Error = FileTimeRangeError
type Error = FileTimeRangeError
source§impl TryFrom<SystemTime> for FileTime
Available on crate feature std only.
impl TryFrom<SystemTime> for FileTime
std only.source§fn try_from(time: SystemTime) -> Result<Self, Self::Error>
fn try_from(time: SystemTime) -> Result<Self, Self::Error>
Converts a SystemTime to a FileTime.
Errors
Returns Err if time is out of range of the Windows NT system time.