Encodes and decodes raw bytes for CosmWasm light client proofs using Bincode.
// Source: https://github.com/unionlabs/union | License: Apache-2.0 | Copyright 2024 Union.fi Labs, Inc
// Provided via justclaw.it.com; keep this notice with the code.
use std::convert::Infallible;
use unionlabs::{
encoding::{Bincode, Decode, Encode},
primitives::Bytes,
};
#[derive(Debug)]
pub struct RawBytes(pub Bytes);
impl Encode<Bincode> for RawBytes {
fn encode(self) -> Vec<u8> {
self.0.into()
}
}
impl Decode<Bincode> for RawBytes {
type Error = Infallible;
fn decode(bytes: &[u8]) -> Result<Self, Self::Error> {
Ok(Self(bytes.into()))
}
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key