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: Fn(&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.
Source§

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

Source§

impl<T> MaybeSendSync for T