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

use super::super::enums::{PosQtyStatus, PosType};
use super::NestedParties;

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

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

impl<'a> PositionQty<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(702),
        Tag(703),
        &[Tag(539), Tag(703), Tag(704), Tag(705), Tag(706)],
        &[NestedParties::TABLE],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(703), Tag(704), Tag(705), Tag(706), Tag(539)],
            &[NestedParties::known_tags()],
        );
        &TAGS
    }

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

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

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

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

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

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

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