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
sourceimpl 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
sourceimpl<'de> Deserialize<'de> for Info
impl<'de> Deserialize<'de> for Info
sourcefn 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
sourceimpl Ord for Info
impl Ord for Info
sourceimpl PartialOrd<Info> for Info
impl PartialOrd<Info> for Info
sourcefn partial_cmp(&self, other: &Info) -> Option<Ordering>
fn partial_cmp(&self, other: &Info) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Info
impl StructuralEq for Info
impl StructuralPartialEq for Info
Auto Trait Implementations
impl RefUnwindSafe for Info
impl Send for Info
impl Sync for Info
impl Unpin for Info
impl UnwindSafe for Info
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more