pub struct Codegen { /* private fields */ }
Expand description

Entry point for .proto to .rs code generation.

This is similar to protoc --rust_out....

Implementations

Create new codegen object.

Uses protoc from $PATH by default.

Can be switched to pure rust parser using pure function.

Switch to pure Rust parser of .proto files.

Switch to protoc parser of .proto files.

Output directory for generated code.

When invoking from build.rs, consider using cargo_out_dir instead.

Set output directory relative to Cargo output dir.

With this option, output directory is erased and recreated during invocation.

Add an include directory.

Add include directories.

Append a .proto file path to compile

Append multiple .proto file paths to compile

Specify protoc command path to be used when invoking code generation.

Examples

use protobuf_codegen::Codegen;

Codegen::new()
    .protoc()
    .protoc_path(&protoc_bin_vendored::protoc_bin_path().unwrap())
    // ...
    .run()
    .unwrap();

This option is ignored when pure Rust parser is used.

Extra command line flags for protoc invocation.

For example, --experimental_allow_proto3_optional option.

This option is ignored when pure Rust parser is used.

Set options to customize code generation

Callback for dynamic per-element customization.

Invoke the code generation.

This is roughly equivalent to protoc --rust_out=... but without requiring protoc-gen-rust command in $PATH.

This function uses pure Rust parser or protoc parser depending on how this object was configured.

Similar to run, but prints the message to stderr and exits the process on error.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.