#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Date, InvalidValue, RawMessage, Tag, UtcTimestamp};
use super::super::components::{Header, Trailer};
use super::super::enums::{AllocRejCode, AllocStatus};
pub struct AllocationInstructionAck(RawMessage);
impl AllocationInstructionAck {
pub const MSG_TYPE: &[u8] = b"P";
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 = "ClientID")]
pub fn client_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(109))
}
#[doc(alias = "ExecBroker")]
pub fn exec_broker(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(76))
}
#[doc(alias = "AllocID")]
pub fn alloc_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(70))
}
#[doc(alias = "TradeDate")]
pub fn trade_date(&self) -> Result<Option<Date>, InvalidValue> {
self.0.get_date(Tag(75))
}
#[doc(alias = "TransactTime")]
pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(60))
}
#[doc(alias = "AllocStatus")]
pub fn alloc_status(&self) -> Result<Option<AllocStatus>, InvalidValue> {
Ok(self.0.get_int(Tag(87))?.map(AllocStatus::from_value))
}
#[doc(alias = "AllocRejCode")]
pub fn alloc_rej_code(&self) -> Result<Option<AllocRejCode>, InvalidValue> {
Ok(self.0.get_int(Tag(88))?.map(AllocRejCode::from_value))
}
#[doc(alias = "Text")]
pub fn text(&self) -> Result<Option<&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<&[u8]> {
self.0.get(Tag(355))
}
}
impl std::fmt::Debug for AllocationInstructionAck {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "AllocationInstructionAck({})", self.0)
}
}
impl std::fmt::Display for AllocationInstructionAck {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}