#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Decimal, GroupTable, Instances, InvalidValue, LazyKnownTags, Tag};
use super::super::enums::{QuoteRequestType, QuoteType};
use super::{EvntGrp, InstrmtLegGrp, Instrument, SecAltIDGrp, UndInstrmtGrp};
#[derive(Clone, Copy)]
pub struct RFQReqGrp<'a>(refix_message::Scope<'a>);
impl<'a> From<refix_message::Scope<'a>> for RFQReqGrp<'a> {
fn from(scope: refix_message::Scope<'a>) -> Self {
Self(scope)
}
}
impl<'a> RFQReqGrp<'a> {
pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
Tag(146),
Tag(55),
&[
Tag(22), Tag(48), Tag(55), Tag(65), Tag(106), Tag(107), Tag(140), Tag(167), Tag(200),
Tag(201), Tag(202), Tag(206), Tag(207), Tag(223), Tag(224), Tag(225), Tag(226),
Tag(227), Tag(228), Tag(231), Tag(239), Tag(240), Tag(255), Tag(303), Tag(336),
Tag(348), Tag(349), Tag(350), Tag(351), Tag(454), Tag(460), Tag(461), Tag(470),
Tag(471), Tag(472), Tag(537), Tag(541), Tag(543), Tag(555), Tag(625), Tag(667),
Tag(691), Tag(711), Tag(762), Tag(864), Tag(873), Tag(874), Tag(875), Tag(876),
Tag(947),
],
&[SecAltIDGrp::TABLE, EvntGrp::TABLE, UndInstrmtGrp::TABLE, InstrmtLegGrp::TABLE],
);
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[Tag(711), Tag(555), Tag(140), Tag(303), Tag(537), Tag(336), Tag(625)],
&[Instrument::known_tags(), UndInstrmtGrp::known_tags(), InstrmtLegGrp::known_tags()],
);
&TAGS
}
pub fn raw(&self) -> refix_message::Scope<'a> {
self.0
}
pub fn instrument(&self) -> Instrument<'a> {
Instrument(self.0, Self::known_tags().get())
}
#[doc(alias = "NoUnderlyings")]
pub fn underlyings(&self) -> Result<Instances<'a, UndInstrmtGrp<'a>>, InvalidValue> {
self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "NoLegs")]
pub fn legs(&self) -> Result<Instances<'a, InstrmtLegGrp<'a>>, InvalidValue> {
self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "PrevClosePx")]
pub fn prev_close_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(140))
}
#[doc(alias = "QuoteRequestType")]
pub fn quote_request_type(&self) -> Result<Option<QuoteRequestType>, InvalidValue> {
Ok(self.0.get_int(Tag(303))?.map(QuoteRequestType::from_value))
}
#[doc(alias = "QuoteType")]
pub fn quote_type(&self) -> Result<Option<QuoteType>, InvalidValue> {
Ok(self.0.get_int(Tag(537))?.map(QuoteType::from_value))
}
#[doc(alias = "TradingSessionID")]
pub fn trading_session_id(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(336))
}
#[doc(alias = "TradingSessionSubID")]
pub fn trading_session_sub_id(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(625))
}
}
impl std::fmt::Debug for RFQReqGrp<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "RFQReqGrp({})", self.0)
}
}