Commit Graph

6 Commits

Author SHA1 Message Date
Jacek Sieka 0ef1a14564
size computations (#40)
* size computations

* add `Protobuf.computeSize` to compute the encoded size of an object
* readd `VarIntLengthPrefix` support
* don't expose loosely typed `writeValue` for objects that might
conflict with other serializers
* ensure all `writeValue` and `writeField` are tagged with a `codec`
type
* avoid writing all-defaults proto3 object fields

* Fix sizer for reference

* Create TableObject in a template

---------

Co-authored-by: Ludovic Chenut <ludovic@status.im>
2023-03-01 12:19:11 +01:00
Jacek Sieka e8169c0ff4
Cleanup / rewrite (#36)
This is a cleanup / rewrite of the implementation increasing
interoperability with other implementations and fixing several bugs /
security issues

* remove special handling of nim:isms (`ptr`, `ref`, `Option`, `HashSet`
etc) (#4)
* these deviate from "standard" protobuf behavior making the library
less interoperable with other langagues
* supporting "custom" types should be done as part of an extension
framework instead (that can support any type / collection instead of a
few hand-picked special cases)
* don't allow encoding scalars in the core encoder (#31)
  * `codec` can be used to encode simple scalars
* switch to `libp2p/minprotobuf`-like encoding base, fixing several
bugs, crashes and inaccuracies (#30, #32, #33)
* move parsing support to separate import
  * the parser is a heavy dependency
* allow unknown fields
* unknown fields should be given an extension point allowing the user
to detect / handle them - standard behavior for protobuf is to ignore
them
* work around several faststreams bugs (#22)
* remove machine-word-dependent length prefix options (#35)
* actually, remove varint length prefix too for now (due to
faststreams bugs)
* update version
* verify that strings are valid utf-8 on parse
* fix warnings
* truncate values like C++ version
* allow unpacked fields in proto3
* protobuf2/3 -> proto2/3
* update docs

There's lots left to do here in terms of tests and features:

* Almost all tests are roundtrip tests - meaning they check that writing
and reading have the same bugs (vs outputting conforming protobuf)
* There are very few invalid-input tests
* There's a beginning of an extension mechanism, but it needs more work
* It's generally inefficient to copy data to a protobuf object and then
write it to a stream - the stream writers should probably be made more
general to handle this case better (either via callbacks or some other
"builder-like" mechanism - projects currently using `minprotobuf` will
likely see a performance regression using this library
* `required` semantics are still off - a set/not-set flag is needed for
every field in proto2
* possibly, when annotated with proto2, we should simply rewrite all
members to become `PBOption` (as well as rename the field)
2023-01-10 09:07:24 +01:00
Zahary Karadjov d79b5c8849
Handle API changes in the serialization library 2021-03-25 01:01:43 +02:00
Luke Parker 3a47c7c518 Add support for Protobuf 3 spec files. 2020-08-03 12:15:47 +03:00
zah b5fd5611ae
Initial version of the library completed (#2)
Initial version of the library integrated with nim-serialization

Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
2020-07-14 15:51:44 +03:00
Joey 08c6db775f
[WIP] Protobuf implementation (#1)
* Initial implementation by @jyapayne
2020-04-10 17:41:47 +03:00