We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi There,
I am getting a compilation error there are too many leading 'super' keywords when building following example:
there are too many leading 'super' keywords
event-types.proto
syntax = "proto3"; package my.event_types; enum EventType { NotAnEvent = 0; Event1 = 1; Event2 = 2; }
messages.proto
syntax = "proto3"; import "google/protobuf/timestamp.proto"; package my.messages; message Content { oneof body { string some_string = 1; bool some_bool = 2; float some_float = 3; } } message Foo { string data = 1; google.protobuf.Timestamp timestamp = 2; Content content = 3; }
requests.proto
syntax = "proto3"; import "google/protobuf/any.proto"; import "messages.proto"; import "event-types.proto"; package my.requests; message Request { string requestId = 1; google.protobuf.Any payload = 2; } message AnotherRequest { string requestId = 1; my.event_types.EventType eventType = 2; my.messages.Foo foo = 3; }
The generated my.requests.rs is:
my.requests.rs
#[derive(serde::Serialize, serde::Deserialize)] #[serde(default, rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Request { #[prost(string, tag = "1")] pub request_id: ::prost::alloc::string::String, #[prost(message, optional, tag = "2")] pub payload: ::core::option::Option<::prost_wkt_types::Any>, } #[derive(serde::Serialize, serde::Deserialize)] #[serde(default, rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct AnotherRequest { #[prost(string, tag = "1")] pub request_id: ::prost::alloc::string::String, #[prost(enumeration = "super::event_types::EventType", tag = "2")] pub event_type: i32, #[prost(message, optional, tag = "3")] pub foo: ::core::option::Option<super::messages::Foo>, } # [allow (dead_code)] const IMPL_MESSAGE_SERDE_FOR_REQUEST : () = { use :: prost_wkt :: typetag ; # [typetag :: serde (name = "type.googleapis.com/my.requests.Request")] impl :: prost_wkt :: MessageSerde for Request { fn package_name (& self) -> & 'static str { "my.requests" } fn message_name (& self) -> & 'static str { "Request" } fn type_url (& self) -> & 'static str { "type.googleapis.com/my.requests.Request" } fn new_instance (& self , data : Vec < u8 >) -> :: std :: result :: Result < Box < dyn :: prost_wkt :: MessageSerde > , :: prost :: DecodeError > { let mut target = Self :: default () ; :: prost :: Message :: merge (& mut target , data . as_slice ()) ? ; let erased : :: std :: boxed :: Box < dyn :: prost_wkt :: MessageSerde > = :: std :: boxed :: Box :: new (target) ; Ok (erased) } fn try_encoded (& self) -> :: std :: result :: Result < :: std :: vec :: Vec < u8 > , :: prost :: EncodeError > { let mut buf = :: std :: vec :: Vec :: new () ; buf . reserve (:: prost :: Message :: encoded_len (self)) ; :: prost :: Message :: encode (self , & mut buf) ? ; Ok (buf) } } :: prost_wkt :: inventory :: submit ! { :: prost_wkt :: MessageSerdeDecoderEntry { type_url : "type.googleapis.com/my.requests.Request" , decoder : | buf : & [u8] | { let msg : Request = :: prost :: Message :: decode (buf) ? ; Ok (:: std :: boxed :: Box :: new (msg)) } } } } ; # [allow (dead_code)] const IMPL_MESSAGE_SERDE_FOR_ANOTHER_REQUEST : () = { use :: prost_wkt :: typetag ; # [typetag :: serde (name = "type.googleapis.com/my.requests.AnotherRequest")] impl :: prost_wkt :: MessageSerde for AnotherRequest { fn package_name (& self) -> & 'static str { "my.requests" } fn message_name (& self) -> & 'static str { "AnotherRequest" } fn type_url (& self) -> & 'static str { "type.googleapis.com/my.requests.AnotherRequest" } fn new_instance (& self , data : Vec < u8 >) -> :: std :: result :: Result < Box < dyn :: prost_wkt :: MessageSerde > , :: prost :: DecodeError > { let mut target = Self :: default () ; :: prost :: Message :: merge (& mut target , data . as_slice ()) ? ; let erased : :: std :: boxed :: Box < dyn :: prost_wkt :: MessageSerde > = :: std :: boxed :: Box :: new (target) ; Ok (erased) } fn try_encoded (& self) -> :: std :: result :: Result < :: std :: vec :: Vec < u8 > , :: prost :: EncodeError > { let mut buf = :: std :: vec :: Vec :: new () ; buf . reserve (:: prost :: Message :: encoded_len (self)) ; :: prost :: Message :: encode (self , & mut buf) ? ; Ok (buf) } } :: prost_wkt :: inventory :: submit ! { :: prost_wkt :: MessageSerdeDecoderEntry { type_url : "type.googleapis.com/my.requests.AnotherRequest" , decoder : | buf : & [u8] | { let msg : AnotherRequest = :: prost :: Message :: decode (buf) ? ; Ok (:: std :: boxed :: Box :: new (msg)) } } } } ;
The compilation error is on line pub foo: ::core::option::Option<super::messages::Foo>.
pub foo: ::core::option::Option<super::messages::Foo>
How can I resolve this error?
Another question is that generated type of event_type is i32, is it possible to have something like pub event_type: ::event_types::EventType instead?
event_type
i32
pub event_type: ::event_types::EventType
Regards Farhan
The text was updated successfully, but these errors were encountered:
I will need to investigate this a little further. What version of rust were you using?
Sorry, something went wrong.
Here is my Cargo.tml
Cargo.tml
name = "proto-generator" version = "0.1.0" edition = "2021" [dependencies] prost = "0.11.9" #prost-types = "0.11.9" prost-wkt = "0.4.2" prost-wkt-types = "0.4.2" serde = "1.0.183" serde_json = "1.0.104" chrono = { version = "0.4.26", default-features = false, features = ["clock", "serde"] } [build-dependencies] prost-build = "0.11.9" prost-wkt-build = "0.4.2"
Rust version is1.71.1.
1.71.1
Thanks in advance.
No branches or pull requests
Hi There,
I am getting a compilation error
there are too many leading 'super' keywords
when building following example:event-types.proto
messages.proto
requests.proto
The generated
my.requests.rs
is:The compilation error is on line
pub foo: ::core::option::Option<super::messages::Foo>
.How can I resolve this error?
Another question is that generated type of
event_type
isi32
, is it possible to have something likepub event_type: ::event_types::EventType
instead?Regards Farhan
The text was updated successfully, but these errors were encountered: