Skip to main content

fixer_fix/fix50/
trading_session_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/// `TradingSessionList` is the `fix50` `TradingSessionList` type, `MsgType` = BJ.
17pub struct TradingSessionList {
18    pub message: Message,
19}
20
21impl TradingSessionList {
22    /// Creates a new `TradingSessionList` with required fields.
23    pub fn new(no_trading_sessions: field::NoTradingSessionsField) -> Self {
24        let mut msg = Message::new();
25        msg.header.set_field(tag::MSG_TYPE, FIXString::from("BJ".to_string()));
26
27        msg.body.set_field(tag::NO_TRADING_SESSIONS, no_trading_sessions.0);
28
29        Self { message: msg }
30    }
31
32    /// Creates a `TradingSessionList` 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 `NoTradingSessions`, Tag 386.
46    pub fn set_no_trading_sessions(&mut self, v: isize) {
47        self.message.body.set_field(tag::NO_TRADING_SESSIONS, fixer::fix_int::FIXInt::from(v));
48    }
49
50    /// Gets `NoTradingSessions`, Tag 386.
51    pub fn get_no_trading_sessions(&self) -> Result<isize, MessageRejectErrorEnum> {
52        let mut fld = field::NoTradingSessionsField::new(0);
53        self.message.body.get_field(tag::NO_TRADING_SESSIONS, &mut fld.0)?;
54        Ok(fld.value())
55    }
56
57
58    /// Returns true if `NoTradingSessions` is present, Tag 386.
59    pub fn has_no_trading_sessions(&self) -> bool {
60        self.message.body.has(tag::NO_TRADING_SESSIONS)
61    }
62
63
64
65
66    /// Sets `TradSesReqID`, Tag 335.
67    pub fn set_trad_ses_req_id(&mut self, v: String) {
68        self.message.body.set_field(tag::TRAD_SES_REQ_ID, FIXString::from(v));
69    }
70
71    /// Gets `TradSesReqID`, Tag 335.
72    pub fn get_trad_ses_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
73        let mut fld = field::TradSesReqIDField::new(String::new());
74        self.message.body.get_field(tag::TRAD_SES_REQ_ID, &mut fld.0)?;
75        Ok(fld.value().to_string())
76    }
77
78
79    /// Returns true if `TradSesReqID` is present, Tag 335.
80    pub fn has_trad_ses_req_id(&self) -> bool {
81        self.message.body.has(tag::TRAD_SES_REQ_ID)
82    }
83
84
85}
86
87/// `RouteOut` is the callback type for routing `TradingSessionList` messages.
88pub type RouteOut = fn(msg: TradingSessionList, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
89
90/// Route type returned by the `route` function.
91pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
92
93/// Returns the begin string, message type, and route function for `TradingSessionList`.
94pub fn route(router: RouteOut) -> Route {
95    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
96        router(TradingSessionList::from_message(msg.clone()), session_id)
97    };
98    ("7", "BJ", Box::new(r))
99}