Skip to main content

Config

Struct Config 

Source
pub struct Config { /* private fields */ }
Expand description

Builder configuring how witforge-generated .proto files are compiled.

Implementations§

Source§

impl Config

Source

pub fn new() -> Self

Create a default configuration that writes DEFAULT_INCLUDE_FILE to OUT_DIR and emits per-directory and per-file cargo:rerun-if-changed directives.

Source

pub fn out_dir(self, dir: impl Into<PathBuf>) -> Self

Override the output directory (defaults to Cargo’s OUT_DIR environment variable).

Source

pub fn include_file(self, name: impl Into<PathBuf>) -> Self

Override the include filename written inside out_dir (defaults to DEFAULT_INCLUDE_FILE).

Must be a single plain filename (no directory separators or .. components).

Source

pub fn no_include_file(self) -> Self

Disable generating the combined include file (only per-package .rs files are written).

Source

pub fn file_descriptor_set_path(self, path: impl Into<PathBuf>) -> Self

Also write the compiled protobuf FileDescriptorSet bytes to path.

Source

pub const fn emit_rerun_if_changed(self, enabled: bool) -> Self

Control whether cargo:rerun-if-changed=... lines are printed to stdout (default true).

Source

pub fn prost_config(&mut self) -> &mut Config

Access the underlying prost_build::Config for custom codegen tweaks.

Note that out_dir and include_file are managed by Config::out_dir and Config::include_file and take precedence during Config::compile_protos.

Source

pub fn with_prost_config(self, configure: impl FnOnce(&mut Config)) -> Self

Configure the underlying prost_build::Config in builder style.

Note that out_dir and include_file are managed by Config::out_dir and Config::include_file and take precedence during Config::compile_protos.

Source

pub const fn pbjson(self, enabled: bool) -> Self

Enable or disable pbjson-build proto3-JSON serde code generation (default false).

When enabled alongside an include file, the generated *.serde.rs files are included automatically beside their matching prost modules.

Source

pub fn pbjson_builder(&mut self) -> &mut Builder

Access the underlying pbjson_build::Builder for custom proto3-JSON codegen options (such as pbjson_build::Builder::ignore_unknown_fields).

Calling this method does not automatically enable pbjson; pair it with .pbjson(true) or use Self::with_pbjson_builder.

Source

pub fn with_pbjson_builder(self, configure: impl FnOnce(&mut Builder)) -> Self

Enable pbjson code generation and configure the underlying pbjson_build::Builder in builder style (for example .with_pbjson_builder(|b| { b.ignore_unknown_fields(); })).

Source

pub fn compile_protos( self, proto_dir: impl AsRef<Path>, ) -> Result<BuildOutput, Error>

Discover and compile every .proto file under proto_dir.

§Errors

Returns Error if proto_dir cannot be read, contains symlinks or no .proto files, include_file is invalid, OUT_DIR is unset, or protox / prost-build / pbjson-build fails.

Trait Implementations§

Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Config

§

impl !Send for Config

§

impl !Sync for Config

§

impl !UnwindSafe for Config

§

impl Forget for Config

§

impl Freeze for Config

§

impl Move for Config

§

impl Unpin for Config

§

impl UnsafeUnpin for Config

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.