cap_primitives/fs/
system_time_spec.rs1use crate::time::SystemTime;
2
3#[derive(Debug)]
5#[allow(clippy::module_name_repetitions)]
6pub enum SystemTimeSpec {
7 SymbolicNow,
10
11 Absolute(SystemTime),
13}
14
15impl SystemTimeSpec {
16 #[inline]
20 pub fn from_std(std: fs_set_times::SystemTimeSpec) -> Self {
21 match std {
22 fs_set_times::SystemTimeSpec::SymbolicNow => Self::SymbolicNow,
23 fs_set_times::SystemTimeSpec::Absolute(time) => {
24 Self::Absolute(SystemTime::from_std(time))
25 }
26 }
27 }
28
29 #[inline]
32 pub const fn into_std(self) -> fs_set_times::SystemTimeSpec {
33 match self {
34 Self::SymbolicNow => fs_set_times::SystemTimeSpec::SymbolicNow,
35 Self::Absolute(time) => fs_set_times::SystemTimeSpec::Absolute(time.into_std()),
36 }
37 }
38}
39
40impl From<SystemTime> for SystemTimeSpec {
41 #[inline]
42 fn from(time: SystemTime) -> Self {
43 Self::Absolute(time)
44 }
45}