use pile_config::Label; use smartstring::{LazyCompact, SmartString}; use std::{collections::HashMap, sync::Arc}; use crate::{source::DirDataSource, value::PileValue}; // // MARK: item // /// A cheaply-cloneable pointer to an item in a dataset #[derive(Clone)] pub enum Item { File { key: SmartString, source: Arc, files: HashMap, }, } impl std::fmt::Debug for Item { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::File { key, files, .. } => f .debug_struct("Item::File") .field("key", key) .field("files", &files.keys().collect::>()) .finish(), } } } impl Item { pub fn source_name(&self) -> &pile_config::Label { match self { Self::File { source, .. } => &source.name, } } pub fn key(&self) -> SmartString { match self { Self::File { key, .. } => key.clone(), } } }