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
12
13use jiff::Timestamp;
14
15use crate::field;
16use crate::tag;
17
18pub struct AllocationReportAck {
20 pub message: Message,
21}
22
23impl AllocationReportAck {
24 pub fn new(alloc_report_id: field::AllocReportIDField, alloc_id: field::AllocIDField, transact_time: field::TransactTimeField, alloc_status: field::AllocStatusField) -> Self {
26 let mut msg = Message::new();
27 msg.header.set_field(tag::MSG_TYPE, FIXString::from("AT".to_string()));
28
29 msg.body.set_field(tag::ALLOC_REPORT_ID, alloc_report_id.0);
30
31 msg.body.set_field(tag::ALLOC_ID, alloc_id.0);
32
33 msg.body.set_field(tag::TRANSACT_TIME, transact_time.0);
34
35 msg.body.set_field(tag::ALLOC_STATUS, alloc_status.0);
36
37 Self { message: msg }
38 }
39
40 pub fn from_message(msg: Message) -> Self {
42 Self { message: msg }
43 }
44
45 pub fn to_message(self) -> Message {
47 self.message
48 }
49
50
51
52
53 pub fn set_alloc_id(&mut self, v: String) {
55 self.message.body.set_field(tag::ALLOC_ID, FIXString::from(v));
56 }
57
58 pub fn get_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
60 let mut fld = field::AllocIDField::new(String::new());
61 self.message.body.get_field(tag::ALLOC_ID, &mut fld.0)?;
62 Ok(fld.value().to_string())
63 }
64
65
66 pub fn has_alloc_id(&self) -> bool {
68 self.message.body.has(tag::ALLOC_ID)
69 }
70
71
72
73
74 pub fn set_alloc_intermed_req_type(&mut self, v: isize) {
76 self.message.body.set_field(tag::ALLOC_INTERMED_REQ_TYPE, fixer::fix_int::FIXInt::from(v));
77 }
78
79 pub fn get_alloc_intermed_req_type(&self) -> Result<isize, MessageRejectErrorEnum> {
81 let mut fld = field::AllocIntermedReqTypeField::new(0);
82 self.message.body.get_field(tag::ALLOC_INTERMED_REQ_TYPE, &mut fld.0)?;
83 Ok(fld.value())
84 }
85
86
87 pub fn has_alloc_intermed_req_type(&self) -> bool {
89 self.message.body.has(tag::ALLOC_INTERMED_REQ_TYPE)
90 }
91
92
93
94
95 pub fn set_alloc_rej_code(&mut self, v: isize) {
97 self.message.body.set_field(tag::ALLOC_REJ_CODE, fixer::fix_int::FIXInt::from(v));
98 }
99
100 pub fn get_alloc_rej_code(&self) -> Result<isize, MessageRejectErrorEnum> {
102 let mut fld = field::AllocRejCodeField::new(0);
103 self.message.body.get_field(tag::ALLOC_REJ_CODE, &mut fld.0)?;
104 Ok(fld.value())
105 }
106
107
108 pub fn has_alloc_rej_code(&self) -> bool {
110 self.message.body.has(tag::ALLOC_REJ_CODE)
111 }
112
113
114
115
116 pub fn set_alloc_report_id(&mut self, v: String) {
118 self.message.body.set_field(tag::ALLOC_REPORT_ID, FIXString::from(v));
119 }
120
121 pub fn get_alloc_report_id(&self) -> Result<String, MessageRejectErrorEnum> {
123 let mut fld = field::AllocReportIDField::new(String::new());
124 self.message.body.get_field(tag::ALLOC_REPORT_ID, &mut fld.0)?;
125 Ok(fld.value().to_string())
126 }
127
128
129 pub fn has_alloc_report_id(&self) -> bool {
131 self.message.body.has(tag::ALLOC_REPORT_ID)
132 }
133
134
135
136
137 pub fn set_alloc_report_type(&mut self, v: isize) {
139 self.message.body.set_field(tag::ALLOC_REPORT_TYPE, fixer::fix_int::FIXInt::from(v));
140 }
141
142 pub fn get_alloc_report_type(&self) -> Result<isize, MessageRejectErrorEnum> {
144 let mut fld = field::AllocReportTypeField::new(0);
145 self.message.body.get_field(tag::ALLOC_REPORT_TYPE, &mut fld.0)?;
146 Ok(fld.value())
147 }
148
149
150 pub fn has_alloc_report_type(&self) -> bool {
152 self.message.body.has(tag::ALLOC_REPORT_TYPE)
153 }
154
155
156
157
158 pub fn set_alloc_status(&mut self, v: isize) {
160 self.message.body.set_field(tag::ALLOC_STATUS, fixer::fix_int::FIXInt::from(v));
161 }
162
163 pub fn get_alloc_status(&self) -> Result<isize, MessageRejectErrorEnum> {
165 let mut fld = field::AllocStatusField::new(0);
166 self.message.body.get_field(tag::ALLOC_STATUS, &mut fld.0)?;
167 Ok(fld.value())
168 }
169
170
171 pub fn has_alloc_status(&self) -> bool {
173 self.message.body.has(tag::ALLOC_STATUS)
174 }
175
176
177
178
179 pub fn set_encoded_text(&mut self, v: String) {
181 self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
182 }
183
184 pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
186 let mut fld = field::EncodedTextField::new(String::new());
187 self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
188 Ok(fld.value().to_string())
189 }
190
191
192 pub fn has_encoded_text(&self) -> bool {
194 self.message.body.has(tag::ENCODED_TEXT)
195 }
196
197
198
199
200 pub fn set_encoded_text_len(&mut self, v: isize) {
202 self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
203 }
204
205 pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
207 let mut fld = field::EncodedTextLenField::new(0);
208 self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
209 Ok(fld.value())
210 }
211
212
213 pub fn has_encoded_text_len(&self) -> bool {
215 self.message.body.has(tag::ENCODED_TEXT_LEN)
216 }
217
218
219
220
221 pub fn set_match_status(&mut self, v: String) {
223 self.message.body.set_field(tag::MATCH_STATUS, FIXString::from(v));
224 }
225
226 pub fn get_match_status(&self) -> Result<String, MessageRejectErrorEnum> {
228 let mut fld = field::MatchStatusField::new(String::new());
229 self.message.body.get_field(tag::MATCH_STATUS, &mut fld.0)?;
230 Ok(fld.value().to_string())
231 }
232
233
234 pub fn has_match_status(&self) -> bool {
236 self.message.body.has(tag::MATCH_STATUS)
237 }
238
239
240
241
242 pub fn set_no_allocs(&mut self, v: isize) {
244 self.message.body.set_field(tag::NO_ALLOCS, fixer::fix_int::FIXInt::from(v));
245 }
246
247 pub fn get_no_allocs(&self) -> Result<isize, MessageRejectErrorEnum> {
249 let mut fld = field::NoAllocsField::new(0);
250 self.message.body.get_field(tag::NO_ALLOCS, &mut fld.0)?;
251 Ok(fld.value())
252 }
253
254
255 pub fn has_no_allocs(&self) -> bool {
257 self.message.body.has(tag::NO_ALLOCS)
258 }
259
260
261
262
263 pub fn set_no_party_i_ds(&mut self, v: isize) {
265 self.message.body.set_field(tag::NO_PARTY_I_DS, fixer::fix_int::FIXInt::from(v));
266 }
267
268 pub fn get_no_party_i_ds(&self) -> Result<isize, MessageRejectErrorEnum> {
270 let mut fld = field::NoPartyIDsField::new(0);
271 self.message.body.get_field(tag::NO_PARTY_I_DS, &mut fld.0)?;
272 Ok(fld.value())
273 }
274
275
276 pub fn has_no_party_i_ds(&self) -> bool {
278 self.message.body.has(tag::NO_PARTY_I_DS)
279 }
280
281
282
283
284 pub fn set_product(&mut self, v: isize) {
286 self.message.body.set_field(tag::PRODUCT, fixer::fix_int::FIXInt::from(v));
287 }
288
289 pub fn get_product(&self) -> Result<isize, MessageRejectErrorEnum> {
291 let mut fld = field::ProductField::new(0);
292 self.message.body.get_field(tag::PRODUCT, &mut fld.0)?;
293 Ok(fld.value())
294 }
295
296
297 pub fn has_product(&self) -> bool {
299 self.message.body.has(tag::PRODUCT)
300 }
301
302
303
304
305 pub fn set_secondary_alloc_id(&mut self, v: String) {
307 self.message.body.set_field(tag::SECONDARY_ALLOC_ID, FIXString::from(v));
308 }
309
310 pub fn get_secondary_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
312 let mut fld = field::SecondaryAllocIDField::new(String::new());
313 self.message.body.get_field(tag::SECONDARY_ALLOC_ID, &mut fld.0)?;
314 Ok(fld.value().to_string())
315 }
316
317
318 pub fn has_secondary_alloc_id(&self) -> bool {
320 self.message.body.has(tag::SECONDARY_ALLOC_ID)
321 }
322
323
324
325
326 pub fn set_security_type(&mut self, v: String) {
328 self.message.body.set_field(tag::SECURITY_TYPE, FIXString::from(v));
329 }
330
331 pub fn get_security_type(&self) -> Result<String, MessageRejectErrorEnum> {
333 let mut fld = field::SecurityTypeField::new(String::new());
334 self.message.body.get_field(tag::SECURITY_TYPE, &mut fld.0)?;
335 Ok(fld.value().to_string())
336 }
337
338
339 pub fn has_security_type(&self) -> bool {
341 self.message.body.has(tag::SECURITY_TYPE)
342 }
343
344
345
346
347 pub fn set_text(&mut self, v: String) {
349 self.message.body.set_field(tag::TEXT, FIXString::from(v));
350 }
351
352 pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
354 let mut fld = field::TextField::new(String::new());
355 self.message.body.get_field(tag::TEXT, &mut fld.0)?;
356 Ok(fld.value().to_string())
357 }
358
359
360 pub fn has_text(&self) -> bool {
362 self.message.body.has(tag::TEXT)
363 }
364
365
366
367
368 pub fn set_trade_date(&mut self, v: String) {
370 self.message.body.set_field(tag::TRADE_DATE, FIXString::from(v));
371 }
372
373 pub fn get_trade_date(&self) -> Result<String, MessageRejectErrorEnum> {
375 let mut fld = field::TradeDateField::new(String::new());
376 self.message.body.get_field(tag::TRADE_DATE, &mut fld.0)?;
377 Ok(fld.value().to_string())
378 }
379
380
381 pub fn has_trade_date(&self) -> bool {
383 self.message.body.has(tag::TRADE_DATE)
384 }
385
386
387
388
389 pub fn set_transact_time(&mut self, v: Timestamp) {
391 self.message.body.set_field(tag::TRANSACT_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
392 time: v,
393 precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
394 });
395 }
396
397 pub fn get_transact_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
399 let mut fld = field::TransactTimeField::new(Timestamp::UNIX_EPOCH);
400 self.message.body.get_field(tag::TRANSACT_TIME, &mut fld.0)?;
401 Ok(fld.value())
402 }
403
404
405 pub fn has_transact_time(&self) -> bool {
407 self.message.body.has(tag::TRANSACT_TIME)
408 }
409
410
411}
412
413pub type RouteOut = fn(msg: AllocationReportAck, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
415
416pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
418
419pub fn route(router: RouteOut) -> Route {
421 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
422 router(AllocationReportAck::from_message(msg.clone()), session_id)
423 };
424 ("FIX.4.4", "AT", Box::new(r))
425}