Skip to content

Commit 47a2608

Browse files
Clarify Rust documentation for non-bazel users.
Fixes #298 PiperOrigin-RevId: 869199733
1 parent 934c97b commit 47a2608

1 file changed

Lines changed: 9 additions & 28 deletions

File tree

content/reference/rust/rust-generated.md

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,18 @@ Rust std types like `str`. See
2929
[Rust Proto Design Decisions](/reference/rust/rust-design-decisions)
3030
for more on this topic.
3131

32-
## Generated Filenames {#filenames}
33-
34-
Each `rust_proto_library` will be compiled as one crate. Most importantly, for
35-
every `.proto` file in the `srcs` of the corresponding `proto_library`, one Rust
36-
file is emitted, and all these files form a single crate.
37-
38-
Files generated by the compiler vary between kernels. In general, the names of
39-
the output files are computed by taking the name of the `.proto` file and
40-
replacing the extension.
41-
42-
Generated files:
43-
44-
* C++ kernel:
45-
* `.c.pb.rs` - generated Rust code
46-
* `.pb.thunks.cc` - generated C++ thunks (glue code that Rust code calls,
47-
and that delegates to the C++ Protobuf APIs).
48-
* C++ Lite kernel:
49-
* <same as C++ kernel>
50-
* UPB kernel
51-
* `.u.pb.rs` - generated Rust code.
52-
53-
Each `proto_library` will also have a `generated.rs` file which is treated as
54-
the entry point for the crate. That file will re-export the symbols from all the
55-
other Rust files in the crate.
56-
5732
## Packages {#packages}
5833

5934
Unlike in most other languages, the `package` declarations in the `.proto` files
60-
are not used in Rust codegen. Instead, each `rust_proto_library(name =
61-
"some_rust_proto")` target emits a crate named `some_rust_proto` which contains
62-
the generated code for all `.proto` files in the target.
35+
are not used in Rust codegen.
36+
37+
When `rust_proto_library` is used, the library will correspond to one crate. The
38+
name of the target is used as the crate name. Choose your library name
39+
correspondingly.
40+
41+
When using Cargo, we recommend you `include!` the `generated.rs` entry point in
42+
a mod of an appropriate name, as in our
43+
[Example Crate](https://docs.rs/crate/protobuf-example).
6344

6445
## Messages {#messages}
6546

0 commit comments

Comments
 (0)