refix-fix42 0.4.0

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

use refix_message::{Date, InvalidValue, RawMessage, Tag, UtcTimestamp};

use super::super::components::{Header, Trailer};
use super::super::enums::{AllocRejCode, AllocStatus};

/// The `AllocationInstructionAck` (35=P) message.
pub struct AllocationInstructionAck(RawMessage);

impl AllocationInstructionAck {
    pub const MSG_TYPE: &[u8] = b"P";

    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())
    }

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

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

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

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

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

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

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