#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Decimal, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag};
use super::super::components::{Header, ListOrdGrp, Trailer};
use super::super::enums::{
BidType, CancellationRights, ListExecInstType, MoneyLaunderingStatus, ProgRptReqs,
};
pub struct NewOrderList(RawMessage);
impl NewOrderList {
pub const MSG_TYPE: &[u8] = b"E";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(66), Tag(390), Tag(391), Tag(414), Tag(394), Tag(415), Tag(480), Tag(481),
Tag(513), Tag(433), Tag(69), Tag(352), Tag(353), Tag(765), Tag(766), Tag(767),
Tag(68), Tag(893), Tag(73),
],
&[Header::known_tags(), Trailer::known_tags(), ListOrdGrp::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 = "ListID")]
pub fn list_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(66))
}
#[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 = "ProgRptReqs")]
pub fn prog_rpt_reqs(&self) -> Result<Option<ProgRptReqs>, InvalidValue> {
Ok(self.0.get_int(Tag(414))?.map(ProgRptReqs::from_value))
}
#[doc(alias = "BidType")]
pub fn bid_type(&self) -> Result<Option<BidType>, InvalidValue> {
Ok(self.0.get_int(Tag(394))?.map(BidType::from_value))
}
#[doc(alias = "ProgPeriodInterval")]
pub fn prog_period_interval(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(415))
}
#[doc(alias = "CancellationRights")]
pub fn cancellation_rights(&self) -> Result<Option<CancellationRights<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(480))?.map(CancellationRights::from_value))
}
#[doc(alias = "MoneyLaunderingStatus")]
pub fn money_laundering_status(&self) -> Result<Option<MoneyLaunderingStatus<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(481))?.map(MoneyLaunderingStatus::from_value))
}
#[doc(alias = "RegistID")]
pub fn regist_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(513))
}
#[doc(alias = "ListExecInstType")]
pub fn list_exec_inst_type(&self) -> Result<Option<ListExecInstType<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(433))?.map(ListExecInstType::from_value))
}
#[doc(alias = "ListExecInst")]
pub fn list_exec_inst(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(69))
}
#[doc(alias = "EncodedListExecInstLen")]
pub fn encoded_list_exec_inst_len(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(352))
}
#[doc(alias = "EncodedListExecInst")]
pub fn encoded_list_exec_inst(&self) -> Option<&[u8]> {
self.0.get(Tag(353))
}
#[doc(alias = "AllowableOneSidednessPct")]
pub fn allowable_one_sidedness_pct(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(765))
}
#[doc(alias = "AllowableOneSidednessValue")]
pub fn allowable_one_sidedness_value(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(766))
}
#[doc(alias = "AllowableOneSidednessCurr")]
pub fn allowable_one_sidedness_curr(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(767))
}
#[doc(alias = "TotNoOrders")]
pub fn tot_no_orders(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(68))
}
#[doc(alias = "LastFragment")]
pub fn last_fragment(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(893))
}
#[doc(alias = "NoOrders")]
pub fn orders(&self) -> Result<Instances<'_, ListOrdGrp<'_>>, InvalidValue> {
self.0.get_group(&ListOrdGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
}
impl std::fmt::Debug for NewOrderList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "NewOrderList({})", self.0)
}
}
impl std::fmt::Display for NewOrderList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}