index : license-api-rs.git

ascending towards madness

use std::path::Path;

use serde::Deserialize;

#[derive(Debug, Deserialize)]
pub struct LicenseDatabase {
    pub licenses: Vec<License>,
}

impl LicenseDatabase {
    pub fn load_file(file: &Path) -> LicenseDatabase {
        let file_contents = std::fs::read_to_string(file).unwrap();
        let database: LicenseDatabase = serde_yaml::from_str(&file_contents).unwrap();

        database
    }
}

#[derive(Debug, Deserialize, Clone)]
pub struct License {
    pub id: String,
    pub filename: String,
    pub description: String,
}