Crate serde_styx

Crate serde_styx 

Source
Expand description

§serde_styx

crates.io documentation MIT/Apache-2.0 licensed

Serde support for the Styx configuration language. Deserialize Styx documents using serde’s derive macros.

§Sponsors

Thanks to all individual sponsors:

GitHub Sponsors Patreon

…along with corporate sponsors:

AWS Zed Depot

…without whom this work could not exist.

§License

Licensed under either of:

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.
FormatOptions
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.