Final docs

This commit is contained in:
arkpar
2016-02-03 16:43:48 +01:00
parent fe97809649
commit 42d5c09131
17 changed files with 75 additions and 189 deletions

View File

@@ -140,9 +140,9 @@ impl <T>ToBytes for T where T: FixedHash {
/// Error returned when FromBytes conversation goes wrong
#[derive(Debug, PartialEq, Eq)]
pub enum FromBytesError {
/// TODO [debris] Please document me
/// Expected more RLP data
DataIsTooShort,
/// TODO [debris] Please document me
/// Extra bytes after the end of the last item
DataIsTooLong,
/// Integer-representation is non-canonically prefixed with zero byte(s).
ZeroPrefixedInt,
@@ -165,7 +165,7 @@ pub type FromBytesResult<T> = Result<T, FromBytesError>;
///
/// TODO: check size of bytes before conversation and return appropriate error
pub trait FromBytes: Sized {
/// TODO [debris] Please document me
/// Create a value from bytes
fn from_bytes(bytes: &[u8]) -> FromBytesResult<Self>;
}

View File

@@ -103,12 +103,12 @@ impl <'a, 'view> Rlp<'a> where 'a: 'view {
res.unwrap_or_else(|_| panic!())
}
/// TODO [debris] Please document me
/// Decode into an object
pub fn as_val<T>(&self) -> T where T: RlpDecodable {
Self::view_as_val(self)
}
/// TODO [debris] Please document me
/// Decode list item at given index into an object
pub fn val_at<T>(&self, index: usize) -> T where T: RlpDecodable {
Self::view_as_val(&self.at(index))
}

View File

@@ -31,17 +31,17 @@ pub trait RlpDecodable: Sized {
fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder;
}
/// TODO [debris] Please document me
/// A view into RLP encoded data
pub trait View<'a, 'view>: Sized {
/// TODO [debris] Please document me
/// RLP prototype type
type Prototype;
/// TODO [debris] Please document me
/// Payload info type
type PayloadInfo;
/// TODO [debris] Please document me
/// Data type
type Data;
/// TODO [debris] Please document me
/// Item type
type Item;
/// TODO [debris] Please document me
/// Iterator type
type Iter;
/// Creates a new instance of `Rlp` reader
@@ -65,10 +65,10 @@ pub trait View<'a, 'view>: Sized {
/// Get the prototype of the RLP.
fn prototype(&self) -> Self::Prototype;
/// TODO [debris] Please document me
/// Get payload info.
fn payload_info(&self) -> Self::PayloadInfo;
/// TODO [debris] Please document me
/// Get underlieing data.
fn data(&'view self) -> Self::Data;
/// Returns number of RLP items.
@@ -205,18 +205,18 @@ pub trait View<'a, 'view>: Sized {
/// ```
fn iter(&'view self) -> Self::Iter;
/// TODO [debris] Please document me
/// Decode data into an object
fn as_val<T>(&self) -> Result<T, DecoderError> where T: RlpDecodable;
/// TODO [debris] Please document me
/// Decode data at given list index into an object
fn val_at<T>(&self, index: usize) -> Result<T, DecoderError> where T: RlpDecodable;
}
/// TODO [debris] Please document me
/// Raw RLP encoder
pub trait Encoder {
/// TODO [debris] Please document me
/// Write a value represented as bytes
fn emit_value<E: ByteEncodable>(&mut self, value: &E);
/// TODO [debris] Please document me
/// Write raw preencoded data to the output
fn emit_raw(&mut self, bytes: &[u8]) -> ();
}
@@ -250,7 +250,7 @@ pub trait RlpEncodable {
fn rlp_append(&self, s: &mut RlpStream);
}
/// TODO [debris] Please document me
/// RLP encoding stream
pub trait Stream: Sized {
/// Initializes instance of empty `Stream`.
@@ -341,7 +341,7 @@ pub trait Stream: Sized {
/// }
fn is_finished(&self) -> bool;
/// TODO [debris] Please document me
/// Get raw encoded bytes
fn as_raw(&self) -> &[u8];
/// Streams out encoded bytes.

View File

@@ -21,21 +21,21 @@ impl OffsetCache {
}
#[derive(Debug)]
/// TODO [debris] Please document me
/// RLP prototype
pub enum Prototype {
/// TODO [debris] Please document me
/// Empty
Null,
/// TODO [debris] Please document me
/// Value
Data(usize),
/// TODO [debris] Please document me
/// List
List(usize),
}
/// Stores basic information about item
pub struct PayloadInfo {
/// TODO [debris] Please document me
/// Header length in bytes
pub header_len: usize,
/// TODO [debris] Please document me
/// Value length in bytes
pub value_len: usize,
}