refix_fix44/generated/messages/
advertisement.rs1#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{
5 Date, Decimal, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp,
6};
7
8use super::super::components::{Header, InstrmtLegGrp, Instrument, Trailer, UndInstrmtGrp};
9use super::super::enums::{AdvSide, AdvTransType, QtyType};
10
11pub struct Advertisement(RawMessage);
13
14impl Advertisement {
15 pub const MSG_TYPE: &[u8] = b"7";
16
17 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
18 static TAGS: LazyKnownTags = LazyKnownTags::new(
19 &[
20 Tag(2), Tag(5), Tag(3), Tag(555), Tag(711), Tag(4), Tag(53), Tag(854), Tag(44),
21 Tag(15), Tag(75), Tag(60), Tag(58), Tag(354), Tag(355), Tag(149), Tag(30), Tag(336),
22 Tag(625),
23 ],
24 &[
25 Header::known_tags(), Trailer::known_tags(), Instrument::known_tags(),
26 InstrmtLegGrp::known_tags(), UndInstrmtGrp::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 = "AdvId")]
50 pub fn adv_id(&self) -> Result<Option<&str>, InvalidValue> {
51 self.0.get_str(Tag(2))
52 }
53
54 #[doc(alias = "AdvTransType")]
56 pub fn adv_trans_type(&self) -> Result<Option<AdvTransType<'_>>, InvalidValue> {
57 Ok(self.0.get_str(Tag(5))?.map(AdvTransType::from_value))
58 }
59
60 #[doc(alias = "AdvRefID")]
62 pub fn adv_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
63 self.0.get_str(Tag(3))
64 }
65
66 pub fn instrument(&self) -> Instrument<'_> {
68 Instrument(self.0.scope(), Self::known_tags().get())
69 }
70
71 #[doc(alias = "NoLegs")]
73 pub fn legs(&self) -> Result<Instances<'_, InstrmtLegGrp<'_>>, InvalidValue> {
74 self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
75 }
76
77 #[doc(alias = "NoUnderlyings")]
79 pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, InvalidValue> {
80 self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
81 }
82
83 #[doc(alias = "AdvSide")]
85 pub fn adv_side(&self) -> Result<Option<AdvSide<'_>>, InvalidValue> {
86 Ok(self.0.get_str(Tag(4))?.map(AdvSide::from_value))
87 }
88
89 #[doc(alias = "Quantity")]
91 pub fn quantity(&self) -> Result<Option<Decimal>, InvalidValue> {
92 self.0.get_decimal(Tag(53))
93 }
94
95 #[doc(alias = "QtyType")]
97 pub fn qty_type(&self) -> Result<Option<QtyType>, InvalidValue> {
98 Ok(self.0.get_int(Tag(854))?.map(QtyType::from_value))
99 }
100
101 #[doc(alias = "Price")]
103 pub fn price(&self) -> Result<Option<Decimal>, InvalidValue> {
104 self.0.get_decimal(Tag(44))
105 }
106
107 #[doc(alias = "Currency")]
109 pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
110 self.0.get_str(Tag(15))
111 }
112
113 #[doc(alias = "TradeDate")]
115 pub fn trade_date(&self) -> Result<Option<Date>, InvalidValue> {
116 self.0.get_date(Tag(75))
117 }
118
119 #[doc(alias = "TransactTime")]
121 pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
122 self.0.get_utc_timestamp(Tag(60))
123 }
124
125 #[doc(alias = "Text")]
127 pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
128 self.0.get_str(Tag(58))
129 }
130
131 #[doc(alias = "EncodedTextLen")]
133 pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
134 self.0.get_int(Tag(354))
135 }
136
137 #[doc(alias = "EncodedText")]
139 pub fn encoded_text(&self) -> Option<&[u8]> {
140 self.0.get(Tag(355))
141 }
142
143 #[doc(alias = "URLLink")]
145 pub fn url_link(&self) -> Result<Option<&str>, InvalidValue> {
146 self.0.get_str(Tag(149))
147 }
148
149 #[doc(alias = "LastMkt")]
151 pub fn last_mkt(&self) -> Result<Option<&str>, InvalidValue> {
152 self.0.get_str(Tag(30))
153 }
154
155 #[doc(alias = "TradingSessionID")]
157 pub fn trading_session_id(&self) -> Result<Option<&str>, InvalidValue> {
158 self.0.get_str(Tag(336))
159 }
160
161 #[doc(alias = "TradingSessionSubID")]
163 pub fn trading_session_sub_id(&self) -> Result<Option<&str>, InvalidValue> {
164 self.0.get_str(Tag(625))
165 }
166}
167
168impl std::fmt::Debug for Advertisement {
169 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
170 write!(f, "Advertisement({})", self.0)
171 }
172}
173
174impl std::fmt::Display for Advertisement {
175 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
176 std::fmt::Display::fmt(&self.0, f)
177 }
178}