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

use super::super::components::{
    Header, InstrmtLegGrp, Instrument, OrderQtyData, Trailer, UndInstrmtGrp,
};
use super::super::enums::{DKReason, Side};

/// The `DontKnowTrade` (35=Q) message.
pub struct DontKnowTrade(RawMessage);

impl DontKnowTrade {
    pub const MSG_TYPE: &[u8] = b"Q";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(37), Tag(198), Tag(17), Tag(127), Tag(711), Tag(555), Tag(54), Tag(32), Tag(31),
                Tag(58), Tag(354), Tag(355),
            ],
            &[
                Header::known_tags(), Trailer::known_tags(), Instrument::known_tags(),
                UndInstrmtGrp::known_tags(), InstrmtLegGrp::known_tags(),
                OrderQtyData::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 `OrderID` (37) field.
    #[doc(alias = "OrderID")]
    pub fn order_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(37))
    }

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

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

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

    /// The `Instrument` component.
    pub fn instrument(&self) -> Instrument<'_> {
        Instrument(self.0.scope(), Self::known_tags().get())
    }

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

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

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

    /// The `OrderQtyData` component.
    pub fn order_qty_data(&self) -> OrderQtyData<'_> {
        OrderQtyData(self.0.scope())
    }

    /// The `LastQty` (32) field.
    #[doc(alias = "LastQty")]
    pub fn last_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(32))
    }

    /// The `LastPx` (31) field.
    #[doc(alias = "LastPx")]
    pub fn last_px(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(31))
    }

    /// 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 DontKnowTrade {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "DontKnowTrade({})", self.0)
    }
}

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