fix(miniprotocols): Handle regression related to multi-msg payloads (#76)
This commit is contained in:
parent
d1caf79198
commit
3234523c83
4 changed files with 79 additions and 39 deletions
|
|
@ -1,25 +1,9 @@
|
|||
use minicbor::encode::Write;
|
||||
|
||||
/// Shared re-export of minicbor lib across all Pallas
|
||||
pub use minicbor;
|
||||
|
||||
/// Round-trip friendly common helper structs
|
||||
pub mod utils;
|
||||
|
||||
pub trait Fragment: Sized {
|
||||
fn read_cbor(buffer: &[u8]) -> Result<Self, minicbor::decode::Error>;
|
||||
fn write_cbor<W: Write>(&self, write: W) -> Result<(), minicbor::encode::Error<W::Error>>;
|
||||
}
|
||||
pub trait Fragment: Sized + for<'b> minicbor::Decode<'b> + minicbor::Encode {}
|
||||
|
||||
impl<T> Fragment for T
|
||||
where
|
||||
T: for<'b> minicbor::Decode<'b> + minicbor::Encode,
|
||||
{
|
||||
fn read_cbor(buffer: &[u8]) -> Result<Self, minicbor::decode::Error> {
|
||||
minicbor::decode(buffer)
|
||||
}
|
||||
|
||||
fn write_cbor<W: Write>(&self, write: W) -> Result<(), minicbor::encode::Error<W::Error>> {
|
||||
minicbor::encode(self, write)
|
||||
}
|
||||
}
|
||||
impl<T> Fragment for T where T: for<'b> minicbor::Decode<'b> + minicbor::Encode + Sized {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue