1use std::ffi::OsStr;
2use std::fmt;
3use std::path::Path;
4
5use heim_common::prelude::*;
6
7use crate::{sys, FileSystem};
8
9pub struct Partition(sys::Partition);
17
18wrap!(Partition, sys::Partition);
19
20impl Partition {
21 pub fn device(&self) -> Option<&OsStr> {
23 self.as_ref().device()
24 }
25
26 pub fn mount_point(&self) -> &Path {
28 self.as_ref().mount_point()
29 }
30
31 pub fn file_system(&self) -> &FileSystem {
33 self.as_ref().file_system()
34 }
35}
36
37impl fmt::Debug for Partition {
38 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
39 f.debug_struct("Partition")
40 .field("device", &self.device())
41 .field("mount_point", &self.mount_point())
42 .field("file_system", &self.file_system())
43 .finish()
44 }
45}
46
47pub fn partitions() -> impl Stream<Item = Result<Partition>> {
54 sys::partitions().map_ok(Into::into)
55}
56
57pub fn partitions_physical() -> impl Stream<Item = Result<Partition>> {
61 sys::partitions_physical().map_ok(Into::into)
62}