[−][src]Struct exonum_build::ProtobufGenerator
Generates Rust modules from Protobuf files.
The protoc
executable (i.e., the Protobuf compiler) should be in $PATH
.
Examples
Specify in the build script (build.rs
) of your crate:
use exonum_build::ProtobufGenerator; ProtobufGenerator::with_mod_name("example_mod.rs") .with_input_dir("src/proto") .with_crypto() .with_common() .with_merkledb() .generate();
After the successful run, $OUT_DIR
will contain a module for each Protobuf file in
src/proto
and example_mod.rs
which will include all generated modules
as submodules.
To use the generated Rust types corresponding to Protobuf messages, specify
in src/proto/mod.rs
:
include!(concat!(env!("OUT_DIR"), "/example_mod.rs")); // If you use types from `exonum` .proto files. use exonum::proto::schema::*;
Methods
impl<'a> ProtobufGenerator<'a>
[src]
pub fn with_mod_name(mod_name: &'a str) -> Self
[src]
pub fn with_input_dir(self, path: &'a str) -> Self
[src]
A directory containing input protobuf files.
For single mod_name
you can provide only one input directory,
If proto-files in the input directory have dependencies located in another
directories, you must specify them using add_path
method.
Predefined dependencies can be specified using corresponding methods
with_common
, with_crypto
, with_exonum
.
Panics
If the input directory is already specified.
pub fn add_path(self, path: &'a str) -> Self
[src]
An additional directory containing dependent proto-files, can be used multiple times.
pub fn with_common(self) -> Self
[src]
Common types for all crates.
pub fn with_crypto(self) -> Self
[src]
Proto files from exonum-crypto
crate (Hash
, PublicKey
, etc.).
pub fn with_merkledb(self) -> Self
[src]
Proto files from exonum-merkledb
crate (MapProof
, ListProof
).
pub fn with_exonum(self) -> Self
[src]
Exonum core related proto files,
pub fn with_includes(self, includes: &'a [ProtoSources]) -> Self
[src]
Add multiple include directories.
pub fn without_sources(self) -> Self
[src]
Switches off inclusion of source Protobuf files into the generated output.
pub fn generate(self)
[src]
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for ProtobufGenerator<'a>
impl<'a> Send for ProtobufGenerator<'a>
impl<'a> Sync for ProtobufGenerator<'a>
impl<'a> Unpin for ProtobufGenerator<'a>
impl<'a> UnwindSafe for ProtobufGenerator<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,