Struct protoc::Protoc [−][src]
pub struct Protoc { /* fields omitted */ }
Expand description
A builder for a protobuf compilation.
Implementations
Adds an include path to the compilation.
Adds an input file to the compilation.
Parses the inputs into a file descriptor set.
A FileDescriptorSet
is protobuf’s internal representation of a
collection .proto file. It is similar in spirit to an AST, and is useful
for callers who will analyze the protobuf messages to provide bespoke
deserialization and serialization behavior, rather than relying on the
stock code generation.
Most users will want to call Protoc::compile_into
or
Protoc::build_script_exec
instead.
Executes the compilation.
The generated files are placed into out_dir
according to the
conventions of the protobuf_codegen_pure
crate. Roughly speaking, for
each input file path/to/file.proto
, this method generates the Rust
file OUT_DIR/path/to/file.rs
. The details involve some special rules
for escaping Rust keywords and special characters, but you will have to
consult the protobuf_codegen_pure
source code for details.
Executes the compilation, following build script conventions for input and output.
This is roughly equivalent to calling
compile_into
, with the following adjustments.
-
The directory to generate into is read from the environment variable
OUT_DIR
. -
If an error occurs, instead of returning the error, the error is printed to stderr and the process is aborted.
-
If the compilation is Serde-enabled, Cargo will be instructed to enable the
with-serde
feature to work around a bug inprotobuf_codegen_pure
. -
Various diagnostic information is printed to stdout for users following along with e.g.
cargo build -vv
.