Skip to main content

UnixTimes

Struct UnixTimes 

Source
pub struct UnixTimes {
    pub mtime: Option<u64>,
    pub atime: Option<u64>,
    pub ctime: Option<u64>,
}
Expand description

A snapshot of a file’s Unix timestamps, in seconds since 1970-01-01.

Every field is Option<u64> so partial sources (tar has only mtime) don’t have to fabricate the others. When a field is None the destination driver falls back to whatever it would use for a genuinely new file.

Fields§

§mtime: Option<u64>

Modification time — the “when the content last changed” one, the number ls -l and tar display. This is the field that matters most; both dir_import and tar_import populate it.

§atime: Option<u64>

Access time — often equal to mtime on write. dir_import captures the host file’s atime; tar has no access-time field so tar_import leaves it None (driver falls back to mtime or now).

§ctime: Option<u64>

Metadata-change time — bumped by chmod / rename on POSIX. Almost never available at import time (tar doesn’t carry it, hosts don’t usually expose it portably), so this is usually None → driver uses mtime or now.

Implementations§

Source§

impl UnixTimes

Source

pub fn all(secs: u64) -> Self

Snapshot with all three fields set to the same value. What dir_import uses when the host has only st_mtime to hand.

Source

pub fn mtime_only(secs: u64) -> Self

Snapshot with only mtime set. What tar_import produces (tar has no atime/ctime fields).

Source

pub fn mtime_or_now(&self) -> u64

Convenience: mtime if set, else atime, else ctime, else now. The pattern most drivers want when writing a single-field on-disk time (e.g. UFS’s di_mtime only) — pick the most user-meaningful value the caller supplied without overwriting it with now.

Source

pub fn atime_or_now(&self) -> u64

Convenience: atime if set, else mtime, else ctime, else now.

Source

pub fn ctime_or_now(&self) -> u64

Convenience: ctime if set, else mtime, else atime, else now.

Source

pub fn is_empty(&self) -> bool

True when every field is None (equivalent to Default::default).

Trait Implementations§

Source§

impl Clone for UnixTimes

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for UnixTimes

Source§

impl Debug for UnixTimes

Source§

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

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

impl Default for UnixTimes

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for UnixTimes

Source§

impl PartialEq for UnixTimes

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for UnixTimes

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.