#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Instances, InvalidValue, LazyKnownTags, MultipleValues, RawMessage, Tag};
use super::super::components::{Header, InstrmtMDReqGrp, MDReqGrp, Trailer, TrdgSesGrp};
use super::super::enums::{
ApplQueueAction, MDUpdateType, OpenCloseSettlFlag, Scope, SubscriptionRequestType,
};
pub struct MarketDataRequest(RawMessage);
impl MarketDataRequest {
pub const MSG_TYPE: &[u8] = b"V";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(262), Tag(263), Tag(264), Tag(265), Tag(266), Tag(286), Tag(546), Tag(547),
Tag(267), Tag(146), Tag(386), Tag(815), Tag(812),
],
&[
Header::known_tags(), Trailer::known_tags(), MDReqGrp::known_tags(),
InstrmtMDReqGrp::known_tags(), TrdgSesGrp::known_tags(),
],
);
&TAGS
}
pub fn from_raw(raw: RawMessage) -> Self {
Self(raw)
}
pub fn raw(&self) -> &RawMessage {
&self.0
}
pub fn header(&self) -> Header<'_> {
Header(self.0.scope(), Self::known_tags().get())
}
pub fn trailer(&self) -> Trailer<'_> {
Trailer(self.0.scope())
}
#[doc(alias = "MDReqID")]
pub fn md_req_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(262))
}
#[doc(alias = "SubscriptionRequestType")]
pub fn subscription_request_type(&self) -> Result<Option<SubscriptionRequestType<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(263))?.map(SubscriptionRequestType::from_value))
}
#[doc(alias = "MarketDepth")]
pub fn market_depth(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(264))
}
#[doc(alias = "MDUpdateType")]
pub fn md_update_type(&self) -> Result<Option<MDUpdateType>, InvalidValue> {
Ok(self.0.get_int(Tag(265))?.map(MDUpdateType::from_value))
}
#[doc(alias = "AggregatedBook")]
pub fn aggregated_book(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(266))
}
#[doc(alias = "OpenCloseSettlFlag")]
pub fn open_close_settl_flag(&self) -> Result<Option<MultipleValues<'_, OpenCloseSettlFlag<'_>>>, InvalidValue> {
self.0.get_multiple_values(Tag(286))
}
#[doc(alias = "Scope")]
pub fn scope(&self) -> Result<Option<MultipleValues<'_, Scope<'_>>>, InvalidValue> {
self.0.get_multiple_values(Tag(546))
}
#[doc(alias = "MDImplicitDelete")]
pub fn md_implicit_delete(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(547))
}
#[doc(alias = "NoMDEntryTypes")]
pub fn md_entry_types(&self) -> Result<Instances<'_, MDReqGrp<'_>>, InvalidValue> {
self.0.get_group(&MDReqGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "NoRelatedSym")]
pub fn related_sym(&self) -> Result<Instances<'_, InstrmtMDReqGrp<'_>>, InvalidValue> {
self.0.get_group(&InstrmtMDReqGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "NoTradingSessions")]
pub fn trading_sessions(&self) -> Result<Instances<'_, TrdgSesGrp<'_>>, InvalidValue> {
self.0.get_group(&TrdgSesGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "ApplQueueAction")]
pub fn appl_queue_action(&self) -> Result<Option<ApplQueueAction>, InvalidValue> {
Ok(self.0.get_int(Tag(815))?.map(ApplQueueAction::from_value))
}
#[doc(alias = "ApplQueueMax")]
pub fn appl_queue_max(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(812))
}
}
impl std::fmt::Debug for MarketDataRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "MarketDataRequest({})", self.0)
}
}
impl std::fmt::Display for MarketDataRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}