0Pricing
Learn Rust Coding · Lesson

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,
}

All lessons in this course

  1. Serialize and Deserialize
  2. Working with JSON
  3. Custom Serialization
  4. Other Formats
← Back to Learn Rust Coding