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;

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

impl ApplicationMessageRequest {
    /// Creates a new `ApplicationMessageRequest` with required fields.
    pub fn new(appl_req_id: field::ApplReqIDField, appl_req_type: field::ApplReqTypeField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("BW".to_string()));

        msg.body.set_field(tag::APPL_REQ_ID, appl_req_id.0);

        msg.body.set_field(tag::APPL_REQ_TYPE, appl_req_type.0);

        Self { message: msg }
    }

    /// Creates a `ApplicationMessageRequest` 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 `ApplReqID`, Tag 1346.
    pub fn set_appl_req_id(&mut self, v: String) {
        self.message.body.set_field(tag::APPL_REQ_ID, FIXString::from(v));
    }

    /// Gets `ApplReqID`, Tag 1346.
    pub fn get_appl_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::ApplReqIDField::new(String::new());
        self.message.body.get_field(tag::APPL_REQ_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `ApplReqID` is present, Tag 1346.
    pub fn has_appl_req_id(&self) -> bool {
        self.message.body.has(tag::APPL_REQ_ID)
    }




    /// Sets `ApplReqType`, Tag 1347.
    pub fn set_appl_req_type(&mut self, v: isize) {
        self.message.body.set_field(tag::APPL_REQ_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `ApplReqType`, Tag 1347.
    pub fn get_appl_req_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::ApplReqTypeField::new(0);
        self.message.body.get_field(tag::APPL_REQ_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `ApplReqType` is present, Tag 1347.
    pub fn has_appl_req_type(&self) -> bool {
        self.message.body.has(tag::APPL_REQ_TYPE)
    }




    /// 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 `NoApplIDs`, Tag 1351.
    pub fn set_no_appl_i_ds(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_APPL_I_DS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoApplIDs`, Tag 1351.
    pub fn get_no_appl_i_ds(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoApplIDsField::new(0);
        self.message.body.get_field(tag::NO_APPL_I_DS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoApplIDs` is present, Tag 1351.
    pub fn has_no_appl_i_ds(&self) -> bool {
        self.message.body.has(tag::NO_APPL_I_DS)
    }




    /// 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 `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)
    }


}

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