Rlp data function
This commit is contained in:
parent
f42e8c0665
commit
93f2bd9314
36
src/rlp.rs
36
src/rlp.rs
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user