mercur 0.1.5

mercur - junolang package manager
use std::{collections::HashMap, fs::File, io::Read, path::Path};

use serde::{Deserialize, Serialize};


#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MercurLock {
    #[serde(rename = "package")]
    pub packages: Vec<MercurLockPackage>
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MercurLockPackage {
    pub authority: String,
    pub namespace: String,
    pub name: String,
    pub version: String,
    #[serde(rename = "ref")]
    pub reference: String,
    pub hash: Option<String>,
    pub sign: Option<String>,
    
}


pub fn parse_mercur_lock(path: &Path) -> anyhow::Result<MercurLock> {
    let buf: &mut String = &mut String::new();
    File::open(path)?.read_to_string(buf)?;
    let mercur_lock: MercurLock = toml::from_str(buf)?;
    Ok(mercur_lock)
}