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;

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

impl ConfirmationRequest {
    /// Creates a new `ConfirmationRequest` with required fields.
    pub fn new(confirm_req_id: field::ConfirmReqIDField, confirm_type: field::ConfirmTypeField, transact_time: field::TransactTimeField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("BH".to_string()));

        msg.body.set_field(tag::CONFIRM_REQ_ID, confirm_req_id.0);

        msg.body.set_field(tag::CONFIRM_TYPE, confirm_type.0);

        msg.body.set_field(tag::TRANSACT_TIME, transact_time.0);

        Self { message: msg }
    }

    /// Creates a `ConfirmationRequest` 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 `AllocAccount`, Tag 79.
    pub fn set_alloc_account(&mut self, v: String) {
        self.message.body.set_field(tag::ALLOC_ACCOUNT, FIXString::from(v));
    }

    /// Gets `AllocAccount`, Tag 79.
    pub fn get_alloc_account(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::AllocAccountField::new(String::new());
        self.message.body.get_field(tag::ALLOC_ACCOUNT, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `AllocAccount` is present, Tag 79.
    pub fn has_alloc_account(&self) -> bool {
        self.message.body.has(tag::ALLOC_ACCOUNT)
    }




    /// Sets `AllocAccountType`, Tag 798.
    pub fn set_alloc_account_type(&mut self, v: isize) {
        self.message.body.set_field(tag::ALLOC_ACCOUNT_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `AllocAccountType`, Tag 798.
    pub fn get_alloc_account_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::AllocAccountTypeField::new(0);
        self.message.body.get_field(tag::ALLOC_ACCOUNT_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `AllocAccountType` is present, Tag 798.
    pub fn has_alloc_account_type(&self) -> bool {
        self.message.body.has(tag::ALLOC_ACCOUNT_TYPE)
    }




    /// Sets `AllocAcctIDSource`, Tag 661.
    pub fn set_alloc_acct_id_source(&mut self, v: isize) {
        self.message.body.set_field(tag::ALLOC_ACCT_ID_SOURCE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `AllocAcctIDSource`, Tag 661.
    pub fn get_alloc_acct_id_source(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::AllocAcctIDSourceField::new(0);
        self.message.body.get_field(tag::ALLOC_ACCT_ID_SOURCE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `AllocAcctIDSource` is present, Tag 661.
    pub fn has_alloc_acct_id_source(&self) -> bool {
        self.message.body.has(tag::ALLOC_ACCT_ID_SOURCE)
    }




    /// 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 `ConfirmReqID`, Tag 859.
    pub fn set_confirm_req_id(&mut self, v: String) {
        self.message.body.set_field(tag::CONFIRM_REQ_ID, FIXString::from(v));
    }

    /// Gets `ConfirmReqID`, Tag 859.
    pub fn get_confirm_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::ConfirmReqIDField::new(String::new());
        self.message.body.get_field(tag::CONFIRM_REQ_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `ConfirmReqID` is present, Tag 859.
    pub fn has_confirm_req_id(&self) -> bool {
        self.message.body.has(tag::CONFIRM_REQ_ID)
    }




    /// Sets `ConfirmType`, Tag 773.
    pub fn set_confirm_type(&mut self, v: isize) {
        self.message.body.set_field(tag::CONFIRM_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `ConfirmType`, Tag 773.
    pub fn get_confirm_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::ConfirmTypeField::new(0);
        self.message.body.get_field(tag::CONFIRM_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `ConfirmType` is present, Tag 773.
    pub fn has_confirm_type(&self) -> bool {
        self.message.body.has(tag::CONFIRM_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 `IndividualAllocID`, Tag 467.
    pub fn set_individual_alloc_id(&mut self, v: String) {
        self.message.body.set_field(tag::INDIVIDUAL_ALLOC_ID, FIXString::from(v));
    }

    /// Gets `IndividualAllocID`, Tag 467.
    pub fn get_individual_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::IndividualAllocIDField::new(String::new());
        self.message.body.get_field(tag::INDIVIDUAL_ALLOC_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `IndividualAllocID` is present, Tag 467.
    pub fn has_individual_alloc_id(&self) -> bool {
        self.message.body.has(tag::INDIVIDUAL_ALLOC_ID)
    }




    /// Sets `NoOrders`, Tag 73.
    pub fn set_no_orders(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_ORDERS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoOrders`, Tag 73.
    pub fn get_no_orders(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoOrdersField::new(0);
        self.message.body.get_field(tag::NO_ORDERS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoOrders` is present, Tag 73.
    pub fn has_no_orders(&self) -> bool {
        self.message.body.has(tag::NO_ORDERS)
    }




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