#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Decimal, Instances, InvalidValue, KnownTags, LazyKnownTags, Tag};
use super::super::enums::DeliveryForm;
use super::AttrbGrp;
#[derive(Clone, Copy)]
pub struct InstrumentExtension<'a>(
pub(in super::super) refix_message::Scope<'a>,
pub(in super::super) KnownTags<'static>,
);
impl<'a> InstrumentExtension<'a> {
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[Tag(668), Tag(869), Tag(870)],
&[AttrbGrp::known_tags()],
);
&TAGS
}
pub fn raw(&self) -> refix_message::Scope<'a> {
self.0
}
#[doc(alias = "DeliveryForm")]
pub fn delivery_form(&self) -> Result<Option<DeliveryForm>, InvalidValue> {
Ok(self.0.get_int(Tag(668))?.map(DeliveryForm::from_value))
}
#[doc(alias = "PctAtRisk")]
pub fn pct_at_risk(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(869))
}
#[doc(alias = "NoInstrAttrib")]
pub fn instr_attrib(&self) -> Result<Instances<'a, AttrbGrp<'a>>, InvalidValue> {
self.0.get_group(&AttrbGrp::TABLE, &self.1).map(Instances::from)
}
}
impl std::fmt::Debug for InstrumentExtension<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "InstrumentExtension({})", self.0.display_known(&Self::known_tags().get()))
}
}