From 1aa6f2d49ac7eaf875d872ac6267fb8c1ed3627c Mon Sep 17 00:00:00 2001 From: Iain McGinniss <309153+iainmcgin@users.noreply.github.com> Date: Sun, 6 Sep 2026 08:38:00 -0700 Subject: [PATCH] docs: note that google::protobuf::Option shadows the prelude under a glob import type.proto's Option message is kept under its proto name, as protoc, prost-types and protobuf-go keep it; the guide now says to import WKTs by name and what the error looks like if a module glob-imports the package. --- docs/guide.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guide.md b/docs/guide.md index 7c177a25..f0667e3f 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -1643,6 +1643,8 @@ The `buffa-types` crate provides pre-generated types for Google's well-known pro `Api`, `Type`, `Enum`, `SourceContext` and the messages they contain (`Method`, `Mixin`, `Field`, `EnumValue`, `Option`) implement the binary, view, and text codecs but not `Serialize`/`Deserialize`. A message that embeds one of them under `json = true` fails to compile with `the trait bound Api: Serialize is not satisfied`; map the type to your own generated copy with `extern_path` if you need JSON for it. +Import well-known types by name (`use buffa_types::google::protobuf::Timestamp;`) rather than with a glob. `type.proto` defines a message named `Option`, so `use buffa_types::google::protobuf::*;` brings a struct `Option` into scope that shadows the prelude's `core::option::Option` and turns every `Option` in that module into `error[E0107]: struct takes 0 generic arguments`. The name is kept as protoc, prost-types and protobuf-go keep it, because the proto-path-to-Rust-path mapping that `extern_path` relies on has no room for a rename; generated code is unaffected since it always spells `::core::option::Option`. + ### Timestamp and Duration With the `std` feature, `Timestamp` and `Duration` convert to/from `std::time` types: