1#![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 SecurityTypes {
18 pub message: Message,
19}
20
21impl SecurityTypes {
22 pub fn new(security_req_id: field::SecurityReqIDField, security_response_id: field::SecurityResponseIDField, security_response_type: field::SecurityResponseTypeField) -> Self {
24 let mut msg = Message::new();
25 msg.header.set_field(tag::MSG_TYPE, FIXString::from("w".to_string()));
26
27 msg.body.set_field(tag::SECURITY_REQ_ID, security_req_id.0);
28
29 msg.body.set_field(tag::SECURITY_RESPONSE_ID, security_response_id.0);
30
31 msg.body.set_field(tag::SECURITY_RESPONSE_TYPE, security_response_type.0);
32
33 Self { message: msg }
34 }
35
36 pub fn from_message(msg: Message) -> Self {
38 Self { message: msg }
39 }
40
41 pub fn to_message(self) -> Message {
43 self.message
44 }
45
46
47
48
49 pub fn set_appl_id(&mut self, v: String) {
51 self.message.body.set_field(tag::APPL_ID, FIXString::from(v));
52 }
53
54 pub fn get_appl_id(&self) -> Result<String, MessageRejectErrorEnum> {
56 let mut fld = field::ApplIDField::new(String::new());
57 self.message.body.get_field(tag::APPL_ID, &mut fld.0)?;
58 Ok(fld.value().to_string())
59 }
60
61
62 pub fn has_appl_id(&self) -> bool {
64 self.message.body.has(tag::APPL_ID)
65 }
66
67
68
69
70 pub fn set_appl_last_seq_num(&mut self, v: isize) {
72 self.message.body.set_field(tag::APPL_LAST_SEQ_NUM, fixer::fix_int::FIXInt::from(v));
73 }
74
75 pub fn get_appl_last_seq_num(&self) -> Result<isize, MessageRejectErrorEnum> {
77 let mut fld = field::ApplLastSeqNumField::new(0);
78 self.message.body.get_field(tag::APPL_LAST_SEQ_NUM, &mut fld.0)?;
79 Ok(fld.value())
80 }
81
82
83 pub fn has_appl_last_seq_num(&self) -> bool {
85 self.message.body.has(tag::APPL_LAST_SEQ_NUM)
86 }
87
88
89
90
91 pub fn set_appl_resend_flag(&mut self, v: bool) {
93 self.message.body.set_field(tag::APPL_RESEND_FLAG, fixer::fix_boolean::FIXBoolean::from(v));
94 }
95
96 pub fn get_appl_resend_flag(&self) -> Result<bool, MessageRejectErrorEnum> {
98 let mut fld = field::ApplResendFlagField::new(false);
99 self.message.body.get_field(tag::APPL_RESEND_FLAG, &mut fld.0)?;
100 Ok(fld.value())
101 }
102
103
104 pub fn has_appl_resend_flag(&self) -> bool {
106 self.message.body.has(tag::APPL_RESEND_FLAG)
107 }
108
109
110
111
112 pub fn set_appl_seq_num(&mut self, v: isize) {
114 self.message.body.set_field(tag::APPL_SEQ_NUM, fixer::fix_int::FIXInt::from(v));
115 }
116
117 pub fn get_appl_seq_num(&self) -> Result<isize, MessageRejectErrorEnum> {
119 let mut fld = field::ApplSeqNumField::new(0);
120 self.message.body.get_field(tag::APPL_SEQ_NUM, &mut fld.0)?;
121 Ok(fld.value())
122 }
123
124
125 pub fn has_appl_seq_num(&self) -> bool {
127 self.message.body.has(tag::APPL_SEQ_NUM)
128 }
129
130
131
132
133 pub fn set_encoded_text(&mut self, v: String) {
135 self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
136 }
137
138 pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
140 let mut fld = field::EncodedTextField::new(String::new());
141 self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
142 Ok(fld.value().to_string())
143 }
144
145
146 pub fn has_encoded_text(&self) -> bool {
148 self.message.body.has(tag::ENCODED_TEXT)
149 }
150
151
152
153
154 pub fn set_encoded_text_len(&mut self, v: isize) {
156 self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
157 }
158
159 pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
161 let mut fld = field::EncodedTextLenField::new(0);
162 self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
163 Ok(fld.value())
164 }
165
166
167 pub fn has_encoded_text_len(&self) -> bool {
169 self.message.body.has(tag::ENCODED_TEXT_LEN)
170 }
171
172
173
174
175 pub fn set_last_fragment(&mut self, v: bool) {
177 self.message.body.set_field(tag::LAST_FRAGMENT, fixer::fix_boolean::FIXBoolean::from(v));
178 }
179
180 pub fn get_last_fragment(&self) -> Result<bool, MessageRejectErrorEnum> {
182 let mut fld = field::LastFragmentField::new(false);
183 self.message.body.get_field(tag::LAST_FRAGMENT, &mut fld.0)?;
184 Ok(fld.value())
185 }
186
187
188 pub fn has_last_fragment(&self) -> bool {
190 self.message.body.has(tag::LAST_FRAGMENT)
191 }
192
193
194
195
196 pub fn set_market_id(&mut self, v: String) {
198 self.message.body.set_field(tag::MARKET_ID, FIXString::from(v));
199 }
200
201 pub fn get_market_id(&self) -> Result<String, MessageRejectErrorEnum> {
203 let mut fld = field::MarketIDField::new(String::new());
204 self.message.body.get_field(tag::MARKET_ID, &mut fld.0)?;
205 Ok(fld.value().to_string())
206 }
207
208
209 pub fn has_market_id(&self) -> bool {
211 self.message.body.has(tag::MARKET_ID)
212 }
213
214
215
216
217 pub fn set_market_segment_id(&mut self, v: String) {
219 self.message.body.set_field(tag::MARKET_SEGMENT_ID, FIXString::from(v));
220 }
221
222 pub fn get_market_segment_id(&self) -> Result<String, MessageRejectErrorEnum> {
224 let mut fld = field::MarketSegmentIDField::new(String::new());
225 self.message.body.get_field(tag::MARKET_SEGMENT_ID, &mut fld.0)?;
226 Ok(fld.value().to_string())
227 }
228
229
230 pub fn has_market_segment_id(&self) -> bool {
232 self.message.body.has(tag::MARKET_SEGMENT_ID)
233 }
234
235
236
237
238 pub fn set_no_security_types(&mut self, v: isize) {
240 self.message.body.set_field(tag::NO_SECURITY_TYPES, fixer::fix_int::FIXInt::from(v));
241 }
242
243 pub fn get_no_security_types(&self) -> Result<isize, MessageRejectErrorEnum> {
245 let mut fld = field::NoSecurityTypesField::new(0);
246 self.message.body.get_field(tag::NO_SECURITY_TYPES, &mut fld.0)?;
247 Ok(fld.value())
248 }
249
250
251 pub fn has_no_security_types(&self) -> bool {
253 self.message.body.has(tag::NO_SECURITY_TYPES)
254 }
255
256
257
258
259 pub fn set_security_req_id(&mut self, v: String) {
261 self.message.body.set_field(tag::SECURITY_REQ_ID, FIXString::from(v));
262 }
263
264 pub fn get_security_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
266 let mut fld = field::SecurityReqIDField::new(String::new());
267 self.message.body.get_field(tag::SECURITY_REQ_ID, &mut fld.0)?;
268 Ok(fld.value().to_string())
269 }
270
271
272 pub fn has_security_req_id(&self) -> bool {
274 self.message.body.has(tag::SECURITY_REQ_ID)
275 }
276
277
278
279
280 pub fn set_security_response_id(&mut self, v: String) {
282 self.message.body.set_field(tag::SECURITY_RESPONSE_ID, FIXString::from(v));
283 }
284
285 pub fn get_security_response_id(&self) -> Result<String, MessageRejectErrorEnum> {
287 let mut fld = field::SecurityResponseIDField::new(String::new());
288 self.message.body.get_field(tag::SECURITY_RESPONSE_ID, &mut fld.0)?;
289 Ok(fld.value().to_string())
290 }
291
292
293 pub fn has_security_response_id(&self) -> bool {
295 self.message.body.has(tag::SECURITY_RESPONSE_ID)
296 }
297
298
299
300
301 pub fn set_security_response_type(&mut self, v: isize) {
303 self.message.body.set_field(tag::SECURITY_RESPONSE_TYPE, fixer::fix_int::FIXInt::from(v));
304 }
305
306 pub fn get_security_response_type(&self) -> Result<isize, MessageRejectErrorEnum> {
308 let mut fld = field::SecurityResponseTypeField::new(0);
309 self.message.body.get_field(tag::SECURITY_RESPONSE_TYPE, &mut fld.0)?;
310 Ok(fld.value())
311 }
312
313
314 pub fn has_security_response_type(&self) -> bool {
316 self.message.body.has(tag::SECURITY_RESPONSE_TYPE)
317 }
318
319
320
321
322 pub fn set_subscription_request_type(&mut self, v: String) {
324 self.message.body.set_field(tag::SUBSCRIPTION_REQUEST_TYPE, FIXString::from(v));
325 }
326
327 pub fn get_subscription_request_type(&self) -> Result<String, MessageRejectErrorEnum> {
329 let mut fld = field::SubscriptionRequestTypeField::new(String::new());
330 self.message.body.get_field(tag::SUBSCRIPTION_REQUEST_TYPE, &mut fld.0)?;
331 Ok(fld.value().to_string())
332 }
333
334
335 pub fn has_subscription_request_type(&self) -> bool {
337 self.message.body.has(tag::SUBSCRIPTION_REQUEST_TYPE)
338 }
339
340
341
342
343 pub fn set_text(&mut self, v: String) {
345 self.message.body.set_field(tag::TEXT, FIXString::from(v));
346 }
347
348 pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
350 let mut fld = field::TextField::new(String::new());
351 self.message.body.get_field(tag::TEXT, &mut fld.0)?;
352 Ok(fld.value().to_string())
353 }
354
355
356 pub fn has_text(&self) -> bool {
358 self.message.body.has(tag::TEXT)
359 }
360
361
362
363
364 pub fn set_tot_no_security_types(&mut self, v: isize) {
366 self.message.body.set_field(tag::TOT_NO_SECURITY_TYPES, fixer::fix_int::FIXInt::from(v));
367 }
368
369 pub fn get_tot_no_security_types(&self) -> Result<isize, MessageRejectErrorEnum> {
371 let mut fld = field::TotNoSecurityTypesField::new(0);
372 self.message.body.get_field(tag::TOT_NO_SECURITY_TYPES, &mut fld.0)?;
373 Ok(fld.value())
374 }
375
376
377 pub fn has_tot_no_security_types(&self) -> bool {
379 self.message.body.has(tag::TOT_NO_SECURITY_TYPES)
380 }
381
382
383
384
385 pub fn set_trading_session_id(&mut self, v: String) {
387 self.message.body.set_field(tag::TRADING_SESSION_ID, FIXString::from(v));
388 }
389
390 pub fn get_trading_session_id(&self) -> Result<String, MessageRejectErrorEnum> {
392 let mut fld = field::TradingSessionIDField::new(String::new());
393 self.message.body.get_field(tag::TRADING_SESSION_ID, &mut fld.0)?;
394 Ok(fld.value().to_string())
395 }
396
397
398 pub fn has_trading_session_id(&self) -> bool {
400 self.message.body.has(tag::TRADING_SESSION_ID)
401 }
402
403
404
405
406 pub fn set_trading_session_sub_id(&mut self, v: String) {
408 self.message.body.set_field(tag::TRADING_SESSION_SUB_ID, FIXString::from(v));
409 }
410
411 pub fn get_trading_session_sub_id(&self) -> Result<String, MessageRejectErrorEnum> {
413 let mut fld = field::TradingSessionSubIDField::new(String::new());
414 self.message.body.get_field(tag::TRADING_SESSION_SUB_ID, &mut fld.0)?;
415 Ok(fld.value().to_string())
416 }
417
418
419 pub fn has_trading_session_sub_id(&self) -> bool {
421 self.message.body.has(tag::TRADING_SESSION_SUB_ID)
422 }
423
424
425}
426
427pub type RouteOut = fn(msg: SecurityTypes, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
429
430pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
432
433pub fn route(router: RouteOut) -> Route {
435 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
436 router(SecurityTypes::from_message(msg.clone()), session_id)
437 };
438 ("9", "w", Box::new(r))
439}