From 8256b0e417571577bdb0a0f1c2367eb25b0c7104 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 22 Nov 2019 09:04:52 +0100 Subject: [PATCH] src/api_schema/registry.rs: remove dead code --- src/api_schema.rs | 1 - src/api_schema/registry.rs | 90 -------------------------------------- 2 files changed, 91 deletions(-) delete mode 100644 src/api_schema/registry.rs diff --git a/src/api_schema.rs b/src/api_schema.rs index 5ac6a0b3..27ef3194 100644 --- a/src/api_schema.rs +++ b/src/api_schema.rs @@ -8,6 +8,5 @@ //! hierarchy of API entries, and provides ways to find an API //! definition by path. -//pub mod registry; pub mod config; pub mod format; diff --git a/src/api_schema/registry.rs b/src/api_schema/registry.rs deleted file mode 100644 index ae4c3875..00000000 --- a/src/api_schema/registry.rs +++ /dev/null @@ -1,90 +0,0 @@ -use crate::api_schema::*; - -use failure::*; -use std::collections::HashMap; -use std::sync::Arc; - -#[derive(Default)] -pub struct Registry { - formats: HashMap<&'static str, Arc>, - options: HashMap<&'static str, Arc>, -} - -impl Registry { - - pub fn new() -> Self { - - let mut me = Self { - formats: HashMap::new(), - options: HashMap::new(), - }; - - me.initialize_formats(); - - me.initialize_options(); - - me - } - - pub fn register_format(&mut self, name: &'static str, format: ApiStringFormat) { - - if let Some(_format) = self.formats.get(name) { - panic!("standard format '{}' already registered.", name); // fixme: really panic? - } - - self.formats.insert(name, Arc::new(format)); - } - - pub fn lookup_format(&self, name: &str) -> Option> { - - if let Some(format) = self.formats.get(name) { - return Some(format.clone()); - } - None - } - - pub fn register_option>(&mut self, name: &'static str, schema: S) { - - if let Some(_schema) = self.options.get(name) { - panic!("standard option '{}' already registered.", name); // fixme: really panic? - } - - self.options.insert(name, Arc::new(schema.into())); - } - - pub fn lookup_option(&self, name: &str) -> Option> { - - if let Some(schema) = self.options.get(name) { - return Some(schema.clone()); - } - None - } - - fn initialize_formats(&mut self) { - - self.register_format("pve-node", ApiStringFormat::VerifyFn(verify_pve_node)); - - } - - fn initialize_options(&mut self) { - - self.register_option( - "pve-vmid", - IntegerSchema::new("The (unique) ID of the VM.") - .minimum(1) - ); - - self.register_option( - "pve-node", - StringSchema::new("The cluster node name.") - .format(self.lookup_format("pve-node").unwrap()) //fixme: unwrap? - ); - } - -} - -fn verify_pve_node(_value: &str) -> Result<(), Error> { - - // fixme: ?? - Ok(()) -}