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;

/// `SecurityTypes` is the `fix44` `SecurityTypes` type, `MsgType` = w.
pub struct SecurityTypes {
    pub message: Message,
}

impl SecurityTypes {
    /// Creates a new `SecurityTypes` with required fields.
    pub fn new(security_req_id: field::SecurityReqIDField, security_response_id: field::SecurityResponseIDField, security_response_type: field::SecurityResponseTypeField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("w".to_string()));

        msg.body.set_field(tag::SECURITY_REQ_ID, security_req_id.0);

        msg.body.set_field(tag::SECURITY_RESPONSE_ID, security_response_id.0);

        msg.body.set_field(tag::SECURITY_RESPONSE_TYPE, security_response_type.0);

        Self { message: msg }
    }

    /// Creates a `SecurityTypes` 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 `EncodedText`, Tag 355.
    pub fn set_encoded_text(&mut self, v: String) {
        self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
    }

    /// Gets `EncodedText`, Tag 355.
    pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::EncodedTextField::new(String::new());
        self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `EncodedText` is present, Tag 355.
    pub fn has_encoded_text(&self) -> bool {
        self.message.body.has(tag::ENCODED_TEXT)
    }




    /// Sets `EncodedTextLen`, Tag 354.
    pub fn set_encoded_text_len(&mut self, v: isize) {
        self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `EncodedTextLen`, Tag 354.
    pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::EncodedTextLenField::new(0);
        self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `EncodedTextLen` is present, Tag 354.
    pub fn has_encoded_text_len(&self) -> bool {
        self.message.body.has(tag::ENCODED_TEXT_LEN)
    }




    /// Sets `LastFragment`, Tag 893.
    pub fn set_last_fragment(&mut self, v: bool) {
        self.message.body.set_field(tag::LAST_FRAGMENT, fixer::fix_boolean::FIXBoolean::from(v));
    }

    /// Gets `LastFragment`, Tag 893.
    pub fn get_last_fragment(&self) -> Result<bool, MessageRejectErrorEnum> {
        let mut fld = field::LastFragmentField::new(false);
        self.message.body.get_field(tag::LAST_FRAGMENT, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `LastFragment` is present, Tag 893.
    pub fn has_last_fragment(&self) -> bool {
        self.message.body.has(tag::LAST_FRAGMENT)
    }




    /// Sets `NoSecurityTypes`, Tag 558.
    pub fn set_no_security_types(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_SECURITY_TYPES, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoSecurityTypes`, Tag 558.
    pub fn get_no_security_types(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoSecurityTypesField::new(0);
        self.message.body.get_field(tag::NO_SECURITY_TYPES, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoSecurityTypes` is present, Tag 558.
    pub fn has_no_security_types(&self) -> bool {
        self.message.body.has(tag::NO_SECURITY_TYPES)
    }




    /// Sets `SecurityReqID`, Tag 320.
    pub fn set_security_req_id(&mut self, v: String) {
        self.message.body.set_field(tag::SECURITY_REQ_ID, FIXString::from(v));
    }

    /// Gets `SecurityReqID`, Tag 320.
    pub fn get_security_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::SecurityReqIDField::new(String::new());
        self.message.body.get_field(tag::SECURITY_REQ_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `SecurityReqID` is present, Tag 320.
    pub fn has_security_req_id(&self) -> bool {
        self.message.body.has(tag::SECURITY_REQ_ID)
    }




    /// Sets `SecurityResponseID`, Tag 322.
    pub fn set_security_response_id(&mut self, v: String) {
        self.message.body.set_field(tag::SECURITY_RESPONSE_ID, FIXString::from(v));
    }

    /// Gets `SecurityResponseID`, Tag 322.
    pub fn get_security_response_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::SecurityResponseIDField::new(String::new());
        self.message.body.get_field(tag::SECURITY_RESPONSE_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `SecurityResponseID` is present, Tag 322.
    pub fn has_security_response_id(&self) -> bool {
        self.message.body.has(tag::SECURITY_RESPONSE_ID)
    }




    /// Sets `SecurityResponseType`, Tag 323.
    pub fn set_security_response_type(&mut self, v: isize) {
        self.message.body.set_field(tag::SECURITY_RESPONSE_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `SecurityResponseType`, Tag 323.
    pub fn get_security_response_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::SecurityResponseTypeField::new(0);
        self.message.body.get_field(tag::SECURITY_RESPONSE_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `SecurityResponseType` is present, Tag 323.
    pub fn has_security_response_type(&self) -> bool {
        self.message.body.has(tag::SECURITY_RESPONSE_TYPE)
    }




    /// Sets `SubscriptionRequestType`, Tag 263.
    pub fn set_subscription_request_type(&mut self, v: String) {
        self.message.body.set_field(tag::SUBSCRIPTION_REQUEST_TYPE, FIXString::from(v));
    }

    /// Gets `SubscriptionRequestType`, Tag 263.
    pub fn get_subscription_request_type(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::SubscriptionRequestTypeField::new(String::new());
        self.message.body.get_field(tag::SUBSCRIPTION_REQUEST_TYPE, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `SubscriptionRequestType` is present, Tag 263.
    pub fn has_subscription_request_type(&self) -> bool {
        self.message.body.has(tag::SUBSCRIPTION_REQUEST_TYPE)
    }




    /// Sets `Text`, Tag 58.
    pub fn set_text(&mut self, v: String) {
        self.message.body.set_field(tag::TEXT, FIXString::from(v));
    }

    /// Gets `Text`, Tag 58.
    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::TextField::new(String::new());
        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `Text` is present, Tag 58.
    pub fn has_text(&self) -> bool {
        self.message.body.has(tag::TEXT)
    }




    /// Sets `TotNoSecurityTypes`, Tag 557.
    pub fn set_tot_no_security_types(&mut self, v: isize) {
        self.message.body.set_field(tag::TOT_NO_SECURITY_TYPES, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `TotNoSecurityTypes`, Tag 557.
    pub fn get_tot_no_security_types(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::TotNoSecurityTypesField::new(0);
        self.message.body.get_field(tag::TOT_NO_SECURITY_TYPES, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `TotNoSecurityTypes` is present, Tag 557.
    pub fn has_tot_no_security_types(&self) -> bool {
        self.message.body.has(tag::TOT_NO_SECURITY_TYPES)
    }




    /// Sets `TradingSessionID`, Tag 336.
    pub fn set_trading_session_id(&mut self, v: String) {
        self.message.body.set_field(tag::TRADING_SESSION_ID, FIXString::from(v));
    }

    /// Gets `TradingSessionID`, Tag 336.
    pub fn get_trading_session_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::TradingSessionIDField::new(String::new());
        self.message.body.get_field(tag::TRADING_SESSION_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `TradingSessionID` is present, Tag 336.
    pub fn has_trading_session_id(&self) -> bool {
        self.message.body.has(tag::TRADING_SESSION_ID)
    }




    /// Sets `TradingSessionSubID`, Tag 625.
    pub fn set_trading_session_sub_id(&mut self, v: String) {
        self.message.body.set_field(tag::TRADING_SESSION_SUB_ID, FIXString::from(v));
    }

    /// Gets `TradingSessionSubID`, Tag 625.
    pub fn get_trading_session_sub_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::TradingSessionSubIDField::new(String::new());
        self.message.body.get_field(tag::TRADING_SESSION_SUB_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `TradingSessionSubID` is present, Tag 625.
    pub fn has_trading_session_sub_id(&self) -> bool {
        self.message.body.has(tag::TRADING_SESSION_SUB_ID)
    }


}

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