Struct pbjson_build::Builder

source ·
pub struct Builder { /* private fields */ }

Implementations§

source§

impl Builder

source

pub fn new() -> Self

Create a new Builder

source

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.

source

pub fn register_descriptors(&mut self, descriptors: &[u8]) -> Result<&mut Self>

Register an encoded FileDescriptorSet with this Builder

source

pub fn register_file_descriptor( &mut self, file: FileDescriptorProto ) -> &mut Self

Register a decoded FileDescriptor with this Builder

source

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

source

pub fn retain_enum_prefix(&mut self) -> &mut Self

Configures the code generator to not strip the enum name from variant names.

source

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

source

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.

source

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.

source

pub fn emit_fields(&mut self) -> &mut Self

Output fields with their default values.

source

pub fn use_integers_for_enums(&mut self) -> &mut Self

source

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

source

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

source

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§

source§

impl Debug for Builder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Builder

source§

fn default() -> Builder

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.