Skip to main content

Crate toon_core

Crate toon_core 

Source
Expand description

§temporal-cortex-toon

Pure-Rust encoder and decoder for TOON (Token-Oriented Object Notation) v3.0.

TOON is a compact, human-readable serialization format designed to reduce LLM token consumption when processing structured data. It achieves this through key folding (indentation instead of braces), tabular compression for uniform arrays, and context-dependent quoting that eliminates unnecessary quote tokens.

§Quick start

use toon_core::{encode, decode};

// JSON → TOON
let json = r#"{"name":"Alice","scores":[95,87,92]}"#;
let toon = encode(json).unwrap();
assert_eq!(toon, "name: Alice\nscores[3]: 95,87,92");

// TOON → JSON (roundtrip)
let back = decode(&toon).unwrap();
assert_eq!(back, json);

§Modules

  • encoder — JSON string → TOON string
  • decoder — TOON string → JSON string
  • filter — Semantic filtering + TOON encode (filter_and_encode, CalendarFilter)
  • error — Error types for parse/encode failures
  • typesToonValue AST (reserved for future direct-manipulation use)

Re-exports§

pub use decoder::decode;
pub use encoder::encode;
pub use error::ToonError;
pub use filter::filter_and_encode;
pub use filter::filter_fields;
pub use filter::CalendarFilter;

Modules§

decoder
TOON v3.0 Decoder — converts TOON back into JSON.
encoder
TOON v3.0 Encoder — converts JSON into Token-Oriented Object Notation.
error
Error types for TOON encoding and decoding operations.
filter
Semantic filtering – strip unnecessary fields before TOON encoding.
types
TOON value types for direct AST manipulation (reserved for future use).