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

feat(model)!: preserve unknown bitflag values #2089

Draft
wants to merge 6 commits into
base: next
Choose a base branch
from

Commits on Jan 25, 2023

  1. 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.
    zeylahellyer committed Jan 25, 2023
    Configuration menu
    Copy the full SHA
    e0c3306 View commit details
    Browse the repository at this point in the history
  2. fix

    zeylahellyer committed Jan 25, 2023
    Configuration menu
    Copy the full SHA
    a5908bd View commit details
    Browse the repository at this point in the history
  3. 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.
    zeylahellyer committed Jan 25, 2023
    Configuration menu
    Copy the full SHA
    071b7ae View commit details
    Browse the repository at this point in the history

Commits on Jan 28, 2023

  1. Configuration menu
    Copy the full SHA
    208b556 View commit details
    Browse the repository at this point in the history

Commits on Feb 5, 2023

  1. Configuration menu
    Copy the full SHA
    e8c61dd View commit details
    Browse the repository at this point in the history
  2. uh

    7596ff committed Feb 5, 2023
    Configuration menu
    Copy the full SHA
    a9d4c46 View commit details
    Browse the repository at this point in the history