Final docs
This commit is contained in:
@@ -111,11 +111,11 @@ impl ToPretty for Bytes {
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO [debris] Please document me
|
||||
/// A byte collection reference that can either be a slice or a vector
|
||||
pub enum BytesRef<'a> {
|
||||
/// TODO [debris] Please document me
|
||||
/// This is a reference to a vector
|
||||
Flexible(&'a mut Bytes),
|
||||
/// TODO [debris] Please document me
|
||||
/// This is a reference to a slice
|
||||
Fixed(&'a mut [u8])
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,9 @@ use sha3::*;
|
||||
/// index. Their `BloomIndex` can be created from block number and given level.
|
||||
#[derive(Eq, PartialEq, Hash, Clone, Debug)]
|
||||
pub struct BloomIndex {
|
||||
/// TODO [debris] Please document me
|
||||
/// Bloom level
|
||||
pub level: u8,
|
||||
/// TODO [debris] Please document me
|
||||
/// Filter Index
|
||||
pub index: usize,
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,17 @@ impl Signature {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Crypto error
|
||||
pub enum CryptoError {
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Invalid secret key
|
||||
InvalidSecret,
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Invalid public key
|
||||
InvalidPublic,
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Invalid EC signature
|
||||
InvalidSignature,
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Invalid AES message
|
||||
InvalidMessage,
|
||||
/// TODO [arkpar] Please document me
|
||||
/// IO Error
|
||||
Io(::std::io::Error),
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ impl KeyPair {
|
||||
pub fn sign(&self, message: &H256) -> Result<Signature, CryptoError> { ec::sign(&self.secret, message) }
|
||||
}
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// EC functions
|
||||
pub mod ec {
|
||||
use hash::*;
|
||||
use uint::*;
|
||||
@@ -211,12 +211,12 @@ pub mod ec {
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// ECDH functions
|
||||
pub mod ecdh {
|
||||
use crypto::*;
|
||||
use crypto::{self};
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Agree on a shared secret
|
||||
pub fn agree(secret: &Secret, public: &Public, ) -> Result<Secret, CryptoError> {
|
||||
use secp256k1::*;
|
||||
let context = &crypto::SECP256K1;
|
||||
@@ -232,13 +232,13 @@ pub mod ecdh {
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// ECIES function
|
||||
pub mod ecies {
|
||||
use hash::*;
|
||||
use bytes::*;
|
||||
use crypto::*;
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Encrypt a message with a public key
|
||||
pub fn encrypt(public: &Public, plain: &[u8]) -> Result<Bytes, CryptoError> {
|
||||
use ::rcrypto::digest::Digest;
|
||||
use ::rcrypto::sha2::Sha256;
|
||||
@@ -274,7 +274,7 @@ pub mod ecies {
|
||||
Ok(msg)
|
||||
}
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Decrypt a message with a secret key
|
||||
pub fn decrypt(secret: &Secret, encrypted: &[u8]) -> Result<Bytes, CryptoError> {
|
||||
use ::rcrypto::digest::Digest;
|
||||
use ::rcrypto::sha2::Sha256;
|
||||
@@ -340,20 +340,20 @@ pub mod ecies {
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// AES encryption
|
||||
pub mod aes {
|
||||
use ::rcrypto::blockmodes::*;
|
||||
use ::rcrypto::aessafe::*;
|
||||
use ::rcrypto::symmetriccipher::*;
|
||||
use ::rcrypto::buffer::*;
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Encrypt a message
|
||||
pub fn encrypt(k: &[u8], iv: &[u8], plain: &[u8], dest: &mut [u8]) {
|
||||
let mut encryptor = CtrMode::new(AesSafe128Encryptor::new(k), iv.to_vec());
|
||||
encryptor.encrypt(&mut RefReadBuffer::new(plain), &mut RefWriteBuffer::new(dest), true).expect("Invalid length or padding");
|
||||
}
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Decrypt a message
|
||||
pub fn decrypt(k: &[u8], iv: &[u8], encrypted: &[u8], dest: &mut [u8]) {
|
||||
let mut encryptor = CtrMode::new(AesSafe128Encryptor::new(k), iv.to_vec());
|
||||
encryptor.decrypt(&mut RefReadBuffer::new(encrypted), &mut RefWriteBuffer::new(dest), true).expect("Invalid length or padding");
|
||||
|
||||
@@ -42,9 +42,9 @@ mod worker;
|
||||
use mio::{EventLoop, Token};
|
||||
|
||||
#[derive(Debug)]
|
||||
/// TODO [arkpar] Please document me
|
||||
/// IO Error
|
||||
pub enum IoError {
|
||||
/// TODO [arkpar] Please document me
|
||||
/// Low level error from mio crate
|
||||
Mio(::std::io::Error),
|
||||
}
|
||||
|
||||
@@ -78,19 +78,12 @@ pub trait IoHandler<Message>: Send + Sync where Message: Send + Sync + Clone + '
|
||||
fn deregister_stream(&self, _stream: StreamToken, _event_loop: &mut EventLoop<IoManager<Message>>) {}
|
||||
}
|
||||
|
||||
/// TODO [arkpar] Please document me
|
||||
pub use io::service::TimerToken;
|
||||
/// TODO [arkpar] Please document me
|
||||
pub use io::service::StreamToken;
|
||||
/// TODO [arkpar] Please document me
|
||||
pub use io::service::IoContext;
|
||||
/// TODO [arkpar] Please document me
|
||||
pub use io::service::IoService;
|
||||
/// TODO [arkpar] Please document me
|
||||
pub use io::service::IoChannel;
|
||||
/// TODO [arkpar] Please document me
|
||||
pub use io::service::IoManager;
|
||||
/// TODO [arkpar] Please document me
|
||||
pub use io::service::TOKENS_PER_HANDLER;
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ use heapsize::HeapSizeOf;
|
||||
|
||||
/// Should be used to squeeze collections to certain size in bytes
|
||||
pub trait Squeeze {
|
||||
/// TODO [debris] Please document me
|
||||
/// Try to reduce collection size to `size` bytes
|
||||
fn squeeze(&mut self, size: usize);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
/// }
|
||||
/// ```
|
||||
pub trait SharedPrefix <T> {
|
||||
/// TODO [debris] Please document me
|
||||
/// Get common prefix length
|
||||
fn shared_prefix_len(&self, elem: &[T]) -> usize;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user