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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
//! Runtime — public API for loading and using `.mdix` files.
//!
//! ## Loading
//!
//! ```rust,ignore
//! use dixscript::Runtime::{DixLoader, DixLoadOptions};
//!
//! let loader = DixLoader::new();
//! let data = loader.load_text("config.mdix", &DixLoadOptions::new())?;
//! ```
//!
//! ## Reading
//!
//! ```rust,ignore
//! let port: i32 = data.get("server.port")?;
//! let host: String = data.get("server.host")?;
//! ```
//!
//! ## Struct deserialization
//!
//! ```rust,ignore
//! use dixscript::Runtime::{DixDeserialize, dix_get};
//!
//! impl DixDeserialize for ServerConfig {
//! fn from_dix(data: &DixData, prefix: &str) -> Result<Self, String> {
//! Ok(ServerConfig {
//! host: dix_get(data, prefix, "host")?,
//! port: dix_get(data, prefix, "port")?,
//! })
//! }
//! }
//!
//! let config: ServerConfig = data.deserialize_at("server")?;
//! ```
//!
//! ## Struct serialization
//!
//! ```rust,ignore
//! use dixscript::Runtime::{DixSerialize, DataBuilder, dix_set_str, dix_set_int};
//!
//! impl DixSerialize for ServerConfig {
//! fn to_dix(&self, d: &mut DataBuilder, prefix: &str) -> Result<(), String> {
//! dix_set_str(d, prefix, "host", &self.host);
//! dix_set_int(d, prefix, "port", self.port);
//! Ok(())
//! }
//! }
//!
//! let data = DixDataBuilder::new()
//! .serialize_at("server", &config)
//! .build()?;
//! ```
//!
//! ## Schema validation
//!
//! ```rust,ignore
//! use dixscript::Runtime::SchemaBuilder;
//!
//! let report = data.validate_schema(
//! SchemaBuilder::new()
//! .require_string("server.host")
//! .require_int("server.port"),
//! );
//!
//! assert!(report.is_valid());
//! ```
//!
//! ## Querying
//!
//! LINQ-style chaining over an array field's elements. `query(path)`
//! covers a plain `Array` literal or a `GroupArray`'s items alike;
//! `query_many(pattern)` matches across sibling paths that share shape
//! via a wildcarded segment (see `query` module docs for the difference).
//!
//! ```rust,ignore
//! use dixscript::Runtime::DixValue;
//!
//! let filtered = data.query("tasks")
//! .expect("tasks should be an array")
//! .where_(|v| v.field("priority").and_then(DixValue::as_int) == Some(3))
//! .order_by_desc(|v| v.field("priority").and_then(DixValue::as_int).unwrap_or(0));
//!
//! let names: Vec<Option<&str>> = filtered.select(|v| v.field("name").and_then(DixValue::as_string));
//! ```
//!
//! ## Merging
//!
//! ```rust,ignore
//! use dixscript::Runtime::merge::{MdixMerger, MdixMergeInput, MdixMergeStrategy};
//!
//! // AST-level merge with weight-based conflict resolution.
//! let result = MdixMerger::new()
//! .with_strategy(MdixMergeStrategy::WeightedPriority)
//! .merge_all(vec![
//! MdixMergeInput::new(ast_base).with_weight(1.0).with_label("base"),
//! MdixMergeInput::new(ast_patch).with_weight(0.8).with_label("patch"),
//! MdixMergeInput::new(ast_local).with_weight(0.5).with_label("local"),
//! ]);
//!
//! // File-path convenience — loads, compiles, merges, returns DixData.
//! let data = MdixMerger::new().merge_files(&["base.mdix", "overrides.mdix"])?;
//!
//! // Explicit per-file weights.
//! let data = MdixMerger::new().merge_files_weighted(&[
//! ("base.mdix", 1.0),
//! ("overrides.mdix", 0.8),
//! ("local.mdix", 0.5),
//! ])?;
//! ```
//!
//! ## Hot reload
//!
//! ```rust,ignore
//! use dixscript::Runtime::HotReloadWatcher;
//!
//! let mut watcher = HotReloadWatcher::new("config.mdix");
//!
//! // in your game loop / tick / update:
//! match watcher.check_and_reload() {
//! Ok(Some(data)) => apply_new_config(data), // file changed, reloaded
//! Ok(None) => {} // unchanged, nothing to do
//! Err(e) => eprintln!("hot reload failed: {e}"),
//! }
//! ```
// ── Core types ────────────────────────────────────────────────────────────────
pub use homogenize_data_section;
pub use DixCompactor;
pub use DixConverter;
pub use DixData;
pub use DixValue;
pub use DixFormatOptions;
pub use DixLoadOptions;
pub use DixLoader;
// ── Builder ───────────────────────────────────────────────────────────────────
pub use ;
// ── Encryption / key management ───────────────────────────────────────────────
pub use ;
// ── Deserialization ───────────────────────────────────────────────────────────
pub use ;
// Re-export `dix_value` function under a non-colliding name.
pub use dix_value as dix_raw_value;
// ── Serialization ─────────────────────────────────────────────────────────────
pub use ;
// ── Schema validation ─────────────────────────────────────────────────────────
pub use ;
// ── Querying ──────────────────────────────────────────────────────────────────
pub use DixQuery;
// ── Merging ───────────────────────────────────────────────────────────────────
pub use ;
// ── Hot reload ────────────────────────────────────────────────────────────────
// Poll-based watcher for Rust consumers only. Each language binding implements
// its own native FS-event mechanism (inotify, FSEvents, ReadDirectoryChangesW).
// See `hot_reload` module docs for the intended game-loop usage pattern.
pub use HotReloadWatcher;