sys_info

Struct LinuxOSReleaseInfo

Source
pub struct LinuxOSReleaseInfo {
Show 18 fields pub id: Option<String>, pub id_like: Option<String>, pub name: Option<String>, pub pretty_name: Option<String>, pub version: Option<String>, pub version_id: Option<String>, pub version_codename: Option<String>, pub ansi_color: Option<String>, pub logo: Option<String>, pub cpe_name: Option<String>, pub build_id: Option<String>, pub variant: Option<String>, pub variant_id: Option<String>, pub home_url: Option<String>, pub documentation_url: Option<String>, pub support_url: Option<String>, pub bug_report_url: Option<String>, pub privacy_policy_url: Option<String>,
}
Expand description

The os release info of Linux.

See man os-release.

Fields§

§id: Option<String>

A lower-case string (no spaces or other characters outside of 0–9, a–z, “.”, “_” and “-”) identifying the operating system, excluding any version information and suitable for processing by scripts or usage in generated filenames.

Note that we don’t verify that the string is lower-case and can be used in file-names. If the /etc/os-release file has an invalid value, you will get this value.

If not set, defaults to “ID=linux”. Use self.id() to fallback to the default.

Example: “fedora” or “debian”.

§id_like: Option<String>

A space-separated list of operating system identifiers in the same syntax as the ID= setting. It should list identifiers of operating systems that are closely related to the local operating system in regards to packaging and programming interfaces, for example listing one or more OS identifiers the local OS is a derivative from. An OS should generally only list other OS identifiers it itself is a derivative of, and not any OSes that are derived from it, though symmetric relationships are possible. Build scripts and similar should check this variable if they need to identify the local operating system and the value of ID= is not recognized. Operating systems should be listed in order of how closely the local operating system relates to the listed ones, starting with the closest.

This field is optional.

Example: for an operating system with ID=centos, an assignment of ID_LIKE="rhel fedora" would be appropriate. For an operating system with ID=ubuntu, an assignment of ID_LIKE=debian is appropriate.

§name: Option<String>

A string identifying the operating system, without a version component, and suitable for presentation to the user.

If not set, defaults to “NAME=Linux”.Use self.id() to fallback to the default.

Example: “Fedora” or “Debian GNU/Linux”.

§pretty_name: Option<String>

A pretty operating system name in a format suitable for presentation to the user. May or may not contain a release code name or OS version of some kind, as suitable.

If not set, defaults to “Linux”. Use self.id() to fallback to the default.

Example: “Fedora 17 (Beefy Miracle)”.

§version: Option<String>

A string identifying the operating system version, excluding any OS name information, possibly including a release code name, and suitable for presentation to the user.

This field is optional.

Example: “17” or “17 (Beefy Miracle)”

§version_id: Option<String>

A lower-case string (mostly numeric, no spaces or other characters outside of 0–9, a–z, “.”, “_” and “-”) identifying the operating system version, excluding any OS name information or release code name, and suitable for processing by scripts or usage in generated filenames.

This field is optional.

Example: “17” or “11.04”.

§version_codename: Option<String>

A lower-case string (no spaces or other characters outside of 0–9, a–z, “.”, “_” and “-”) identifying the operating system release code name, excluding any OS name information or release version, and suitable for processing by scripts or usage in generated filenames.

This field is optional and may not be implemented on all systems.

Examples: “buster”, “xenial”.

§ansi_color: Option<String>

A suggested presentation color when showing the OS name on the console. This should be specified as string suitable for inclusion in the ESC [ m ANSI/ECMA-48 escape code for setting graphical rendition.

This field is optional.

Example: “0;31” for red, “1;34” for light blue, or “0;38;2;60;110;180” for Fedora blue.

A string, specifying the name of an icon as defined by freedesktop.org Icon Theme Specification. This can be used by graphical applications to display an operating system’s or distributor’s logo.

This field is optional and may not necessarily be implemented on all systems.

Examples: “LOGO=fedora-logo”, “LOGO=distributor-logo-opensuse”.

§cpe_name: Option<String>

A CPE name for the operating system, in URI binding syntax, following the Common Platform Enumeration Specification as proposed by the NIST.

This field is optional.

Example: “cpe:/o:fedoraproject:fedora:17”.

§build_id: Option<String>

A string uniquely identifying the system image used as the origin for a distribution (it is not updated with system updates). The field can be identical between different VERSION_IDs as BUILD_ID is an only a unique identifier to a specific version. Distributions that release each update as a new version would only need to use VERSION_ID as each build is already distinct based on the VERSION_ID.

This field is optional.

Example: “2013-03-20.3” or “BUILD_ID=201303203”.

§variant: Option<String>

A string identifying a specific variant or edition of the operating system suitable for presentation to the user. This field may be used to inform the user that the configuration of this system is subject to a specific divergent set of rules or default configuration settings.

This field is optional and may not be implemented on all systems.

Examples: “Server Edition”, “Smart Refrigerator Edition”.

Note: this field is for display purposes only. The VARIANT_ID field should be used for making programmatic decisions.

§variant_id: Option<String>

A lower-case string (no spaces or other characters outside of 0–9, a–z, “.”, “_” and “-”), identifying a specific variant or edition of the operating system. This may be interpreted by other packages in order to determine a divergent default configuration.

This field is optional and may not be implemented on all systems.

Examples: “server”, “embedded”.

§home_url: Option<String>

HOME_URL= should refer to the homepage of the operating system, or alternatively some homepage of the specific version of the operating system.

These URLs are intended to be exposed in “About this system” UIs behind links with captions such as “About this Operating System”, “Obtain Support”, “Report a Bug”, or “Privacy Policy”. The values should be in RFC3986 format, and should be “http:” or “https:” URLs, and possibly “mailto:” or “tel:”. Only one URL shall be listed in each setting. If multiple resources need to be referenced, it is recommended to provide an online landing page linking all available resources.

Example: “https://fedoraproject.org/”.

§documentation_url: Option<String>

DOCUMENTATION_URL= should refer to the main documentation page for this operating system.

See also home_url.

§support_url: Option<String>

SUPPORT_URL= should refer to the main support page for the operating system, if there is any. This is primarily intended for operating systems which vendors provide support for.

See also home_url.

§bug_report_url: Option<String>

BUG_REPORT_URL= should refer to the main bug reporting page for the operating system, if there is any. This is primarily intended for operating systems that rely on community QA.

Example: “https://bugzilla.redhat.com/”.

See also home_url.

§privacy_policy_url: Option<String>

PRIVACY_POLICY_URL= should refer to the main privacy policy page for the operating system, if there is any. These settings are optional, and providing only some of these settings is common.

See also home_url.

Implementations§

Source§

impl LinuxOSReleaseInfo

Source

pub fn id(&self) -> &str

Returns the value of self.id or, if None, “linux” (the default value).

Source

pub fn name(&self) -> &str

Returns the value of self.name or, if None, “Linux” (the default value).

Source

pub fn pretty_name(&self) -> &str

Returns the value of self.pretty_name or, if None, “Linux” (the default value).

Trait Implementations§

Source§

impl Debug for LinuxOSReleaseInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LinuxOSReleaseInfo

Source§

fn default() -> LinuxOSReleaseInfo

Returns the “default value” for a type. 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.