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;

/// `ListStrikePrice` is the `fix50sp1` `ListStrikePrice` type, `MsgType` = m.
pub struct ListStrikePrice {
    pub message: Message,
}

impl ListStrikePrice {
    /// Creates a new `ListStrikePrice` with required fields.
    pub fn new(list_id: field::ListIDField, tot_no_strikes: field::TotNoStrikesField, no_strikes: field::NoStrikesField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("m".to_string()));

        msg.body.set_field(tag::LIST_ID, list_id.0);

        msg.body.set_field(tag::TOT_NO_STRIKES, tot_no_strikes.0);

        msg.body.set_field(tag::NO_STRIKES, no_strikes.0);

        Self { message: msg }
    }

    /// Creates a `ListStrikePrice` 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 `LastFragment`, Tag 893.
    pub fn set_last_fragment(&mut self, v: bool) {
        self.message.body.set_field(tag::LAST_FRAGMENT, fixer::fix_boolean::FIXBoolean::from(v));
    }

    /// Gets `LastFragment`, Tag 893.
    pub fn get_last_fragment(&self) -> Result<bool, MessageRejectErrorEnum> {
        let mut fld = field::LastFragmentField::new(false);
        self.message.body.get_field(tag::LAST_FRAGMENT, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `LastFragment` is present, Tag 893.
    pub fn has_last_fragment(&self) -> bool {
        self.message.body.has(tag::LAST_FRAGMENT)
    }




    /// Sets `ListID`, Tag 66.
    pub fn set_list_id(&mut self, v: String) {
        self.message.body.set_field(tag::LIST_ID, FIXString::from(v));
    }

    /// Gets `ListID`, Tag 66.
    pub fn get_list_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::ListIDField::new(String::new());
        self.message.body.get_field(tag::LIST_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `ListID` is present, Tag 66.
    pub fn has_list_id(&self) -> bool {
        self.message.body.has(tag::LIST_ID)
    }




    /// Sets `NoStrikes`, Tag 428.
    pub fn set_no_strikes(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_STRIKES, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoStrikes`, Tag 428.
    pub fn get_no_strikes(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoStrikesField::new(0);
        self.message.body.get_field(tag::NO_STRIKES, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoStrikes` is present, Tag 428.
    pub fn has_no_strikes(&self) -> bool {
        self.message.body.has(tag::NO_STRIKES)
    }




    /// Sets `TotNoStrikes`, Tag 422.
    pub fn set_tot_no_strikes(&mut self, v: isize) {
        self.message.body.set_field(tag::TOT_NO_STRIKES, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `TotNoStrikes`, Tag 422.
    pub fn get_tot_no_strikes(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::TotNoStrikesField::new(0);
        self.message.body.get_field(tag::TOT_NO_STRIKES, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `TotNoStrikes` is present, Tag 422.
    pub fn has_tot_no_strikes(&self) -> bool {
        self.message.body.has(tag::TOT_NO_STRIKES)
    }


}

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