1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Token-Oriented Object Notation (TOON) - Rust implementation
//!
//! TOON is a compact, human-readable format designed to reduce token usage
//! in Large Language Model (LLM) prompts by 30–60% compared to JSON.
//!
//! # Examples
//!
//! ## Standalone API
//!
//! ```rust
//! use toon_rust::{encode, decode};
//! use serde_json::json;
//!
//! let data = json!({
//! "items": [
//! {"sku": "A1", "qty": 2, "price": 9.99},
//! {"sku": "B2", "qty": 1, "price": 14.5}
//! ]
//! });
//!
//! let toon = encode(&data, None).unwrap();
//! let decoded = decode(&toon, None).unwrap();
//! ```
//!
//! ## Streaming API
//!
//! For large datasets, use the streaming API to avoid loading everything into memory:
//!
//! ```rust,no_run
//! use std::fs::File;
//! use std::io::BufWriter;
//! use serde_json::json;
//! use toon_rust::{encode_stream, decode_stream};
//!
//! // Encode to file
//! let data = json!({"name": "Alice", "age": 30});
//! let file = File::create("output.toon").unwrap();
//! let mut writer = BufWriter::new(file);
//! encode_stream(&data, &mut writer, None).unwrap();
//!
//! // Decode from file
//! let file = File::open("output.toon").unwrap();
//! let decoded = decode_stream(file, None).unwrap();
//! ```
//!
//! ## Serde API (requires `serde` feature)
//!
//! ```rust,no_run
//! use serde::{Serialize, Deserialize};
//! use toon_rust::{to_string, from_str};
//!
//! #[derive(Serialize, Deserialize)]
//! struct Product {
//! sku: String,
//! qty: u32,
//! price: f64,
//! }
//!
//! let products = vec![
//! Product { sku: "A1".to_string(), qty: 2, price: 9.99 },
//! Product { sku: "B2".to_string(), qty: 1, price: 14.5 },
//! ];
//!
//! let toon = to_string(&products).unwrap();
//! let decoded: Vec<Product> = from_str(&toon).unwrap();
//! ```
pub use ;
pub use ;
pub use Error;
pub use ;
pub use ;