#![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;
pub struct BidResponse {
pub message: Message,
}
impl BidResponse {
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 }
}
pub fn from_message(msg: Message) -> Self {
Self { message: msg }
}
pub fn to_message(self) -> Message {
self.message
}
pub fn set_bid_id(&mut self, v: String) {
self.message.body.set_field(tag::BID_ID, FIXString::from(v));
}
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())
}
pub fn has_bid_id(&self) -> bool {
self.message.body.has(tag::BID_ID)
}
pub fn set_client_bid_id(&mut self, v: String) {
self.message.body.set_field(tag::CLIENT_BID_ID, FIXString::from(v));
}
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())
}
pub fn has_client_bid_id(&self) -> bool {
self.message.body.has(tag::CLIENT_BID_ID)
}
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));
}
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())
}
pub fn has_no_bid_components(&self) -> bool {
self.message.body.has(tag::NO_BID_COMPONENTS)
}
}
pub type RouteOut = fn(msg: BidResponse, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
pub fn route(router: RouteOut) -> Route {
let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
router(BidResponse::from_message(msg.clone()), session_id)
};
("9", "l", Box::new(r))
}