fdeantoni / prost-wkt

Prost Well-Known-Types serialization and deserialization.
Apache License 2.0
76 stars 35 forks source link

Unable run example #50

Closed sfali23 closed 1 year ago

sfali23 commented 1 year ago

Hi There,

I am trying to run example but build the example.

My Cargo.toml is following:

[package]
name = "prost-example"
version = "0.1.0"
edition = "2021"

[dependencies]
prost = "0.11.9"
prost-wkt = "0.4.2"
prost-wkt-types = "0.4.2"
serde = "1.0.183"
serde_derive = "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"

Generated my.requests.rs is:


# [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)) } } } } ;

my.messages.rs


# [allow (dead_code)] const IMPL_MESSAGE_SERDE_FOR_CONTENT : () = { use :: prost_wkt :: typetag ; # [typetag :: serde (name = "type.googleapis.com/my.messages.Content")] impl :: prost_wkt :: MessageSerde for Content { fn package_name (& self) -> & 'static str { "my.messages" } fn message_name (& self) -> & 'static str { "Content" } fn type_url (& self) -> & 'static str { "type.googleapis.com/my.messages.Content" } 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.messages.Content" , decoder : | buf : & [u8] | { let msg : Content = :: prost :: Message :: decode (buf) ? ; Ok (:: std :: boxed :: Box :: new (msg)) } } } } ;

# [allow (dead_code)] const IMPL_MESSAGE_SERDE_FOR_FOO : () = { use :: prost_wkt :: typetag ; # [typetag :: serde (name = "type.googleapis.com/my.messages.Foo")] impl :: prost_wkt :: MessageSerde for Foo { fn package_name (& self) -> & 'static str { "my.messages" } fn message_name (& self) -> & 'static str { "Foo" } fn type_url (& self) -> & 'static str { "type.googleapis.com/my.messages.Foo" } 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.messages.Foo" , decoder : | buf : & [u8] | { let msg : Foo = :: prost :: Message :: decode (buf) ? ; Ok (:: std :: boxed :: Box :: new (msg)) } } } } ;

Don't see any generated code for messages.

Any idea what's going on.

Regards

Farhan

sfali23 commented 1 year ago

Sorry I wasn't setting out dir in build. It is working