Skip to main content

refix_fix42/generated/messages/
logon.rs

1// @generated by refix codegen from FIX42.xml. Do not edit.
2#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{GroupTable, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag};
5
6use super::super::components::{Header, Trailer};
7use super::super::enums::{EncryptMethod, MsgDirection};
8
9/// The `Logon` (35=A) message.
10pub struct Logon(RawMessage);
11
12impl Logon {
13    pub const MSG_TYPE: &[u8] = b"A";
14
15    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
16        static TAGS: LazyKnownTags = LazyKnownTags::new(
17            &[Tag(98), Tag(108), Tag(95), Tag(96), Tag(141), Tag(383), Tag(384)],
18            &[Header::known_tags(), Trailer::known_tags(), LogonMsgTypes::known_tags()],
19        );
20        &TAGS
21    }
22
23    pub fn from_raw(raw: RawMessage) -> Self {
24        Self(raw)
25    }
26
27    pub fn raw(&self) -> &RawMessage {
28        &self.0
29    }
30
31    pub fn header(&self) -> Header<'_> {
32        Header(self.0.scope())
33    }
34
35    pub fn trailer(&self) -> Trailer<'_> {
36        Trailer(self.0.scope())
37    }
38
39    /// The `EncryptMethod` (98) field.
40    #[doc(alias = "EncryptMethod")]
41    pub fn encrypt_method(&self) -> Result<Option<EncryptMethod>, InvalidValue> {
42        Ok(self.0.get_int(Tag(98))?.map(EncryptMethod::from_value))
43    }
44
45    /// The `HeartBtInt` (108) field.
46    #[doc(alias = "HeartBtInt")]
47    pub fn heart_bt_int(&self) -> Result<Option<i64>, InvalidValue> {
48        self.0.get_int(Tag(108))
49    }
50
51    /// The `RawDataLength` (95) field.
52    #[doc(alias = "RawDataLength")]
53    pub fn raw_data_length(&self) -> Result<Option<i64>, InvalidValue> {
54        self.0.get_int(Tag(95))
55    }
56
57    /// The `RawData` (96) field.
58    #[doc(alias = "RawData")]
59    pub fn raw_data(&self) -> Option<&[u8]> {
60        self.0.get(Tag(96))
61    }
62
63    /// The `ResetSeqNumFlag` (141) field.
64    #[doc(alias = "ResetSeqNumFlag")]
65    pub fn reset_seq_num_flag(&self) -> Result<Option<bool>, InvalidValue> {
66        self.0.get_bool(Tag(141))
67    }
68
69    /// The `MaxMessageSize` (383) field.
70    #[doc(alias = "MaxMessageSize")]
71    pub fn max_message_size(&self) -> Result<Option<i64>, InvalidValue> {
72        self.0.get_int(Tag(383))
73    }
74
75    /// The instances of the `NoMsgTypes` (384) group.
76    #[doc(alias = "NoMsgTypes")]
77    pub fn msg_types(&self) -> Result<Instances<'_, LogonMsgTypes<'_>>, InvalidValue> {
78        self.0.get_group(&LogonMsgTypes::TABLE, &Self::known_tags().get()).map(Instances::from)
79    }
80}
81
82impl std::fmt::Debug for Logon {
83    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
84        write!(f, "Logon({})", self.0)
85    }
86}
87
88impl std::fmt::Display for Logon {
89    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
90        std::fmt::Display::fmt(&self.0, f)
91    }
92}
93
94/// An instance of the `NoMsgTypes` (384) group.
95#[derive(Clone, Copy)]
96pub struct LogonMsgTypes<'a>(refix_message::Scope<'a>);
97
98impl<'a> From<refix_message::Scope<'a>> for LogonMsgTypes<'a> {
99    fn from(scope: refix_message::Scope<'a>) -> Self {
100        Self(scope)
101    }
102}
103
104impl<'a> LogonMsgTypes<'a> {
105    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
106        Tag(384),
107        Tag(372),
108        &[Tag(372), Tag(385)],
109        &[],
110    );
111
112    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
113        static TAGS: LazyKnownTags = LazyKnownTags::new(&[Tag(372), Tag(385)], &[]);
114        &TAGS
115    }
116
117    pub fn raw(&self) -> refix_message::Scope<'a> {
118        self.0
119    }
120
121    /// The `RefMsgType` (372) field.
122    #[doc(alias = "RefMsgType")]
123    pub fn ref_msg_type(&self) -> Result<Option<&'a str>, InvalidValue> {
124        self.0.get_str(Tag(372))
125    }
126
127    /// The `MsgDirection` (385) field.
128    #[doc(alias = "MsgDirection")]
129    pub fn msg_direction(&self) -> Result<Option<MsgDirection<'a>>, InvalidValue> {
130        Ok(self.0.get_str(Tag(385))?.map(MsgDirection::from_value))
131    }
132}
133
134impl std::fmt::Debug for LogonMsgTypes<'_> {
135    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
136        write!(f, "LogonMsgTypes({})", self.0)
137    }
138}