feat: add contructor utility functions to entity and attribute

This commit is contained in:
2025-09-27 07:47:43 +02:00
parent 1786c9104f
commit e274ccafec
2 changed files with 23 additions and 0 deletions

View File

@@ -5,3 +5,12 @@ pub struct O {
pub id: String, pub id: String,
pub value: Value, pub value: Value,
} }
impl O {
pub fn new(id: &str, value: Value) -> Self {
Self {
id: String::from(id),
value,
}
}
}

View File

@@ -5,3 +5,17 @@ pub struct O {
pub class: String, pub class: String,
pub attributes: std::collections::HashMap<String, Attribute>, pub attributes: std::collections::HashMap<String, Attribute>,
} }
impl O {
pub fn new(class: &str) -> Self {
Self {
class: String::from(class),
attributes: std::collections::HashMap::new(),
}
}
pub fn with_attribute(mut self, id: &str, value: Value) -> Self {
let attribute = Attribute::new(id, value);
self.attributes.insert(attribute.id.clone(), attribute);
self
}
}