#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Instances, InvalidValue, LazyKnownTags, RawMessage, Tag};
use super::super::components::{Header, Parties, RgstDistInstGrp, RgstDtlsGrp, Trailer};
use super::super::enums::{AcctIDSource, OwnershipType, RegistTransType, TaxAdvantageType};
pub struct RegistrationInstructions(RawMessage);
impl RegistrationInstructions {
pub const MSG_TYPE: &[u8] = b"o";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(513), Tag(514), Tag(508), Tag(11), Tag(453), Tag(1), Tag(660), Tag(493),
Tag(495), Tag(517), Tag(473), Tag(510),
],
&[
Header::known_tags(), Trailer::known_tags(), Parties::known_tags(),
RgstDtlsGrp::known_tags(), RgstDistInstGrp::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 = "RegistID")]
pub fn regist_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(513))
}
#[doc(alias = "RegistTransType")]
pub fn regist_trans_type(&self) -> Result<Option<RegistTransType<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(514))?.map(RegistTransType::from_value))
}
#[doc(alias = "RegistRefID")]
pub fn regist_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(508))
}
#[doc(alias = "ClOrdID")]
pub fn cl_ord_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(11))
}
#[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 = "Account")]
pub fn account(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(1))
}
#[doc(alias = "AcctIDSource")]
pub fn acct_id_source(&self) -> Result<Option<AcctIDSource>, InvalidValue> {
Ok(self.0.get_int(Tag(660))?.map(AcctIDSource::from_value))
}
#[doc(alias = "RegistAcctType")]
pub fn regist_acct_type(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(493))
}
#[doc(alias = "TaxAdvantageType")]
pub fn tax_advantage_type(&self) -> Result<Option<TaxAdvantageType>, InvalidValue> {
Ok(self.0.get_int(Tag(495))?.map(TaxAdvantageType::from_value))
}
#[doc(alias = "OwnershipType")]
pub fn ownership_type(&self) -> Result<Option<OwnershipType<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(517))?.map(OwnershipType::from_value))
}
#[doc(alias = "NoRegistDtls")]
pub fn regist_dtls(&self) -> Result<Instances<'_, RgstDtlsGrp<'_>>, InvalidValue> {
self.0.get_group(&RgstDtlsGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "NoDistribInsts")]
pub fn distrib_insts(&self) -> Result<Instances<'_, RgstDistInstGrp<'_>>, InvalidValue> {
self.0.get_group(&RgstDistInstGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
}
impl std::fmt::Debug for RegistrationInstructions {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "RegistrationInstructions({})", self.0)
}
}
impl std::fmt::Display for RegistrationInstructions {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}