Struct nt_time::FileTime

source ·
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

source

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)
);
source

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)
);
source

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);
source

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);
source

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);
source

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
);
source

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
);
source

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 Add<Duration> for FileTime

§

type Output = FileTime

The resulting type after applying the + operator.
source§

fn add(self, rhs: Duration) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<Duration> for FileTime

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl Clone for FileTime

source§

fn clone(&self) -> FileTime

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FileTime

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for FileTime

source§

fn default() -> Self

Returns the default value of “1601-01-01 00:00:00 UTC”.

Examples
assert_eq!(FileTime::default(), FileTime::NT_EPOCH);
source§

impl Display for FileTime

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<FileTime> for u64

source§

fn from(time: FileTime) -> Self

Converts a FileTime to the Windows NT system time.

Examples
assert_eq!(u64::from(FileTime::NT_EPOCH), u64::MIN);
assert_eq!(u64::from(FileTime::MAX), u64::MAX);
source§

impl From<u64> for FileTime

source§

fn from(time: u64) -> Self

Converts the Windows NT system time to a FileTime.

Examples
assert_eq!(FileTime::from(u64::MIN), FileTime::NT_EPOCH);
assert_eq!(FileTime::from(u64::MAX), FileTime::MAX);
source§

impl Hash for FileTime

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for FileTime

source§

fn cmp(&self, other: &FileTime) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<FileTime> for FileTime

source§

fn eq(&self, other: &FileTime) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<FileTime> for FileTime

source§

fn partial_cmp(&self, other: &FileTime) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<Duration> for FileTime

§

type Output = FileTime

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Duration) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<FileTime> for FileTime

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl SubAssign<Duration> for FileTime

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl TryFrom<FileTime> for OffsetDateTime

source§

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

The type returned in the event of a conversion error.
source§

impl TryFrom<FileTime> for SystemTime

Available on crate feature std only.
source§

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

The type returned in the event of a conversion error.
source§

impl TryFrom<OffsetDateTime> for FileTime

source§

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

The type returned in the event of a conversion error.
source§

impl TryFrom<SystemTime> for FileTime

Available on crate feature std only.
source§

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.

§

type Error = FileTimeRangeError

The type returned in the event of a conversion error.
source§

impl Copy for FileTime

source§

impl Eq for FileTime

source§

impl StructuralEq for FileTime

source§

impl StructuralPartialEq for FileTime

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.