Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better enum deserialization #199

Merged
merged 4 commits into from
Jul 19, 2023
Merged

Conversation

rooooooooob
Copy link
Collaborator

Together these fix #194 and #145

NoVariantMatchedWithCauses deser error variant

Addresses #194

This helps avoid any type/group choice from eating any errors on
variants as instead of receiving a NoVariantMatched you will receive one
with errors as to why each variant failed.

This drastically helps debugging and also works for nested choices as
well.

Avoid try-all on enums with non-overlapping CBOR

Fixes #145

When all variants have non-overlapping first CBOR type we can avoid
brute-force trying all possible variants for type/group choices and
instead branch on raw.cbor_type() to only try the variant that makes
sense.

Addresses #194

This helps avoid any type/group choice from eating any errors on
variants as instead of receiving a NoVariantMatched you will receive one
with errors as to why each variant failed.

This drastically helps debugging and also works for nested choices as
well.
Fixes #145

When all variants have non-overlapping first CBOR type we can avoid
brute-force trying all possible variants for type/group choices and
instead branch on raw.cbor_type() to only try the variant that makes
sense.
@rooooooooob rooooooooob merged commit 4eb8f4a into master Jul 19, 2023
@rooooooooob rooooooooob deleted the better-enum-deserialization branch July 19, 2023 20:54
rooooooooob added a commit that referenced this pull request Apr 9, 2024
Caused when the inlining would made cddl-codegen think that the types
were not overlapping since it was looking at the stored type not the
actual starting cbor type (e.g. when it was a fixed value).

This would cause a problem as the type matching introduced in #199
but only in very specific cases with basic groups starting with fixed
values.
rooooooooob added a commit that referenced this pull request May 18, 2024
* Fix issue with overlapping inlined basic embedded enums

Caused when the inlining would made cddl-codegen think that the types
were not overlapping since it was looking at the stored type not the
actual starting cbor type (e.g. when it was a fixed value).

This would cause a problem as the type matching introduced in #199
but only in very specific cases with basic groups starting with fixed
values.

* Fix #229

Possibly needs more tests covering combinations with non-basic groups
mixed with basic, tagged basic groups and optional fields (should work
though)

* Fix #230 #231 #232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants