Skip to main content

fixer_fix/fixt11/
logout.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/// `Logout` is the `fixt11` `Logout` type, `MsgType` = 5.
17pub struct Logout {
18    pub message: Message,
19}
20
21impl Logout {
22    /// Creates a new `Logout` with required fields.
23    pub fn new() -> Self {
24        let mut msg = Message::new();
25        msg.header.set_field(tag::MSG_TYPE, FIXString::from("5".to_string()));
26
27        Self { message: msg }
28    }
29
30    /// Creates a `Logout` from an existing `Message`.
31    pub fn from_message(msg: Message) -> Self {
32        Self { message: msg }
33    }
34
35    /// Returns the underlying `Message`.
36    pub fn to_message(self) -> Message {
37        self.message
38    }
39
40
41
42
43    /// Sets `EncodedText`, Tag 355.
44    pub fn set_encoded_text(&mut self, v: String) {
45        self.message.body.set_field(tag::ENCODED_TEXT, FIXString::from(v));
46    }
47
48    /// Gets `EncodedText`, Tag 355.
49    pub fn get_encoded_text(&self) -> Result<String, MessageRejectErrorEnum> {
50        let mut fld = field::EncodedTextField::new(String::new());
51        self.message.body.get_field(tag::ENCODED_TEXT, &mut fld.0)?;
52        Ok(fld.value().to_string())
53    }
54
55
56    /// Returns true if `EncodedText` is present, Tag 355.
57    pub fn has_encoded_text(&self) -> bool {
58        self.message.body.has(tag::ENCODED_TEXT)
59    }
60
61
62
63
64    /// Sets `EncodedTextLen`, Tag 354.
65    pub fn set_encoded_text_len(&mut self, v: isize) {
66        self.message.body.set_field(tag::ENCODED_TEXT_LEN, fixer::fix_int::FIXInt::from(v));
67    }
68
69    /// Gets `EncodedTextLen`, Tag 354.
70    pub fn get_encoded_text_len(&self) -> Result<isize, MessageRejectErrorEnum> {
71        let mut fld = field::EncodedTextLenField::new(0);
72        self.message.body.get_field(tag::ENCODED_TEXT_LEN, &mut fld.0)?;
73        Ok(fld.value())
74    }
75
76
77    /// Returns true if `EncodedTextLen` is present, Tag 354.
78    pub fn has_encoded_text_len(&self) -> bool {
79        self.message.body.has(tag::ENCODED_TEXT_LEN)
80    }
81
82
83
84
85    /// Sets `Text`, Tag 58.
86    pub fn set_text(&mut self, v: String) {
87        self.message.body.set_field(tag::TEXT, FIXString::from(v));
88    }
89
90    /// Gets `Text`, Tag 58.
91    pub fn get_text(&self) -> Result<String, MessageRejectErrorEnum> {
92        let mut fld = field::TextField::new(String::new());
93        self.message.body.get_field(tag::TEXT, &mut fld.0)?;
94        Ok(fld.value().to_string())
95    }
96
97
98    /// Returns true if `Text` is present, Tag 58.
99    pub fn has_text(&self) -> bool {
100        self.message.body.has(tag::TEXT)
101    }
102
103
104}
105
106/// `RouteOut` is the callback type for routing `Logout` messages.
107pub type RouteOut = fn(msg: Logout, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
108
109/// Route type returned by the `route` function.
110pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
111
112/// Returns the begin string, message type, and route function for `Logout`.
113pub fn route(router: RouteOut) -> Route {
114    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
115        router(Logout::from_message(msg.clone()), session_id)
116    };
117    ("FIXT.1.1", "5", Box::new(r))
118}