You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rust runtime cannot serialize or deserialize 'bitfields' (flags, bitflags).
To Reproduce
schema:
enum Flags {
None = 0;
A = 1;
B = 2;
C = 4;
D = 8;
}
You cannot serialize a combination of these 'flags' (Flags::A | Flags::B in other languages) (simply not a thing in Rust due to enums), you cannot cast a u32 into a Flags (non-primative)
Deserializing calls the enums try_into which expects distinct values:
impl::core::convert::TryFrom<u32>forFlags{typeError = ::bebop::DeserializeError;fntry_from(value:u32) -> ::bebop::DeResult<Self>{match value {0 => Ok(Flags::None),1 => Ok(Flags::A),2 => Ok(Flags::B),4 => Ok(Flags::C),8 => Ok(Flags::D),
d => Err(::bebop::DeserializeError::InvalidEnumDiscriminator(d)),}}}
Expected behavior
Be able to serialize + deserialize 'bitfields' in some way.
Imo distinct enum values should either be enforced or expected for 'regular enums', 'bitfields' can then be denoted with an 'attribute' (Similar to C# [Flags]) to allow bitfields which the code generators can then use.
Bebop info:
2.3.0
Rust
Desktop (please complete the following information):
OS: Windows
Version 10 19043.1237
The text was updated successfully, but these errors were encountered:
Describe the bug
Rust runtime cannot serialize or deserialize 'bitfields' (flags, bitflags).
To Reproduce
schema:
Flags::A | Flags::B
in other languages) (simply not a thing in Rust due to enums), you cannot cast a u32 into a Flags (non-primative)try_into
which expects distinct values:Expected behavior
Be able to serialize + deserialize 'bitfields' in some way.
Imo distinct enum values should either be enforced or expected for 'regular enums', 'bitfields' can then be denoted with an 'attribute' (Similar to C#
[Flags]
) to allow bitfields which the code generators can then use.Bebop info:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: