You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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`.
0 commit comments