toml_as

Function toml_as 

Source
pub fn toml_as<T>(input: &str) -> QuartzResult
Expand description

Checks if a string is valid TOML for T.

ยงExamples

use serde::Deserialize;
use quartz_cli::validator;

#[derive(Deserialize)]
struct Config {
    title: String,
    owner: Owner,
}

#[derive(Deserialize)]
struct Owner {
    name: String,
}

let input = r#"
    title = 'TOML Example'

    [owner]
    name = 'Lisa'
"#;

let input_missing = r#"
    title = 'TOML Example'

    [owner]
"#;


assert!(validator::toml_as::<Config>(input).is_ok());
assert!(validator::toml_as::<Config>(input_missing).is_err());