Skip to main content

fixer_fix/fix44/
confirmation_ack.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/// `ConfirmationAck` is the `fix44` `ConfirmationAck` type, `MsgType` = AU.
19pub struct ConfirmationAck {
20    pub message: Message,
21}
22
23impl ConfirmationAck {
24    /// Creates a new `ConfirmationAck` with required fields.
25    pub fn new(confirm_id: field::ConfirmIDField, trade_date: field::TradeDateField, transact_time: field::TransactTimeField, affirm_status: field::AffirmStatusField) -> Self {
26        let mut msg = Message::new();
27        msg.header.set_field(tag::MSG_TYPE, FIXString::from("AU".to_string()));
28
29        msg.body.set_field(tag::CONFIRM_ID, confirm_id.0);
30
31        msg.body.set_field(tag::TRADE_DATE, trade_date.0);
32
33        msg.body.set_field(tag::TRANSACT_TIME, transact_time.0);
34
35        msg.body.set_field(tag::AFFIRM_STATUS, affirm_status.0);
36
37        Self { message: msg }
38    }
39
40    /// Creates a `ConfirmationAck` 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 `AffirmStatus`, Tag 940.
54    pub fn set_affirm_status(&mut self, v: isize) {
55        self.message.body.set_field(tag::AFFIRM_STATUS, fixer::fix_int::FIXInt::from(v));
56    }
57
58    /// Gets `AffirmStatus`, Tag 940.
59    pub fn get_affirm_status(&self) -> Result<isize, MessageRejectErrorEnum> {
60        let mut fld = field::AffirmStatusField::new(0);
61        self.message.body.get_field(tag::AFFIRM_STATUS, &mut fld.0)?;
62        Ok(fld.value())
63    }
64
65
66    /// Returns true if `AffirmStatus` is present, Tag 940.
67    pub fn has_affirm_status(&self) -> bool {
68        self.message.body.has(tag::AFFIRM_STATUS)
69    }
70
71
72
73
74    /// Sets `ConfirmID`, Tag 664.
75    pub fn set_confirm_id(&mut self, v: String) {
76        self.message.body.set_field(tag::CONFIRM_ID, FIXString::from(v));
77    }
78
79    /// Gets `ConfirmID`, Tag 664.
80    pub fn get_confirm_id(&self) -> Result<String, MessageRejectErrorEnum> {
81        let mut fld = field::ConfirmIDField::new(String::new());
82        self.message.body.get_field(tag::CONFIRM_ID, &mut fld.0)?;
83        Ok(fld.value().to_string())
84    }
85
86
87    /// Returns true if `ConfirmID` is present, Tag 664.
88    pub fn has_confirm_id(&self) -> bool {
89        self.message.body.has(tag::CONFIRM_ID)
90    }
91
92
93
94
95    /// Sets `ConfirmRejReason`, Tag 774.
96    pub fn set_confirm_rej_reason(&mut self, v: isize) {
97        self.message.body.set_field(tag::CONFIRM_REJ_REASON, fixer::fix_int::FIXInt::from(v));
98    }
99
100    /// Gets `ConfirmRejReason`, Tag 774.
101    pub fn get_confirm_rej_reason(&self) -> Result<isize, MessageRejectErrorEnum> {
102        let mut fld = field::ConfirmRejReasonField::new(0);
103        self.message.body.get_field(tag::CONFIRM_REJ_REASON, &mut fld.0)?;
104        Ok(fld.value())
105    }
106
107
108    /// Returns true if `ConfirmRejReason` is present, Tag 774.
109    pub fn has_confirm_rej_reason(&self) -> bool {
110        self.message.body.has(tag::CONFIRM_REJ_REASON)
111    }
112
113
114
115
116    /// Sets `EncodedText`, Tag 355.
117    pub fn set_encoded_text(&mut self, v: String) {
118        self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
119    }
120
121    /// Gets `EncodedText`, Tag 355.
122    pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
123        let mut fld = field::EncodedTextField::new(String::new());
124        self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
125        Ok(fld.value().to_string())
126    }
127
128
129    /// Returns true if `EncodedText` is present, Tag 355.
130    pub fn has_encoded_text(&self) -> bool {
131        self.message.body.has(tag::ENCODED_TEXT)
132    }
133
134
135
136
137    /// Sets `EncodedTextLen`, Tag 354.
138    pub fn set_encoded_text_len(&mut self, v: isize) {
139        self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
140    }
141
142    /// Gets `EncodedTextLen`, Tag 354.
143    pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
144        let mut fld = field::EncodedTextLenField::new(0);
145        self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
146        Ok(fld.value())
147    }
148
149
150    /// Returns true if `EncodedTextLen` is present, Tag 354.
151    pub fn has_encoded_text_len(&self) -> bool {
152        self.message.body.has(tag::ENCODED_TEXT_LEN)
153    }
154
155
156
157
158    /// Sets `MatchStatus`, Tag 573.
159    pub fn set_match_status(&mut self, v: String) {
160        self.message.body.set_field(tag::MATCH_STATUS, FIXString::from(v));
161    }
162
163    /// Gets `MatchStatus`, Tag 573.
164    pub fn get_match_status(&self) -> Result<String, MessageRejectErrorEnum> {
165        let mut fld = field::MatchStatusField::new(String::new());
166        self.message.body.get_field(tag::MATCH_STATUS, &mut fld.0)?;
167        Ok(fld.value().to_string())
168    }
169
170
171    /// Returns true if `MatchStatus` is present, Tag 573.
172    pub fn has_match_status(&self) -> bool {
173        self.message.body.has(tag::MATCH_STATUS)
174    }
175
176
177
178
179    /// Sets `Text`, Tag 58.
180    pub fn set_text(&mut self, v: String) {
181        self.message.body.set_field(tag::TEXT, FIXString::from(v));
182    }
183
184    /// Gets `Text`, Tag 58.
185    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
186        let mut fld = field::TextField::new(String::new());
187        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
188        Ok(fld.value().to_string())
189    }
190
191
192    /// Returns true if `Text` is present, Tag 58.
193    pub fn has_text(&self) -> bool {
194        self.message.body.has(tag::TEXT)
195    }
196
197
198
199
200    /// Sets `TradeDate`, Tag 75.
201    pub fn set_trade_date(&mut self, v: String) {
202        self.message.body.set_field(tag::TRADE_DATE, FIXString::from(v));
203    }
204
205    /// Gets `TradeDate`, Tag 75.
206    pub fn get_trade_date(&self) -> Result<String, MessageRejectErrorEnum> {
207        let mut fld = field::TradeDateField::new(String::new());
208        self.message.body.get_field(tag::TRADE_DATE, &mut fld.0)?;
209        Ok(fld.value().to_string())
210    }
211
212
213    /// Returns true if `TradeDate` is present, Tag 75.
214    pub fn has_trade_date(&self) -> bool {
215        self.message.body.has(tag::TRADE_DATE)
216    }
217
218
219
220
221    /// Sets `TransactTime`, Tag 60.
222    pub fn set_transact_time(&mut self, v: Timestamp) {
223        self.message.body.set_field(tag::TRANSACT_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
224            time: v,
225            precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
226        });
227    }
228
229    /// Gets `TransactTime`, Tag 60.
230    pub fn get_transact_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
231        let mut fld = field::TransactTimeField::new(Timestamp::UNIX_EPOCH);
232        self.message.body.get_field(tag::TRANSACT_TIME, &mut fld.0)?;
233        Ok(fld.value())
234    }
235
236
237    /// Returns true if `TransactTime` is present, Tag 60.
238    pub fn has_transact_time(&self) -> bool {
239        self.message.body.has(tag::TRANSACT_TIME)
240    }
241
242
243}
244
245/// `RouteOut` is the callback type for routing `ConfirmationAck` messages.
246pub type RouteOut = fn(msg: ConfirmationAck, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
247
248/// Route type returned by the `route` function.
249pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
250
251/// Returns the begin string, message type, and route function for `ConfirmationAck`.
252pub fn route(router: RouteOut) -> Route {
253    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
254        router(ConfirmationAck::from_message(msg.clone()), session_id)
255    };
256    ("FIX.4.4", "AU", Box::new(r))
257}