codec - trait default implementation cleanup#2400
Merged
Merged
Conversation
|
Contract comparison - from 0097bb4 to 04c2769
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the codec traits’ default implementations by removing the default bodies of the *_or_handle_err methods (making them required) and instead providing defaults for the simpler top_encode/top_decode/dep_encode/dep_decode methods that delegate to the handler-based variants. It also updates one scenario value type to implement the new required method.
Changes:
- Make
TopEncode::top_encode_or_handle_err,TopDecode::top_decode_or_handle_err,NestedEncode::dep_encode_or_handle_err, andNestedDecode::dep_decode_or_handle_errrequired trait methods by removing their default implementations. - Provide/keep default implementations for
top_encode/top_decode/dep_encode/dep_decodethat call the handler-based variants withDefaultErrorHandler. - Update
BytesValueto implementTopEncode::top_encode_or_handle_errand adjust imports accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/scenario/src/scenario/model/value/bytes_value.rs | Updates BytesValue’s TopEncode impl to the new required handler-based method signature. |
| data/codec/src/single/top_en.rs | Removes default impl for TopEncode::top_encode_or_handle_err, leaving it required; keeps top_encode delegating via DefaultErrorHandler. |
| data/codec/src/single/top_de.rs | Removes default impl for TopDecode::top_decode_or_handle_err, leaving it required; keeps top_decode delegating via DefaultErrorHandler. |
| data/codec/src/single/nested_en.rs | Removes default impl for NestedEncode::dep_encode_or_handle_err, leaving it required; keeps dep_encode delegating via DefaultErrorHandler. |
| data/codec/src/single/nested_de.rs | Removes default impl for NestedDecode::dep_decode_or_handle_err, leaving it required; keeps dep_decode delegating via DefaultErrorHandler. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
This PR refactors the codec traits’ default implementations by removing the default bodies of the
*_or_handle_errmethods (making them required) and instead providing defaults for the simplertop_encode/top_decode/dep_encode/dep_decodemethods that delegate to the handler-based variants. It also updates one scenario value type to implement the new required method.Changes:
TopEncode::top_encode_or_handle_err,TopDecode::top_decode_or_handle_err,NestedEncode::dep_encode_or_handle_err, andNestedDecode::dep_decode_or_handle_errrequired trait methods by removing their default implementations.top_encode/top_decode/dep_encode/dep_decodethat call the handler-based variants withDefaultErrorHandler.BytesValueto implementTopEncode::top_encode_or_handle_errand adjust imports accordingly.