Skip to main content

fixer_fix/fix44/
user_request.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/// `UserRequest` is the `fix44` `UserRequest` type, `MsgType` = BE.
17pub struct UserRequest {
18    pub message: Message,
19}
20
21impl UserRequest {
22    /// Creates a new `UserRequest` with required fields.
23    pub fn new(user_request_id: field::UserRequestIDField, user_request_type: field::UserRequestTypeField, username: field::UsernameField) -> Self {
24        let mut msg = Message::new();
25        msg.header.set_field(tag::MSG_TYPE, FIXString::from("BE".to_string()));
26
27        msg.body.set_field(tag::USER_REQUEST_ID, user_request_id.0);
28
29        msg.body.set_field(tag::USER_REQUEST_TYPE, user_request_type.0);
30
31        msg.body.set_field(tag::USERNAME, username.0);
32
33        Self { message: msg }
34    }
35
36    /// Creates a `UserRequest` from an existing `Message`.
37    pub fn from_message(msg: Message) -> Self {
38        Self { message: msg }
39    }
40
41    /// Returns the underlying `Message`.
42    pub fn to_message(self) -> Message {
43        self.message
44    }
45
46
47
48
49    /// Sets `NewPassword`, Tag 925.
50    pub fn set_new_password(&mut self, v: String) {
51        self.message.body.set_field(tag::NEW_PASSWORD, FIXString::from(v));
52    }
53
54    /// Gets `NewPassword`, Tag 925.
55    pub fn get_new_password(&self) -> Result<String, MessageRejectErrorEnum> {
56        let mut fld = field::NewPasswordField::new(String::new());
57        self.message.body.get_field(tag::NEW_PASSWORD, &mut fld.0)?;
58        Ok(fld.value().to_string())
59    }
60
61
62    /// Returns true if `NewPassword` is present, Tag 925.
63    pub fn has_new_password(&self) -> bool {
64        self.message.body.has(tag::NEW_PASSWORD)
65    }
66
67
68
69
70    /// Sets `Password`, Tag 554.
71    pub fn set_password(&mut self, v: String) {
72        self.message.body.set_field(tag::PASSWORD, FIXString::from(v));
73    }
74
75    /// Gets `Password`, Tag 554.
76    pub fn get_password(&self) -> Result<String, MessageRejectErrorEnum> {
77        let mut fld = field::PasswordField::new(String::new());
78        self.message.body.get_field(tag::PASSWORD, &mut fld.0)?;
79        Ok(fld.value().to_string())
80    }
81
82
83    /// Returns true if `Password` is present, Tag 554.
84    pub fn has_password(&self) -> bool {
85        self.message.body.has(tag::PASSWORD)
86    }
87
88
89
90
91    /// Sets `RawData`, Tag 96.
92    pub fn set_raw_data(&mut self, v: String) {
93        self.message.body.set_field(tag::RAW_DATA, FIXString::from(v));
94    }
95
96    /// Gets `RawData`, Tag 96.
97    pub fn get_raw_data(&self) -> Result<String, MessageRejectErrorEnum> {
98        let mut fld = field::RawDataField::new(String::new());
99        self.message.body.get_field(tag::RAW_DATA, &mut fld.0)?;
100        Ok(fld.value().to_string())
101    }
102
103
104    /// Returns true if `RawData` is present, Tag 96.
105    pub fn has_raw_data(&self) -> bool {
106        self.message.body.has(tag::RAW_DATA)
107    }
108
109
110
111
112    /// Sets `RawDataLength`, Tag 95.
113    pub fn set_raw_data_length(&mut self, v: isize) {
114        self.message.body.set_field(tag::RAW_DATA_LENGTH, fixer::fix_int::FIXInt::from(v));
115    }
116
117    /// Gets `RawDataLength`, Tag 95.
118    pub fn get_raw_data_length(&self) -> Result<isize, MessageRejectErrorEnum> {
119        let mut fld = field::RawDataLengthField::new(0);
120        self.message.body.get_field(tag::RAW_DATA_LENGTH, &mut fld.0)?;
121        Ok(fld.value())
122    }
123
124
125    /// Returns true if `RawDataLength` is present, Tag 95.
126    pub fn has_raw_data_length(&self) -> bool {
127        self.message.body.has(tag::RAW_DATA_LENGTH)
128    }
129
130
131
132
133    /// Sets `UserRequestID`, Tag 923.
134    pub fn set_user_request_id(&mut self, v: String) {
135        self.message.body.set_field(tag::USER_REQUEST_ID, FIXString::from(v));
136    }
137
138    /// Gets `UserRequestID`, Tag 923.
139    pub fn get_user_request_id(&self) -> Result<String, MessageRejectErrorEnum> {
140        let mut fld = field::UserRequestIDField::new(String::new());
141        self.message.body.get_field(tag::USER_REQUEST_ID, &mut fld.0)?;
142        Ok(fld.value().to_string())
143    }
144
145
146    /// Returns true if `UserRequestID` is present, Tag 923.
147    pub fn has_user_request_id(&self) -> bool {
148        self.message.body.has(tag::USER_REQUEST_ID)
149    }
150
151
152
153
154    /// Sets `UserRequestType`, Tag 924.
155    pub fn set_user_request_type(&mut self, v: isize) {
156        self.message.body.set_field(tag::USER_REQUEST_TYPE, fixer::fix_int::FIXInt::from(v));
157    }
158
159    /// Gets `UserRequestType`, Tag 924.
160    pub fn get_user_request_type(&self) -> Result<isize, MessageRejectErrorEnum> {
161        let mut fld = field::UserRequestTypeField::new(0);
162        self.message.body.get_field(tag::USER_REQUEST_TYPE, &mut fld.0)?;
163        Ok(fld.value())
164    }
165
166
167    /// Returns true if `UserRequestType` is present, Tag 924.
168    pub fn has_user_request_type(&self) -> bool {
169        self.message.body.has(tag::USER_REQUEST_TYPE)
170    }
171
172
173
174
175    /// Sets `Username`, Tag 553.
176    pub fn set_username(&mut self, v: String) {
177        self.message.body.set_field(tag::USERNAME, FIXString::from(v));
178    }
179
180    /// Gets `Username`, Tag 553.
181    pub fn get_username(&self) -> Result<String, MessageRejectErrorEnum> {
182        let mut fld = field::UsernameField::new(String::new());
183        self.message.body.get_field(tag::USERNAME, &mut fld.0)?;
184        Ok(fld.value().to_string())
185    }
186
187
188    /// Returns true if `Username` is present, Tag 553.
189    pub fn has_username(&self) -> bool {
190        self.message.body.has(tag::USERNAME)
191    }
192
193
194}
195
196/// `RouteOut` is the callback type for routing `UserRequest` messages.
197pub type RouteOut = fn(msg: UserRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
198
199/// Route type returned by the `route` function.
200pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
201
202/// Returns the begin string, message type, and route function for `UserRequest`.
203pub fn route(router: RouteOut) -> Route {
204    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
205        router(UserRequest::from_message(msg.clone()), session_id)
206    };
207    ("FIX.4.4", "BE", Box::new(r))
208}