Skip to content

Don't use WEnum for bitflags? #791

@ids1024

Description

@ids1024

If I recall, bitflags 1.x was different, but bitflags 2.x allows constructing a flags instance with unrecognized fields: https://docs.rs/bitflags/latest/bitflags/trait.Flags.html#tymethod.from_bits_retain.

This way it is easy to test for recognized bitflags, but still easy to see what unknown flags are set if needed. Probably better not to wrap this in WEnum? Currently if any unrecognized bitflag is set, even if there are also recognized flags, it ends up a WEnum::Unknown.

See pop-os/cosmic-protocols@b1fa8c4 for an example of code that maps WEnum to the underlying bitfield, with unrecognized fields if any retained. So this is possible to wrap currently, but may be cleaner if that's just what wayland-rs did already.

See also #764 and https://gitlab.freedesktop.org/wayland/wayland/-/issues/497 for discussion around "open" and "closed" enums (that's primarily about non-bitflag enums).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions