pub struct ShadowBuilder<'a> { /* private fields */ }
Expand description
A builder pattern structure to construct a Shadow
instance.
This struct allows for configuring various aspects of how shadow-rs will be built into your Rust project. It provides methods to set up hooks, specify build patterns, define paths, and deny certain build constants.
§Fields
hook
: An optional hook that can be used during the build process. Hooks implement theHookExt
trait.build_pattern
: Determines the strategy for triggering package rebuilds (Lazy
,RealTime
, orCustom
).deny_const
: A set of build constant identifiers that should not be included in the build.src_path
: The source path from which files are read for building.out_path
: The output path where generated files will be placed.
Implementations§
Source§impl<'a> ShadowBuilder<'a>
impl<'a> ShadowBuilder<'a>
Sourcepub fn builder() -> Self
pub fn builder() -> Self
Creates a new ShadowBuilder
with default settings.
Initializes the builder with the following defaults:
hook
: Nonebuild_pattern
:BuildPattern::Lazy
deny_const
: Uses the result fromdefault_deny()
src_path
: Attempts to get the manifest directory usingCARGO_MANIFEST_DIR
environment variable.out_path
: Attempts to get the output directory usingOUT_DIR
environment variable.
§Returns
A new instance of ShadowBuilder
.
Sourcepub fn build_pattern(self, pattern: BuildPattern) -> Self
pub fn build_pattern(self, pattern: BuildPattern) -> Self
Sourcepub fn deny_const(self, deny_const: BTreeSet<ShadowConst>) -> Self
pub fn deny_const(self, deny_const: BTreeSet<ShadowConst>) -> Self
Sourcepub fn build(self) -> SdResult<Shadow>
pub fn build(self) -> SdResult<Shadow>
Builds a Shadow
instance based on the current configuration.
§Returns
A SdResult<Shadow>
that represents the outcome of the build operation.
Sourcepub fn get_src_path(&self) -> SdResult<&String>
pub fn get_src_path(&self) -> SdResult<&String>
Gets the source path if it has been set.
§Returns
A SdResult<&String>
containing the source path or an error if the path is missing.
Sourcepub fn get_out_path(&self) -> SdResult<&String>
pub fn get_out_path(&self) -> SdResult<&String>
Gets the output path if it has been set.
§Returns
A SdResult<&String>
containing the output path or an error if the path is missing.
Sourcepub fn get_build_pattern(&self) -> &BuildPattern
pub fn get_build_pattern(&self) -> &BuildPattern
Gets the build pattern.
§Returns
A reference to the BuildPattern
currently configured for this builder.
Sourcepub fn get_deny_const(&self) -> &BTreeSet<ShadowConst>
pub fn get_deny_const(&self) -> &BTreeSet<ShadowConst>
Gets the denied constants.
§Returns
A reference to the set of ShadowConst
that are denied for this build.