Add API for extracting the inner payload of RawNetworkMessage

I'd like to take out the `payload` of RawNetworkMessage and
then send it to the actual network message processor, but
finds there is no way to do it. This commit adds such an API
to expose the owned value of inner `payload`.
This commit is contained in:
Liu-Cheng Xu 2024-06-06 11:19:42 +08:00
parent 2cfe0e204d
commit 61565957ad
1 changed files with 5 additions and 0 deletions

View File

@ -310,6 +310,11 @@ impl RawNetworkMessage {
Self { magic, payload, payload_len, checksum }
}
/// Consumes the [RawNetworkMessage] instance and returns the inner payload.
pub fn into_payload(self) -> NetworkMessage {
self.payload
}
/// The actual message data
pub fn payload(&self) -> &NetworkMessage { &self.payload }