#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{InvalidValue, LazyKnownTags, RawMessage, Tag};
use super::super::components::{Header, Trailer};
use super::super::enums::SessionRejectReason;
pub struct Reject(RawMessage);
impl Reject {
pub const MSG_TYPE: &[u8] = b"3";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[Tag(45), Tag(371), Tag(372), Tag(373), Tag(58), Tag(354), Tag(355)],
&[Header::known_tags(), Trailer::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 = "RefSeqNum")]
pub fn ref_seq_num(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(45))
}
#[doc(alias = "RefTagID")]
pub fn ref_tag_id(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(371))
}
#[doc(alias = "RefMsgType")]
pub fn ref_msg_type(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(372))
}
#[doc(alias = "SessionRejectReason")]
pub fn session_reject_reason(&self) -> Result<Option<SessionRejectReason>, InvalidValue> {
Ok(self.0.get_int(Tag(373))?.map(SessionRejectReason::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 Reject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Reject({})", self.0)
}
}
impl std::fmt::Display for Reject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}