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>, }
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(())
}
}