deja-vu/core/src/system/cpu.rs
2025-02-09 14:50:45 -08:00

26 lines
1,008 B
Rust

// This file is part of Deja-Vu.
//
// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Deja-Vu. If not, see <https://www.gnu.org/licenses/>.
//
#[must_use]
pub fn get_cpu_name() -> String {
let cpuid = raw_cpuid::CpuId::new();
if let Some(name) = cpuid.get_processor_brand_string() {
String::from(name.as_str())
} else if let Some(vendor) = cpuid.get_vendor_info() {
format!("{vendor}: Unknown Model")
} else {
String::from("Unknown")
}
}