Rlp data function

This commit is contained in:
debris 2015-11-30 11:54:09 +01:00
parent f42e8c0665
commit 93f2bd9314
1 changed files with 36 additions and 0 deletions

View File

@ -134,6 +134,24 @@ impl<'a> Rlp<'a> {
}
}
/// The bare data of the rlp.
///
/// ```rust
/// extern crate ethcore_util as util;
/// use util::rlp::*;
///
/// fn main () {
/// let data = vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g'];
/// let rlp = Rlp::new(&data);
/// let view = rlp.at(1);
/// let dog = view.data();
/// assert_eq!(dog, &[0x83, b'd', b'o', b'g']);
/// }
/// ```
pub fn data(&'a self) -> &'a [u8] {
self.rlp.data()
}
/// Get view onto rlp-slice at index.
///
/// Caches offset to given index, so access to successive
@ -212,6 +230,24 @@ impl<'a> UntrustedRlp<'a> {
}
}
/// The bare data of the rlp.
///
/// ```rust
/// extern crate ethcore_util as util;
/// use util::rlp::*;
///
/// fn main () {
/// let data = vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g'];
/// let rlp = UntrustedRlp::new(&data);
/// let view = rlp.at(1).unwrap();
/// let dog = view.data();
/// assert_eq!(dog, &[0x83, b'd', b'o', b'g']);
/// }
/// ```
pub fn data(&'a self) -> &'a [u8] {
self.bytes
}
/// Get view onto rlp-slice at index
///
/// Caches offset to given index, so access to successive