AppDetails

Struct AppDetails 

Source
pub struct AppDetails { /* private fields */ }
Expand description

Application details.

§Configuration

This struct is generated at build time and contains information about the detected application name and version based on detected environment variables. The following environment variables are used:

  • APP_FULL_NAME: Application’s full name. If this is not set, the default value is “unknown”.
  • APP_SHORT_NAME: Application’s short name. If this is not set, the default value is “unknown”.
  • APP_IDENTIFIER: Application’s identifier. If this is not set, the default value is “unknown”.
  • APP_VERSION: Version of the application. If this is not set, the default value is “0.0.0”.
  • APP_GIT_HASH: Git hash of the application. If this is not set, the default value is “unknown”.
  • APP_BUILD_TIME: Build time of the application. If this is not set, the default value is “0000-00-00 00:00:00”.
  • APP_DEV_BUILD: Whether the application is a development build. If this is not set, the default value is true.
  • TARGET: Target architecture of the application. If this is not 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.

The version string will be treated as a semantic version, and will be split on periods to extract the major, minor, and patch numbers. Additionally, the patch number will be split on hyphens to remove any pre-release or build metadata.

Implementations§

Source§

impl AppDetails

Source

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 full name could not be detected, this will return “unknown”.

Source

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 short name could not be detected, this will return “unknown”.

Source

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 identifier could not be detected, this will return “unknown”.

Source

pub fn git_hash(&self) -> &'static str

Returns the Git hash used to build the application.

If the Git hash could not be detected, this will return “unknown”.

Source

pub fn version(&self) -> &Version

Returns the application’s version.

If the version could not be detected, this will return a version equivalent to 0.0.0.

Source

pub fn build_time(&self) -> &'static str

Returns the build time of the application.

If the build time could not be detected, this will return “0000-00-00 00:00:00”.

Source

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 are not related to versioned artifacts intended for public release.

If the development build flag could not be detected, this will return true.

Source

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), the “vendor” (“apple”, “pc”, etc), the 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 could not be detected, this will return “unknown-arch”.

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