karyon_core/util/decode.rs
1use bincode::Decode;
2
3use crate::Result;
4
5/// Decodes a given type `T` from the given slice. returns the decoded value
6/// along with the number of bytes read.
7pub fn decode<T: Decode<()>>(src: &[u8]) -> Result<(T, usize)> {
8 let (result, bytes_read) = bincode::decode_from_slice(src, bincode::config::standard())?;
9 Ok((result, bytes_read))
10}