Function nereon::parse_noc

source ·
pub fn parse_noc<T>(input: &str) -> Result<T, NocError>where
    T: FromValue,
Expand description

Parse a NOC string and convert into any type that implements FromValue

extern crate nereon;
use nereon::{parse_noc, Value};
use std::collections::HashMap;

let noc = r#"
    user admin {
        uid 1000 + 10
        name "John Doe"
    }"#;

let expected = Value::Table(HashMap::new())
    .insert(vec!["user", "admin", "uid"], Value::from("1010"))
    .insert(vec!["user", "admin", "name"], Value::from("John Doe"));

assert_eq!(parse_noc(noc), Ok(expected));