refix_fix44/generated/messages/
logon.rs1#![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
9pub 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 &[
18 Tag(98), Tag(108), Tag(95), Tag(96), Tag(141), Tag(789), Tag(383), Tag(384),
19 Tag(464), Tag(553), Tag(554),
20 ],
21 &[Header::known_tags(), Trailer::known_tags(), LogonMsgTypes::known_tags()],
22 );
23 &TAGS
24 }
25
26 pub fn from_raw(raw: RawMessage) -> Self {
27 Self(raw)
28 }
29
30 pub fn raw(&self) -> &RawMessage {
31 &self.0
32 }
33
34 pub fn header(&self) -> Header<'_> {
35 Header(self.0.scope(), Self::known_tags().get())
36 }
37
38 pub fn trailer(&self) -> Trailer<'_> {
39 Trailer(self.0.scope())
40 }
41
42 #[doc(alias = "EncryptMethod")]
44 pub fn encrypt_method(&self) -> Result<Option<EncryptMethod>, InvalidValue> {
45 Ok(self.0.get_int(Tag(98))?.map(EncryptMethod::from_value))
46 }
47
48 #[doc(alias = "HeartBtInt")]
50 pub fn heart_bt_int(&self) -> Result<Option<i64>, InvalidValue> {
51 self.0.get_int(Tag(108))
52 }
53
54 #[doc(alias = "RawDataLength")]
56 pub fn raw_data_length(&self) -> Result<Option<i64>, InvalidValue> {
57 self.0.get_int(Tag(95))
58 }
59
60 #[doc(alias = "RawData")]
62 pub fn raw_data(&self) -> Option<&[u8]> {
63 self.0.get(Tag(96))
64 }
65
66 #[doc(alias = "ResetSeqNumFlag")]
68 pub fn reset_seq_num_flag(&self) -> Result<Option<bool>, InvalidValue> {
69 self.0.get_bool(Tag(141))
70 }
71
72 #[doc(alias = "NextExpectedMsgSeqNum")]
74 pub fn next_expected_msg_seq_num(&self) -> Result<Option<i64>, InvalidValue> {
75 self.0.get_int(Tag(789))
76 }
77
78 #[doc(alias = "MaxMessageSize")]
80 pub fn max_message_size(&self) -> Result<Option<i64>, InvalidValue> {
81 self.0.get_int(Tag(383))
82 }
83
84 #[doc(alias = "NoMsgTypes")]
86 pub fn msg_types(&self) -> Result<Instances<'_, LogonMsgTypes<'_>>, InvalidValue> {
87 self.0.get_group(&LogonMsgTypes::TABLE, &Self::known_tags().get()).map(Instances::from)
88 }
89
90 #[doc(alias = "TestMessageIndicator")]
92 pub fn test_message_indicator(&self) -> Result<Option<bool>, InvalidValue> {
93 self.0.get_bool(Tag(464))
94 }
95
96 #[doc(alias = "Username")]
98 pub fn username(&self) -> Result<Option<&str>, InvalidValue> {
99 self.0.get_str(Tag(553))
100 }
101
102 #[doc(alias = "Password")]
104 pub fn password(&self) -> Result<Option<&str>, InvalidValue> {
105 self.0.get_str(Tag(554))
106 }
107}
108
109impl std::fmt::Debug for Logon {
110 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
111 write!(f, "Logon({})", self.0)
112 }
113}
114
115impl std::fmt::Display for Logon {
116 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
117 std::fmt::Display::fmt(&self.0, f)
118 }
119}
120
121#[derive(Clone, Copy)]
123pub struct LogonMsgTypes<'a>(refix_message::Scope<'a>);
124
125impl<'a> From<refix_message::Scope<'a>> for LogonMsgTypes<'a> {
126 fn from(scope: refix_message::Scope<'a>) -> Self {
127 Self(scope)
128 }
129}
130
131impl<'a> LogonMsgTypes<'a> {
132 pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
133 Tag(384),
134 Tag(372),
135 &[Tag(372), Tag(385)],
136 &[],
137 );
138
139 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
140 static TAGS: LazyKnownTags = LazyKnownTags::new(&[Tag(372), Tag(385)], &[]);
141 &TAGS
142 }
143
144 pub fn raw(&self) -> refix_message::Scope<'a> {
145 self.0
146 }
147
148 #[doc(alias = "RefMsgType")]
150 pub fn ref_msg_type(&self) -> Result<Option<&'a str>, InvalidValue> {
151 self.0.get_str(Tag(372))
152 }
153
154 #[doc(alias = "MsgDirection")]
156 pub fn msg_direction(&self) -> Result<Option<MsgDirection<'a>>, InvalidValue> {
157 Ok(self.0.get_str(Tag(385))?.map(MsgDirection::from_value))
158 }
159}
160
161impl std::fmt::Debug for LogonMsgTypes<'_> {
162 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
163 write!(f, "LogonMsgTypes({})", self.0)
164 }
165}