Struct ShadowBuilder

Source
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 the HookExt trait.
  • build_pattern: Determines the strategy for triggering package rebuilds (Lazy, RealTime, or Custom).
  • 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>

Source

pub fn builder() -> Self

Creates a new ShadowBuilder with default settings.

Initializes the builder with the following defaults:

  • hook: None
  • build_pattern: BuildPattern::Lazy
  • deny_const: Uses the result from default_deny()
  • src_path: Attempts to get the manifest directory using CARGO_MANIFEST_DIR environment variable.
  • out_path: Attempts to get the output directory using OUT_DIR environment variable.
§Returns

A new instance of ShadowBuilder.

Source

pub fn hook(self, hook: impl HookExt + 'a) -> Self

Sets the build hook for this builder.

§Arguments
  • hook - An object implementing the HookExt trait that defines custom behavior for the build process.
§Returns

A new ShadowBuilder instance with the specified hook applied.

Source

pub fn src_path<P: AsRef<str>>(self, src_path: P) -> Self

Sets the source path for this builder.

§Arguments
  • src_path - A string reference that specifies the source directory for the build.
§Returns

A new ShadowBuilder instance with the specified source path.

Source

pub fn out_path<P: AsRef<str>>(self, out_path: P) -> Self

Sets the output path for this builder.

§Arguments
  • out_path - A string reference that specifies the output directory for the build.
§Returns

A new ShadowBuilder instance with the specified output path.

Source

pub fn build_pattern(self, pattern: BuildPattern) -> Self

Sets the build pattern for this builder.

§Arguments
  • pattern - A BuildPattern that determines when the package should be rebuilt.
§Returns

A new ShadowBuilder instance with the specified build pattern.

Source

pub fn deny_const(self, deny_const: BTreeSet<ShadowConst>) -> Self

Sets the denied constants for this builder.

§Arguments
  • deny_const - A set of ShadowConst that should be excluded from the build.
§Returns

A new ShadowBuilder instance with the specified denied constants.

Source

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.

Source

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.

Source

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.

Source

pub fn get_build_pattern(&self) -> &BuildPattern

Gets the build pattern.

§Returns

A reference to the BuildPattern currently configured for this builder.

Source

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.

Source

pub fn get_hook(&'a self) -> Option<&'a (dyn HookExt + 'a)>

Gets the build hook if it has been set.

§Returns

An option containing a reference to the hook if one is present.

Auto Trait Implementations§

§

impl<'a> Freeze for ShadowBuilder<'a>

§

impl<'a> !RefUnwindSafe for ShadowBuilder<'a>

§

impl<'a> !Send for ShadowBuilder<'a>

§

impl<'a> !Sync for ShadowBuilder<'a>

§

impl<'a> Unpin for ShadowBuilder<'a>

§

impl<'a> !UnwindSafe for ShadowBuilder<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T