Replace system info dependency
This commit is contained in:
parent
3481551926
commit
c85d807942
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -936,7 +936,6 @@ dependencies = [
|
|||||||
"egui_extras",
|
"egui_extras",
|
||||||
"git2",
|
"git2",
|
||||||
"json",
|
"json",
|
||||||
"lazy_static",
|
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
"rand",
|
"rand",
|
||||||
"rayon",
|
"rayon",
|
||||||
@ -944,7 +943,6 @@ dependencies = [
|
|||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sys-info",
|
|
||||||
"sysinfo",
|
"sysinfo",
|
||||||
"toml",
|
"toml",
|
||||||
"toml_edit",
|
"toml_edit",
|
||||||
@ -2906,16 +2904,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sys-info"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sysinfo"
|
name = "sysinfo"
|
||||||
version = "0.29.7"
|
version = "0.29.7"
|
||||||
|
@ -21,10 +21,8 @@ rand = "0.8.5"
|
|||||||
chrono = "0.4.26"
|
chrono = "0.4.26"
|
||||||
eframe = "0.22.0"
|
eframe = "0.22.0"
|
||||||
trash = "3.0.3"
|
trash = "3.0.3"
|
||||||
lazy_static = "1.4.0"
|
|
||||||
rayon = "1.7.0"
|
rayon = "1.7.0"
|
||||||
serde = { version = "1.0.171", features = ["derive"] }
|
serde = { version = "1.0.171", features = ["derive"] }
|
||||||
sys-info = "0.9.1"
|
|
||||||
sysinfo = "0.29.6"
|
sysinfo = "0.29.6"
|
||||||
toml = "0.7.6"
|
toml = "0.7.6"
|
||||||
toml_edit = "0.19.14"
|
toml_edit = "0.19.14"
|
||||||
|
@ -281,12 +281,6 @@ impl From<serde_json::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<sys_info::Error> for Error {
|
|
||||||
fn from(value: sys_info::Error) -> Self {
|
|
||||||
Error::MacroFailure(value.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<SystemTimeError> for Error {
|
impl From<SystemTimeError> for Error {
|
||||||
fn from(value: SystemTimeError) -> Self {
|
fn from(value: SystemTimeError) -> Self {
|
||||||
Error::MacroFailure(value.to_string())
|
Error::MacroFailure(value.to_string())
|
||||||
|
@ -97,7 +97,7 @@ pub const TOOL_LIST: [&'static dyn Tool; 51] = [
|
|||||||
&random::RandomFloat,
|
&random::RandomFloat,
|
||||||
&random::RandomInteger,
|
&random::RandomInteger,
|
||||||
&random::RandomString,
|
&random::RandomString,
|
||||||
&system::CpuSpeed,
|
&system::Users,
|
||||||
&logic::Assert,
|
&logic::Assert,
|
||||||
&logic::AssertEqual,
|
&logic::AssertEqual,
|
||||||
&time::Local,
|
&time::Local,
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
use sys_info::cpu_speed;
|
use sysinfo::{RefreshKind, System, SystemExt, UserExt};
|
||||||
|
|
||||||
use crate::{Result, Tool, ToolInfo, Value, ValueType};
|
use crate::{Result, Tool, ToolInfo, Value, ValueType};
|
||||||
|
|
||||||
pub struct CpuSpeed;
|
pub struct Users;
|
||||||
|
|
||||||
impl Tool for CpuSpeed {
|
impl Tool for Users {
|
||||||
fn info(&self) -> ToolInfo<'static> {
|
fn info(&self) -> ToolInfo<'static> {
|
||||||
ToolInfo {
|
ToolInfo {
|
||||||
identifier: "cpu_speed",
|
identifier: "users",
|
||||||
description: "Return the current processor speed in megahertz.",
|
description: "Get a list of the system's users.",
|
||||||
group: "system",
|
group: "system",
|
||||||
inputs: vec![ValueType::Empty],
|
inputs: vec![ValueType::Empty],
|
||||||
}
|
}
|
||||||
@ -17,8 +17,12 @@ impl Tool for CpuSpeed {
|
|||||||
fn run(&self, argument: &Value) -> Result<Value> {
|
fn run(&self, argument: &Value) -> Result<Value> {
|
||||||
argument.as_empty()?;
|
argument.as_empty()?;
|
||||||
|
|
||||||
let speed = cpu_speed().unwrap_or_default() as i64;
|
let users = System::new_with_specifics(RefreshKind::new().with_users_list())
|
||||||
|
.users()
|
||||||
|
.iter()
|
||||||
|
.map(|user| Value::String(user.name().to_string()))
|
||||||
|
.collect();
|
||||||
|
|
||||||
Ok(Value::Integer(speed))
|
Ok(Value::List(users))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user