Expand description

§Serde Gura
Gura is a file format for configuration files. Gura is as readable as YAML and simple as TOML. Its syntax is clear and powerful, yet familiar for YAML/TOML users.
This crate provides Serde implementation for serialize/deserialize Gura format:
use serde_derive::{Deserialize, Serialize};
use serde_gura::Result;
#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct Database {
ip: String,
port: Vec<u16>,
connection_max: u32,
enabled: bool,
}
fn main() -> Result<()> {
// You have some type.
let database = Database {
ip: "127.0.0.1".to_string(),
port: vec![80, 8080],
connection_max: 1200,
enabled: true,
};
// Serialize it to a Gura string
let database_str = serde_gura::to_string(&database)?;
let expected = r#"
ip: "127.0.0.1"
port: [80, 8080]
connection_max: 1200
enabled: true
"#;
assert_eq!(database_str, expected.trim());
// Deserialize it back to a Rust type
let deserialized_database: Database = serde_gura::from_str(&database_str)?;
assert_eq!(database, deserialized_database);
Ok(())
}Structs§
Enums§
- Error
- Types of errors that may occur during serialization/deserialization
Functions§
- from_
str - from_
value - Interpret a
gura::GuraTypeas an instance of typeT. - to_
string - Serialize the given data structure as a String of Gura.
- to_
value - Convert a
Tintogura::GuraTypewhich is an enum that can represent any valid Gura data.