use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Blueprint {
pub params: Vec<String>, pub body: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Fragment {
pub params: Vec<String>,
pub body: String,
}
#[derive(Default, Debug)]
pub struct Registry {
pub fragments: HashMap<String, Fragment>,
pub blueprints: HashMap<String, Blueprint>,
pub schemas: HashMap<String, String>,
pub concrete_schemas: HashMap<String, String>,
}
impl Registry {
pub fn new() -> Self {
Self::default()
}
pub fn insert_fragment(&mut self, name: String, params: Vec<String>, content: String) {
self.fragments.insert(
name,
Fragment {
params,
body: content,
},
);
}
pub fn insert_blueprint(&mut self, name: String, params: Vec<String>, content: String) {
self.blueprints.insert(
name,
Blueprint {
params,
body: content,
},
);
}
pub fn insert_schema(&mut self, name: String, content: String) {
self.schemas.insert(name, content);
}
}