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
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).