Commit Graph

157 Commits

Author SHA1 Message Date
Andy Goetz 5d6dfa1fb9 Update docs to highlight differences between DefaultOptions and functions (#373)
Due to historical reasons, the default options used by bincode for the
helper functions at the root of the crate differ from the options in
the `config` module.

Changing the default options is a breaking change, so until a decision
is made, we can at least document the current behavior.
2021-02-23 05:33:55 -08:00
Lena Hellström 00c43bf3b1 fix logic error in fill_buffer (#336) 2020-06-23 23:41:55 -07:00
Lena Hellström a822c09d93 bump version to 1.3.0 (#330) 2020-06-04 21:20:43 -07:00
Lena Hellström 752262a03d update documentation to reflect new config options (#329) 2020-06-04 21:20:00 -07:00
Lena Hellström e80f61b9da Reject trailing bytes (#198) 2020-05-26 12:40:04 -07:00
Lena Hellström f9faa33686 refactor config module (#323)
Break up the config module into one submodule per configuration
option. This commit also changes the default configuration with
the new options system to be varint (the old system still uses
fixint to preserve backwards compatibility).
2020-05-18 22:46:12 -07:00
Lena Hellström c27e9c6874 Varint enum tags and lengths (#306)
Adds varint encoding to all numbers, including sequence lengths and enum discriminants. Varints are encoded according to the following scheme

1. If `u < 251`, encode it as a single byte with that value.
2. If `251 <= u < 2**16`, encode it as a literal byte 251, followed by a u16 with value `u`.
3. If `2**16 <= u < 2**32`, encode it as a literal byte 252, followed by a u32 with value `u`.
4. If `2**32 <= u < 2**64`, encode it as a literal byte 253, followed by a u64 with value `u`.
5. If `2**64 <= u < 2**128`, encode it as a literal byte 254, followed by a u128 with value `u`.

Signed integers are first encoded using zigzag format (see docs for details)

Co-authored-by: Maciej Hirsz <maciej.hirsz@gmail.com>
Co-authored-by: Nicole Mazzuca <nicole@strega-nil.co>
2020-05-18 17:07:10 -07:00
Lena Hellström 2355e48a7b expose default options and serializers (#310)
Deprecate the old config system and make a refined version of the internal config system public. Doing allows the Serializer/Deserializer to be exposed since all of its generic type parameters are now public.
2020-04-16 15:23:07 -07:00
Lena Hellström 8839b0600d Modernize CI (#311)
Switches our CI from Travis-CI to Github Actions. At the same time this also turns on clippy and rustfmt linting.
2020-03-24 14:33:13 -07:00
jean-airoldie e2d8742743 Add contraints to {Serializer,Deserializer}Acceptor
This allows the user to retreive concrete types from the
serializer & deserializer output.
2020-01-23 09:23:48 +00:00
David Tolnay 6c4b23ce62 Release 1.2.1 2019-12-09 22:25:24 -08:00
Justin Starry 0215da2d29 Fix emscripten build failures due to lack of i128 support 2019-10-19 19:51:34 -04:00
Josh Matthews 293e9cea32 Release 1.2.0. 2019-09-24 14:16:47 -04:00
Josh Matthews d4d13aa37c Release 1.1.5. 2019-09-23 18:56:44 -04:00
David Tolnay 18da2c95d5 Release 1.1.4 2019-05-14 21:16:49 -07:00
David Tolnay 107a1930b5 Update documentation to 2018 edition 2019-04-30 01:18:32 -07:00
David Tolnay c954d3352c Remove unneeded ```rust from rustdoc 2019-04-30 01:15:01 -07:00
David Tolnay 0a67cf66e7 Release 1.1.3 2019-04-07 17:28:48 -07:00
David Tolnay f5af5b992b Define html_root_url 2019-02-16 11:28:17 -08:00
Diggory Hardy a04c750960 Make i128 support automatic for supporting Rustc versions
Uses autocfg
2019-01-28 09:59:18 -05:00
Jeff Muizelaar 20da2c841a Make config() inline(always)
Without this we end up generating code for all configs unless LTO is on.
2018-11-20 11:13:44 -05:00
Ty Overby d8704644d7 format 2018-09-04 16:25:10 -07:00
Ashley Mannix 2ef9a06894 add support for 128bit numbers 2018-05-30 09:44:38 -07:00
Ty Overby 72f002cc0a some comment fixes 2018-02-13 16:24:57 -08:00
Ty Overby 5081ac7c08 remove unused function type parameter 2018-02-07 20:23:07 -08:00
Ty Overby 24b007e194 public but hidden read types 2018-02-07 20:13:26 -08:00
Ty Overby 3c5b38097f hide with_deserializer and with_serializer 2018-02-07 19:46:25 -08:00
Ty Overby 76b7662dcd move to custom read implementation for deserialize_in_place 2018-02-07 19:39:27 -08:00
Ty Overby 68ca894b81 add deserialize_in_place 2018-02-07 18:32:10 -08:00
Ty Overby b31151a605 2nd implementation of the Config Trait (#214)
* add option and config traits

* thread options everywhere

* add WithOtherLimit, WithOtherEndian, and update internal to take advantage of it

* wip

* add rest of the public API and fix tests

* dtolnay feedback

* remove serialized_size_bounded and replace it with a use of config

* remove inline from trait method

* finish documentation and add custom reader support

* minor config_map refactor

* doc changes

* add with_(de)serializer functions and their associated modules
2018-02-07 18:26:46 -08:00
Ty Overby 47b66f55ce switched type parameter on deserializer 2017-10-13 17:44:36 -07:00
Ty Overby 251bbe22d4 remove _types from read module 2017-10-13 17:42:09 -07:00
Ty Overby 40889ec016 capitalize Bincode 2017-10-13 17:38:36 -07:00
Ty Overby 3a24da087b cargo fmt source 2017-10-13 08:57:04 -07:00
Ty Overby d04ba007dc remove references to old type (#210) 2017-10-11 09:53:45 -07:00
Ty Overby 62941544ea rename doc functions (#208)
* fix up docs
2017-10-10 16:41:27 -07:00
Ty Overby ab70e7d507 remove completely unused dependency 2017-10-10 10:32:18 -07:00
Lena Hellström 34aba9acbe Internal type names (#199)
* Remove internal type names from api

* Rename IoReadReader to IoReader
2017-07-23 21:57:53 -07:00
Lena Hellström 18bcfc420e Seal SizeLimit and BincodeRead 2017-07-22 14:37:08 -05:00
Ty Overby 6692674f43 WIP Implement nocopy support for bincode (#150)
* basic infrastructure

* use BincodeRead internally

* fix zero copy behavior

* rearrange module layout; remove pub(crate)

* add size-limit safety checks when deserializing str or bytes

* fix-up tests
2017-04-20 18:27:22 -07:00
David Tolnay 7eccffd783 Update to serde 1.0 branch (#149)
* Update to serde 1.0 branch

* The serde 1.0 branch merged
2017-04-19 16:05:59 -07:00
Ty Overby c6fa2358e5 add docs to everything that was undocumented 2017-03-20 17:32:55 -07:00
Ty Overby 539637d78b remove refbox (#140) 2017-03-19 20:10:35 -07:00
Ty Overby 2b465047b9 Eager prealloc no inline (#127)
* make SizeLimit a trait

* always preallocate
2017-03-17 18:14:59 -07:00
Ty Overby f4c97fde6a make SizeLimit a trait (#124)
* make SizeLimit a trait

* move inline to the correct location
2017-03-17 17:59:12 -07:00
Olaf Buddenhagen 5784fe28ad Fix unintentional breaking API change in `Serializer`/`Deserializer` (#128)
While introducing selectable endianness in
https://github.com/TyOverby/bincode/pull/103 , the new type parameter
has been hidden from the public `serialize()`, `deserialize()` etc.
functions, and only made available through an alternate API entry point.
The same kind of encapsulation also needs to be performed for the public
`Serializer` and `Deserializer` types.
2017-03-01 17:14:11 -08:00
Ty Overby 1631cb2d80 Make Reader and Writer generic on Endianness (#103)
* Make Reader and Writer generic on Endianness

* make alternate API modules

* add test asserting that big endian encoding is different from little endian encoding

* clean up tests
2017-02-24 18:58:46 -08:00
Ty Overby e7a74aa6c2 Remove rustc serialize support (#95)
* Remove rustc_serialize support

* Add changelist and bump version number for alpha

* Move refbox and friends into own module

* update changelog

* update travis config

* move serde functions out into global namespace
2017-01-31 15:50:55 -08:00
Ms2ger c7bdb4a90c Use num-traits. (#72) 2016-04-21 09:28:33 -07:00
Alexander Bulaev ff69e6f3e1 Add cargo features for rustc-serialize and serde (#70)
* Add cargo features for rustc-serialize and serde

If you only really need one of them

* Check that both "serde" and "rustc-serialize" are compiling

* Minor: change Travis build order
2016-04-15 11:03:32 -07:00
Brian Bowman 127380a506 fix typo 2016-04-07 03:05:41 -05:00
Ty Overby a63e80d75d add docs for the new modules 2015-08-07 23:16:35 -07:00
Ty Overby 0cfb64511c moved the two designs into modules 2015-08-07 17:35:27 -07:00
Ty Overby 9c6bf1aa41 remove unused code 2015-08-07 16:39:15 -07:00
Erick Tryzelaar 0d6b8a48b6 Get serde working 2015-07-29 13:15:04 -07:00
Erick Tryzelaar b206032ff1 Initial support for serde serialization 2015-07-01 15:21:26 -07:00
Erick Tryzelaar f11ba0c41f Move tests into the tests/ directory 2015-06-30 07:52:18 -07:00
Ty Overby e3837055d7 Removes the "bytes read" return part from `decode`
This reverts commit 5fa0c2bd8a.

Conflicts:
	Cargo.toml
2015-05-18 23:28:39 -07:00
Ty Overby 3d8f97923d strbox and slicebox 2015-05-02 03:52:27 -07:00
Ty Overby 5fa0c2bd8a Decoders return the number of bytes that they read
Closes #35
2015-05-01 09:17:18 -07:00
Ty Overby d87e7dad2d rustfmt 2015-04-29 23:26:58 -07:00
TyOverby 209b274062 remove dependency on the unicode library 2015-04-29 18:09:01 -07:00
Mohd Tarmizi 4e0f2457ac Fix rustdoc comment syntax
I also moved the comment block to the top of the file so that rustdoc won't throw "expected outer comment" error
2015-04-27 21:36:59 +08:00
Ty Overby 31572a2da5 remove use of the unicode library 2015-04-12 21:12:24 -07:00
Ty Overby cb3c84acd6 Merge branch 'master' of github.com:TyOverby/bincode 2015-04-12 21:04:29 -07:00
Ty Overby 92d6b95c2c remove reimplementation of read_exactly 2015-04-12 21:04:15 -07:00
TyOverby be66f5fed4 change wording of some docs 2015-04-07 13:35:11 -07:00
Ty Overby e5d0c33acd update for rustc 2015-04-02 12:24:05 -07:00
Mike Dilger a92429505a Update full slice syntax 2015-04-01 08:54:58 +13:00
Ty Overby 1bbd5377e3 rustup 2015-03-25 15:50:41 -07:00
Ty Overby 575002877b removed warnings 2015-03-23 10:36:29 -07:00
Cody P Schafer b9f201c792 Don't require BufRead, only Read
While BufRead is preferable to avoid dog-slow performance, requiring
when no methods are called is also problematic, especially for wrappers
around Read that shouldn't necessarily need to know they're wrapping
BufRead.
2015-03-02 17:23:10 -05:00
Ty Overby 5f85e9b19a Use new io, update for rustc changes 2015-02-21 21:42:59 -08:00
Ty Overby 28b5007731 mark new version 2015-02-21 21:05:30 -08:00
Ty Overby 6c6d92ef45 feature new_io 2015-02-20 08:48:48 -08:00
Ty Overby f5111f9476 Add RefBox.
RefBox is a structure for encoding references, and decoding them into
a box.  This makes it easy to nest structures that otherwise would not
be able to be nested and encoded.
2015-02-17 13:18:25 -08:00
Ty Overby 873815ab0a prepare for newio 2015-02-16 11:33:21 -08:00
Ty Overby b15b85797e added doc icon 2015-02-15 12:56:42 -08:00
Ty Overby 15e7672703 prepare for the new io library 2015-02-09 14:56:40 -08:00
Ty Overby 64a8877c55 add another test and change Show -> Debug 2015-02-05 01:18:44 -08:00
TyOverby 5952c3adb0 update for stdlib 2015-01-28 13:01:11 -08:00
TyOverby 0e044483ee Fix doc tests. 2015-01-16 13:25:55 -08:00
TyOverby aeaa4aafd4 Merge branch 'master' of github.com:TyOverby/bincode 2015-01-16 13:21:46 -08:00
TyOverby 89a6b007b1 add encoded_size function 2015-01-16 13:21:35 -08:00
Ty Overby 54061d5eff Add more documentation and a doc example 2015-01-13 13:37:53 -08:00
TyOverby 97e675ac06 Merge branch 'master' of github.com:TyOverby/bincode
Conflicts:
	src/writer.rs
2015-01-09 12:58:04 -08:00
TyOverby 6fe6e8d251 update for 1.0.0-alpha 2015-01-09 12:51:58 -08:00
Ty Overby c7ed0e106c `decode` takes a slice rather than a vec.
Also added comments for the main functions.
2015-01-08 23:32:21 -08:00
Ty Overby 08e726cb10 Added size checking on serialization.
Specifying a bound on serialization is optional, so when specified, it
will run a pass over the object and make sure that the serialized object
will fit into the required amount of bytes.
2015-01-08 22:32:59 -08:00
Ty Overby 23d8310f0b Fix size estimation of chars.
`char` in rust is 32-bits long, but is encoded using utf-8.  Previously,
bincode would assume the worst and say that chars are 4-bytes long
always, when in reality, they are often only 1 byte long.

This commit fixes that bug, adds a test for it, and does some general
cleanup in the library.
2015-01-08 11:05:12 -08:00
Francesco Mazzoli 7cd16ea194 More robust and precise error handling.
When decoding, decoding errors are now isolated from `IoError`s.
2015-01-08 04:02:19 +01:00
Ty Overby b4023f5281 Fix utf-8 handling when reading malformed messages. 2015-01-07 10:18:39 -08:00
Francesco Mazzoli cea4129b05 Remove stale comments. 2015-01-07 03:15:37 +01:00
Francesco Mazzoli 14f6b84c88 Update to the latest rustc-serialize 2015-01-07 02:23:05 +01:00
TyOverby bfbaeaacd1 added size-limits to all functions. Currently the size limits aren't actually enforced. 2015-01-05 11:19:08 -08:00
Ty Overby b873c9e75f added old_orphan_check feature to tests and examples 2015-01-03 15:06:43 -08:00
crhino 8f982f334e serialize crate has moved out of tree to rustc-serialize.
See commit b04bc5cc49
2014-12-24 12:25:57 -05:00
crhino 1219fe8cf0 Fix rustc warnings. 2014-12-15 23:15:19 -08:00
Ty Overby 4c6006dfb0 update tests to pass with new compiler 2014-11-20 12:08:47 -08:00
Ty Overby ed96883a53 changed project name to 'bincode' 2014-10-27 09:45:24 -07:00