pub struct ConfigParser<T: for<'a> Deserialize<'a>> { /* private fields */ }Implementations§
Source§impl<C: for<'a> Deserialize<'a>> ConfigParser<C>
impl<C: for<'a> Deserialize<'a>> ConfigParser<C>
Sourcepub fn parse(contents: String) -> C
pub fn parse(contents: String) -> C
Parse the contents from a TOML string
§Examples
use dns_geolocation_checker::configs_parser::{ConfigParser, Config};
let test_config = r#"
[test_subnets]
us = { subnets = ["44.208.193.0/24"] }
[[domain]]
host = "google.com"
geo_routing = ["us"]
"#;
let config: Config = ConfigParser::parse(test_config.to_string());
assert_eq!(config.domain.len(), 1);
assert_eq!(config.test_subnets.len(), 1);
assert_eq!(config.domain[0].host, "google.com");
assert_eq!(config.test_subnets.get("us").unwrap().subnets[0], "44.208.193.0/24");Source§impl ConfigParser<Config>
impl ConfigParser<Config>
Sourcepub fn new_with_path<T: ToString>(path: T) -> ConfigParser<Config>
pub fn new_with_path<T: ToString>(path: T) -> ConfigParser<Config>
Create a new ConfigParser with the contents of a file
Trait Implementations§
Source§impl<T: Clone + for<'a> Deserialize<'a>> Clone for ConfigParser<T>
impl<T: Clone + for<'a> Deserialize<'a>> Clone for ConfigParser<T>
Source§fn clone(&self) -> ConfigParser<T>
fn clone(&self) -> ConfigParser<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for ConfigParser<T>where
T: Freeze,
impl<T> RefUnwindSafe for ConfigParser<T>where
T: RefUnwindSafe,
impl<T> Send for ConfigParser<T>where
T: Send,
impl<T> Sync for ConfigParser<T>where
T: Sync,
impl<T> Unpin for ConfigParser<T>where
T: Unpin,
impl<T> UnwindSafe for ConfigParser<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more