Struct oca_rust::state::oca::OCABuilder
source · pub struct OCABuilder {
pub oca: OCA,
pub meta_translations: HashMap<Language, OCATranslation>,
pub form_layout: Option<String>,
pub default_form_layout: bool,
pub form_layout_reference: BTreeMap<String, String>,
pub credential_layout: Option<String>,
pub default_credential_layout: bool,
pub credential_layout_reference: BTreeMap<String, String>,
/* private fields */
}
Fields§
§oca: OCA
§meta_translations: HashMap<Language, OCATranslation>
§form_layout: Option<String>
§default_form_layout: bool
§form_layout_reference: BTreeMap<String, String>
§credential_layout: Option<String>
§default_credential_layout: bool
§credential_layout_reference: BTreeMap<String, String>
Implementations§
source§impl OCABuilder
impl OCABuilder
pub fn new(default_encoding: Encoding) -> OCABuilder
pub fn add_classification(self, classification: String) -> OCABuilder
pub fn add_form_layout(self, layout: String) -> OCABuilder
pub fn add_default_form_layout(self) -> OCABuilder
pub fn add_credential_layout(self, layout: String) -> OCABuilder
pub fn add_default_credential_layout(self) -> OCABuilder
pub fn add_name(self, names: HashMap<Language, String>) -> OCABuilder
pub fn add_description(
self,
descriptions: HashMap<Language, String>
) -> OCABuilder
pub fn add_meta(
self,
name: String,
values: HashMap<Language, String>
) -> OCABuilder
pub fn add_attribute(self, attr: Attribute) -> OCABuilder
pub fn finalize(self) -> OCA
sourcepub fn build_default_form_layout(&self) -> String
pub fn build_default_form_layout(&self) -> String
Examples found in repository?
src/state/oca.rs (line 753)
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817
pub fn finalize(mut self) -> OCA {
for (lang, translation) in self.meta_translations.iter() {
self.oca
.overlays
.push(overlay::Meta::new(lang.to_string(), translation));
}
let mut form_layout_tmp = None;
if let Some(ref layout) = self.form_layout {
if !layout.is_empty() {
form_layout_tmp = Some(layout.clone());
}
} else if self.default_form_layout {
form_layout_tmp = Some(self.build_default_form_layout());
}
if let Some(mut layout) = form_layout_tmp {
for (i, (name, ref_layout)) in self.form_layout_reference.iter().enumerate() {
if i == 0 {
layout.push_str(
r#"
reference_layouts:"#,
);
}
layout.push_str(
format!(
r#"
{}:
{}"#,
name,
ref_layout.replace('\n', "\n ")
)
.as_str(),
);
}
self.oca.overlays.push(overlay::FormLayout::new(layout));
}
let mut credential_layout_tmp = None;
if let Some(ref layout) = self.credential_layout {
if !layout.is_empty() {
credential_layout_tmp = Some(layout.clone());
}
} else if self.default_credential_layout {
credential_layout_tmp = Some(self.build_default_credential_layout());
}
if let Some(mut layout) = credential_layout_tmp {
for (i, (name, ref_layout)) in self.credential_layout_reference.iter().enumerate() {
if i == 0 {
layout.push_str(
r#"
reference_layouts:"#,
);
}
layout.push_str(
format!(
r#"
{}:
{}"#,
name,
ref_layout.replace('\n', "\n ")
)
.as_str(),
);
}
self.oca
.overlays
.push(overlay::CredentialLayout::new(layout));
}
self.oca.capture_base.sign();
for o in self.oca.overlays.iter_mut() {
o.sign(&self.oca.capture_base.said);
}
self.oca
}
pub fn add_form_layout_reference(&mut self, name: String, layout: String)
sourcepub fn build_default_credential_layout(&self) -> String
pub fn build_default_credential_layout(&self) -> String
Examples found in repository?
src/state/oca.rs (line 784)
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817
pub fn finalize(mut self) -> OCA {
for (lang, translation) in self.meta_translations.iter() {
self.oca
.overlays
.push(overlay::Meta::new(lang.to_string(), translation));
}
let mut form_layout_tmp = None;
if let Some(ref layout) = self.form_layout {
if !layout.is_empty() {
form_layout_tmp = Some(layout.clone());
}
} else if self.default_form_layout {
form_layout_tmp = Some(self.build_default_form_layout());
}
if let Some(mut layout) = form_layout_tmp {
for (i, (name, ref_layout)) in self.form_layout_reference.iter().enumerate() {
if i == 0 {
layout.push_str(
r#"
reference_layouts:"#,
);
}
layout.push_str(
format!(
r#"
{}:
{}"#,
name,
ref_layout.replace('\n', "\n ")
)
.as_str(),
);
}
self.oca.overlays.push(overlay::FormLayout::new(layout));
}
let mut credential_layout_tmp = None;
if let Some(ref layout) = self.credential_layout {
if !layout.is_empty() {
credential_layout_tmp = Some(layout.clone());
}
} else if self.default_credential_layout {
credential_layout_tmp = Some(self.build_default_credential_layout());
}
if let Some(mut layout) = credential_layout_tmp {
for (i, (name, ref_layout)) in self.credential_layout_reference.iter().enumerate() {
if i == 0 {
layout.push_str(
r#"
reference_layouts:"#,
);
}
layout.push_str(
format!(
r#"
{}:
{}"#,
name,
ref_layout.replace('\n', "\n ")
)
.as_str(),
);
}
self.oca
.overlays
.push(overlay::CredentialLayout::new(layout));
}
self.oca.capture_base.sign();
for o in self.oca.overlays.iter_mut() {
o.sign(&self.oca.capture_base.said);
}
self.oca
}
pub fn add_credential_layout_reference(&mut self, name: String, layout: String)
Trait Implementations§
source§impl<'de> Deserialize<'de> for OCABuilder
impl<'de> Deserialize<'de> for OCABuilder
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more