Skip to main content

fixer_fix/fix41/
advertisement.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 jiff::Timestamp;
16
17use crate::field;
18use crate::tag;
19
20/// `Advertisement` is the `fix41` `Advertisement` type, `MsgType` = 7.
21pub struct Advertisement {
22    pub message: Message,
23}
24
25impl Advertisement {
26    /// Creates a new `Advertisement` with required fields.
27    pub fn new(adv_id: field::AdvIdField, adv_trans_type: field::AdvTransTypeField, symbol: field::SymbolField, adv_side: field::AdvSideField, shares: field::SharesField) -> Self {
28        let mut msg = Message::new();
29        msg.header.set_field(tag::MSG_TYPE, FIXString::from("7".to_string()));
30
31        msg.body.set_field(tag::ADV_ID, adv_id.0);
32
33        msg.body.set_field(tag::ADV_TRANS_TYPE, adv_trans_type.0);
34
35        msg.body.set_field(tag::SYMBOL, symbol.0);
36
37        msg.body.set_field(tag::ADV_SIDE, adv_side.0);
38
39        msg.body.set_field(tag::SHARES, shares.0);
40
41        Self { message: msg }
42    }
43
44    /// Creates a `Advertisement` from an existing `Message`.
45    pub fn from_message(msg: Message) -> Self {
46        Self { message: msg }
47    }
48
49    /// Returns the underlying `Message`.
50    pub fn to_message(self) -> Message {
51        self.message
52    }
53
54
55
56
57    /// Sets `AdvId`, Tag 2.
58    pub fn set_adv_id(&mut self, v: String) {
59        self.message.body.set_field(tag::ADV_ID, FIXString::from(v));
60    }
61
62    /// Gets `AdvId`, Tag 2.
63    pub fn get_adv_id(&self) -> Result<String, MessageRejectErrorEnum> {
64        let mut fld = field::AdvIdField::new(String::new());
65        self.message.body.get_field(tag::ADV_ID, &mut fld.0)?;
66        Ok(fld.value().to_string())
67    }
68
69
70    /// Returns true if `AdvId` is present, Tag 2.
71    pub fn has_adv_id(&self) -> bool {
72        self.message.body.has(tag::ADV_ID)
73    }
74
75
76
77
78    /// Sets `AdvRefID`, Tag 3.
79    pub fn set_adv_ref_id(&mut self, v: String) {
80        self.message.body.set_field(tag::ADV_REF_ID, FIXString::from(v));
81    }
82
83    /// Gets `AdvRefID`, Tag 3.
84    pub fn get_adv_ref_id(&self) -> Result<String, MessageRejectErrorEnum> {
85        let mut fld = field::AdvRefIDField::new(String::new());
86        self.message.body.get_field(tag::ADV_REF_ID, &mut fld.0)?;
87        Ok(fld.value().to_string())
88    }
89
90
91    /// Returns true if `AdvRefID` is present, Tag 3.
92    pub fn has_adv_ref_id(&self) -> bool {
93        self.message.body.has(tag::ADV_REF_ID)
94    }
95
96
97
98
99    /// Sets `AdvSide`, Tag 4.
100    pub fn set_adv_side(&mut self, v: String) {
101        self.message.body.set_field(tag::ADV_SIDE, FIXString::from(v));
102    }
103
104    /// Gets `AdvSide`, Tag 4.
105    pub fn get_adv_side(&self) -> Result<String, MessageRejectErrorEnum> {
106        let mut fld = field::AdvSideField::new(String::new());
107        self.message.body.get_field(tag::ADV_SIDE, &mut fld.0)?;
108        Ok(fld.value().to_string())
109    }
110
111
112    /// Returns true if `AdvSide` is present, Tag 4.
113    pub fn has_adv_side(&self) -> bool {
114        self.message.body.has(tag::ADV_SIDE)
115    }
116
117
118
119
120    /// Sets `AdvTransType`, Tag 5.
121    pub fn set_adv_trans_type(&mut self, v: String) {
122        self.message.body.set_field(tag::ADV_TRANS_TYPE, FIXString::from(v));
123    }
124
125    /// Gets `AdvTransType`, Tag 5.
126    pub fn get_adv_trans_type(&self) -> Result<String, MessageRejectErrorEnum> {
127        let mut fld = field::AdvTransTypeField::new(String::new());
128        self.message.body.get_field(tag::ADV_TRANS_TYPE, &mut fld.0)?;
129        Ok(fld.value().to_string())
130    }
131
132
133    /// Returns true if `AdvTransType` is present, Tag 5.
134    pub fn has_adv_trans_type(&self) -> bool {
135        self.message.body.has(tag::ADV_TRANS_TYPE)
136    }
137
138
139
140
141    /// Sets `Currency`, Tag 15.
142    pub fn set_currency(&mut self, v: String) {
143        self.message.body.set_field(tag::CURRENCY, FIXString::from(v));
144    }
145
146    /// Gets `Currency`, Tag 15.
147    pub fn get_currency(&self) -> Result<String, MessageRejectErrorEnum> {
148        let mut fld = field::CurrencyField::new(String::new());
149        self.message.body.get_field(tag::CURRENCY, &mut fld.0)?;
150        Ok(fld.value().to_string())
151    }
152
153
154    /// Returns true if `Currency` is present, Tag 15.
155    pub fn has_currency(&self) -> bool {
156        self.message.body.has(tag::CURRENCY)
157    }
158
159
160
161
162    /// Sets `IDSource`, Tag 22.
163    pub fn set_id_source(&mut self, v: String) {
164        self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
165    }
166
167    /// Gets `IDSource`, Tag 22.
168    pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
169        let mut fld = field::IDSourceField::new(String::new());
170        self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
171        Ok(fld.value().to_string())
172    }
173
174
175    /// Returns true if `IDSource` is present, Tag 22.
176    pub fn has_id_source(&self) -> bool {
177        self.message.body.has(tag::ID_SOURCE)
178    }
179
180
181
182
183    /// Sets `Issuer`, Tag 106.
184    pub fn set_issuer(&mut self, v: String) {
185        self.message.body.set_field(tag::ISSUER, FIXString::from(v));
186    }
187
188    /// Gets `Issuer`, Tag 106.
189    pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
190        let mut fld = field::IssuerField::new(String::new());
191        self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
192        Ok(fld.value().to_string())
193    }
194
195
196    /// Returns true if `Issuer` is present, Tag 106.
197    pub fn has_issuer(&self) -> bool {
198        self.message.body.has(tag::ISSUER)
199    }
200
201
202
203
204    /// Sets `LastMkt`, Tag 30.
205    pub fn set_last_mkt(&mut self, v: String) {
206        self.message.body.set_field(tag::LAST_MKT, FIXString::from(v));
207    }
208
209    /// Gets `LastMkt`, Tag 30.
210    pub fn get_last_mkt(&self) -> Result<String, MessageRejectErrorEnum> {
211        let mut fld = field::LastMktField::new(String::new());
212        self.message.body.get_field(tag::LAST_MKT, &mut fld.0)?;
213        Ok(fld.value().to_string())
214    }
215
216
217    /// Returns true if `LastMkt` is present, Tag 30.
218    pub fn has_last_mkt(&self) -> bool {
219        self.message.body.has(tag::LAST_MKT)
220    }
221
222
223
224
225    /// Sets `MaturityDay`, Tag 205.
226    pub fn set_maturity_day(&mut self, v: isize) {
227        self.message.body.set_field(tag::MATURITY_DAY, fixer::fix_int::FIXInt::from(v));
228    }
229
230    /// Gets `MaturityDay`, Tag 205.
231    pub fn get_maturity_day(&self) -> Result<isize, MessageRejectErrorEnum> {
232        let mut fld = field::MaturityDayField::new(0);
233        self.message.body.get_field(tag::MATURITY_DAY, &mut fld.0)?;
234        Ok(fld.value())
235    }
236
237
238    /// Returns true if `MaturityDay` is present, Tag 205.
239    pub fn has_maturity_day(&self) -> bool {
240        self.message.body.has(tag::MATURITY_DAY)
241    }
242
243
244
245
246    /// Sets `MaturityMonthYear`, Tag 200.
247    pub fn set_maturity_month_year(&mut self, v: String) {
248        self.message.body.set_field(tag::MATURITY_MONTH_YEAR, FIXString::from(v));
249    }
250
251    /// Gets `MaturityMonthYear`, Tag 200.
252    pub fn get_maturity_month_year(&self) -> Result<String, MessageRejectErrorEnum> {
253        let mut fld = field::MaturityMonthYearField::new(String::new());
254        self.message.body.get_field(tag::MATURITY_MONTH_YEAR, &mut fld.0)?;
255        Ok(fld.value().to_string())
256    }
257
258
259    /// Returns true if `MaturityMonthYear` is present, Tag 200.
260    pub fn has_maturity_month_year(&self) -> bool {
261        self.message.body.has(tag::MATURITY_MONTH_YEAR)
262    }
263
264
265
266
267    /// Sets `OptAttribute`, Tag 206.
268    pub fn set_opt_attribute(&mut self, v: String) {
269        self.message.body.set_field(tag::OPT_ATTRIBUTE, FIXString::from(v));
270    }
271
272    /// Gets `OptAttribute`, Tag 206.
273    pub fn get_opt_attribute(&self) -> Result<String, MessageRejectErrorEnum> {
274        let mut fld = field::OptAttributeField::new(String::new());
275        self.message.body.get_field(tag::OPT_ATTRIBUTE, &mut fld.0)?;
276        Ok(fld.value().to_string())
277    }
278
279
280    /// Returns true if `OptAttribute` is present, Tag 206.
281    pub fn has_opt_attribute(&self) -> bool {
282        self.message.body.has(tag::OPT_ATTRIBUTE)
283    }
284
285
286
287
288    /// Sets `Price`, Tag 44.
289    pub fn set_price(&mut self, val: Decimal, scale: i32) {
290        self.message.body.set_field(tag::PRICE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
291    }
292
293    /// Gets `Price`, Tag 44.
294    pub fn get_price(&self) -> Result<Decimal, MessageRejectErrorEnum> {
295        let mut fld = field::PriceField::new(Decimal::ZERO, 0);
296        self.message.body.get_field(tag::PRICE, &mut fld.0)?;
297        Ok(fld.value())
298    }
299
300
301    /// Returns true if `Price` is present, Tag 44.
302    pub fn has_price(&self) -> bool {
303        self.message.body.has(tag::PRICE)
304    }
305
306
307
308
309    /// Sets `PutOrCall`, Tag 201.
310    pub fn set_put_or_call(&mut self, v: isize) {
311        self.message.body.set_field(tag::PUT_OR_CALL, fixer::fix_int::FIXInt::from(v));
312    }
313
314    /// Gets `PutOrCall`, Tag 201.
315    pub fn get_put_or_call(&self) -> Result<isize, MessageRejectErrorEnum> {
316        let mut fld = field::PutOrCallField::new(0);
317        self.message.body.get_field(tag::PUT_OR_CALL, &mut fld.0)?;
318        Ok(fld.value())
319    }
320
321
322    /// Returns true if `PutOrCall` is present, Tag 201.
323    pub fn has_put_or_call(&self) -> bool {
324        self.message.body.has(tag::PUT_OR_CALL)
325    }
326
327
328
329
330    /// Sets `SecurityDesc`, Tag 107.
331    pub fn set_security_desc(&mut self, v: String) {
332        self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
333    }
334
335    /// Gets `SecurityDesc`, Tag 107.
336    pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
337        let mut fld = field::SecurityDescField::new(String::new());
338        self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
339        Ok(fld.value().to_string())
340    }
341
342
343    /// Returns true if `SecurityDesc` is present, Tag 107.
344    pub fn has_security_desc(&self) -> bool {
345        self.message.body.has(tag::SECURITY_DESC)
346    }
347
348
349
350
351    /// Sets `SecurityExchange`, Tag 207.
352    pub fn set_security_exchange(&mut self, v: String) {
353        self.message.body.set_field(tag::SECURITY_EXCHANGE, FIXString::from(v));
354    }
355
356    /// Gets `SecurityExchange`, Tag 207.
357    pub fn get_security_exchange(&self) -> Result<String, MessageRejectErrorEnum> {
358        let mut fld = field::SecurityExchangeField::new(String::new());
359        self.message.body.get_field(tag::SECURITY_EXCHANGE, &mut fld.0)?;
360        Ok(fld.value().to_string())
361    }
362
363
364    /// Returns true if `SecurityExchange` is present, Tag 207.
365    pub fn has_security_exchange(&self) -> bool {
366        self.message.body.has(tag::SECURITY_EXCHANGE)
367    }
368
369
370
371
372    /// Sets `SecurityID`, Tag 48.
373    pub fn set_security_id(&mut self, v: String) {
374        self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
375    }
376
377    /// Gets `SecurityID`, Tag 48.
378    pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
379        let mut fld = field::SecurityIDField::new(String::new());
380        self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
381        Ok(fld.value().to_string())
382    }
383
384
385    /// Returns true if `SecurityID` is present, Tag 48.
386    pub fn has_security_id(&self) -> bool {
387        self.message.body.has(tag::SECURITY_ID)
388    }
389
390
391
392
393    /// Sets `SecurityType`, Tag 167.
394    pub fn set_security_type(&mut self, v: String) {
395        self.message.body.set_field(tag::SECURITY_TYPE, FIXString::from(v));
396    }
397
398    /// Gets `SecurityType`, Tag 167.
399    pub fn get_security_type(&self) -> Result<String, MessageRejectErrorEnum> {
400        let mut fld = field::SecurityTypeField::new(String::new());
401        self.message.body.get_field(tag::SECURITY_TYPE, &mut fld.0)?;
402        Ok(fld.value().to_string())
403    }
404
405
406    /// Returns true if `SecurityType` is present, Tag 167.
407    pub fn has_security_type(&self) -> bool {
408        self.message.body.has(tag::SECURITY_TYPE)
409    }
410
411
412
413
414    /// Sets `Shares`, Tag 53.
415    pub fn set_shares(&mut self, val: Decimal, scale: i32) {
416        self.message.body.set_field(tag::SHARES, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
417    }
418
419    /// Gets `Shares`, Tag 53.
420    pub fn get_shares(&self) -> Result<Decimal, MessageRejectErrorEnum> {
421        let mut fld = field::SharesField::new(Decimal::ZERO, 0);
422        self.message.body.get_field(tag::SHARES, &mut fld.0)?;
423        Ok(fld.value())
424    }
425
426
427    /// Returns true if `Shares` is present, Tag 53.
428    pub fn has_shares(&self) -> bool {
429        self.message.body.has(tag::SHARES)
430    }
431
432
433
434
435    /// Sets `StrikePrice`, Tag 202.
436    pub fn set_strike_price(&mut self, val: Decimal, scale: i32) {
437        self.message.body.set_field(tag::STRIKE_PRICE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
438    }
439
440    /// Gets `StrikePrice`, Tag 202.
441    pub fn get_strike_price(&self) -> Result<Decimal, MessageRejectErrorEnum> {
442        let mut fld = field::StrikePriceField::new(Decimal::ZERO, 0);
443        self.message.body.get_field(tag::STRIKE_PRICE, &mut fld.0)?;
444        Ok(fld.value())
445    }
446
447
448    /// Returns true if `StrikePrice` is present, Tag 202.
449    pub fn has_strike_price(&self) -> bool {
450        self.message.body.has(tag::STRIKE_PRICE)
451    }
452
453
454
455
456    /// Sets `Symbol`, Tag 55.
457    pub fn set_symbol(&mut self, v: String) {
458        self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
459    }
460
461    /// Gets `Symbol`, Tag 55.
462    pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
463        let mut fld = field::SymbolField::new(String::new());
464        self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
465        Ok(fld.value().to_string())
466    }
467
468
469    /// Returns true if `Symbol` is present, Tag 55.
470    pub fn has_symbol(&self) -> bool {
471        self.message.body.has(tag::SYMBOL)
472    }
473
474
475
476
477    /// Sets `SymbolSfx`, Tag 65.
478    pub fn set_symbol_sfx(&mut self, v: String) {
479        self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
480    }
481
482    /// Gets `SymbolSfx`, Tag 65.
483    pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
484        let mut fld = field::SymbolSfxField::new(String::new());
485        self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
486        Ok(fld.value().to_string())
487    }
488
489
490    /// Returns true if `SymbolSfx` is present, Tag 65.
491    pub fn has_symbol_sfx(&self) -> bool {
492        self.message.body.has(tag::SYMBOL_SFX)
493    }
494
495
496
497
498    /// Sets `Text`, Tag 58.
499    pub fn set_text(&mut self, v: String) {
500        self.message.body.set_field(tag::TEXT, FIXString::from(v));
501    }
502
503    /// Gets `Text`, Tag 58.
504    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
505        let mut fld = field::TextField::new(String::new());
506        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
507        Ok(fld.value().to_string())
508    }
509
510
511    /// Returns true if `Text` is present, Tag 58.
512    pub fn has_text(&self) -> bool {
513        self.message.body.has(tag::TEXT)
514    }
515
516
517
518
519    /// Sets `TradeDate`, Tag 75.
520    pub fn set_trade_date(&mut self, v: String) {
521        self.message.body.set_field(tag::TRADE_DATE, FIXString::from(v));
522    }
523
524    /// Gets `TradeDate`, Tag 75.
525    pub fn get_trade_date(&self) -> Result<String, MessageRejectErrorEnum> {
526        let mut fld = field::TradeDateField::new(String::new());
527        self.message.body.get_field(tag::TRADE_DATE, &mut fld.0)?;
528        Ok(fld.value().to_string())
529    }
530
531
532    /// Returns true if `TradeDate` is present, Tag 75.
533    pub fn has_trade_date(&self) -> bool {
534        self.message.body.has(tag::TRADE_DATE)
535    }
536
537
538
539
540    /// Sets `TransactTime`, Tag 60.
541    pub fn set_transact_time(&mut self, v: Timestamp) {
542        self.message.body.set_field(tag::TRANSACT_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
543            time: v,
544            precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
545        });
546    }
547
548    /// Gets `TransactTime`, Tag 60.
549    pub fn get_transact_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
550        let mut fld = field::TransactTimeField::new(Timestamp::UNIX_EPOCH);
551        self.message.body.get_field(tag::TRANSACT_TIME, &mut fld.0)?;
552        Ok(fld.value())
553    }
554
555
556    /// Returns true if `TransactTime` is present, Tag 60.
557    pub fn has_transact_time(&self) -> bool {
558        self.message.body.has(tag::TRANSACT_TIME)
559    }
560
561
562
563
564    /// Sets `URLLink`, Tag 149.
565    pub fn set_url_link(&mut self, v: String) {
566        self.message.body.set_field(tag::URL_LINK, FIXString::from(v));
567    }
568
569    /// Gets `URLLink`, Tag 149.
570    pub fn get_url_link(&self) -> Result<String, MessageRejectErrorEnum> {
571        let mut fld = field::URLLinkField::new(String::new());
572        self.message.body.get_field(tag::URL_LINK, &mut fld.0)?;
573        Ok(fld.value().to_string())
574    }
575
576
577    /// Returns true if `URLLink` is present, Tag 149.
578    pub fn has_url_link(&self) -> bool {
579        self.message.body.has(tag::URL_LINK)
580    }
581
582
583}
584
585/// `RouteOut` is the callback type for routing `Advertisement` messages.
586pub type RouteOut = fn(msg: Advertisement, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
587
588/// Route type returned by the `route` function.
589pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
590
591/// Returns the begin string, message type, and route function for `Advertisement`.
592pub fn route(router: RouteOut) -> Route {
593    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
594        router(Advertisement::from_message(msg.clone()), session_id)
595    };
596    ("FIX.4.1", "7", Box::new(r))
597}