More doc updates. All Gav Wood docs done.
This commit is contained in:
@@ -236,7 +236,7 @@ impl_uint_from_bytes!(U128);
|
||||
|
||||
impl <T>FromBytes for T where T: FixedHash {
|
||||
fn from_bytes(bytes: &[u8]) -> FromBytesResult<T> {
|
||||
match bytes.len().cmp(&T::size()) {
|
||||
match bytes.len().cmp(&T::len()) {
|
||||
Ordering::Less => return Err(FromBytesError::DataIsTooShort),
|
||||
Ordering::Greater => return Err(FromBytesError::DataIsTooLong),
|
||||
Ordering::Equal => ()
|
||||
@@ -246,7 +246,7 @@ impl <T>FromBytes for T where T: FixedHash {
|
||||
use std::{mem, ptr};
|
||||
|
||||
let mut res: T = mem::uninitialized();
|
||||
ptr::copy(bytes.as_ptr(), res.as_slice_mut().as_mut_ptr(), T::size());
|
||||
ptr::copy(bytes.as_ptr(), res.as_slice_mut().as_mut_ptr(), T::len());
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
@@ -48,13 +48,13 @@ pub use self::rlpstream::{RlpStream};
|
||||
pub use elastic_array::ElasticArray1024;
|
||||
use super::hash::H256;
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// The RLP encoded empty data (used to mean "null value").
|
||||
pub const NULL_RLP: [u8; 1] = [0x80; 1];
|
||||
/// TODO [Gav Wood] Please document me
|
||||
/// The RLP encoded empty list.
|
||||
pub const EMPTY_LIST_RLP: [u8; 1] = [0xC0; 1];
|
||||
/// TODO [arkpar] Please document me
|
||||
/// The SHA3 of the RLP encoding of empty data.
|
||||
pub const SHA3_NULL_RLP: H256 = H256( [0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e, 0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x01, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21] );
|
||||
/// TODO [debris] Please document me
|
||||
/// The SHA3 of the RLP encoding of empty list.
|
||||
pub const SHA3_EMPTY_LIST_RLP: H256 = H256( [0x1d, 0xcc, 0x4d, 0xe8, 0xde, 0xc7, 0x5d, 0x7a, 0xab, 0x85, 0xb5, 0x67, 0xb6, 0xcc, 0xd4, 0x1a, 0xd3, 0x12, 0x45, 0x1b, 0x94, 0x8a, 0x74, 0x13, 0xf0, 0xa1, 0x42, 0xfd, 0x40, 0xd4, 0x93, 0x47] );
|
||||
|
||||
/// Shortcut function to decode trusted rlp
|
||||
|
||||
@@ -3,27 +3,27 @@ use std::error::Error as StdError;
|
||||
use rlp::bytes::FromBytesError;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
/// TODO [debris] Please document me
|
||||
/// Error concerning the RLP decoder.
|
||||
pub enum DecoderError {
|
||||
/// TODO [debris] Please document me
|
||||
/// Couldn't convert given bytes to an instance of required type.
|
||||
FromBytesError(FromBytesError),
|
||||
/// Given data has additional bytes at the end of the valid RLP fragment.
|
||||
/// Data has additional bytes at the end of the valid RLP fragment.
|
||||
RlpIsTooBig,
|
||||
/// TODO [debris] Please document me
|
||||
/// Data has too few bytes for valid RLP.
|
||||
RlpIsTooShort,
|
||||
/// TODO [debris] Please document me
|
||||
/// Expect an encoded list, RLP was something else.
|
||||
RlpExpectedToBeList,
|
||||
/// TODO [Gav Wood] Please document me
|
||||
/// Expect encoded data, RLP was something else.
|
||||
RlpExpectedToBeData,
|
||||
/// TODO [Gav Wood] Please document me
|
||||
/// Expected a different size list.
|
||||
RlpIncorrectListLen,
|
||||
/// TODO [Gav Wood] Please document me
|
||||
/// Data length number has a prefixed zero byte, invalid for numbers.
|
||||
RlpDataLenWithZeroPrefix,
|
||||
/// TODO [Gav Wood] Please document me
|
||||
/// List length number has a prefixed zero byte, invalid for numbers.
|
||||
RlpListLenWithZeroPrefix,
|
||||
/// TODO [debris] Please document me
|
||||
/// Non-canonical (longer than necessary) representation used for data or list.
|
||||
RlpInvalidIndirection,
|
||||
/// Returned when declared length is inconsistent with data specified after
|
||||
/// Declared length is inconsistent with data specified after.
|
||||
RlpInconsistentLengthAndData
|
||||
}
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ use elastic_array::ElasticArray1024;
|
||||
use hash::H256;
|
||||
use sha3::*;
|
||||
|
||||
/// TODO [debris] Please document me
|
||||
/// Type is able to decode RLP.
|
||||
pub trait Decoder: Sized {
|
||||
/// TODO [debris] Please document me
|
||||
/// Read a value from the RLP into a given type.
|
||||
fn read_value<T, F>(&self, f: F) -> Result<T, DecoderError>
|
||||
where F: FnOnce(&[u8]) -> Result<T, DecoderError>;
|
||||
|
||||
/// TODO [Gav Wood] Please document me
|
||||
/// Get underlying `UntrustedRLP` object.
|
||||
fn as_rlp(&self) -> &UntrustedRlp;
|
||||
/// TODO [debris] Please document me
|
||||
/// Get underlying raw bytes slice.
|
||||
fn as_raw(&self) -> &[u8];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user