parallel_disk_usage/app/sub/
unix_ext.rs

1use super::HardlinkSubroutines;
2use crate::{
3    data_tree::DataTree, hardlink::HardlinkAware, json_data::JsonShared,
4    os_string_display::OsStringDisplay, runtime_error::RuntimeError, size,
5};
6use pipe_trait::Pipe;
7
8impl<Size> HardlinkSubroutines<Size> for HardlinkAware<Size>
9where
10    DataTree<OsStringDisplay, Size>: Send,
11    Size: size::Size + Sync,
12{
13    fn convert_error(error: Self::Error) -> RuntimeError {
14        match error {}
15    }
16
17    fn print_report(
18        report: Self::Report,
19        bytes_format: Size::DisplayFormat,
20    ) -> Result<(), RuntimeError> {
21        let summary = report.summarize();
22        if summary.inodes > 0 {
23            print!("{}", summary.display(bytes_format)); // the summary already ends with "\n", println! isn't needed here.
24        }
25        Ok(())
26    }
27
28    fn json_report(report: Self::Report) -> Result<Option<JsonShared<Size>>, RuntimeError> {
29        let summary = report.summarize().pipe(Some);
30        let details = report.into_reflection().pipe(Some);
31        Ok(Some(JsonShared { details, summary }))
32    }
33}