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;

/// `TradingSessionListUpdateReport` is the `fix50sp2` `TradingSessionListUpdateReport` type, `MsgType` = BS.
pub struct TradingSessionListUpdateReport {
    pub message: Message,
}

impl TradingSessionListUpdateReport {
    /// Creates a new `TradingSessionListUpdateReport` with required fields.
    pub fn new(no_trading_sessions: field::NoTradingSessionsField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("BS".to_string()));

        msg.body.set_field(tag::NO_TRADING_SESSIONS, no_trading_sessions.0);

        Self { message: msg }
    }

    /// Creates a `TradingSessionListUpdateReport` 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 `ApplID`, Tag 1180.
    pub fn set_appl_id(&mut self, v: String) {
        self.message.body.set_field(tag::APPL_ID, FIXString::from(v));
    }

    /// Gets `ApplID`, Tag 1180.
    pub fn get_appl_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::ApplIDField::new(String::new());
        self.message.body.get_field(tag::APPL_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `ApplID` is present, Tag 1180.
    pub fn has_appl_id(&self) -> bool {
        self.message.body.has(tag::APPL_ID)
    }




    /// Sets `ApplLastSeqNum`, Tag 1350.
    pub fn set_appl_last_seq_num(&mut self, v: isize) {
        self.message.body.set_field(tag::APPL_LAST_SEQ_NUM, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `ApplLastSeqNum`, Tag 1350.
    pub fn get_appl_last_seq_num(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::ApplLastSeqNumField::new(0);
        self.message.body.get_field(tag::APPL_LAST_SEQ_NUM, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `ApplLastSeqNum` is present, Tag 1350.
    pub fn has_appl_last_seq_num(&self) -> bool {
        self.message.body.has(tag::APPL_LAST_SEQ_NUM)
    }




    /// Sets `ApplResendFlag`, Tag 1352.
    pub fn set_appl_resend_flag(&mut self, v: bool) {
        self.message.body.set_field(tag::APPL_RESEND_FLAG, fixer::fix_boolean::FIXBoolean::from(v));
    }

    /// Gets `ApplResendFlag`, Tag 1352.
    pub fn get_appl_resend_flag(&self) -> Result<bool, MessageRejectErrorEnum> {
        let mut fld = field::ApplResendFlagField::new(false);
        self.message.body.get_field(tag::APPL_RESEND_FLAG, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `ApplResendFlag` is present, Tag 1352.
    pub fn has_appl_resend_flag(&self) -> bool {
        self.message.body.has(tag::APPL_RESEND_FLAG)
    }




    /// Sets `ApplSeqNum`, Tag 1181.
    pub fn set_appl_seq_num(&mut self, v: isize) {
        self.message.body.set_field(tag::APPL_SEQ_NUM, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `ApplSeqNum`, Tag 1181.
    pub fn get_appl_seq_num(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::ApplSeqNumField::new(0);
        self.message.body.get_field(tag::APPL_SEQ_NUM, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `ApplSeqNum` is present, Tag 1181.
    pub fn has_appl_seq_num(&self) -> bool {
        self.message.body.has(tag::APPL_SEQ_NUM)
    }




    /// Sets `NoTradingSessions`, Tag 386.
    pub fn set_no_trading_sessions(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_TRADING_SESSIONS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoTradingSessions`, Tag 386.
    pub fn get_no_trading_sessions(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoTradingSessionsField::new(0);
        self.message.body.get_field(tag::NO_TRADING_SESSIONS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoTradingSessions` is present, Tag 386.
    pub fn has_no_trading_sessions(&self) -> bool {
        self.message.body.has(tag::NO_TRADING_SESSIONS)
    }




    /// Sets `TradSesReqID`, Tag 335.
    pub fn set_trad_ses_req_id(&mut self, v: String) {
        self.message.body.set_field(tag::TRAD_SES_REQ_ID, FIXString::from(v));
    }

    /// Gets `TradSesReqID`, Tag 335.
    pub fn get_trad_ses_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::TradSesReqIDField::new(String::new());
        self.message.body.get_field(tag::TRAD_SES_REQ_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `TradSesReqID` is present, Tag 335.
    pub fn has_trad_ses_req_id(&self) -> bool {
        self.message.body.has(tag::TRAD_SES_REQ_ID)
    }


}

/// `RouteOut` is the callback type for routing `TradingSessionListUpdateReport` messages.
pub type RouteOut = fn(msg: TradingSessionListUpdateReport, 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 `TradingSessionListUpdateReport`.
pub fn route(router: RouteOut) -> Route {
    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
        router(TradingSessionListUpdateReport::from_message(msg.clone()), session_id)
    };
    ("9", "BS", Box::new(r))
}