refix_fix44/generated/messages/
security_definition.rs1#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{Decimal, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag};
5
6use super::super::components::{
7 Header, InstrmtLegGrp, Instrument, InstrumentExtension, Trailer, UndInstrmtGrp,
8};
9use super::super::enums::{ExpirationCycle, SecurityResponseType};
10
11pub struct SecurityDefinition(RawMessage);
13
14impl SecurityDefinition {
15 pub const MSG_TYPE: &[u8] = b"d";
16
17 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
18 static TAGS: LazyKnownTags = LazyKnownTags::new(
19 &[
20 Tag(320), Tag(322), Tag(323), Tag(711), Tag(15), Tag(336), Tag(625), Tag(58),
21 Tag(354), Tag(355), Tag(555), Tag(827), Tag(561), Tag(562),
22 ],
23 &[
24 Header::known_tags(), Trailer::known_tags(), Instrument::known_tags(),
25 InstrumentExtension::known_tags(), UndInstrmtGrp::known_tags(),
26 InstrmtLegGrp::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 = "SecurityReqID")]
50 pub fn security_req_id(&self) -> Result<Option<&str>, InvalidValue> {
51 self.0.get_str(Tag(320))
52 }
53
54 #[doc(alias = "SecurityResponseID")]
56 pub fn security_response_id(&self) -> Result<Option<&str>, InvalidValue> {
57 self.0.get_str(Tag(322))
58 }
59
60 #[doc(alias = "SecurityResponseType")]
62 pub fn security_response_type(&self) -> Result<Option<SecurityResponseType>, InvalidValue> {
63 Ok(self.0.get_int(Tag(323))?.map(SecurityResponseType::from_value))
64 }
65
66 pub fn instrument(&self) -> Instrument<'_> {
68 Instrument(self.0.scope(), Self::known_tags().get())
69 }
70
71 pub fn instrument_extension(&self) -> InstrumentExtension<'_> {
73 InstrumentExtension(self.0.scope(), Self::known_tags().get())
74 }
75
76 #[doc(alias = "NoUnderlyings")]
78 pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, InvalidValue> {
79 self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
80 }
81
82 #[doc(alias = "Currency")]
84 pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
85 self.0.get_str(Tag(15))
86 }
87
88 #[doc(alias = "TradingSessionID")]
90 pub fn trading_session_id(&self) -> Result<Option<&str>, InvalidValue> {
91 self.0.get_str(Tag(336))
92 }
93
94 #[doc(alias = "TradingSessionSubID")]
96 pub fn trading_session_sub_id(&self) -> Result<Option<&str>, InvalidValue> {
97 self.0.get_str(Tag(625))
98 }
99
100 #[doc(alias = "Text")]
102 pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
103 self.0.get_str(Tag(58))
104 }
105
106 #[doc(alias = "EncodedTextLen")]
108 pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
109 self.0.get_int(Tag(354))
110 }
111
112 #[doc(alias = "EncodedText")]
114 pub fn encoded_text(&self) -> Option<&[u8]> {
115 self.0.get(Tag(355))
116 }
117
118 #[doc(alias = "NoLegs")]
120 pub fn legs(&self) -> Result<Instances<'_, InstrmtLegGrp<'_>>, InvalidValue> {
121 self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
122 }
123
124 #[doc(alias = "ExpirationCycle")]
126 pub fn expiration_cycle(&self) -> Result<Option<ExpirationCycle>, InvalidValue> {
127 Ok(self.0.get_int(Tag(827))?.map(ExpirationCycle::from_value))
128 }
129
130 #[doc(alias = "RoundLot")]
132 pub fn round_lot(&self) -> Result<Option<Decimal>, InvalidValue> {
133 self.0.get_decimal(Tag(561))
134 }
135
136 #[doc(alias = "MinTradeVol")]
138 pub fn min_trade_vol(&self) -> Result<Option<Decimal>, InvalidValue> {
139 self.0.get_decimal(Tag(562))
140 }
141}
142
143impl std::fmt::Debug for SecurityDefinition {
144 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
145 write!(f, "SecurityDefinition({})", self.0)
146 }
147}
148
149impl std::fmt::Display for SecurityDefinition {
150 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
151 std::fmt::Display::fmt(&self.0, f)
152 }
153}