pub struct Config { /* private fields */ }Expand description
Builder configuring how witforge-generated .proto files are compiled.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new() -> Self
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.
Sourcepub fn out_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn out_dir(self, dir: impl Into<PathBuf>) -> Self
Override the output directory (defaults to Cargo’s OUT_DIR environment variable).
Sourcepub fn include_file(self, name: impl Into<PathBuf>) -> Self
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).
Sourcepub fn no_include_file(self) -> Self
pub fn no_include_file(self) -> Self
Disable generating the combined include file (only per-package .rs files are written).
Sourcepub fn file_descriptor_set_path(self, path: impl Into<PathBuf>) -> Self
pub fn file_descriptor_set_path(self, path: impl Into<PathBuf>) -> Self
Also write the compiled protobuf FileDescriptorSet bytes to path.
Sourcepub const fn emit_rerun_if_changed(self, enabled: bool) -> Self
pub const fn emit_rerun_if_changed(self, enabled: bool) -> Self
Control whether cargo:rerun-if-changed=... lines are printed to stdout (default true).
Sourcepub fn prost_config(&mut self) -> &mut Config
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.
Sourcepub fn with_prost_config(self, configure: impl FnOnce(&mut Config)) -> Self
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.
Sourcepub const fn pbjson(self, enabled: bool) -> Self
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.
Sourcepub fn pbjson_builder(&mut self) -> &mut Builder
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.
Sourcepub fn with_pbjson_builder(self, configure: impl FnOnce(&mut Builder)) -> Self
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(); })).
Sourcepub fn compile_protos(
self,
proto_dir: impl AsRef<Path>,
) -> Result<BuildOutput, Error>
pub fn compile_protos( self, proto_dir: impl AsRef<Path>, ) -> Result<BuildOutput, Error>
Trait Implementations§
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> 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