Struct pbjson_build::Builder
source · pub struct Builder { /* private fields */ }
Implementations§
source§impl Builder
impl Builder
sourcepub fn out_dir<P>(&mut self, path: P) -> &mut Selfwhere
P: Into<PathBuf>,
pub fn out_dir<P>(&mut self, path: P) -> &mut Selfwhere P: Into<PathBuf>,
Configures the output directory where generated Rust files will be written.
If unset, defaults to the OUT_DIR
environment variable. OUT_DIR
is set by Cargo when
executing build scripts, so out_dir
typically does not need to be configured.
sourcepub fn register_descriptors(&mut self, descriptors: &[u8]) -> Result<&mut Self>
pub fn register_descriptors(&mut self, descriptors: &[u8]) -> Result<&mut Self>
Register an encoded FileDescriptorSet
with this Builder
sourcepub fn register_file_descriptor(
&mut self,
file: FileDescriptorProto
) -> &mut Self
pub fn register_file_descriptor( &mut self, file: FileDescriptorProto ) -> &mut Self
Register a decoded FileDescriptor
with this Builder
sourcepub fn exclude<S: Into<String>, I: IntoIterator<Item = S>>(
&mut self,
prefixes: I
) -> &mut Self
pub fn exclude<S: Into<String>, I: IntoIterator<Item = S>>( &mut self, prefixes: I ) -> &mut Self
Don’t generate code for the following type prefixes
sourcepub fn retain_enum_prefix(&mut self) -> &mut Self
pub fn retain_enum_prefix(&mut self) -> &mut Self
Configures the code generator to not strip the enum name from variant names.
sourcepub fn extern_path(
&mut self,
proto_path: impl Into<String>,
rust_path: impl Into<String>
) -> &mut Self
pub fn extern_path( &mut self, proto_path: impl Into<String>, rust_path: impl Into<String> ) -> &mut Self
Declare an externally provided Protobuf package or type
sourcepub fn ignore_unknown_fields(&mut self) -> &mut Self
pub fn ignore_unknown_fields(&mut self) -> &mut Self
Don’t error out in the presence of unknown fields when deserializing, instead skip the field.
sourcepub fn btree_map<S: Into<String>, I: IntoIterator<Item = S>>(
&mut self,
paths: I
) -> &mut Self
pub fn btree_map<S: Into<String>, I: IntoIterator<Item = S>>( &mut self, paths: I ) -> &mut Self
Generate Rust BTreeMap implementations for Protobuf map type fields.
sourcepub fn emit_fields(&mut self) -> &mut Self
pub fn emit_fields(&mut self) -> &mut Self
Output fields with their default values.
pub fn use_integers_for_enums(&mut self) -> &mut Self
sourcepub fn preserve_proto_field_names(&mut self) -> &mut Self
pub fn preserve_proto_field_names(&mut self) -> &mut Self
Output fields with their original names as defined in their proto schemas, instead of lowerCamelCase
sourcepub fn build<S: AsRef<str>>(&mut self, prefixes: &[S]) -> Result<()>
pub fn build<S: AsRef<str>>(&mut self, prefixes: &[S]) -> Result<()>
Generates code for all registered types where prefixes
contains a prefix of
the fully-qualified path of the type
sourcepub fn generate<S: AsRef<str>, W: Write, F: FnMut(&Package) -> Result<W>>(
&self,
prefixes: &[S],
write_factory: F
) -> Result<Vec<(Package, W)>>
pub fn generate<S: AsRef<str>, W: Write, F: FnMut(&Package) -> Result<W>>( &self, prefixes: &[S], write_factory: F ) -> Result<Vec<(Package, W)>>
Generates code into instances of write as provided by the write_factory
This function is intended for use when writing output of code generation
directly to output files is not desired. For most use cases inside a
build.rs
file, the build()
method should be preferred.