shadow_rs

Struct Shadow

source
pub struct Shadow {
    pub f: File,
    pub map: BTreeMap<ShadowConst, ConstVal>,
    pub std_env: BTreeMap<String, String>,
    pub deny_const: BTreeSet<ShadowConst>,
}
Expand description

shadow-rs configuration.

If you use the recommended utility functions new, new_deny, or new_hook, you do not have to handle Shadow configurations themselves. However, this struct provides more fine-grained access to shadow-rs configuration, such as using a denylist and a hook function at the same time.

Fields§

§f: File

The file that shadow-rs writes build information to.

§map: BTreeMap<ShadowConst, ConstVal>

The values of build constants to be written.

§std_env: BTreeMap<String, String>

Build environment variables, obtained through std::env::vars.

§deny_const: BTreeSet<ShadowConst>

Constants in the deny list, passed through new_deny or Shadow::build.

Implementations§

source§

impl Shadow

source

pub fn hook<F>(&self, f: F) -> SdResult<()>
where F: FnOnce(&File) -> SdResult<()>,

Write the build configuration specified by this Shadow instance. The hook function is run as well, allowing it to append to shadow-rs’s output.

source

pub fn deny_contains(&self, deny_const: ShadowConst) -> bool

Checks if the specified build constant is in the deny list.

§Arguments
  • deny_const - A value of type ShadowConst representing the build constant to check.
§Returns
  • true if the build constant is present in the deny list; otherwise, false.
source

pub fn build(deny_const: BTreeSet<ShadowConst>) -> SdResult<Shadow>

Create a new Shadow configuration with a provided denylist. The project source path and output file are automatically derived from Cargo build environment variables.

source

pub fn build_with( src_path: String, out_path: String, deny_const: BTreeSet<ShadowConst>, ) -> SdResult<Shadow>

source

pub fn cargo_rerun_if_env_changed(&self)

Request Cargo to re-run the build script if any environment variable observed by this Shadow configuration changes.

source

pub fn cargo_rerun_env_inject(&self, env: &[&str])

Request Cargo to re-run the build script if any of the specified environment variables change. This function is not influenced by this Shadow configuration.

Trait Implementations§

source§

impl Debug for Shadow

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Shadow

§

impl RefUnwindSafe for Shadow

§

impl Send for Shadow

§

impl Sync for Shadow

§

impl Unpin for Shadow

§

impl UnwindSafe for Shadow

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.