11 releases

0.2.0 Jul 26, 2023
0.2.0-alpha.1 Jul 18, 2023
0.1.6 Jul 12, 2023
0.1.5 Feb 3, 2023
0.1.4 Jan 29, 2023

#2748 in Parser implementations

MPL-2.0 license

97KB
3K SLoC

tot-rs

A Rust implementation of Tot.

NOTE: heavily WIP

Features Completed

  • Serialization
  • Deserialization
    • Rudimentary deserialization is implemented via nom. Still no support for S-Expressions

License

MPL-2.0


lib.rs:

A Rust implementation of Tot.

Tot is a configuration language meant to be edited by hand.

Features

  • Whitespace-based format that does not require indentation
  • Simple, limited syntax
  • JSON-style objects and lists
  • Reference values (WIP)
  • File import (WIP)
  • Non-Turing complete Lisp-style expressions (WIP)
  • Compatible with:
  • JSON
  • YAML
  • TOML

Example

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct Person {
name: String,
age: u32,
}

fn main() {
let person = Person {
name: "youwin".to_string(),
age: 100
};

let output = tot::to_string(&person).unwrap();

assert_eq!("\
name \"youwin\"
age 100.0
", output);

let person = tot::from_str::<Person>(output.as_str()).unwrap();

assert_eq!(person.name, "youwin");
assert_eq!(person.age, 100);
}

Dependencies

~1.3–2.2MB
~45K SLoC