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.
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).
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>
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.
* 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
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.
* 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
* 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
* 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
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.
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.
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.
`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.