1use std::fmt;
2
3use heim_common::prelude::*;
4use heim_common::units::Information;
5
6use crate::sys;
7
8pub struct Swap(sys::Swap);
15
16wrap!(Swap, sys::Swap);
17
18impl Swap {
19 pub fn total(&self) -> Information {
21 self.0.total()
22 }
23
24 pub fn used(&self) -> Information {
26 self.0.used()
27 }
28
29 pub fn free(&self) -> Information {
31 self.0.free()
32 }
33}
34
35impl fmt::Debug for Swap {
36 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
37 f.debug_struct("Swap")
38 .field("total", &self.total())
39 .field("used", &self.used())
40 .field("free", &self.free())
41 .finish()
42 }
43}
44
45pub fn swap() -> impl Future<Output = Result<Swap>> {
49 sys::swap().map(|res| res.map(Into::into))
50}