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>,
) -> Os
pub fn new( id: IdentifierString, version_id: Option<IdentifierString>, variant_id: Option<IdentifierString>, image_id: Option<IdentifierString>, image_version: Option<IdentifierString>, ) -> Os
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()?),
);Sourcepub fn os_to_string(&self) -> String
pub 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 fn parser(input: &mut &str) -> Result<Os, ErrMode<ContextError>>
pub fn parser(input: &mut &str) -> Result<Os, ErrMode<ContextError>>
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")?;Trait Implementations§
Source§impl<'de> Deserialize<'de> for Os
impl<'de> Deserialize<'de> for Os
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Os, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Os, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Os
impl Ord for Os
Source§impl PartialOrd for Os
impl PartialOrd for Os
Source§impl Serialize for Os
impl Serialize for Os
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Os
impl StructuralPartialEq for Os
Auto Trait Implementations§
impl Freeze for Os
impl RefUnwindSafe for Os
impl Send for Os
impl Sync for Os
impl Unpin for Os
impl UnwindSafe for Os
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString]. Read more