fixer-fix 0.10.1

Generated FIX protocol types for fixer
Documentation
// Code generated by fixer-gen. DO NOT EDIT.
#![allow(clippy::new_without_default)]
#![allow(clippy::needless_pass_by_value)]
#![allow(clippy::too_many_arguments)]
#![allow(unused_imports)]

use fixer::message::Message;
use fixer::fix_string::FIXString;
use fixer::errors::MessageRejectErrorEnum;
use fixer::session::session_id::SessionID;


use crate::field;
use crate::tag;

/// `RegistrationInstructions` is the `fix50` `RegistrationInstructions` type, `MsgType` = o.
pub struct RegistrationInstructions {
    pub message: Message,
}

impl RegistrationInstructions {
    /// Creates a new `RegistrationInstructions` with required fields.
    pub fn new(regist_id: field::RegistIDField, regist_trans_type: field::RegistTransTypeField, regist_ref_id: field::RegistRefIDField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("o".to_string()));

        msg.body.set_field(tag::REGIST_ID, regist_id.0);

        msg.body.set_field(tag::REGIST_TRANS_TYPE, regist_trans_type.0);

        msg.body.set_field(tag::REGIST_REF_ID, regist_ref_id.0);

        Self { message: msg }
    }

    /// Creates a `RegistrationInstructions` from an existing `Message`.
    pub fn from_message(msg: Message) -> Self {
        Self { message: msg }
    }

    /// Returns the underlying `Message`.
    pub fn to_message(self) -> Message {
        self.message
    }




    /// Sets `Account`, Tag 1.
    pub fn set_account(&mut self, v: String) {
        self.message.body.set_field(tag::ACCOUNT, FIXString::from(v));
    }

    /// Gets `Account`, Tag 1.
    pub fn get_account(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::AccountField::new(String::new());
        self.message.body.get_field(tag::ACCOUNT, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `Account` is present, Tag 1.
    pub fn has_account(&self) -> bool {
        self.message.body.has(tag::ACCOUNT)
    }




    /// Sets `AcctIDSource`, Tag 660.
    pub fn set_acct_id_source(&mut self, v: isize) {
        self.message.body.set_field(tag::ACCT_ID_SOURCE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `AcctIDSource`, Tag 660.
    pub fn get_acct_id_source(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::AcctIDSourceField::new(0);
        self.message.body.get_field(tag::ACCT_ID_SOURCE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `AcctIDSource` is present, Tag 660.
    pub fn has_acct_id_source(&self) -> bool {
        self.message.body.has(tag::ACCT_ID_SOURCE)
    }




    /// Sets `ClOrdID`, Tag 11.
    pub fn set_cl_ord_id(&mut self, v: String) {
        self.message.body.set_field(tag::CL_ORD_ID, FIXString::from(v));
    }

    /// Gets `ClOrdID`, Tag 11.
    pub fn get_cl_ord_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::ClOrdIDField::new(String::new());
        self.message.body.get_field(tag::CL_ORD_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `ClOrdID` is present, Tag 11.
    pub fn has_cl_ord_id(&self) -> bool {
        self.message.body.has(tag::CL_ORD_ID)
    }




    /// Sets `NoDistribInsts`, Tag 510.
    pub fn set_no_distrib_insts(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_DISTRIB_INSTS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoDistribInsts`, Tag 510.
    pub fn get_no_distrib_insts(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoDistribInstsField::new(0);
        self.message.body.get_field(tag::NO_DISTRIB_INSTS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoDistribInsts` is present, Tag 510.
    pub fn has_no_distrib_insts(&self) -> bool {
        self.message.body.has(tag::NO_DISTRIB_INSTS)
    }




    /// Sets `NoPartyIDs`, Tag 453.
    pub fn set_no_party_i_ds(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_PARTY_I_DS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoPartyIDs`, Tag 453.
    pub fn get_no_party_i_ds(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoPartyIDsField::new(0);
        self.message.body.get_field(tag::NO_PARTY_I_DS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoPartyIDs` is present, Tag 453.
    pub fn has_no_party_i_ds(&self) -> bool {
        self.message.body.has(tag::NO_PARTY_I_DS)
    }




    /// Sets `NoRegistDtls`, Tag 473.
    pub fn set_no_regist_dtls(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_REGIST_DTLS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoRegistDtls`, Tag 473.
    pub fn get_no_regist_dtls(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoRegistDtlsField::new(0);
        self.message.body.get_field(tag::NO_REGIST_DTLS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoRegistDtls` is present, Tag 473.
    pub fn has_no_regist_dtls(&self) -> bool {
        self.message.body.has(tag::NO_REGIST_DTLS)
    }




    /// Sets `OwnershipType`, Tag 517.
    pub fn set_ownership_type(&mut self, v: String) {
        self.message.body.set_field(tag::OWNERSHIP_TYPE, FIXString::from(v));
    }

    /// Gets `OwnershipType`, Tag 517.
    pub fn get_ownership_type(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::OwnershipTypeField::new(String::new());
        self.message.body.get_field(tag::OWNERSHIP_TYPE, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `OwnershipType` is present, Tag 517.
    pub fn has_ownership_type(&self) -> bool {
        self.message.body.has(tag::OWNERSHIP_TYPE)
    }




    /// Sets `RegistAcctType`, Tag 493.
    pub fn set_regist_acct_type(&mut self, v: String) {
        self.message.body.set_field(tag::REGIST_ACCT_TYPE, FIXString::from(v));
    }

    /// Gets `RegistAcctType`, Tag 493.
    pub fn get_regist_acct_type(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::RegistAcctTypeField::new(String::new());
        self.message.body.get_field(tag::REGIST_ACCT_TYPE, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `RegistAcctType` is present, Tag 493.
    pub fn has_regist_acct_type(&self) -> bool {
        self.message.body.has(tag::REGIST_ACCT_TYPE)
    }




    /// Sets `RegistID`, Tag 513.
    pub fn set_regist_id(&mut self, v: String) {
        self.message.body.set_field(tag::REGIST_ID, FIXString::from(v));
    }

    /// Gets `RegistID`, Tag 513.
    pub fn get_regist_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::RegistIDField::new(String::new());
        self.message.body.get_field(tag::REGIST_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `RegistID` is present, Tag 513.
    pub fn has_regist_id(&self) -> bool {
        self.message.body.has(tag::REGIST_ID)
    }




    /// Sets `RegistRefID`, Tag 508.
    pub fn set_regist_ref_id(&mut self, v: String) {
        self.message.body.set_field(tag::REGIST_REF_ID, FIXString::from(v));
    }

    /// Gets `RegistRefID`, Tag 508.
    pub fn get_regist_ref_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::RegistRefIDField::new(String::new());
        self.message.body.get_field(tag::REGIST_REF_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `RegistRefID` is present, Tag 508.
    pub fn has_regist_ref_id(&self) -> bool {
        self.message.body.has(tag::REGIST_REF_ID)
    }




    /// Sets `RegistTransType`, Tag 514.
    pub fn set_regist_trans_type(&mut self, v: String) {
        self.message.body.set_field(tag::REGIST_TRANS_TYPE, FIXString::from(v));
    }

    /// Gets `RegistTransType`, Tag 514.
    pub fn get_regist_trans_type(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::RegistTransTypeField::new(String::new());
        self.message.body.get_field(tag::REGIST_TRANS_TYPE, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `RegistTransType` is present, Tag 514.
    pub fn has_regist_trans_type(&self) -> bool {
        self.message.body.has(tag::REGIST_TRANS_TYPE)
    }




    /// Sets `TaxAdvantageType`, Tag 495.
    pub fn set_tax_advantage_type(&mut self, v: isize) {
        self.message.body.set_field(tag::TAX_ADVANTAGE_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `TaxAdvantageType`, Tag 495.
    pub fn get_tax_advantage_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::TaxAdvantageTypeField::new(0);
        self.message.body.get_field(tag::TAX_ADVANTAGE_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `TaxAdvantageType` is present, Tag 495.
    pub fn has_tax_advantage_type(&self) -> bool {
        self.message.body.has(tag::TAX_ADVANTAGE_TYPE)
    }


}

/// `RouteOut` is the callback type for routing `RegistrationInstructions` messages.
pub type RouteOut = fn(msg: RegistrationInstructions, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;

/// Route type returned by the `route` function.
pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);

/// Returns the begin string, message type, and route function for `RegistrationInstructions`.
pub fn route(router: RouteOut) -> Route {
    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
        router(RegistrationInstructions::from_message(msg.clone()), session_id)
    };
    ("7", "o", Box::new(r))
}