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
//! Parser and data model for `.ion` documents.
//!
//! An Ion document is represented as [`Ion`], which contains named [`Section`] values.
//! Each section can hold:
//!
//! - a [`Dictionary`] of scalar, array, or nested dictionary fields
//! - tabular [`Row`] data
//!
//! The crate provides two entry points:
//!
//! - [`Ion`] for the high-level parsed document model
//! - [`Parser`] for lower-level iteration and error inspection
//!
//! # Feature flags
//!
//! - default: section and dictionary storage use `BTreeMap`, so iteration and
//! serialization are sorted by key
//! - `dictionary-indexmap`: section and dictionary storage use `IndexMap`, so
//! iteration and serialization preserve insertion order
//!
//! # Examples
//!
//! ```rust
//! use ion::{Ion, Value};
//!
//! let mut ion: Ion = r#"
//! [APP]
//! name = "demo"
//! retries = 3
//! "#.parse()?;
//!
//! let app = ion.get_mut("APP").unwrap();
//! app.dictionary
//! .insert("enabled".into(), Value::Boolean(true));
//!
//! assert_eq!(Some("demo"), app.get("name").and_then(Value::as_str));
//! # Ok::<(), ion::IonError>(())
//! ```
//!
//! # Ordering backend
//!
//! The selected backend affects both [`Dictionary`] and [`Sections`], which means it
//! changes:
//!
//! - top-level section iteration
//! - document serialization via [`std::string::ToString::to_string`]
//! - dictionary field iteration
//! - nested dictionary serialization
pub use *;
pub use *;
/// Dictionary storage used by [`Section::dictionary`][crate::Section::dictionary].
///
/// The concrete map type depends on the `dictionary-indexmap` feature:
///
/// - default: `BTreeMap<Box<str>, Value>`
/// - `dictionary-indexmap`: `IndexMap<Box<str>, Value>`
pub type Dictionary = IndexMap;
/// Dictionary storage used by [`Section::dictionary`][crate::Section::dictionary].
///
/// In default builds this is `BTreeMap<Box<str>, Value>`.
pub type Dictionary = BTreeMap;
/// Top-level section storage used by [`Ion`].
///
/// The concrete map type depends on the `dictionary-indexmap` feature:
///
/// - default: `BTreeMap<Box<str>, Section>`
/// - `dictionary-indexmap`: `IndexMap<Box<str>, Section>`
pub type Sections = IndexMap;
/// Top-level section storage used by [`Ion`].
///
/// In default builds this is `BTreeMap<Box<str>, Section>`.
pub type Sections = BTreeMap;
/// A single table row stored inside a [`Section`].
pub type Row = ;