diff options
Diffstat (limited to 'zone_zfs')
-rw-r--r-- | zone_zfs/Cargo.toml | 6 | ||||
-rw-r--r-- | zone_zfs/src/config.rs | 8 | ||||
-rw-r--r-- | zone_zfs/src/file_system.rs | 12 | ||||
-rw-r--r-- | zone_zfs/src/zfs.rs | 3 |
4 files changed, 13 insertions, 16 deletions
diff --git a/zone_zfs/Cargo.toml b/zone_zfs/Cargo.toml index 5abefa3..241710a 100644 --- a/zone_zfs/Cargo.toml +++ b/zone_zfs/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bytesize = { version = "1.1.0", features = ["serde"] } +byte-unit = { version = "4.0.13", features = ["serde"], default-features = false } chrono = { version = "0.4.19", optional = true } derive_builder = "0.10.2" -figment = "0.10.6" -serde = "1.0.136" +figment = { version = "0.10.6", features = ["toml", "env", "test"] } +serde = { version = "1.0.136", features = ["derive"] } thiserror = "1.0.30" tracing = "0.1.29" diff --git a/zone_zfs/src/config.rs b/zone_zfs/src/config.rs index abe07ac..4c0a8b5 100644 --- a/zone_zfs/src/config.rs +++ b/zone_zfs/src/config.rs @@ -1,4 +1,4 @@ -use bytesize::ByteSize; +use byte_unit::Byte; use figment::{ error::Result, providers::{Env, Format, Serialized, Toml}, @@ -8,9 +8,9 @@ use figment::{ use serde::{Deserialize, Serialize}; use std::path::PathBuf; -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] pub struct Config { - pub quota: ByteSize, + pub quota: Byte, pub pool_name: String, pub mountpoint: PathBuf, } @@ -18,7 +18,7 @@ pub struct Config { impl Default for Config { fn default() -> Self { Config { - quota: ByteSize::gb(16), + quota: 16_000_000_000u64.into(), pool_name: String::from("pool"), mountpoint: PathBuf::from("/srv"), } diff --git a/zone_zfs/src/file_system.rs b/zone_zfs/src/file_system.rs index 62169d0..85bd6ca 100644 --- a/zone_zfs/src/file_system.rs +++ b/zone_zfs/src/file_system.rs @@ -1,5 +1,5 @@ use crate::{Error, Result, Snapshot}; -use bytesize::ByteSize; +use byte_unit::Byte; use derive_builder::Builder; use std::{ ffi::{OsStr, OsString}, @@ -26,7 +26,7 @@ macro_rules! concat_opt [ pub struct FileSystem { dataset: PathBuf, mountpoint: PathBuf, - quota: ByteSize, + quota: Byte, } impl Display for FileSystem { @@ -65,7 +65,7 @@ impl FileSystem { } /// Get the file system's quota. - pub fn quota(&self) -> ByteSize { + pub fn quota(&self) -> Byte { self.quota } @@ -104,7 +104,7 @@ impl FileSystem { }) } - pub fn set_quota(&mut self, quota: ByteSize) -> Result<Self> { + pub fn set_quota(&mut self, quota: Byte) -> Result<Self> { self.set_opt("quota", quota.to_string())?; self.quota = quota; Ok(self.to_owned()) @@ -116,10 +116,6 @@ impl FileSystem { Ok(self.to_owned()) } - pub fn get_mountpoint(&self) -> PathBuf { - self.mountpoint.to_owned() - } - pub fn get_snapshots(&self) -> Result<Vec<Snapshot>> { Command::new("zfs") .arg("list") diff --git a/zone_zfs/src/zfs.rs b/zone_zfs/src/zfs.rs index b1c4ed2..b24fe3a 100644 --- a/zone_zfs/src/zfs.rs +++ b/zone_zfs/src/zfs.rs @@ -51,6 +51,7 @@ impl ZFS { FileSystem::builder() .mountpoint(mountpoint) .dataset(dataset) + .quota(self.config.quota) .to_file_system() .ok() }) @@ -69,7 +70,7 @@ impl ZFS { #[cfg(test)] mod tests { #[test] - fn zfs_list() { + fn get_file_systems() { use super::*; assert!(ZFS::new().unwrap().get_file_systems().is_ok()); } |