use std::path::Path;
use serde::Serialize;
use serde::de::DeserializeOwned;
pub mod capture;
pub mod isolated_replay;
pub fn store_computed_layout<ElementsOutput: Clone + Serialize>(
res: &Vec<ElementsOutput>,
file: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
let bytes = serde_json::to_vec(res)?;
std::fs::write(file, bytes)?;
Ok(())
}
pub fn load_computed_layout<ElementsOutput: Clone + DeserializeOwned>(
file: &Path,
) -> Result<Vec<ElementsOutput>, Box<dyn std::error::Error>> {
let bytes = std::fs::read(file)?;
let serialized: Vec<ElementsOutput> = serde_json::from_slice(&bytes)?;
Ok(serialized)
}