Commit cd002f6
authored
Add textproto (text format) encoding and decoding (#6)
The protobuf text format is the human-readable debug representation —
useful
for config files, golden-file tests, and logging. This implements the
full
format with 883/883 conformance suite coverage.
Runtime (feature = "text", zero deps, no_std + alloc)
- buffa::text module: TextFormat trait, TextEncoder, TextDecoder,
encode_to_string / decode_from_str conveniences
- Tokenizer handles all grammar quirks: both { } and < > delimiters,
adjacent string concatenation, #-comments, [pkg.ext] bracket names,
hex/octal/float number forms, nan/inf, C++-style bool literals
- Decoder returns Cow<'a, str> for strings (zero-copy when no escapes)
- \u escapes are BMP-only (surrogates rejected per spec; use \U for
non-BMP)
- Heuristic nested-message detection for unknown LD fields (speculative
wire-format parse, C++ text_format.cc:2926 / Java TextFormat.java:87)
TypeRegistry — unified type/extension registry
- JsonRegistry → TypeRegistry with feature-split entry types:
JsonAnyEntry,
TextAnyEntry, JsonExtEntry, TextExtEntry each under their own cfg gate
- json and text features are now independently enableable (previously
json
pulled in text because unified entry structs referenced TextEncoder)
- Codegen emits one register_types() per file covering whichever formats
were enabled — lines inside are emitted per generate_json/generate_text,
no #[cfg] in generated code
- Any expansion ([type.googleapis.com/...] { ... }) and extension
brackets
([pkg.ext] { ... }) both consult TypeRegistry
- Deprecated aliases: JsonRegistry, set_json_registry, AnyTypeEntry,
ExtensionRegistryEntry
Codegen
- generate_text(bool) config option and buffa-build builder method
- impl TextFormat emission in impl_text.rs, skip-gated for Any
(hand-written
in buffa-types) and MessageSet
- Group-field naming: GroupLikeType { ... } (message type name) and
groupliketype { ... } (lowercase/field name) both accepted on parse;
type name emitted on encode
- Separate __FOO_JSON_ANY / __FOO_TEXT_ANY consts per codegen flag
- emit_register_fn config (default true) — gen_wkt_types sets false
since
seven include!'d WKT files would collide on register_types
Conformance
- Text suite: 0 → 883 passing (was entirely skipped), zero expected
failures
- Binary+JSON unchanged at 5549/5529/2797
- known_failures_text.txt added (empty — passes the full suite)
- print_unknown_fields request field parsed and threaded to TextEncoder
Docs & examples
- guide.md "Text format (textproto)" section
- README/CHANGELOG/CONTRIBUTING/migration-from-protobuf.md updated
- addressbook example gains a dump command (encode_to_string_pretty)
- Taskfile: build-examples, example-addressbook, example-envelope,
example-logging tasks (USER_WORKING_DIR for file-path preservation)1 parent 52e40a3 commit cd002f6
File tree
58 files changed
+8443
-1071
lines changed- buffa-build/src
- buffa-codegen/src
- bin
- tests
- buffa-test
- src/tests
- buffa-types
- src
- generated
- buffa
- src
- text
- conformance
- src
- docs
- examples
- addressbook
- src
- envelope
- src
- logging
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
58 files changed
+8443
-1071
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
47 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
48 | 64 | | |
49 | 65 | | |
50 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
460 | 505 | | |
461 | 506 | | |
462 | 507 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
117 | 128 | | |
118 | 129 | | |
119 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
| 93 | + | |
| 94 | + | |
82 | 95 | | |
83 | 96 | | |
84 | 97 | | |
| |||
0 commit comments