use std::path::Path; use serde::de::DeserializeOwned; use crate::cli::cli::OutputFormat; use crate::system::model::HistoryLine; use crate::system::Position; pub mod boxcount; pub mod render; pub fn read(path: &Path, format: OutputFormat) -> Vec where T: DeserializeOwned { match format { OutputFormat::FullDataJson => read_json(path), OutputFormat::Positions => read_csv(path) } } pub fn read_json(path: &Path) -> Vec where T: DeserializeOwned { serde_json::from_reader::<_, Vec>>(File::open(path).expect("Failed to open file")) .expect("Failed to read json") .iter() .map(|l| (l.position.clone())) .collect::>() } pub fn read_csv(path: &Path) -> Vec where T: DeserializeOwned { csv::Reader::from_path(path).expect("Failed to read positions csv").deserialize::() .collect::, _>>() .unwrap() }