Skip to main content

fixer_fix/fix43/
security_list.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/// `SecurityList` is the `fix43` `SecurityList` type, `MsgType` = y.
17pub struct SecurityList {
18    pub message: Message,
19}
20
21impl SecurityList {
22    /// Creates a new `SecurityList` with required fields.
23    pub fn new(security_req_id: field::SecurityReqIDField, security_response_id: field::SecurityResponseIDField, security_request_result: field::SecurityRequestResultField) -> Self {
24        let mut msg = Message::new();
25        msg.header.set_field(tag::MSG_TYPE, FIXString::from("y".to_string()));
26
27        msg.body.set_field(tag::SECURITY_REQ_ID, security_req_id.0);
28
29        msg.body.set_field(tag::SECURITY_RESPONSE_ID, security_response_id.0);
30
31        msg.body.set_field(tag::SECURITY_REQUEST_RESULT, security_request_result.0);
32
33        Self { message: msg }
34    }
35
36    /// Creates a `SecurityList` 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 `NoRelatedSym`, Tag 146.
50    pub fn set_no_related_sym(&mut self, v: isize) {
51        self.message.body.set_field(tag::NO_RELATED_SYM, fixer::fix_int::FIXInt::from(v));
52    }
53
54    /// Gets `NoRelatedSym`, Tag 146.
55    pub fn get_no_related_sym(&self) -> Result<isize, MessageRejectErrorEnum> {
56        let mut fld = field::NoRelatedSymField::new(0);
57        self.message.body.get_field(tag::NO_RELATED_SYM, &mut fld.0)?;
58        Ok(fld.value())
59    }
60
61
62    /// Returns true if `NoRelatedSym` is present, Tag 146.
63    pub fn has_no_related_sym(&self) -> bool {
64        self.message.body.has(tag::NO_RELATED_SYM)
65    }
66
67
68
69
70    /// Sets `SecurityReqID`, Tag 320.
71    pub fn set_security_req_id(&mut self, v: String) {
72        self.message.body.set_field(tag::SECURITY_REQ_ID, FIXString::from(v));
73    }
74
75    /// Gets `SecurityReqID`, Tag 320.
76    pub fn get_security_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
77        let mut fld = field::SecurityReqIDField::new(String::new());
78        self.message.body.get_field(tag::SECURITY_REQ_ID, &mut fld.0)?;
79        Ok(fld.value().to_string())
80    }
81
82
83    /// Returns true if `SecurityReqID` is present, Tag 320.
84    pub fn has_security_req_id(&self) -> bool {
85        self.message.body.has(tag::SECURITY_REQ_ID)
86    }
87
88
89
90
91    /// Sets `SecurityRequestResult`, Tag 560.
92    pub fn set_security_request_result(&mut self, v: isize) {
93        self.message.body.set_field(tag::SECURITY_REQUEST_RESULT, fixer::fix_int::FIXInt::from(v));
94    }
95
96    /// Gets `SecurityRequestResult`, Tag 560.
97    pub fn get_security_request_result(&self) -> Result<isize, MessageRejectErrorEnum> {
98        let mut fld = field::SecurityRequestResultField::new(0);
99        self.message.body.get_field(tag::SECURITY_REQUEST_RESULT, &mut fld.0)?;
100        Ok(fld.value())
101    }
102
103
104    /// Returns true if `SecurityRequestResult` is present, Tag 560.
105    pub fn has_security_request_result(&self) -> bool {
106        self.message.body.has(tag::SECURITY_REQUEST_RESULT)
107    }
108
109
110
111
112    /// Sets `SecurityResponseID`, Tag 322.
113    pub fn set_security_response_id(&mut self, v: String) {
114        self.message.body.set_field(tag::SECURITY_RESPONSE_ID, FIXString::from(v));
115    }
116
117    /// Gets `SecurityResponseID`, Tag 322.
118    pub fn get_security_response_id(&self) -> Result<String, MessageRejectErrorEnum> {
119        let mut fld = field::SecurityResponseIDField::new(String::new());
120        self.message.body.get_field(tag::SECURITY_RESPONSE_ID, &mut fld.0)?;
121        Ok(fld.value().to_string())
122    }
123
124
125    /// Returns true if `SecurityResponseID` is present, Tag 322.
126    pub fn has_security_response_id(&self) -> bool {
127        self.message.body.has(tag::SECURITY_RESPONSE_ID)
128    }
129
130
131
132
133    /// Sets `TotalNumSecurities`, Tag 393.
134    pub fn set_total_num_securities(&mut self, v: isize) {
135        self.message.body.set_field(tag::TOTAL_NUM_SECURITIES, fixer::fix_int::FIXInt::from(v));
136    }
137
138    /// Gets `TotalNumSecurities`, Tag 393.
139    pub fn get_total_num_securities(&self) -> Result<isize, MessageRejectErrorEnum> {
140        let mut fld = field::TotalNumSecuritiesField::new(0);
141        self.message.body.get_field(tag::TOTAL_NUM_SECURITIES, &mut fld.0)?;
142        Ok(fld.value())
143    }
144
145
146    /// Returns true if `TotalNumSecurities` is present, Tag 393.
147    pub fn has_total_num_securities(&self) -> bool {
148        self.message.body.has(tag::TOTAL_NUM_SECURITIES)
149    }
150
151
152}
153
154/// `RouteOut` is the callback type for routing `SecurityList` messages.
155pub type RouteOut = fn(msg: SecurityList, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
156
157/// Route type returned by the `route` function.
158pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
159
160/// Returns the begin string, message type, and route function for `SecurityList`.
161pub fn route(router: RouteOut) -> Route {
162    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
163        router(SecurityList::from_message(msg.clone()), session_id)
164    };
165    ("FIX.4.3", "y", Box::new(r))
166}