Additional rkyv support by trying to derive the Archived type as Self where possible #762
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current support for
rkyv
inchrono
isn't very useful, becauserkyv
generates a new type on each invocation ofderive(Archive)
. This new type won't have any traits or methods implemented on it exceptDeserialize
, so it can't be easily used in a zero-copy manner.However, most
chrono
types areCopy
, which means thatrkyv
can be configured to useSelf
forderive(Archive)
instead of generating a new one. One downside is that this doesn't work ifrkyv
is configured to use a specific endianness.Code can be generic to which specific type
rkyv
generated for theArchive
impl through the use ofrkyv::Archived<_>
, sochrono
can opportunistically generate a different type without breaking code that wants to support different endianness, which is also what rkyv currently does for primitives: https://docs.rs/rkyv/0.7.39/src/rkyv/impls/core/primitive.rs.html#107