feat: add contructor utility functions to entity and attribute
This commit is contained in:
@@ -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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user