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 Self
pub fn out_dir<P>(&mut self, path: P) -> &mut Self
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.
sourcepub fn use_integers_for_enums(&mut self) -> &mut Self
pub fn use_integers_for_enums(&mut self) -> &mut Self
Print integers instead of enum names.
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more