mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 23:07:57 +00:00
Update to parity-scale-codec (#3232)
* WIP: update codec * WIP * compiling * WIP * rename parity-scale-codec to codec * WIP * fix * remove old comments * use published crates * fix expected error msg * bump version * fmt and fix * remove old comment * fix wrong decoding impl * implement encode like for structures * undo removal of old pending changes * trailingzeroinput * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * update codec * fmt * version is 1.0.0 * show more error * fmt
This commit is contained in:
committed by
Bastian Köcher
parent
a0d442333f
commit
4ed67e03a4
@@ -20,7 +20,7 @@
|
||||
use serde::Serialize;
|
||||
#[cfg(feature = "std")]
|
||||
use log::debug;
|
||||
use crate::codec::{Decode, Encode, Codec, Input, Output, HasCompact, EncodeAsRef};
|
||||
use crate::codec::{Decode, Encode, Codec, Input, Output, HasCompact, EncodeAsRef, Error};
|
||||
use crate::traits::{
|
||||
self, Member, SimpleArithmetic, SimpleBitOps, MaybeDisplay, Hash as HashT, MaybeSerializeDebug,
|
||||
MaybeSerializeDebugButNotDeserialize
|
||||
@@ -60,8 +60,8 @@ impl<Number, Hash> Decode for Header<Number, Hash> where
|
||||
Hash: HashT,
|
||||
Hash::Output: Decode,
|
||||
{
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
Some(Header {
|
||||
fn decode<I: Input>(input: &mut I) -> Result<Self, Error> {
|
||||
Ok(Header {
|
||||
parent_hash: Decode::decode(input)?,
|
||||
number: <<Number as HasCompact>::Type>::decode(input)?.into(),
|
||||
state_root: Decode::decode(input)?,
|
||||
@@ -85,6 +85,12 @@ impl<Number, Hash> Encode for Header<Number, Hash> where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Number, Hash> codec::EncodeLike for Header<Number, Hash> where
|
||||
Number: HasCompact + Copy + Into<u128>,
|
||||
Hash: HashT,
|
||||
Hash::Output: Encode,
|
||||
{}
|
||||
|
||||
impl<Number, Hash> traits::Header for Header<Number, Hash> where
|
||||
Number: Member + MaybeSerializeDebug + ::rstd::hash::Hash + MaybeDisplay + SimpleArithmetic + Codec + Copy + Into<u128>,
|
||||
Hash: HashT,
|
||||
|
||||
Reference in New Issue
Block a user