hermit_toolkit_serialization/
bincode2.rs1use std::any::type_name;
2
3use serde::{de::DeserializeOwned, Serialize};
4
5use cosmwasm_std::{StdError, StdResult};
6
7use crate::Serde;
8
9#[derive(Copy, Clone, Debug)]
11pub struct Bincode2;
12
13impl Serde for Bincode2 {
14 fn serialize<T: Serialize>(obj: &T) -> StdResult<Vec<u8>> {
15 bincode2::serialize(obj).map_err(|err| StdError::serialize_err(type_name::<T>(), err))
16 }
17
18 fn deserialize<T: DeserializeOwned>(data: &[u8]) -> StdResult<T> {
19 bincode2::deserialize(data).map_err(|err| StdError::parse_err(type_name::<T>(), err))
20 }
21}