use std::path::Path; #[cfg(test)] pub mod tests; pub mod store; pub mod song; pub mod playlist; pub mod query; pub type Result = anyhow::Result; pub struct Manifest { store: Box, } impl Manifest { pub fn new(p: &Path) -> Result{ let mut store = ST::empty(); if p.exists() { store.load_from(p)?; } else { store.save_to(p)?; } store.save_original_path(p); Ok(Self { store: Box::new(store) }) } pub fn store(&self) -> &ST { self.store.as_ref() } pub fn store_mut(&mut self) -> &mut ST { self.store.as_mut() } pub fn save(&self) -> Result<()> { self.store().save_to(self.store().get_original_path())?; Ok(()) } pub fn load(&mut self) -> Result<()> { let p = self.store().get_original_path().to_path_buf(); self.store_mut().load_from(&p)?; Ok(()) } }