Expand description
§serde_styx
Serde support for the Styx configuration language. Deserialize Styx documents using serde’s derive macros.
§Sponsors
Thanks to all individual sponsors:
…along with corporate sponsors:
…without whom this work could not exist.
§License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option. Serde support for the Styx configuration language.
This crate provides Styx serialization and deserialization using serde.
§Deserialization Example
use serde::Deserialize;
use serde_styx::from_str;
#[derive(Deserialize, Debug, PartialEq)]
struct Config {
name: String,
port: u16,
}
let styx = "name myapp\nport 8080";
let config: Config = from_str(styx).unwrap();
assert_eq!(config.name, "myapp");
assert_eq!(config.port, 8080);§Serialization Example
use serde::Serialize;
use serde_styx::to_string;
#[derive(Serialize, Debug)]
struct Config {
name: String,
port: u16,
}
let config = Config { name: "myapp".into(), port: 8080 };
let styx = to_string(&config).unwrap();
assert!(styx.contains("name myapp"));
assert!(styx.contains("port 8080"));Structs§
- Deserializer
- Styx deserializer implementing serde::Deserializer.
- Error
- Error type for serde_styx operations.
- Format
Options - Options for Styx serialization.
- Serializer
- Styx serializer implementing serde::Serializer.
Functions§
- from_
str - Deserialize a value from a Styx string.
- to_
string - Serialize a value to a Styx string.
- to_
string_ compact - Serialize a value to a compact Styx string (single line, comma separators).
- to_
string_ with_ options - Serialize a value to a Styx string with custom options.
Type Aliases§
- Result
- Result type for serde_styx operations.