parallel_disk_usage/
device.rs1use derive_more::{Display, From, Into, LowerHex, Octal, UpperHex};
2
3#[cfg(feature = "json")]
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub enum DeviceBoundary {
9 Cross,
10 Stay,
11}
12
13impl DeviceBoundary {
14 #[cfg(feature = "cli")]
16 pub(crate) fn from_one_file_system(one_file_system: bool) -> Self {
17 match one_file_system {
18 false => DeviceBoundary::Cross,
19 true => DeviceBoundary::Stay,
20 }
21 }
22}
23
24#[derive(
26 Debug, Display, LowerHex, UpperHex, Octal, Clone, Copy, PartialEq, Eq, Hash, From, Into,
27)]
28#[cfg_attr(feature = "json", derive(Deserialize, Serialize))]
29pub struct DeviceNumber(u64);
30
31#[cfg(unix)]
33impl DeviceNumber {
34 #[inline]
36 pub fn get(stats: &std::fs::Metadata) -> Self {
37 use pipe_trait::Pipe;
38 use std::os::unix::fs::MetadataExt;
39 stats.dev().pipe(DeviceNumber)
40 }
41}