-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow serializer to be used with serde-transcode (#27)
Prior to this change, the `Serializer` was private. With this change it's now possible to use this library with `serde-transcode` [1]. The handling of the map key order needed to be changed. We were using `collect_map` in order to make sure maps have the correct order. But that is only called when a `BTreeMap` or `HashMap` is used [2]. `serde-transcode` calls `serialize_map` directly. Therefore the logic to do the sorting was moved into the `SerializeMap` implementation. This way it's used by all known cases. With the `Serializer` being public and being able to being used with serde-transcode [1], we need to make sure that always valid DAG-CBOR is generated, this means that sequences are always bound ones, where the size is known beforehand. If the input is an unbound sequence, then the data is buffered until the total size was determined. Closes #26. [1]: https://crates.io/crates/serde-transcode [2]: https://github.com/serde-rs/serde/blob/00c4b0cef80557c33fbcd75fcc70dc034720b4df/serde/src/ser/impls.rs#L430-L487
- Loading branch information
Showing
3 changed files
with
149 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters