refix-fix44 0.12.0

Typed FIX 4.4 protocol messages for the ReFIX engine
Documentation
// @generated by refix codegen from FIX44.xml. Do not edit.
#![cfg_attr(rustfmt, rustfmt::skip)]

use refix_message::{InvalidValue, LazyKnownTags, RawMessage, Tag};

use super::super::components::{Header, Trailer};
use super::super::enums::UserStatus;

/// The `UserResponse` (35=BF) message.
pub struct UserResponse(RawMessage);

impl UserResponse {
    pub const MSG_TYPE: &[u8] = b"BF";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(923), Tag(553), Tag(926), Tag(927)],
            &[Header::known_tags(), Trailer::known_tags()],
        );
        &TAGS
    }

    pub fn from_raw(raw: RawMessage) -> Self {
        Self(raw)
    }

    pub fn raw(&self) -> &RawMessage {
        &self.0
    }

    pub fn header(&self) -> Header<'_> {
        Header(self.0.scope(), Self::known_tags().get())
    }

    pub fn trailer(&self) -> Trailer<'_> {
        Trailer(self.0.scope())
    }

    /// The `UserRequestID` (923) field.
    #[doc(alias = "UserRequestID")]
    pub fn user_request_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(923))
    }

    /// The `Username` (553) field.
    #[doc(alias = "Username")]
    pub fn username(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(553))
    }

    /// The `UserStatus` (926) field.
    #[doc(alias = "UserStatus")]
    pub fn user_status(&self) -> Result<Option<UserStatus>, InvalidValue> {
        Ok(self.0.get_int(Tag(926))?.map(UserStatus::from_value))
    }

    /// The `UserStatusText` (927) field.
    #[doc(alias = "UserStatusText")]
    pub fn user_status_text(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(927))
    }
}

impl std::fmt::Debug for UserResponse {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "UserResponse({})", self.0)
    }
}

impl std::fmt::Display for UserResponse {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(&self.0, f)
    }
}