TOML

RecipeCratesCategories
basic_tomlbasic-tomlcat-parser-implementations
toml_edittoml_editcat-parser-implementations
tomltomlcat-parser-implementations

toml is the primary crate.

toml

toml toml-crates.io toml-github toml-lib.rs cat-config cat-encoding cat-parser-implementations cat-parsing

toml is a native Rust encoder and decoder of TOML-formatted files and streams. Provides implementations of the standard Serialize/Deserialize traits for TOML data to facilitate deserializing and serializing Rust structures.

use serde::Deserialize;
use toml::value::Datetime;

#[derive(Deserialize, Debug)]
struct Config {
    title: String,
    database: Database,
}

#[derive(Deserialize, Debug)]
struct Database {
    server: String,
    ports: Vec<u32>,
    connection_max: u32,
    enabled: bool,
    date: Datetime,
}

fn main() {
    let toml_string = r#"
        title = "TOML Example"

        [database]
        server = "192.168.1.1"
        ports = [ 8001, 8001, 8002 ]
        connection_max = 5000
        enabled = true
        date = 1979-05-27T07:32:00Z
    "#;

    let parsed_toml: Config = toml::from_str(toml_string).unwrap();
    println!("{:#?}", parsed_toml);
}

toml_edit

toml_edit toml_edit-crates.io toml_edit-github toml_edit-lib.rs cat-config cat-encoding cat-parser-implementations cat-parsing

toml_edit is a format-preserving TOML parser.

// // COMING SOON

basic_toml

basic-toml basic-toml-crates.io basic-toml-github basic-toml-lib.rs cat-config cat-parser-implementations cat-encoding

basic_toml is a minimal TOML library with few dependencies

// // COMING SOON