fixer_fix/fix50/
trading_session_status_request.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 TradingSessionStatusRequest {
18 pub message: Message,
19}
20
21impl TradingSessionStatusRequest {
22 pub fn new(trad_ses_req_id: field::TradSesReqIDField, subscription_request_type: field::SubscriptionRequestTypeField) -> Self {
24 let mut msg = Message::new();
25 msg.header.set_field(tag::MSG_TYPE, FIXString::from("g".to_string()));
26
27 msg.body.set_field(tag::TRAD_SES_REQ_ID, trad_ses_req_id.0);
28
29 msg.body.set_field(tag::SUBSCRIPTION_REQUEST_TYPE, subscription_request_type.0);
30
31 Self { message: msg }
32 }
33
34 pub fn from_message(msg: Message) -> Self {
36 Self { message: msg }
37 }
38
39 pub fn to_message(self) -> Message {
41 self.message
42 }
43
44
45
46
47 pub fn set_security_exchange(&mut self, v: String) {
49 self.message.body.set_field(tag::SECURITY_EXCHANGE, FIXString::from(v));
50 }
51
52 pub fn get_security_exchange(&self) -> Result<String, MessageRejectErrorEnum> {
54 let mut fld = field::SecurityExchangeField::new(String::new());
55 self.message.body.get_field(tag::SECURITY_EXCHANGE, &mut fld.0)?;
56 Ok(fld.value().to_string())
57 }
58
59
60 pub fn has_security_exchange(&self) -> bool {
62 self.message.body.has(tag::SECURITY_EXCHANGE)
63 }
64
65
66
67
68 pub fn set_subscription_request_type(&mut self, v: String) {
70 self.message.body.set_field(tag::SUBSCRIPTION_REQUEST_TYPE, FIXString::from(v));
71 }
72
73 pub fn get_subscription_request_type(&self) -> Result<String, MessageRejectErrorEnum> {
75 let mut fld = field::SubscriptionRequestTypeField::new(String::new());
76 self.message.body.get_field(tag::SUBSCRIPTION_REQUEST_TYPE, &mut fld.0)?;
77 Ok(fld.value().to_string())
78 }
79
80
81 pub fn has_subscription_request_type(&self) -> bool {
83 self.message.body.has(tag::SUBSCRIPTION_REQUEST_TYPE)
84 }
85
86
87
88
89 pub fn set_trad_ses_method(&mut self, v: isize) {
91 self.message.body.set_field(tag::TRAD_SES_METHOD, fixer::fix_int::FIXInt::from(v));
92 }
93
94 pub fn get_trad_ses_method(&self) -> Result<isize, MessageRejectErrorEnum> {
96 let mut fld = field::TradSesMethodField::new(0);
97 self.message.body.get_field(tag::TRAD_SES_METHOD, &mut fld.0)?;
98 Ok(fld.value())
99 }
100
101
102 pub fn has_trad_ses_method(&self) -> bool {
104 self.message.body.has(tag::TRAD_SES_METHOD)
105 }
106
107
108
109
110 pub fn set_trad_ses_mode(&mut self, v: isize) {
112 self.message.body.set_field(tag::TRAD_SES_MODE, fixer::fix_int::FIXInt::from(v));
113 }
114
115 pub fn get_trad_ses_mode(&self) -> Result<isize, MessageRejectErrorEnum> {
117 let mut fld = field::TradSesModeField::new(0);
118 self.message.body.get_field(tag::TRAD_SES_MODE, &mut fld.0)?;
119 Ok(fld.value())
120 }
121
122
123 pub fn has_trad_ses_mode(&self) -> bool {
125 self.message.body.has(tag::TRAD_SES_MODE)
126 }
127
128
129
130
131 pub fn set_trad_ses_req_id(&mut self, v: String) {
133 self.message.body.set_field(tag::TRAD_SES_REQ_ID, FIXString::from(v));
134 }
135
136 pub fn get_trad_ses_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
138 let mut fld = field::TradSesReqIDField::new(String::new());
139 self.message.body.get_field(tag::TRAD_SES_REQ_ID, &mut fld.0)?;
140 Ok(fld.value().to_string())
141 }
142
143
144 pub fn has_trad_ses_req_id(&self) -> bool {
146 self.message.body.has(tag::TRAD_SES_REQ_ID)
147 }
148
149
150
151
152 pub fn set_trading_session_id(&mut self, v: String) {
154 self.message.body.set_field(tag::TRADING_SESSION_ID, FIXString::from(v));
155 }
156
157 pub fn get_trading_session_id(&self) -> Result<String, MessageRejectErrorEnum> {
159 let mut fld = field::TradingSessionIDField::new(String::new());
160 self.message.body.get_field(tag::TRADING_SESSION_ID, &mut fld.0)?;
161 Ok(fld.value().to_string())
162 }
163
164
165 pub fn has_trading_session_id(&self) -> bool {
167 self.message.body.has(tag::TRADING_SESSION_ID)
168 }
169
170
171
172
173 pub fn set_trading_session_sub_id(&mut self, v: String) {
175 self.message.body.set_field(tag::TRADING_SESSION_SUB_ID, FIXString::from(v));
176 }
177
178 pub fn get_trading_session_sub_id(&self) -> Result<String, MessageRejectErrorEnum> {
180 let mut fld = field::TradingSessionSubIDField::new(String::new());
181 self.message.body.get_field(tag::TRADING_SESSION_SUB_ID, &mut fld.0)?;
182 Ok(fld.value().to_string())
183 }
184
185
186 pub fn has_trading_session_sub_id(&self) -> bool {
188 self.message.body.has(tag::TRADING_SESSION_SUB_ID)
189 }
190
191
192}
193
194pub type RouteOut = fn(msg: TradingSessionStatusRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
196
197pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
199
200pub fn route(router: RouteOut) -> Route {
202 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
203 router(TradingSessionStatusRequest::from_message(msg.clone()), session_id)
204 };
205 ("7", "g", Box::new(r))
206}