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
Due to how the variants of MessageKind and ADSBMessageKind are built, they are pretty easy to create, but from a user of the API's perspective, due to the individual variants being Enums, they cannot be typed and assigned to new variables.
I'd suggest to convert messageKinds into individual types, but they consumes a common trait that can still be extended using impl on both of these types for creation purposes. This is particularly impactful on the enum variants that have highly differing contents and sub-fields. By implementing this, in theory you could then the following which is not really possible as Enums aren't types:
let packet = parse_avr(&input).unwrap();
let adsb: ADSBMessage = packet.kind;
let postition: Position = adsb.kind.cpr_frame.position;
The text was updated successfully, but these errors were encountered:
Unfortunately rust doesn't support enum variants as types and it looks like this won't be changing anytime soon (rust-lang/lang-team#122).
Another alternative to improve the ergonomics of assigning message types would be to convert the anonymous struct variants into tuple variants containing a named struct:
Due to how the variants of MessageKind and ADSBMessageKind are built, they are pretty easy to create, but from a user of the API's perspective, due to the individual variants being Enums, they cannot be typed and assigned to new variables.
I'd suggest to convert messageKinds into individual types, but they consumes a common trait that can still be extended using impl on both of these types for creation purposes. This is particularly impactful on the enum variants that have highly differing contents and sub-fields. By implementing this, in theory you could then the following which is not really possible as Enums aren't types:
The text was updated successfully, but these errors were encountered: