Skip to main content

fixer_fix/fix43/
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 `fix43` `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, lines_of_text: field::LinesOfTextField) -> 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::LINES_OF_TEXT, 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 `LinesOfText`, Tag 33.
159    pub fn set_lines_of_text(&mut self, v: isize) {
160        self.message.body.set_field(tag::LINES_OF_TEXT, fixer::fix_int::FIXInt::from(v));
161    }
162
163    /// Gets `LinesOfText`, Tag 33.
164    pub fn get_lines_of_text(&self) -> Result<isize, MessageRejectErrorEnum> {
165        let mut fld = field::LinesOfTextField::new(0);
166        self.message.body.get_field(tag::LINES_OF_TEXT, &mut fld.0)?;
167        Ok(fld.value())
168    }
169
170
171    /// Returns true if `LinesOfText` is present, Tag 33.
172    pub fn has_lines_of_text(&self) -> bool {
173        self.message.body.has(tag::LINES_OF_TEXT)
174    }
175
176
177
178
179    /// Sets `NoRelatedSym`, Tag 146.
180    pub fn set_no_related_sym(&mut self, v: isize) {
181        self.message.body.set_field(tag::NO_RELATED_SYM, fixer::fix_int::FIXInt::from(v));
182    }
183
184    /// Gets `NoRelatedSym`, Tag 146.
185    pub fn get_no_related_sym(&self) -> Result<isize, MessageRejectErrorEnum> {
186        let mut fld = field::NoRelatedSymField::new(0);
187        self.message.body.get_field(tag::NO_RELATED_SYM, &mut fld.0)?;
188        Ok(fld.value())
189    }
190
191
192    /// Returns true if `NoRelatedSym` is present, Tag 146.
193    pub fn has_no_related_sym(&self) -> bool {
194        self.message.body.has(tag::NO_RELATED_SYM)
195    }
196
197
198
199
200    /// Sets `NoRoutingIDs`, Tag 215.
201    pub fn set_no_routing_i_ds(&mut self, v: isize) {
202        self.message.body.set_field(tag::NO_ROUTING_I_DS, fixer::fix_int::FIXInt::from(v));
203    }
204
205    /// Gets `NoRoutingIDs`, Tag 215.
206    pub fn get_no_routing_i_ds(&self) -> Result<isize, MessageRejectErrorEnum> {
207        let mut fld = field::NoRoutingIDsField::new(0);
208        self.message.body.get_field(tag::NO_ROUTING_I_DS, &mut fld.0)?;
209        Ok(fld.value())
210    }
211
212
213    /// Returns true if `NoRoutingIDs` is present, Tag 215.
214    pub fn has_no_routing_i_ds(&self) -> bool {
215        self.message.body.has(tag::NO_ROUTING_I_DS)
216    }
217
218
219
220
221    /// Sets `OrderID`, Tag 37.
222    pub fn set_order_id(&mut self, v: String) {
223        self.message.body.set_field(tag::ORDER_ID, FIXString::from(v));
224    }
225
226    /// Gets `OrderID`, Tag 37.
227    pub fn get_order_id(&self) -> Result<String, MessageRejectErrorEnum> {
228        let mut fld = field::OrderIDField::new(String::new());
229        self.message.body.get_field(tag::ORDER_ID, &mut fld.0)?;
230        Ok(fld.value().to_string())
231    }
232
233
234    /// Returns true if `OrderID` is present, Tag 37.
235    pub fn has_order_id(&self) -> bool {
236        self.message.body.has(tag::ORDER_ID)
237    }
238
239
240
241
242    /// Sets `OrigTime`, Tag 42.
243    pub fn set_orig_time(&mut self, v: Timestamp) {
244        self.message.body.set_field(tag::ORIG_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
245            time: v,
246            precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
247        });
248    }
249
250    /// Gets `OrigTime`, Tag 42.
251    pub fn get_orig_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
252        let mut fld = field::OrigTimeField::new(Timestamp::UNIX_EPOCH);
253        self.message.body.get_field(tag::ORIG_TIME, &mut fld.0)?;
254        Ok(fld.value())
255    }
256
257
258    /// Returns true if `OrigTime` is present, Tag 42.
259    pub fn has_orig_time(&self) -> bool {
260        self.message.body.has(tag::ORIG_TIME)
261    }
262
263
264
265
266    /// Sets `RawData`, Tag 96.
267    pub fn set_raw_data(&mut self, v: String) {
268        self.message.body.set_field(tag::RAW_DATA, FIXString::from(v));
269    }
270
271    /// Gets `RawData`, Tag 96.
272    pub fn get_raw_data(&self) -> Result<String, MessageRejectErrorEnum> {
273        let mut fld = field::RawDataField::new(String::new());
274        self.message.body.get_field(tag::RAW_DATA, &mut fld.0)?;
275        Ok(fld.value().to_string())
276    }
277
278
279    /// Returns true if `RawData` is present, Tag 96.
280    pub fn has_raw_data(&self) -> bool {
281        self.message.body.has(tag::RAW_DATA)
282    }
283
284
285
286
287    /// Sets `RawDataLength`, Tag 95.
288    pub fn set_raw_data_length(&mut self, v: isize) {
289        self.message.body.set_field(tag::RAW_DATA_LENGTH, fixer::fix_int::FIXInt::from(v));
290    }
291
292    /// Gets `RawDataLength`, Tag 95.
293    pub fn get_raw_data_length(&self) -> Result<isize, MessageRejectErrorEnum> {
294        let mut fld = field::RawDataLengthField::new(0);
295        self.message.body.get_field(tag::RAW_DATA_LENGTH, &mut fld.0)?;
296        Ok(fld.value())
297    }
298
299
300    /// Returns true if `RawDataLength` is present, Tag 95.
301    pub fn has_raw_data_length(&self) -> bool {
302        self.message.body.has(tag::RAW_DATA_LENGTH)
303    }
304
305
306
307
308    /// Sets `Subject`, Tag 147.
309    pub fn set_subject(&mut self, v: String) {
310        self.message.body.set_field(tag::SUBJECT, FIXString::from(v));
311    }
312
313    /// Gets `Subject`, Tag 147.
314    pub fn get_subject(&self) -> Result<String, MessageRejectErrorEnum> {
315        let mut fld = field::SubjectField::new(String::new());
316        self.message.body.get_field(tag::SUBJECT, &mut fld.0)?;
317        Ok(fld.value().to_string())
318    }
319
320
321    /// Returns true if `Subject` is present, Tag 147.
322    pub fn has_subject(&self) -> bool {
323        self.message.body.has(tag::SUBJECT)
324    }
325
326
327}
328
329/// `RouteOut` is the callback type for routing `Email` messages.
330pub type RouteOut = fn(msg: Email, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
331
332/// Route type returned by the `route` function.
333pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
334
335/// Returns the begin string, message type, and route function for `Email`.
336pub fn route(router: RouteOut) -> Route {
337    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
338        router(Email::from_message(msg.clone()), session_id)
339    };
340    ("FIX.4.3", "C", Box::new(r))
341}