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, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:camt.020.001.04")]
pub struct BusinessInformationCriteria1 {
    #[yaserde(rename = "NewQryNm")]
    #[cfg_attr(feature = "serde", serde(rename = "NewQryNm"))]
    pub new_qry_nm: Max35Text,

    #[yaserde(rename = "SchCrit")]
    #[cfg_attr(feature = "serde", serde(rename = "SchCrit"))]
    pub sch_crit: Vec<GeneralBusinessInformationSearchCriteria1>,

    #[yaserde(rename = "RtrCrit")]
    #[cfg_attr(feature = "serde", serde(rename = "RtrCrit"))]
    pub rtr_crit: GeneralBusinessInformationReturnCriteria1,
}

impl Validate for BusinessInformationCriteria1 {}


#[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:camt.020.001.04")]
pub struct BusinessInformationQueryDefinition3 {
    #[yaserde(rename = "QryTp")]
    #[cfg_attr(feature = "serde", serde(rename = "QryTp"))]
    pub qry_tp: QueryType2Code,

    #[yaserde(rename = "GnlBizInfCrit")]
    #[cfg_attr(feature = "serde", serde(rename = "GnlBizInfCrit"))]
    pub gnl_biz_inf_crit: GeneralBusinessInformationCriteriaDefinition1Choice,
}

impl Validate for BusinessInformationQueryDefinition3 {}
#[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:camt.020.001.04")]
pub struct CharacterSearch1Choice {
    #[yaserde(rename = "EQ")]
    #[cfg_attr(feature = "serde", serde(rename = "EQ"))]
    pub eq: Option<Max35Text>,
    #[yaserde(rename = "NEQ")]
    #[cfg_attr(feature = "serde", serde(rename = "NEQ"))]
    pub neq: Option<Max35Text>,
    #[yaserde(rename = "CT")]
    #[cfg_attr(feature = "serde", serde(rename = "CT"))]
    pub ct: Option<Max35Text>,
    #[yaserde(rename = "NCT")]
    #[cfg_attr(feature = "serde", serde(rename = "NCT"))]
    pub nct: Option<Max35Text>,
}

impl Validate for CharacterSearch1Choice {}




#[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:camt.020.001.04")]
pub struct Document {
    #[yaserde(rename = "GetGnlBizInf")]
    #[cfg_attr(feature = "serde", serde(rename = "GetGnlBizInf"))]
    pub get_gnl_biz_inf: GetGeneralBusinessInformationV04,
}

impl Validate for Document {}
#[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:camt.020.001.04")]
pub struct GeneralBusinessInformationCriteriaDefinition1Choice {
    #[yaserde(rename = "QryNm")]
    #[cfg_attr(feature = "serde", serde(rename = "QryNm"))]
    pub qry_nm: Option<Max35Text>,
    #[yaserde(rename = "NewCrit")]
    #[cfg_attr(feature = "serde", serde(rename = "NewCrit"))]
    pub new_crit: Option<BusinessInformationCriteria1>,
}

impl Validate for GeneralBusinessInformationCriteriaDefinition1Choice {}




#[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:camt.020.001.04")]
pub struct GeneralBusinessInformationReturnCriteria1 {
    #[yaserde(rename = "QlfrInd")]
    #[cfg_attr(feature = "serde", serde(rename = "QlfrInd"))]
    pub qlfr_ind: RequestedIndicator,

    #[yaserde(rename = "SbjtInd")]
    #[cfg_attr(feature = "serde", serde(rename = "SbjtInd"))]
    pub sbjt_ind: RequestedIndicator,

    #[yaserde(rename = "SbjtDtlsInd")]
    #[cfg_attr(feature = "serde", serde(rename = "SbjtDtlsInd"))]
    pub sbjt_dtls_ind: RequestedIndicator,
}

impl Validate for GeneralBusinessInformationReturnCriteria1 {}


#[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:camt.020.001.04")]
pub struct GeneralBusinessInformationSearchCriteria1 {
    #[yaserde(rename = "Ref")]
    #[cfg_attr(feature = "serde", serde(rename = "Ref"))]
    pub _ref: Vec<Max35Text>,

    #[yaserde(rename = "Sbjt")]
    #[cfg_attr(feature = "serde", serde(rename = "Sbjt"))]
    pub sbjt: Vec<CharacterSearch1Choice>,

    #[yaserde(rename = "Qlfr")]
    #[cfg_attr(feature = "serde", serde(rename = "Qlfr"))]
    pub qlfr: Vec<InformationQualifierType1>,
}

impl Validate for GeneralBusinessInformationSearchCriteria1 {}


#[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:camt.020.001.04")]
pub struct GetGeneralBusinessInformationV04 {
    #[yaserde(rename = "MsgHdr")]
    #[cfg_attr(feature = "serde", serde(rename = "MsgHdr"))]
    pub msg_hdr: MessageHeader1,

    #[yaserde(rename = "GnlBizInfQryDef")]
    #[cfg_attr(feature = "serde", serde(rename = "GnlBizInfQryDef"))]
    pub gnl_biz_inf_qry_def: BusinessInformationQueryDefinition3,

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

impl Validate for GetGeneralBusinessInformationV04 {}


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

impl Validate for IsodateTime {}
#[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:camt.020.001.04")]
pub struct InformationQualifierType1 {
    #[yaserde(rename = "IsFrmtd")]
    #[cfg_attr(feature = "serde", serde(rename = "IsFrmtd"))]
    pub is_frmtd: YesNoIndicator,

    #[yaserde(rename = "Prty")]
    #[cfg_attr(feature = "serde", serde(rename = "Prty"))]
    pub prty: Priority1Code,
}

impl Validate for InformationQualifierType1 {}


#[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:camt.020.001.04")]
pub struct MessageHeader1 {
    #[yaserde(rename = "MsgId")]
    #[cfg_attr(feature = "serde", serde(rename = "MsgId"))]
    pub msg_id: Max35Text,

    #[yaserde(rename = "CreDtTm")]
    #[cfg_attr(feature = "serde", serde(rename = "CreDtTm"))]
    pub cre_dt_tm: IsodateTime,
}

impl Validate for MessageHeader1 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:camt.020.001.04")]

pub enum Priority1Code {
    #[yaserde(rename = "HIGH")]
    #[cfg_attr(feature = "serde", serde(rename = "HIGH"))]
    High,
    #[yaserde(rename = "NORM")]
    #[cfg_attr(feature = "serde", serde(rename = "NORM"))]
    Norm,
    #[yaserde(rename = "LOWW")]
    #[cfg_attr(feature = "serde", serde(rename = "LOWW"))]
    Loww,
    __Unknown__(String),
}

impl Default for Priority1Code {
    fn default() -> Priority1Code {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for Priority1Code {}



#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:camt.020.001.04")]

pub enum QueryType2Code {
    #[yaserde(rename = "ALLL")]
    #[cfg_attr(feature = "serde", serde(rename = "ALLL"))]
    Alll,
    #[yaserde(rename = "CHNG")]
    #[cfg_attr(feature = "serde", serde(rename = "CHNG"))]
    Chng,
    #[yaserde(rename = "MODF")]
    #[cfg_attr(feature = "serde", serde(rename = "MODF"))]
    Modf,
    #[yaserde(rename = "DELD")]
    #[cfg_attr(feature = "serde", serde(rename = "DELD"))]
    Deld,
    __Unknown__(String),
}

impl Default for QueryType2Code {
    fn default() -> QueryType2Code {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for QueryType2Code {}



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

impl Validate for RequestedIndicator {}
#[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:camt.020.001.04")]
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:camt.020.001.04")]
pub struct SupplementaryDataEnvelope1 {}

impl Validate for SupplementaryDataEnvelope1 {}


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

impl Validate for YesNoIndicator {}

impl crate::MxMessage for Document {
    const BUSINESS_AREA: crate::BusinessArea = crate::BusinessArea::camt;
    const FUNCTIONALITY: &'static str = "020";
    const VARIANT: &'static str = "001";
    const VERSION: &'static str = "04";
    const MESSAGE_NAME: &'static str = "camt.020.001.04";
    const NAMESPACE: &'static str = "urn:iso:std:iso:20022:tech:xsd:camt.020.001.04";
}