1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
use js_sys::{JsString, Object}; use wasm_bindgen::prelude::*; #[wasm_bindgen] extern { #[wasm_bindgen(extends = Object)] #[derive(Clone, Debug)] pub type CpuInfo; #[wasm_bindgen(method, getter)] pub fn model(this: &CpuInfo) -> JsString; #[wasm_bindgen(method, getter)] pub fn speed(this: &CpuInfo) -> f64; #[wasm_bindgen(method, getter)] pub fn times(this: &CpuInfo) -> CpuInfoTimes; } #[wasm_bindgen] extern { #[wasm_bindgen(extends = Object)] #[derive(Clone, Debug)] pub type CpuInfoTimes; #[wasm_bindgen(method, getter)] pub fn idle(this: &CpuInfoTimes) -> f64; #[wasm_bindgen(method, getter)] pub fn irq(this: &CpuInfoTimes) -> f64; #[wasm_bindgen(method, getter)] pub fn nice(this: &CpuInfoTimes) -> f64; #[wasm_bindgen(method, getter)] pub fn sys(this: &CpuInfoTimes) -> f64; #[wasm_bindgen(method, getter)] pub fn user(this: &CpuInfoTimes) -> f64; }