Skip to main content

refix_fix44/generated/components/
header.rs

1// @generated by refix codegen from FIX44.xml. Do not edit.
2#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{
5    GroupTable, Instances, InvalidValue, KnownTags, LazyKnownTags, Tag, UtcTimestamp,
6};
7
8use super::super::enums::{MessageEncoding, MsgType};
9use super::Trailer;
10
11/// The header fields of a message.
12#[derive(Clone, Copy)]
13pub struct Header<'a>(
14    pub(in super::super) refix_message::Scope<'a>,
15    pub(in super::super) KnownTags<'static>,
16);
17
18impl<'a> From<refix_message::Scope<'a>> for Header<'a> {
19    fn from(scope: refix_message::Scope<'a>) -> Self {
20        Self(scope, Self::envelope_tags().get())
21    }
22}
23
24impl<'a> Header<'a> {
25    pub(in super::super) const fn envelope_tags() -> &'static LazyKnownTags {
26        static TAGS: LazyKnownTags = LazyKnownTags::new(
27            &[],
28            &[Header::known_tags(), Trailer::known_tags()],
29        );
30        &TAGS
31    }
32
33    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
34        static TAGS: LazyKnownTags = LazyKnownTags::new(
35            &[
36                Tag(8), Tag(9), Tag(35), Tag(49), Tag(56), Tag(115), Tag(128), Tag(90), Tag(91),
37                Tag(34), Tag(50), Tag(142), Tag(57), Tag(143), Tag(116), Tag(144), Tag(129),
38                Tag(145), Tag(43), Tag(97), Tag(52), Tag(122), Tag(212), Tag(213), Tag(347),
39                Tag(369), Tag(627),
40            ],
41            &[HeaderHops::known_tags()],
42        );
43        &TAGS
44    }
45
46    pub fn raw(&self) -> refix_message::Scope<'a> {
47        self.0
48    }
49
50    /// The `BeginString` (8) field.
51    #[doc(alias = "BeginString")]
52    pub fn begin_string(&self) -> Result<Option<&'a str>, InvalidValue> {
53        self.0.get_str(Tag(8))
54    }
55
56    /// The `BodyLength` (9) field.
57    #[doc(alias = "BodyLength")]
58    pub fn body_length(&self) -> Result<Option<i64>, InvalidValue> {
59        self.0.get_int(Tag(9))
60    }
61
62    /// The `MsgType` (35) field.
63    #[doc(alias = "MsgType")]
64    pub fn msg_type(&self) -> Result<Option<MsgType<'a>>, InvalidValue> {
65        Ok(self.0.get_str(Tag(35))?.map(MsgType::from_value))
66    }
67
68    /// The `SenderCompID` (49) field.
69    #[doc(alias = "SenderCompID")]
70    pub fn sender_comp_id(&self) -> Result<Option<&'a str>, InvalidValue> {
71        self.0.get_str(Tag(49))
72    }
73
74    /// The `TargetCompID` (56) field.
75    #[doc(alias = "TargetCompID")]
76    pub fn target_comp_id(&self) -> Result<Option<&'a str>, InvalidValue> {
77        self.0.get_str(Tag(56))
78    }
79
80    /// The `OnBehalfOfCompID` (115) field.
81    #[doc(alias = "OnBehalfOfCompID")]
82    pub fn on_behalf_of_comp_id(&self) -> Result<Option<&'a str>, InvalidValue> {
83        self.0.get_str(Tag(115))
84    }
85
86    /// The `DeliverToCompID` (128) field.
87    #[doc(alias = "DeliverToCompID")]
88    pub fn deliver_to_comp_id(&self) -> Result<Option<&'a str>, InvalidValue> {
89        self.0.get_str(Tag(128))
90    }
91
92    /// The `SecureDataLen` (90) field.
93    #[doc(alias = "SecureDataLen")]
94    pub fn secure_data_len(&self) -> Result<Option<i64>, InvalidValue> {
95        self.0.get_int(Tag(90))
96    }
97
98    /// The `SecureData` (91) field.
99    #[doc(alias = "SecureData")]
100    pub fn secure_data(&self) -> Option<&'a [u8]> {
101        self.0.get(Tag(91))
102    }
103
104    /// The `MsgSeqNum` (34) field.
105    #[doc(alias = "MsgSeqNum")]
106    pub fn msg_seq_num(&self) -> Result<Option<i64>, InvalidValue> {
107        self.0.get_int(Tag(34))
108    }
109
110    /// The `SenderSubID` (50) field.
111    #[doc(alias = "SenderSubID")]
112    pub fn sender_sub_id(&self) -> Result<Option<&'a str>, InvalidValue> {
113        self.0.get_str(Tag(50))
114    }
115
116    /// The `SenderLocationID` (142) field.
117    #[doc(alias = "SenderLocationID")]
118    pub fn sender_location_id(&self) -> Result<Option<&'a str>, InvalidValue> {
119        self.0.get_str(Tag(142))
120    }
121
122    /// The `TargetSubID` (57) field.
123    #[doc(alias = "TargetSubID")]
124    pub fn target_sub_id(&self) -> Result<Option<&'a str>, InvalidValue> {
125        self.0.get_str(Tag(57))
126    }
127
128    /// The `TargetLocationID` (143) field.
129    #[doc(alias = "TargetLocationID")]
130    pub fn target_location_id(&self) -> Result<Option<&'a str>, InvalidValue> {
131        self.0.get_str(Tag(143))
132    }
133
134    /// The `OnBehalfOfSubID` (116) field.
135    #[doc(alias = "OnBehalfOfSubID")]
136    pub fn on_behalf_of_sub_id(&self) -> Result<Option<&'a str>, InvalidValue> {
137        self.0.get_str(Tag(116))
138    }
139
140    /// The `OnBehalfOfLocationID` (144) field.
141    #[doc(alias = "OnBehalfOfLocationID")]
142    pub fn on_behalf_of_location_id(&self) -> Result<Option<&'a str>, InvalidValue> {
143        self.0.get_str(Tag(144))
144    }
145
146    /// The `DeliverToSubID` (129) field.
147    #[doc(alias = "DeliverToSubID")]
148    pub fn deliver_to_sub_id(&self) -> Result<Option<&'a str>, InvalidValue> {
149        self.0.get_str(Tag(129))
150    }
151
152    /// The `DeliverToLocationID` (145) field.
153    #[doc(alias = "DeliverToLocationID")]
154    pub fn deliver_to_location_id(&self) -> Result<Option<&'a str>, InvalidValue> {
155        self.0.get_str(Tag(145))
156    }
157
158    /// The `PossDupFlag` (43) field.
159    #[doc(alias = "PossDupFlag")]
160    pub fn poss_dup_flag(&self) -> Result<Option<bool>, InvalidValue> {
161        self.0.get_bool(Tag(43))
162    }
163
164    /// The `PossResend` (97) field.
165    #[doc(alias = "PossResend")]
166    pub fn poss_resend(&self) -> Result<Option<bool>, InvalidValue> {
167        self.0.get_bool(Tag(97))
168    }
169
170    /// The `SendingTime` (52) field.
171    #[doc(alias = "SendingTime")]
172    pub fn sending_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
173        self.0.get_utc_timestamp(Tag(52))
174    }
175
176    /// The `OrigSendingTime` (122) field.
177    #[doc(alias = "OrigSendingTime")]
178    pub fn orig_sending_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
179        self.0.get_utc_timestamp(Tag(122))
180    }
181
182    /// The `XmlDataLen` (212) field.
183    #[doc(alias = "XmlDataLen")]
184    pub fn xml_data_len(&self) -> Result<Option<i64>, InvalidValue> {
185        self.0.get_int(Tag(212))
186    }
187
188    /// The `XmlData` (213) field.
189    #[doc(alias = "XmlData")]
190    pub fn xml_data(&self) -> Option<&'a [u8]> {
191        self.0.get(Tag(213))
192    }
193
194    /// The `MessageEncoding` (347) field.
195    #[doc(alias = "MessageEncoding")]
196    pub fn message_encoding(&self) -> Result<Option<MessageEncoding<'a>>, InvalidValue> {
197        Ok(self.0.get_str(Tag(347))?.map(MessageEncoding::from_value))
198    }
199
200    /// The `LastMsgSeqNumProcessed` (369) field.
201    #[doc(alias = "LastMsgSeqNumProcessed")]
202    pub fn last_msg_seq_num_processed(&self) -> Result<Option<i64>, InvalidValue> {
203        self.0.get_int(Tag(369))
204    }
205
206    /// The instances of the `NoHops` (627) group.
207    #[doc(alias = "NoHops")]
208    pub fn hops(&self) -> Result<Instances<'a, HeaderHops<'a>>, InvalidValue> {
209        self.0.get_group(&HeaderHops::TABLE, &self.1).map(Instances::from)
210    }
211}
212
213impl std::fmt::Debug for Header<'_> {
214    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
215        write!(f, "Header({})", self.0.display_known(&Self::known_tags().get()))
216    }
217}
218
219/// An instance of the `NoHops` (627) group.
220#[derive(Clone, Copy)]
221pub struct HeaderHops<'a>(refix_message::Scope<'a>);
222
223impl<'a> From<refix_message::Scope<'a>> for HeaderHops<'a> {
224    fn from(scope: refix_message::Scope<'a>) -> Self {
225        Self(scope)
226    }
227}
228
229impl<'a> HeaderHops<'a> {
230    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
231        Tag(627),
232        Tag(628),
233        &[Tag(628), Tag(629), Tag(630)],
234        &[],
235    );
236
237    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
238        static TAGS: LazyKnownTags = LazyKnownTags::new(&[Tag(628), Tag(629), Tag(630)], &[]);
239        &TAGS
240    }
241
242    pub fn raw(&self) -> refix_message::Scope<'a> {
243        self.0
244    }
245
246    /// The `HopCompID` (628) field.
247    #[doc(alias = "HopCompID")]
248    pub fn hop_comp_id(&self) -> Result<Option<&'a str>, InvalidValue> {
249        self.0.get_str(Tag(628))
250    }
251
252    /// The `HopSendingTime` (629) field.
253    #[doc(alias = "HopSendingTime")]
254    pub fn hop_sending_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
255        self.0.get_utc_timestamp(Tag(629))
256    }
257
258    /// The `HopRefID` (630) field.
259    #[doc(alias = "HopRefID")]
260    pub fn hop_ref_id(&self) -> Result<Option<i64>, InvalidValue> {
261        self.0.get_int(Tag(630))
262    }
263}
264
265impl std::fmt::Debug for HeaderHops<'_> {
266    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
267        write!(f, "HeaderHops({})", self.0)
268    }
269}