#[cfg(feature = "async")]
pub mod r#async;
#[cfg(feature = "blocking")]
pub mod blocking;
pub mod common;
pub mod manager;
pub mod power;
pub mod storage;
pub mod thermal;
#[cfg(feature = "blocking")]
pub use blocking::Redfish;
#[derive(Default, Copy, Clone, Debug)]
pub enum ApiVersion {
#[default]
V1,
V2,
}
impl std::fmt::Display for ApiVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::V1 => write!(f, "redfish/v1"),
Self::V2 => write!(f, "redfish/v2"),
}
}
}
#[derive(Debug, Clone)]
pub struct Config {
pub user: Option<String>,
pub host: String,
pub api_version: Option<ApiVersion>,
pub password: Option<String>,
pub port: Option<u16>,
}
fn build_uri(
host: &String,
port: Option<u16>,
api_version: Option<ApiVersion>,
api: &str,
) -> String {
match port {
Some(p) => match api_version {
Some(v) => format!("https://{}:{}/{}/{}", host, p, v, api),
None => format!("https://{}:{}/{}", host, p, api),
},
None => match api_version {
Some(v) => format!("https://{}/{}/{}", host, v, api),
None => format!("https://{}/{}", host, api),
},
}
}