Skip to main content

fixer_fix/fix40/
list_status.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 crate::field;
14use crate::tag;
15
16/// `ListStatus` is the `fix40` `ListStatus` type, `MsgType` = N.
17pub struct ListStatus {
18    pub message: Message,
19}
20
21impl ListStatus {
22    /// Creates a new `ListStatus` with required fields.
23    pub fn new(list_id: field::ListIDField, no_rpts: field::NoRptsField, rpt_seq: field::RptSeqField, no_orders: field::NoOrdersField) -> Self {
24        let mut msg = Message::new();
25        msg.header.set_field(tag::MSG_TYPE, FIXString::from("N".to_string()));
26
27        msg.body.set_field(tag::LIST_ID, list_id.0);
28
29        msg.body.set_field(tag::NO_RPTS, no_rpts.0);
30
31        msg.body.set_field(tag::RPT_SEQ, rpt_seq.0);
32
33        msg.body.set_field(tag::NO_ORDERS, no_orders.0);
34
35        Self { message: msg }
36    }
37
38    /// Creates a `ListStatus` 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 `ListID`, Tag 66.
52    pub fn set_list_id(&mut self, v: String) {
53        self.message.body.set_field(tag::LIST_ID, FIXString::from(v));
54    }
55
56    /// Gets `ListID`, Tag 66.
57    pub fn get_list_id(&self) -> Result<String, MessageRejectErrorEnum> {
58        let mut fld = field::ListIDField::new(String::new());
59        self.message.body.get_field(tag::LIST_ID, &mut fld.0)?;
60        Ok(fld.value().to_string())
61    }
62
63
64    /// Returns true if `ListID` is present, Tag 66.
65    pub fn has_list_id(&self) -> bool {
66        self.message.body.has(tag::LIST_ID)
67    }
68
69
70
71
72    /// Sets `NoOrders`, Tag 73.
73    pub fn set_no_orders(&mut self, v: isize) {
74        self.message.body.set_field(tag::NO_ORDERS, fixer::fix_int::FIXInt::from(v));
75    }
76
77    /// Gets `NoOrders`, Tag 73.
78    pub fn get_no_orders(&self) -> Result<isize, MessageRejectErrorEnum> {
79        let mut fld = field::NoOrdersField::new(0);
80        self.message.body.get_field(tag::NO_ORDERS, &mut fld.0)?;
81        Ok(fld.value())
82    }
83
84
85    /// Returns true if `NoOrders` is present, Tag 73.
86    pub fn has_no_orders(&self) -> bool {
87        self.message.body.has(tag::NO_ORDERS)
88    }
89
90
91
92
93    /// Sets `NoRpts`, Tag 82.
94    pub fn set_no_rpts(&mut self, v: isize) {
95        self.message.body.set_field(tag::NO_RPTS, fixer::fix_int::FIXInt::from(v));
96    }
97
98    /// Gets `NoRpts`, Tag 82.
99    pub fn get_no_rpts(&self) -> Result<isize, MessageRejectErrorEnum> {
100        let mut fld = field::NoRptsField::new(0);
101        self.message.body.get_field(tag::NO_RPTS, &mut fld.0)?;
102        Ok(fld.value())
103    }
104
105
106    /// Returns true if `NoRpts` is present, Tag 82.
107    pub fn has_no_rpts(&self) -> bool {
108        self.message.body.has(tag::NO_RPTS)
109    }
110
111
112
113
114    /// Sets `RptSeq`, Tag 83.
115    pub fn set_rpt_seq(&mut self, v: isize) {
116        self.message.body.set_field(tag::RPT_SEQ, fixer::fix_int::FIXInt::from(v));
117    }
118
119    /// Gets `RptSeq`, Tag 83.
120    pub fn get_rpt_seq(&self) -> Result<isize, MessageRejectErrorEnum> {
121        let mut fld = field::RptSeqField::new(0);
122        self.message.body.get_field(tag::RPT_SEQ, &mut fld.0)?;
123        Ok(fld.value())
124    }
125
126
127    /// Returns true if `RptSeq` is present, Tag 83.
128    pub fn has_rpt_seq(&self) -> bool {
129        self.message.body.has(tag::RPT_SEQ)
130    }
131
132
133
134
135    /// Sets `WaveNo`, Tag 105.
136    pub fn set_wave_no(&mut self, v: String) {
137        self.message.body.set_field(tag::WAVE_NO, FIXString::from(v));
138    }
139
140    /// Gets `WaveNo`, Tag 105.
141    pub fn get_wave_no(&self) -> Result<String, MessageRejectErrorEnum> {
142        let mut fld = field::WaveNoField::new(String::new());
143        self.message.body.get_field(tag::WAVE_NO, &mut fld.0)?;
144        Ok(fld.value().to_string())
145    }
146
147
148    /// Returns true if `WaveNo` is present, Tag 105.
149    pub fn has_wave_no(&self) -> bool {
150        self.message.body.has(tag::WAVE_NO)
151    }
152
153
154}
155
156/// `RouteOut` is the callback type for routing `ListStatus` messages.
157pub type RouteOut = fn(msg: ListStatus, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
158
159/// Route type returned by the `route` function.
160pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
161
162/// Returns the begin string, message type, and route function for `ListStatus`.
163pub fn route(router: RouteOut) -> Route {
164    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
165        router(ListStatus::from_message(msg.clone()), session_id)
166    };
167    ("FIX.4.0", "N", Box::new(r))
168}