I try to build a yaml checker. It just opens files, tries to parse it and returns an error if, for example, there are keys defined multiple times.
I did it with serde_yaml, but if I have more than one yaml defined in a file, I get "deserializing from YAML containing more than one document is not supported".
Is there a way to solve that?
here's my code so far.
use walkdir::WalkDir;
use serde_yaml;
fn main() {
for entry in WalkDir::new(".").into_iter().filter_map(|e| e.ok()) {
if entry.path().display().to_string().ends_with(".yml") || entry.path().display().to_string().ends_with(".yaml") {
println!("{}", entry.path().display());
let f = match std::fs::File::open(entry.path()) {
Err(e) => {
println!("{}", e);
continue;
}
Ok(f) => f,
};
let _ :serde_yaml::Value = match serde_yaml::from_reader(f) {
Err(e) => {
println!("{}", e);
continue;
}
Ok(s) => s,
};
}
}
}