pub struct Environment { /* private fields */ }
Expand description

A description of the current build environment

Implementations§

source§

impl Environment

source

pub fn new() -> Result<Environment, EnvironmentError>

Construct a new build configuration structure, or die trying.

source

pub fn cargo(&self) -> &Path

Get the path to the cargo executables

source

pub fn locked(&self) -> bool

Get whether cargo was invoked with the --locked flag

source

pub fn features(&self) -> HashSetIter<'_, String>

Get a reference to a hash set of enabled cargo features (as lower-kebab-case strings)

source

pub fn feature(&self, feature: &str) -> bool

Get whether a feature is enabled or not.

Feature names are normalized into lower-kebab-case (as opposed to UPPER_SNAKE_CASE).

source

pub fn depvars(&self) -> HashMapIter<'_, String, String>

Get a reference to a hash map of variables injected by the current crate’s dependencies

source

pub fn depvar(&self, var: &str) -> Option<&str>

Get the contents of a particular depvar, if one is provided.

source

pub fn dir(&self) -> &Path

Get the directory where the current Cargo.toml resides

Get the string contents of this crate’s links key

source

pub fn debug(&self) -> bool

Get whether debug is enabled on this build

source

pub fn host(&self) -> &str

Get the hostname of the build

source

pub fn linker(&self) -> &Path

Get the path to the linker executable being used

source

pub fn num_jobs(&self) -> usize

Get the number of jobs which can be run in parallel

source

pub fn out_dir(&self) -> &Path

Get the output directory path

source

pub fn opt_level(&self) -> usize

Get the optimization level

source

pub fn profile(&self) -> &str

Get the build profile as a string

source

pub fn rustc(&self) -> &Path

Get the path to the rustc compiler being used

source

pub fn rustdoc(&self) -> &Path

Get the path to the rustdoc executable being used

source

pub fn target(&self) -> &str

Get the target triple string

source

pub fn version(&self) -> &str

Get the package version string

source

pub fn version_major(&self) -> u64

Get the package version major number

source

pub fn version_minor(&self) -> u64

Get the package version minor number

source

pub fn version_patch(&self) -> u64

Get the package version patch number

source

pub fn version_pre(&self) -> Option<String>

Get the package version pre-release number

source

pub fn authors(&self) -> &HashSet<String>

Get a reference to a hash set of package author strings

source

pub fn name(&self) -> &str

Get the name of the package of the current package

source

pub fn description(&self) -> &str

Get the description of the current package

source

pub fn homepage(&self) -> &str

Get the homepage of the current package

source

pub fn repository(&self) -> &str

Get the repository of the current package

source

pub fn debug_assertions(&self) -> bool

Get whether or not debug assertions are enabled in this build

source

pub fn proc_macro(&self) -> bool

Get whether or not proc macros are enabled in this build

source

pub fn target_arch(&self) -> &str

Get the target architecture

source

pub fn target_endian(&self) -> Endianness

Get the endianness

source

pub fn target_env(&self) -> &str

Get the target environment

source

pub fn target_family(&self) -> TargetFamily

Get the target architecture family

source

pub fn target_features(&self) -> &HashSet<String>

Get a reference to the target feature set

source

pub fn target_has_atomic(&self) -> &HashSet<String>

Get a list of types which support atomic operations on the target platform

source

pub fn target_has_atomic_load_store(&self) -> &HashSet<String>

Get a list of types which support atomic load and store

source

pub fn target_os(&self) -> &str

Get the target OS

source

pub fn target_pointer_width(&self) -> usize

Get the target pointer width

source

pub fn target_thread_local(&self) -> bool

Get whether thread-local storage is available

source

pub fn target_vendor(&self) -> &str

Get the target triple vendor

source

pub fn target_dir(&self) -> &Path

Get the target directory (i.e. the --target-dir flag)

source

pub fn profile_target_dir(&self) -> &Path

Get the profile target directory

Trait Implementations§

source§

impl Clone for Environment

source§

fn clone(&self) -> Environment

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Environment

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Environment

source§

fn default() -> Environment

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.