diff --git a/proxmox-rrd-api-types/Cargo.toml b/proxmox-rrd-api-types/Cargo.toml new file mode 100644 index 00000000..eaae9a90 --- /dev/null +++ b/proxmox-rrd-api-types/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "proxmox-rrd-api-types" +version = "0.1.0" +authors = ["Proxmox Support Team "] +edition = "2018" +description = "API type definitions for proxmox-rrd crate." + + +[dependencies] +serde = { version = "1.0", features = [] } +proxmox = { version = "0.13.5", features = ["api-macro"] } diff --git a/proxmox-rrd-api-types/src/lib.rs b/proxmox-rrd-api-types/src/lib.rs new file mode 100644 index 00000000..4a0165ff --- /dev/null +++ b/proxmox-rrd-api-types/src/lib.rs @@ -0,0 +1,31 @@ +use serde::{Deserialize, Serialize}; +use proxmox::api::api; + +#[api()] +#[derive(Copy, Clone, Serialize, Deserialize)] +#[serde(rename_all = "UPPERCASE")] +/// RRD consolidation mode +pub enum RRDMode { + /// Maximum + Max, + /// Average + Average, +} + +#[api()] +#[repr(u64)] +#[derive(Copy, Clone, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +/// RRD time frame resolution +pub enum RRDTimeFrameResolution { + /// 1 min => last 70 minutes + Hour = 60, + /// 30 min => last 35 hours + Day = 60*30, + /// 3 hours => about 8 days + Week = 60*180, + /// 12 hours => last 35 days + Month = 60*720, + /// 1 week => last 490 days + Year = 60*10080, +} diff --git a/proxmox-rrd/Cargo.toml b/proxmox-rrd/Cargo.toml index c2b2d213..e5a0e2b0 100644 --- a/proxmox-rrd/Cargo.toml +++ b/proxmox-rrd/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "proxmox-rrd" version = "0.1.0" -authors = ["Dietmar Maurer "] +authors = ["Proxmox Support Team "] edition = "2018" description = "Simple RRD database implementation." @@ -11,3 +11,5 @@ bitflags = "1.2.1" serde = { version = "1.0", features = [] } proxmox = { version = "0.13.5", features = ["api-macro"] } + +proxmox-rrd-api-types = { path = "../proxmox-rrd-api-types" } diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs index c0e46d35..550eb30c 100644 --- a/proxmox-rrd/src/cache.rs +++ b/proxmox-rrd/src/cache.rs @@ -6,7 +6,7 @@ use anyhow::{format_err, Error}; use proxmox::tools::fs::{create_path, CreateOptions}; -use crate::{RRDMode, RRDTimeFrameResolution}; +use proxmox_rrd_api_types::{RRDMode, RRDTimeFrameResolution}; use super::*; diff --git a/proxmox-rrd/src/lib.rs b/proxmox-rrd/src/lib.rs index d6ba54c9..446aff04 100644 --- a/proxmox-rrd/src/lib.rs +++ b/proxmox-rrd/src/lib.rs @@ -3,35 +3,3 @@ pub use rrd::*; mod cache; pub use cache::*; - -use serde::{Deserialize, Serialize}; -use proxmox::api::api; - -#[api()] -#[derive(Copy, Clone, Serialize, Deserialize)] -#[serde(rename_all = "UPPERCASE")] -/// RRD consolidation mode -pub enum RRDMode { - /// Maximum - Max, - /// Average - Average, -} - -#[api()] -#[repr(u64)] -#[derive(Copy, Clone, Serialize, Deserialize)] -#[serde(rename_all = "lowercase")] -/// RRD time frame resolution -pub enum RRDTimeFrameResolution { - /// 1 min => last 70 minutes - Hour = 60, - /// 30 min => last 35 hours - Day = 60*30, - /// 3 hours => about 8 days - Week = 60*180, - /// 12 hours => last 35 days - Month = 60*720, - /// 1 week => last 490 days - Year = 60*10080, -} diff --git a/proxmox-rrd/src/rrd.rs b/proxmox-rrd/src/rrd.rs index 19a6deba..526d36b3 100644 --- a/proxmox-rrd/src/rrd.rs +++ b/proxmox-rrd/src/rrd.rs @@ -5,7 +5,7 @@ use anyhow::Error; use proxmox::tools::{fs::replace_file, fs::CreateOptions}; -use crate::{RRDMode, RRDTimeFrameResolution}; +use proxmox_rrd_api_types::{RRDMode, RRDTimeFrameResolution}; /// The number of data entries per RRA pub const RRD_DATA_ENTRIES: usize = 70;