parallel_disk_usage/hardlink/link_path_list/
reflection.rs1use super::LinkPathList;
2use derive_more::{From, Into, IntoIterator};
3use pipe_trait::Pipe;
4use std::{collections::HashSet, path::PathBuf};
5
6#[cfg(feature = "json")]
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Default, Clone, PartialEq, Eq, From, Into, IntoIterator)]
18#[cfg_attr(feature = "json", derive(Deserialize, Serialize))]
19pub struct Reflection(pub HashSet<PathBuf>);
20
21impl Reflection {
22 #[inline]
24 pub fn new() -> Self {
25 Reflection::default()
26 }
27
28 #[inline]
30 pub fn len(&self) -> usize {
31 self.0.len()
32 }
33
34 #[inline]
36 pub fn is_empty(&self) -> bool {
37 self.0.is_empty()
38 }
39}
40
41impl From<LinkPathList> for Reflection {
42 fn from(value: LinkPathList) -> Self {
43 value.0.into_iter().collect::<HashSet<_>>().pipe(Reflection)
44 }
45}
46
47impl From<Reflection> for LinkPathList {
48 fn from(value: Reflection) -> Self {
49 value.0.into_iter().collect::<Vec<_>>().pipe(LinkPathList)
50 }
51}