unibuf 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +170 -200
  3. data/CODE_OF_CONDUCT.md +132 -0
  4. data/README.adoc +306 -114
  5. data/docs/CAPNPROTO.adoc +436 -0
  6. data/docs/FLATBUFFERS.adoc +430 -0
  7. data/docs/PROTOBUF.adoc +515 -0
  8. data/docs/TXTPROTO.adoc +369 -0
  9. data/lib/unibuf/commands/convert.rb +60 -2
  10. data/lib/unibuf/commands/schema.rb +68 -11
  11. data/lib/unibuf/errors.rb +23 -26
  12. data/lib/unibuf/models/capnproto/enum_definition.rb +72 -0
  13. data/lib/unibuf/models/capnproto/field_definition.rb +81 -0
  14. data/lib/unibuf/models/capnproto/interface_definition.rb +70 -0
  15. data/lib/unibuf/models/capnproto/method_definition.rb +81 -0
  16. data/lib/unibuf/models/capnproto/schema.rb +84 -0
  17. data/lib/unibuf/models/capnproto/struct_definition.rb +96 -0
  18. data/lib/unibuf/models/capnproto/union_definition.rb +62 -0
  19. data/lib/unibuf/models/flatbuffers/enum_definition.rb +69 -0
  20. data/lib/unibuf/models/flatbuffers/field_definition.rb +88 -0
  21. data/lib/unibuf/models/flatbuffers/schema.rb +102 -0
  22. data/lib/unibuf/models/flatbuffers/struct_definition.rb +70 -0
  23. data/lib/unibuf/models/flatbuffers/table_definition.rb +73 -0
  24. data/lib/unibuf/models/flatbuffers/union_definition.rb +60 -0
  25. data/lib/unibuf/models/message.rb +10 -0
  26. data/lib/unibuf/parsers/capnproto/binary_parser.rb +267 -0
  27. data/lib/unibuf/parsers/capnproto/grammar.rb +272 -0
  28. data/lib/unibuf/parsers/capnproto/list_reader.rb +208 -0
  29. data/lib/unibuf/parsers/capnproto/pointer_decoder.rb +163 -0
  30. data/lib/unibuf/parsers/capnproto/processor.rb +348 -0
  31. data/lib/unibuf/parsers/capnproto/segment_reader.rb +131 -0
  32. data/lib/unibuf/parsers/capnproto/struct_reader.rb +199 -0
  33. data/lib/unibuf/parsers/flatbuffers/binary_parser.rb +325 -0
  34. data/lib/unibuf/parsers/flatbuffers/grammar.rb +235 -0
  35. data/lib/unibuf/parsers/flatbuffers/processor.rb +299 -0
  36. data/lib/unibuf/serializers/binary_serializer.rb +218 -0
  37. data/lib/unibuf/serializers/capnproto/binary_serializer.rb +402 -0
  38. data/lib/unibuf/serializers/capnproto/list_writer.rb +199 -0
  39. data/lib/unibuf/serializers/capnproto/pointer_encoder.rb +118 -0
  40. data/lib/unibuf/serializers/capnproto/segment_builder.rb +124 -0
  41. data/lib/unibuf/serializers/capnproto/struct_writer.rb +139 -0
  42. data/lib/unibuf/serializers/flatbuffers/binary_serializer.rb +167 -0
  43. data/lib/unibuf/version.rb +1 -1
  44. data/lib/unibuf.rb +27 -0
  45. metadata +36 -1
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/README.adoc CHANGED
@@ -1,4 +1,4 @@
1
- = Unibuf: Universal Protocol Buffer & FlatBuffer Parser
1
+ = Unibuf: Universal Buffer Format Parser
2
2
 
3
3
  image:https://img.shields.io/gem/v/unibuf.svg[Gem Version,link=https://rubygems.org/gems/unibuf]
4
4
  image:https://img.shields.io/github/license/lutaml/unibuf.svg[License,link=https://github.com/lutaml/unibuf/blob/main/LICENSE]
@@ -6,21 +6,43 @@ image:https://github.com/lutaml/unibuf/actions/workflows/rake.yml/badge.svg[Buil
6
6
 
7
7
  == Purpose
8
8
 
9
- Unibuf is a pure Ruby gem for parsing and manipulating Protocol Buffers in both text and binary formats with schema-driven validation.
9
+ Unibuf is a pure Ruby gem for parsing and manipulating multiple serialization
10
+ formats including Protocol Buffers, FlatBuffers, and Cap'n Proto.
10
11
 
11
- It provides a fully object-oriented, specification-compliant parser with rich domain models, comprehensive schema validation, wire format decoding, and complete round-trip serialization support.
12
+ It provides fully object-oriented, specification-compliant parsers with rich
13
+ domain models, comprehensive schema validation, binary format encoding/decoding,
14
+ and complete round-trip serialization support.
12
15
 
13
16
  Key features:
14
17
 
15
- * Parse Protocol Buffers text format (`.txtpb`, `.textproto`)
16
- * Parse Protocol Buffers binary format (`.binpb`) with schema
17
- * Parse Proto3 schemas (`.proto`) for validation
18
- * Schema-driven validation and deserialization
19
- * Wire format decoding (varint, zigzag, all wire types)
20
- * Round-trip serialization with 100% accuracy
21
- * Rich domain models with 45+ behavioral classes
22
- * Complete CLI toolkit for text and binary formats
23
- * Specification-compliant implementation
18
+ * Protocol Buffers
19
+ ** Parse text format (`.txtpb`, `.textproto`)
20
+ ** Parse binary format (`.binpb`) with schema
21
+ ** Serialize to binary format (`.binpb`)
22
+ ** Parse Proto3 schemas (`.proto`)
23
+ ** Wire format encoding/decoding (varint, zigzag, all wire types)
24
+
25
+ * FlatBuffers
26
+ ** Parse schemas (`.fbs`)
27
+ ** Parse binary format (`.fb`)
28
+ ** Serialize to binary format (`.fb`)
29
+
30
+ * Cap'n Proto
31
+ ** Parse schemas (`.capnp`)
32
+ ** Parse binary format with segment management
33
+ ** Serialize to binary format with pointer encoding
34
+ ** Support for structs, enums, interfaces (RPC)
35
+ ** Generic types (List<T>)
36
+ ** Unions and annotations
37
+
38
+ * Serialization and validation
39
+ ** Complete round-trip serialization for all formats
40
+ ** Schema-driven validation and deserialization
41
+
42
+ * Developer usage
43
+ ** Rich domain models with 60+ behavioral classes
44
+ ** Complete CLI toolkit for all formats
45
+ ** Pure Ruby - no C/C++ dependencies
24
46
 
25
47
  == Installation
26
48
 
@@ -47,6 +69,9 @@ gem install unibuf
47
69
 
48
70
  == Features
49
71
 
72
+ * <<protocol-buffers,Protocol Buffers support>>
73
+ * <<flatbuffers,FlatBuffers support>>
74
+ * <<capnproto,Cap'n Proto support>>
50
75
  * <<schema-required-design,Schema-required design>>
51
76
  * <<parsing-textproto,Parsing text format>>
52
77
  * <<parsing-binary,Parsing binary format>>
@@ -56,32 +81,182 @@ gem install unibuf
56
81
  * <<rich-domain-models,Rich domain models>>
57
82
  * <<cli-tools,Command-line tools>>
58
83
 
59
- [[schema-required-design]]
60
- == Schema-required design
84
+ [[protocol-buffers]]
85
+ == Protocol Buffers
61
86
 
62
87
  === General
63
88
 
64
- Unibuf follows Protocol Buffers' schema-driven architecture. The schema (`.proto` file) defines the message structure and is REQUIRED for binary parsing and recommended for text parsing.
89
+ Full support for Protocol Buffers (protobuf) including text format parsing,
90
+ binary format parsing/serialization, and Proto3 schema parsing.
65
91
 
66
- This design ensures type safety and enables proper deserialization of binary formats.
92
+ See link:docs/PROTOBUF.adoc[PROTOBUF.adoc] for detailed documentation.
67
93
 
68
- === Why schema is required
69
94
 
70
- The schema defines:
71
- - Message types and their fields
72
- - Field types and numbers
73
- - Field wire types for binary encoding
74
- - Repeated and optional fields
75
- - Nested message structures
95
+ === Parsing Protocol Buffers text format
96
+
97
+ [source,ruby]
98
+ ----
99
+ require "unibuf"
100
+
101
+ # Load schema (recommended for validation)
102
+ schema = Unibuf.parse_schema("schema.proto") # <1>
103
+
104
+ # Parse text format file
105
+ message = Unibuf.parse_textproto_file("data.txtpb") # <2>
106
+
107
+ # Validate against schema
108
+ validator = Unibuf::Validators::SchemaValidator.new(schema) # <3>
109
+ validator.validate!(message, "MessageType") # <4>
110
+ ----
111
+ <1> Load Proto3 schema from .proto file
112
+ <2> Parse Protocol Buffers text format
113
+ <3> Create validator with schema
114
+ <4> Validate message against schema
115
+
116
+ === Parsing Protocol Buffers binary format
117
+
118
+ [source,ruby]
119
+ ----
120
+ require "unibuf"
121
+
122
+ # 1. Load schema (REQUIRED for binary)
123
+ schema = Unibuf.parse_schema("schema.proto") # <1>
124
+
125
+ # 2. Parse binary Protocol Buffer file
126
+ message = Unibuf.parse_binary_file("data.binpb", schema: schema) # <2>
127
+
128
+ # 3. Access fields normally
129
+ puts message.find_field("name").value # <3>
130
+ ----
131
+ <1> Schema is mandatory for binary parsing
132
+ <2> Parse binary file with schema
133
+ <3> Access fields like text format
134
+
135
+ [[flatbuffers]]
136
+ == FlatBuffers
137
+
138
+ === General
139
+
140
+ Complete support for Google FlatBuffers including schema parsing (`.fbs` files)
141
+ and binary format parsing/serialization.
142
+
143
+ See link:docs/FLATBUFFERS.adoc[FLATBUFFERS.adoc] for detailed documentation.
144
+
145
+ === Parsing FlatBuffers schema
146
+
147
+ [source,ruby]
148
+ ----
149
+ require "unibuf"
150
+
151
+ # Parse FlatBuffers schema
152
+ schema = Unibuf.parse_flatbuffers_schema("schema.fbs") # <1>
153
+
154
+ # Access schema structure
155
+ table = schema.find_table("Monster") # <2>
156
+ table.fields.each { |f| puts "#{f.name}: #{f.type}" } # <3>
157
+ ----
158
+ <1> Parse `.fbs` schema file
159
+ <2> Find table definition
160
+ <3> Iterate through fields
161
+
162
+ === Parsing FlatBuffers binary format
163
+
164
+ [source,ruby]
165
+ ----
166
+ # Parse binary FlatBuffer
167
+ data = Unibuf.parse_flatbuffers_binary(binary_data, schema: schema) # <1>
168
+
169
+ # Access data
170
+ puts data["name"] # <2>
171
+ puts data["hp"] # <3>
172
+ ----
173
+ <1> Parse binary with schema
174
+ <2> Access string field
175
+ <3> Access numeric field
176
+
177
+
178
+ [[capnproto]]
179
+ == Cap'n Proto
180
+
181
+ === General
182
+
183
+ Complete support for Cap'n Proto including schema parsing (`.capnp` files) and
184
+ binary format parsing/serialization with segment management and pointer
185
+ encoding.
186
+
187
+ See link:docs/CAPNPROTO.adoc[CAPNPROTO.adoc] for detailed documentation.
188
+
189
+ === Parsing Cap'n Proto schema
190
+
191
+ [source,ruby]
192
+ ----
193
+ require "unibuf"
194
+
195
+ # Parse Cap'n Proto schema
196
+ schema = Unibuf.parse_capnproto_schema("addressbook.capnp") # <1>
197
+
198
+ # Access schema structure
199
+ person = schema.find_struct("Person") # <2>
200
+ person.fields.each { |f| puts "#{f.name} @#{f.ordinal} :#{f.type}" } # <3>
201
+
202
+ # Access interfaces (RPC)
203
+ calc = schema.find_interface("Calculator") # <4>
204
+ calc.methods.each { |m| puts "#{m.name} @#{m.ordinal}" } # <5>
205
+ ----
206
+ <1> Parse `.capnp` schema file
207
+ <2> Find struct definition
208
+ <3> Iterate through fields with ordinals
209
+ <4> Find interface definition (RPC)
210
+ <5> List RPC methods
211
+
212
+ === Parsing Cap'n Proto binary format
213
+
214
+ [source,ruby]
215
+ ----
216
+ # Parse binary Cap'n Proto data
217
+ parser = Unibuf::Parsers::Capnproto::BinaryParser.new(schema) # <1>
218
+ data = parser.parse(binary_data, root_type: "Person") # <2>
219
+
220
+ # Access data
221
+ puts data[:name] # <3>
222
+ puts data[:email] # <4>
223
+ ----
224
+ <1> Create parser with schema
225
+ <2> Parse binary with root type
226
+ <3> Access text field
227
+ <4> Access another field
228
+
229
+ === Serializing Cap'n Proto binary format
230
+
231
+ [source,ruby]
232
+ ----
233
+ # Serialize to binary
234
+ serializer = Unibuf::Serializers::Capnproto::BinarySerializer.new(schema) # <1>
235
+ binary = serializer.serialize(
236
+ { id: 1, name: "Alice", email: "alice@example.com" }, # <2>
237
+ root_type: "Person" # <3>
238
+ )
239
+
240
+ # Write to file
241
+ File.binwrite("output.capnp.bin", binary) # <4>
242
+ ----
243
+ <1> Create serializer with schema
244
+ <2> Provide data as hash
245
+ <3> Specify root struct type
246
+ <4> Write binary output
247
+
76
248
 
77
- Binary Protocol Buffers cannot be parsed without a schema because the binary format only stores field numbers, not field names or types.
78
249
 
79
250
  [[parsing-textproto]]
80
- == Parsing Protocol Buffers text format
251
+ == Protocol Buffers text format
81
252
 
82
253
  === General
83
254
 
84
- Parse human-readable Protocol Buffer text format files following the https://protobuf.dev/reference/protobuf/textformat-spec/[official specification].
255
+ Parse human-readable Protocol Buffer text format files following the
256
+ https://protobuf.dev/reference/protobuf/textformat-spec/[official specification].
257
+
258
+ See link:docs/TXTPROTO.adoc[TXTPROTO.adoc] for detailed documentation.
259
+
85
260
 
86
261
  === Parsing text format
87
262
 
@@ -109,9 +284,11 @@ validator.validate!(message, "MessageType") # <4>
109
284
 
110
285
  === General
111
286
 
112
- Parse binary Protocol Buffer data using wire format decoding with schema-driven deserialization.
287
+ Parse binary Protocol Buffer data using wire format decoding with schema-driven
288
+ deserialization.
113
289
 
114
- The schema is REQUIRED for binary parsing because binary format only stores field numbers, not names or types.
290
+ The schema is REQUIRED for binary parsing because binary format only stores
291
+ field numbers, not names or types.
115
292
 
116
293
  === Parsing binary format
117
294
 
@@ -160,46 +337,14 @@ Variable-length data: string, bytes, embedded messages, packed repeated fields
160
337
  32-bit (Type 5)::
161
338
  Fixed 4-byte values: fixed32, sfixed32, float
162
339
 
163
- [[schema-validation]]
164
- == Schema-based validation
165
-
166
- === General
167
-
168
- Validate Protocol Buffer messages (text or binary) against their Proto3 schemas.
169
-
170
- === Validating with schema
171
-
172
- [source,ruby]
173
- ----
174
- # Load schema
175
- schema = Unibuf.parse_schema("schema.proto") # <1>
176
-
177
- # Parse message (text or binary)
178
- message = Unibuf.parse_binary_file("data.binpb", schema: schema) # <2>
179
-
180
- # Validate
181
- validator = Unibuf::Validators::SchemaValidator.new(schema) # <3>
182
- errors = validator.validate(message, "MessageType") # <4>
183
-
184
- if errors.empty?
185
- puts "✓ Valid!" # <5>
186
- else
187
- errors.each { |e| puts " - #{e}" } # <6>
188
- end
189
- ----
190
- <1> Parse the Proto3 schema
191
- <2> Parse binary Protocol Buffer
192
- <3> Create validator with schema
193
- <4> Validate message
194
- <5> Validation passed
195
- <6> Show errors if any
196
340
 
197
341
  [[wire-format]]
198
- == Wire format support
342
+ == Protocol Buffers wire format
199
343
 
200
344
  === General
201
345
 
202
- Unibuf implements complete Protocol Buffers wire format decoding according to the official specification.
346
+ Unibuf implements complete Protocol Buffers wire format decoding according to
347
+ the official specification.
203
348
 
204
349
  === Wire format features
205
350
 
@@ -236,12 +381,78 @@ message.field_names # => ["name", "id", "enabled"]
236
381
  message.find_field("id").value # => Properly decoded integer
237
382
  ----
238
383
 
384
+
385
+
386
+ [[schema-required-design]]
387
+ == Schema-required design
388
+
389
+ === General
390
+
391
+ Unibuf follows Protocol Buffers' and FlatBuffers' schema-driven architecture.
392
+ The schema (`.proto` or `.fbs` file) defines the message structure and is
393
+ REQUIRED for binary parsing and serialization.
394
+
395
+ This design ensures type safety and enables proper deserialization of binary
396
+ formats.
397
+
398
+ === Why schema is required
399
+
400
+ The schema defines:
401
+
402
+ * Message/struct types and their fields
403
+ * Field types, numbers, and ordinals
404
+ * Field wire types for binary encoding
405
+ * Repeated and optional fields
406
+ * Nested message/struct structures
407
+
408
+ Binary Protocol Buffers, FlatBuffers, and Cap'n Proto cannot be parsed without a
409
+ schema because the binary formats only store field identifiers, not field names
410
+ or complete type information.
411
+
412
+
413
+ [[schema-validation]]
414
+ == Schema-based validation
415
+
416
+ === General
417
+
418
+ Validate Protocol Buffer messages (text or binary) against their Proto3 schemas.
419
+
420
+ === Validating with schema
421
+
422
+ [source,ruby]
423
+ ----
424
+ # Load schema
425
+ schema = Unibuf.parse_schema("schema.proto") # <1>
426
+
427
+ # Parse message (text or binary)
428
+ message = Unibuf.parse_binary_file("data.binpb", schema: schema) # <2>
429
+
430
+ # Validate
431
+ validator = Unibuf::Validators::SchemaValidator.new(schema) # <3>
432
+ errors = validator.validate(message, "MessageType") # <4>
433
+
434
+ if errors.empty?
435
+ puts "✓ Valid!" # <5>
436
+ else
437
+ errors.each { |e| puts " - #{e}" } # <6>
438
+ end
439
+ ----
440
+ <1> Parse the Proto3 schema
441
+ <2> Parse binary Protocol Buffer
442
+ <3> Create validator with schema
443
+ <4> Validate message
444
+ <5> Validation passed
445
+ <6> Show errors if any
446
+
447
+
448
+
239
449
  [[round-trip-serialization]]
240
450
  == Round-trip serialization
241
451
 
242
452
  === General
243
453
 
244
- Unibuf supports complete round-trip serialization for text format, allowing you to parse, modify, and serialize back while preserving semantic equivalence.
454
+ Unibuf supports complete round-trip serialization for text format, allowing you
455
+ to parse, modify, and serialize back while preserving semantic equivalence.
245
456
 
246
457
  === Serializing to textproto format
247
458
 
@@ -272,7 +483,7 @@ puts message == reparsed # => true <5>
272
483
 
273
484
  Unibuf provides rich domain models with comprehensive behavior.
274
485
 
275
- Over 45 classes provide extensive functionality following object-oriented principles.
486
+ Over 60 classes provide extensive functionality following object-oriented principles.
276
487
 
277
488
  === Message model
278
489
 
@@ -386,8 +597,30 @@ Unibuf
386
597
  │ │ ├── Grammar Proto3 grammar
387
598
  │ │ ├── Processor Schema builder
388
599
  │ │ └── Parser Schema API
389
- └── Binary Binary format parser
390
- └── WireFormatParser Wire format decoder
600
+ ├── Binary Binary Protocol Buffers
601
+ └── WireFormatParser Wire format decoder
602
+ │ ├── Flatbuffers FlatBuffers parser
603
+ │ │ ├── Grammar FBS grammar
604
+ │ │ ├── Processor Schema builder
605
+ │ │ └── BinaryParser Binary format
606
+ │ └── Capnproto Cap'n Proto parser
607
+ │ ├── Grammar Cap'n Proto grammar
608
+ │ ├── Processor Schema builder
609
+ │ ├── SegmentReader Segment management
610
+ │ ├── PointerDecoder Pointer decoding
611
+ │ ├── StructReader Struct reading
612
+ │ ├── ListReader List reading
613
+ │ └── BinaryParser Binary format
614
+ ├── Serializers
615
+ │ ├── BinarySerializer Protocol Buffers binary
616
+ │ ├── Flatbuffers FlatBuffers binary
617
+ │ │ └── BinarySerializer
618
+ │ └── Capnproto Cap'n Proto binary
619
+ │ ├── SegmentBuilder Segment allocation
620
+ │ ├── PointerEncoder Pointer encoding
621
+ │ ├── StructWriter Struct writing
622
+ │ ├── ListWriter List writing
623
+ │ └── BinarySerializer
391
624
  ├── Models
392
625
  │ ├── Message Protocol Buffer message
393
626
  │ ├── Field Message field
@@ -395,6 +628,8 @@ Unibuf
395
628
  │ ├── MessageDefinition Message type definition
396
629
  │ ├── FieldDefinition Field specification
397
630
  │ ├── EnumDefinition Enum type definition
631
+ │ ├── Flatbuffers FlatBuffers models (6 classes)
632
+ │ ├── Capnproto Cap'n Proto models (7 classes)
398
633
  │ └── Values Value type hierarchy (5 classes)
399
634
  ├── Validators
400
635
  │ ├── TypeValidator Type and range validation
@@ -403,41 +638,6 @@ Unibuf
403
638
  └── Commands parse, validate, convert, schema
404
639
  ----
405
640
 
406
- === Design principles
407
-
408
- Object-Oriented::
409
- 45+ rich classes with extensive behavior.
410
- No anemic data structures.
411
-
412
- MECE::
413
- Mutually exclusive, collectively exhaustive classifications.
414
- Complete type hierarchies.
415
-
416
- Separation of Concerns::
417
- Clean layer separation: Grammar, Processor, Models, Validators, CLI.
418
-
419
- Open/Closed::
420
- Extensible for new formats without modifying core.
421
-
422
- Schema-Driven::
423
- Schema-required for binary, recommended for text.
424
- Proper Protocol Buffer architecture.
425
-
426
- == Real-World Validation
427
-
428
- Curated test suite with diverse Protocol Buffer features:
429
-
430
- .Test fixtures
431
- [example]
432
- ====
433
- - robotoflex: Multi-axis variable font
434
- - mavenpro: Static font
435
- - opensans: Popular font variants
436
- - playfair: Optical size axis
437
- - wavefont: Custom axes
438
-
439
- Validation: 100% parse success, 100% round-trip accuracy
440
- ====
441
641
 
442
642
  == Development
443
643
 
@@ -457,23 +657,15 @@ bundle exec rubocop -A
457
657
 
458
658
  == Roadmap
459
659
 
460
- === Current Version (v1.0.0)
461
-
462
- - ✅ Text format parsing
463
- - ✅ Binary format parsing (wire format decoder)
464
- - ✅ Proto3 schema parsing
465
- - ✅ Schema-based validation
466
- - ✅ Complete CLI toolkit
467
- - ✅ 277 comprehensive tests
468
-
469
660
  === Future work
470
661
 
471
- ==== FlatBuffers
662
+ ==== Additional features
472
663
 
473
- - FlatBuffers schema parsing
474
- - FlatBuffers binary parsing
664
+ - gRPC support (Protocol Buffers RPC)
665
+ - Cap'n Proto RPC implementation
475
666
  - Performance optimizations
476
667
  - Additional Protocol Buffer features
668
+ - Schema evolution tools
477
669
 
478
670
  == Contributing
479
671