From e51947663346548c1747b1c40a648fac7f4506da Mon Sep 17 00:00:00 2001 From: Pyfisch Date: Sat, 13 May 2017 17:37:46 +0200 Subject: [PATCH 01/17] uint -> usize in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b37d430..cda12a2 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ then the contents. However, there are some implementation details to be aware of: * `isize`/`usize` are encoded as `i64`/`u64`, for portability. -* enums variants are encoded as a `u32` instead of a `uint`. +* enums variants are encoded as a `u32` instead of a `usize`. `u32` is enough for all practical uses. * `str` is encoded as `(u64, &[u8])`, where the `u64` is the number of bytes contained in the encoded string. From 46712f7b133400f3f34c868d2c6dc7804cbc8e38 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Wed, 31 May 2017 16:23:04 +0200 Subject: [PATCH 02/17] readme: follow idiom (#187) --- README.md | 2 +- examples/basic.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cda12a2..cbb0da7 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ fn main() { let decoded: World = deserialize(&encoded[..]).unwrap(); - assert!(world == decoded); + assert_eq!(world, decoded); } ``` diff --git a/examples/basic.rs b/examples/basic.rs index 28c8b61..0ef4f92 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -4,13 +4,13 @@ extern crate bincode; use bincode::{serialize, deserialize, Infinite}; -#[derive(Serialize, Deserialize, PartialEq)] +#[derive(Serialize, Deserialize, PartialEq, Debug)] struct Entity { x: f32, y: f32, } -#[derive(Serialize, Deserialize, PartialEq)] +#[derive(Serialize, Deserialize, PartialEq, Debug)] struct World(Vec); fn main() { @@ -23,5 +23,5 @@ fn main() { let decoded: World = deserialize(&encoded[..]).unwrap(); - assert!(world == decoded); + assert_eq!(world, decoded); } From 04b5ff5938515e6e03d6e9f9f1d8da39f5d65ca0 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Wed, 31 May 2017 16:23:50 +0200 Subject: [PATCH 03/17] example: a reminder that usize is assumed to be 8 bytes long (#188) --- examples/basic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic.rs b/examples/basic.rs index 0ef4f92..1632d75 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -18,7 +18,7 @@ fn main() { let encoded: Vec = serialize(&world, Infinite).unwrap(); - // 8 bytes for the length of the vector, 4 bytes per float. + // 8 bytes for the length of the vector (usize), 4 bytes per float. assert_eq!(encoded.len(), 8 + 4 * 4); let decoded: World = deserialize(&encoded[..]).unwrap(); From 43712ac366cf424900603b816714ebed8e4a3921 Mon Sep 17 00:00:00 2001 From: Nelson Chen Date: Fri, 7 Jul 2017 15:52:22 -0700 Subject: [PATCH 04/17] Add Debug derivation to structs of the example in README.md (#191) The `assert_eq!` macro expects its arguments to satisfy the `Debug` trait as if and when it panics, it'll print out the `Debug` representation. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cbb0da7..adfd126 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,13 @@ extern crate bincode; use bincode::{serialize, deserialize, Infinite}; -#[derive(Serialize, Deserialize, PartialEq)] +#[derive(Serialize, Deserialize, PartialEq, Debug)] struct Entity { x: f32, y: f32, } -#[derive(Serialize, Deserialize, PartialEq)] +#[derive(Serialize, Deserialize, PartialEq, Debug)] struct World(Vec); fn main() { From e27043a036e6436e991add56c4bd026a270b4d91 Mon Sep 17 00:00:00 2001 From: Ty Overby Date: Fri, 14 Jul 2017 13:30:39 -0700 Subject: [PATCH 05/17] use docs.rs for documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index adfd126..1d10484 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ perfectly with other stream-based apis such as rust files, network streams, and the [flate2-rs](https://github.com/alexcrichton/flate2-rs) compression library. -## [Api Documentation](http://tyoverby.github.io/bincode/bincode/) +## [Api Documentation](http://docs.rs/bincode/) ## Bincode in the wild From d55bbf150f739bc9e18c3d5bf953f36728889286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Hellstr=C3=B6m?= Date: Tue, 18 Jul 2017 21:54:23 -0700 Subject: [PATCH 06/17] Remove naming redundancy with IoError --- src/de/read.rs | 2 +- src/internal.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/de/read.rs b/src/de/read.rs index c22ee23..048cba2 100644 --- a/src/de/read.rs +++ b/src/de/read.rs @@ -61,7 +61,7 @@ impl IoRead for IoReadReader { impl <'storage> SliceReader<'storage> { fn unexpected_eof() -> Box<::ErrorKind> { - return Box::new(::ErrorKind::IoError(IoError::new(IoErrorKind::UnexpectedEof, ""))); + return Box::new(::ErrorKind::Io(IoError::new(IoErrorKind::UnexpectedEof, ""))); } } diff --git a/src/internal.rs b/src/internal.rs index d8aa74e..2584598 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -34,7 +34,7 @@ pub type Error = Box; pub enum ErrorKind { /// If the error stems from the reader/writer that is being used /// during (de)serialization, that error will be stored and returned here. - IoError(IoError), + Io(IoError), /// If the bytes in the reader are not decodable because of an invalid /// encoding, this error will be returned. This error is only possible /// if a stream is corrupted. A stream produced from `encode` or `encode_into` @@ -57,7 +57,7 @@ pub enum ErrorKind { impl error::Error for ErrorKind { fn description(&self) -> &str { match *self { - ErrorKind::IoError(ref err) => error::Error::description(err), + ErrorKind::Io(ref err) => error::Error::description(err), ErrorKind::InvalidEncoding{desc, ..} => desc, ErrorKind::SequenceMustHaveLength => "bincode can't encode infinite sequences", ErrorKind::SizeLimit => "the size limit for decoding has been reached", @@ -68,7 +68,7 @@ impl error::Error for ErrorKind { fn cause(&self) -> Option<&error::Error> { match *self { - ErrorKind::IoError(ref err) => err.cause(), + ErrorKind::Io(ref err) => err.cause(), ErrorKind::InvalidEncoding{..} => None, ErrorKind::SequenceMustHaveLength => None, ErrorKind::SizeLimit => None, @@ -79,16 +79,16 @@ impl error::Error for ErrorKind { impl From for Error { fn from(err: IoError) -> Error { - ErrorKind::IoError(err).into() + ErrorKind::Io(err).into() } } impl fmt::Display for ErrorKind { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { - ErrorKind::IoError(ref ioerr) => - write!(fmt, "IoError: {}", ioerr), - ErrorKind::InvalidEncoding{desc, detail: None}=> + ErrorKind::Io(ref ioerr) => + write!(fmt, "Io: {}", ioerr), + ErrorKind::InvalidEncoding{desc, detail: None}=> write!(fmt, "InvalidEncoding: {}", desc), ErrorKind::InvalidEncoding{desc, detail: Some(ref detail)}=> write!(fmt, "InvalidEncoding: {} ({})", desc, detail), @@ -201,7 +201,7 @@ pub fn serialized_size_bounded(value: &T, max: u64) -> Option where T: serde::Serialize { let mut size_counter = SizeChecker { - size_limit: CountSize { total: 0, limit: Some(max) } + size_limit: CountSize { total: 0, limit: Some(max) } }; match value.serialize(&mut size_counter) { From b6dbb08f920821c85a42a91d3bf61c4c144ad79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Hellstr=C3=B6m?= Date: Thu, 20 Jul 2017 10:12:36 -0700 Subject: [PATCH 07/17] Correctlly report the cause of IoError (#195) --- src/internal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal.rs b/src/internal.rs index d8aa74e..140af99 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -68,7 +68,7 @@ impl error::Error for ErrorKind { fn cause(&self) -> Option<&error::Error> { match *self { - ErrorKind::IoError(ref err) => err.cause(), + ErrorKind::IoError(ref err) => Some(err), ErrorKind::InvalidEncoding{..} => None, ErrorKind::SequenceMustHaveLength => None, ErrorKind::SizeLimit => None, From 18bcfc420e085b3700a58af5fea92ecb69ba6164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Hellstr=C3=B6m?= Date: Sat, 22 Jul 2017 14:37:08 -0500 Subject: [PATCH 08/17] Seal SizeLimit and BincodeRead --- src/de/read.rs | 2 +- src/internal.rs | 8 +------- src/lib.rs | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/de/read.rs b/src/de/read.rs index c22ee23..e2d64eb 100644 --- a/src/de/read.rs +++ b/src/de/read.rs @@ -4,7 +4,7 @@ use serde_crate as serde; /// A byte-oriented reading trait that is specialized for /// slices and generic readers. -pub trait BincodeRead<'storage>: IoRead { +pub trait BincodeRead<'storage>: IoRead + ::private::Sealed { #[doc(hidden)] fn forward_read_str(&mut self, length: usize, visitor: V) -> Result where V: serde::de::Visitor<'storage>; diff --git a/src/internal.rs b/src/internal.rs index 140af99..2090ab8 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -5,7 +5,7 @@ use std::io::{Write, Read}; use std::io::Error as IoError; use std::{error, fmt, result}; -use ::SizeLimit; +use ::{CountSize, SizeLimit}; use byteorder::{ByteOrder}; pub use super::de::{ @@ -155,12 +155,6 @@ pub fn serialize(value: &T, size_limit: S) -> Result> Ok(writer) } - -struct CountSize { - total: u64, - limit: Option, -} - impl SizeLimit for CountSize { fn add(&mut self, c: u64) -> Result<()> { self.total += c; diff --git a/src/lib.rs b/src/lib.rs index f4d7681..d825f13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -125,7 +125,7 @@ pub fn serialize(value: &T, size_limit: S) -> internal::Result Result<()>; @@ -143,6 +143,11 @@ pub struct Bounded(pub u64); #[derive(Copy, Clone)] pub struct Infinite; +struct CountSize { + total: u64, + limit: Option, +} + impl SizeLimit for Bounded { #[inline(always)] fn add(&mut self, n: u64) -> Result<()> { @@ -165,3 +170,13 @@ impl SizeLimit for Infinite { #[inline(always)] fn limit(&self) -> Option { None } } + +mod private { + pub trait Sealed {} + + impl<'a> Sealed for super::de::read::SliceReader<'a> {} + impl Sealed for super::de::read::IoReadReader {} + impl Sealed for super::Infinite {} + impl Sealed for super::Bounded {} + impl Sealed for super::CountSize {} +} From d44adb148e51976d8d45a9a7971d7414ba96e37d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 22 Jul 2017 13:33:48 -0700 Subject: [PATCH 09/17] Correctly report the cause of IO error This was fixed in #195 but unintentionally reverted in #194. --- src/internal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal.rs b/src/internal.rs index 3baa5a6..e6b55a8 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -68,7 +68,7 @@ impl error::Error for ErrorKind { fn cause(&self) -> Option<&error::Error> { match *self { - ErrorKind::Io(ref err) => err.cause(), + ErrorKind::Io(ref err) => Some(err), ErrorKind::InvalidEncoding{..} => None, ErrorKind::SequenceMustHaveLength => None, ErrorKind::SizeLimit => None, From 2f1ab0a0e503dc102a49fae0721d3b99703a200d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 22 Jul 2017 13:34:12 -0700 Subject: [PATCH 10/17] Revert whitespace changes from #194 --- src/internal.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal.rs b/src/internal.rs index e6b55a8..565e3ab 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -86,9 +86,9 @@ impl From for Error { impl fmt::Display for ErrorKind { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { - ErrorKind::Io(ref ioerr) => + ErrorKind::Io(ref ioerr) => write!(fmt, "Io: {}", ioerr), - ErrorKind::InvalidEncoding{desc, detail: None}=> + ErrorKind::InvalidEncoding{desc, detail: None}=> write!(fmt, "InvalidEncoding: {}", desc), ErrorKind::InvalidEncoding{desc, detail: Some(ref detail)}=> write!(fmt, "InvalidEncoding: {} ({})", desc, detail), @@ -195,7 +195,7 @@ pub fn serialized_size_bounded(value: &T, max: u64) -> Option where T: serde::Serialize { let mut size_counter = SizeChecker { - size_limit: CountSize { total: 0, limit: Some(max) } + size_limit: CountSize { total: 0, limit: Some(max) } }; match value.serialize(&mut size_counter) { From 07b2514737f5ab498536725c62124792289aeff9 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Sat, 22 Jul 2017 23:40:45 +0200 Subject: [PATCH 11/17] readme: deserializer/decoder actually accepts `&[u8]`, not `Vec` --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cda12a2..cd0a13a 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,9 @@ A compact encoder / decoder pair that uses a binary zero-fluff encoding scheme. The size of the encoded object will be the same or smaller than the size that the object takes up in memory in a running Rust program. -In addition to exposing two simple functions that encode to Vec and decode -from Vec, binary-encode exposes a Reader/Writer API that makes it work +In addition to exposing two simple functions +(one that encodes to `Vec`, and one that decodes from `&[u8]`), +binary-encode exposes a Reader/Writer API that makes it work perfectly with other stream-based apis such as rust files, network streams, and the [flate2-rs](https://github.com/alexcrichton/flate2-rs) compression library. From 34aba9acbe0aaf0a0ca251e3d9cd6b634f9f08ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Hellstr=C3=B6m?= Date: Sun, 23 Jul 2017 23:57:53 -0500 Subject: [PATCH 12/17] Internal type names (#199) * Remove internal type names from api * Rename IoReadReader to IoReader --- src/de/read.rs | 26 +++++++++++++------------- src/internal.rs | 11 +++++------ src/lib.rs | 4 ++-- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/de/read.rs b/src/de/read.rs index 5235eb9..04f9639 100644 --- a/src/de/read.rs +++ b/src/de/read.rs @@ -1,10 +1,10 @@ -use std::io::{Read as IoRead, Result as IoResult, Error as IoError, ErrorKind as IoErrorKind}; +use std::io; use ::Result; use serde_crate as serde; /// A byte-oriented reading trait that is specialized for /// slices and generic readers. -pub trait BincodeRead<'storage>: IoRead + ::private::Sealed { +pub trait BincodeRead<'storage>: io::Read + ::private::Sealed { #[doc(hidden)] fn forward_read_str(&mut self, length: usize, visitor: V) -> Result where V: serde::de::Visitor<'storage>; @@ -23,7 +23,7 @@ pub struct SliceReader<'storage> { } /// A BincodeRead implementation for io::Readers -pub struct IoReadReader { +pub struct IoReader { reader: R, temp_buffer: Vec, } @@ -37,31 +37,31 @@ impl <'storage> SliceReader<'storage> { } } -impl IoReadReader { +impl IoReader { /// Constructs an IoReadReader - pub fn new(r: R) -> IoReadReader { - IoReadReader { + pub fn new(r: R) -> IoReader { + IoReader { reader: r, temp_buffer: vec![], } } } -impl <'storage> IoRead for SliceReader<'storage> { - fn read(&mut self, out: & mut [u8]) -> IoResult { +impl <'storage> io::Read for SliceReader<'storage> { + fn read(&mut self, out: & mut [u8]) -> io::Result { (&mut self.slice).read(out) } } -impl IoRead for IoReadReader { - fn read(&mut self, out: & mut [u8]) -> IoResult { +impl io::Read for IoReader { + fn read(&mut self, out: & mut [u8]) -> io::Result { self.reader.read(out) } } impl <'storage> SliceReader<'storage> { fn unexpected_eof() -> Box<::ErrorKind> { - return Box::new(::ErrorKind::Io(IoError::new(IoErrorKind::UnexpectedEof, ""))); + return Box::new(::ErrorKind::Io(io::Error::new(io::ErrorKind::UnexpectedEof, ""))); } } @@ -107,7 +107,7 @@ impl <'storage> BincodeRead<'storage> for SliceReader<'storage> { } } -impl IoReadReader where R: IoRead { +impl IoReader where R: io::Read { fn fill_buffer(&mut self, length: usize) -> Result<()> { let current_length = self.temp_buffer.len(); if length > current_length{ @@ -120,7 +120,7 @@ impl IoReadReader where R: IoRead { } } -impl BincodeRead<'static> for IoReadReader where R: IoRead { +impl BincodeRead<'static> for IoReader where R: io::Read { fn forward_read_str(&mut self, length: usize, visitor: V) -> Result where V: serde::de::Visitor<'static> { self.fill_buffer(length)?; diff --git a/src/internal.rs b/src/internal.rs index 565e3ab..b0efe05 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -2,8 +2,7 @@ //! that use the `serde` crate for the serializable and deserializable //! implementation. -use std::io::{Write, Read}; -use std::io::Error as IoError; +use std::io::{self, Write, Read}; use std::{error, fmt, result}; use ::{CountSize, SizeLimit}; use byteorder::{ByteOrder}; @@ -34,7 +33,7 @@ pub type Error = Box; pub enum ErrorKind { /// If the error stems from the reader/writer that is being used /// during (de)serialization, that error will be stored and returned here. - Io(IoError), + Io(io::Error), /// If the bytes in the reader are not decodable because of an invalid /// encoding, this error will be returned. This error is only possible /// if a stream is corrupted. A stream produced from `encode` or `encode_into` @@ -77,8 +76,8 @@ impl error::Error for ErrorKind { } } -impl From for Error { - fn from(err: IoError) -> Error { +impl From for Error { + fn from(err: io::Error) -> Error { ErrorKind::Io(err).into() } } @@ -216,7 +215,7 @@ pub fn serialized_size_bounded(value: &T, max: u64) -> Option pub fn deserialize_from(reader: &mut R, size_limit: S) -> Result where R: Read, T: serde::de::DeserializeOwned, S: SizeLimit, E: ByteOrder { - let reader = ::de::read::IoReadReader::new(reader); + let reader = ::de::read::IoReader::new(reader); let mut deserializer = Deserializer::<_, S, E>::new(reader, size_limit); serde::Deserialize::deserialize(&mut deserializer) } diff --git a/src/lib.rs b/src/lib.rs index d825f13..364b380 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,7 +46,7 @@ pub mod internal; pub mod read_types { //! The types that the deserializer uses for optimizations - pub use ::de::read::{SliceReader, BincodeRead, IoReadReader}; + pub use ::de::read::{SliceReader, BincodeRead, IoReader}; } use std::io::{Read, Write}; @@ -175,7 +175,7 @@ mod private { pub trait Sealed {} impl<'a> Sealed for super::de::read::SliceReader<'a> {} - impl Sealed for super::de::read::IoReadReader {} + impl Sealed for super::de::read::IoReader {} impl Sealed for super::Infinite {} impl Sealed for super::Bounded {} impl Sealed for super::CountSize {} From 4777efdfaadaaba041bbfe582180fcbde2a4850e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Hellstr=C3=B6m?= Date: Sun, 23 Jul 2017 23:58:29 -0500 Subject: [PATCH 13/17] take reader and writer by value (#200) --- src/internal.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal.rs b/src/internal.rs index b0efe05..78e4cfa 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -121,7 +121,7 @@ impl serde::ser::Error for Error { /// If this returns an `Error` (other than SizeLimit), assume that the /// writer is in an invalid state, as writing could bail out in the middle of /// serializing. -pub fn serialize_into(writer: &mut W, value: &T, size_limit: S) -> Result<()> +pub fn serialize_into(writer: W, value: &T, size_limit: S) -> Result<()> where W: Write, T: serde::Serialize, S: SizeLimit, E: ByteOrder { if let Some(limit) = size_limit.limit() { @@ -212,7 +212,7 @@ pub fn serialized_size_bounded(value: &T, max: u64) -> Option /// If this returns an `Error`, assume that the buffer that you passed /// in is in an invalid state, as the error could be returned during any point /// in the reading. -pub fn deserialize_from(reader: &mut R, size_limit: S) -> Result +pub fn deserialize_from(reader: R, size_limit: S) -> Result where R: Read, T: serde::de::DeserializeOwned, S: SizeLimit, E: ByteOrder { let reader = ::de::read::IoReader::new(reader); From f20770a09f65cb5d047b3b29c3e01f3d410f99a9 Mon Sep 17 00:00:00 2001 From: Thomas Schaller Date: Sun, 10 Sep 2017 17:25:32 +0200 Subject: [PATCH 14/17] Correct error message Spotted the mistake while skimming over the code. --- src/de/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/mod.rs b/src/de/mod.rs index b98be7e..ec3cb17 100644 --- a/src/de/mod.rs +++ b/src/de/mod.rs @@ -85,7 +85,7 @@ where R: BincodeRead<'de>, S: SizeLimit, E: ByteOrder { fn deserialize_any(self, _visitor: V) -> Result where V: serde::de::Visitor<'de>, { - let message = "bincode does not support Deserializer::deserialize"; + let message = "bincode does not support Deserializer::deserialize_any"; Err(Error::custom(message)) } From d033583700ad6daa0c665d05053f3ae1797cb3e7 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 10 Oct 2017 13:20:34 -0400 Subject: [PATCH 15/17] Forward read_exact() as well as read(). (#207) If we don't do this we end up using the generic read_exact method which is not necessarily optimal. This is especially when using a specialized Read implementation to go fast. See https://github.com/TyOverby/bincode/issues/206 --- src/de/read.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/de/read.rs b/src/de/read.rs index 04f9639..87aa304 100644 --- a/src/de/read.rs +++ b/src/de/read.rs @@ -51,12 +51,18 @@ impl <'storage> io::Read for SliceReader<'storage> { fn read(&mut self, out: & mut [u8]) -> io::Result { (&mut self.slice).read(out) } + fn read_exact(&mut self, out: & mut [u8]) -> io::Result<()> { + (&mut self.slice).read_exact(out) + } } impl io::Read for IoReader { fn read(&mut self, out: & mut [u8]) -> io::Result { self.reader.read(out) } + fn read_exact(&mut self, out: & mut [u8]) -> io::Result<()> { + self.reader.read_exact(out) + } } impl <'storage> SliceReader<'storage> { From 0214c6f4c29d9e37433a995ac6df43a6aaea7e3f Mon Sep 17 00:00:00 2001 From: Ty Overby Date: Tue, 10 Oct 2017 10:25:19 -0700 Subject: [PATCH 16/17] bump version number --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4d7df29..0692653 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bincode" -version = "0.8.0" +version = "0.8.1" authors = ["Ty Overby ", "Francesco Mazzoli ", "David Tolnay ", "Daniel Griffen"] publish = false From ab70e7d5075777721be23de8d0d4735f10dcd07f Mon Sep 17 00:00:00 2001 From: Ty Overby Date: Tue, 10 Oct 2017 10:32:18 -0700 Subject: [PATCH 17/17] remove completely unused dependency --- Cargo.toml | 1 - src/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0692653..212f070 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ description = "A binary serialization / deserialization strategy that uses Serde [dependencies] byteorder = "1.0.0" -num-traits = "0.1.32" serde = "1.*.*" [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 364b380..c1c736b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,7 +37,6 @@ #![crate_type = "dylib"] extern crate byteorder; -extern crate num_traits; extern crate serde as serde_crate; mod ser;