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::{Date, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp};

use super::super::components::{Header, Trailer};
use super::super::enums::{AffirmStatus, ConfirmRejReason, MatchStatus};

/// The `ConfirmationAck` (35=AU) message.
pub struct ConfirmationAck(RawMessage);

impl ConfirmationAck {
    pub const MSG_TYPE: &[u8] = b"AU";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(664), Tag(75), Tag(60), Tag(940), Tag(774), Tag(573), 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 `ConfirmID` (664) field.
    #[doc(alias = "ConfirmID")]
    pub fn confirm_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(664))
    }

    /// The `TradeDate` (75) field.
    #[doc(alias = "TradeDate")]
    pub fn trade_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(75))
    }

    /// The `TransactTime` (60) field.
    #[doc(alias = "TransactTime")]
    pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
        self.0.get_utc_timestamp(Tag(60))
    }

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

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

    /// The `MatchStatus` (573) field.
    #[doc(alias = "MatchStatus")]
    pub fn match_status(&self) -> Result<Option<MatchStatus<'_>>, InvalidValue> {
        Ok(self.0.get_str(Tag(573))?.map(MatchStatus::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 ConfirmationAck {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "ConfirmationAck({})", self.0)
    }
}

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