Other Formats
TOML, YAML, bincode.
Beyond JSON
serde's core is format-agnostic, so the same derived struct works with many formats just by swapping the format crate.
- TOML for config
- YAML for human-friendly data
- bincode for compact binary
One struct, many formats
You define the struct once. Each format crate provides its own to_string / from_str equivalents over the same Serialize / Deserialize impls.
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct Config {
name: String,
port: u16,
}