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, OrdAllocGrp, Trailer};
use super::super::enums::{AllocAccountType, ConfirmType};

/// The `ConfirmationRequest` (35=BH) message.
pub struct ConfirmationRequest(RawMessage);

impl ConfirmationRequest {
    pub const MSG_TYPE: &[u8] = b"BH";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(859), Tag(773), Tag(73), Tag(70), Tag(793), Tag(467), Tag(60), Tag(79),
                Tag(661), Tag(798), Tag(58), Tag(354), Tag(355),
            ],
            &[Header::known_tags(), Trailer::known_tags(), OrdAllocGrp::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 `ConfirmReqID` (859) field.
    #[doc(alias = "ConfirmReqID")]
    pub fn confirm_req_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(859))
    }

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

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

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

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

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

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

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

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

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

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