项目作者: marirs

项目描述 :
Rust System Information crate
高级语言: Rust
项目地址: git://github.com/marirs/systeminfo-rs.git
创建时间: 2021-05-17T03:09:01Z
项目社区:https://github.com/marirs/systeminfo-rs

开源协议:MIT License

下载


systeminfo

Build Status

Get the System Hardware & Operating System information.

Usage

  1. [dependencies]
  2. systeminfo = { git = "https://github.com/marirs/systeminfo-rs", branch = "main" }

and then

  1. use systeminfo;
  2. fn main() {
  3. let sysinfo = systeminfo::from_system_hardware();
  4. println!("{:#?}", sysinfo);
  5. let osinfo = systeminfo::from_system_os();
  6. println!("{:#?}", osinfo);
  7. }

If you want to return the object:

  1. use systeminfo::{
  2. consts::SystemHardware,
  3. from_system_hardware
  4. };
  5. fn get_hw_info() -> SystemHardware {
  6. from_system_hardware()
  7. }
  8. fn main() {
  9. println!("{:#?}", get_hw_info())
  10. }

Running the example

  1. cargo b --example info

Example Output

  • macOS

    1. SystemHardware {
    2. system_manufacturer: "Apple",
    3. system_model: "MacBookPro15,2 (MacBook Pro)",
    4. serial_number: "C02Z90HQLVDL",
    5. bios: "1554.60.15.0.0 (iBridge: 18.16.13030.0.0,0)",
    6. physical_memory: "16 GB",
    7. processor: "Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz",
    8. architecture: "x86_64",
    9. processor_vendor: "GenuineIntel",
    10. processor_physical_cpus: "4",
    11. processor_logical_cpus: "8",
    12. processor_features: [
    13. "FPU",
    14. ...
    15. ],
    16. }
    17. SystemOS {
    18. os: "macOS",
    19. kernel: "20.2.0",
    20. edition: "macOS Big Sur",
    21. version: "11.1",
    22. architecture: "64-bit",
    23. hostname: "chocolate",
    24. ip_address: "192.168.0.115",
    25. }
  • Linux

    1. SystemHardware {
    2. system_manufacturer: "Raspberry Pi 4 Model B Rev 1.4",
    3. system_model: "",
    4. serial_number: "10000000f62c0f0d",
    5. bios: "",
    6. physical_memory: "8 GB",
    7. processor: "Cortex-A72",
    8. architecture: "aarch64",
    9. processor_vendor: "ARM",
    10. processor_physical_cpus: "4",
    11. processor_logical_cpus: "4",
    12. processor_features: [
    13. "FP",
    14. ...
    15. ],
    16. }
    17. SystemOS {
    18. os: "Ubuntu",
    19. kernel: "Linux 5.11.0-1008-raspi",
    20. edition: "HIRSUTE",
    21. version: "21.04 (Hirsute Hippo)",
    22. architecture: "64-bit",
    23. hostname: "chocolate",
    24. ip_address: "192.168.0.116",
    25. }
  • Windows
    1. SystemHardware {
    2. system_manufacturer: "VMware, Inc.",
    3. system_model: "VMware Virtual Platform",
    4. serial_number: "43 2e 97 b3 5e",
    5. bios: "PhoenixBIOS 4.0 Release 6.0 (Wed, 22 Jul 2020 00:00:00 +0000)",
    6. physical_memory: "2.15 GB",
    7. processor: "Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz",
    8. architecture: "X86-based PC",
    9. processor_vendor: "GenuineIntel",
    10. processor_physical_cpus: "1",
    11. processor_logical_cpus: "2",
    12. processor_features: [],
    13. }
    14. SystemOS {
    15. os: "Microsoft Windows",
    16. kernel: "19041",
    17. edition: "Windows 10 Pro",
    18. version: "10.0.19041",
    19. architecture: "32-bit",
    20. hostname: "DESKTOP-G089JUF",
    21. ip_address: "192.168.0.114",
    22. }

Requirements

  • Rust 1.52+

Supports & Tested on

  • macOS
  • Windows
  • Linux

License: MIT