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:admi.004.001.02")]
pub struct Document {
    #[yaserde(rename = "SysEvtNtfctn")]
    #[cfg_attr(feature = "serde", serde(rename = "SysEvtNtfctn"))]
    pub sys_evt_ntfctn: SystemEventNotificationV02,
}

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:admi.004.001.02")]
pub struct Event2 {
    #[yaserde(rename = "EvtCd")]
    #[cfg_attr(feature = "serde", serde(rename = "EvtCd"))]
    pub evt_cd: Max4AlphaNumericText,

    #[yaserde(rename = "EvtParam")]
    #[cfg_attr(feature = "serde", serde(rename = "EvtParam"))]
    pub evt_param: Vec<Max35Text>,

    #[yaserde(rename = "EvtDesc")]
    #[cfg_attr(feature = "serde", serde(rename = "EvtDesc"))]
    pub evt_desc: Max1000Text,

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

impl Validate for Event2 {}


#[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)]
pub struct Max1000Text (pub String);
crate::simple_type!(Max1000Text);

impl Validate for Max1000Text {
    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() > 1000 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 1000 \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)]
pub struct Max4AlphaNumericText (pub String);
crate::simple_type!(Max4AlphaNumericText);

impl Validate for Max4AlphaNumericText {
    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:admi.004.001.02")]
pub struct SystemEventNotificationV02 {
    #[yaserde(rename = "EvtInf")]
    #[cfg_attr(feature = "serde", serde(rename = "EvtInf"))]
    pub evt_inf: Event2,
}

impl Validate for SystemEventNotificationV02 {}

impl crate::MxMessage for Document {
    const BUSINESS_AREA: crate::BusinessArea = crate::BusinessArea::admi;
    const FUNCTIONALITY: &'static str = "004";
    const VARIANT: &'static str = "001";
    const VERSION: &'static str = "02";
    const MESSAGE_NAME: &'static str = "admi.004.001.02";
    const NAMESPACE: &'static str = "urn:iso:std:iso:20022:tech:xsd:admi.004.001.02";
}