parent
7fe00c6e22
commit
43c3cbd457
33 changed files with 402 additions and 450 deletions
|
|
@ -1,5 +1,7 @@
|
|||
pub type Error = Box<dyn std::error::Error>;
|
||||
|
||||
use pallas_codec::minicbor::{decode, to_vec, Decode, Encode};
|
||||
|
||||
pub trait Fragment<'a>
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
@ -10,14 +12,14 @@ where
|
|||
|
||||
impl<'a, T> Fragment<'a> for T
|
||||
where
|
||||
T: minicbor::Encode + minicbor::Decode<'a> + Sized,
|
||||
T: Encode + Decode<'a> + Sized,
|
||||
{
|
||||
fn encode_fragment(&self) -> Result<Vec<u8>, Error> {
|
||||
minicbor::to_vec(self).map_err(|e| e.into())
|
||||
to_vec(self).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
fn decode_fragment(bytes: &'a [u8]) -> Result<Self, Error> {
|
||||
minicbor::decode(bytes).map_err(|e| e.into())
|
||||
decode(bytes).map_err(|e| e.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue