Skip to main content

fixer_fix/fix44/
reject.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/// `Reject` is the `fix44` `Reject` type, `MsgType` = 3.
17pub struct Reject {
18    pub message: Message,
19}
20
21impl Reject {
22    /// Creates a new `Reject` with required fields.
23    pub fn new(ref_seq_num: field::RefSeqNumField) -> Self {
24        let mut msg = Message::new();
25        msg.header.set_field(tag::MSG_TYPE, FIXString::from("3".to_string()));
26
27        msg.body.set_field(tag::REF_SEQ_NUM, ref_seq_num.0);
28
29        Self { message: msg }
30    }
31
32    /// Creates a `Reject` from an existing `Message`.
33    pub fn from_message(msg: Message) -> Self {
34        Self { message: msg }
35    }
36
37    /// Returns the underlying `Message`.
38    pub fn to_message(self) -> Message {
39        self.message
40    }
41
42
43
44
45    /// Sets `EncodedText`, Tag 355.
46    pub fn set_encoded_text(&mut self, v: String) {
47        self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
48    }
49
50    /// Gets `EncodedText`, Tag 355.
51    pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
52        let mut fld = field::EncodedTextField::new(String::new());
53        self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
54        Ok(fld.value().to_string())
55    }
56
57
58    /// Returns true if `EncodedText` is present, Tag 355.
59    pub fn has_encoded_text(&self) -> bool {
60        self.message.body.has(tag::ENCODED_TEXT)
61    }
62
63
64
65
66    /// Sets `EncodedTextLen`, Tag 354.
67    pub fn set_encoded_text_len(&mut self, v: isize) {
68        self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
69    }
70
71    /// Gets `EncodedTextLen`, Tag 354.
72    pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
73        let mut fld = field::EncodedTextLenField::new(0);
74        self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
75        Ok(fld.value())
76    }
77
78
79    /// Returns true if `EncodedTextLen` is present, Tag 354.
80    pub fn has_encoded_text_len(&self) -> bool {
81        self.message.body.has(tag::ENCODED_TEXT_LEN)
82    }
83
84
85
86
87    /// Sets `RefMsgType`, Tag 372.
88    pub fn set_ref_msg_type(&mut self, v: String) {
89        self.message.body.set_field(tag::REF_MSG_TYPE, FIXString::from(v));
90    }
91
92    /// Gets `RefMsgType`, Tag 372.
93    pub fn get_ref_msg_type(&self) -> Result<String, MessageRejectErrorEnum> {
94        let mut fld = field::RefMsgTypeField::new(String::new());
95        self.message.body.get_field(tag::REF_MSG_TYPE, &mut fld.0)?;
96        Ok(fld.value().to_string())
97    }
98
99
100    /// Returns true if `RefMsgType` is present, Tag 372.
101    pub fn has_ref_msg_type(&self) -> bool {
102        self.message.body.has(tag::REF_MSG_TYPE)
103    }
104
105
106
107
108    /// Sets `RefSeqNum`, Tag 45.
109    pub fn set_ref_seq_num(&mut self, v: isize) {
110        self.message.body.set_field(tag::REF_SEQ_NUM, fixer::fix_int::FIXInt::from(v));
111    }
112
113    /// Gets `RefSeqNum`, Tag 45.
114    pub fn get_ref_seq_num(&self) -> Result<isize, MessageRejectErrorEnum> {
115        let mut fld = field::RefSeqNumField::new(0);
116        self.message.body.get_field(tag::REF_SEQ_NUM, &mut fld.0)?;
117        Ok(fld.value())
118    }
119
120
121    /// Returns true if `RefSeqNum` is present, Tag 45.
122    pub fn has_ref_seq_num(&self) -> bool {
123        self.message.body.has(tag::REF_SEQ_NUM)
124    }
125
126
127
128
129    /// Sets `RefTagID`, Tag 371.
130    pub fn set_ref_tag_id(&mut self, v: isize) {
131        self.message.body.set_field(tag::REF_TAG_ID, fixer::fix_int::FIXInt::from(v));
132    }
133
134    /// Gets `RefTagID`, Tag 371.
135    pub fn get_ref_tag_id(&self) -> Result<isize, MessageRejectErrorEnum> {
136        let mut fld = field::RefTagIDField::new(0);
137        self.message.body.get_field(tag::REF_TAG_ID, &mut fld.0)?;
138        Ok(fld.value())
139    }
140
141
142    /// Returns true if `RefTagID` is present, Tag 371.
143    pub fn has_ref_tag_id(&self) -> bool {
144        self.message.body.has(tag::REF_TAG_ID)
145    }
146
147
148
149
150    /// Sets `SessionRejectReason`, Tag 373.
151    pub fn set_session_reject_reason(&mut self, v: isize) {
152        self.message.body.set_field(tag::SESSION_REJECT_REASON, fixer::fix_int::FIXInt::from(v));
153    }
154
155    /// Gets `SessionRejectReason`, Tag 373.
156    pub fn get_session_reject_reason(&self) -> Result<isize, MessageRejectErrorEnum> {
157        let mut fld = field::SessionRejectReasonField::new(0);
158        self.message.body.get_field(tag::SESSION_REJECT_REASON, &mut fld.0)?;
159        Ok(fld.value())
160    }
161
162
163    /// Returns true if `SessionRejectReason` is present, Tag 373.
164    pub fn has_session_reject_reason(&self) -> bool {
165        self.message.body.has(tag::SESSION_REJECT_REASON)
166    }
167
168
169
170
171    /// Sets `Text`, Tag 58.
172    pub fn set_text(&mut self, v: String) {
173        self.message.body.set_field(tag::TEXT, FIXString::from(v));
174    }
175
176    /// Gets `Text`, Tag 58.
177    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
178        let mut fld = field::TextField::new(String::new());
179        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
180        Ok(fld.value().to_string())
181    }
182
183
184    /// Returns true if `Text` is present, Tag 58.
185    pub fn has_text(&self) -> bool {
186        self.message.body.has(tag::TEXT)
187    }
188
189
190}
191
192/// `RouteOut` is the callback type for routing `Reject` messages.
193pub type RouteOut = fn(msg: Reject, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
194
195/// Route type returned by the `route` function.
196pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
197
198/// Returns the begin string, message type, and route function for `Reject`.
199pub fn route(router: RouteOut) -> Route {
200    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
201        router(Reject::from_message(msg.clone()), session_id)
202    };
203    ("FIX.4.4", "3", Box::new(r))
204}