Skip to main content

fixer_fix/fix50sp1/
confirmation_request.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/// `ConfirmationRequest` is the `fix50sp1` `ConfirmationRequest` type, `MsgType` = BH.
19pub struct ConfirmationRequest {
20    pub message: Message,
21}
22
23impl ConfirmationRequest {
24    /// Creates a new `ConfirmationRequest` with required fields.
25    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    /// Creates a `ConfirmationRequest` from an existing `Message`.
39    pub fn from_message(msg: Message) -> Self {
40        Self { message: msg }
41    }
42
43    /// Returns the underlying `Message`.
44    pub fn to_message(self) -> Message {
45        self.message
46    }
47
48
49
50
51    /// Sets `AllocAccount`, Tag 79.
52    pub fn set_alloc_account(&mut self, v: String) {
53        self.message.body.set_field(tag::ALLOC_ACCOUNT, FIXString::from(v));
54    }
55
56    /// Gets `AllocAccount`, Tag 79.
57    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    /// Returns true if `AllocAccount` is present, Tag 79.
65    pub fn has_alloc_account(&self) -> bool {
66        self.message.body.has(tag::ALLOC_ACCOUNT)
67    }
68
69
70
71
72    /// Sets `AllocAccountType`, Tag 798.
73    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    /// Gets `AllocAccountType`, Tag 798.
78    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    /// Returns true if `AllocAccountType` is present, Tag 798.
86    pub fn has_alloc_account_type(&self) -> bool {
87        self.message.body.has(tag::ALLOC_ACCOUNT_TYPE)
88    }
89
90
91
92
93    /// Sets `AllocAcctIDSource`, Tag 661.
94    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    /// Gets `AllocAcctIDSource`, Tag 661.
99    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    /// Returns true if `AllocAcctIDSource` is present, Tag 661.
107    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    /// Sets `AllocID`, Tag 70.
115    pub fn set_alloc_id(&mut self, v: String) {
116        self.message.body.set_field(tag::ALLOC_ID, FIXString::from(v));
117    }
118
119    /// Gets `AllocID`, Tag 70.
120    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    /// Returns true if `AllocID` is present, Tag 70.
128    pub fn has_alloc_id(&self) -> bool {
129        self.message.body.has(tag::ALLOC_ID)
130    }
131
132
133
134
135    /// Sets `ConfirmReqID`, Tag 859.
136    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    /// Gets `ConfirmReqID`, Tag 859.
141    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    /// Returns true if `ConfirmReqID` is present, Tag 859.
149    pub fn has_confirm_req_id(&self) -> bool {
150        self.message.body.has(tag::CONFIRM_REQ_ID)
151    }
152
153
154
155
156    /// Sets `ConfirmType`, Tag 773.
157    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    /// Gets `ConfirmType`, Tag 773.
162    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    /// Returns true if `ConfirmType` is present, Tag 773.
170    pub fn has_confirm_type(&self) -> bool {
171        self.message.body.has(tag::CONFIRM_TYPE)
172    }
173
174
175
176
177    /// Sets `EncodedText`, Tag 355.
178    pub fn set_encoded_text(&mut self, v: String) {
179        self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
180    }
181
182    /// Gets `EncodedText`, Tag 355.
183    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    /// Returns true if `EncodedText` is present, Tag 355.
191    pub fn has_encoded_text(&self) -> bool {
192        self.message.body.has(tag::ENCODED_TEXT)
193    }
194
195
196
197
198    /// Sets `EncodedTextLen`, Tag 354.
199    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    /// Gets `EncodedTextLen`, Tag 354.
204    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    /// Returns true if `EncodedTextLen` is present, Tag 354.
212    pub fn has_encoded_text_len(&self) -> bool {
213        self.message.body.has(tag::ENCODED_TEXT_LEN)
214    }
215
216
217
218
219    /// Sets `IndividualAllocID`, Tag 467.
220    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    /// Gets `IndividualAllocID`, Tag 467.
225    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    /// Returns true if `IndividualAllocID` is present, Tag 467.
233    pub fn has_individual_alloc_id(&self) -> bool {
234        self.message.body.has(tag::INDIVIDUAL_ALLOC_ID)
235    }
236
237
238
239
240    /// Sets `NoOrders`, Tag 73.
241    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    /// Gets `NoOrders`, Tag 73.
246    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    /// Returns true if `NoOrders` is present, Tag 73.
254    pub fn has_no_orders(&self) -> bool {
255        self.message.body.has(tag::NO_ORDERS)
256    }
257
258
259
260
261    /// Sets `SecondaryAllocID`, Tag 793.
262    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    /// Gets `SecondaryAllocID`, Tag 793.
267    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    /// Returns true if `SecondaryAllocID` is present, Tag 793.
275    pub fn has_secondary_alloc_id(&self) -> bool {
276        self.message.body.has(tag::SECONDARY_ALLOC_ID)
277    }
278
279
280
281
282    /// Sets `Text`, Tag 58.
283    pub fn set_text(&mut self, v: String) {
284        self.message.body.set_field(tag::TEXT, FIXString::from(v));
285    }
286
287    /// Gets `Text`, Tag 58.
288    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    /// Returns true if `Text` is present, Tag 58.
296    pub fn has_text(&self) -> bool {
297        self.message.body.has(tag::TEXT)
298    }
299
300
301
302
303    /// Sets `TransactTime`, Tag 60.
304    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    /// Gets `TransactTime`, Tag 60.
312    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    /// Returns true if `TransactTime` is present, Tag 60.
320    pub fn has_transact_time(&self) -> bool {
321        self.message.body.has(tag::TRANSACT_TIME)
322    }
323
324
325}
326
327/// `RouteOut` is the callback type for routing `ConfirmationRequest` messages.
328pub type RouteOut = fn(msg: ConfirmationRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
329
330/// Route type returned by the `route` function.
331pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
332
333/// Returns the begin string, message type, and route function for `ConfirmationRequest`.
334pub 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    ("8", "BH", Box::new(r))
339}