AppDetails

Struct AppDetails 

Source
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 is true.
  • 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

Source

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.

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 application hasn’t registered its details, 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 application hasn’t registered its details, 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 application hasn’t registered its details, 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 couldn’t be detected, this will return "unknown".

Source

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

Source

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

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 aren’t related to versioned artifacts intended for public release.

If the development build flag couldn’t 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), 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".

Trait Implementations§

Source§

impl Serialize for AppDetails

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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.