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:tsmt.003.001.03")]
pub struct ActivityReportRequestV03 {
    #[yaserde(rename = "ReqId")]
    #[cfg_attr(feature = "serde", serde(rename = "ReqId"))]
    pub req_id: MessageIdentification1,

    #[yaserde(rename = "NttiesToBeRptd")]
    #[cfg_attr(feature = "serde", serde(rename = "NttiesToBeRptd"))]
    pub ntties_to_be_rptd: Vec<Bicidentification1>,

    #[yaserde(rename = "RptPrd")]
    #[cfg_attr(feature = "serde", serde(rename = "RptPrd"))]
    pub rpt_prd: DateTimePeriodDetails1,
}

impl Validate for ActivityReportRequestV03 {}


#[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:tsmt.003.001.03")]
pub struct Bicidentification1 {
    #[yaserde(rename = "BIC")]
    #[cfg_attr(feature = "serde", serde(rename = "BIC"))]
    pub bic: Bicidentifier,
}

impl Validate for Bicidentification1 {}


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

impl Validate for Bicidentifier {}
#[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:tsmt.003.001.03")]
pub struct DateTimePeriodDetails1 {
    #[yaserde(rename = "FrDtTm")]
    #[cfg_attr(feature = "serde", serde(rename = "FrDtTm"))]
    pub fr_dt_tm: IsodateTime,

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

impl Validate for DateTimePeriodDetails1 {}


#[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:tsmt.003.001.03")]
pub struct Document {
    #[yaserde(rename = "ActvtyReqRpt")]
    #[cfg_attr(feature = "serde", serde(rename = "ActvtyReqRpt"))]
    pub actvty_req_rpt: ActivityReportRequestV03,
}

impl Validate for Document {}


#[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 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:tsmt.003.001.03")]
pub struct MessageIdentification1 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: Max35Text,

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

impl Validate for MessageIdentification1 {}

impl crate::MxMessage for Document {
    const BUSINESS_AREA: crate::BusinessArea = crate::BusinessArea::tsmt;
    const FUNCTIONALITY: &'static str = "003";
    const VARIANT: &'static str = "001";
    const VERSION: &'static str = "03";
    const MESSAGE_NAME: &'static str = "tsmt.003.001.03";
    const NAMESPACE: &'static str = "urn:iso:std:iso:20022:tech:xsd:tsmt.003.001.03";
}