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 `fix40` `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 `ClientID`, Tag 109.
    pub fn set_client_id(&mut self, v: String) {
        self.message.body.set_field(tag::CLIENT_ID, FIXString::from(v));
    }

    /// Gets `ClientID`, Tag 109.
    pub fn get_client_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::ClientIDField::new(String::new());
        self.message.body.get_field(tag::CLIENT_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `ClientID` is present, Tag 109.
    pub fn has_client_id(&self) -> bool {
        self.message.body.has(tag::CLIENT_ID)
    }




    /// Sets `ExecBroker`, Tag 76.
    pub fn set_exec_broker(&mut self, v: String) {
        self.message.body.set_field(tag::EXEC_BROKER, FIXString::from(v));
    }

    /// Gets `ExecBroker`, Tag 76.
    pub fn get_exec_broker(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::ExecBrokerField::new(String::new());
        self.message.body.get_field(tag::EXEC_BROKER, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `ExecBroker` is present, Tag 76.
    pub fn has_exec_broker(&self) -> bool {
        self.message.body.has(tag::EXEC_BROKER)
    }




    /// 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.0", "P", Box::new(r))
}