Expand description
§File - parse file types with pretty diagnostics.
Well structured parsing error reports with the language specific error types. thanks to the thiserror and miette crate.
Let say you want to deserialize to a Config struct.
let res = serde_yaml::from_str::<Value>(&string);
match res {
Ok(res) => {
// do things
},
Err(e) => {
let err = YamlError::new(e, &string);
return Err(err.into());
}
};
let res = toml::from_str::<Value>(&string);
match res {
Ok(res) => {
// do things
},
Err(e) => {
let err = TomlError::new(e, &string);
return Err(err.into());
}
};
Structs§
- File
Type Iter - An iterator over the variants of FileType
- HclError
- A Hcl report type with hint, colors and code span. For better configuration file debugging
- Json
Error - A JSON report type with hint, colors and code span. For better configuration file debugging
- Toml
Error - A TOML report type with hint, colors and code span. For better configuration file debugging
- Yaml
Error - A YAML report type with hint, colors and code span. For better configuration file debugging
Enums§
Functions§
- is_
absolute - Determine whether the provided path struct is an absolute path
- is_
filename - Determine whether the provided path struct is a filename
- is_
relative - Determine whether the provided path struct is a relative pathReturn false if the path is a filename like “my_file” and isn’t prefixed with “./”.Return true if the file path is “./my_file”.This is a tweaked strict version of the standard Path::is_relative() method.
- read_
last_ line - Read the last line of the file at the provide path and return it as a string.