Skip to main content

fixer_fix/fix40/
quote.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
12use rust_decimal::Decimal;
13
14
15use jiff::Timestamp;
16
17use crate::field;
18use crate::tag;
19
20/// `Quote` is the `fix40` `Quote` type, `MsgType` = S.
21pub struct Quote {
22    pub message: Message,
23}
24
25impl Quote {
26    /// Creates a new `Quote` with required fields.
27    pub fn new(quote_id: field::QuoteIDField, symbol: field::SymbolField, bid_px: field::BidPxField) -> Self {
28        let mut msg = Message::new();
29        msg.header.set_field(tag::MSG_TYPE, FIXString::from("S".to_string()));
30
31        msg.body.set_field(tag::QUOTE_ID, quote_id.0);
32
33        msg.body.set_field(tag::SYMBOL, symbol.0);
34
35        msg.body.set_field(tag::BID_PX, bid_px.0);
36
37        Self { message: msg }
38    }
39
40    /// Creates a `Quote` 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 `BidPx`, Tag 132.
54    pub fn set_bid_px(&mut self, val: Decimal, scale: i32) {
55        self.message.body.set_field(tag::BID_PX, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
56    }
57
58    /// Gets `BidPx`, Tag 132.
59    pub fn get_bid_px(&self) -> Result<Decimal, MessageRejectErrorEnum> {
60        let mut fld = field::BidPxField::new(Decimal::ZERO, 0);
61        self.message.body.get_field(tag::BID_PX, &mut fld.0)?;
62        Ok(fld.value())
63    }
64
65
66    /// Returns true if `BidPx` is present, Tag 132.
67    pub fn has_bid_px(&self) -> bool {
68        self.message.body.has(tag::BID_PX)
69    }
70
71
72
73
74    /// Sets `BidSize`, Tag 134.
75    pub fn set_bid_size(&mut self, val: Decimal, scale: i32) {
76        self.message.body.set_field(tag::BID_SIZE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
77    }
78
79    /// Gets `BidSize`, Tag 134.
80    pub fn get_bid_size(&self) -> Result<Decimal, MessageRejectErrorEnum> {
81        let mut fld = field::BidSizeField::new(Decimal::ZERO, 0);
82        self.message.body.get_field(tag::BID_SIZE, &mut fld.0)?;
83        Ok(fld.value())
84    }
85
86
87    /// Returns true if `BidSize` is present, Tag 134.
88    pub fn has_bid_size(&self) -> bool {
89        self.message.body.has(tag::BID_SIZE)
90    }
91
92
93
94
95    /// Sets `IDSource`, Tag 22.
96    pub fn set_id_source(&mut self, v: String) {
97        self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
98    }
99
100    /// Gets `IDSource`, Tag 22.
101    pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
102        let mut fld = field::IDSourceField::new(String::new());
103        self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
104        Ok(fld.value().to_string())
105    }
106
107
108    /// Returns true if `IDSource` is present, Tag 22.
109    pub fn has_id_source(&self) -> bool {
110        self.message.body.has(tag::ID_SOURCE)
111    }
112
113
114
115
116    /// Sets `Issuer`, Tag 106.
117    pub fn set_issuer(&mut self, v: String) {
118        self.message.body.set_field(tag::ISSUER, FIXString::from(v));
119    }
120
121    /// Gets `Issuer`, Tag 106.
122    pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
123        let mut fld = field::IssuerField::new(String::new());
124        self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
125        Ok(fld.value().to_string())
126    }
127
128
129    /// Returns true if `Issuer` is present, Tag 106.
130    pub fn has_issuer(&self) -> bool {
131        self.message.body.has(tag::ISSUER)
132    }
133
134
135
136
137    /// Sets `OfferPx`, Tag 133.
138    pub fn set_offer_px(&mut self, val: Decimal, scale: i32) {
139        self.message.body.set_field(tag::OFFER_PX, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
140    }
141
142    /// Gets `OfferPx`, Tag 133.
143    pub fn get_offer_px(&self) -> Result<Decimal, MessageRejectErrorEnum> {
144        let mut fld = field::OfferPxField::new(Decimal::ZERO, 0);
145        self.message.body.get_field(tag::OFFER_PX, &mut fld.0)?;
146        Ok(fld.value())
147    }
148
149
150    /// Returns true if `OfferPx` is present, Tag 133.
151    pub fn has_offer_px(&self) -> bool {
152        self.message.body.has(tag::OFFER_PX)
153    }
154
155
156
157
158    /// Sets `OfferSize`, Tag 135.
159    pub fn set_offer_size(&mut self, val: Decimal, scale: i32) {
160        self.message.body.set_field(tag::OFFER_SIZE, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
161    }
162
163    /// Gets `OfferSize`, Tag 135.
164    pub fn get_offer_size(&self) -> Result<Decimal, MessageRejectErrorEnum> {
165        let mut fld = field::OfferSizeField::new(Decimal::ZERO, 0);
166        self.message.body.get_field(tag::OFFER_SIZE, &mut fld.0)?;
167        Ok(fld.value())
168    }
169
170
171    /// Returns true if `OfferSize` is present, Tag 135.
172    pub fn has_offer_size(&self) -> bool {
173        self.message.body.has(tag::OFFER_SIZE)
174    }
175
176
177
178
179    /// Sets `QuoteID`, Tag 117.
180    pub fn set_quote_id(&mut self, v: String) {
181        self.message.body.set_field(tag::QUOTE_ID, FIXString::from(v));
182    }
183
184    /// Gets `QuoteID`, Tag 117.
185    pub fn get_quote_id(&self) -> Result<String, MessageRejectErrorEnum> {
186        let mut fld = field::QuoteIDField::new(String::new());
187        self.message.body.get_field(tag::QUOTE_ID, &mut fld.0)?;
188        Ok(fld.value().to_string())
189    }
190
191
192    /// Returns true if `QuoteID` is present, Tag 117.
193    pub fn has_quote_id(&self) -> bool {
194        self.message.body.has(tag::QUOTE_ID)
195    }
196
197
198
199
200    /// Sets `QuoteReqID`, Tag 131.
201    pub fn set_quote_req_id(&mut self, v: String) {
202        self.message.body.set_field(tag::QUOTE_REQ_ID, FIXString::from(v));
203    }
204
205    /// Gets `QuoteReqID`, Tag 131.
206    pub fn get_quote_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
207        let mut fld = field::QuoteReqIDField::new(String::new());
208        self.message.body.get_field(tag::QUOTE_REQ_ID, &mut fld.0)?;
209        Ok(fld.value().to_string())
210    }
211
212
213    /// Returns true if `QuoteReqID` is present, Tag 131.
214    pub fn has_quote_req_id(&self) -> bool {
215        self.message.body.has(tag::QUOTE_REQ_ID)
216    }
217
218
219
220
221    /// Sets `SecurityDesc`, Tag 107.
222    pub fn set_security_desc(&mut self, v: String) {
223        self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
224    }
225
226    /// Gets `SecurityDesc`, Tag 107.
227    pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
228        let mut fld = field::SecurityDescField::new(String::new());
229        self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
230        Ok(fld.value().to_string())
231    }
232
233
234    /// Returns true if `SecurityDesc` is present, Tag 107.
235    pub fn has_security_desc(&self) -> bool {
236        self.message.body.has(tag::SECURITY_DESC)
237    }
238
239
240
241
242    /// Sets `SecurityID`, Tag 48.
243    pub fn set_security_id(&mut self, v: String) {
244        self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
245    }
246
247    /// Gets `SecurityID`, Tag 48.
248    pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
249        let mut fld = field::SecurityIDField::new(String::new());
250        self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
251        Ok(fld.value().to_string())
252    }
253
254
255    /// Returns true if `SecurityID` is present, Tag 48.
256    pub fn has_security_id(&self) -> bool {
257        self.message.body.has(tag::SECURITY_ID)
258    }
259
260
261
262
263    /// Sets `Symbol`, Tag 55.
264    pub fn set_symbol(&mut self, v: String) {
265        self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
266    }
267
268    /// Gets `Symbol`, Tag 55.
269    pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
270        let mut fld = field::SymbolField::new(String::new());
271        self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
272        Ok(fld.value().to_string())
273    }
274
275
276    /// Returns true if `Symbol` is present, Tag 55.
277    pub fn has_symbol(&self) -> bool {
278        self.message.body.has(tag::SYMBOL)
279    }
280
281
282
283
284    /// Sets `SymbolSfx`, Tag 65.
285    pub fn set_symbol_sfx(&mut self, v: String) {
286        self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
287    }
288
289    /// Gets `SymbolSfx`, Tag 65.
290    pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
291        let mut fld = field::SymbolSfxField::new(String::new());
292        self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
293        Ok(fld.value().to_string())
294    }
295
296
297    /// Returns true if `SymbolSfx` is present, Tag 65.
298    pub fn has_symbol_sfx(&self) -> bool {
299        self.message.body.has(tag::SYMBOL_SFX)
300    }
301
302
303
304
305    /// Sets `ValidUntilTime`, Tag 62.
306    pub fn set_valid_until_time(&mut self, v: Timestamp) {
307        self.message.body.set_field(tag::VALID_UNTIL_TIME, fixer::fix_utc_timestamp::FIXUTCTimestamp {
308            time: v,
309            precision: fixer::fix_utc_timestamp::TimestampPrecision::Millis,
310        });
311    }
312
313    /// Gets `ValidUntilTime`, Tag 62.
314    pub fn get_valid_until_time(&self) -> Result<Timestamp, MessageRejectErrorEnum> {
315        let mut fld = field::ValidUntilTimeField::new(Timestamp::UNIX_EPOCH);
316        self.message.body.get_field(tag::VALID_UNTIL_TIME, &mut fld.0)?;
317        Ok(fld.value())
318    }
319
320
321    /// Returns true if `ValidUntilTime` is present, Tag 62.
322    pub fn has_valid_until_time(&self) -> bool {
323        self.message.body.has(tag::VALID_UNTIL_TIME)
324    }
325
326
327}
328
329/// `RouteOut` is the callback type for routing `Quote` messages.
330pub type RouteOut = fn(msg: Quote, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
331
332/// Route type returned by the `route` function.
333pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
334
335/// Returns the begin string, message type, and route function for `Quote`.
336pub fn route(router: RouteOut) -> Route {
337    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
338        router(Quote::from_message(msg.clone()), session_id)
339    };
340    ("FIX.4.0", "S", Box::new(r))
341}