Commit Graph

34 Commits

Author SHA1 Message Date
Trangar a27b63b7fa Make bincode_derive 0 dependencies (#409)
Removed `syn`, `quote` and `proc_macro2` dependency
2021-10-12 15:53:02 +02:00
Lena Hellström 044942891f Clean up the borrow crimes 2021-09-22 22:17:26 +02:00
Lena Hellström 4b672de110 Enable non-slice readers 2021-09-22 15:08:52 +02:00
Victor Koenders 9c7fb85e0e Added support for slices, str, fixed size arrays. Added lifetime to Decode trait 2021-09-22 12:03:00 +02:00
Victor Koenders 78cb27f782 Added decode_ fns 2021-09-22 09:59:13 +02:00
Lena Hellström e414cabd33 Add derive for Decodeable 2021-09-20 16:35:36 +02:00
Victor Koenders ccca6ee49e Split Error into EncodeError and DecodeError 2021-09-19 10:52:21 +02:00
Victor Koenders bab0cf4bd1 Started working on bincode_derive 2021-09-13 13:20:47 +02:00
Lena Hellström b7c0d1fac0 reorganize de/enc modules 2021-06-20 00:12:10 +02:00
Lena Hellström e160c73acb a fresh new start 2021-06-19 19:31:34 +02:00
Lena Hellström e39a047b4b prep branch for 2.0 work (#379)
* prep branch for 2.0 work

* switch to 2018 edition

* fix clippy issues

* fix tests

* fix warnings

* fix formatting
2021-04-08 14:54:31 +02:00
Alyssa Ross 4a57853a3b Fix Deserializer::{from_slice, with_reader} types (#332)
Having these in the impl block with a generic R paramter would make
them unusable, at least without type annotations:

    error[E0282]: type annotations needed
      --> msg_socket2/src/socket.rs:45:32
       |
    45 |         let mut deserializer = Deserializer::with_reader(bytes.as_slice(), DefaultOptions::new());
       |                                ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `R`

    error: aborting due to previous error

    For more information about this error, try `rustc --explain E0282`.

Moving these into separate impl blocks, which set the type of the
Deserializer to the return type of the functions, fixes this error.
2020-06-23 10:47:00 -07:00
Lena Hellström e80f61b9da Reject trailing bytes (#198) 2020-05-26 12:40:04 -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
Leonard Kramer c48a064bad Fix compile warnings caused by deprecated macros. 2020-01-23 09:25:41 +00:00
Justin Starry 0215da2d29 Fix emscripten build failures due to lack of i128 support 2019-10-19 19:51:34 -04:00
David Tolnay c954d3352c Remove unneeded ```rust from rustdoc 2019-04-30 01:15:01 -07:00
Diggory Hardy a04c750960 Make i128 support automatic for supporting Rustc versions
Uses autocfg
2019-01-28 09:59:18 -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 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
Markus Westerlind 7464ba7272 Allow serialized types to use a more compact representation ... (#217)
... by utilizing that bincode is not human readable.

Uses the changes in https://github.com/serde-rs/serde/pull/1044 which
allows data formats to report that they are not human readable. This
lets certain types serialize themselves into a more compact form as they
know that the serialized form does not need to be readable.

Closes #215

BREAKING CHANGE

This changes how types serialize themselves if they detect the
`is_human_readable` state.
2017-11-20 09:55:34 -08:00
Ty Overby 1cc66df1d5 add documentation to utf8_char_width 2017-10-13 17:58:53 -07:00
Ty Overby 1cf9a0eb56 fix doc comment for deserializing function 2017-10-13 17:48:55 -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 c8f02e30aa 177 invalid encodings (#212)
* split out invalid encoding errors

* detail breaking changes
2017-10-12 09:04:14 -07:00
Ty Overby 45e70e297e add ErrorKind::DeserializeAnyNotSupported (#211) 2017-10-11 10:38:35 -07:00
Ty Overby a135fd44dc uncapitalize error messages (#209) 2017-10-11 09:53:36 -07:00
Thomas Schaller f20770a09f Correct error message
Spotted the mistake while skimming over the code.
2017-09-10 17:25:32 +02:00
Ty Overby cb7e9f87eb fix buffer length bug 2017-04-20 22:11:28 -07: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