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::BusinessRejectReason;

/// The `BusinessMessageReject` (35=j) message.
pub struct BusinessMessageReject(RawMessage);

impl BusinessMessageReject {
    pub const MSG_TYPE: &[u8] = b"j";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(45), Tag(372), Tag(379), Tag(380), Tag(58), Tag(354), Tag(355)],
            &[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 `RefSeqNum` (45) field.
    #[doc(alias = "RefSeqNum")]
    pub fn ref_seq_num(&self) -> Result<Option<i64>, InvalidValue> {
        self.0.get_int(Tag(45))
    }

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

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

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

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

    /// The `EncodedTextLen` (354) field.
    #[doc(alias = "EncodedTextLen")]
    pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
        self.0.get_int(Tag(354))
    }

    /// The `EncodedText` (355) field.
    #[doc(alias = "EncodedText")]
    pub fn encoded_text(&self) -> Option<&[u8]> {
        self.0.get(Tag(355))
    }
}

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

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