1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: MIT
//! Generic build-helper primitives for proto-source services.
//!
//! The four primitives this crate exposes are the ones every
//! `.proto`-publishing or `.proto`-consuming Rust crate ends up
//! reimplementing:
//!
//! 1. **Stage embedded proto bytes onto a tempdir** at protoc-relative
//! paths so `import "myproto/v1/foo.proto";` resolves at build time
//! without the consumer vendoring the file ([`Stager`]).
//! 2. **Compile `.proto` files via `protox`** (pure Rust, no `protoc`
//! subprocess) and return both the `prost-reflect` descriptor pool
//! (preserves custom-option VALUES) and the FDS bytes for downstream
//! codegen ([`compile_protos`]).
//! 3. **Read `MethodOptions` extension values** from the descriptor pool
//! — encoded FDS drops them, the pool keeps them
//! ([`extract_method_string_extension`]).
//! 4. **Drive `tonic-prost-build`** with `type_attribute(...)` injection
//! from an annotation-FQN map ([`tonic_prost_build_with_attrs`], gated
//! on the `tonic` feature).
//!
//! The crate is **schema-agnostic** — it doesn't know about any specific
//! proto package or annotation. Consumers pair it with a tiny sibling
//! crate that ships their `.proto` bytes via `include_bytes!`:
//!
//! ```ignore
//! // some-protos/src/lib.rs (your bytes crate):
//! const FOO: &[u8] = include_bytes!("../proto/my/v1/foo.proto");
//! pub fn files() -> impl Iterator<Item = (&'static str, &'static [u8])> {
//! [("my/v1/foo.proto", FOO)].into_iter()
//! }
//! ```
//!
//! Consumer `build.rs` then composes any number of `*-protos` crates:
//!
//! ```ignore
//! use proto_build_kit::Stager;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let staged = Stager::new()
//! .with(some_protos::files())
//! .with(other_protos::files())
//! .stage()?;
//!
//! // Drive whatever codegen you want (connectrpc-build, tonic, ...)
//! // against `staged.path()` on the include path.
//! Ok(())
//! }
//! ```
//!
//! Hold the returned [`tempfile::TempDir`] until codegen completes —
//! drop deletes the staged files.
pub use ;
pub use Error;
pub use extract_method_string_extension;
pub use Stager;
pub use tonic_prost_build_with_attrs;