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
//! Scalar metadata attached to a stored vector.
//!
//! [`Metadata`] is an immutable, ordered map from string keys to scalar
//! [`Value`]s. It carries the structured attributes a query filters on (an
//! author, a timestamp encoded as an integer, a published flag). Construct it
//! once from a map or an iterator; it has no in-place mutators.
use ;
/// A scalar metadata value.
///
/// A closed set of JSON-like scalars. It deliberately has no nesting — metadata
/// is a flat map of scalars, which keeps filtering simple and predictable. It
/// holds an `f64`, so it is [`PartialEq`] but not [`Eq`].
///
/// # Examples
///
/// ```
/// use iqdb_types::Value;
///
/// let title = Value::String("intro".to_string());
/// let year = Value::Int(2026);
/// let score = Value::Float(0.5);
/// let published = Value::Bool(true);
/// let missing = Value::Null;
///
/// assert_eq!(year, Value::Int(2026));
/// assert_ne!(title, missing);
/// let _ = (score, published);
/// ```
/// An immutable, ordered map of metadata keys to [`Value`]s.
///
/// Build one from a [`BTreeMap`] with [`From`], or collect it from an iterator
/// of `(String, Value)` pairs. Read it with [`get`](Metadata::get),
/// [`len`](Metadata::len), [`is_empty`](Metadata::is_empty), and
/// [`iter`](Metadata::iter). There are no setters — to change metadata, build a
/// new value.
///
/// # Examples
///
/// ```
/// use iqdb_types::{Metadata, Value};
///
/// let meta: Metadata = [
/// ("title".to_string(), Value::String("intro".to_string())),
/// ("year".to_string(), Value::Int(2026)),
/// ]
/// .into_iter()
/// .collect();
///
/// assert_eq!(meta.len(), 2);
/// assert_eq!(meta.get("year"), Some(&Value::Int(2026)));
/// assert_eq!(meta.get("missing"), None);
/// ```
;