Trait yaml_rust_davvid::yaml::YamlScalarParser
source · pub trait YamlScalarParser {
// Required method
fn parse_scalar(&self, tag: &TokenType, value: &str) -> Option<Yaml>;
}
Expand description
A YamlScalarParser
is a parser that change the parsing of a yaml scalar value
like a tag
§Examples
use yaml_rust::yaml;
use yaml_rust::scanner;
struct HelloTagParser;
impl yaml::YamlScalarParser for HelloTagParser {
fn parse_scalar(&self, tag: &scanner::TokenType, value: &str) -> Option<yaml::Yaml> {
if let scanner::TokenType::Tag(ref handle, ref suffix) = *tag {
if *handle == "!" && *suffix == "hello" {
return Some(yaml::Yaml::String("Hello ".to_string() + value))
}
}
None
}
}