pub struct Info { /* private fields */ }
Expand description
Holds information about operating system (type, version, etc.).
The best way to get string representation of the operation system information is to use its
Display
implementation.
§Examples
use os_info;
let info = os_info::get();
println!("OS information: {}", info);
Implementations§
Source§impl Info
impl Info
Sourcepub fn unknown() -> Self
pub fn unknown() -> Self
Constructs a new Info
instance with unknown type, version and bitness.
§Examples
use os_info::{Info, Type, Version, Bitness};
let info = Info::unknown();
assert_eq!(Type::Unknown, info.os_type());
assert_eq!(&Version::Unknown, info.version());
assert_eq!(None, info.edition());
assert_eq!(None, info.codename());
assert_eq!(Bitness::Unknown, info.bitness());
Sourcepub fn with_type(os_type: Type) -> Self
pub fn with_type(os_type: Type) -> Self
Constructs a new Info
instance with the specified operating system type.
§Examples
use os_info::{Info, Type, Version, Bitness};
let os_type = Type::Linux;
let info = Info::with_type(os_type);
assert_eq!(os_type, info.os_type());
assert_eq!(&Version::Unknown, info.version());
assert_eq!(None, info.edition());
assert_eq!(None, info.codename());
assert_eq!(Bitness::Unknown, info.bitness());
Sourcepub fn os_type(&self) -> Type
pub fn os_type(&self) -> Type
Returns operating system type. See Type
for details.
§Examples
use os_info::{Info, Type};
let info = Info::unknown();
assert_eq!(Type::Unknown, info.os_type());
Sourcepub fn version(&self) -> &Version
pub fn version(&self) -> &Version
Returns operating system version. See Version
for details.
§Examples
use os_info::{Info, Version};
let info = Info::unknown();
assert_eq!(&Version::Unknown, info.version());
Sourcepub fn edition(&self) -> Option<&str>
pub fn edition(&self) -> Option<&str>
Returns optional operation system edition.
§Examples
use os_info::Info;
let info = Info::unknown();
assert_eq!(None, info.edition());
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Info
impl<'de> Deserialize<'de> for Info
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Info
impl Ord for Info
Source§impl PartialOrd for Info
impl PartialOrd for Info
impl Eq for Info
impl StructuralPartialEq for Info
Auto Trait Implementations§
impl Freeze for Info
impl RefUnwindSafe for Info
impl Send for Info
impl Sync for Info
impl Unpin for Info
impl UnwindSafe for Info
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
Mutably borrows from an owned value. Read more