Commit ca6b082
committed
libserialize: tuple-arity should be provided to
Currently `Decoder` implementations are not provided the tuple arity as
a parameter to `read_tuple`. This forces all encoder/decoder combos to
serialize the arity along with the elements. Tuple-arity is always known
statically at the decode site, because it is part of the type of the
tuple, so it could instead be provided as an argument to `read_tuple`,
as it is to `read_struct`.
The upside to this is that serialized tuples could become smaller in
encoder/decoder implementations which choose not to serialize type
(arity) information. For example, @TyOverby's
[binary-encode](https://github.com/TyOverby/binary-encode) format is
currently forced to serialize the tuple-arity along with every tuple,
despite the information being statically known at the decode site.
A downside to this change is that the tuple-arity of serialized tuples
can no longer be automatically checked during deserialization. However,
for formats which do serialize the tuple-arity, either explicitly (rbml)
or implicitly (json), this check can be added to the `read_tuple` method.
The signature of `Deserialize::read_tuple` and
`Deserialize::read_tuple_struct` are changed, and thus binary
backwards-compatibility is broken. This change does *not* force
serialization formats to change, and thus does not break decoding values
serialized prior to this change.
[breaking-change]Decoder::read_tuple
1 parent 0547a40 commit ca6b082
3 files changed
+52
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
| 561 | + | |
| 562 | + | |
562 | 563 | | |
563 | | - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
564 | 570 | | |
565 | 571 | | |
566 | 572 | | |
| |||
571 | 577 | | |
572 | 578 | | |
573 | 579 | | |
574 | | - | |
| 580 | + | |
| 581 | + | |
575 | 582 | | |
576 | 583 | | |
577 | | - | |
| 584 | + | |
578 | 585 | | |
579 | 586 | | |
580 | 587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2153 | 2153 | | |
2154 | 2154 | | |
2155 | 2155 | | |
2156 | | - | |
| 2156 | + | |
2157 | 2157 | | |
2158 | | - | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
2159 | 2164 | | |
2160 | 2165 | | |
2161 | 2166 | | |
| |||
2167 | 2172 | | |
2168 | 2173 | | |
2169 | 2174 | | |
2170 | | - | |
| 2175 | + | |
| 2176 | + | |
2171 | 2177 | | |
2172 | 2178 | | |
2173 | | - | |
| 2179 | + | |
2174 | 2180 | | |
2175 | 2181 | | |
2176 | 2182 | | |
| |||
2872 | 2878 | | |
2873 | 2879 | | |
2874 | 2880 | | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
2875 | 2901 | | |
2876 | 2902 | | |
2877 | 2903 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
| 151 | + | |
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| |||
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
468 | 475 | | |
469 | 476 | | |
470 | 477 | | |
471 | 478 | | |
472 | 479 | | |
473 | 480 | | |
474 | | - | |
| 481 | + | |
| 482 | + | |
475 | 483 | | |
476 | 484 | | |
477 | 485 | | |
478 | 486 | | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | 487 | | |
483 | 488 | | |
484 | 489 | | |
| |||
0 commit comments