fixer_fix/fix50sp2/
confirmation_request.rs1#![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 ConfirmationRequest {
20 pub message: Message,
21}
22
23impl ConfirmationRequest {
24 pub fn new(confirm_req_id: field::ConfirmReqIDField, confirm_type: field::ConfirmTypeField, transact_time: field::TransactTimeField) -> Self {
26 let mut msg = Message::new();
27 msg.header.set_field(tag::MSG_TYPE, FIXString::from("BH".to_string()));
28
29 msg.body.set_field(tag::CONFIRM_REQ_ID, confirm_req_id.0);
30
31 msg.body.set_field(tag::CONFIRM_TYPE, confirm_type.0);
32
33 msg.body.set_field(tag::TRANSACT_TIME, transact_time.0);
34
35 Self { message: msg }
36 }
37
38 pub fn from_message(msg: Message) -> Self {
40 Self { message: msg }
41 }
42
43 pub fn to_message(self) -> Message {
45 self.message
46 }
47
48
49
50
51 pub fn set_alloc_account(&mut self, v: String) {
53 self.message.body.set_field(tag::ALLOC_ACCOUNT, FIXString::from(v));
54 }
55
56 pub fn get_alloc_account(&self) -> Result<String, MessageRejectErrorEnum> {
58 let mut fld = field::AllocAccountField::new(String::new());
59 self.message.body.get_field(tag::ALLOC_ACCOUNT, &mut fld.0)?;
60 Ok(fld.value().to_string())
61 }
62
63
64 pub fn has_alloc_account(&self) -> bool {
66 self.message.body.has(tag::ALLOC_ACCOUNT)
67 }
68
69
70
71
72 pub fn set_alloc_account_type(&mut self, v: isize) {
74 self.message.body.set_field(tag::ALLOC_ACCOUNT_TYPE, fixer::fix_int::FIXInt::from(v));
75 }
76
77 pub fn get_alloc_account_type(&self) -> Result<isize, MessageRejectErrorEnum> {
79 let mut fld = field::AllocAccountTypeField::new(0);
80 self.message.body.get_field(tag::ALLOC_ACCOUNT_TYPE, &mut fld.0)?;
81 Ok(fld.value())
82 }
83
84
85 pub fn has_alloc_account_type(&self) -> bool {
87 self.message.body.has(tag::ALLOC_ACCOUNT_TYPE)
88 }
89
90
91
92
93 pub fn set_alloc_acct_id_source(&mut self, v: isize) {
95 self.message.body.set_field(tag::ALLOC_ACCT_ID_SOURCE, fixer::fix_int::FIXInt::from(v));
96 }
97
98 pub fn get_alloc_acct_id_source(&self) -> Result<isize, MessageRejectErrorEnum> {
100 let mut fld = field::AllocAcctIDSourceField::new(0);
101 self.message.body.get_field(tag::ALLOC_ACCT_ID_SOURCE, &mut fld.0)?;
102 Ok(fld.value())
103 }
104
105
106 pub fn has_alloc_acct_id_source(&self) -> bool {
108 self.message.body.has(tag::ALLOC_ACCT_ID_SOURCE)
109 }
110
111
112
113
114 pub fn set_alloc_id(&mut self, v: String) {
116 self.message.body.set_field(tag::ALLOC_ID, FIXString::from(v));
117 }
118
119 pub fn get_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
121 let mut fld = field::AllocIDField::new(String::new());
122 self.message.body.get_field(tag::ALLOC_ID, &mut fld.0)?;
123 Ok(fld.value().to_string())
124 }
125
126
127 pub fn has_alloc_id(&self) -> bool {
129 self.message.body.has(tag::ALLOC_ID)
130 }
131
132
133
134
135 pub fn set_confirm_req_id(&mut self, v: String) {
137 self.message.body.set_field(tag::CONFIRM_REQ_ID, FIXString::from(v));
138 }
139
140 pub fn get_confirm_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
142 let mut fld = field::ConfirmReqIDField::new(String::new());
143 self.message.body.get_field(tag::CONFIRM_REQ_ID, &mut fld.0)?;
144 Ok(fld.value().to_string())
145 }
146
147
148 pub fn has_confirm_req_id(&self) -> bool {
150 self.message.body.has(tag::CONFIRM_REQ_ID)
151 }
152
153
154
155
156 pub fn set_confirm_type(&mut self, v: isize) {
158 self.message.body.set_field(tag::CONFIRM_TYPE, fixer::fix_int::FIXInt::from(v));
159 }
160
161 pub fn get_confirm_type(&self) -> Result<isize, MessageRejectErrorEnum> {
163 let mut fld = field::ConfirmTypeField::new(0);
164 self.message.body.get_field(tag::CONFIRM_TYPE, &mut fld.0)?;
165 Ok(fld.value())
166 }
167
168
169 pub fn has_confirm_type(&self) -> bool {
171 self.message.body.has(tag::CONFIRM_TYPE)
172 }
173
174
175
176
177 pub fn set_encoded_text(&mut self, v: String) {
179 self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
180 }
181
182 pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
184 let mut fld = field::EncodedTextField::new(String::new());
185 self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
186 Ok(fld.value().to_string())
187 }
188
189
190 pub fn has_encoded_text(&self) -> bool {
192 self.message.body.has(tag::ENCODED_TEXT)
193 }
194
195
196
197
198 pub fn set_encoded_text_len(&mut self, v: isize) {
200 self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
201 }
202
203 pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
205 let mut fld = field::EncodedTextLenField::new(0);
206 self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
207 Ok(fld.value())
208 }
209
210
211 pub fn has_encoded_text_len(&self) -> bool {
213 self.message.body.has(tag::ENCODED_TEXT_LEN)
214 }
215
216
217
218
219 pub fn set_individual_alloc_id(&mut self, v: String) {
221 self.message.body.set_field(tag::INDIVIDUAL_ALLOC_ID, FIXString::from(v));
222 }
223
224 pub fn get_individual_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
226 let mut fld = field::IndividualAllocIDField::new(String::new());
227 self.message.body.get_field(tag::INDIVIDUAL_ALLOC_ID, &mut fld.0)?;
228 Ok(fld.value().to_string())
229 }
230
231
232 pub fn has_individual_alloc_id(&self) -> bool {
234 self.message.body.has(tag::INDIVIDUAL_ALLOC_ID)
235 }
236
237
238
239
240 pub fn set_no_orders(&mut self, v: isize) {
242 self.message.body.set_field(tag::NO_ORDERS, fixer::fix_int::FIXInt::from(v));
243 }
244
245 pub fn get_no_orders(&self) -> Result<isize, MessageRejectErrorEnum> {
247 let mut fld = field::NoOrdersField::new(0);
248 self.message.body.get_field(tag::NO_ORDERS, &mut fld.0)?;
249 Ok(fld.value())
250 }
251
252
253 pub fn has_no_orders(&self) -> bool {
255 self.message.body.has(tag::NO_ORDERS)
256 }
257
258
259
260
261 pub fn set_secondary_alloc_id(&mut self, v: String) {
263 self.message.body.set_field(tag::SECONDARY_ALLOC_ID, FIXString::from(v));
264 }
265
266 pub fn get_secondary_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
268 let mut fld = field::SecondaryAllocIDField::new(String::new());
269 self.message.body.get_field(tag::SECONDARY_ALLOC_ID, &mut fld.0)?;
270 Ok(fld.value().to_string())
271 }
272
273
274 pub fn has_secondary_alloc_id(&self) -> bool {
276 self.message.body.has(tag::SECONDARY_ALLOC_ID)
277 }
278
279
280
281
282 pub fn set_text(&mut self, v: String) {
284 self.message.body.set_field(tag::TEXT, FIXString::from(v));
285 }
286
287 pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
289 let mut fld = field::TextField::new(String::new());
290 self.message.body.get_field(tag::TEXT, &mut fld.0)?;
291 Ok(fld.value().to_string())
292 }
293
294
295 pub fn has_text(&self) -> bool {
297 self.message.body.has(tag::TEXT)
298 }
299
300
301
302
303 pub fn set_transact_time(&mut self, v: Timestamp) {
305 self.message.body.set_field(tag::TRANSACT_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
306 time: v,
307 precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
308 });
309 }
310
311 pub fn get_transact_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
313 let mut fld = field::TransactTimeField::new(Timestamp::UNIX_EPOCH);
314 self.message.body.get_field(tag::TRANSACT_TIME, &mut fld.0)?;
315 Ok(fld.value())
316 }
317
318
319 pub fn has_transact_time(&self) -> bool {
321 self.message.body.has(tag::TRANSACT_TIME)
322 }
323
324
325}
326
327pub type RouteOut = fn(msg: ConfirmationRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
329
330pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
332
333pub fn route(router: RouteOut) -> Route {
335 let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
336 router(ConfirmationRequest::from_message(msg.clone()), session_id)
337 };
338 ("9", "BH", Box::new(r))
339}