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

use super::super::enums::LegSwapType;
use super::{InstrumentLeg, LegSecAltIDGrp, LegStipulations, NestedParties};

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

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

impl<'a> InstrmtLegExecGrp<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(555),
        Tag(600),
        &[
            Tag(248), Tag(249), Tag(250), Tag(251), Tag(252), Tag(253), Tag(254), Tag(257),
            Tag(539), Tag(556), Tag(564), Tag(565), Tag(566), Tag(587), Tag(588), Tag(596),
            Tag(597), Tag(598), Tag(599), Tag(600), Tag(601), Tag(602), Tag(603), Tag(604),
            Tag(607), Tag(608), Tag(609), Tag(610), Tag(611), Tag(612), Tag(613), Tag(614),
            Tag(615), Tag(616), Tag(617), Tag(618), Tag(619), Tag(620), Tag(621), Tag(622),
            Tag(623), Tag(624), Tag(637), Tag(654), Tag(683), Tag(687), Tag(690), Tag(739),
            Tag(740), Tag(764), Tag(942), Tag(955), Tag(956),
        ],
        &[LegSecAltIDGrp::TABLE, LegStipulations::TABLE, NestedParties::TABLE],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(687), Tag(690), Tag(683), Tag(564), Tag(565), Tag(539), Tag(654), Tag(566),
                Tag(587), Tag(588), Tag(637),
            ],
            &[
                InstrumentLeg::known_tags(), LegStipulations::known_tags(),
                NestedParties::known_tags(),
            ],
        );
        &TAGS
    }

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

    /// The `InstrumentLeg` component.
    pub fn instrument_leg(&self) -> InstrumentLeg<'a> {
        InstrumentLeg(self.0, Self::known_tags().get())
    }

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

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

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

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

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

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

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

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

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

    /// The `LegSettlDate` (588) field.
    #[doc(alias = "LegSettlDate")]
    pub fn leg_settl_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(588))
    }

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

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