From 275c93ab6b5fb0b4892f44ba1421d6d02f649d3e Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Fri, 1 Aug 2014 11:16:18 -0700 Subject: [PATCH] Add docs for SimpleDecoder and SimpleEncoder traits --- src/network/serialize.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/network/serialize.rs b/src/network/serialize.rs index 80611cc..14644c3 100644 --- a/src/network/serialize.rs +++ b/src/network/serialize.rs @@ -86,33 +86,52 @@ impl RawDecoder { /// A simple Encoder trait pub trait SimpleEncoder { + /// Output a 64-bit uint fn emit_u64(&mut self, v: u64) -> Result<(), E>; + /// Output a 32-bit uint fn emit_u32(&mut self, v: u32) -> Result<(), E>; + /// Output a 16-bit uint fn emit_u16(&mut self, v: u16) -> Result<(), E>; + /// Output a 8-bit uint fn emit_u8(&mut self, v: u8) -> Result<(), E>; + /// Output a 64-bit int fn emit_i64(&mut self, v: i64) -> Result<(), E>; + /// Output a 32-bit int fn emit_i32(&mut self, v: i32) -> Result<(), E>; + /// Output a 16-bit int fn emit_i16(&mut self, v: i16) -> Result<(), E>; + /// Output a 8-bit int fn emit_i8(&mut self, v: i8) -> Result<(), E>; + /// Output a boolean fn emit_bool(&mut self, v: bool) -> Result<(), E>; } /// A simple Decoder trait pub trait SimpleDecoder { + /// Read a 64-bit uint fn read_u64(&mut self) -> Result; + /// Read a 32-bit uint fn read_u32(&mut self) -> Result; + /// Read a 16-bit uint fn read_u16(&mut self) -> Result; + /// Read a 8-bit uint fn read_u8(&mut self) -> Result; + /// Read a 64-bit int fn read_i64(&mut self) -> Result; + /// Read a 32-bit int fn read_i32(&mut self) -> Result; + /// Read a 16-bit int fn read_i16(&mut self) -> Result; + /// Read a 8-bit int fn read_i8(&mut self) -> Result; + /// Read a boolean fn read_bool(&mut self) -> Result; + /// Signal a decoding error fn error(&mut self, err: &str) -> E; }