6 releases

Uses new Rust 2024

new 0.1.5 Nov 7, 2025
0.1.4 Oct 29, 2025
0.1.2 Aug 22, 2025
0.1.0 Jul 12, 2025

#1 in #punctuation

Download history 153/week @ 2025-07-11 37/week @ 2025-07-18 19/week @ 2025-07-25 158/week @ 2025-08-01 79/week @ 2025-08-08 66/week @ 2025-08-15 149/week @ 2025-08-22 32/week @ 2025-08-29 29/week @ 2025-09-05 57/week @ 2025-09-12 39/week @ 2025-09-19 30/week @ 2025-09-26 22/week @ 2025-10-03 4/week @ 2025-10-10 139/week @ 2025-10-17 87/week @ 2025-10-24

263 downloads per month
Used in 5 crates (via swamp-yini)

MIT license

26KB
654 lines

yini

A tiny, opinionated text data format and parser (think simple INI with a few extras). It keeps punctuation to a minimum while still supporting nested structs, arrays, tuples, and enum-like variants.

Quick Start

Add the crate to your Cargo.toml, then feed the parser an input &str:

use yini::Parser;

let mut parser = Parser::new(r#"
name "Alice"
age 30
"#);
let root = parser.parse();
assert_eq!(root.get("age").and_then(|v| v.as_int()), Some(30));

The parser reports non-fatal issues through parser.errors(), allowing you to inspect partially parsed documents.

Format Basics

  • Every line defines a key value pair—whether at the top level or inside a struct. Keys are identifiers or quoted strings.

  • Values can be: strings (quoted), integers, floats, booleans (true/false), structs { ... }, arrays [ ... ], or tuples ( ... ).

  • Structs use braces and contain their own key value lines; these nested entries follow the exact same rules as top-level pairs.

  • Arrays use separate elements. Elements may be single values, structs, or tuples.

  • Tuples are groups of two-or-more values written in parentheses , e.g. (a b c).

  • Variants start with : (e.g. :state) and may carry an immediate payload in parentheses, braces, or brackets—: must touch the payload (:state(1 2) or :state{key value}).

  • Comments start with # and run to end-of-line.

Examples:

key 42
name "Alice"
coords [1, 2, 3]
pairs [ (k1 "v1") ("k2", "v2") ]   # array of 2-tuples
triple (a, b, c)                     # 3-tuple as a value for `triple`
screen :fullscreen( 1024 768 )
mode :windowed # without payload

person {
    name "Alice"
    age 30
    tags [developer, rust]
}

Benchmark

The repository contains a small micro-benchmark in examples/benchmark.rs. Run it in release mode for meaningful numbers:

cargo run --release --example benchmark

The benchmark parses a synthetic data set repeatedly to give an aggregate throughput figure.

Rationale:

  • The format aims for readability and minimal punctuation.

  • keys must start on a newline, to be easy to read.

Dependencies

~21KB