rlp payload_info method

This commit is contained in:
debris 2015-12-02 14:14:12 +01:00
parent 35ae32a8a5
commit 356be1c635

View File

@ -170,6 +170,10 @@ impl<'a, 'view> Rlp<'a> where 'a: 'view {
self.rlp.raw() self.rlp.raw()
} }
pub fn payload_info(&self) -> PayloadInfo {
self.rlp.payload_info().unwrap()
}
pub fn data(&'view self) -> &'a [u8] { pub fn data(&'view self) -> &'a [u8] {
self.rlp.data() self.rlp.data()
} }
@ -354,6 +358,10 @@ impl<'a, 'view> UntrustedRlp<'a> where 'a: 'view {
self.bytes self.bytes
} }
pub fn payload_info(&self) -> Result<PayloadInfo, DecoderError> {
BasicDecoder::payload_info(self.bytes)
}
pub fn data(&'view self) -> &'a [u8] { pub fn data(&'view self) -> &'a [u8] {
let ii = BasicDecoder::payload_info(self.bytes).unwrap(); let ii = BasicDecoder::payload_info(self.bytes).unwrap();
&self.bytes[ii.header_len..(ii.header_len + ii.value_len)] &self.bytes[ii.header_len..(ii.header_len + ii.value_len)]
@ -401,8 +409,6 @@ impl<'a, 'view> UntrustedRlp<'a> where 'a: 'view {
} }
} }
//pub fn payload_offset(&self) ->
/// Get view onto rlp-slice at index /// Get view onto rlp-slice at index
/// ///
/// Caches offset to given index, so access to successive /// Caches offset to given index, so access to successive