#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{
Date, Decimal, GroupTable, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag,
};
use super::super::components::{Header, Trailer};
use super::super::enums::{CommType, NetGrossInd, PriceType, SettlmntTyp, Side};
pub struct BidResponse(RawMessage);
impl BidResponse {
pub const MSG_TYPE: &[u8] = b"l";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[Tag(390), Tag(391), Tag(420)],
&[Header::known_tags(), Trailer::known_tags(), BidResponseBidComponents::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())
}
pub fn trailer(&self) -> Trailer<'_> {
Trailer(self.0.scope())
}
#[doc(alias = "BidID")]
pub fn bid_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(390))
}
#[doc(alias = "ClientBidID")]
pub fn client_bid_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(391))
}
#[doc(alias = "NoBidComponents")]
pub fn bid_components(&self) -> Result<Instances<'_, BidResponseBidComponents<'_>>, InvalidValue> {
self.0.get_group(&BidResponseBidComponents::TABLE, &Self::known_tags().get()).map(Instances::from)
}
}
impl std::fmt::Debug for BidResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "BidResponse({})", self.0)
}
}
impl std::fmt::Display for BidResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
#[derive(Clone, Copy)]
pub struct BidResponseBidComponents<'a>(refix_message::Scope<'a>);
impl<'a> From<refix_message::Scope<'a>> for BidResponseBidComponents<'a> {
fn from(scope: refix_message::Scope<'a>) -> Self {
Self(scope)
}
}
impl<'a> BidResponseBidComponents<'a> {
pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
Tag(420),
Tag(12),
&[
Tag(12), Tag(13), Tag(44), Tag(54), Tag(58), Tag(63), Tag(64), Tag(66), Tag(336),
Tag(354), Tag(355), Tag(406), Tag(421), Tag(423), Tag(430),
],
&[],
);
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(12), Tag(13), Tag(66), Tag(421), Tag(54), Tag(44), Tag(423), Tag(406), Tag(430),
Tag(63), Tag(64), Tag(336), Tag(58), Tag(354), Tag(355),
],
&[],
);
&TAGS
}
pub fn raw(&self) -> refix_message::Scope<'a> {
self.0
}
#[doc(alias = "Commission")]
pub fn commission(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(12))
}
#[doc(alias = "CommType")]
pub fn comm_type(&self) -> Result<Option<CommType<'a>>, InvalidValue> {
Ok(self.0.get_str(Tag(13))?.map(CommType::from_value))
}
#[doc(alias = "ListID")]
pub fn list_id(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(66))
}
#[doc(alias = "Country")]
pub fn country(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(421))
}
#[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 = "PriceType")]
pub fn price_type(&self) -> Result<Option<PriceType>, InvalidValue> {
Ok(self.0.get_int(Tag(423))?.map(PriceType::from_value))
}
#[doc(alias = "FairValue")]
pub fn fair_value(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(406))
}
#[doc(alias = "NetGrossInd")]
pub fn net_gross_ind(&self) -> Result<Option<NetGrossInd>, InvalidValue> {
Ok(self.0.get_int(Tag(430))?.map(NetGrossInd::from_value))
}
#[doc(alias = "SettlmntTyp")]
pub fn settlmnt_typ(&self) -> Result<Option<SettlmntTyp<'a>>, InvalidValue> {
Ok(self.0.get_str(Tag(63))?.map(SettlmntTyp::from_value))
}
#[doc(alias = "FutSettDate")]
pub fn fut_sett_date(&self) -> Result<Option<Date>, InvalidValue> {
self.0.get_date(Tag(64))
}
#[doc(alias = "TradingSessionID")]
pub fn trading_session_id(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(336))
}
#[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 BidResponseBidComponents<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "BidResponseBidComponents({})", self.0)
}
}