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

use super::super::components::{Header, SettlInstGrp, Trailer};
use super::super::enums::{SettlInstMode, SettlInstReqRejCode};

/// The `SettlementInstructions` (35=T) message.
pub struct SettlementInstructions(RawMessage);

impl SettlementInstructions {
    pub const MSG_TYPE: &[u8] = b"T";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(777), Tag(791), Tag(160), Tag(792), Tag(58), Tag(354), Tag(355), Tag(11),
                Tag(60), Tag(778),
            ],
            &[Header::known_tags(), Trailer::known_tags(), SettlInstGrp::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 `SettlInstMsgID` (777) field.
    #[doc(alias = "SettlInstMsgID")]
    pub fn settl_inst_msg_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(777))
    }

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

    /// The `SettlInstMode` (160) field.
    #[doc(alias = "SettlInstMode")]
    pub fn settl_inst_mode(&self) -> Result<Option<SettlInstMode<'_>>, InvalidValue> {
        Ok(self.0.get_str(Tag(160))?.map(SettlInstMode::from_value))
    }

    /// The `SettlInstReqRejCode` (792) field.
    #[doc(alias = "SettlInstReqRejCode")]
    pub fn settl_inst_req_rej_code(&self) -> Result<Option<SettlInstReqRejCode>, InvalidValue> {
        Ok(self.0.get_int(Tag(792))?.map(SettlInstReqRejCode::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))
    }

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

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

    /// The instances of the `NoSettlInst` (778) group.
    #[doc(alias = "NoSettlInst")]
    pub fn settl_inst(&self) -> Result<Instances<'_, SettlInstGrp<'_>>, InvalidValue> {
        self.0.get_group(&SettlInstGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
    }
}

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

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