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

use super::super::enums::PosAmtType;

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

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

impl<'a> PositionAmountData<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(753),
        Tag(707),
        &[Tag(707), Tag(708)],
        &[],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(&[Tag(707), Tag(708)], &[]);
        &TAGS
    }

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

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

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

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