Commit Graph

550 Commits

Author SHA1 Message Date
Trangar fe611f77c0 Release 2.0.0-rc.1 (#510) 2022-03-04 11:05:38 +01:00
Trangar 4d2e75e247 Made the compat fuzzer ignore any LimitExceeded error (#515)
* Made the compat fuzzer ignore any LimitExceeded error

* Switched from deserialize to deserialize_from

Co-authored-by: Victor Koenders <git@trangar.com>
2022-03-03 15:44:28 +01:00
Trangar caa71b5d9f Added HashSet (#516)
* Added HashSet

* Added hashset to the same tests that hashmap has
2022-03-03 15:23:53 +01:00
Trangar 03450ac49f Made config::standard() implement .write_fixed_array_header() by default (#509)
* Made config::standard() implement .write_fixed_array_header() by default

* Fixed failing unit test

* Fixed formatting
2022-02-28 17:26:46 +01:00
Pietro 1c5041390f Add reference implementation for Writer and remove unnecessary lifetimes from Reader's one (#507) 2022-02-23 11:08:28 +01:00
Trangar 7c72e4c1fa Release v2.0.0-beta.3 (#505) 2022-02-16 12:53:44 +01:00
Pedro Paulo Amorim 610b44d57f Add Membership test (#500)
* Add membership type

* Update README.md

* Update README.md

* Resolve missing info

* Restore README

* Fix trailing line

* Fix range

* Fixed formatting

Co-authored-by: Trangar <gpg@trangar.com>
2022-02-07 17:02:16 +01:00
Trangar 58dc788dfa Fix/issue 500 (#503)
* Fixed an issue where serde would decode a sequence with an u32 instead of a usize

* Added serde to the `the_same` test for roundtrips, fixed several issues.

* Fixed backwards compatibility for result, ipv4addr and ipv6addr

* Processed feedback
2022-02-07 16:52:15 +01:00
5225225 da94b7aaf9 Fuzz for compatibility with bincode v1 (#498)
* Fuzz for compatibility with bincode v1

* Make AllTypes recursive

* Revert round trip test (add recursion to it too)

* Update fuzzer lockfile

* Adjust compat fuzzer to be stricter

* data doesn't need to be a &&[u8]
2022-02-07 16:36:41 +01:00
Lena Hellström cbad043a53 Fix CString compatibility with bincode v1 (#502) 2022-02-06 10:36:03 +01:00
Trangar a8bdffa844 Made the compatibility check also include bincode 2 serde, and added comments (#501)
* Made the compatibility check also include bincode 2 serde, and added comments

* Added a CI step to run the compatibility tests
2022-02-06 09:50:16 +01:00
Trangar bef1f47f0f Added documentation on how to add compatibility tests (#497)
* Added documentation on how to add compatibility tests

* Fixed grammar issues
2022-02-02 09:40:38 +01:00
Trangar 00eea110d7 Bincode 1 compatibility framework (#489)
* Added a basic compatibility test to compare bincode 1 and bincode 2 output

* Moved compatibility to the /compatibility/ crate, made bincode-derive support `#[bincode(crate = "bincode_2")]`

* Added decode/deserialize test to test_same

* Added random test cases to compatibility/src/sway.rs

* Added test for bincode_1::options().with_fixint_encoding() and bincode_2::config::legacy(). Added rand license

* Added comments on why the configs are chosen
2022-02-01 14:15:15 +01:00
Trangar 9535e7b5da Bumped dependency of virtue to 0.0.7 (#495) 2022-02-01 14:10:09 +01:00
Trangar d4e7915c17 Updated to virtue 0.0.6, added #[bincode(crate = other)] attribute (#494)
* Updated to virtue 0.0.6, added #[bincode(crate = other)] attribute

* Simplified the ContainerAttributes and FieldAttributes
2022-01-31 19:46:57 +01:00
poljar d90f501872 Return an error if a decoded slice length doesn't fit into usize (#491)
* Return an error if a decoded slice length doesn't fit into usize

Bincode encodes a slice length, which is an usize, as an u64. When such
an encoded slice length needs to be decoded it again uses an u64 but
critically it truncates it into an usize.

An usize is architecture dependent, it is the size how many bytes it takes to
reference any location in memory. The most common sizes for an usize are 64, 32,
and 16 bit.

This might lead to silent data loss if the architecture that encoded the
slice differs from the architecture that decoded the slice, i.e. if we
go from a 64 bit architecture to a 32 or 16 bit one.

Since bincode aims to be suitable for storage, aiming to support the
exchange of data between different architectures silently truncating
such slice lenghts should be avoided.

This patch changes the behaviour to error out if we try to decode an
slice lenght that can't fit into the current usize type.

* Remove another two usize truncations

* Rename the error variant if the usize doesn't fit anymore

Co-authored-by: Trangar <victor.koenders@gmail.com>
2022-01-25 17:49:26 +01:00
poljar 306a772835 Fix a bunch of typos (#492) 2022-01-25 12:13:38 +01:00
Trangar 3c64d7dbbe Added a table to the documentation to pick which functions to use (#490)
* Added a table to the documentation to pick which functions to use

* Forgot cargo fmt

* Added a line on custom readers and writers
2022-01-24 16:45:41 +01:00
Trangar 25dd4debc4 Release v2.0.0-beta.2 (#488) 2022-01-23 10:15:00 +01:00
Trangar d0fd1a98cd Fixed an error in bincode derive where it would implement the wrong trait if a generic parameter is present (#487)
* Fixed an error in bincode derive where it would implement the wrong trait if a generic parameter is present

* Reorganized the derive tests, added a roundtrip test for an enum with generics

* I didn't forget cargo fmt I swear

* Simplified some paths
2022-01-23 10:10:36 +01:00
Trangar 20e4a02ea3 Added #[serde(untagged)] to the documentation of attributes that don't work (#486) 2022-01-23 10:05:54 +01:00
Lena Hellström 6293dab41b Update code coverage pipeline (#485) 2022-01-19 20:34:21 +01:00
Trangar 09e7a6265d Release v2.0.0-beta.1 (#484) 2022-01-19 19:11:35 +01:00
Trangar a00f37ee59 Migration guide (#482)
* Added a guide on how to migrate from bincode 1 to 2

* Removed unneeded dependency on bincode 1

* Processed feedback

* Added a link to the migration guide, added `#[cfg(doc)]` to the doc modules
2022-01-19 19:04:20 +01:00
Trangar d13d177bea made the serde functions consistent with the base bincode functions (#483) 2022-01-19 18:57:52 +01:00
Trangar fc1f3acdcb Feature/improve serde (#477)
* Made serde able to be used with alloc and no_std targets

* Processed feedback
2022-01-19 18:14:21 +01:00
Trangar 59b787cbf8 Moved Configuration::standard() and ::legacy() to the config module (#481)
* Moved Configuration::standard() and ::legacy() to the config module

* Fixed issue with config that would overwrite the limit, added a checklist on adding config variables
2022-01-19 16:46:25 +01:00
Trangar a5e57d51d8 Update documentation (#480)
* Updated documentation

* Updated spec.md
2022-01-18 15:17:58 +01:00
Trangar f3c21f2245 Made SerdeDecoder attempt to allocate a string before complaining about being able to decode borrowed data (#475) 2022-01-17 17:16:14 +01:00
Trangar c1e9828e7d Implemented the newly stabilized CString::from_vec_with_nul method (#473) 2022-01-13 20:52:51 +01:00
Lena Hellström 8106eadf66 Switch Encode to take &mut E (#471) 2022-01-13 12:26:09 +01:00
Trangar 4149c0f29f Switched Decode and BorrowDecode to take &mut D (#470)
* Switched Decode and BorrowDecode to take &mut D, fixes #467

* I didn't forget to run cargo fmt, you did
2022-01-11 20:23:31 +01:00
5225225 4450fd40a4 Add fuzzing harness, try to decode into various types (#468)
* WIP adding fuzzing

* Check for round trips (BinaryHeap isn't PartialEq)

* Expand globs

* Rename fuzzing target
2022-01-10 19:17:24 +01:00
5225225 39ba03b2e5 Fix panic with invalid system time (#469) 2022-01-09 14:54:51 +01:00
5225225 236d350f13 Fix overflow error when deserializing invalid Duration (#465)
* Fix overflow error when deserializing invalid Duration

* Use unwrap_err instead of match in test
2022-01-08 22:54:04 +01:00
Trangar a08e528cc7 Release v2.0.0-beta.0 (#464) 2022-01-08 15:42:49 +01:00
Trangar 99707d0d0b Fixed derive impl on an empty enum (#462)
* Fixed derive impl on an empty enum

* Added DecodeError::EmptyEnum in case a user tries to decode an empty enum
2022-01-08 12:39:03 +01:00
Trangar 030905e7d5 Bump virtue 0.0.4 (#463)
* Updated breaking virtue changes in preperation of virtue 0.0.4 release

* Added contents of derive.rs test_macro_newtype
2022-01-08 12:11:24 +01:00
Trangar 5e9186ea8f Updated readme for bincode 2. Added a paragraph on why we don't support #[repr(u8)] (#461) 2022-01-03 19:53:12 +01:00
ygf11 f2d2fc05a8 Fix varint bench failed (#457) 2021-12-22 17:38:57 +01:00
Popog dbb9a43ccd feat: Make `Configuration` functions `const` (#456) 2021-12-16 09:53:15 +01:00
Trangar 45c0fa7782 Release v2.0.0-alpha.2 (#455) 2021-12-14 15:27:40 +01:00
Trangar 7690da5203 Made the derive macros automatically implement the required traits on generic arguments (#454) 2021-12-14 15:18:13 +01:00
Trangar a5255465bd Made the CI also check the benchmarks, fixed compile issue in benchmarks (#449) 2021-12-11 16:09:23 +01:00
Trangar 0ee07c3212 Extract virtue (#443) 2021-12-11 15:58:49 +01:00
Trangar 404946f12b [Breaking change] Made all `decode_from_slice` also return the number of bytes read (#445) 2021-12-11 15:51:50 +01:00
Trangar 63f4607992 Feature/config limit (#439)
* Added Limit<N> and NoLimit to the configuration
* Added a limit check to Decoder and DecoderImpl
* Added test cases, added a helper function specialized for containers
* Added a test to see if inlining makes the limit config faster, added inlining to the decoder
2021-12-11 15:44:43 +01:00
李冬冬 ed57fd0810 Impl BorrowDecode for Option<&[u8]> and Option<&str> (#446)
Co-authored-by: Trangar <victor.koenders@gmail.com>
2021-12-10 19:50:24 +01:00
Trangar bb3612103a Fixed clippy warnings (#447) 2021-12-10 17:39:35 +01:00
Trangar 7cb10d4ab3 Added test case for a borrowed str (#441) 2021-12-02 11:44:08 +01:00