pub struct Cargo { /* private fields */ }Available on crate feature
cargo only.Expand description
Configure the emission of VERGEN_CARGO_* instructions
NOTE - All cargo instructions are considered deterministic. If you change the version of cargo you are compiling with, these values should change if being used in the generated binary.
| Variable | Sample |
|---|---|
VERGEN_CARGO_DEBUG | true |
VERGEN_CARGO_FEATURES | git,build |
VERGEN_CARGO_OPT_LEVEL | 1 |
VERGEN_CARGO_TARGET_TRIPLE | x86_64-unknown-linux-gnu |
§Example
Emit all of the cargo instructions
fn main() -> Result<()> {
temp_env::with_vars([
("CARGO_FEATURE_BUILD", Some("")),
("DEBUG", Some("true")),
("OPT_LEVEL", Some("1")),
("TARGET", Some("x86_64-unknown-linux-gnu"))
], || {
let cargo = Cargo::all_cargo();
Emitter::default().add_instructions(&cargo)?.emit()?;
});Emit some of the cargo instructions
temp_env::with_vars([
("OPT_LEVEL", Some("1")),
("TARGET", Some("x86_64-unknown-linux-gnu"))
], || {
let cargo = Cargo::builder().opt_level(true).build();
Emitter::default().add_instructions(&cargo)?.emit()?;
});Override output with your own value
fn main() -> Result<()> {
temp_env::with_vars([
("CARGO_FEATURE_BUILD", Some("")),
("VERGEN_CARGO_DEBUG", Some("my own debug value")),
("OPT_LEVEL", Some("1")),
("TARGET", Some("x86_64-unknown-linux-gnu"))
], || {
let cargo = Cargo::all_cargo();
Emitter::default().add_instructions(&cargo)?.emit()?;
});Implementations§
Trait Implementations§
Source§impl Add for Cargo
impl Add for Cargo
Source§fn add_map_entries(
&self,
_idempotent: bool,
cargo_rustc_env: &mut BTreeMap<VergenKey, String>,
_cargo_rerun_if_changed: &mut Vec<String>,
_cargo_warning: &mut Vec<String>,
) -> Result<(), Error>
fn add_map_entries( &self, _idempotent: bool, cargo_rustc_env: &mut BTreeMap<VergenKey, String>, _cargo_rerun_if_changed: &mut Vec<String>, _cargo_warning: &mut Vec<String>, ) -> Result<(), Error>
Try to add instructions entries to the various given arguments. Read more
Source§fn add_default_entries(
&self,
config: &DefaultConfig,
cargo_rustc_env_map: &mut BTreeMap<VergenKey, String>,
_cargo_rerun_if_changed: &mut Vec<String>,
cargo_warning: &mut Vec<String>,
) -> Result<(), Error>
fn add_default_entries( &self, config: &DefaultConfig, cargo_rustc_env_map: &mut BTreeMap<VergenKey, String>, _cargo_rerun_if_changed: &mut Vec<String>, cargo_warning: &mut Vec<String>, ) -> Result<(), Error>
Based on the given configuration, emit either default idempotent output or generate a failue. Read more
impl Copy for Cargo
impl StructuralPartialEq for Cargo
Auto Trait Implementations§
impl Freeze for Cargo
impl RefUnwindSafe for Cargo
impl Send for Cargo
impl Sync for Cargo
impl Unpin for Cargo
impl UnwindSafe for Cargo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more