diff --git a/src/rlp/faces.rs b/src/rlp/faces.rs index d72f2f96c..392908f16 100644 --- a/src/rlp/faces.rs +++ b/src/rlp/faces.rs @@ -37,7 +37,7 @@ pub trait Decoder { } pub trait Decodable: Sized { - fn decode(decoder: &D) -> Result where D: Decoder; + fn decode(decoder: &D) -> Result where D: Decoder; } pub trait View<'a, 'view>: Sized { diff --git a/src/rlp/untrusted_rlp.rs b/src/rlp/untrusted_rlp.rs index 89c3b664f..fd385b99d 100644 --- a/src/rlp/untrusted_rlp.rs +++ b/src/rlp/untrusted_rlp.rs @@ -312,19 +312,27 @@ impl<'a> Decoder for BasicDecoder<'a> { } impl Decodable for T where T: FromBytes { - fn decode(decoder: &D) -> Result where D: Decoder { - unimplemented!() + fn decode(decoder: &D) -> Result where D: Decoder { + decoder.read_value(| bytes | { + Ok(try!(T::from_bytes(bytes))) + }) } } impl Decodable for Vec where T: Decodable { - fn decode(decoder: &D) -> Result where D: Decoder { - unimplemented!() + fn decode(decoder: &D) -> Result where D: Decoder { + decoder.read_list(| decoders | { + decoders.iter().map(|d| T::decode(d)).collect() + }) } } impl Decodable for Vec { - fn decode(decoder: &D) -> Result where D: Decoder { - unimplemented!() + fn decode(decoder: &D) -> Result where D: Decoder { + decoder.read_value(| bytes | { + let mut res = vec![]; + res.extend(bytes); + Ok(res) + }) } }