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
12use rust_decimal::Decimal;
13
14
15use crate::field;
16use crate::tag;
17
18pub struct SecurityDefinition {
20 pub message: Message,
21}
22
23impl SecurityDefinition {
24 pub fn new(security_req_id: field::SecurityReqIDField, security_response_id: field::SecurityResponseIDField, total_num_securities: field::TotalNumSecuritiesField) -> Self {
26 let mut msg = Message::new();
27 msg.header.set_field(tag::MSG_TYPE, FIXString::from("d".to_string()));
28
29 msg.body.set_field(tag::SECURITY_REQ_ID, security_req_id.0);
30
31 msg.body.set_field(tag::SECURITY_RESPONSE_ID, security_response_id.0);
32
33 msg.body.set_field(tag::TOTAL_NUM_SECURITIES, total_num_securities.0);
34
35 Self { message: msg }
36 }
37
38 pub fn from_message(msg: Message) -> Self {
40 Self { message: msg }
41 }
42
43 pub fn to_message(self) -> Message {
45 self.message
46 }
47
48
49
50
51 pub fn set_contract_multiplier(&mut self, val: Decimal, scale: i32) {
53 self.message.body.set_field(tag::CONTRACT_MULTIPLIER, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
54 }
55
56 pub fn get_contract_multiplier(&self) -> Result<Decimal, MessageRejectErrorEnum> {
58 let mut fld = field::ContractMultiplierField::new(Decimal::ZERO, 0);
59 self.message.body.get_field(tag::CONTRACT_MULTIPLIER, &mut fld.0)?;
60 Ok(fld.value())
61 }
62
63
64 pub fn has_contract_multiplier(&self) -> bool {
66 self.message.body.has(tag::CONTRACT_MULTIPLIER)
67 }
68
69
70
71
72 pub fn set_coupon_rate(&mut self, val: Decimal, scale: i32) {
74 self.message.body.set_field(tag::COUPON_RATE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
75 }
76
77 pub fn get_coupon_rate(&self) -> Result<Decimal, MessageRejectErrorEnum> {
79 let mut fld = field::CouponRateField::new(Decimal::ZERO, 0);
80 self.message.body.get_field(tag::COUPON_RATE, &mut fld.0)?;
81 Ok(fld.value())
82 }
83
84
85 pub fn has_coupon_rate(&self) -> bool {
87 self.message.body.has(tag::COUPON_RATE)
88 }
89
90
91
92
93 pub fn set_currency(&mut self, v: String) {
95 self.message.body.set_field(tag::CURRENCY, FIXString::from(v));
96 }
97
98 pub fn get_currency(&self) -> Result<String, MessageRejectErrorEnum> {
100 let mut fld = field::CurrencyField::new(String::new());
101 self.message.body.get_field(tag::CURRENCY, &mut fld.0)?;
102 Ok(fld.value().to_string())
103 }
104
105
106 pub fn has_currency(&self) -> bool {
108 self.message.body.has(tag::CURRENCY)
109 }
110
111
112
113
114 pub fn set_encoded_issuer(&mut self, v: String) {
116 self.message.body.set_field(tag::ENCODED_ISSUER, FIXString::from(v));
117 }
118
119 pub fn get_encoded_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
121 let mut fld = field::EncodedIssuerField::new(String::new());
122 self.message.body.get_field(tag::ENCODED_ISSUER, &mut fld.0)?;
123 Ok(fld.value().to_string())
124 }
125
126
127 pub fn has_encoded_issuer(&self) -> bool {
129 self.message.body.has(tag::ENCODED_ISSUER)
130 }
131
132
133
134
135 pub fn set_encoded_issuer_len(&mut self, v: isize) {
137 self.message.body.set_field(tag::ENCODED_ISSUER_LEN, fixer::fix_int::FIXInt::from(v));
138 }
139
140 pub fn get_encoded_issuer_len(&self) -> Result<isize, MessageRejectErrorEnum> {
142 let mut fld = field::EncodedIssuerLenField::new(0);
143 self.message.body.get_field(tag::ENCODED_ISSUER_LEN, &mut fld.0)?;
144 Ok(fld.value())
145 }
146
147
148 pub fn has_encoded_issuer_len(&self) -> bool {
150 self.message.body.has(tag::ENCODED_ISSUER_LEN)
151 }
152
153
154
155
156 pub fn set_encoded_security_desc(&mut self, v: String) {
158 self.message.body.set_field(tag::ENCODED_SECURITY_DESC, FIXString::from(v));
159 }
160
161 pub fn get_encoded_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
163 let mut fld = field::EncodedSecurityDescField::new(String::new());
164 self.message.body.get_field(tag::ENCODED_SECURITY_DESC, &mut fld.0)?;
165 Ok(fld.value().to_string())
166 }
167
168
169 pub fn has_encoded_security_desc(&self) -> bool {
171 self.message.body.has(tag::ENCODED_SECURITY_DESC)
172 }
173
174
175
176
177 pub fn set_encoded_security_desc_len(&mut self, v: isize) {
179 self.message.body.set_field(tag::ENCODED_SECURITY_DESC_LEN, fixer::fix_int::FIXInt::from(v));
180 }
181
182 pub fn get_encoded_security_desc_len(&self) -> Result<isize, MessageRejectErrorEnum> {
184 let mut fld = field::EncodedSecurityDescLenField::new(0);
185 self.message.body.get_field(tag::ENCODED_SECURITY_DESC_LEN, &mut fld.0)?;
186 Ok(fld.value())
187 }
188
189
190 pub fn has_encoded_security_desc_len(&self) -> bool {
192 self.message.body.has(tag::ENCODED_SECURITY_DESC_LEN)
193 }
194
195
196
197
198 pub fn set_encoded_text(&mut self, v: String) {
200 self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
201 }
202
203 pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
205 let mut fld = field::EncodedTextField::new(String::new());
206 self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
207 Ok(fld.value().to_string())
208 }
209
210
211 pub fn has_encoded_text(&self) -> bool {
213 self.message.body.has(tag::ENCODED_TEXT)
214 }
215
216
217
218
219 pub fn set_encoded_text_len(&mut self, v: isize) {
221 self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
222 }
223
224 pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
226 let mut fld = field::EncodedTextLenField::new(0);
227 self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
228 Ok(fld.value())
229 }
230
231
232 pub fn has_encoded_text_len(&self) -> bool {
234 self.message.body.has(tag::ENCODED_TEXT_LEN)
235 }
236
237
238
239
240 pub fn set_id_source(&mut self, v: String) {
242 self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
243 }
244
245 pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
247 let mut fld = field::IDSourceField::new(String::new());
248 self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
249 Ok(fld.value().to_string())
250 }
251
252
253 pub fn has_id_source(&self) -> bool {
255 self.message.body.has(tag::ID_SOURCE)
256 }
257
258
259
260
261 pub fn set_issuer(&mut self, v: String) {
263 self.message.body.set_field(tag::ISSUER, FIXString::from(v));
264 }
265
266 pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
268 let mut fld = field::IssuerField::new(String::new());
269 self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
270 Ok(fld.value().to_string())
271 }
272
273
274 pub fn has_issuer(&self) -> bool {
276 self.message.body.has(tag::ISSUER)
277 }
278
279
280
281
282 pub fn set_maturity_day(&mut self, v: isize) {
284 self.message.body.set_field(tag::MATURITY_DAY, fixer::fix_int::FIXInt::from(v));
285 }
286
287 pub fn get_maturity_day(&self) -> Result<isize, MessageRejectErrorEnum> {
289 let mut fld = field::MaturityDayField::new(0);
290 self.message.body.get_field(tag::MATURITY_DAY, &mut fld.0)?;
291 Ok(fld.value())
292 }
293
294
295 pub fn has_maturity_day(&self) -> bool {
297 self.message.body.has(tag::MATURITY_DAY)
298 }
299
300
301
302
303 pub fn set_maturity_month_year(&mut self, v: String) {
305 self.message.body.set_field(tag::MATURITY_MONTH_YEAR, FIXString::from(v));
306 }
307
308 pub fn get_maturity_month_year(&self) -> Result<String, MessageRejectErrorEnum> {
310 let mut fld = field::MaturityMonthYearField::new(String::new());
311 self.message.body.get_field(tag::MATURITY_MONTH_YEAR, &mut fld.0)?;
312 Ok(fld.value().to_string())
313 }
314
315
316 pub fn has_maturity_month_year(&self) -> bool {
318 self.message.body.has(tag::MATURITY_MONTH_YEAR)
319 }
320
321
322
323
324 pub fn set_no_related_sym(&mut self, v: isize) {
326 self.message.body.set_field(tag::NO_RELATED_SYM, fixer::fix_int::FIXInt::from(v));
327 }
328
329 pub fn get_no_related_sym(&self) -> Result<isize, MessageRejectErrorEnum> {
331 let mut fld = field::NoRelatedSymField::new(0);
332 self.message.body.get_field(tag::NO_RELATED_SYM, &mut fld.0)?;
333 Ok(fld.value())
334 }
335
336
337 pub fn has_no_related_sym(&self) -> bool {
339 self.message.body.has(tag::NO_RELATED_SYM)
340 }
341
342
343
344
345 pub fn set_opt_attribute(&mut self, v: String) {
347 self.message.body.set_field(tag::OPT_ATTRIBUTE, FIXString::from(v));
348 }
349
350 pub fn get_opt_attribute(&self) -> Result<String, MessageRejectErrorEnum> {
352 let mut fld = field::OptAttributeField::new(String::new());
353 self.message.body.get_field(tag::OPT_ATTRIBUTE, &mut fld.0)?;
354 Ok(fld.value().to_string())
355 }
356
357
358 pub fn has_opt_attribute(&self) -> bool {
360 self.message.body.has(tag::OPT_ATTRIBUTE)
361 }
362
363
364
365
366 pub fn set_put_or_call(&mut self, v: isize) {
368 self.message.body.set_field(tag::PUT_OR_CALL, fixer::fix_int::FIXInt::from(v));
369 }
370
371 pub fn get_put_or_call(&self) -> Result<isize, MessageRejectErrorEnum> {
373 let mut fld = field::PutOrCallField::new(0);
374 self.message.body.get_field(tag::PUT_OR_CALL, &mut fld.0)?;
375 Ok(fld.value())
376 }
377
378
379 pub fn has_put_or_call(&self) -> bool {
381 self.message.body.has(tag::PUT_OR_CALL)
382 }
383
384
385
386
387 pub fn set_security_desc(&mut self, v: String) {
389 self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
390 }
391
392 pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
394 let mut fld = field::SecurityDescField::new(String::new());
395 self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
396 Ok(fld.value().to_string())
397 }
398
399
400 pub fn has_security_desc(&self) -> bool {
402 self.message.body.has(tag::SECURITY_DESC)
403 }
404
405
406
407
408 pub fn set_security_exchange(&mut self, v: String) {
410 self.message.body.set_field(tag::SECURITY_EXCHANGE, FIXString::from(v));
411 }
412
413 pub fn get_security_exchange(&self) -> Result<String, MessageRejectErrorEnum> {
415 let mut fld = field::SecurityExchangeField::new(String::new());
416 self.message.body.get_field(tag::SECURITY_EXCHANGE, &mut fld.0)?;
417 Ok(fld.value().to_string())
418 }
419
420
421 pub fn has_security_exchange(&self) -> bool {
423 self.message.body.has(tag::SECURITY_EXCHANGE)
424 }
425
426
427
428
429 pub fn set_security_id(&mut self, v: String) {
431 self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
432 }
433
434 pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
436 let mut fld = field::SecurityIDField::new(String::new());
437 self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
438 Ok(fld.value().to_string())
439 }
440
441
442 pub fn has_security_id(&self) -> bool {
444 self.message.body.has(tag::SECURITY_ID)
445 }
446
447
448
449
450 pub fn set_security_req_id(&mut self, v: String) {
452 self.message.body.set_field(tag::SECURITY_REQ_ID, FIXString::from(v));
453 }
454
455 pub fn get_security_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
457 let mut fld = field::SecurityReqIDField::new(String::new());
458 self.message.body.get_field(tag::SECURITY_REQ_ID, &mut fld.0)?;
459 Ok(fld.value().to_string())
460 }
461
462
463 pub fn has_security_req_id(&self) -> bool {
465 self.message.body.has(tag::SECURITY_REQ_ID)
466 }
467
468
469
470
471 pub fn set_security_response_id(&mut self, v: String) {
473 self.message.body.set_field(tag::SECURITY_RESPONSE_ID, FIXString::from(v));
474 }
475
476 pub fn get_security_response_id(&self) -> Result<String, MessageRejectErrorEnum> {
478 let mut fld = field::SecurityResponseIDField::new(String::new());
479 self.message.body.get_field(tag::SECURITY_RESPONSE_ID, &mut fld.0)?;
480 Ok(fld.value().to_string())
481 }
482
483
484 pub fn has_security_response_id(&self) -> bool {
486 self.message.body.has(tag::SECURITY_RESPONSE_ID)
487 }
488
489
490
491
492 pub fn set_security_response_type(&mut self, v: isize) {
494 self.message.body.set_field(tag::SECURITY_RESPONSE_TYPE, fixer::fix_int::FIXInt::from(v));
495 }
496
497 pub fn get_security_response_type(&self) -> Result<isize, MessageRejectErrorEnum> {
499 let mut fld = field::SecurityResponseTypeField::new(0);
500 self.message.body.get_field(tag::SECURITY_RESPONSE_TYPE, &mut fld.0)?;
501 Ok(fld.value())
502 }
503
504
505 pub fn has_security_response_type(&self) -> bool {
507 self.message.body.has(tag::SECURITY_RESPONSE_TYPE)
508 }
509
510
511
512
513 pub fn set_security_type(&mut self, v: String) {
515 self.message.body.set_field(tag::SECURITY_TYPE, FIXString::from(v));
516 }
517
518 pub fn get_security_type(&self) -> Result<String, MessageRejectErrorEnum> {
520 let mut fld = field::SecurityTypeField::new(String::new());
521 self.message.body.get_field(tag::SECURITY_TYPE, &mut fld.0)?;
522 Ok(fld.value().to_string())
523 }
524
525
526 pub fn has_security_type(&self) -> bool {
528 self.message.body.has(tag::SECURITY_TYPE)
529 }
530
531
532
533
534 pub fn set_strike_price(&mut self, val: Decimal, scale: i32) {
536 self.message.body.set_field(tag::STRIKE_PRICE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
537 }
538
539 pub fn get_strike_price(&self) -> Result<Decimal, MessageRejectErrorEnum> {
541 let mut fld = field::StrikePriceField::new(Decimal::ZERO, 0);
542 self.message.body.get_field(tag::STRIKE_PRICE, &mut fld.0)?;
543 Ok(fld.value())
544 }
545
546
547 pub fn has_strike_price(&self) -> bool {
549 self.message.body.has(tag::STRIKE_PRICE)
550 }
551
552
553
554
555 pub fn set_symbol(&mut self, v: String) {
557 self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
558 }
559
560 pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
562 let mut fld = field::SymbolField::new(String::new());
563 self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
564 Ok(fld.value().to_string())
565 }
566
567
568 pub fn has_symbol(&self) -> bool {
570 self.message.body.has(tag::SYMBOL)
571 }
572
573
574
575
576 pub fn set_symbol_sfx(&mut self, v: String) {
578 self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
579 }
580
581 pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
583 let mut fld = field::SymbolSfxField::new(String::new());
584 self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
585 Ok(fld.value().to_string())
586 }
587
588
589 pub fn has_symbol_sfx(&self) -> bool {
591 self.message.body.has(tag::SYMBOL_SFX)
592 }
593
594
595
596
597 pub fn set_text(&mut self, v: String) {
599 self.message.body.set_field(tag::TEXT, FIXString::from(v));
600 }
601
602 pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
604 let mut fld = field::TextField::new(String::new());
605 self.message.body.get_field(tag::TEXT, &mut fld.0)?;
606 Ok(fld.value().to_string())
607 }
608
609
610 pub fn has_text(&self) -> bool {
612 self.message.body.has(tag::TEXT)
613 }
614
615
616
617
618 pub fn set_total_num_securities(&mut self, v: isize) {
620 self.message.body.set_field(tag::TOTAL_NUM_SECURITIES, fixer::fix_int::FIXInt::from(v));
621 }
622
623 pub fn get_total_num_securities(&self) -> Result<isize, MessageRejectErrorEnum> {
625 let mut fld = field::TotalNumSecuritiesField::new(0);
626 self.message.body.get_field(tag::TOTAL_NUM_SECURITIES, &mut fld.0)?;
627 Ok(fld.value())
628 }
629
630
631 pub fn has_total_num_securities(&self) -> bool {
633 self.message.body.has(tag::TOTAL_NUM_SECURITIES)
634 }
635
636
637
638
639 pub fn set_trading_session_id(&mut self, v: String) {
641 self.message.body.set_field(tag::TRADING_SESSION_ID, FIXString::from(v));
642 }
643
644 pub fn get_trading_session_id(&self) -> Result<String, MessageRejectErrorEnum> {
646 let mut fld = field::TradingSessionIDField::new(String::new());
647 self.message.body.get_field(tag::TRADING_SESSION_ID, &mut fld.0)?;
648 Ok(fld.value().to_string())
649 }
650
651
652 pub fn has_trading_session_id(&self) -> bool {
654 self.message.body.has(tag::TRADING_SESSION_ID)
655 }
656
657
658}
659
660pub type RouteOut = fn(msg: SecurityDefinition, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
662
663pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
665
666pub fn route(router: RouteOut) -> Route {
668 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
669 router(SecurityDefinition::from_message(msg.clone()), session_id)
670 };
671 ("FIX.4.2", "d", Box::new(r))
672}