Sha256: 8fb83eb04ab4ed9473b7249759464f9f6d3ef6a67be2fecdf56b09c9734a0e5f

Contents?: true

Size: 1.41 KB

Versions: 36

Compression:

Stored size: 1.41 KB

Contents

use crate::time::SystemTime;

/// A value for specifying a time.
#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
pub enum SystemTimeSpec {
    /// A value which always represents the current time, in symbolic form, so
    /// that even as time elapses, it continues to represent the current time.
    SymbolicNow,

    /// An absolute time value.
    Absolute(SystemTime),
}

impl SystemTimeSpec {
    /// Constructs a new instance of `Self` from the given
    /// [`fs_set_times::SystemTimeSpec`].
    // TODO: Make this a `const fn` once `SystemTime::from_std` is a `const fn`.
    #[inline]
    pub fn from_std(std: fs_set_times::SystemTimeSpec) -> Self {
        match std {
            fs_set_times::SystemTimeSpec::SymbolicNow => Self::SymbolicNow,
            fs_set_times::SystemTimeSpec::Absolute(time) => {
                Self::Absolute(SystemTime::from_std(time))
            }
        }
    }

    /// Constructs a new instance of [`fs_set_times::SystemTimeSpec`] from the
    /// given `Self`.
    #[inline]
    pub const fn into_std(self) -> fs_set_times::SystemTimeSpec {
        match self {
            Self::SymbolicNow => fs_set_times::SystemTimeSpec::SymbolicNow,
            Self::Absolute(time) => fs_set_times::SystemTimeSpec::Absolute(time.into_std()),
        }
    }
}

impl From<SystemTime> for SystemTimeSpec {
    #[inline]
    fn from(time: SystemTime) -> Self {
        Self::Absolute(time)
    }
}

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
wasmtime-27.0.0 ./ext/cargo-vendor/cap-primitives-3.4.1/src/fs/system_time_spec.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cap-primitives-3.3.0/src/fs/system_time_spec.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/system_time_spec.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/system_time_spec.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/system_time_spec.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/system_time_spec.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/system_time_spec.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/system_time_spec.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/system_time_spec.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/system_time_spec.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cap-primitives-3.0.0/src/fs/system_time_spec.rs
wasmtime-18.0.3 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/system_time_spec.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/system_time_spec.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/system_time_spec.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/system_time_spec.rs
wasmtime-15.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/system_time_spec.rs
wasmtime-15.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/system_time_spec.rs
wasmtime-14.0.4 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/system_time_spec.rs
wasmtime-14.0.3 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/system_time_spec.rs
wasmtime-14.0.1 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/system_time_spec.rs