From 0992071a7f1a36424bcfaf1fbc84541ea041df1a Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 11 Apr 2024 10:19:20 +0200 Subject: add support for tokio & improve net crate api --- core/src/util/encode.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'core/src/util') diff --git a/core/src/util/encode.rs b/core/src/util/encode.rs index 7d1061b..bf63671 100644 --- a/core/src/util/encode.rs +++ b/core/src/util/encode.rs @@ -1,15 +1,14 @@ use bincode::Encode; -use crate::Result; +use crate::{Error, Result}; /// Encode the given type `T` into a `Vec`. -pub fn encode(msg: &T) -> Result> { - let vec = bincode::encode_to_vec(msg, bincode::config::standard())?; +pub fn encode(src: &T) -> Result> { + let vec = bincode::encode_to_vec(src, bincode::config::standard())?; Ok(vec) } /// Encode the given type `T` into the given slice.. -pub fn encode_into_slice(msg: &T, dst: &mut [u8]) -> Result<()> { - bincode::encode_into_slice(msg, dst, bincode::config::standard())?; - Ok(()) +pub fn encode_into_slice(src: &T, dst: &mut [u8]) -> Result { + bincode::encode_into_slice(src, dst, bincode::config::standard()).map_err(Error::from) } -- cgit v1.2.3