rust_iso20022 0.1.0

ISO 20022 message definitions and external code sets for Rust, generated from the official XSD schemas.
Documentation
// @generated by src/bin/codegen.rs from the ISO 20022 XSD schema. Do not edit.
#![allow(clippy::all)]
#![allow(non_snake_case, non_camel_case_types, dead_code, unused_imports)]
// yaserde_derive 0.7 emits trait impls inside nested choice submodules, which
// trips the `non_local_definitions` lint on recent rustc. The generated code is
// correct; silence the lint here.
#![allow(non_local_definitions)]
use std::str::FromStr;
use crate::validate::Validate;
use yaserde_derive::{YaDeserialize, YaSerialize};

// pub type Document = Document;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Bicfidec2014Identifier (pub String);
crate::simple_type!(Bicfidec2014Identifier);

impl Validate for Bicfidec2014Identifier {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct BuyerProtectionInstructionReportRequestV01 {
    #[yaserde(rename = "QryRef")]
    #[cfg_attr(feature = "serde", serde(rename = "QryRef"))]
    pub qry_ref: Max35Text,

    #[yaserde(rename = "BuyrPrtcnSelctnCrit")]
    #[cfg_attr(feature = "serde", serde(rename = "BuyrPrtcnSelctnCrit"))]
    pub buyr_prtcn_selctn_crit: BuyerProtectionSelectionCriteria1,

    #[yaserde(rename = "SplmtryData")]
    #[cfg_attr(feature = "serde", serde(rename = "SplmtryData"))]
    pub splmtry_data: Vec<SupplementaryData1>,
}

impl Validate for BuyerProtectionInstructionReportRequestV01 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct BuyerProtectionSelectionCriteria1 {
    #[yaserde(rename = "FIId")]
    #[cfg_attr(feature = "serde", serde(rename = "FIId"))]
    pub fi_id: FinancialInstitutionIdentification28,

    #[yaserde(rename = "AcctId")]
    #[cfg_attr(feature = "serde", serde(rename = "AcctId"))]
    pub acct_id: SecuritiesAccountIdentification1Choice,

    #[yaserde(rename = "ISIN")]
    #[cfg_attr(feature = "serde", serde(rename = "ISIN"))]
    pub isin: Isinoct2015Identifier,

    #[yaserde(rename = "CorpActnEvtId")]
    #[cfg_attr(feature = "serde", serde(rename = "CorpActnEvtId"))]
    pub corp_actn_evt_id: Max35Text,

    #[yaserde(rename = "MktInfrstrctrTxId")]
    #[cfg_attr(feature = "serde", serde(rename = "MktInfrstrctrTxId"))]
    pub mkt_infrstrctr_tx_id: Max35Text,

    #[yaserde(rename = "PrcrTxId")]
    #[cfg_attr(feature = "serde", serde(rename = "PrcrTxId"))]
    pub prcr_tx_id: Max35Text,

    #[yaserde(rename = "UnqTxIdr")]
    #[cfg_attr(feature = "serde", serde(rename = "UnqTxIdr"))]
    pub unq_tx_idr: Utiidentifier,
}

impl Validate for BuyerProtectionSelectionCriteria1 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct Document {
    #[yaserde(rename = "BuyrPrtcnInstrRptReq")]
    #[cfg_attr(feature = "serde", serde(rename = "BuyrPrtcnInstrRptReq"))]
    pub buyr_prtcn_instr_rpt_req: BuyerProtectionInstructionReportRequestV01,
}

impl Validate for Document {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct ExternalFinancialInstitutionIdentification1Code (pub String);
crate::simple_type!(ExternalFinancialInstitutionIdentification1Code);

impl Validate for ExternalFinancialInstitutionIdentification1Code {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 4 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 4 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct FinancialIdentificationSchemeName1Choice {
    #[yaserde(rename = "Cd")]
    #[cfg_attr(feature = "serde", serde(rename = "Cd"))]
    pub cd: Option<ExternalFinancialInstitutionIdentification1Code>,
    #[yaserde(rename = "Prtry")]
    #[cfg_attr(feature = "serde", serde(rename = "Prtry"))]
    pub prtry: Option<Max35Text>,
}

impl Validate for FinancialIdentificationSchemeName1Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct FinancialInstitutionIdentification28 {
    #[yaserde(rename = "BICFI")]
    #[cfg_attr(feature = "serde", serde(rename = "BICFI"))]
    pub bicfi: Bicfidec2014Identifier,

    #[yaserde(rename = "LEI")]
    #[cfg_attr(feature = "serde", serde(rename = "LEI"))]
    pub lei: Leiidentifier,

    #[yaserde(rename = "Othr")]
    #[cfg_attr(feature = "serde", serde(rename = "Othr"))]
    pub othr: GenericFinancialIdentification1,
}

impl Validate for FinancialInstitutionIdentification28 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct GenericFinancialIdentification1 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: Max35Text,

    #[yaserde(rename = "SchmeNm")]
    #[cfg_attr(feature = "serde", serde(rename = "SchmeNm"))]
    pub schme_nm: FinancialIdentificationSchemeName1Choice,

    #[yaserde(rename = "Issr")]
    #[cfg_attr(feature = "serde", serde(rename = "Issr"))]
    pub issr: Max35Text,
}

impl Validate for GenericFinancialIdentification1 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Isinoct2015Identifier (pub String);
crate::simple_type!(Isinoct2015Identifier);

impl Validate for Isinoct2015Identifier {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Leiidentifier (pub String);
crate::simple_type!(Leiidentifier);

impl Validate for Leiidentifier {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Max140Text (pub String);
crate::simple_type!(Max140Text);

impl Validate for Max140Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 140 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 140 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Max350Text (pub String);
crate::simple_type!(Max350Text);

impl Validate for Max350Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 350 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 350 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Max35Text (pub String);
crate::simple_type!(Max35Text);

impl Validate for Max35Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 35 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 35 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct SecuritiesAccountIdentification1Choice {
    #[yaserde(rename = "SfkpgAcct")]
    #[cfg_attr(feature = "serde", serde(rename = "SfkpgAcct"))]
    pub sfkpg_acct: Option<Max35Text>,
    #[yaserde(rename = "BlckChainAdrOrWllt")]
    #[cfg_attr(feature = "serde", serde(rename = "BlckChainAdrOrWllt"))]
    pub blck_chain_adr_or_wllt: Option<Max140Text>,
}

impl Validate for SecuritiesAccountIdentification1Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct SupplementaryData1 {
    #[yaserde(rename = "PlcAndNm")]
    #[cfg_attr(feature = "serde", serde(rename = "PlcAndNm"))]
    pub plc_and_nm: Max350Text,

    #[yaserde(rename = "Envlp")]
    #[cfg_attr(feature = "serde", serde(rename = "Envlp"))]
    pub envlp: SupplementaryDataEnvelope1,
}

impl Validate for SupplementaryData1 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:seev.066.001.01")]
pub struct SupplementaryDataEnvelope1 {}

impl Validate for SupplementaryDataEnvelope1 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Utiidentifier (pub String);
crate::simple_type!(Utiidentifier);

impl Validate for Utiidentifier {}

impl crate::MxMessage for Document {
    const BUSINESS_AREA: crate::BusinessArea = crate::BusinessArea::seev;
    const FUNCTIONALITY: &'static str = "066";
    const VARIANT: &'static str = "001";
    const VERSION: &'static str = "01";
    const MESSAGE_NAME: &'static str = "seev.066.001.01";
    const NAMESPACE: &'static str = "urn:iso:std:iso:20022:tech:xsd:seev.066.001.01";
}