Struct oca_bundle_semantics::state::oca::OCABox
source · pub struct OCABox {
pub attributes: HashMap<String, Attribute>,
pub credential_layouts: Option<Vec<Layout>>,
pub form_layouts: Option<Vec<Layout>>,
pub mappings: Option<Vec<AttributeMapping>>,
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>§credential_layouts: Option<Vec<Layout>>§form_layouts: Option<Vec<Layout>>§mappings: Option<Vec<AttributeMapping>>§meta: Option<HashMap<Language, HashMap<String, String>>>§classification: Option<String>Implementations§
source§impl OCABox
impl OCABox
pub fn new() -> Self
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
pub fn get_attribute_by_name(&self, name: &str) -> Option<&Attribute>
pub fn add_attribute_mapping(&mut self, mapping: AttributeMapping)
pub fn add_classification(&mut self, classification: String)
pub fn remove_classification(&mut self)
pub fn generate_bundle(&mut self) -> OCABundle
Trait Implementations§
source§impl CredentialLayouts for OCABox
impl CredentialLayouts for OCABox
fn add_credential_layout(&mut self, layout_str: String)
source§impl FormLayouts for OCABox
impl FormLayouts for OCABox
fn add_form_layout(&mut self, layout_str: String)
Auto Trait Implementations§
impl Freeze for OCABox
impl RefUnwindSafe for OCABox
impl Send for OCABox
impl Sync for OCABox
impl Unpin for OCABox
impl UnwindSafe for OCABox
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)