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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! # TOON Format Support for RustAPI
//!
//! This crate provides [TOON (Token-Oriented Object Notation)](https://toonformat.dev/)
//! support for the RustAPI framework. TOON is a compact, human-readable format
//! designed for passing structured data to Large Language Models (LLMs) with
//! significantly reduced token usage (typically 20-40% savings).
//!
//! ## Quick Example
//!
//! **JSON (16 tokens, 40 bytes):**
//! ```json
//! {
//! "users": [
//! { "id": 1, "name": "Alice" },
//! { "id": 2, "name": "Bob" }
//! ]
//! }
//! ```
//!
//! **TOON (13 tokens, 28 bytes) - 18.75% token savings:**
//! ```text
//! users[2]{id,name}:
//! 1,Alice
//! 2,Bob
//! ```
//!
//! ## Usage
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! rustapi-rs = { version = "0.1.300", features = ["toon"] }
//! ```
//!
//! ### Toon Extractor
//!
//! Parse TOON request bodies:
//!
//! ```rust,ignore
//! use rustapi_rs::prelude::*;
//! use rustapi_rs::toon::Toon;
//!
//! #[derive(Deserialize)]
//! struct CreateUser {
//! name: String,
//! email: String,
//! }
//!
//! async fn create_user(Toon(user): Toon<CreateUser>) -> impl IntoResponse {
//! Json(user)
//! }
//! ```
//!
//! ### Toon Response
//!
//! Return TOON formatted responses:
//!
//! ```rust,ignore
//! use rustapi_rs::prelude::*;
//! use rustapi_rs::toon::Toon;
//!
//! #[derive(Serialize)]
//! struct User {
//! id: u64,
//! name: String,
//! }
//!
//! async fn get_user() -> Toon<User> {
//! Toon(User {
//! id: 1,
//! name: "Alice".to_string(),
//! })
//! }
//! ```
//!
//! ## Content Types
//!
//! - Request: `application/toon` or `text/toon`
//! - Response: `application/toon`
pub use ToonError;
pub use Toon;
pub use ;
pub use ;
pub use ;
// Re-export toon-format types for advanced usage
pub use ;
/// TOON Content-Type header value
pub const TOON_CONTENT_TYPE: &str = "application/toon";
/// Alternative TOON Content-Type (text-based)
pub const TOON_CONTENT_TYPE_TEXT: &str = "text/toon";