summaryrefslogtreecommitdiffstats
path: root/vendor/sysinfo/src/freebsd/cpu.rs
blob: 9d6c8e506f5542a0dfa7da388603355c9d621ca4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::CpuExt;

#[doc = include_str!("../../md_doc/cpu.md")]
pub struct Cpu {
    pub(crate) cpu_usage: f32,
    name: String,
    pub(crate) vendor_id: String,
    pub(crate) frequency: u64,
}

impl Cpu {
    pub(crate) fn new(name: String, vendor_id: String, frequency: u64) -> Cpu {
        Cpu {
            cpu_usage: 0.,
            name,
            vendor_id,
            frequency,
        }
    }
}

impl CpuExt for Cpu {
    fn cpu_usage(&self) -> f32 {
        self.cpu_usage
    }

    fn name(&self) -> &str {
        &self.name
    }

    fn frequency(&self) -> u64 {
        self.frequency
    }

    fn vendor_id(&self) -> &str {
        &self.vendor_id
    }

    fn brand(&self) -> &str {
        ""
    }
}