#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Instances, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp};
use super::super::components::{Header, Parties, Trailer};
use super::super::enums::{Product, SecurityType, Side, StandInstDbType};
pub struct SettlementInstructionRequest(RawMessage);
impl SettlementInstructionRequest {
pub const MSG_TYPE: &[u8] = b"AV";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(791), Tag(60), Tag(453), Tag(79), Tag(661), Tag(54), Tag(460), Tag(167),
Tag(461), Tag(168), Tag(126), Tag(779), Tag(169), Tag(170), Tag(171),
],
&[Header::known_tags(), Trailer::known_tags(), Parties::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 = "SettlInstReqID")]
pub fn settl_inst_req_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(791))
}
#[doc(alias = "TransactTime")]
pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(60))
}
#[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 = "AllocAccount")]
pub fn alloc_account(&self) -> Result<Option<&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 = "Side")]
pub fn side(&self) -> Result<Option<Side<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(54))?.map(Side::from_value))
}
#[doc(alias = "Product")]
pub fn product(&self) -> Result<Option<Product>, InvalidValue> {
Ok(self.0.get_int(Tag(460))?.map(Product::from_value))
}
#[doc(alias = "SecurityType")]
pub fn security_type(&self) -> Result<Option<SecurityType<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(167))?.map(SecurityType::from_value))
}
#[doc(alias = "CFICode")]
pub fn cfi_code(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(461))
}
#[doc(alias = "EffectiveTime")]
pub fn effective_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(168))
}
#[doc(alias = "ExpireTime")]
pub fn expire_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(126))
}
#[doc(alias = "LastUpdateTime")]
pub fn last_update_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(779))
}
#[doc(alias = "StandInstDbType")]
pub fn stand_inst_db_type(&self) -> Result<Option<StandInstDbType>, InvalidValue> {
Ok(self.0.get_int(Tag(169))?.map(StandInstDbType::from_value))
}
#[doc(alias = "StandInstDbName")]
pub fn stand_inst_db_name(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(170))
}
#[doc(alias = "StandInstDbID")]
pub fn stand_inst_db_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(171))
}
}
impl std::fmt::Debug for SettlementInstructionRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "SettlementInstructionRequest({})", self.0)
}
}
impl std::fmt::Display for SettlementInstructionRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}