Skip to main content

fixer_fix/fix50sp1/
application_message_report.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/// `ApplicationMessageReport` is the `fix50sp1` `ApplicationMessageReport` type, `MsgType` = BY.
17pub struct ApplicationMessageReport {
18    pub message: Message,
19}
20
21impl ApplicationMessageReport {
22    /// Creates a new `ApplicationMessageReport` with required fields.
23    pub fn new(appl_report_id: field::ApplReportIDField, appl_report_type: field::ApplReportTypeField) -> Self {
24        let mut msg = Message::new();
25        msg.header.set_field(tag::MSG_TYPE, FIXString::from("BY".to_string()));
26
27        msg.body.set_field(tag::APPL_REPORT_ID, appl_report_id.0);
28
29        msg.body.set_field(tag::APPL_REPORT_TYPE, appl_report_type.0);
30
31        Self { message: msg }
32    }
33
34    /// Creates a `ApplicationMessageReport` from an existing `Message`.
35    pub fn from_message(msg: Message) -> Self {
36        Self { message: msg }
37    }
38
39    /// Returns the underlying `Message`.
40    pub fn to_message(self) -> Message {
41        self.message
42    }
43
44
45
46
47    /// Sets `ApplReportID`, Tag 1356.
48    pub fn set_appl_report_id(&mut self, v: String) {
49        self.message.body.set_field(tag::APPL_REPORT_ID, FIXString::from(v));
50    }
51
52    /// Gets `ApplReportID`, Tag 1356.
53    pub fn get_appl_report_id(&self) -> Result<String, MessageRejectErrorEnum> {
54        let mut fld = field::ApplReportIDField::new(String::new());
55        self.message.body.get_field(tag::APPL_REPORT_ID, &mut fld.0)?;
56        Ok(fld.value().to_string())
57    }
58
59
60    /// Returns true if `ApplReportID` is present, Tag 1356.
61    pub fn has_appl_report_id(&self) -> bool {
62        self.message.body.has(tag::APPL_REPORT_ID)
63    }
64
65
66
67
68    /// Sets `ApplReportType`, Tag 1426.
69    pub fn set_appl_report_type(&mut self, v: isize) {
70        self.message.body.set_field(tag::APPL_REPORT_TYPE, fixer::fix_int::FIXInt::from(v));
71    }
72
73    /// Gets `ApplReportType`, Tag 1426.
74    pub fn get_appl_report_type(&self) -> Result<isize, MessageRejectErrorEnum> {
75        let mut fld = field::ApplReportTypeField::new(0);
76        self.message.body.get_field(tag::APPL_REPORT_TYPE, &mut fld.0)?;
77        Ok(fld.value())
78    }
79
80
81    /// Returns true if `ApplReportType` is present, Tag 1426.
82    pub fn has_appl_report_type(&self) -> bool {
83        self.message.body.has(tag::APPL_REPORT_TYPE)
84    }
85
86
87
88
89    /// Sets `EncodedText`, Tag 355.
90    pub fn set_encoded_text(&mut self, v: String) {
91        self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
92    }
93
94    /// Gets `EncodedText`, Tag 355.
95    pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
96        let mut fld = field::EncodedTextField::new(String::new());
97        self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
98        Ok(fld.value().to_string())
99    }
100
101
102    /// Returns true if `EncodedText` is present, Tag 355.
103    pub fn has_encoded_text(&self) -> bool {
104        self.message.body.has(tag::ENCODED_TEXT)
105    }
106
107
108
109
110    /// Sets `EncodedTextLen`, Tag 354.
111    pub fn set_encoded_text_len(&mut self, v: isize) {
112        self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
113    }
114
115    /// Gets `EncodedTextLen`, Tag 354.
116    pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
117        let mut fld = field::EncodedTextLenField::new(0);
118        self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
119        Ok(fld.value())
120    }
121
122
123    /// Returns true if `EncodedTextLen` is present, Tag 354.
124    pub fn has_encoded_text_len(&self) -> bool {
125        self.message.body.has(tag::ENCODED_TEXT_LEN)
126    }
127
128
129
130
131    /// Sets `NoApplIDs`, Tag 1351.
132    pub fn set_no_appl_i_ds(&mut self, v: isize) {
133        self.message.body.set_field(tag::NO_APPL_I_DS, fixer::fix_int::FIXInt::from(v));
134    }
135
136    /// Gets `NoApplIDs`, Tag 1351.
137    pub fn get_no_appl_i_ds(&self) -> Result<isize, MessageRejectErrorEnum> {
138        let mut fld = field::NoApplIDsField::new(0);
139        self.message.body.get_field(tag::NO_APPL_I_DS, &mut fld.0)?;
140        Ok(fld.value())
141    }
142
143
144    /// Returns true if `NoApplIDs` is present, Tag 1351.
145    pub fn has_no_appl_i_ds(&self) -> bool {
146        self.message.body.has(tag::NO_APPL_I_DS)
147    }
148
149
150
151
152    /// Sets `Text`, Tag 58.
153    pub fn set_text(&mut self, v: String) {
154        self.message.body.set_field(tag::TEXT, FIXString::from(v));
155    }
156
157    /// Gets `Text`, Tag 58.
158    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
159        let mut fld = field::TextField::new(String::new());
160        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
161        Ok(fld.value().to_string())
162    }
163
164
165    /// Returns true if `Text` is present, Tag 58.
166    pub fn has_text(&self) -> bool {
167        self.message.body.has(tag::TEXT)
168    }
169
170
171}
172
173/// `RouteOut` is the callback type for routing `ApplicationMessageReport` messages.
174pub type RouteOut = fn(msg: ApplicationMessageReport, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
175
176/// Route type returned by the `route` function.
177pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
178
179/// Returns the begin string, message type, and route function for `ApplicationMessageReport`.
180pub fn route(router: RouteOut) -> Route {
181    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
182        router(ApplicationMessageReport::from_message(msg.clone()), session_id)
183    };
184    ("8", "BY", Box::new(r))
185}