ConfigNodeParser

Struct ConfigNodeParser 

Source
pub struct ConfigNodeParser<'a> { /* private fields */ }
Expand description

Parses a string into a ConfigNode struct

Implementations§

Source§

impl ConfigNodeParser<'_>

Source

pub fn parse(text: &str) -> Result<ConfigNode, ParseError>

Parses a ConfigNode string into a ConfigNode struct.

Examples found in repository?
examples/savefile.rs (line 4)
1fn main() {
2    let filename = std::env::args().nth(1).unwrap();
3    let savefile =
4        confignode::ConfigNodeParser::parse(&std::fs::read_to_string(filename).unwrap()).unwrap();
5    let game = savefile.children.get("GAME").unwrap().as_node().unwrap();
6
7    println!(
8        "Title: {}",
9        game.children.get("Title").unwrap().as_text().unwrap()
10    );
11    println!(
12        "Version: {}",
13        game.children.get("version").unwrap().as_text().unwrap()
14    );
15    println!(
16        "Version created: {}",
17        game.children
18            .get("versionCreated")
19            .unwrap()
20            .as_text()
21            .unwrap()
22    );
23}

Auto Trait Implementations§

§

impl<'a> Freeze for ConfigNodeParser<'a>

§

impl<'a> RefUnwindSafe for ConfigNodeParser<'a>

§

impl<'a> Send for ConfigNodeParser<'a>

§

impl<'a> Sync for ConfigNodeParser<'a>

§

impl<'a> Unpin for ConfigNodeParser<'a>

§

impl<'a> UnwindSafe for ConfigNodeParser<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.