Skip to main content

fixer_fix/fix50/
email.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
12
13use jiff::Timestamp;
14
15use crate::field;
16use crate::tag;
17
18/// `Email` is the `fix50` `Email` type, `MsgType` = C.
19pub struct Email {
20    pub message: Message,
21}
22
23impl Email {
24    /// Creates a new `Email` with required fields.
25    pub fn new(email_thread_id: field::EmailThreadIDField, email_type: field::EmailTypeField, subject: field::SubjectField, no_lines_of_text: field::NoLinesOfTextField) -> 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::EMAIL_THREAD_ID, email_thread_id.0);
30
31        msg.body.set_field(tag::EMAIL_TYPE, email_type.0);
32
33        msg.body.set_field(tag::SUBJECT, subject.0);
34
35        msg.body.set_field(tag::NO_LINES_OF_TEXT, no_lines_of_text.0);
36
37        Self { message: msg }
38    }
39
40    /// Creates a `Email` from an existing `Message`.
41    pub fn from_message(msg: Message) -> Self {
42        Self { message: msg }
43    }
44
45    /// Returns the underlying `Message`.
46    pub fn to_message(self) -> Message {
47        self.message
48    }
49
50
51
52
53    /// Sets `ClOrdID`, Tag 11.
54    pub fn set_cl_ord_id(&mut self, v: String) {
55        self.message.body.set_field(tag::CL_ORD_ID, FIXString::from(v));
56    }
57
58    /// Gets `ClOrdID`, Tag 11.
59    pub fn get_cl_ord_id(&self) -> Result<String, MessageRejectErrorEnum> {
60        let mut fld = field::ClOrdIDField::new(String::new());
61        self.message.body.get_field(tag::CL_ORD_ID, &mut fld.0)?;
62        Ok(fld.value().to_string())
63    }
64
65
66    /// Returns true if `ClOrdID` is present, Tag 11.
67    pub fn has_cl_ord_id(&self) -> bool {
68        self.message.body.has(tag::CL_ORD_ID)
69    }
70
71
72
73
74    /// Sets `EmailThreadID`, Tag 164.
75    pub fn set_email_thread_id(&mut self, v: String) {
76        self.message.body.set_field(tag::EMAIL_THREAD_ID, FIXString::from(v));
77    }
78
79    /// Gets `EmailThreadID`, Tag 164.
80    pub fn get_email_thread_id(&self) -> Result<String, MessageRejectErrorEnum> {
81        let mut fld = field::EmailThreadIDField::new(String::new());
82        self.message.body.get_field(tag::EMAIL_THREAD_ID, &mut fld.0)?;
83        Ok(fld.value().to_string())
84    }
85
86
87    /// Returns true if `EmailThreadID` is present, Tag 164.
88    pub fn has_email_thread_id(&self) -> bool {
89        self.message.body.has(tag::EMAIL_THREAD_ID)
90    }
91
92
93
94
95    /// Sets `EmailType`, Tag 94.
96    pub fn set_email_type(&mut self, v: String) {
97        self.message.body.set_field(tag::EMAIL_TYPE, FIXString::from(v));
98    }
99
100    /// Gets `EmailType`, Tag 94.
101    pub fn get_email_type(&self) -> Result<String, MessageRejectErrorEnum> {
102        let mut fld = field::EmailTypeField::new(String::new());
103        self.message.body.get_field(tag::EMAIL_TYPE, &mut fld.0)?;
104        Ok(fld.value().to_string())
105    }
106
107
108    /// Returns true if `EmailType` is present, Tag 94.
109    pub fn has_email_type(&self) -> bool {
110        self.message.body.has(tag::EMAIL_TYPE)
111    }
112
113
114
115
116    /// Sets `EncodedSubject`, Tag 357.
117    pub fn set_encoded_subject(&mut self, v: String) {
118        self.message.body.set_field(tag::ENCODED_SUBJECT, FIXString::from(v));
119    }
120
121    /// Gets `EncodedSubject`, Tag 357.
122    pub fn get_encoded_subject(&self) -> Result<String, MessageRejectErrorEnum> {
123        let mut fld = field::EncodedSubjectField::new(String::new());
124        self.message.body.get_field(tag::ENCODED_SUBJECT, &mut fld.0)?;
125        Ok(fld.value().to_string())
126    }
127
128
129    /// Returns true if `EncodedSubject` is present, Tag 357.
130    pub fn has_encoded_subject(&self) -> bool {
131        self.message.body.has(tag::ENCODED_SUBJECT)
132    }
133
134
135
136
137    /// Sets `EncodedSubjectLen`, Tag 356.
138    pub fn set_encoded_subject_len(&mut self, v: isize) {
139        self.message.body.set_field(tag::ENCODED_SUBJECT_LEN, fixer::fix_int::FIXInt::from(v));
140    }
141
142    /// Gets `EncodedSubjectLen`, Tag 356.
143    pub fn get_encoded_subject_len(&self) -> Result<isize, MessageRejectErrorEnum> {
144        let mut fld = field::EncodedSubjectLenField::new(0);
145        self.message.body.get_field(tag::ENCODED_SUBJECT_LEN, &mut fld.0)?;
146        Ok(fld.value())
147    }
148
149
150    /// Returns true if `EncodedSubjectLen` is present, Tag 356.
151    pub fn has_encoded_subject_len(&self) -> bool {
152        self.message.body.has(tag::ENCODED_SUBJECT_LEN)
153    }
154
155
156
157
158    /// Sets `NoLegs`, Tag 555.
159    pub fn set_no_legs(&mut self, v: isize) {
160        self.message.body.set_field(tag::NO_LEGS, fixer::fix_int::FIXInt::from(v));
161    }
162
163    /// Gets `NoLegs`, Tag 555.
164    pub fn get_no_legs(&self) -> Result<isize, MessageRejectErrorEnum> {
165        let mut fld = field::NoLegsField::new(0);
166        self.message.body.get_field(tag::NO_LEGS, &mut fld.0)?;
167        Ok(fld.value())
168    }
169
170
171    /// Returns true if `NoLegs` is present, Tag 555.
172    pub fn has_no_legs(&self) -> bool {
173        self.message.body.has(tag::NO_LEGS)
174    }
175
176
177
178
179    /// Sets `NoLinesOfText`, Tag 33.
180    pub fn set_no_lines_of_text(&mut self, v: isize) {
181        self.message.body.set_field(tag::NO_LINES_OF_TEXT, fixer::fix_int::FIXInt::from(v));
182    }
183
184    /// Gets `NoLinesOfText`, Tag 33.
185    pub fn get_no_lines_of_text(&self) -> Result<isize, MessageRejectErrorEnum> {
186        let mut fld = field::NoLinesOfTextField::new(0);
187        self.message.body.get_field(tag::NO_LINES_OF_TEXT, &mut fld.0)?;
188        Ok(fld.value())
189    }
190
191
192    /// Returns true if `NoLinesOfText` is present, Tag 33.
193    pub fn has_no_lines_of_text(&self) -> bool {
194        self.message.body.has(tag::NO_LINES_OF_TEXT)
195    }
196
197
198
199
200    /// Sets `NoRelatedSym`, Tag 146.
201    pub fn set_no_related_sym(&mut self, v: isize) {
202        self.message.body.set_field(tag::NO_RELATED_SYM, fixer::fix_int::FIXInt::from(v));
203    }
204
205    /// Gets `NoRelatedSym`, Tag 146.
206    pub fn get_no_related_sym(&self) -> Result<isize, MessageRejectErrorEnum> {
207        let mut fld = field::NoRelatedSymField::new(0);
208        self.message.body.get_field(tag::NO_RELATED_SYM, &mut fld.0)?;
209        Ok(fld.value())
210    }
211
212
213    /// Returns true if `NoRelatedSym` is present, Tag 146.
214    pub fn has_no_related_sym(&self) -> bool {
215        self.message.body.has(tag::NO_RELATED_SYM)
216    }
217
218
219
220
221    /// Sets `NoRoutingIDs`, Tag 215.
222    pub fn set_no_routing_i_ds(&mut self, v: isize) {
223        self.message.body.set_field(tag::NO_ROUTING_I_DS, fixer::fix_int::FIXInt::from(v));
224    }
225
226    /// Gets `NoRoutingIDs`, Tag 215.
227    pub fn get_no_routing_i_ds(&self) -> Result<isize, MessageRejectErrorEnum> {
228        let mut fld = field::NoRoutingIDsField::new(0);
229        self.message.body.get_field(tag::NO_ROUTING_I_DS, &mut fld.0)?;
230        Ok(fld.value())
231    }
232
233
234    /// Returns true if `NoRoutingIDs` is present, Tag 215.
235    pub fn has_no_routing_i_ds(&self) -> bool {
236        self.message.body.has(tag::NO_ROUTING_I_DS)
237    }
238
239
240
241
242    /// Sets `NoUnderlyings`, Tag 711.
243    pub fn set_no_underlyings(&mut self, v: isize) {
244        self.message.body.set_field(tag::NO_UNDERLYINGS, fixer::fix_int::FIXInt::from(v));
245    }
246
247    /// Gets `NoUnderlyings`, Tag 711.
248    pub fn get_no_underlyings(&self) -> Result<isize, MessageRejectErrorEnum> {
249        let mut fld = field::NoUnderlyingsField::new(0);
250        self.message.body.get_field(tag::NO_UNDERLYINGS, &mut fld.0)?;
251        Ok(fld.value())
252    }
253
254
255    /// Returns true if `NoUnderlyings` is present, Tag 711.
256    pub fn has_no_underlyings(&self) -> bool {
257        self.message.body.has(tag::NO_UNDERLYINGS)
258    }
259
260
261
262
263    /// Sets `OrderID`, Tag 37.
264    pub fn set_order_id(&mut self, v: String) {
265        self.message.body.set_field(tag::ORDER_ID, FIXString::from(v));
266    }
267
268    /// Gets `OrderID`, Tag 37.
269    pub fn get_order_id(&self) -> Result<String, MessageRejectErrorEnum> {
270        let mut fld = field::OrderIDField::new(String::new());
271        self.message.body.get_field(tag::ORDER_ID, &mut fld.0)?;
272        Ok(fld.value().to_string())
273    }
274
275
276    /// Returns true if `OrderID` is present, Tag 37.
277    pub fn has_order_id(&self) -> bool {
278        self.message.body.has(tag::ORDER_ID)
279    }
280
281
282
283
284    /// Sets `OrigTime`, Tag 42.
285    pub fn set_orig_time(&mut self, v: Timestamp) {
286        self.message.body.set_field(tag::ORIG_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
287            time: v,
288            precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
289        });
290    }
291
292    /// Gets `OrigTime`, Tag 42.
293    pub fn get_orig_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
294        let mut fld = field::OrigTimeField::new(Timestamp::UNIX_EPOCH);
295        self.message.body.get_field(tag::ORIG_TIME, &mut fld.0)?;
296        Ok(fld.value())
297    }
298
299
300    /// Returns true if `OrigTime` is present, Tag 42.
301    pub fn has_orig_time(&self) -> bool {
302        self.message.body.has(tag::ORIG_TIME)
303    }
304
305
306
307
308    /// Sets `RawData`, Tag 96.
309    pub fn set_raw_data(&mut self, v: String) {
310        self.message.body.set_field(tag::RAW_DATA, FIXString::from(v));
311    }
312
313    /// Gets `RawData`, Tag 96.
314    pub fn get_raw_data(&self) -> Result<String, MessageRejectErrorEnum> {
315        let mut fld = field::RawDataField::new(String::new());
316        self.message.body.get_field(tag::RAW_DATA, &mut fld.0)?;
317        Ok(fld.value().to_string())
318    }
319
320
321    /// Returns true if `RawData` is present, Tag 96.
322    pub fn has_raw_data(&self) -> bool {
323        self.message.body.has(tag::RAW_DATA)
324    }
325
326
327
328
329    /// Sets `RawDataLength`, Tag 95.
330    pub fn set_raw_data_length(&mut self, v: isize) {
331        self.message.body.set_field(tag::RAW_DATA_LENGTH, fixer::fix_int::FIXInt::from(v));
332    }
333
334    /// Gets `RawDataLength`, Tag 95.
335    pub fn get_raw_data_length(&self) -> Result<isize, MessageRejectErrorEnum> {
336        let mut fld = field::RawDataLengthField::new(0);
337        self.message.body.get_field(tag::RAW_DATA_LENGTH, &mut fld.0)?;
338        Ok(fld.value())
339    }
340
341
342    /// Returns true if `RawDataLength` is present, Tag 95.
343    pub fn has_raw_data_length(&self) -> bool {
344        self.message.body.has(tag::RAW_DATA_LENGTH)
345    }
346
347
348
349
350    /// Sets `Subject`, Tag 147.
351    pub fn set_subject(&mut self, v: String) {
352        self.message.body.set_field(tag::SUBJECT, FIXString::from(v));
353    }
354
355    /// Gets `Subject`, Tag 147.
356    pub fn get_subject(&self) -> Result<String, MessageRejectErrorEnum> {
357        let mut fld = field::SubjectField::new(String::new());
358        self.message.body.get_field(tag::SUBJECT, &mut fld.0)?;
359        Ok(fld.value().to_string())
360    }
361
362
363    /// Returns true if `Subject` is present, Tag 147.
364    pub fn has_subject(&self) -> bool {
365        self.message.body.has(tag::SUBJECT)
366    }
367
368
369}
370
371/// `RouteOut` is the callback type for routing `Email` messages.
372pub type RouteOut = fn(msg: Email, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
373
374/// Route type returned by the `route` function.
375pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
376
377/// Returns the begin string, message type, and route function for `Email`.
378pub fn route(router: RouteOut) -> Route {
379    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
380        router(Email::from_message(msg.clone()), session_id)
381    };
382    ("7", "C", Box::new(r))
383}