use super::LinkPathList;
use derive_more::{From, Into, IntoIterator};
use pipe_trait::Pipe;
use std::{collections::HashSet, path::PathBuf};
#[cfg(feature = "json")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, PartialEq, Eq, From, Into, IntoIterator)]
#[cfg_attr(feature = "json", derive(Deserialize, Serialize))]
pub struct Reflection(pub HashSet<PathBuf>);
impl Reflection {
#[inline]
pub fn new() -> Self {
Reflection::default()
}
#[inline]
pub fn len(&self) -> usize {
self.0.len()
}
#[inline]
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
impl From<LinkPathList> for Reflection {
fn from(value: LinkPathList) -> Self {
value.0.into_iter().collect::<HashSet<_>>().pipe(Reflection)
}
}
impl From<Reflection> for LinkPathList {
fn from(value: Reflection) -> Self {
value.0.into_iter().collect::<Vec<_>>().pipe(LinkPathList)
}
}