Skip to main content

Module os_version

Module os_version 

Source
Available on crate feature sys only.
Expand description

Operating system version type for system information.

This module provides a type-safe abstraction for operating system versions, ensuring valid version number parsing and comparison.

§Version Format

OS versions follow semantic versioning principles:

  • Major: Major version number (e.g., 14 for macOS Sonoma)
  • Minor: Minor version number (e.g., 6 for macOS 14.6)
  • Patch: Patch/build number (e.g., 1 for 14.6.1)

§Examples

use bare_types::sys::OsVersion;

// Parse from string
let version: OsVersion = "14.6.1".parse()?;

// Access components
assert_eq!(version.major(), 14);
assert_eq!(version.minor(), 6);
assert_eq!(version.patch(), Some(1));

// Compare versions
assert!(version >= OsVersion::new(14, 0, None));

// Short version (no patch)
let version: OsVersion = "14.6".parse()?;
assert_eq!(version.patch(), None);

Structs§

OsVersion
Operating system version.

Enums§

OsVersionError
Error type for OS version parsing.