#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Instances, InvalidValue, LazyKnownTags, RawMessage, Tag};
use super::super::components::{Header, RelSymDerivSecGrp, Trailer, UnderlyingInstrument};
use super::super::enums::SecurityRequestResult;
pub struct DerivativeSecurityList(RawMessage);
impl DerivativeSecurityList {
pub const MSG_TYPE: &[u8] = b"AA";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[Tag(320), Tag(322), Tag(560), Tag(393), Tag(893), Tag(146)],
&[
Header::known_tags(), Trailer::known_tags(), UnderlyingInstrument::known_tags(),
RelSymDerivSecGrp::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 = "SecurityReqID")]
pub fn security_req_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(320))
}
#[doc(alias = "SecurityResponseID")]
pub fn security_response_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(322))
}
#[doc(alias = "SecurityRequestResult")]
pub fn security_request_result(&self) -> Result<Option<SecurityRequestResult>, InvalidValue> {
Ok(self.0.get_int(Tag(560))?.map(SecurityRequestResult::from_value))
}
pub fn underlying_instrument(&self) -> UnderlyingInstrument<'_> {
UnderlyingInstrument(self.0.scope(), Self::known_tags().get())
}
#[doc(alias = "TotNoRelatedSym")]
pub fn tot_no_related_sym(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(393))
}
#[doc(alias = "LastFragment")]
pub fn last_fragment(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(893))
}
#[doc(alias = "NoRelatedSym")]
pub fn related_sym(&self) -> Result<Instances<'_, RelSymDerivSecGrp<'_>>, InvalidValue> {
self.0.get_group(&RelSymDerivSecGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
}
impl std::fmt::Debug for DerivativeSecurityList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "DerivativeSecurityList({})", self.0)
}
}
impl std::fmt::Display for DerivativeSecurityList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}