[][src]Struct confindent::ConfSection

pub struct ConfSection { /* fields omitted */ }

Methods

impl ConfSection[src]

pub fn set_value<T: Into<String>>(&mut self, value: T) -> &mut Self[src]

Set the value of this section

Example

use confindent::{Confindent, ConfParent};

let mut conf = Confindent::new();
conf.create("Section", "Placeholder");

let section = conf.child_mut("Section").unwrap();
section.set_value("Value");

assert_eq!(section.get::<String>().unwrap(), "Value");

pub fn set<T: Into<String>>(&mut self, value: T) -> &mut Self[src]

Shorthand for set_value()

pub fn get_value<T: FromStr>(&self) -> Option<T>[src]

Get the scalar value of this section

Example

use std::str::FromStr;
use confindent::{Confindent, ConfParent};

let conf_str = "Section value";
let conf = Confindent::from_str(conf_str).unwrap();
let section = conf.child("Section").unwrap();

assert_eq!(section.get_value::<String>().unwrap(), "value");

pub fn get<T: FromStr>(&self) -> Option<T>[src]

Shorthand for get_value()

pub fn get_vec<T: FromStr>(&self) -> Option<Vec<T>>[src]

Get the value in this section as a vector

Example

use std::str::FromStr;
use confindent::{Confindent, ConfParent};

let conf_str = "Section 1,2,3";
let conf = Confindent::from_str(conf_str).unwrap();

let section = conf.child("Section").unwrap();
assert_eq!(section.get_vec(), Some(vec![1, 2, 3]));

Trait Implementations

impl ConfParent for ConfSection[src]

fn get_child<T: Into<String>>(&self, key: T) -> Option<&ConfSection>[src]

Get a reference to the first child section with this name Read more

fn child<T: Into<String>>(&self, key: T) -> Option<&ConfSection>[src]

Shorthand for get_child()

fn children<T: Into<String>>(&self, key: T) -> Option<Vec<&ConfSection>>[src]

fn get_child_mut<T: Into<String>>(&mut self, key: T) -> Option<&mut ConfSection>[src]

Get a mutable reference to the first child section with this name Read more

fn child_mut<T: Into<String>>(&mut self, key: T) -> Option<&mut ConfSection>[src]

Shorthand for get_child_mut()

fn children_mut<T: Into<String>>(
    &mut self,
    key: T
) -> Option<Vec<&mut ConfSection>>
[src]

fn create<T: Into<String>>(&mut self, key: T, value: T) -> &mut Self[src]

Shorthand for create_child()

fn get_child_value<T: Into<String>, Y: FromStr>(&self, key: T) -> Option<Y>[src]

Get the value of the first child with this name Read more

fn child_value<T: Into<String>, Y: FromStr>(&self, key: T) -> Option<Y>[src]

Shorthand for get_child_value()

impl PartialEq<ConfSection> for ConfSection[src]

impl Debug for ConfSection[src]

Auto Trait Implementations

impl Send for ConfSection

impl Sync for ConfSection

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]