-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
feat(model)!: preserve unknown bitflag values #2089
Draft
zeylahellyer
wants to merge
6
commits into
next
Choose a base branch
from
zeyla/feat-dont-truncate-bitflags
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Commits on Jan 25, 2023
-
test(model): bitflags static assertions + serde
Add static assertions for bitflag implementations and constant values, as well as tests for the serde implementations. The serde tests include a test for the (de)serialization of a variant and that unknown bits are truncated on deserialization.
Configuration menu - View commit details
-
Copy full SHA for e0c3306 - Browse repository at this point
Copy the full SHA e0c3306View commit details -
Configuration menu - View commit details
-
Copy full SHA for a5908bd - Browse repository at this point
Copy the full SHA a5908bdView commit details -
feat(model)!: don't truncate bitflags
Bitflags received from the Discord API are truncated when deserialized. However, we have recently taken a model of accepting "unknown information", with our recent reworks of enums the shining example. Instead of failing to deserialize / ignore "unknown variants" we have taken the step to treat unknown data as "first class", in that Twilight not necessarily registering known values is okay and users can manually handle variants as they need. We should apply the same logic to bitflags and not trim unknown data. This unfortunately makes use of unsafe code for constructing bitflags in tests, because `bitflags` has an unorthodox definition of what "unsafe" is for its `Bitflags::from_bits_unchecked` function. `bitflags` treats unknown bits as being "unsafe", and so the function to construct bitflags with possibly unknown variants is unsafe. I have added notes detailing this. This is a breaking change because unknown bits are no longer truncated. Blocks on PR #2088.
Configuration menu - View commit details
-
Copy full SHA for 071b7ae - Browse repository at this point
Copy the full SHA 071b7aeView commit details
Commits on Jan 28, 2023
-
Update twilight-model/src/gateway/presence/activity_flags.rs
Co-authored-by: Erk <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 208b556 - Browse repository at this point
Copy the full SHA 208b556View commit details
Commits on Feb 5, 2023
-
Configuration menu - View commit details
-
Copy full SHA for e8c61dd - Browse repository at this point
Copy the full SHA e8c61ddView commit details -
Configuration menu - View commit details
-
Copy full SHA for a9d4c46 - Browse repository at this point
Copy the full SHA a9d4c46View commit details
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.