tokio-rs / prost

PROST! a Protocol Buffers implementation for the Rust Language
Apache License 2.0
3.87k stars 501 forks source link

trait `prost::Message` not implemented for `Timestamp` #1171

Open duncanrhamill opened 4 days ago

duncanrhamill commented 4 days ago

Hello, I'm trying to use prost with a proto file that includes google.protobuf.Timestamp like so:

syntax = "proto3";

import "google/protobuf/timestamp.proto";

message Command {
  google.protobuf.Timestamp timestamp = 1;
}

I'm using prost-build with the following build script:

prost_build::Config::new().compile_protos(
    &["../../proto/public.proto"],
    &["../../proto/"],
)?;

With these versions in my Cargo.toml:

[dependencies]
prost = { version = "0.13.3", features = ["prost-derive"] }
prost-types = "0.13.3"

[build-dependencies]
prost-build = "0.13.3"

However when I try to build I get the following error messages:

error[E0277]: the trait bound `Timestamp: prost::Message` is not satisfied
   --> <PROJECT_BUILD_PATH>/out/public.rs:7:28
    |
7   | #[derive(Clone, PartialEq, ::prost::Message)]
    |                            ^^^^^^^^^^^^^^^^ the trait `prost::Message` is not implemented for `Timestamp`
    |
    = help: the following other types implement trait `prost::Message`:
              bool
              i32
              i64
              u32
              u64
              f32
              f64
              public::Command
            and 7 others
note: required by a bound in `message::encode`
   --> <CARGO_PATH>\prost-0.13.3\src\encoding.rs:789:12
    |
787 |     pub fn encode<M>(tag: u32, msg: &M, buf: &mut impl BufMut)
    |            ------ required by a bound in this function
788 |     where
789 |         M: Message,
    |            ^^^^^^^ required by this bound in `encode`
    = note: this error originates in the derive macro `::prost::Message` (in Nightly builds, run with -Z 
macro-backtrace for more info)

This is with both rust 1.81 and 1.77.2, on Windows 10. I have tried using prost-wkt-types, setting the compile_well_known_types flag in the prost_build::Config, and setting various extern_path values to try and map the types correctly. What is frustrating is that I can see the #[derive(..., ::prost::Message)] on my instance of the Timestamp struct in the cargo registry!

Does anyone know how to fix this issue?