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 SecurityDefinitionRequest {
20 pub message: Message,
21}
22
23impl SecurityDefinitionRequest {
24 pub fn new(security_req_id: field::SecurityReqIDField, security_request_type: field::SecurityRequestTypeField) -> Self {
26 let mut msg = Message::new();
27 msg.header.set_field(tag::MSG_TYPE, FIXString::from("c".to_string()));
28
29 msg.body.set_field(tag::SECURITY_REQ_ID, security_req_id.0);
30
31 msg.body.set_field(tag::SECURITY_REQUEST_TYPE, security_request_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_contract_multiplier(&mut self, val: Decimal, scale: i32) {
51 self.message.body.set_field(tag::CONTRACT_MULTIPLIER, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
52 }
53
54 pub fn get_contract_multiplier(&self) -> Result<Decimal, MessageRejectErrorEnum> {
56 let mut fld = field::ContractMultiplierField::new(Decimal::ZERO, 0);
57 self.message.body.get_field(tag::CONTRACT_MULTIPLIER, &mut fld.0)?;
58 Ok(fld.value())
59 }
60
61
62 pub fn has_contract_multiplier(&self) -> bool {
64 self.message.body.has(tag::CONTRACT_MULTIPLIER)
65 }
66
67
68
69
70 pub fn set_coupon_rate(&mut self, val: Decimal, scale: i32) {
72 self.message.body.set_field(tag::COUPON_RATE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
73 }
74
75 pub fn get_coupon_rate(&self) -> Result<Decimal, MessageRejectErrorEnum> {
77 let mut fld = field::CouponRateField::new(Decimal::ZERO, 0);
78 self.message.body.get_field(tag::COUPON_RATE, &mut fld.0)?;
79 Ok(fld.value())
80 }
81
82
83 pub fn has_coupon_rate(&self) -> bool {
85 self.message.body.has(tag::COUPON_RATE)
86 }
87
88
89
90
91 pub fn set_currency(&mut self, v: String) {
93 self.message.body.set_field(tag::CURRENCY, FIXString::from(v));
94 }
95
96 pub fn get_currency(&self) -> Result<String, MessageRejectErrorEnum> {
98 let mut fld = field::CurrencyField::new(String::new());
99 self.message.body.get_field(tag::CURRENCY, &mut fld.0)?;
100 Ok(fld.value().to_string())
101 }
102
103
104 pub fn has_currency(&self) -> bool {
106 self.message.body.has(tag::CURRENCY)
107 }
108
109
110
111
112 pub fn set_encoded_issuer(&mut self, v: String) {
114 self.message.body.set_field(tag::ENCODED_ISSUER, FIXString::from(v));
115 }
116
117 pub fn get_encoded_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
119 let mut fld = field::EncodedIssuerField::new(String::new());
120 self.message.body.get_field(tag::ENCODED_ISSUER, &mut fld.0)?;
121 Ok(fld.value().to_string())
122 }
123
124
125 pub fn has_encoded_issuer(&self) -> bool {
127 self.message.body.has(tag::ENCODED_ISSUER)
128 }
129
130
131
132
133 pub fn set_encoded_issuer_len(&mut self, v: isize) {
135 self.message.body.set_field(tag::ENCODED_ISSUER_LEN, fixer::fix_int::FIXInt::from(v));
136 }
137
138 pub fn get_encoded_issuer_len(&self) -> Result<isize, MessageRejectErrorEnum> {
140 let mut fld = field::EncodedIssuerLenField::new(0);
141 self.message.body.get_field(tag::ENCODED_ISSUER_LEN, &mut fld.0)?;
142 Ok(fld.value())
143 }
144
145
146 pub fn has_encoded_issuer_len(&self) -> bool {
148 self.message.body.has(tag::ENCODED_ISSUER_LEN)
149 }
150
151
152
153
154 pub fn set_encoded_security_desc(&mut self, v: String) {
156 self.message.body.set_field(tag::ENCODED_SECURITY_DESC, FIXString::from(v));
157 }
158
159 pub fn get_encoded_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
161 let mut fld = field::EncodedSecurityDescField::new(String::new());
162 self.message.body.get_field(tag::ENCODED_SECURITY_DESC, &mut fld.0)?;
163 Ok(fld.value().to_string())
164 }
165
166
167 pub fn has_encoded_security_desc(&self) -> bool {
169 self.message.body.has(tag::ENCODED_SECURITY_DESC)
170 }
171
172
173
174
175 pub fn set_encoded_security_desc_len(&mut self, v: isize) {
177 self.message.body.set_field(tag::ENCODED_SECURITY_DESC_LEN, fixer::fix_int::FIXInt::from(v));
178 }
179
180 pub fn get_encoded_security_desc_len(&self) -> Result<isize, MessageRejectErrorEnum> {
182 let mut fld = field::EncodedSecurityDescLenField::new(0);
183 self.message.body.get_field(tag::ENCODED_SECURITY_DESC_LEN, &mut fld.0)?;
184 Ok(fld.value())
185 }
186
187
188 pub fn has_encoded_security_desc_len(&self) -> bool {
190 self.message.body.has(tag::ENCODED_SECURITY_DESC_LEN)
191 }
192
193
194
195
196 pub fn set_encoded_text(&mut self, v: String) {
198 self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
199 }
200
201 pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
203 let mut fld = field::EncodedTextField::new(String::new());
204 self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
205 Ok(fld.value().to_string())
206 }
207
208
209 pub fn has_encoded_text(&self) -> bool {
211 self.message.body.has(tag::ENCODED_TEXT)
212 }
213
214
215
216
217 pub fn set_encoded_text_len(&mut self, v: isize) {
219 self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
220 }
221
222 pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
224 let mut fld = field::EncodedTextLenField::new(0);
225 self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
226 Ok(fld.value())
227 }
228
229
230 pub fn has_encoded_text_len(&self) -> bool {
232 self.message.body.has(tag::ENCODED_TEXT_LEN)
233 }
234
235
236
237
238 pub fn set_id_source(&mut self, v: String) {
240 self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
241 }
242
243 pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
245 let mut fld = field::IDSourceField::new(String::new());
246 self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
247 Ok(fld.value().to_string())
248 }
249
250
251 pub fn has_id_source(&self) -> bool {
253 self.message.body.has(tag::ID_SOURCE)
254 }
255
256
257
258
259 pub fn set_issuer(&mut self, v: String) {
261 self.message.body.set_field(tag::ISSUER, FIXString::from(v));
262 }
263
264 pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
266 let mut fld = field::IssuerField::new(String::new());
267 self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
268 Ok(fld.value().to_string())
269 }
270
271
272 pub fn has_issuer(&self) -> bool {
274 self.message.body.has(tag::ISSUER)
275 }
276
277
278
279
280 pub fn set_maturity_day(&mut self, v: isize) {
282 self.message.body.set_field(tag::MATURITY_DAY, fixer::fix_int::FIXInt::from(v));
283 }
284
285 pub fn get_maturity_day(&self) -> Result<isize, MessageRejectErrorEnum> {
287 let mut fld = field::MaturityDayField::new(0);
288 self.message.body.get_field(tag::MATURITY_DAY, &mut fld.0)?;
289 Ok(fld.value())
290 }
291
292
293 pub fn has_maturity_day(&self) -> bool {
295 self.message.body.has(tag::MATURITY_DAY)
296 }
297
298
299
300
301 pub fn set_maturity_month_year(&mut self, v: String) {
303 self.message.body.set_field(tag::MATURITY_MONTH_YEAR, FIXString::from(v));
304 }
305
306 pub fn get_maturity_month_year(&self) -> Result<String, MessageRejectErrorEnum> {
308 let mut fld = field::MaturityMonthYearField::new(String::new());
309 self.message.body.get_field(tag::MATURITY_MONTH_YEAR, &mut fld.0)?;
310 Ok(fld.value().to_string())
311 }
312
313
314 pub fn has_maturity_month_year(&self) -> bool {
316 self.message.body.has(tag::MATURITY_MONTH_YEAR)
317 }
318
319
320
321
322 pub fn set_no_related_sym(&mut self, v: isize) {
324 self.message.body.set_field(tag::NO_RELATED_SYM, fixer::fix_int::FIXInt::from(v));
325 }
326
327 pub fn get_no_related_sym(&self) -> Result<isize, MessageRejectErrorEnum> {
329 let mut fld = field::NoRelatedSymField::new(0);
330 self.message.body.get_field(tag::NO_RELATED_SYM, &mut fld.0)?;
331 Ok(fld.value())
332 }
333
334
335 pub fn has_no_related_sym(&self) -> bool {
337 self.message.body.has(tag::NO_RELATED_SYM)
338 }
339
340
341
342
343 pub fn set_opt_attribute(&mut self, v: String) {
345 self.message.body.set_field(tag::OPT_ATTRIBUTE, FIXString::from(v));
346 }
347
348 pub fn get_opt_attribute(&self) -> Result<String, MessageRejectErrorEnum> {
350 let mut fld = field::OptAttributeField::new(String::new());
351 self.message.body.get_field(tag::OPT_ATTRIBUTE, &mut fld.0)?;
352 Ok(fld.value().to_string())
353 }
354
355
356 pub fn has_opt_attribute(&self) -> bool {
358 self.message.body.has(tag::OPT_ATTRIBUTE)
359 }
360
361
362
363
364 pub fn set_put_or_call(&mut self, v: isize) {
366 self.message.body.set_field(tag::PUT_OR_CALL, fixer::fix_int::FIXInt::from(v));
367 }
368
369 pub fn get_put_or_call(&self) -> Result<isize, MessageRejectErrorEnum> {
371 let mut fld = field::PutOrCallField::new(0);
372 self.message.body.get_field(tag::PUT_OR_CALL, &mut fld.0)?;
373 Ok(fld.value())
374 }
375
376
377 pub fn has_put_or_call(&self) -> bool {
379 self.message.body.has(tag::PUT_OR_CALL)
380 }
381
382
383
384
385 pub fn set_security_desc(&mut self, v: String) {
387 self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
388 }
389
390 pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
392 let mut fld = field::SecurityDescField::new(String::new());
393 self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
394 Ok(fld.value().to_string())
395 }
396
397
398 pub fn has_security_desc(&self) -> bool {
400 self.message.body.has(tag::SECURITY_DESC)
401 }
402
403
404
405
406 pub fn set_security_exchange(&mut self, v: String) {
408 self.message.body.set_field(tag::SECURITY_EXCHANGE, FIXString::from(v));
409 }
410
411 pub fn get_security_exchange(&self) -> Result<String, MessageRejectErrorEnum> {
413 let mut fld = field::SecurityExchangeField::new(String::new());
414 self.message.body.get_field(tag::SECURITY_EXCHANGE, &mut fld.0)?;
415 Ok(fld.value().to_string())
416 }
417
418
419 pub fn has_security_exchange(&self) -> bool {
421 self.message.body.has(tag::SECURITY_EXCHANGE)
422 }
423
424
425
426
427 pub fn set_security_id(&mut self, v: String) {
429 self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
430 }
431
432 pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
434 let mut fld = field::SecurityIDField::new(String::new());
435 self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
436 Ok(fld.value().to_string())
437 }
438
439
440 pub fn has_security_id(&self) -> bool {
442 self.message.body.has(tag::SECURITY_ID)
443 }
444
445
446
447
448 pub fn set_security_req_id(&mut self, v: String) {
450 self.message.body.set_field(tag::SECURITY_REQ_ID, FIXString::from(v));
451 }
452
453 pub fn get_security_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
455 let mut fld = field::SecurityReqIDField::new(String::new());
456 self.message.body.get_field(tag::SECURITY_REQ_ID, &mut fld.0)?;
457 Ok(fld.value().to_string())
458 }
459
460
461 pub fn has_security_req_id(&self) -> bool {
463 self.message.body.has(tag::SECURITY_REQ_ID)
464 }
465
466
467
468
469 pub fn set_security_request_type(&mut self, v: isize) {
471 self.message.body.set_field(tag::SECURITY_REQUEST_TYPE, fixer::fix_int::FIXInt::from(v));
472 }
473
474 pub fn get_security_request_type(&self) -> Result<isize, MessageRejectErrorEnum> {
476 let mut fld = field::SecurityRequestTypeField::new(0);
477 self.message.body.get_field(tag::SECURITY_REQUEST_TYPE, &mut fld.0)?;
478 Ok(fld.value())
479 }
480
481
482 pub fn has_security_request_type(&self) -> bool {
484 self.message.body.has(tag::SECURITY_REQUEST_TYPE)
485 }
486
487
488
489
490 pub fn set_security_type(&mut self, v: String) {
492 self.message.body.set_field(tag::SECURITY_TYPE, FIXString::from(v));
493 }
494
495 pub fn get_security_type(&self) -> Result<String, MessageRejectErrorEnum> {
497 let mut fld = field::SecurityTypeField::new(String::new());
498 self.message.body.get_field(tag::SECURITY_TYPE, &mut fld.0)?;
499 Ok(fld.value().to_string())
500 }
501
502
503 pub fn has_security_type(&self) -> bool {
505 self.message.body.has(tag::SECURITY_TYPE)
506 }
507
508
509
510
511 pub fn set_strike_price(&mut self, val: Decimal, scale: i32) {
513 self.message.body.set_field(tag::STRIKE_PRICE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
514 }
515
516 pub fn get_strike_price(&self) -> Result<Decimal, MessageRejectErrorEnum> {
518 let mut fld = field::StrikePriceField::new(Decimal::ZERO, 0);
519 self.message.body.get_field(tag::STRIKE_PRICE, &mut fld.0)?;
520 Ok(fld.value())
521 }
522
523
524 pub fn has_strike_price(&self) -> bool {
526 self.message.body.has(tag::STRIKE_PRICE)
527 }
528
529
530
531
532 pub fn set_symbol(&mut self, v: String) {
534 self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
535 }
536
537 pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
539 let mut fld = field::SymbolField::new(String::new());
540 self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
541 Ok(fld.value().to_string())
542 }
543
544
545 pub fn has_symbol(&self) -> bool {
547 self.message.body.has(tag::SYMBOL)
548 }
549
550
551
552
553 pub fn set_symbol_sfx(&mut self, v: String) {
555 self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
556 }
557
558 pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
560 let mut fld = field::SymbolSfxField::new(String::new());
561 self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
562 Ok(fld.value().to_string())
563 }
564
565
566 pub fn has_symbol_sfx(&self) -> bool {
568 self.message.body.has(tag::SYMBOL_SFX)
569 }
570
571
572
573
574 pub fn set_text(&mut self, v: String) {
576 self.message.body.set_field(tag::TEXT, FIXString::from(v));
577 }
578
579 pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
581 let mut fld = field::TextField::new(String::new());
582 self.message.body.get_field(tag::TEXT, &mut fld.0)?;
583 Ok(fld.value().to_string())
584 }
585
586
587 pub fn has_text(&self) -> bool {
589 self.message.body.has(tag::TEXT)
590 }
591
592
593
594
595 pub fn set_trading_session_id(&mut self, v: String) {
597 self.message.body.set_field(tag::TRADING_SESSION_ID, FIXString::from(v));
598 }
599
600 pub fn get_trading_session_id(&self) -> Result<String, MessageRejectErrorEnum> {
602 let mut fld = field::TradingSessionIDField::new(String::new());
603 self.message.body.get_field(tag::TRADING_SESSION_ID, &mut fld.0)?;
604 Ok(fld.value().to_string())
605 }
606
607
608 pub fn has_trading_session_id(&self) -> bool {
610 self.message.body.has(tag::TRADING_SESSION_ID)
611 }
612
613
614}
615
616pub type RouteOut = fn(msg: SecurityDefinitionRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
618
619pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
621
622pub fn route(router: RouteOut) -> Route {
624 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
625 router(SecurityDefinitionRequest::from_message(msg.clone()), session_id)
626 };
627 ("FIX.4.2", "c", Box::new(r))
628}