openssh_sftp_client/
unix_timestamp.rsuse super::{lowlevel, UnixTimeStampError};
use std::time::{Duration, SystemTime};
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)]
#[repr(transparent)]
pub struct UnixTimeStamp(pub(crate) lowlevel::UnixTimeStamp);
impl UnixTimeStamp {
pub fn new(system_time: SystemTime) -> Result<Self, UnixTimeStampError> {
lowlevel::UnixTimeStamp::new(system_time).map(Self)
}
pub const fn unix_epoch() -> Self {
Self(lowlevel::UnixTimeStamp::unix_epoch())
}
pub fn from_raw(elapsed: u32) -> Option<Self> {
lowlevel::UnixTimeStamp::from_raw(elapsed).map(Self)
}
pub fn into_raw(self) -> u32 {
self.0.into_raw()
}
pub fn as_duration(self) -> Duration {
self.0.as_duration()
}
pub fn as_system_time(self) -> SystemTime {
self.0.as_system_time()
}
}