refix_fix44/generated/messages/
reject.rs1#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{InvalidValue, LazyKnownTags, RawMessage, Tag};
5
6use super::super::components::{Header, Trailer};
7use super::super::enums::SessionRejectReason;
8
9pub struct Reject(RawMessage);
11
12impl Reject {
13 pub const MSG_TYPE: &[u8] = b"3";
14
15 pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
16 static TAGS: LazyKnownTags = LazyKnownTags::new(
17 &[Tag(45), Tag(371), Tag(372), Tag(373), Tag(58), Tag(354), Tag(355)],
18 &[Header::known_tags(), Trailer::known_tags()],
19 );
20 &TAGS
21 }
22
23 pub fn from_raw(raw: RawMessage) -> Self {
24 Self(raw)
25 }
26
27 pub fn raw(&self) -> &RawMessage {
28 &self.0
29 }
30
31 pub fn header(&self) -> Header<'_> {
32 Header(self.0.scope(), Self::known_tags().get())
33 }
34
35 pub fn trailer(&self) -> Trailer<'_> {
36 Trailer(self.0.scope())
37 }
38
39 #[doc(alias = "RefSeqNum")]
41 pub fn ref_seq_num(&self) -> Result<Option<i64>, InvalidValue> {
42 self.0.get_int(Tag(45))
43 }
44
45 #[doc(alias = "RefTagID")]
47 pub fn ref_tag_id(&self) -> Result<Option<i64>, InvalidValue> {
48 self.0.get_int(Tag(371))
49 }
50
51 #[doc(alias = "RefMsgType")]
53 pub fn ref_msg_type(&self) -> Result<Option<&str>, InvalidValue> {
54 self.0.get_str(Tag(372))
55 }
56
57 #[doc(alias = "SessionRejectReason")]
59 pub fn session_reject_reason(&self) -> Result<Option<SessionRejectReason>, InvalidValue> {
60 Ok(self.0.get_int(Tag(373))?.map(SessionRejectReason::from_value))
61 }
62
63 #[doc(alias = "Text")]
65 pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
66 self.0.get_str(Tag(58))
67 }
68
69 #[doc(alias = "EncodedTextLen")]
71 pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
72 self.0.get_int(Tag(354))
73 }
74
75 #[doc(alias = "EncodedText")]
77 pub fn encoded_text(&self) -> Option<&[u8]> {
78 self.0.get(Tag(355))
79 }
80}
81
82impl std::fmt::Debug for Reject {
83 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
84 write!(f, "Reject({})", self.0)
85 }
86}
87
88impl std::fmt::Display for Reject {
89 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
90 std::fmt::Display::fmt(&self.0, f)
91 }
92}