[][src]Struct proc_getter::cpuinfo::CpuInfo

pub struct CpuInfo(_);

represent an entry in /proc/cpuinfo

There are some common fileds can be retrived by the same name method, other fileds should retrvie from inner HashMap.

use proc_getter::cpuinfo::*;

let info = cpuinfo().unwrap();
assert_eq!(info[0].cpu_family(), info[0].get("cpu family").unwrap());Run

Methods

impl CpuInfo[src]

pub fn processor(&self) -> usize[src]

pub fn cpu_family(&self) -> &str[src]

pub fn model_name(&self) -> &str[src]

pub fn cpu_mhz(&self) -> f64[src]

pub fn cache_size(&self) -> &str[src]

pub fn siblings(&self) -> usize[src]

pub fn flags(&self) -> Vec<&str>[src]

Methods from Deref<Target = HashMap<String, String>>

pub fn capacity(&self) -> usize1.0.0[src]

Returns the number of elements the map can hold without reallocating.

This number is a lower bound; the HashMap<K, V> might be able to hold more, but is guaranteed to be able to hold at least this many.

Examples

use std::collections::HashMap;
let map: HashMap<i32, i32> = HashMap::with_capacity(100);
assert!(map.capacity() >= 100);Run

pub fn keys(&self) -> Keys<K, V>1.0.0[src]

An iterator visiting all keys in arbitrary order. The iterator element type is &'a K.

Examples

use std::collections::HashMap;

let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);

for key in map.keys() {
    println!("{}", key);
}Run

pub fn values(&self) -> Values<K, V>1.0.0[src]

An iterator visiting all values in arbitrary order. The iterator element type is &'a V.

Examples

use std::collections::HashMap;

let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);

for val in map.values() {
    println!("{}", val);
}Run

pub fn iter(&self) -> Iter<K, V>1.0.0[src]

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a K, &'a V).

Examples

use std::collections::HashMap;

let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);

for (key, val) in map.iter() {
    println!("key: {} val: {}", key, val);
}Run

pub fn len(&self) -> usize1.0.0[src]

Returns the number of elements in the map.

Examples

use std::collections::HashMap;

let mut a = HashMap::new();
assert_eq!(a.len(), 0);
a.insert(1, "a");
assert_eq!(a.len(), 1);Run

pub fn is_empty(&self) -> bool1.0.0[src]

Returns true if the map contains no elements.

Examples

use std::collections::HashMap;

let mut a = HashMap::new();
assert!(a.is_empty());
a.insert(1, "a");
assert!(!a.is_empty());Run

pub fn hasher(&self) -> &S1.9.0[src]

Returns a reference to the map's BuildHasher.

Examples

use std::collections::HashMap;
use std::collections::hash_map::RandomState;

let hasher = RandomState::new();
let map: HashMap<i32, i32> = HashMap::with_hasher(hasher);
let hasher: &RandomState = map.hasher();Run

pub fn get<Q>(&self, k: &Q) -> Option<&V> where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
1.0.0[src]

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

Examples

use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.get(&1), Some(&"a"));
assert_eq!(map.get(&2), None);Run

pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)> where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
1.40.0[src]

Returns the key-value pair corresponding to the supplied key.

The supplied key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

Examples

use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.get_key_value(&1), Some((&1, &"a")));
assert_eq!(map.get_key_value(&2), None);Run

pub fn contains_key<Q>(&self, k: &Q) -> bool where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
1.0.0[src]

Returns true if the map contains a value for the specified key.

The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

Examples

use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.contains_key(&1), true);
assert_eq!(map.contains_key(&2), false);Run

pub fn raw_entry(&self) -> RawEntryBuilder<K, V, S>[src]

🔬 This is a nightly-only experimental API. (hash_raw_entry)

Creates a raw immutable entry builder for the HashMap.

Raw entries provide the lowest level of control for searching and manipulating a map. They must be manually initialized with a hash and then manually searched.

This is useful for

  • Hash memoization
  • Using a search key that doesn't work with the Borrow trait
  • Using custom comparison logic without newtype wrappers

Unless you are in such a situation, higher-level and more foolproof APIs like get should be preferred.

Immutable raw entries have very limited use; you might instead want raw_entry_mut.

Trait Implementations

impl Debug for CpuInfo[src]

impl FromStr for CpuInfo[src]

type Err = Error

The associated error which can be returned from parsing.

impl Deref for CpuInfo[src]

type Target = HashMap<String, String>

The resulting type after dereferencing.

Auto Trait Implementations

impl Send for CpuInfo

impl Sync for CpuInfo

impl Unpin for CpuInfo

impl UnwindSafe for CpuInfo

impl RefUnwindSafe for CpuInfo

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]