Expand description
§serde-structprop
A serde serializer and deserializer for the structprop configuration file format — a simple, human-readable format for structured data.
§Format overview
# comment
key = value
key = "value with spaces"
key = 42
key = true
# nested object
section {
nested_key = value
}
# array of scalars
list = { a b c }§Quick start
use serde::{Deserialize, Serialize};
use serde_structprop::{from_str, to_string};
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Config {
hostname: String,
port: u16,
}
// Deserialize
let input = "hostname = localhost\nport = 8080\n";
let cfg: Config = from_str(input).unwrap();
assert_eq!(cfg.hostname, "localhost");
assert_eq!(cfg.port, 8080);
// Serialize
let out = to_string(&cfg).unwrap();
assert!(out.contains("hostname = localhost"));
assert!(out.contains("port = 8080"));§Module layout
Re-exports§
pub use de::from_str;pub use de::from_value;pub use error::Error;pub use error::Result;pub use parse::parse;pub use parse::Value;pub use ser::to_string;
Modules§
- de
- Serde deserializer for structprop documents.
Serde
Deserializerfor the structprop format. - error
- Error type shared by the serializer and deserializer.
Error type used throughout
serde-structprop. - lexer
- Lexer (tokenizer) that converts raw structprop text into tokens. Lexer (tokenizer) for the structprop format.
- parse
- Parser that converts a token stream into a
parse::Valuetree. Parser for the structprop format. - ser
- Serde serializer for structprop documents.
Serde
Serializerfor the structprop format.