#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Decimal, GroupTable, InvalidValue, LazyKnownTags, Tag};
use super::super::enums::Side;
use super::{UndSecAltIDGrp, UnderlyingInstrument, UnderlyingStipulations};
#[derive(Clone, Copy)]
pub struct UndInstrmtStrkPxGrp<'a>(refix_message::Scope<'a>);
impl<'a> From<refix_message::Scope<'a>> for UndInstrmtStrkPxGrp<'a> {
fn from(scope: refix_message::Scope<'a>) -> Self {
Self(scope)
}
}
impl<'a> UndInstrmtStrkPxGrp<'a> {
pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
Tag(711),
Tag(311),
&[
Tag(11), Tag(15), Tag(44), Tag(54), Tag(58), Tag(140), Tag(241), Tag(242), Tag(243),
Tag(244), Tag(245), Tag(246), Tag(247), Tag(256), Tag(305), Tag(306), Tag(307),
Tag(308), Tag(309), Tag(310), Tag(311), Tag(312), Tag(313), Tag(315), Tag(316),
Tag(317), Tag(318), Tag(354), Tag(355), Tag(362), Tag(363), Tag(364), Tag(365),
Tag(435), Tag(436), Tag(457), Tag(462), Tag(463), Tag(526), Tag(542), Tag(592),
Tag(593), Tag(594), Tag(595), Tag(763), Tag(810), Tag(877), Tag(878), Tag(879),
Tag(882), Tag(883), Tag(884), Tag(885), Tag(886), Tag(887), Tag(941),
],
&[UndSecAltIDGrp::TABLE, UnderlyingStipulations::TABLE],
);
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[Tag(140), Tag(11), Tag(526), Tag(54), Tag(44), Tag(15), Tag(58), Tag(354), Tag(355)],
&[UnderlyingInstrument::known_tags()],
);
&TAGS
}
pub fn raw(&self) -> refix_message::Scope<'a> {
self.0
}
pub fn underlying_instrument(&self) -> UnderlyingInstrument<'a> {
UnderlyingInstrument(self.0, Self::known_tags().get())
}
#[doc(alias = "PrevClosePx")]
pub fn prev_close_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(140))
}
#[doc(alias = "ClOrdID")]
pub fn cl_ord_id(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(11))
}
#[doc(alias = "SecondaryClOrdID")]
pub fn secondary_cl_ord_id(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(526))
}
#[doc(alias = "Side")]
pub fn side(&self) -> Result<Option<Side<'a>>, InvalidValue> {
Ok(self.0.get_str(Tag(54))?.map(Side::from_value))
}
#[doc(alias = "Price")]
pub fn price(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(44))
}
#[doc(alias = "Currency")]
pub fn currency(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(15))
}
#[doc(alias = "Text")]
pub fn text(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(58))
}
#[doc(alias = "EncodedTextLen")]
pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(354))
}
#[doc(alias = "EncodedText")]
pub fn encoded_text(&self) -> Option<&'a [u8]> {
self.0.get(Tag(355))
}
}
impl std::fmt::Debug for UndInstrmtStrkPxGrp<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "UndInstrmtStrkPxGrp({})", self.0)
}
}