pub struct Cargo(/* private fields */);
Expand description
The Cargo
struct serves as a utility for interacting with Cargo-specific environment variables and commands.
Implementations§
Source§impl Cargo
impl Cargo
Sourcepub fn rerun_if_changed(path: impl AsRef<Path>)
pub fn rerun_if_changed(path: impl AsRef<Path>)
Specifies to Cargo that a build script should be re-run if the specified file changes.
Sourcepub fn rerun_if_env_changed(env: impl AsRef<str>)
pub fn rerun_if_env_changed(env: impl AsRef<str>)
Specifies to Cargo that a build script should be re-run if the specified environment variable changes.
Sourcepub fn metadata(key: impl AsRef<str>, value: impl AsRef<str>)
pub fn metadata(key: impl AsRef<str>, value: impl AsRef<str>)
Sets metadata that can be accessed by downstream tools or build scripts.
Sourcepub fn binary_executable_path(
binary_name: impl AsRef<str>,
) -> Result<PathBuf, VarError>
pub fn binary_executable_path( binary_name: impl AsRef<str>, ) -> Result<PathBuf, VarError>
Fetches the path to the binary executable for a specified binary name from the environment variables.
Sourcepub fn is_primary_package() -> bool
pub fn is_primary_package() -> bool
Checks if the package being built is the primary package.
Sourcepub fn binary_path() -> Result<PathBuf, VarError>
pub fn binary_path() -> Result<PathBuf, VarError>
Path to the cargo
binary performing the build
Sourcepub fn manifest_dir() -> Result<PathBuf, VarError>
pub fn manifest_dir() -> Result<PathBuf, VarError>
The directory containing the manifest of your package
Sourcepub fn manifest_path() -> Result<PathBuf, VarError>
pub fn manifest_path() -> Result<PathBuf, VarError>
The path to the manifest of your package
Sourcepub fn pkg_version() -> Result<String, VarError>
pub fn pkg_version() -> Result<String, VarError>
The full version of your package
Sourcepub fn pkg_version_major() -> Result<String, VarError>
pub fn pkg_version_major() -> Result<String, VarError>
The major version of your package
Sourcepub fn pkg_version_minor() -> Result<String, VarError>
pub fn pkg_version_minor() -> Result<String, VarError>
The minor version of your package
Sourcepub fn pkg_version_patch() -> Result<String, VarError>
pub fn pkg_version_patch() -> Result<String, VarError>
The patch version of your package
Sourcepub fn pkg_version_pre() -> Result<String, VarError>
pub fn pkg_version_pre() -> Result<String, VarError>
The pre-release version of your package
Colon separated list of authors from the manifest of your package
Sourcepub fn pkg_description() -> Result<String, VarError>
pub fn pkg_description() -> Result<String, VarError>
The description from the manifest of your package
Sourcepub fn pkg_homepage() -> Result<String, VarError>
pub fn pkg_homepage() -> Result<String, VarError>
The home page from the manifest of your package
Sourcepub fn pkg_repository() -> Result<String, VarError>
pub fn pkg_repository() -> Result<String, VarError>
The repository from the manifest of your package
Sourcepub fn pkg_license() -> Result<String, VarError>
pub fn pkg_license() -> Result<String, VarError>
The license from the manifest of your package
Sourcepub fn pkg_license_file() -> Result<PathBuf, VarError>
pub fn pkg_license_file() -> Result<PathBuf, VarError>
The license file from the manifest of your package
Sourcepub fn pkg_rust_version() -> Result<String, VarError>
pub fn pkg_rust_version() -> Result<String, VarError>
The Rust version from the manifest of your package. Note that this is the minimum Rust version supported by the package, not the current Rust version
Sourcepub fn pkg_readme() -> Result<PathBuf, VarError>
pub fn pkg_readme() -> Result<PathBuf, VarError>
Path to the README file of your package
Sourcepub fn crate_name() -> Result<String, VarError>
pub fn crate_name() -> Result<String, VarError>
The name of the crate that is currently being compiled. It is the name of the Cargo target with - converted to _, such as the name of the library, binary, example, integration test, or benchmark
Sourcepub fn bin_name() -> Result<String, VarError>
pub fn bin_name() -> Result<String, VarError>
The name of the binary that is currently being compiled. Only set for binaries or binary examples. This name does not include any file extension, such as .exe
Sourcepub fn out_dir() -> Result<PathBuf, VarError>
pub fn out_dir() -> Result<PathBuf, VarError>
If the package has a build script, this is set to the folder where the build script should place its output. See below for more information. (Only set during compilation.)
Sourcepub fn target_tmpdir() -> Result<PathBuf, VarError>
pub fn target_tmpdir() -> Result<PathBuf, VarError>
Only set when building integration test or benchmark code. This is a path to a directory inside the target directory where integration tests or benchmarks are free to put any data needed by the tests/benches. Cargo initially creates this directory but doesn’t manage its content in any way, this is the responsibility of the test code
Sourcepub fn rustc_current_dir() -> Result<PathBuf, VarError>
pub fn rustc_current_dir() -> Result<PathBuf, VarError>
This is a path that rustc is invoked from (nightly only)