aboutsummaryrefslogtreecommitdiff
path: root/core/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/util')
-rw-r--r--core/src/util/encode.rs11
1 files changed, 5 insertions, 6 deletions
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<u8>`.
-pub fn encode<T: Encode>(msg: &T) -> Result<Vec<u8>> {
- let vec = bincode::encode_to_vec(msg, bincode::config::standard())?;
+pub fn encode<T: Encode>(src: &T) -> Result<Vec<u8>> {
+ 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<T: Encode>(msg: &T, dst: &mut [u8]) -> Result<()> {
- bincode::encode_into_slice(msg, dst, bincode::config::standard())?;
- Ok(())
+pub fn encode_into_slice<T: Encode>(src: &T, dst: &mut [u8]) -> Result<usize> {
+ bincode::encode_into_slice(src, dst, bincode::config::standard()).map_err(Error::from)
}