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
//! # Unicode Separated Values (USV) ™
//!
//! Unicode Separated Values (USV) ™ is a data format that uses Unicode characters for markup.
//!
//! This USV crate implements the USV specification: <https://github.com/sixarm/usv>.
//!
//! This USV crate and aims to help developers build new USV applications, tools, and workflows.
//!
//! ## USV characters
//!
//! Separators:
//!
//! * File Separator (FS) is U+001C or U+241C ␜
//!
//! * Group Separator (GS) is U+001D or U+241D ␝
//!
//! * Record Separator (RS) is U+001E or U+241E ␞
//!
//! * Unit Separator (US) is U+001F or U+241F ␟
//!
//! Modifiers:
//!
//! * Escape (ESC) is U+001B or U+241B ␛
//!
//! * End of Transmission (EOT) is U+0004 or U+2404 ␄
//!
//! ## Units
//!
//! ```rust
//! use usv::*;
//! let str = "a␟b␟";
//! let units: Units = str.units().collect();
//! assert_eq!(units, ["a", "b"]);
//! assert_eq!(units.into_usv_string(), str);
//!
//! ```
//!
//! ## Records
//!
//! ```rust
//! use usv::*;
//! let str = "a␟b␟␞c␟d␟␞";
//! let records: Records = str.records().collect();
//! assert_eq!(records, [["a", "b"],["c", "d"]]);
//! assert_eq!(records.into_usv_string(), str);
//! ```
//!
//! ## Groups
//!
//! ```rust
//! use usv::*;
//! let str = "a␟b␟␞c␟d␟␞␝e␟f␟␞g␟h␟␞␝";
//! let groups: Groups = str.groups().collect();
//! assert_eq!(groups, [[["a", "b"],["c", "d"]],[["e", "f"],["g", "h"]]]);
//! assert_eq!(groups.into_usv_string(), str);
//! ```
//!
//! ## Files
//!
//! ```rust
//! use usv::*;
//! let str = "a␟b␟␞c␟d␟␞␝e␟f␟␞g␟h␟␞␝␜i␟j␟␞k␟l␟␞␝m␟n␟␞o␟p␟␞␝␜";
//! let files: Files = str.files().collect();
//! assert_eq!(files, [[[["a", "b"],["c", "d"]],[["e", "f"],["g", "h"]]],[[["i", "j"],["k", "l"]],[["m", "n"],["o", "p"]]]]);
//! assert_eq!(files.into_usv_string(), str);
//! ```
//!
//! ## Architecture
//!
//! The architecture of this crate looks like this, in order of importance:
//!
//! * `lib.rs`: the library entry point.
//!
//! * `constants.rs`: constants for USV characters.
//!
//! * `token.rs`: the USV Token enumerator for returning parser results.
//!
//! * `iter/`: iterators for units, records, groups, files, tokens.
//!
//! * `style/`: style sets of characters for symbols, controls, braces.
//!
//! * `layout/`: layout formats for lines, visual displays, and editors.
//!
//! * `from/`: convert from one thing into another thing.
//!
//! * `into_usv_string`: trait and impl to convert from data into a usv string.
//!
//! * `examples.rs`: data strings suitable for demos and tests.
//!
//! * `str_ext.rs`: string extension traits for parsing USV.
//!
//! * `svec.rs`: a simple macro for creating string vectors.
//!
//! * `bench/`: benchmark tests; this is work in progress.
//!
//! * `tests/`: integration tests placeholder; not needed yet.
//!
//! ## Token
//!
//! A token is the underlying USV enumeration for parsing a string to output:
//!
//! ```no_run
//! pub enum Token {
//! Unit(String),
//! UnitSeparator,
//! RecordSeparator,
//! GroupSeparator,
//! FileSeparator,
//! EndOfTransmission,
//! }
//! ```
//!
//! ## Type aliases
//!
//! * Token = described above
//!
//! * Tokens = Vec<Token>
//!
//! * Unit = String
//!
//! * Units = Vec<Unit>
//!
//! * Record = Units
//!
//! * Records = Vec<Record>
//!
//! * Group = Records
//!
//! * Groups = Vec<Records>
//!
//! * File = Groups
//!
//! * Files = Vec<File>
//!
//! ## Legal protection for standardization
//!
//! The USV project aims to become a free open source IETF standard and IANA standard, much like the standards for CSV and TDF.
//!
//! Until the standardization happens, the terms "Unicode Separated Values" and "USV" are both trademarks of this project. This repository is copyright 2022-2024. The trademarks and copyrights are by Joel Parker Henderson, me, an individual, not a company.
//!
//! When IETF and IANA approve the submissions as a standard, then the trademarks and copyright will go to a free libre open source software advocacy foundation. We welcome advice about how to do this well.
//!
//! ## Conclusion
//!
//! USV is helping us with data projects. We hope USV may help you too.
//!
//! We welcome constructive feedback about USV, as well as git issues, pull requests, and standardization help.
// Constants for each USV character as a control character and symbol character.
pub use *;
// Token enum that holds content data or a special character value.
pub use Token;
// Examples for demos and tests.
pub use *;
// Type aliases for USV naming
pub type Tokens = Vec;
pub type Unit = String;
pub type Units = Vec;
pub type Record = Units;
pub type Records = Vec;
pub type Group = Records;
pub type Groups = Vec;
pub type File = Groups;
pub type Files = Vec;
// Iterator for token, unit, record, group, file.
// &str extensions such as iterators for units, records, groups, files.
pub use StrExt;
// Convert such as from vectors of strings to a USV string.
pub use *;
// String extensions such as from functions for conversions.
pub use *;
// Style provides rendering configuration for separators etc.
pub use Style;
// Layout provides style decorations for rendering liners.
pub use *;
// svec! macro that makes string vectors.
pub use *;