#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{
Decimal, GroupTable, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp,
};
use super::super::components::{Header, Trailer};
use super::super::enums::{OrdRejReason, OrdStatus};
pub struct ListStatus(RawMessage);
impl ListStatus {
pub const MSG_TYPE: &[u8] = b"N";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(66), Tag(429), Tag(82), Tag(431), Tag(83), Tag(444), Tag(445), Tag(446),
Tag(60), Tag(68), Tag(73),
],
&[Header::known_tags(), Trailer::known_tags(), ListStatusOrders::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 = "ListID")]
pub fn list_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(66))
}
#[doc(alias = "ListStatusType")]
pub fn list_status_type(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(429))
}
#[doc(alias = "NoRpts")]
pub fn no_rpts(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(82))
}
#[doc(alias = "ListOrderStatus")]
pub fn list_order_status(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(431))
}
#[doc(alias = "RptSeq")]
pub fn rpt_seq(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(83))
}
#[doc(alias = "ListStatusText")]
pub fn list_status_text(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(444))
}
#[doc(alias = "EncodedListStatusTextLen")]
pub fn encoded_list_status_text_len(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(445))
}
#[doc(alias = "EncodedListStatusText")]
pub fn encoded_list_status_text(&self) -> Option<&[u8]> {
self.0.get(Tag(446))
}
#[doc(alias = "TransactTime")]
pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(60))
}
#[doc(alias = "TotNoOrders")]
pub fn tot_no_orders(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(68))
}
#[doc(alias = "NoOrders")]
pub fn orders(&self) -> Result<Instances<'_, ListStatusOrders<'_>>, InvalidValue> {
self.0.get_group(&ListStatusOrders::TABLE, &Self::known_tags().get()).map(Instances::from)
}
}
impl std::fmt::Debug for ListStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "ListStatus({})", self.0)
}
}
impl std::fmt::Display for ListStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
#[derive(Clone, Copy)]
pub struct ListStatusOrders<'a>(refix_message::Scope<'a>);
impl<'a> From<refix_message::Scope<'a>> for ListStatusOrders<'a> {
fn from(scope: refix_message::Scope<'a>) -> Self {
Self(scope)
}
}
impl<'a> ListStatusOrders<'a> {
pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
Tag(73),
Tag(11),
&[
Tag(6), Tag(11), Tag(14), Tag(39), Tag(58), Tag(84), Tag(103), Tag(151), Tag(354),
Tag(355),
],
&[],
);
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(11), Tag(14), Tag(39), Tag(151), Tag(84), Tag(6), Tag(103), Tag(58), Tag(354),
Tag(355),
],
&[],
);
&TAGS
}
pub fn raw(&self) -> refix_message::Scope<'a> {
self.0
}
#[doc(alias = "ClOrdID")]
pub fn cl_ord_id(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(11))
}
#[doc(alias = "CumQty")]
pub fn cum_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(14))
}
#[doc(alias = "OrdStatus")]
pub fn ord_status(&self) -> Result<Option<OrdStatus<'a>>, InvalidValue> {
Ok(self.0.get_str(Tag(39))?.map(OrdStatus::from_value))
}
#[doc(alias = "LeavesQty")]
pub fn leaves_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(151))
}
#[doc(alias = "CxlQty")]
pub fn cxl_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(84))
}
#[doc(alias = "AvgPx")]
pub fn avg_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(6))
}
#[doc(alias = "OrdRejReason")]
pub fn ord_rej_reason(&self) -> Result<Option<OrdRejReason>, InvalidValue> {
Ok(self.0.get_int(Tag(103))?.map(OrdRejReason::from_value))
}
#[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 ListStatusOrders<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "ListStatusOrders({})", self.0)
}
}