sval_flatten/
lib.rs

1/*!
2Flatten nested values when streaming.
3
4This library is like the standard library's `Iterator::flatten` method, but for `sval::Stream`s.
5Given a value, it will flatten its nested values onto a parent structure. It supports flattening
6any combination of map, sequence, record, or tuple onto any other.
7
8If you're using `sval_derive`, you can use the `#[flatten]` attribute on a field.
9
10# Specifics
11
12Flattening unwraps containers and translates their values into the form needed by their parent.
13The following types can be flattened:
14
15- maps
16- sequences
17- records
18- tuples
19
20Any other type, including primitives like tags, booleans, and text will be ignored if flattened.
21
22## Maps
23
24- **maps**: keys are passed through directly, even if they're complex values like other maps.
25- **sequences**: keys are the stringified offset of sequence values.
26- **records**: keys are the label of record values.
27- **tuples**: keys are the stringified index of tuple values.
28
29## Sequences
30
31- **maps**: map keys are ignored; only map values are flattened.
32- **sequences**: sequence values are passed through directly.
33- **records**: record values are passed through directly.
34- **tuples**: tuple values are passed through directly.
35
36## Records
37
38- **maps**: map keys are stringified into labels. For complex values like other maps each nested
39value is stringified and concatenated together.
40- **sequences**: labels are the stringified offset of sequence values.
41- **records**: labels are passed through directly.
42- **tuples**: labels are the stringified index of tuple values.
43
44## Tuples
45
46- **maps**: map keys are ignored; only map values are flattened.
47- **sequences**: indexes are the offset of sequence values.
48- **records**: indexes are the offset of record values.
49- **tuples**: tuple values are passed through directly.
50*/
51
52#![no_std]
53#![deny(missing_docs)]
54
55#[cfg(any(test, feature = "alloc"))]
56extern crate alloc;
57
58mod flattener;
59mod index;
60mod label;
61mod map;
62mod record;
63mod record_tuple;
64mod seq;
65mod tuple;
66
67pub use self::{map::*, record::*, record_tuple::*, seq::*, tuple::*};