#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Decimal, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag};
use super::super::components::{Header, Parties, QuotSetGrp, Trailer};
use super::super::enums::{AccountType, AcctIDSource, QuoteResponseLevel, QuoteType};
pub struct MassQuote(RawMessage);
impl MassQuote {
pub const MSG_TYPE: &[u8] = b"i";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(131), Tag(117), Tag(537), Tag(301), Tag(453), Tag(1), Tag(660), Tag(581),
Tag(293), Tag(294), Tag(296),
],
&[
Header::known_tags(), Trailer::known_tags(), Parties::known_tags(),
QuotSetGrp::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 = "QuoteReqID")]
pub fn quote_req_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(131))
}
#[doc(alias = "QuoteID")]
pub fn quote_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(117))
}
#[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 = "QuoteResponseLevel")]
pub fn quote_response_level(&self) -> Result<Option<QuoteResponseLevel>, InvalidValue> {
Ok(self.0.get_int(Tag(301))?.map(QuoteResponseLevel::from_value))
}
#[doc(alias = "NoPartyIDs")]
pub fn party_ids(&self) -> Result<Instances<'_, Parties<'_>>, InvalidValue> {
self.0.get_group(&Parties::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "Account")]
pub fn account(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(1))
}
#[doc(alias = "AcctIDSource")]
pub fn acct_id_source(&self) -> Result<Option<AcctIDSource>, InvalidValue> {
Ok(self.0.get_int(Tag(660))?.map(AcctIDSource::from_value))
}
#[doc(alias = "AccountType")]
pub fn account_type(&self) -> Result<Option<AccountType>, InvalidValue> {
Ok(self.0.get_int(Tag(581))?.map(AccountType::from_value))
}
#[doc(alias = "DefBidSize")]
pub fn def_bid_size(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(293))
}
#[doc(alias = "DefOfferSize")]
pub fn def_offer_size(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(294))
}
#[doc(alias = "NoQuoteSets")]
pub fn quote_sets(&self) -> Result<Instances<'_, QuotSetGrp<'_>>, InvalidValue> {
self.0.get_group(&QuotSetGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
}
impl std::fmt::Debug for MassQuote {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "MassQuote({})", self.0)
}
}
impl std::fmt::Display for MassQuote {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}