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§

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
    }
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
    }

Trait Implementations§

Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.