From d5108907968ffb98e035295ced48199c26e2932d Mon Sep 17 00:00:00 2001 From: Jasper Bekkers Date: Tue, 9 Jul 2024 20:54:05 +0200 Subject: [PATCH] json --- Cargo.lock | 24 ++++++++++++++++++++++++ Cargo.toml | 3 +++ examples/info.rs | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index b27790f..b5921dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,6 +86,7 @@ dependencies = [ "bytemuck", "cc", "serde", + "serde_json", ] [[package]] @@ -128,6 +129,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + [[package]] name = "lazy_static" version = "1.5.0" @@ -272,6 +279,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + [[package]] name = "serde" version = "1.0.204" @@ -292,6 +305,17 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "shlex" version = "1.3.0" diff --git a/Cargo.toml b/Cargo.toml index 6af8d2e..daf1d94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ generate_bindings = ["dep:bindgen"] bytemuck = "1" serde = { version = "1", features = ["derive", "rc"] } +[dev-dependencies] +serde_json = "1" + [build-dependencies] bindgen = { version = "0.69", optional = true } cc = "1.0.83" diff --git a/examples/info.rs b/examples/info.rs index 6038b41..e37e995 100644 --- a/examples/info.rs +++ b/examples/info.rs @@ -2,5 +2,5 @@ use cpuinfo_rs::CpuInfo; fn main() { let info = CpuInfo::new(); - let _ = std::fs::write("info.txt", format!("{:#?}", info.processors())); + let _ = std::fs::write("info.txt", serde_json::to_string(&info.processors()).unwrap()); }