vios_app 0.1.1

Small JSON vaults: Argon2id + AES-GCM, with optional AAD binding.
Documentation
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::Write;
use std::path::Path;

#[derive(Serialize, Deserialize, Debug)]
pub struct VaultLicense {
    pub rights: String,
    pub royalty_percent: u8,
    pub creator_wallet: String,
    pub expiration: Option<String>, // ISO 8601 e.g., "2026-01-01T00:00:00Z"
}

impl VaultLicense {
    pub fn new(
        rights: &str,
        royalty_percent: u8,
        creator_wallet: &str,
        expiration: Option<String>,
    ) -> Self {
        VaultLicense {
            rights: rights.to_string(),
            royalty_percent,
            creator_wallet: creator_wallet.to_string(),
            expiration,
        }
    }

    pub fn save_to_file(&self, path: &Path) -> std::io::Result<()> {
        let json = serde_json::to_string_pretty(self)?;
        let mut file = File::create(path)?;
        file.write_all(json.as_bytes())?;
        Ok(())
    }
}