tauri_plugin_system_info/
lib.rs

1use tauri::{
2    plugin::{Builder, TauriPlugin},
3    Manager, Runtime,
4};
5
6use std::{collections::HashMap, sync::Mutex};
7
8pub mod commands;
9#[cfg(desktop)]
10mod desktop;
11mod error;
12#[cfg(mobile)]
13mod mobile;
14pub mod model;
15pub mod utils;
16
17pub use error::{Error, Result};
18
19pub use utils::SysInfoState;
20
21#[cfg(desktop)]
22use desktop::SysInfo;
23#[cfg(mobile)]
24use mobile::SysInfo;
25
26/// Initializes the plugin.
27pub fn init<R: Runtime>() -> TauriPlugin<R> {
28    Builder::new("system-info")
29        .invoke_handler(tauri::generate_handler![
30            commands::all_sys_info,
31            // memory
32            commands::memory::total_memory,
33            commands::memory::used_memory,
34            commands::memory::total_swap,
35            commands::memory::used_swap,
36            commands::memory::memory_info,
37            // static info
38            commands::static_info::hostname,
39            commands::static_info::name,
40            commands::static_info::kernel_version,
41            commands::static_info::os_version,
42            commands::static_info::static_info,
43            // componenets
44            commands::component::components,
45            // cpu
46            commands::cpu::cpus,
47            commands::cpu::cpu_count,
48            commands::cpu::cpu_info,
49            // disk
50            commands::disk::disks,
51            // networks
52            commands::network::networks,
53            // processes
54            commands::process::processes,
55            // refresh
56            commands::refresh::refresh_all,
57            commands::refresh::refresh_memory,
58            commands::refresh::refresh_cpu,
59            commands::refresh::refresh_processes,
60            commands::battery::batteries,
61        ])
62        .setup(|app, api| {
63            #[cfg(mobile)]
64            let system_info = mobile::init(app, api)?;
65            #[cfg(desktop)]
66            // let system_info = desktop::init(app, api)?;
67            // app.manage(system_info);
68            app.manage(SysInfoState::default());
69
70            Ok(())
71        })
72        .build()
73}