diff options
Diffstat (limited to 'zone_zfs/src/snapshot.rs')
-rw-r--r-- | zone_zfs/src/snapshot.rs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/zone_zfs/src/snapshot.rs b/zone_zfs/src/snapshot.rs deleted file mode 100644 index 84db4e3..0000000 --- a/zone_zfs/src/snapshot.rs +++ /dev/null @@ -1,54 +0,0 @@ -use crate::{Error, FileSystem, Result}; -use std::{ffi::OsString, path::PathBuf}; - -#[cfg(feature = "chrono")] -use chrono::{DateTime, Utc, MIN_DATETIME}; - -#[derive(Debug)] -pub struct Snapshot { - name: OsString, - dataset: PathBuf, - - #[cfg(feature = "chrono")] - timestamp: DateTime<Utc>, -} - -impl TryFrom<&str> for Snapshot { - type Error = Error; - - fn try_from(s: &str) -> Result<Self> { - s.split_once('@') - .map(|(d, n)| Snapshot { - name: n.into(), - dataset: d.into(), - - #[cfg(feature = "chrono")] - timestamp: n.parse().unwrap_or(MIN_DATETIME), - }) - .ok_or_else(|| Error::Snapshot(format!("Failed to parse snapshot: {:?}", s))) - } -} - -impl Snapshot { - pub fn clone_new(&self, path: String) -> Result<FileSystem> { - FileSystem::builder() - .dataset(&self.dataset.join(path)) - .build_from(self.to_owned()) - } - - /// Get a reference to the snapshot's name. - pub fn name(&self) -> &OsString { - &self.name - } - - /// Get a reference to the snapshot's dataset. - pub fn dataset(&self) -> &PathBuf { - &self.dataset - } - - #[cfg(feature = "chrono")] - /// Get the snapshot's timestamp. - pub fn timestamp(&self) -> DateTime<Utc> { - self.timestamp - } -} |