pub struct Os {
id: IdentifierString,
version_id: Option<IdentifierString>,
variant_id: Option<IdentifierString>,
image_id: Option<IdentifierString>,
image_version: Option<IdentifierString>,
}Expand description
The Os identifier is used to uniquely identify an Operating System (OS), it relies on data
provided by os-release.
§Format
An Os identifier consists of up to five parts. Each part of the identifier can consist of the characters “0–9”, “a–z”, “.”, “_” and “-”.
In the filesystem, the parts are concatenated into one path using : (colon) symbols
(e.g. debian:12:server:company-x:25.01).
Trailing colons must be omitted for all parts that are unset
(e.g. arch instead of arch::::).
However, colons for intermediate parts must be included.
(e.g. debian:12:::25.01).
See https://uapi-group.org/specifications/specs/file_hierarchy_for_the_verification_of_os_artifacts/#os
Fields§
§id: IdentifierString§version_id: Option<IdentifierString>§variant_id: Option<IdentifierString>§image_id: Option<IdentifierString>§image_version: Option<IdentifierString>Implementations§
Source§impl Os
impl Os
Sourcepub fn new(
id: IdentifierString,
version_id: Option<IdentifierString>,
variant_id: Option<IdentifierString>,
image_id: Option<IdentifierString>,
image_version: Option<IdentifierString>,
) -> Self
pub fn new( id: IdentifierString, version_id: Option<IdentifierString>, variant_id: Option<IdentifierString>, image_id: Option<IdentifierString>, image_version: Option<IdentifierString>, ) -> Self
Creates a new operating system identifier.
§Examples
use voa_core::identifiers::Os;
// Arch Linux is a rolling release distribution.
Os::new("arch".parse()?, None, None, None, None);
// This Debian system is a special purpose image-based OS.
Os::new(
"debian".parse()?,
Some("12".parse()?),
Some("workstation".parse()?),
Some("cashier-system".parse()?),
Some("1.0.0".parse()?),
);Sourcefn os_to_string(&self) -> String
fn os_to_string(&self) -> String
A String representation of this Os specifier.
All parts are joined with :, trailing colons are omitted.
Parts that are unset are represented as empty strings.
This function produces the exact representation specified in https://uapi-group.org/specifications/specs/file_hierarchy_for_the_verification_of_os_artifacts/#os
Sourcepub(crate) fn path_segment(&self) -> PathBuf
pub(crate) fn path_segment(&self) -> PathBuf
A PathBuf representation of this Os specifier.
All parts are joined with :, trailing colons are omitted.
Parts that are unset are represented as empty strings.
Sourcepub fn parser(input: &mut &str) -> ModalResult<Self>
pub fn parser(input: &mut &str) -> ModalResult<Self>
Recognizes an Os in a string slice.
Relies on [winnow] to parse input and recognizes the id, and the optional
version_id, variant_id, image_id and image_version components.
§Errors
Returns an error, if
- detection of one of the
Oscomponents fails, - or there is a trailing colon (
:) character.
§Examples
use voa_core::identifiers::Os;
use winnow::Parser;
Os::parser.parse("arch")?;
Os::parser.parse("debian:13:test-system:test-image:2025.01")?;