fixer_fix/fix50/
bid_response.rs1#![allow(clippy::new_without_default)]
3#![allow(clippy::needless_pass_by_value)]
4#![allow(clippy::too_many_arguments)]
5#![allow(unused_imports)]
6
7use fixer::message::Message;
8use fixer::fix_string::FIXString;
9use fixer::errors::MessageRejectErrorEnum;
10use fixer::session::session_id::SessionID;
11
12
13use crate::field;
14use crate::tag;
15
16pub struct BidResponse {
18 pub message: Message,
19}
20
21impl BidResponse {
22 pub fn new(no_bid_components: field::NoBidComponentsField) -> Self {
24 let mut msg = Message::new();
25 msg.header.set_field(tag::MSG_TYPE, FIXString::from("l".to_string()));
26
27 msg.body.set_field(tag::NO_BID_COMPONENTS, no_bid_components.0);
28
29 Self { message: msg }
30 }
31
32 pub fn from_message(msg: Message) -> Self {
34 Self { message: msg }
35 }
36
37 pub fn to_message(self) -> Message {
39 self.message
40 }
41
42
43
44
45 pub fn set_bid_id(&mut self, v: String) {
47 self.message.body.set_field(tag::BID_ID, FIXString::from(v));
48 }
49
50 pub fn get_bid_id(&self) -> Result<String, MessageRejectErrorEnum> {
52 let mut fld = field::BidIDField::new(String::new());
53 self.message.body.get_field(tag::BID_ID, &mut fld.0)?;
54 Ok(fld.value().to_string())
55 }
56
57
58 pub fn has_bid_id(&self) -> bool {
60 self.message.body.has(tag::BID_ID)
61 }
62
63
64
65
66 pub fn set_client_bid_id(&mut self, v: String) {
68 self.message.body.set_field(tag::CLIENT_BID_ID, FIXString::from(v));
69 }
70
71 pub fn get_client_bid_id(&self) -> Result<String, MessageRejectErrorEnum> {
73 let mut fld = field::ClientBidIDField::new(String::new());
74 self.message.body.get_field(tag::CLIENT_BID_ID, &mut fld.0)?;
75 Ok(fld.value().to_string())
76 }
77
78
79 pub fn has_client_bid_id(&self) -> bool {
81 self.message.body.has(tag::CLIENT_BID_ID)
82 }
83
84
85
86
87 pub fn set_no_bid_components(&mut self, v: isize) {
89 self.message.body.set_field(tag::NO_BID_COMPONENTS, fixer::fix_int::FIXInt::from(v));
90 }
91
92 pub fn get_no_bid_components(&self) -> Result<isize, MessageRejectErrorEnum> {
94 let mut fld = field::NoBidComponentsField::new(0);
95 self.message.body.get_field(tag::NO_BID_COMPONENTS, &mut fld.0)?;
96 Ok(fld.value())
97 }
98
99
100 pub fn has_no_bid_components(&self) -> bool {
102 self.message.body.has(tag::NO_BID_COMPONENTS)
103 }
104
105
106}
107
108pub type RouteOut = fn(msg: BidResponse, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
110
111pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
113
114pub fn route(router: RouteOut) -> Route {
116 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
117 router(BidResponse::from_message(msg.clone()), session_id)
118 };
119 ("7", "l", Box::new(r))
120}