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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
use std::ffi::*; use std::string; use virt; #[derive(Clone)] pub struct NodeInfo { pub ptr: virt::virNodeInfoPtr } impl NodeInfo { pub fn model(self) -> String { unsafe { String::from_utf8_lossy(CStr::from_ptr((*self.ptr).model.as_ptr()).to_bytes()).into_owned() } } pub fn memory(self) -> u64 { unsafe { (*self.ptr).memory } } pub fn cpus(self) -> u32 { unsafe { (*self.ptr).cpus } } pub fn mhz(self) -> u32 { unsafe { (*self.ptr).mhz } } pub fn nodes(self) -> u32 { unsafe { (*self.ptr).mhz } } pub fn sockets(self) -> u32 { unsafe { (*self.ptr).sockets } } pub fn cores(self) -> u32 { unsafe { (*self.ptr).cores } } pub fn threads(self) -> u32 { unsafe { (*self.ptr).threads } } }