#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Decimal, GroupTable, Instances, InvalidValue, LazyKnownTags, Tag};
use super::super::enums::{
AllocHandlInst, AllocSettlInstType, MatchStatus, ProcessCode, SettlCurrFxRateCalc,
};
use super::{
ClrInstGrp, CommissionData, DlvyInstGrp, MiscFeesGrp, NestedParties, SettlInstructionsData,
};
#[derive(Clone, Copy)]
pub struct AllocGrp<'a>(refix_message::Scope<'a>);
impl<'a> From<refix_message::Scope<'a>> for AllocGrp<'a> {
fn from(scope: refix_message::Scope<'a>) -> Self {
Self(scope)
}
}
impl<'a> AllocGrp<'a> {
pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
Tag(78),
Tag(79),
&[
Tag(12), Tag(13), Tag(79), Tag(80), Tag(81), Tag(85), Tag(119), Tag(120), Tag(136),
Tag(153), Tag(154), Tag(155), Tag(156), Tag(161), Tag(169), Tag(170), Tag(171),
Tag(172), Tag(208), Tag(209), Tag(360), Tag(361), Tag(366), Tag(467), Tag(479),
Tag(497), Tag(539), Tag(573), Tag(576), Tag(661), Tag(736), Tag(737), Tag(741),
Tag(742), Tag(780),
],
&[NestedParties::TABLE, MiscFeesGrp::TABLE, ClrInstGrp::TABLE, DlvyInstGrp::TABLE],
);
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(79), Tag(661), Tag(573), Tag(366), Tag(80), Tag(467), Tag(81), Tag(539),
Tag(208), Tag(209), Tag(161), Tag(360), Tag(361), Tag(153), Tag(154), Tag(119),
Tag(737), Tag(120), Tag(736), Tag(155), Tag(156), Tag(742), Tag(741), Tag(136),
Tag(576), Tag(780),
],
&[
NestedParties::known_tags(), CommissionData::known_tags(),
MiscFeesGrp::known_tags(), ClrInstGrp::known_tags(),
SettlInstructionsData::known_tags(),
],
);
&TAGS
}
pub fn raw(&self) -> refix_message::Scope<'a> {
self.0
}
#[doc(alias = "AllocAccount")]
pub fn alloc_account(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(79))
}
#[doc(alias = "AllocAcctIDSource")]
pub fn alloc_acct_id_source(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(661))
}
#[doc(alias = "MatchStatus")]
pub fn match_status(&self) -> Result<Option<MatchStatus<'a>>, InvalidValue> {
Ok(self.0.get_str(Tag(573))?.map(MatchStatus::from_value))
}
#[doc(alias = "AllocPrice")]
pub fn alloc_price(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(366))
}
#[doc(alias = "AllocQty")]
pub fn alloc_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(80))
}
#[doc(alias = "IndividualAllocID")]
pub fn individual_alloc_id(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(467))
}
#[doc(alias = "ProcessCode")]
pub fn process_code(&self) -> Result<Option<ProcessCode<'a>>, InvalidValue> {
Ok(self.0.get_str(Tag(81))?.map(ProcessCode::from_value))
}
#[doc(alias = "NoNestedPartyIDs")]
pub fn nested_party_ids(&self) -> Result<Instances<'a, NestedParties<'a>>, InvalidValue> {
self.0.get_group(&NestedParties::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "NotifyBrokerOfCredit")]
pub fn notify_broker_of_credit(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(208))
}
#[doc(alias = "AllocHandlInst")]
pub fn alloc_handl_inst(&self) -> Result<Option<AllocHandlInst>, InvalidValue> {
Ok(self.0.get_int(Tag(209))?.map(AllocHandlInst::from_value))
}
#[doc(alias = "AllocText")]
pub fn alloc_text(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(161))
}
#[doc(alias = "EncodedAllocTextLen")]
pub fn encoded_alloc_text_len(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(360))
}
#[doc(alias = "EncodedAllocText")]
pub fn encoded_alloc_text(&self) -> Option<&'a [u8]> {
self.0.get(Tag(361))
}
pub fn commission_data(&self) -> CommissionData<'a> {
CommissionData(self.0)
}
#[doc(alias = "AllocAvgPx")]
pub fn alloc_avg_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(153))
}
#[doc(alias = "AllocNetMoney")]
pub fn alloc_net_money(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(154))
}
#[doc(alias = "SettlCurrAmt")]
pub fn settl_curr_amt(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(119))
}
#[doc(alias = "AllocSettlCurrAmt")]
pub fn alloc_settl_curr_amt(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(737))
}
#[doc(alias = "SettlCurrency")]
pub fn settl_currency(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(120))
}
#[doc(alias = "AllocSettlCurrency")]
pub fn alloc_settl_currency(&self) -> Result<Option<&'a str>, InvalidValue> {
self.0.get_str(Tag(736))
}
#[doc(alias = "SettlCurrFxRate")]
pub fn settl_curr_fx_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(155))
}
#[doc(alias = "SettlCurrFxRateCalc")]
pub fn settl_curr_fx_rate_calc(&self) -> Result<Option<SettlCurrFxRateCalc<'a>>, InvalidValue> {
Ok(self.0.get_str(Tag(156))?.map(SettlCurrFxRateCalc::from_value))
}
#[doc(alias = "AllocAccruedInterestAmt")]
pub fn alloc_accrued_interest_amt(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(742))
}
#[doc(alias = "AllocInterestAtMaturity")]
pub fn alloc_interest_at_maturity(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(741))
}
#[doc(alias = "NoMiscFees")]
pub fn misc_fees(&self) -> Result<Instances<'a, MiscFeesGrp<'a>>, InvalidValue> {
self.0.get_group(&MiscFeesGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "NoClearingInstructions")]
pub fn clearing_instructions(&self) -> Result<Instances<'a, ClrInstGrp<'a>>, InvalidValue> {
self.0.get_group(&ClrInstGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "AllocSettlInstType")]
pub fn alloc_settl_inst_type(&self) -> Result<Option<AllocSettlInstType>, InvalidValue> {
Ok(self.0.get_int(Tag(780))?.map(AllocSettlInstType::from_value))
}
pub fn settl_instructions_data(&self) -> SettlInstructionsData<'a> {
SettlInstructionsData(self.0, Self::known_tags().get())
}
}
impl std::fmt::Debug for AllocGrp<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "AllocGrp({})", self.0)
}
}