From 1c951fe39274d72a862433fa45fd6cf0f52295be Mon Sep 17 00:00:00 2001 From: xavo95 Date: Sat, 8 Mar 2025 16:52:31 +0100 Subject: [PATCH] Added possibility to take box as ref for debug logging --- wicked-waifus-protocol/src/message.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wicked-waifus-protocol/src/message.rs b/wicked-waifus-protocol/src/message.rs index 87fd3c6..b297477 100644 --- a/wicked-waifus-protocol/src/message.rs +++ b/wicked-waifus-protocol/src/message.rs @@ -173,6 +173,14 @@ impl Message { | Self::Push { payload, .. } => payload.take().unwrap_or_else(|| Box::new([0u8; 0])), } } + + pub fn get_payload(&mut self) -> Option<&Box<[u8]>> { + match self { + Self::Request { payload, .. } + | Self::Response { payload, .. } + | Self::Push { payload, .. } => payload.as_ref(), + } + } pub fn set_payload(&mut self, new_payload: Box<[u8]>) { match self {