Expand description
LSD (Less Syntax Data) configuration/data transfer format.
It is made out three variants - values (strings/words), lists ([]
) and
levels ({}
). File may not contain only a value (it will be considered a
level).
use lsdata::LSD;
use lsdata::LSDGetExt;
use lsdata::key;
use std::io::Cursor;
#[derive(Debug)]
enum CustomError {
LanguageNameIsNotAValue,
CouldNotFindLanguageName,
}
use CustomError::*;
let file = Cursor::new("languages.rust.name Rust");
let lsd = LSD::parse(file).unwrap();
let lang_key = "rust";
let lang_name = lsd
.value(
|| LanguageNameIsNotAValue,
key!["languages" lang_key "name"],
)
.unwrap()
.ok_or_else(|| CouldNotFindLanguageName)
.unwrap();
assert_eq!(lang_name, "Rust");
Visit LSD repository for a full LSD description.
Macros§
- key
- Macro for creating key paths.
Enums§
- KeyPath
Part - Key path part - key (string) or index (number).
- LSD
- Main LSD enum.
- Parse
Error - All errors thrown by the LSD parser.
Traits§
- LSDGet
Ext - Extensions for LSD types that can pull deeply nested values.