The suggestion on stack overflow looks correct: Rust's language enums are
"tagged unions", the Protobuf `oneof` feature also acts as a tagged union.
Protobuf Enums are intended to be more semantically like C++ enums (which
cannot hold values inside).

Can you clarify the followup comment "AAOS stands for Android Automotive
OS. The IDL that generates publisher code, struggles with message types"?
Any documentation links would be helpful for us to follow up on if there's
some deliberate limitation or just an unfortunate technical state that
might be worked around.


On Fri, Apr 19, 2024 at 8:50 PM Daz Wilkin <[email protected]> wrote:

> I took a stab at a reply to your question on Stack overflow:
>
> https://stackoverflow.com/questions/78355748/nested-enum-with-protobuf
>
>
> On Friday, April 19, 2024 at 5:10:25 PM UTC-7 Chedy Souffargi wrote:
>
>> I am working on a Rust project, using Protocol Buffers, and dealing with
>> nested enums. Here's what I have so far in Rust:
>>
>> enum Vehicle { Car(CarType), Truck(TruckType), } enum CarType { Sedan,
>> Coupe, Hatchback, } enum TruckType { Pickup, Semi, } fn
>> create_vehicle_fleet() -> [Vehicle; 8] { [ Vehicle::Car(CarType::Sedan),
>> Vehicle::Truck(TruckType::Pickup), Vehicle::Car(CarType::Coupe),
>> Vehicle::Truck(TruckType::Semi), Vehicle::Car(CarType::Hatchback),
>> Vehicle::Car(CarType::Sedan), Vehicle::Truck(TruckType::Pickup),
>> Vehicle::Car(CarType::Coupe), ] }
>>
>> I cannot find a proper way to represent the Vehicle enum in protobuf. Can
>> anyone suggest a solution or provide guidance on how to handle this
>> situation in Protocol Buffers?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/9827eaf2-7b6f-474c-9cfa-f3fbca084ab8n%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/9827eaf2-7b6f-474c-9cfa-f3fbca084ab8n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CAKRmVH_0nGdx-CBs_m4uMHo8wWmYAc1LZHjYorBJnf3YeL9Uuw%40mail.gmail.com.

Reply via email to