From 7c268d863048d0a9182b3f7bf778668de8db4ccf Mon Sep 17 00:00:00 2001 From: Vladyslav Nikonov Date: Tue, 8 Oct 2024 16:50:24 +0300 Subject: [PATCH] fix(now-proto): expose NowProto::decode_from_body (#557) --- crates/now-proto-pdu/src/core/mod.rs | 2 +- crates/now-proto-pdu/src/message.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/now-proto-pdu/src/core/mod.rs b/crates/now-proto-pdu/src/core/mod.rs index 15dc87735..69e18f26a 100644 --- a/crates/now-proto-pdu/src/core/mod.rs +++ b/crates/now-proto-pdu/src/core/mod.rs @@ -6,7 +6,7 @@ mod number; mod status; mod string; -pub(crate) use header::{NowHeader, NowMessageClass}; +pub use header::{NowHeader, NowMessageClass}; pub use buffer::{NowLrgBuf, NowVarBuf}; pub use number::{VarI16, VarI32, VarI64, VarU16, VarU32, VarU64}; diff --git a/crates/now-proto-pdu/src/message.rs b/crates/now-proto-pdu/src/message.rs index c4981322e..8d9130ebd 100644 --- a/crates/now-proto-pdu/src/message.rs +++ b/crates/now-proto-pdu/src/message.rs @@ -42,7 +42,12 @@ impl Encode for NowMessage { impl Decode<'_> for NowMessage { fn decode(src: &mut ReadCursor<'_>) -> DecodeResult { let header = NowHeader::decode(src)?; + Self::decode_from_body(header, src) + } +} +impl NowMessage { + pub fn decode_from_body(header: NowHeader, src: &mut ReadCursor<'_>) -> DecodeResult { match NowMessageClass(header.class.0) { NowMessageClass::SYSTEM => Ok(Self::System(NowSystemMessage::decode_from_body(header, src)?)), NowMessageClass::SESSION => Ok(Self::Session(NowSessionMessage::decode_from_body(header, src)?)),