Skip to main content

fixer_fix/fix40/
resend_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/// `ResendRequest` is the `fix40` `ResendRequest` type, `MsgType` = 2.
17pub struct ResendRequest {
18    pub message: Message,
19}
20
21impl ResendRequest {
22    /// Creates a new `ResendRequest` with required fields.
23    pub fn new(begin_seq_no: field::BeginSeqNoField, end_seq_no: field::EndSeqNoField) -> Self {
24        let mut msg = Message::new();
25        msg.header.set_field(tag::MSG_TYPE, FIXString::from("2".to_string()));
26
27        msg.body.set_field(tag::BEGIN_SEQ_NO, begin_seq_no.0);
28
29        msg.body.set_field(tag::END_SEQ_NO, end_seq_no.0);
30
31        Self { message: msg }
32    }
33
34    /// Creates a `ResendRequest` 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 `BeginSeqNo`, Tag 7.
48    pub fn set_begin_seq_no(&mut self, v: isize) {
49        self.message.body.set_field(tag::BEGIN_SEQ_NO, fixer::fix_int::FIXInt::from(v));
50    }
51
52    /// Gets `BeginSeqNo`, Tag 7.
53    pub fn get_begin_seq_no(&self) -> Result<isize, MessageRejectErrorEnum> {
54        let mut fld = field::BeginSeqNoField::new(0);
55        self.message.body.get_field(tag::BEGIN_SEQ_NO, &mut fld.0)?;
56        Ok(fld.value())
57    }
58
59
60    /// Returns true if `BeginSeqNo` is present, Tag 7.
61    pub fn has_begin_seq_no(&self) -> bool {
62        self.message.body.has(tag::BEGIN_SEQ_NO)
63    }
64
65
66
67
68    /// Sets `EndSeqNo`, Tag 16.
69    pub fn set_end_seq_no(&mut self, v: isize) {
70        self.message.body.set_field(tag::END_SEQ_NO, fixer::fix_int::FIXInt::from(v));
71    }
72
73    /// Gets `EndSeqNo`, Tag 16.
74    pub fn get_end_seq_no(&self) -> Result<isize, MessageRejectErrorEnum> {
75        let mut fld = field::EndSeqNoField::new(0);
76        self.message.body.get_field(tag::END_SEQ_NO, &mut fld.0)?;
77        Ok(fld.value())
78    }
79
80
81    /// Returns true if `EndSeqNo` is present, Tag 16.
82    pub fn has_end_seq_no(&self) -> bool {
83        self.message.body.has(tag::END_SEQ_NO)
84    }
85
86
87}
88
89/// `RouteOut` is the callback type for routing `ResendRequest` messages.
90pub type RouteOut = fn(msg: ResendRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
91
92/// Route type returned by the `route` function.
93pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
94
95/// Returns the begin string, message type, and route function for `ResendRequest`.
96pub fn route(router: RouteOut) -> Route {
97    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
98        router(ResendRequest::from_message(msg.clone()), session_id)
99    };
100    ("FIX.4.0", "2", Box::new(r))
101}