use std::collections::HashMap;
#[derive(Debug, Clone, Default)]
pub struct GraphMetadata {
pub name: String,
pub version: String,
pub creator: String,
pub target: Option<String>,
pub optimization_level: OptimizationLevel,
pub custom: HashMap<String, String>,
}
impl GraphMetadata {
pub fn new(name: String) -> Self {
Self {
name,
version: "1.0.0".to_string(),
creator: "torsh-jit".to_string(),
target: None,
optimization_level: OptimizationLevel::Default,
custom: HashMap::new(),
}
}
pub fn with_version(mut self, version: String) -> Self {
self.version = version;
self
}
pub fn with_creator(mut self, creator: String) -> Self {
self.creator = creator;
self
}
pub fn with_target(mut self, target: String) -> Self {
self.target = Some(target);
self
}
pub fn with_optimization_level(mut self, level: OptimizationLevel) -> Self {
self.optimization_level = level;
self
}
pub fn with_custom(mut self, key: String, value: String) -> Self {
self.custom.insert(key, value);
self
}
pub fn get_custom(&self, key: &str) -> Option<&String> {
self.custom.get(key)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OptimizationLevel {
None, Basic, Default, Aggressive, }
impl Default for OptimizationLevel {
fn default() -> Self {
OptimizationLevel::Default
}
}