Replace enums with newtype + associated consts
See !134 (comment 1608495) and !123 (comment 1627935).
When binding a pipewire C-style enum
and it's variants, we should stop using a rust enum and instead use a newtype around the raw type and add a constant to it for each possible variants.
This lets us have:
- zero-cost conversion instead of needing to use
match
with one arm for each variant - Invalid variants do not cause UB, panics,
Result::Err
or similar, they simply do not correspond to any constant.
A slight downside is that the Debug
needs to be implemented manually, but that shouldn't be a big issue.
For enums that have type info, we can use !142 (merged) and future safe bindings for that.
There isn't a big change for users, as the type still looks very similar to an enum,
except always needing to add a _
wildcard when matching.
All our enums should have been #[non_exhaustive]
anyway to guard against variants added in the future, but not all are,
so that will be a slight breaking change.