[−][src]Struct librustconfig::config::OptionReader
Reader for configuration option.
Implementations
impl OptionReader
[src]
pub fn delete(&self) -> Result<(), Errors>
[src]
Delete current config element.
Example
use librustconfig::config::Config; let cfg = Config::new(); match cfg.create_section("group") { Some(group) => { /* ... */ if !group.delete().is_ok() { /* ... */ } }, None => { /* ... */ } }
pub fn is_section(&self) -> Option<bool>
[src]
Return true if element is section group.
Example
use librustconfig::config::Config; let cfg = Config::new(); if cfg.create_section("root").is_none() { panic!("Can't create root section!"); } /* ... */ if cfg.value("root").unwrap().is_section().unwrap() { /* ... */ }
pub fn is_array(&self) -> Option<bool>
[src]
Return true if element is array.
Example
use librustconfig::config::Config; let cfg = Config::new(); let root = cfg.create_section("root"); if root.is_none() { panic!("Can't create root section!"); } /* ... */ if root.unwrap().create_array("value").is_none() { panic!("Can't create array!") } /* ... */ if cfg.value("root.value").unwrap().is_array().unwrap() { /* ... */ }
pub fn is_list(&self) -> Option<bool>
[src]
Return true if element is list.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().create_list("list").is_none() { panic!("Can't create list option!"); } /* ... */ if cfg.value("group.list").unwrap().is_list().unwrap() { // ... }
pub fn parent(&self) -> Option<OptionReader>
[src]
Return option element parent item.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create a group section!"); } /* ... */ let section = group.unwrap().create_section("section"); if section.is_none() { panic!("Can't create section!"); } /* ... */ match cfg.value("group.section").unwrap().parent() { Some(val) => { /* ... */ }, None => { /* ... */ } }
pub fn value_type(&self) -> Option<OptionType>
[src]
Return option value type.
Example
use librustconfig::config::{Config, OptionType}; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_int32("value", 1345).is_none() { panic!("Can't write int32 value to config!"); } /* ... */ match cfg.value("group.value").unwrap().value_type().unwrap() { OptionType::IntegerType => { /* ... */ }, OptionType::Int64Type => { /* ... */ }, OptionType::FloatType => { /* ... */ }, OptionType::StringType => { /* ... */ }, OptionType::BooleanType => { /* ... */ } }
pub fn value<S>(&self, path: S) -> Option<OptionReader> where
S: Into<String>,
[src]
S: Into<String>,
Read value from path.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_string("value", "test string").is_none() { panic!("Can't write string value to config!"); } /* ... */ match cfg.value("group.value") { Some(val) => { /* ... */ }, None => { /* ... */ } }
pub fn as_array(&self) -> CollectionReaderIteratorⓘNotable traits for CollectionReaderIterator
impl Iterator for CollectionReaderIterator type Item = OptionReader;
[src]
Notable traits for CollectionReaderIterator
impl Iterator for CollectionReaderIterator type Item = OptionReader;
pub fn as_list(&self) -> CollectionReaderIteratorⓘNotable traits for CollectionReaderIterator
impl Iterator for CollectionReaderIterator type Item = OptionReader;
[src]
Notable traits for CollectionReaderIterator
impl Iterator for CollectionReaderIterator type Item = OptionReader;
pub fn as_int32(&self) -> Option<i32>
[src]
Present option value as i32.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_int32("value", 131).is_none() { panic!("Can't write int32 value!"); } /* ... */ match cfg.value("group.value").unwrap().as_int32() { Some(val) => { /* ... */ }, None => { /* ... */ } }
pub fn as_int32_default(&self, def: i32) -> i32
[src]
Present option value as i32, return def if value not found.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_int32("value", 143).is_none() { panic!("Can't write int32 value!"); } /* ... */ let ival = cfg.value("group.value").unwrap().as_int32_default(0);
pub fn as_int64(&self) -> Option<i64>
[src]
Present option value as i64.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_int64("value", 120).is_none() { panic!("Can't write int64 value!"); } /* ... */ match cfg.value("group.value").unwrap().as_int64() { Some(val) => { /* ... */ }, None => { /* ... */ } }
pub fn as_int64_default(&self, def: i64) -> i64
[src]
Present option value as i64, return def if value not exists.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_int64("value", 145).is_none() { panic!("Can't write int64 value!"); } /* ... */ let value = cfg.value("group.value").unwrap().as_int64_default(0);
pub fn as_float64(&self) -> Option<f64>
[src]
Present option value as f64.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_float64("value", 1.00021).is_none() { panic!("Can't write float64 value!"); } /* ... */ match cfg.value("group.value").unwrap().as_float64() { Some(val) => { /* ... */ }, None => { /* ... */ } }
pub fn as_float64_default(&self, def: f64) -> f64
[src]
Present option value as f64, return def if value not exists.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_float64("value", 20.201).is_none() { panic!("Can't write float64 value!"); } /* ... */ let value = cfg.value("group.value").unwrap().as_float64_default(0.0);
pub fn as_bool(&self) -> Option<bool>
[src]
Present option value as bool.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_bool("value", true).is_none() { panic!("Can't write bool value!"); } /* ... */ match cfg.value("group.value").unwrap().as_bool() { Some(val) => { /* ... */ }, None => { /* ... */ } }
pub fn as_bool_default(&self, def: bool) -> bool
[src]
Present option value as bool, return def if value not exists.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_bool("value", true).is_none() { panic!("Can't write value!"); } /* ... */ let value = cfg.value("group.value").unwrap().as_bool_default(false);
pub fn as_string(&self) -> Option<String>
[src]
Present option value as string.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_string("value", "string val").is_none() { panic!("Can't write string value!"); } /* ... */ match cfg.value("group.value").unwrap().as_string() { Some(val) => { /* ... */ }, None => { /* ... */ } }
pub fn as_string_default<S>(&self, def: S) -> String where
S: Into<String>,
[src]
S: Into<String>,
Present option value as string, return def if value not exists.
Example
use librustconfig::config::Config; let cfg = Config::new(); let group = cfg.create_section("group"); if group.is_none() { panic!("Can't create group section!"); } /* ... */ if group.unwrap().write_string("value", "string val").is_none() { panic!("Can't write seting value!"); } /* ... */ let value = cfg.value("group.value").unwrap() .as_string_default("default");
Auto Trait Implementations
impl RefUnwindSafe for OptionReader
impl !Send for OptionReader
impl !Sync for OptionReader
impl Unpin for OptionReader
impl UnwindSafe for OptionReader
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,