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;

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

impl BidResponse {
    /// Creates a new `BidResponse` with required fields.
    pub fn new(no_bid_components: field::NoBidComponentsField) -> Self {
        let mut msg = Message::new();
        msg.header.set_field(tag::MSG_TYPE, FIXString::from("l".to_string()));

        msg.body.set_field(tag::NO_BID_COMPONENTS, no_bid_components.0);

        Self { message: msg }
    }

    /// Creates a `BidResponse` 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 `BidID`, Tag 390.
    pub fn set_bid_id(&mut self, v: String) {
        self.message.body.set_field(tag::BID_ID, FIXString::from(v));
    }

    /// Gets `BidID`, Tag 390.
    pub fn get_bid_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::BidIDField::new(String::new());
        self.message.body.get_field(tag::BID_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `BidID` is present, Tag 390.
    pub fn has_bid_id(&self) -> bool {
        self.message.body.has(tag::BID_ID)
    }




    /// Sets `ClientBidID`, Tag 391.
    pub fn set_client_bid_id(&mut self, v: String) {
        self.message.body.set_field(tag::CLIENT_BID_ID, FIXString::from(v));
    }

    /// Gets `ClientBidID`, Tag 391.
    pub fn get_client_bid_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::ClientBidIDField::new(String::new());
        self.message.body.get_field(tag::CLIENT_BID_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `ClientBidID` is present, Tag 391.
    pub fn has_client_bid_id(&self) -> bool {
        self.message.body.has(tag::CLIENT_BID_ID)
    }




    /// Sets `NoBidComponents`, Tag 420.
    pub fn set_no_bid_components(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_BID_COMPONENTS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoBidComponents`, Tag 420.
    pub fn get_no_bid_components(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoBidComponentsField::new(0);
        self.message.body.get_field(tag::NO_BID_COMPONENTS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoBidComponents` is present, Tag 420.
    pub fn has_no_bid_components(&self) -> bool {
        self.message.body.has(tag::NO_BID_COMPONENTS)
    }


}

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