pub struct AppDetails { /* private fields */ }Expand description
Application details.
§Configuration
The name and version fields identify a specific application, so they’re declared by the binary itself through
declare_app_details! and registered with set_app_details. The version comes from that binary’s Cargo
manifest.
The remaining fields describe the build rather than the application, so they’re captured at compile time from the following environment variables:
APP_GIT_HASH: Git hash of the application. If this isn’t set, the default value is"unknown".APP_BUILD_TIME: Build time of the application. If this isn’t set, the default value is"0000-00-00 00:00:00".APP_DEV_BUILD: Whether the application is a development build. If this isn’t set, the default value istrue.TARGET: Target architecture of the application. If this isn’t set, the default value is"unknown-arch".
Environment variables prefixed with APP_ are expected to be set by the build script/tooling, while others are
provided automatically by Cargo.
Implementations§
Source§impl AppDetails
impl AppDetails
Sourcepub const fn new(
full_name: &'static str,
short_name: &'static str,
identifier: &'static str,
version: Version,
) -> Self
pub const fn new( full_name: &'static str, short_name: &'static str, identifier: &'static str, version: Version, ) -> Self
Creates a new AppDetails from the given application identity.
Build metadata is filled in from the values captured at compile time, so callers can’t get it wrong. Prefer
declare_app_details!, which also derives the version from the calling crate’s Cargo manifest.
Sourcepub fn full_name(&self) -> &'static str
pub fn full_name(&self) -> &'static str
Returns the application’s full name.
This is typically a human-friendly/“pretty” name of the binary/executable, such as "Agent Data Plane".
If the application hasn’t registered its details, this will return "unknown".
Sourcepub fn short_name(&self) -> &'static str
pub fn short_name(&self) -> &'static str
Returns the application’s short name.
This is typically a shorter version of the name of the binary/executable, such as "Data Plane" or "DATAPLANE".
If the application hasn’t registered its details, this will return "unknown".
Sourcepub fn identifier(&self) -> &'static str
pub fn identifier(&self) -> &'static str
Returns the application’s identifier.
This is typically a very condensed form of the name of the binary/executable, like an acronym, such as "adp"
or "ADP".
If the application hasn’t registered its details, this will return "unknown".
Sourcepub fn git_hash(&self) -> &'static str
pub fn git_hash(&self) -> &'static str
Returns the Git hash used to build the application.
If the Git hash couldn’t be detected, this will return "unknown".
Sourcepub fn version(&self) -> &Version
pub fn version(&self) -> &Version
Returns the application’s version.
If the application hasn’t registered its details, this will return a version equivalent to "0.0.0".
Sourcepub fn build_time(&self) -> &'static str
pub fn build_time(&self) -> &'static str
Returns the build time of the application.
If the build time couldn’t be detected, this will return "0000-00-00 00:00:00".
Sourcepub fn is_dev_build(&self) -> bool
pub fn is_dev_build(&self) -> bool
Returns true if this application is a development build.
Development builds generally encompass all local builds, and any CI builds which aren’t related to versioned artifacts intended for public release.
If the development build flag couldn’t be detected, this will return true.
Sourcepub fn target_arch(&self) -> &'static str
pub fn target_arch(&self) -> &'static str
Returns the target architecture of the application.
This returns a target triple, which is a string that generally has four components: the processor
architecture (x86-64, ARM64, etc), vendor ("apple", "pc", etc), operating system ("linux", "windows",
"darwin", etc) and environment/ABI ("gnu", "musl", etc).
The environment/ABI component can sometimes be omitted in scenarios where there are no meaningful distinctions for the given operating system.
If the target architecture couldn’t be detected, this will return "unknown-arch".