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;

/// `StreamAssignmentReport` is the `fix50sp2` `StreamAssignmentReport` type, `MsgType` = CD.
pub struct StreamAssignmentReport {
    pub message: Message,
}

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

        msg.body.set_field(tag::STREAM_ASGN_RPT_ID, stream_asgn_rpt_id.0);

        Self { message: msg }
    }

    /// Creates a `StreamAssignmentReport` 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 `NoAsgnReqs`, Tag 1499.
    pub fn set_no_asgn_reqs(&mut self, v: isize) {
        self.message.body.set_field(tag::NO_ASGN_REQS, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `NoAsgnReqs`, Tag 1499.
    pub fn get_no_asgn_reqs(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::NoAsgnReqsField::new(0);
        self.message.body.get_field(tag::NO_ASGN_REQS, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `NoAsgnReqs` is present, Tag 1499.
    pub fn has_no_asgn_reqs(&self) -> bool {
        self.message.body.has(tag::NO_ASGN_REQS)
    }




    /// Sets `StreamAsgnReqID`, Tag 1497.
    pub fn set_stream_asgn_req_id(&mut self, v: String) {
        self.message.body.set_field(tag::STREAM_ASGN_REQ_ID, FIXString::from(v));
    }

    /// Gets `StreamAsgnReqID`, Tag 1497.
    pub fn get_stream_asgn_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::StreamAsgnReqIDField::new(String::new());
        self.message.body.get_field(tag::STREAM_ASGN_REQ_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `StreamAsgnReqID` is present, Tag 1497.
    pub fn has_stream_asgn_req_id(&self) -> bool {
        self.message.body.has(tag::STREAM_ASGN_REQ_ID)
    }




    /// Sets `StreamAsgnReqType`, Tag 1498.
    pub fn set_stream_asgn_req_type(&mut self, v: isize) {
        self.message.body.set_field(tag::STREAM_ASGN_REQ_TYPE, fixer::fix_int::FIXInt::from(v));
    }

    /// Gets `StreamAsgnReqType`, Tag 1498.
    pub fn get_stream_asgn_req_type(&self) -> Result<isize, MessageRejectErrorEnum> {
        let mut fld = field::StreamAsgnReqTypeField::new(0);
        self.message.body.get_field(tag::STREAM_ASGN_REQ_TYPE, &mut fld.0)?;
        Ok(fld.value())
    }


    /// Returns true if `StreamAsgnReqType` is present, Tag 1498.
    pub fn has_stream_asgn_req_type(&self) -> bool {
        self.message.body.has(tag::STREAM_ASGN_REQ_TYPE)
    }




    /// Sets `StreamAsgnRptID`, Tag 1501.
    pub fn set_stream_asgn_rpt_id(&mut self, v: String) {
        self.message.body.set_field(tag::STREAM_ASGN_RPT_ID, FIXString::from(v));
    }

    /// Gets `StreamAsgnRptID`, Tag 1501.
    pub fn get_stream_asgn_rpt_id(&self) -> Result<String, MessageRejectErrorEnum> {
        let mut fld = field::StreamAsgnRptIDField::new(String::new());
        self.message.body.get_field(tag::STREAM_ASGN_RPT_ID, &mut fld.0)?;
        Ok(fld.value().to_string())
    }


    /// Returns true if `StreamAsgnRptID` is present, Tag 1501.
    pub fn has_stream_asgn_rpt_id(&self) -> bool {
        self.message.body.has(tag::STREAM_ASGN_RPT_ID)
    }


}

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