Skip to main content

fixer_fix/fix42/
allocation_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/// `AllocationACK` is the `fix42` `AllocationACK` type, `MsgType` = P.
19pub struct AllocationACK {
20    pub message: Message,
21}
22
23impl AllocationACK {
24    /// Creates a new `AllocationACK` with required fields.
25    pub fn new(alloc_id: field::AllocIDField, trade_date: field::TradeDateField, alloc_status: field::AllocStatusField) -> Self {
26        let mut msg = Message::new();
27        msg.header.set_field(tag::MSG_TYPE, FIXString::from("P".to_string()));
28
29        msg.body.set_field(tag::ALLOC_ID, alloc_id.0);
30
31        msg.body.set_field(tag::TRADE_DATE, trade_date.0);
32
33        msg.body.set_field(tag::ALLOC_STATUS, alloc_status.0);
34
35        Self { message: msg }
36    }
37
38    /// Creates a `AllocationACK` 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 `AllocID`, Tag 70.
52    pub fn set_alloc_id(&mut self, v: String) {
53        self.message.body.set_field(tag::ALLOC_ID, FIXString::from(v));
54    }
55
56    /// Gets `AllocID`, Tag 70.
57    pub fn get_alloc_id(&self) -> Result<String, MessageRejectErrorEnum> {
58        let mut fld = field::AllocIDField::new(String::new());
59        self.message.body.get_field(tag::ALLOC_ID, &mut fld.0)?;
60        Ok(fld.value().to_string())
61    }
62
63
64    /// Returns true if `AllocID` is present, Tag 70.
65    pub fn has_alloc_id(&self) -> bool {
66        self.message.body.has(tag::ALLOC_ID)
67    }
68
69
70
71
72    /// Sets `AllocRejCode`, Tag 88.
73    pub fn set_alloc_rej_code(&mut self, v: isize) {
74        self.message.body.set_field(tag::ALLOC_REJ_CODE, fixer::fix_int::FIXInt::from(v));
75    }
76
77    /// Gets `AllocRejCode`, Tag 88.
78    pub fn get_alloc_rej_code(&self) -> Result<isize, MessageRejectErrorEnum> {
79        let mut fld = field::AllocRejCodeField::new(0);
80        self.message.body.get_field(tag::ALLOC_REJ_CODE, &mut fld.0)?;
81        Ok(fld.value())
82    }
83
84
85    /// Returns true if `AllocRejCode` is present, Tag 88.
86    pub fn has_alloc_rej_code(&self) -> bool {
87        self.message.body.has(tag::ALLOC_REJ_CODE)
88    }
89
90
91
92
93    /// Sets `AllocStatus`, Tag 87.
94    pub fn set_alloc_status(&mut self, v: isize) {
95        self.message.body.set_field(tag::ALLOC_STATUS, fixer::fix_int::FIXInt::from(v));
96    }
97
98    /// Gets `AllocStatus`, Tag 87.
99    pub fn get_alloc_status(&self) -> Result<isize, MessageRejectErrorEnum> {
100        let mut fld = field::AllocStatusField::new(0);
101        self.message.body.get_field(tag::ALLOC_STATUS, &mut fld.0)?;
102        Ok(fld.value())
103    }
104
105
106    /// Returns true if `AllocStatus` is present, Tag 87.
107    pub fn has_alloc_status(&self) -> bool {
108        self.message.body.has(tag::ALLOC_STATUS)
109    }
110
111
112
113
114    /// Sets `ClientID`, Tag 109.
115    pub fn set_client_id(&mut self, v: String) {
116        self.message.body.set_field(tag::CLIENT_ID, FIXString::from(v));
117    }
118
119    /// Gets `ClientID`, Tag 109.
120    pub fn get_client_id(&self) -> Result<String, MessageRejectErrorEnum> {
121        let mut fld = field::ClientIDField::new(String::new());
122        self.message.body.get_field(tag::CLIENT_ID, &mut fld.0)?;
123        Ok(fld.value().to_string())
124    }
125
126
127    /// Returns true if `ClientID` is present, Tag 109.
128    pub fn has_client_id(&self) -> bool {
129        self.message.body.has(tag::CLIENT_ID)
130    }
131
132
133
134
135    /// Sets `EncodedText`, Tag 355.
136    pub fn set_encoded_text(&mut self, v: String) {
137        self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
138    }
139
140    /// Gets `EncodedText`, Tag 355.
141    pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
142        let mut fld = field::EncodedTextField::new(String::new());
143        self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
144        Ok(fld.value().to_string())
145    }
146
147
148    /// Returns true if `EncodedText` is present, Tag 355.
149    pub fn has_encoded_text(&self) -> bool {
150        self.message.body.has(tag::ENCODED_TEXT)
151    }
152
153
154
155
156    /// Sets `EncodedTextLen`, Tag 354.
157    pub fn set_encoded_text_len(&mut self, v: isize) {
158        self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
159    }
160
161    /// Gets `EncodedTextLen`, Tag 354.
162    pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
163        let mut fld = field::EncodedTextLenField::new(0);
164        self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
165        Ok(fld.value())
166    }
167
168
169    /// Returns true if `EncodedTextLen` is present, Tag 354.
170    pub fn has_encoded_text_len(&self) -> bool {
171        self.message.body.has(tag::ENCODED_TEXT_LEN)
172    }
173
174
175
176
177    /// Sets `ExecBroker`, Tag 76.
178    pub fn set_exec_broker(&mut self, v: String) {
179        self.message.body.set_field(tag::EXEC_BROKER, FIXString::from(v));
180    }
181
182    /// Gets `ExecBroker`, Tag 76.
183    pub fn get_exec_broker(&self) -> Result<String, MessageRejectErrorEnum> {
184        let mut fld = field::ExecBrokerField::new(String::new());
185        self.message.body.get_field(tag::EXEC_BROKER, &mut fld.0)?;
186        Ok(fld.value().to_string())
187    }
188
189
190    /// Returns true if `ExecBroker` is present, Tag 76.
191    pub fn has_exec_broker(&self) -> bool {
192        self.message.body.has(tag::EXEC_BROKER)
193    }
194
195
196
197
198    /// Sets `Text`, Tag 58.
199    pub fn set_text(&mut self, v: String) {
200        self.message.body.set_field(tag::TEXT, FIXString::from(v));
201    }
202
203    /// Gets `Text`, Tag 58.
204    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
205        let mut fld = field::TextField::new(String::new());
206        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
207        Ok(fld.value().to_string())
208    }
209
210
211    /// Returns true if `Text` is present, Tag 58.
212    pub fn has_text(&self) -> bool {
213        self.message.body.has(tag::TEXT)
214    }
215
216
217
218
219    /// Sets `TradeDate`, Tag 75.
220    pub fn set_trade_date(&mut self, v: String) {
221        self.message.body.set_field(tag::TRADE_DATE, FIXString::from(v));
222    }
223
224    /// Gets `TradeDate`, Tag 75.
225    pub fn get_trade_date(&self) -> Result<String, MessageRejectErrorEnum> {
226        let mut fld = field::TradeDateField::new(String::new());
227        self.message.body.get_field(tag::TRADE_DATE, &mut fld.0)?;
228        Ok(fld.value().to_string())
229    }
230
231
232    /// Returns true if `TradeDate` is present, Tag 75.
233    pub fn has_trade_date(&self) -> bool {
234        self.message.body.has(tag::TRADE_DATE)
235    }
236
237
238
239
240    /// Sets `TransactTime`, Tag 60.
241    pub fn set_transact_time(&mut self, v: Timestamp) {
242        self.message.body.set_field(tag::TRANSACT_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
243            time: v,
244            precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
245        });
246    }
247
248    /// Gets `TransactTime`, Tag 60.
249    pub fn get_transact_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
250        let mut fld = field::TransactTimeField::new(Timestamp::UNIX_EPOCH);
251        self.message.body.get_field(tag::TRANSACT_TIME, &mut fld.0)?;
252        Ok(fld.value())
253    }
254
255
256    /// Returns true if `TransactTime` is present, Tag 60.
257    pub fn has_transact_time(&self) -> bool {
258        self.message.body.has(tag::TRANSACT_TIME)
259    }
260
261
262}
263
264/// `RouteOut` is the callback type for routing `AllocationACK` messages.
265pub type RouteOut = fn(msg: AllocationACK, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
266
267/// Route type returned by the `route` function.
268pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
269
270/// Returns the begin string, message type, and route function for `AllocationACK`.
271pub fn route(router: RouteOut) -> Route {
272    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
273        router(AllocationACK::from_message(msg.clone()), session_id)
274    };
275    ("FIX.4.2", "P", Box::new(r))
276}