Skip to main content

fixer_fix/fix42/
security_definition.rs

1// Code generated by fixer-gen. DO NOT EDIT.
2#![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
18/// `SecurityDefinition` is the `fix42` `SecurityDefinition` type, `MsgType` = d.
19pub struct SecurityDefinition {
20    pub message: Message,
21}
22
23impl SecurityDefinition {
24    /// Creates a new `SecurityDefinition` with required fields.
25    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    /// Creates a `SecurityDefinition` from an existing `Message`.
39    pub fn from_message(msg: Message) -> Self {
40        Self { message: msg }
41    }
42
43    /// Returns the underlying `Message`.
44    pub fn to_message(self) -> Message {
45        self.message
46    }
47
48
49
50
51    /// Sets `ContractMultiplier`, Tag 231.
52    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    /// Gets `ContractMultiplier`, Tag 231.
57    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    /// Returns true if `ContractMultiplier` is present, Tag 231.
65    pub fn has_contract_multiplier(&self) -> bool {
66        self.message.body.has(tag::CONTRACT_MULTIPLIER)
67    }
68
69
70
71
72    /// Sets `CouponRate`, Tag 223.
73    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    /// Gets `CouponRate`, Tag 223.
78    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    /// Returns true if `CouponRate` is present, Tag 223.
86    pub fn has_coupon_rate(&self) -> bool {
87        self.message.body.has(tag::COUPON_RATE)
88    }
89
90
91
92
93    /// Sets `Currency`, Tag 15.
94    pub fn set_currency(&mut self, v: String) {
95        self.message.body.set_field(tag::CURRENCY, FIXString::from(v));
96    }
97
98    /// Gets `Currency`, Tag 15.
99    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    /// Returns true if `Currency` is present, Tag 15.
107    pub fn has_currency(&self) -> bool {
108        self.message.body.has(tag::CURRENCY)
109    }
110
111
112
113
114    /// Sets `EncodedIssuer`, Tag 349.
115    pub fn set_encoded_issuer(&mut self, v: String) {
116        self.message.body.set_field(tag::ENCODED_ISSUER, FIXString::from(v));
117    }
118
119    /// Gets `EncodedIssuer`, Tag 349.
120    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    /// Returns true if `EncodedIssuer` is present, Tag 349.
128    pub fn has_encoded_issuer(&self) -> bool {
129        self.message.body.has(tag::ENCODED_ISSUER)
130    }
131
132
133
134
135    /// Sets `EncodedIssuerLen`, Tag 348.
136    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    /// Gets `EncodedIssuerLen`, Tag 348.
141    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    /// Returns true if `EncodedIssuerLen` is present, Tag 348.
149    pub fn has_encoded_issuer_len(&self) -> bool {
150        self.message.body.has(tag::ENCODED_ISSUER_LEN)
151    }
152
153
154
155
156    /// Sets `EncodedSecurityDesc`, Tag 351.
157    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    /// Gets `EncodedSecurityDesc`, Tag 351.
162    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    /// Returns true if `EncodedSecurityDesc` is present, Tag 351.
170    pub fn has_encoded_security_desc(&self) -> bool {
171        self.message.body.has(tag::ENCODED_SECURITY_DESC)
172    }
173
174
175
176
177    /// Sets `EncodedSecurityDescLen`, Tag 350.
178    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    /// Gets `EncodedSecurityDescLen`, Tag 350.
183    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    /// Returns true if `EncodedSecurityDescLen` is present, Tag 350.
191    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    /// Sets `EncodedText`, Tag 355.
199    pub fn set_encoded_text(&mut self, v: String) {
200        self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
201    }
202
203    /// Gets `EncodedText`, Tag 355.
204    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    /// Returns true if `EncodedText` is present, Tag 355.
212    pub fn has_encoded_text(&self) -> bool {
213        self.message.body.has(tag::ENCODED_TEXT)
214    }
215
216
217
218
219    /// Sets `EncodedTextLen`, Tag 354.
220    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    /// Gets `EncodedTextLen`, Tag 354.
225    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    /// Returns true if `EncodedTextLen` is present, Tag 354.
233    pub fn has_encoded_text_len(&self) -> bool {
234        self.message.body.has(tag::ENCODED_TEXT_LEN)
235    }
236
237
238
239
240    /// Sets `IDSource`, Tag 22.
241    pub fn set_id_source(&mut self, v: String) {
242        self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
243    }
244
245    /// Gets `IDSource`, Tag 22.
246    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    /// Returns true if `IDSource` is present, Tag 22.
254    pub fn has_id_source(&self) -> bool {
255        self.message.body.has(tag::ID_SOURCE)
256    }
257
258
259
260
261    /// Sets `Issuer`, Tag 106.
262    pub fn set_issuer(&mut self, v: String) {
263        self.message.body.set_field(tag::ISSUER, FIXString::from(v));
264    }
265
266    /// Gets `Issuer`, Tag 106.
267    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    /// Returns true if `Issuer` is present, Tag 106.
275    pub fn has_issuer(&self) -> bool {
276        self.message.body.has(tag::ISSUER)
277    }
278
279
280
281
282    /// Sets `MaturityDay`, Tag 205.
283    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    /// Gets `MaturityDay`, Tag 205.
288    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    /// Returns true if `MaturityDay` is present, Tag 205.
296    pub fn has_maturity_day(&self) -> bool {
297        self.message.body.has(tag::MATURITY_DAY)
298    }
299
300
301
302
303    /// Sets `MaturityMonthYear`, Tag 200.
304    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    /// Gets `MaturityMonthYear`, Tag 200.
309    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    /// Returns true if `MaturityMonthYear` is present, Tag 200.
317    pub fn has_maturity_month_year(&self) -> bool {
318        self.message.body.has(tag::MATURITY_MONTH_YEAR)
319    }
320
321
322
323
324    /// Sets `NoRelatedSym`, Tag 146.
325    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    /// Gets `NoRelatedSym`, Tag 146.
330    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    /// Returns true if `NoRelatedSym` is present, Tag 146.
338    pub fn has_no_related_sym(&self) -> bool {
339        self.message.body.has(tag::NO_RELATED_SYM)
340    }
341
342
343
344
345    /// Sets `OptAttribute`, Tag 206.
346    pub fn set_opt_attribute(&mut self, v: String) {
347        self.message.body.set_field(tag::OPT_ATTRIBUTE, FIXString::from(v));
348    }
349
350    /// Gets `OptAttribute`, Tag 206.
351    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    /// Returns true if `OptAttribute` is present, Tag 206.
359    pub fn has_opt_attribute(&self) -> bool {
360        self.message.body.has(tag::OPT_ATTRIBUTE)
361    }
362
363
364
365
366    /// Sets `PutOrCall`, Tag 201.
367    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    /// Gets `PutOrCall`, Tag 201.
372    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    /// Returns true if `PutOrCall` is present, Tag 201.
380    pub fn has_put_or_call(&self) -> bool {
381        self.message.body.has(tag::PUT_OR_CALL)
382    }
383
384
385
386
387    /// Sets `SecurityDesc`, Tag 107.
388    pub fn set_security_desc(&mut self, v: String) {
389        self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
390    }
391
392    /// Gets `SecurityDesc`, Tag 107.
393    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    /// Returns true if `SecurityDesc` is present, Tag 107.
401    pub fn has_security_desc(&self) -> bool {
402        self.message.body.has(tag::SECURITY_DESC)
403    }
404
405
406
407
408    /// Sets `SecurityExchange`, Tag 207.
409    pub fn set_security_exchange(&mut self, v: String) {
410        self.message.body.set_field(tag::SECURITY_EXCHANGE, FIXString::from(v));
411    }
412
413    /// Gets `SecurityExchange`, Tag 207.
414    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    /// Returns true if `SecurityExchange` is present, Tag 207.
422    pub fn has_security_exchange(&self) -> bool {
423        self.message.body.has(tag::SECURITY_EXCHANGE)
424    }
425
426
427
428
429    /// Sets `SecurityID`, Tag 48.
430    pub fn set_security_id(&mut self, v: String) {
431        self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
432    }
433
434    /// Gets `SecurityID`, Tag 48.
435    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    /// Returns true if `SecurityID` is present, Tag 48.
443    pub fn has_security_id(&self) -> bool {
444        self.message.body.has(tag::SECURITY_ID)
445    }
446
447
448
449
450    /// Sets `SecurityReqID`, Tag 320.
451    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    /// Gets `SecurityReqID`, Tag 320.
456    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    /// Returns true if `SecurityReqID` is present, Tag 320.
464    pub fn has_security_req_id(&self) -> bool {
465        self.message.body.has(tag::SECURITY_REQ_ID)
466    }
467
468
469
470
471    /// Sets `SecurityResponseID`, Tag 322.
472    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    /// Gets `SecurityResponseID`, Tag 322.
477    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    /// Returns true if `SecurityResponseID` is present, Tag 322.
485    pub fn has_security_response_id(&self) -> bool {
486        self.message.body.has(tag::SECURITY_RESPONSE_ID)
487    }
488
489
490
491
492    /// Sets `SecurityResponseType`, Tag 323.
493    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    /// Gets `SecurityResponseType`, Tag 323.
498    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    /// Returns true if `SecurityResponseType` is present, Tag 323.
506    pub fn has_security_response_type(&self) -> bool {
507        self.message.body.has(tag::SECURITY_RESPONSE_TYPE)
508    }
509
510
511
512
513    /// Sets `SecurityType`, Tag 167.
514    pub fn set_security_type(&mut self, v: String) {
515        self.message.body.set_field(tag::SECURITY_TYPE, FIXString::from(v));
516    }
517
518    /// Gets `SecurityType`, Tag 167.
519    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    /// Returns true if `SecurityType` is present, Tag 167.
527    pub fn has_security_type(&self) -> bool {
528        self.message.body.has(tag::SECURITY_TYPE)
529    }
530
531
532
533
534    /// Sets `StrikePrice`, Tag 202.
535    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    /// Gets `StrikePrice`, Tag 202.
540    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    /// Returns true if `StrikePrice` is present, Tag 202.
548    pub fn has_strike_price(&self) -> bool {
549        self.message.body.has(tag::STRIKE_PRICE)
550    }
551
552
553
554
555    /// Sets `Symbol`, Tag 55.
556    pub fn set_symbol(&mut self, v: String) {
557        self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
558    }
559
560    /// Gets `Symbol`, Tag 55.
561    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    /// Returns true if `Symbol` is present, Tag 55.
569    pub fn has_symbol(&self) -> bool {
570        self.message.body.has(tag::SYMBOL)
571    }
572
573
574
575
576    /// Sets `SymbolSfx`, Tag 65.
577    pub fn set_symbol_sfx(&mut self, v: String) {
578        self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
579    }
580
581    /// Gets `SymbolSfx`, Tag 65.
582    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    /// Returns true if `SymbolSfx` is present, Tag 65.
590    pub fn has_symbol_sfx(&self) -> bool {
591        self.message.body.has(tag::SYMBOL_SFX)
592    }
593
594
595
596
597    /// Sets `Text`, Tag 58.
598    pub fn set_text(&mut self, v: String) {
599        self.message.body.set_field(tag::TEXT, FIXString::from(v));
600    }
601
602    /// Gets `Text`, Tag 58.
603    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    /// Returns true if `Text` is present, Tag 58.
611    pub fn has_text(&self) -> bool {
612        self.message.body.has(tag::TEXT)
613    }
614
615
616
617
618    /// Sets `TotalNumSecurities`, Tag 393.
619    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    /// Gets `TotalNumSecurities`, Tag 393.
624    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    /// Returns true if `TotalNumSecurities` is present, Tag 393.
632    pub fn has_total_num_securities(&self) -> bool {
633        self.message.body.has(tag::TOTAL_NUM_SECURITIES)
634    }
635
636
637
638
639    /// Sets `TradingSessionID`, Tag 336.
640    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    /// Gets `TradingSessionID`, Tag 336.
645    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    /// Returns true if `TradingSessionID` is present, Tag 336.
653    pub fn has_trading_session_id(&self) -> bool {
654        self.message.body.has(tag::TRADING_SESSION_ID)
655    }
656
657
658}
659
660/// `RouteOut` is the callback type for routing `SecurityDefinition` messages.
661pub type RouteOut = fn(msg: SecurityDefinition, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
662
663/// Route type returned by the `route` function.
664pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
665
666/// Returns the begin string, message type, and route function for `SecurityDefinition`.
667pub 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}