[−][src]Struct librustconfig::config::Config
Configuration file.
Implementations
impl Config
[src]
pub fn new() -> Config
[src]
Constructor. Create new Config struct.
Example
use librustconfig::config::Config; let cfg = Config::new();
pub fn load_from_file(&mut self, file_name: &Path) -> Result<(), Errors>
[src]
Load config file from file and parse it.
Example
use librustconfig::config::Config; use std::path::Path; let mut cfg = Config::new(); if cfg.load_from_file(Path::new("test.cfg")).is_ok() { // ... }
pub fn load_from_string<S>(&mut self, config_string: S) -> Result<(), Errors> where
S: Into<String>,
[src]
S: Into<String>,
Parse configuration from string.
Example
use librustconfig::config::Config; let mut cfg = Config::new(); if cfg.load_from_string("root { value = 1 }").is_ok() { // ... }
pub fn save_to_file(&mut self, file_name: &Path) -> Result<(), Errors>
[src]
Save current config to file.
Example
use librustconfig::config::Config; use std::path::Path; use std::fs; let mut cfg = Config::new(); if cfg.save_to_file(Path::new("test.cfg")).is_ok() { // ... } fs::remove_file(Path::new("test.cfg"));
pub fn include_dir(&mut self, path: &Path)
[src]
Set current config include directory.
Example
use librustconfig::config::Config; use std::path::Path; let mut cfg = Config::new(); cfg.include_dir(Path::new("/config"));
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(); match cfg.value("root.value") { Some(val) => { /* ... */ }, None => { /* ... */ } }
pub fn create_section<S>(&self, path: S) -> Option<OptionWriter> where
S: Into<String>,
[src]
S: Into<String>,
Create new group section.
Example
use librustconfig::config::Config; let cfg = Config::new(); match cfg.create_section("root") { Some(s) => { /* ... */ }, None => { /* ... */ } }
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Config
impl !Send for Config
impl !Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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>,