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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! RON2 - Rusty Object Notation parser with full AST access
//!
//! This crate provides a standalone RON parser with three APIs:
//! - **AST API**: Full fidelity parsing with perfect round-trip support
//! - **Value API**: Simplified access to semantic content only
//! - **Typed Conversions**: [`FromRon`] and [`ToRon`] traits for Rust types
//!
//! No serde dependency required.
//!
//! # AST Example (full fidelity)
//!
//! ```
//! use ron2::ast::{parse_document, serialize_document};
//!
//! let source = "// config\nPoint(x: 1, y: 2)";
//! let doc = parse_document(source).unwrap();
//! let output = serialize_document(&doc).unwrap();
//! assert_eq!(source, output); // Perfect round-trip
//! ```
//!
//! # Value Example (semantic only)
//!
//! ```
//! use ron2::Value;
//!
//! let value: Value = "[1, 2, 3]".parse().unwrap();
//! assert!(matches!(value, Value::Seq(_)));
//! ```
//!
//! # Typed Conversions
//!
//! ```
//! use ron2::{FromRon, ToRon};
//!
//! let numbers: Vec<i32> = Vec::from_ron("[1, 2, 3]").unwrap();
//! assert_eq!(numbers, vec![1, 2, 3]);
//!
//! let ron_string = numbers.to_ron().unwrap();
//! ```
extern crate std;
extern crate alloc;
extern crate self as ron2;
pub
pub
pub
// Re-export derive macros when the derive feature is enabled
pub use ;
pub use crate::;
/// Internal module for benchmarks. Not part of the public API.
/// Format RON source with the given configuration.
///
/// # Example
/// ```
/// use ron2::fmt::FormatConfig;
///
/// let source = "(x:1,y:2)";
/// let formatted = ron2::format(source, &FormatConfig::default())?;
/// # Ok::<(), ron2::Error>(())
/// ```
/// Parse a RON string into a type that implements `FromRon`.
///
/// # Example
/// ```
/// use ron2::from_str;
///
/// let value: i32 = ron2::from_str("42")?;
/// assert_eq!(value, 42);
/// # Ok::<(), ron2::Error>(())
/// ```
/// Serialize a value to a RON string with default formatting.
///
/// The output includes a `#![type = "..."]` attribute using [`core::any::type_name`].
///
/// # Example
/// ```
/// use ron2::{to_string, Value};
///
/// let value = Value::Bool(true);
/// let ron = ron2::to_string(&value)?;
/// assert!(ron.contains("#![type ="));
/// assert!(ron.contains("true"));
/// # Ok::<(), ron2::Error>(())
/// ```
/// Serialize a value to a RON string with custom settings.
///
/// If [`SerializeConfig::include_type_attribute`] is true (the default), the output
/// will include a `#![type = "..."]` attribute using [`core::any::type_name`].
///
/// # Example
/// ```
/// use ron2::{to_string_with, SerializeConfig, Value};
///
/// let value = Value::Bool(true);
///
/// // With type attribute (default)
/// let ron = ron2::to_string_with(&value, &SerializeConfig::default())?;
/// assert!(ron.contains("#![type ="));
/// assert!(ron.contains("true"));
///
/// // Without type attribute
/// let ron = ron2::to_string_with(&value, &SerializeConfig::without_type_attribute())?;
/// assert_eq!(ron.trim(), "true");
/// # Ok::<(), ron2::Error>(())
/// ```