refix_fix44/generated/messages/
email.rs1#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{Instances, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp};
5
6use super::super::components::{
7 Header, InstrmtGrp, InstrmtLegGrp, LinesOfTextGrp, RoutingGrp, Trailer, UndInstrmtGrp,
8};
9use super::super::enums::EmailType;
10
11pub struct Email(RawMessage);
13
14impl Email {
15 pub const MSG_TYPE: &[u8] = b"C";
16
17 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
18 static TAGS: LazyKnownTags = LazyKnownTags::new(
19 &[
20 Tag(164), Tag(94), Tag(42), Tag(147), Tag(356), Tag(357), Tag(215), Tag(146),
21 Tag(711), Tag(555), Tag(37), Tag(11), Tag(33), Tag(95), Tag(96),
22 ],
23 &[
24 Header::known_tags(), Trailer::known_tags(), RoutingGrp::known_tags(),
25 InstrmtGrp::known_tags(), UndInstrmtGrp::known_tags(), InstrmtLegGrp::known_tags(),
26 LinesOfTextGrp::known_tags(),
27 ],
28 );
29 &TAGS
30 }
31
32 pub fn from_raw(raw: RawMessage) -> Self {
33 Self(raw)
34 }
35
36 pub fn raw(&self) -> &RawMessage {
37 &self.0
38 }
39
40 pub fn header(&self) -> Header<'_> {
41 Header(self.0.scope(), Self::known_tags().get())
42 }
43
44 pub fn trailer(&self) -> Trailer<'_> {
45 Trailer(self.0.scope())
46 }
47
48 #[doc(alias = "EmailThreadID")]
50 pub fn email_thread_id(&self) -> Result<Option<&str>, InvalidValue> {
51 self.0.get_str(Tag(164))
52 }
53
54 #[doc(alias = "EmailType")]
56 pub fn email_type(&self) -> Result<Option<EmailType<'_>>, InvalidValue> {
57 Ok(self.0.get_str(Tag(94))?.map(EmailType::from_value))
58 }
59
60 #[doc(alias = "OrigTime")]
62 pub fn orig_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
63 self.0.get_utc_timestamp(Tag(42))
64 }
65
66 #[doc(alias = "Subject")]
68 pub fn subject(&self) -> Result<Option<&str>, InvalidValue> {
69 self.0.get_str(Tag(147))
70 }
71
72 #[doc(alias = "EncodedSubjectLen")]
74 pub fn encoded_subject_len(&self) -> Result<Option<i64>, InvalidValue> {
75 self.0.get_int(Tag(356))
76 }
77
78 #[doc(alias = "EncodedSubject")]
80 pub fn encoded_subject(&self) -> Option<&[u8]> {
81 self.0.get(Tag(357))
82 }
83
84 #[doc(alias = "NoRoutingIDs")]
86 pub fn routing_ids(&self) -> Result<Instances<'_, RoutingGrp<'_>>, InvalidValue> {
87 self.0.get_group(&RoutingGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
88 }
89
90 #[doc(alias = "NoRelatedSym")]
92 pub fn related_sym(&self) -> Result<Instances<'_, InstrmtGrp<'_>>, InvalidValue> {
93 self.0.get_group(&InstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
94 }
95
96 #[doc(alias = "NoUnderlyings")]
98 pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, InvalidValue> {
99 self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
100 }
101
102 #[doc(alias = "NoLegs")]
104 pub fn legs(&self) -> Result<Instances<'_, InstrmtLegGrp<'_>>, InvalidValue> {
105 self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
106 }
107
108 #[doc(alias = "OrderID")]
110 pub fn order_id(&self) -> Result<Option<&str>, InvalidValue> {
111 self.0.get_str(Tag(37))
112 }
113
114 #[doc(alias = "ClOrdID")]
116 pub fn cl_ord_id(&self) -> Result<Option<&str>, InvalidValue> {
117 self.0.get_str(Tag(11))
118 }
119
120 #[doc(alias = "NoLinesOfText")]
122 pub fn lines_of_text(&self) -> Result<Instances<'_, LinesOfTextGrp<'_>>, InvalidValue> {
123 self.0.get_group(&LinesOfTextGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
124 }
125
126 #[doc(alias = "RawDataLength")]
128 pub fn raw_data_length(&self) -> Result<Option<i64>, InvalidValue> {
129 self.0.get_int(Tag(95))
130 }
131
132 #[doc(alias = "RawData")]
134 pub fn raw_data(&self) -> Option<&[u8]> {
135 self.0.get(Tag(96))
136 }
137}
138
139impl std::fmt::Debug for Email {
140 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
141 write!(f, "Email({})", self.0)
142 }
143}
144
145impl std::fmt::Display for Email {
146 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
147 std::fmt::Display::fmt(&self.0, f)
148 }
149}