#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Instances, InvalidValue, LazyKnownTags, RawMessage, Tag};
use super::super::components::{Header, SecListGrp, Trailer};
use super::super::enums::SecurityRequestResult;
pub struct SecurityList(RawMessage);
impl SecurityList {
pub const MSG_TYPE: &[u8] = b"y";
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(), SecListGrp::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))
}
#[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<'_, SecListGrp<'_>>, InvalidValue> {
self.0.get_group(&SecListGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
}
impl std::fmt::Debug for SecurityList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "SecurityList({})", self.0)
}
}
impl std::fmt::Display for SecurityList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}