Skip to content

Commit

Permalink
fix(now-proto): expose NowProto::decode_from_body (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
pacmancoder authored Oct 8, 2024
1 parent ef1be93 commit 7c268d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/now-proto-pdu/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
5 changes: 5 additions & 0 deletions crates/now-proto-pdu/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ impl Encode for NowMessage {
impl Decode<'_> for NowMessage {
fn decode(src: &mut ReadCursor<'_>) -> DecodeResult<Self> {
let header = NowHeader::decode(src)?;
Self::decode_from_body(header, src)
}
}

impl NowMessage {
pub fn decode_from_body(header: NowHeader, src: &mut ReadCursor<'_>) -> DecodeResult<Self> {
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)?)),
Expand Down

0 comments on commit 7c268d8

Please sign in to comment.