#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{InvalidValue, LazyKnownTags, RawMessage, Tag};
use super::super::components::{Header, Trailer};
pub struct Heartbeat(RawMessage);
impl Heartbeat {
pub const MSG_TYPE: &[u8] = b"0";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[Tag(112)],
&[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 = "TestReqID")]
pub fn test_req_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(112))
}
}
impl std::fmt::Debug for Heartbeat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Heartbeat({})", self.0)
}
}
impl std::fmt::Display for Heartbeat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}