pub type Error = Box; use pallas_codec::minicbor::{decode, to_vec, Decode, Encode}; pub trait Fragment<'a> where Self: Sized, { fn encode_fragment(&self) -> Result, Error>; fn decode_fragment(bytes: &'a [u8]) -> Result; } impl<'a, T> Fragment<'a> for T where T: Encode<()> + Decode<'a, ()> + Sized, { fn encode_fragment(&self) -> Result, Error> { to_vec(self).map_err(|e| e.into()) } fn decode_fragment(bytes: &'a [u8]) -> Result { decode(bytes).map_err(|e| e.into()) } } #[cfg(feature = "json")] pub trait ToCanonicalJson { fn to_json(&self) -> serde_json::Value; } pub trait ToHash { fn to_hash(&self) -> pallas_crypto::hash::Hash; }