feat(data-contracts): add per-link codec selection#183
Open
thaodt wants to merge 2 commits into
Open
Conversation
- add `LinkCodec` with builder and registrar overrides - add feature-gated JSON and bounded postcard codecs - preserve reusable scratch encoding with owned fallback - verify MQTT extension composition and zero-allocation fast path - update feature matrix, changelogs, README and design docs
784a5c4 to
30a9e6f
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds registration-time codec selection for individual inbound and outbound links, allowing the same record type to use different wire formats across heterogeneous transports.
For e.g., one record can use bounded
postcardfor an MCU/serial route while using JSON for an MQTT/cloud route, without introducing a runtime codec registry, lock or per-message lookup.What changed
LinkCodec<T>trait.LinkCodecBuilderExt::with_link_codec(codec)for inbound and outbound link builders.LinkCodecRegistrarExt::{linked_from_with, linked_to_with}shorthand methods.link_codecs::Defaultlink_codecs::Jsonlink_codecs::Postcard<N>no_std-compatiblelinkable-postcardfeature.encode_into#180's route-local scratch buffer for boundedpostcardencoding, with owned fallback when the configured capacity is too small..linked_from()and.linked_to()APIs unchanged.Performance
Codec selection is fused into the existing typed serializer/deserializer closures during registration. It does not add a runtime registry or lookup to the message path.
The allocation benchmark covers the codec over 10000 warmed iterations:
Linkable::encode_into: 0 allocations / 0 bytesPostcard<N>::encode_into: 0 allocations / 0 bytesOversized postcard payloads retain the existing owned allocation fallback for correctness.
Related Issue
encode_into#180Checklist
make check).