Struct protoc::Protoc[][src]

pub struct Protoc {
    includes: Vec<PathBuf>,
    inputs: Vec<PathBuf>,
    customize: Customize,
}

A builder for a protobuf compilation.

Fields

includes: Vec<PathBuf>inputs: Vec<PathBuf>customize: Customize

Implementations

impl Protoc[src]

pub fn new() -> Self[src]

Starts a new compilation.

pub fn include<S>(&mut self, include: S) -> &mut Self where
    S: Into<PathBuf>, 
[src]

Adds an include path to the compilation.

pub fn input<S>(&mut self, input: S) -> &mut Self where
    S: Into<PathBuf>, 
[src]

Adds an input file to the compilation.

pub fn serde(&mut self, set: bool) -> &mut Self[src]

Enables or disables serde support.

pub fn compile_into(&mut self, out_dir: &Path) -> Result<(), Error>[src]

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.

pub fn build_script_exec(&mut self) -> ![src]

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 in protobuf_codegen_pure.

  • Various diagnostic information is printed to stdout for users following along with e.g. cargo build -vv.

Trait Implementations

impl Debug for Protoc[src]

impl Default for Protoc[src]

Auto Trait Implementations

impl RefUnwindSafe for Protoc[src]

impl Send for Protoc[src]

impl Sync for Protoc[src]

impl Unpin for Protoc[src]

impl UnwindSafe for Protoc[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]