Struct Environment

Source
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 duplicate of the value. Read more
1.0.0 · Source§

const 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 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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 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,