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;

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

impl AllocationAck {
    /// Creates a new `AllocationAck` with required fields.
    pub fn new(alloc_id: field::AllocIDField, trade_date: field::TradeDateField, 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::TRADE_DATE, trade_date.0);

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

        Self { message: msg }
    }

    /// Creates a `AllocationAck` 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 `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 `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 `LegalConfirm`, Tag 650.
    pub fn set_legal_confirm(&mut self, v: bool) {
        self.message.body.set_field(tag::LEGAL_CONFIRM, fixer::fix_boolean::FIXBoolean::from(v));
    }

    /// Gets `LegalConfirm`, Tag 650.
    pub fn get_legal_confirm(&self) -> Result<bool, MessageRejectErrorEnum> {
        let mut fld = field::LegalConfirmField::new(false);
        self.message.body.get_field(tag::LEGAL_CONFIRM, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `LegalConfirm` is present, Tag 650.
    pub fn has_legal_confirm(&self) -> bool {
        self.message.body.has(tag::LEGAL_CONFIRM)
    }




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




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