Skip to content

What's a good default for protoc-gen-{prost|tonic}'s compile_well_known_types? #2058

Closed
@aaronmondal

Description

@aaronmondal

The compile_well_known_types flag controls whether generated libraries use prost-types or types from generated google.protobuf.* protos.

This flag is currently always enabled here (and a bit further below for tonic):

additional_args.add("--prost_opt=compile_well_known_types")

Being enabled by default means that we have to use e.g. timestamp_proto::google::protobuf::Timestamp instead of prost_types::Timestamp.

I'm not sure whether this is a good or a bad thing.

  • It's more precise if users explicitly use the types that are actually written in the proto files.
  • It seems the ergonomics of prost-types are nicer. E.g. a generated timestamp_proto::google::protobuf::Timestamp doesn't implement From<SystemTime>, but prost_types::Timestamp does. Intuitively I could also imagine the specialized prost-types to be more performant.

There is also a protoc-wkt crate that adds more extensive chrono-timestamp interop and other goodies.

Adding configurability for compile_well_known_types seems straightforward, but I'm not sure what the better default would be.

cc @allada @UebelAndre @freeformstu @illicitonion

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions