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;

/// `QuoteCancel` is the `fix42` `QuoteCancel` type, `MsgType` = Z.
pub struct QuoteCancel {
    pub message: Message,
}

impl QuoteCancel {
    /// Creates a new `QuoteCancel` with required fields.
    pub fn new(quote_id: field::QuoteIDField, quote_cancel_type: field::QuoteCancelTypeField, no_quote_entries: field::NoQuoteEntriesField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("Z".to_string()));

        msg.body.set_field(tag::QUOTE_ID, quote_id.0);

        msg.body.set_field(tag::QUOTE_CANCEL_TYPE, quote_cancel_type.0);

        msg.body.set_field(tag::NO_QUOTE_ENTRIES, no_quote_entries.0);

        Self { message: msg }
    }

    /// Creates a `QuoteCancel` 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 `NoQuoteEntries`, Tag 295.
    pub fn set_no_quote_entries(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_QUOTE_ENTRIES, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoQuoteEntries`, Tag 295.
    pub fn get_no_quote_entries(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoQuoteEntriesField::new(0);
        self.message.body.get_field(tag::NO_QUOTE_ENTRIES, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoQuoteEntries` is present, Tag 295.
    pub fn has_no_quote_entries(&self) -> bool {
        self.message.body.has(tag::NO_QUOTE_ENTRIES)
    }




    /// Sets `QuoteCancelType`, Tag 298.
    pub fn set_quote_cancel_type(&mut self, v: isize) {
        self.message.body.set_field(tag::QUOTE_CANCEL_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `QuoteCancelType`, Tag 298.
    pub fn get_quote_cancel_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::QuoteCancelTypeField::new(0);
        self.message.body.get_field(tag::QUOTE_CANCEL_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `QuoteCancelType` is present, Tag 298.
    pub fn has_quote_cancel_type(&self) -> bool {
        self.message.body.has(tag::QUOTE_CANCEL_TYPE)
    }




    /// Sets `QuoteID`, Tag 117.
    pub fn set_quote_id(&mut self, v: String) {
        self.message.body.set_field(tag::QUOTE_ID, FIXString::from(v));
    }

    /// Gets `QuoteID`, Tag 117.
    pub fn get_quote_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::QuoteIDField::new(String::new());
        self.message.body.get_field(tag::QUOTE_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `QuoteID` is present, Tag 117.
    pub fn has_quote_id(&self) -> bool {
        self.message.body.has(tag::QUOTE_ID)
    }




    /// Sets `QuoteReqID`, Tag 131.
    pub fn set_quote_req_id(&mut self, v: String) {
        self.message.body.set_field(tag::QUOTE_REQ_ID, FIXString::from(v));
    }

    /// Gets `QuoteReqID`, Tag 131.
    pub fn get_quote_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::QuoteReqIDField::new(String::new());
        self.message.body.get_field(tag::QUOTE_REQ_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `QuoteReqID` is present, Tag 131.
    pub fn has_quote_req_id(&self) -> bool {
        self.message.body.has(tag::QUOTE_REQ_ID)
    }




    /// Sets `QuoteResponseLevel`, Tag 301.
    pub fn set_quote_response_level(&mut self, v: isize) {
        self.message.body.set_field(tag::QUOTE_RESPONSE_LEVEL, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `QuoteResponseLevel`, Tag 301.
    pub fn get_quote_response_level(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::QuoteResponseLevelField::new(0);
        self.message.body.get_field(tag::QUOTE_RESPONSE_LEVEL, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `QuoteResponseLevel` is present, Tag 301.
    pub fn has_quote_response_level(&self) -> bool {
        self.message.body.has(tag::QUOTE_RESPONSE_LEVEL)
    }




    /// Sets `TradingSessionID`, Tag 336.
    pub fn set_trading_session_id(&mut self, v: String) {
        self.message.body.set_field(tag::TRADING_SESSION_ID, FIXString::from(v));
    }

    /// Gets `TradingSessionID`, Tag 336.
    pub fn get_trading_session_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::TradingSessionIDField::new(String::new());
        self.message.body.get_field(tag::TRADING_SESSION_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `TradingSessionID` is present, Tag 336.
    pub fn has_trading_session_id(&self) -> bool {
        self.message.body.has(tag::TRADING_SESSION_ID)
    }


}

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