-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR changes the way custom serializers work. If you register serialization routines for type `T` where `T` is an interface type, the serialization routines will now be used for values of type `T` _and every type that implements `T`_. The serialization layer will no longer recursively scan values of type `T` when a custom serializer has been registered for `T` or for an interface that `T` implements. The assumption is that the custom serializers will not serialize the underlying memory regions in a way that makes preserving pointers outside `T` that alias those regions possible, hence scanning is not necessary. These two changes combined allow users to avoid scanning and serializing complex types that the serialization layer cannot currently handle. One example from https://github.com/protocolbuffers/protobuf-go is the `proto.Message` interface and the generated structs that implement it, which use all sorts of unsafe hacks (e.g. to prevent copying and comparisons, and to embed information used for Go and protobuf reflection). The protobuf library provides a native way to serialize any sort of `proto.Message` (via `anypb`). Users can now register custom serialization routines for `proto.Message` and don't have to manually register routines for every type that implements `proto.Message`.
- Loading branch information
Showing
3 changed files
with
52 additions
and
13 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