pub struct OCABox {
pub attributes: HashMap<String, Attribute>,
pub mappings: Option<Vec<AttributeMappingOverlay>>,
pub meta: Option<HashMap<Language, HashMap<String, String>>>,
pub classification: Option<String>,
}
Expand description
Internal representation of OCA objects in split between non-attributes values and attributes. It is used to build dynamically objects without knowing yet whole structure of the object. Used mainly as a container to hold information while parsing OCAfile. Example of usage:
let oca = OCABox::new() let attr = Attribute::new(“name”) oca.add_attribute(attr) oca.get_attribute_by_name(“name”).setEncoding(Encoding::UTF8) oca.get_attribute_by_name(“name”).setLabel(Language::English, “Name”) oca.get_attribute_by_name(“name”).setInformation(Language::German, “Name”) oca.get_attribute_by_name(“name”).setUnit(“kg”) oca.get_attribute_by_name(“name”).setStandard(“ISO 1234”) oca.get_attribute_by_name(“name”).setCategory(“personal”) oca.generate_bundle().unwrap()
TODO: How to add multiple overlays like mapping or layout (how to identify them?)
Fields§
§attributes: HashMap<String, Attribute>
§mappings: Option<Vec<AttributeMappingOverlay>>
§meta: Option<HashMap<Language, HashMap<String, String>>>
§classification: Option<String>
Implementations§
Source§impl OCABox
impl OCABox
pub fn new() -> OCABox
Sourcepub fn remove_attribute(&mut self, attr_name: &String)
pub fn remove_attribute(&mut self, attr_name: &String)
Remove attribute from the OCA Bundle if attribute does not exist, nothing will happen
Sourcepub fn add_attribute(&mut self, attribute: Attribute)
pub fn add_attribute(&mut self, attribute: Attribute)
Add an attribute to the OCA Bundle If the attribute already exists, it will be merged with the new attribute for simple types: the new value will overwrite the old value for complex types: the new value will be added to the old value