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, InstrmtLegGrp, Instrument, SideCrossOrdCxlGrp, Trailer, UndInstrmtGrp,
};
use super::super::enums::{CrossPrioritization, CrossType};

/// The `CrossOrderCancelRequest` (35=u) message.
pub struct CrossOrderCancelRequest(RawMessage);

impl CrossOrderCancelRequest {
    pub const MSG_TYPE: &[u8] = b"u";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(37), Tag(548), Tag(551), Tag(549), Tag(550), Tag(552), Tag(711), Tag(555),
                Tag(60),
            ],
            &[
                Header::known_tags(), Trailer::known_tags(), SideCrossOrdCxlGrp::known_tags(),
                Instrument::known_tags(), UndInstrmtGrp::known_tags(), InstrmtLegGrp::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 `CrossID` (548) field.
    #[doc(alias = "CrossID")]
    pub fn cross_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(548))
    }

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

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

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

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

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

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

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