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

use super::super::components::{Header, Trailer};
use super::super::enums::{OrdRejReason, OrdStatus};

/// The `ListStatus` (35=N) message.
pub struct ListStatus(RawMessage);

impl ListStatus {
    pub const MSG_TYPE: &[u8] = b"N";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(66), Tag(429), Tag(82), Tag(431), Tag(83), Tag(444), Tag(445), Tag(446),
                Tag(60), Tag(68), Tag(73),
            ],
            &[Header::known_tags(), Trailer::known_tags(), ListStatusOrders::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())
    }

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

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

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

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

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

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

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

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

    /// The `EncodedListStatusText` (446) field.
    #[doc(alias = "EncodedListStatusText")]
    pub fn encoded_list_status_text(&self) -> Option<&[u8]> {
        self.0.get(Tag(446))
    }

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

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

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

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

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

/// An instance of the `NoOrders` (73) group.
#[derive(Clone, Copy)]
pub struct ListStatusOrders<'a>(refix_message::Scope<'a>);

impl<'a> From<refix_message::Scope<'a>> for ListStatusOrders<'a> {
    fn from(scope: refix_message::Scope<'a>) -> Self {
        Self(scope)
    }
}

impl<'a> ListStatusOrders<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(73),
        Tag(11),
        &[
            Tag(6), Tag(11), Tag(14), Tag(39), Tag(58), Tag(84), Tag(103), Tag(151), Tag(354),
            Tag(355),
        ],
        &[],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(11), Tag(14), Tag(39), Tag(151), Tag(84), Tag(6), Tag(103), Tag(58), Tag(354),
                Tag(355),
            ],
            &[],
        );
        &TAGS
    }

    pub fn raw(&self) -> refix_message::Scope<'a> {
        self.0
    }

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

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

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

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

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

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

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

    /// The `Text` (58) field.
    #[doc(alias = "Text")]
    pub fn text(&self) -> Result<Option<&'a 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<&'a [u8]> {
        self.0.get(Tag(355))
    }
}

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