#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Decimal, GroupTable, InvalidValue, LazyKnownTags, Tag};
use super::super::enums::PosAmtType;
#[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
}
#[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))
}
#[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)
}
}