Skip to main content

refix_fix44/generated/messages/
user_response.rs

1// @generated by refix codegen from FIX44.xml. Do not edit.
2#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{InvalidValue, LazyKnownTags, RawMessage, Tag};
5
6use super::super::components::{Header, Trailer};
7use super::super::enums::UserStatus;
8
9/// The `UserResponse` (35=BF) message.
10pub struct UserResponse(RawMessage);
11
12impl UserResponse {
13    pub const MSG_TYPE: &[u8] = b"BF";
14
15    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
16        static TAGS: LazyKnownTags = LazyKnownTags::new(
17            &[Tag(923), Tag(553), Tag(926), Tag(927)],
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    /// The `UserRequestID` (923) field.
40    #[doc(alias = "UserRequestID")]
41    pub fn user_request_id(&self) -> Result<Option<&str>, InvalidValue> {
42        self.0.get_str(Tag(923))
43    }
44
45    /// The `Username` (553) field.
46    #[doc(alias = "Username")]
47    pub fn username(&self) -> Result<Option<&str>, InvalidValue> {
48        self.0.get_str(Tag(553))
49    }
50
51    /// The `UserStatus` (926) field.
52    #[doc(alias = "UserStatus")]
53    pub fn user_status(&self) -> Result<Option<UserStatus>, InvalidValue> {
54        Ok(self.0.get_int(Tag(926))?.map(UserStatus::from_value))
55    }
56
57    /// The `UserStatusText` (927) field.
58    #[doc(alias = "UserStatusText")]
59    pub fn user_status_text(&self) -> Result<Option<&str>, InvalidValue> {
60        self.0.get_str(Tag(927))
61    }
62}
63
64impl std::fmt::Debug for UserResponse {
65    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
66        write!(f, "UserResponse({})", self.0)
67    }
68}
69
70impl std::fmt::Display for UserResponse {
71    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
72        std::fmt::Display::fmt(&self.0, f)
73    }
74}