#[allow(dead_code)] // Use in main.rs
pub fn get_all<T>(folder: &str) -> anyhow::Result<Vec<T>>
where
    T: TryFrom<String>,
{
    use std::{path::Path, fs::read_dir};

    let mut datas: Vec<T> = Vec::new();

    let folder_path = Path::new("data_src").join(folder);
    let paths = read_dir(folder_path)?;

    for path_result in paths {
        let data : Result<T, String> = path_result
            .and_then(|path| std::fs::File::open(path.path()))
            .map_err(|e| format!("Open file Error: {:?}", e))
            .and_then(|mut file| {
                use std::io::Read;
                let mut content = String::new();
                file.read_to_string(&mut content)
                    .map_err(|e| format!("Read file Error: {:?}", e))?;
                T::try_from(content)
                    .map_err(|_e| "Parse file Error".to_string())
            });

        match data {
            Ok(data) => datas.push(data),
            Err(e) => log::warn!("{}", e),
        }
    }

    Ok(datas)
}