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 jiff::Timestamp;

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

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

impl AllocationInstructionAck {
    /// Creates a new `AllocationInstructionAck` with required fields.
    pub fn new(alloc_id: field::AllocIDField, alloc_status: field::AllocStatusField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("P".to_string()));

        msg.body.set_field(tag::ALLOC_ID, alloc_id.0);

        msg.body.set_field(tag::ALLOC_STATUS, alloc_status.0);

        Self { message: msg }
    }

    /// Creates a `AllocationInstructionAck` 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 `AllocID`, Tag 70.
    pub fn set_alloc_id(&mut self, v: String) {
        self.message.body.set_field(tag::ALLOC_ID, FIXString::from(v));
    }

    /// Gets `AllocID`, Tag 70.
    pub fn get_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::AllocIDField::new(String::new());
        self.message.body.get_field(tag::ALLOC_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `AllocID` is present, Tag 70.
    pub fn has_alloc_id(&self) -> bool {
        self.message.body.has(tag::ALLOC_ID)
    }




    /// Sets `AllocIntermedReqType`, Tag 808.
    pub fn set_alloc_intermed_req_type(&mut self, v: isize) {
        self.message.body.set_field(tag::ALLOC_INTERMED_REQ_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `AllocIntermedReqType`, Tag 808.
    pub fn get_alloc_intermed_req_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::AllocIntermedReqTypeField::new(0);
        self.message.body.get_field(tag::ALLOC_INTERMED_REQ_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `AllocIntermedReqType` is present, Tag 808.
    pub fn has_alloc_intermed_req_type(&self) -> bool {
        self.message.body.has(tag::ALLOC_INTERMED_REQ_TYPE)
    }




    /// Sets `AllocRejCode`, Tag 88.
    pub fn set_alloc_rej_code(&mut self, v: isize) {
        self.message.body.set_field(tag::ALLOC_REJ_CODE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `AllocRejCode`, Tag 88.
    pub fn get_alloc_rej_code(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::AllocRejCodeField::new(0);
        self.message.body.get_field(tag::ALLOC_REJ_CODE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `AllocRejCode` is present, Tag 88.
    pub fn has_alloc_rej_code(&self) -> bool {
        self.message.body.has(tag::ALLOC_REJ_CODE)
    }




    /// Sets `AllocStatus`, Tag 87.
    pub fn set_alloc_status(&mut self, v: isize) {
        self.message.body.set_field(tag::ALLOC_STATUS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `AllocStatus`, Tag 87.
    pub fn get_alloc_status(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::AllocStatusField::new(0);
        self.message.body.get_field(tag::ALLOC_STATUS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `AllocStatus` is present, Tag 87.
    pub fn has_alloc_status(&self) -> bool {
        self.message.body.has(tag::ALLOC_STATUS)
    }




    /// Sets `AllocType`, Tag 626.
    pub fn set_alloc_type(&mut self, v: isize) {
        self.message.body.set_field(tag::ALLOC_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `AllocType`, Tag 626.
    pub fn get_alloc_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::AllocTypeField::new(0);
        self.message.body.get_field(tag::ALLOC_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `AllocType` is present, Tag 626.
    pub fn has_alloc_type(&self) -> bool {
        self.message.body.has(tag::ALLOC_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 `MatchStatus`, Tag 573.
    pub fn set_match_status(&mut self, v: String) {
        self.message.body.set_field(tag::MATCH_STATUS, FIXString::from(v));
    }

    /// Gets `MatchStatus`, Tag 573.
    pub fn get_match_status(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::MatchStatusField::new(String::new());
        self.message.body.get_field(tag::MATCH_STATUS, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `MatchStatus` is present, Tag 573.
    pub fn has_match_status(&self) -> bool {
        self.message.body.has(tag::MATCH_STATUS)
    }




    /// Sets `NoAllocs`, Tag 78.
    pub fn set_no_allocs(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_ALLOCS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoAllocs`, Tag 78.
    pub fn get_no_allocs(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoAllocsField::new(0);
        self.message.body.get_field(tag::NO_ALLOCS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoAllocs` is present, Tag 78.
    pub fn has_no_allocs(&self) -> bool {
        self.message.body.has(tag::NO_ALLOCS)
    }




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

    /// Gets `Product`, Tag 460.
    pub fn get_product(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::ProductField::new(0);
        self.message.body.get_field(tag::PRODUCT, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `Product` is present, Tag 460.
    pub fn has_product(&self) -> bool {
        self.message.body.has(tag::PRODUCT)
    }




    /// Sets `SecondaryAllocID`, Tag 793.
    pub fn set_secondary_alloc_id(&mut self, v: String) {
        self.message.body.set_field(tag::SECONDARY_ALLOC_ID, FIXString::from(v));
    }

    /// Gets `SecondaryAllocID`, Tag 793.
    pub fn get_secondary_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::SecondaryAllocIDField::new(String::new());
        self.message.body.get_field(tag::SECONDARY_ALLOC_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `SecondaryAllocID` is present, Tag 793.
    pub fn has_secondary_alloc_id(&self) -> bool {
        self.message.body.has(tag::SECONDARY_ALLOC_ID)
    }




    /// Sets `SecurityType`, Tag 167.
    pub fn set_security_type(&mut self, v: String) {
        self.message.body.set_field(tag::SECURITY_TYPE, FIXString::from(v));
    }

    /// Gets `SecurityType`, Tag 167.
    pub fn get_security_type(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::SecurityTypeField::new(String::new());
        self.message.body.get_field(tag::SECURITY_TYPE, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `SecurityType` is present, Tag 167.
    pub fn has_security_type(&self) -> bool {
        self.message.body.has(tag::SECURITY_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 `TradeDate`, Tag 75.
    pub fn set_trade_date(&mut self, v: String) {
        self.message.body.set_field(tag::TRADE_DATE, FIXString::from(v));
    }

    /// Gets `TradeDate`, Tag 75.
    pub fn get_trade_date(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::TradeDateField::new(String::new());
        self.message.body.get_field(tag::TRADE_DATE, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `TradeDate` is present, Tag 75.
    pub fn has_trade_date(&self) -> bool {
        self.message.body.has(tag::TRADE_DATE)
    }




    /// Sets `TransactTime`, Tag 60.
    pub fn set_transact_time(&mut self, v: Timestamp) {
        self.message.body.set_field(tag::TRANSACT_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
            time: v,
            precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
        });
    }

    /// Gets `TransactTime`, Tag 60.
    pub fn get_transact_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
        let mut fld = field::TransactTimeField::new(Timestamp::UNIX_EPOCH);
        self.message.body.get_field(tag::TRANSACT_TIME, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `TransactTime` is present, Tag 60.
    pub fn has_transact_time(&self) -> bool {
        self.message.body.has(tag::TRANSACT_TIME)
    }


}

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