Commit Graph

136 Commits

Author SHA1 Message Date
Trangar e0e5402094 Fixed broken commit to trunk (#687)
Co-authored-by: Victor Koenders <victor.koenders@qrtech.se>
2023-12-15 08:08:38 +01:00
mzachar 67564d2bd4 Implement Encode & Decode for Wrapping<T> types (#686)
* Implement Encode & Decode for Wrapping<T> types

* Implement Encode & Decode for Reverse<T> types
2023-12-15 06:45:27 +00:00
xiang 7344ad0c85 Add missing test for encode_utf8 (#683)
* Add missing test for encode_utf8

* Fix CI error by only run under std

* Merge test into testing framework for utf8 testing

---------

Co-authored-by: cxworks <cxworks@qq.com>
2023-12-11 09:06:15 +01:00
Lorenzo 4933019c44 Compat and BorrowCompat Debug and Display implementations (#670)
* feat: added Display and Debug implementations for Compat and BorrowCompat

* chore: added Compat and BorrowCompat Display and Debug tests

* chore: fixed imports and linter errors
2023-10-21 12:53:43 +02:00
Trangar fb2c928c70 Fix inconsistent naming between serde and non-serde functions (#671)
* Fix inconsistent naming between serde and non-serde functions

* Updated references from old deprecated function

---------

Co-authored-by: Victor Koenders <git@trang.ar>
2023-10-15 15:03:09 +02:00
Trangar 70fefd6dcc Reverted 'static constraint on T in Vec<T> and [T; N] (#663) 2023-09-19 14:58:49 +02:00
Trangar dc468b4bed Made arrays never encode their length (#625)
* Made arrays with 32 elements or less never encode their length

* Removed `write_fixed_array_length` and `skip_fixed_array_length` as this was based on incorrect assumptions on how serde and bincode 1 works

---------

Co-authored-by: Victor Koenders <victor.koenders@qrtech.se>
2023-03-30 15:09:33 +02:00
Trangar a6a5c41038 Bumped virtue to 0.0.13 (#626)
Co-authored-by: Victor Koenders <victor.koenders@qrtech.se>
2023-03-30 13:08:23 +02:00
Trangar 3aa269bfea Fixed new clippy warnings (#617)
* Fixed new clippy warnings

* Undid breaking all the tests

* Fixed more clippy warnings

---------

Co-authored-by: Victor Koenders <git@trang.ar>
2023-03-30 11:06:34 +02:00
trevyn 966c45544f Encode variant index instead of variant value (#593) 2022-10-18 11:56:53 +02:00
trevyn 620078dc8b Bump `virtue` to 0.0.9 and add test for #537 (#591) 2022-10-08 14:31:40 +02:00
Trangar e3f7d5340e Prefixed the E and D generic argument in bincode-derive (#573) 2022-08-18 19:01:30 +02:00
Trangar 974abe8661 Fixed the clippy Eq warning. (#574)
Added DecodeError::Io
Removed `PartialEq` on DecodeError
2022-08-18 15:57:18 +02:00
Maciej Hirsz bd07adea66 Shrink `DecodeError` from 48 to 32 bytes on 64-bit arch (#553)
* Shrink `DecodeError` to 32 bytes on 64-bit arch

* Nul with a single l

* fmt

* Consider feature combinations for error sizes

* Remove superfluous `any`

* fmt

* Box SystemTime in EncodeError
2022-06-15 20:50:09 +02:00
Maciej Hirsz 229b597a84 Add impls for Rc<[T]> and Arc<[T]> (#552) 2022-06-15 07:47:26 +02:00
Trangar 86e03aeda7 Rewrite: seperated Decode and BorrowDecode (#526)
* Rewrite: seperated Decode and BorrowDecode

* Fixed cargo.toml issues

* Fixed clippy warning

* Removed the `impl_tuples` macro call with manually exported code

* Replaced the generated code in `impl_tuples` with the macro instead

* Implemented BorrowDecode for Box<[T]>

* Added a test to see if zoxide can be ported to bincode 2

* Added a test for Arc<str>

* Made several `Encode` implementations require `T: ?Sized`

* Implemented Decode for Arc<str>

* Added BlockedTODO links to commented out code

* Fixed clippy and lint issues

* Updated virtue dependency in fuzz lockfile
2022-06-04 15:23:55 +02:00
Lena Hellström f979383adb Fix tuple struct encoding in serde (#549) 2022-06-04 14:56:20 +02:00
Trangar e7d2292dc2 Switched to weak dependencies (#538)
* Switched to weak dependencies

* Removed old `serde_impl` references

* Fixed CI and updated documentation

* Fixed a cfg for a test

* Removed unneeded package in Cargo.toml
2022-05-21 14:19:13 +02:00
Trangar 8bfa9a376f Fix cross platform tests (#540)
* Fixed cross platform targets

* Uncommented not working archs, with a reason why they fail

* Removed duplicate windows test

* Commented the other sun system

* Commented out i686-pc-windows-gnu

Co-authored-by: Victor Koenders <git@github.com>
2022-05-21 14:04:29 +02:00
Sean Cross d7edfaa0b7 Fix riscv32 atomics and fix tests on 32-bit platforms (#533)
* tests: fix alloc range test on 32-bit Windows

This test checks the range, which is necessarily different when running
on another platform.

Signed-off-by: Sean Cross <sean@xobs.io>

* enc: case usize/isize as u64/i64 in serialization

The deserialization process assumes that usize/isize are 64-bits, as
does the spec at
https://github.com/bincode-org/bincode/blob/trunk/docs/spec.md#varintencoding

Force `usize` and `isize` to be encoded as `u64` and `i64` to force
32-bit platforms to conform to this spec.

This fixes running tests under `cargo test --target i686-pc-windows-msvc`

Signed-off-by: Sean Cross <sean@xobs.io>

* atomic: only provide Atomic*64 on supported platforms

Not all platforms support AtomicI64 or AtomicU64. Use the
`target_has_atomic` config flag to determine whether to include these.

This fixes #532.

Signed-off-by: Sean Cross <sean@xobs.io>

* atomic: remove feature and use new attributes

Now that there is an attribute to indicate which atomic features are
supported on this platform, remove the `atomic` Feature and use these
new attributes.

Signed-off-by: Sean Cross <sean@xobs.io>

* alloc: run `cargo fmt`

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-08 11:35:13 +02:00
Trangar 883278fa0c Added cross platform tests workflow (#534)
* Added cross platform tests

* Added all cross platforms

* Fixed an issue where `usize` and `isize` would be encoded wrong on 32 bit platforms

* Made the cross platform tests actually run on the platforms

* Disabled cross targets that don't build right now

* Fixed a failing test on 32 bit platforms, re-enabled all platforms for testing

* Disabled failing platforms
2022-04-04 14:09:42 +02:00
Bronson Philippa 49c8d1148f Extended Encode and Decode for HashMap and HashSet to support custom hashers (#529) 2022-03-28 12:19:33 +02:00
Trangar a7fba80e23 Made the Cow Encode constraints more permissive (#524)
* Made the Cow Encode constraints more permissive

* Made Decode more permissive for Cow
2022-03-17 11:31:22 +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
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
Lena Hellström cbad043a53 Fix CString compatibility with bincode v1 (#502) 2022-02-06 10:36:03 +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
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 d13d177bea made the serde functions consistent with the base bincode functions (#483) 2022-01-19 18:57:52 +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 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
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 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 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 7690da5203 Made the derive macros automatically implement the required traits on generic arguments (#454) 2021-12-14 15:18:13 +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 7cb10d4ab3 Added test case for a borrowed str (#441) 2021-12-02 11:44:08 +01:00
Trangar 4be23b88de Added Decode/Encode for HashMap<K, V> (#438) 2021-11-22 15:18:58 +01:00
Trangar ad7ddebff3 Allow serde types to be Decode/Encoded (#434)
* Added support for #[bincode(serde)] attribute on fields, added SerdeToBincode helper struct

* Switch to using Compat/BorrowCompat

* Moved all the serde features and functions to its own module

* Fix broken link

* Added support for the bincode(with_serde) attribute in enum variants

* Updated the main documentation on serde, fixed an example not compiling under certain feature flag combinations

* Added #[serde(flatten)] to the list of problematic attributes

* Added better error reporting on invalid attributes
2021-11-09 10:08:47 +01:00
Trangar 8c1279feab functions to enable encoding/decoding serde types (#422)
* functions to enable encoding/decoding serde types
* Removed dev feature I forgot to remove
* Centralized option variant and len() decoding/encoding
2021-11-08 12:38:29 +01:00
Trangar cc13be30d4 split off BorrowDecode from Decode in bincode_derive (#432)
* split off BorrowDecode from Decode in bincode_derive

* Added test case for issue #431

* Fixed Cow implementation having the wrong constraint, added BlockedTODO for cow implementation specialization

* Re-exported the Decode and Encode traits in the crate root

* Removed outdated comments

* Removed some :🇩🇪:Decode that were introduced by the merge
2021-11-07 10:57:35 +01:00
Trangar b4c46a789a Fixes for 427 (#428)
* Made bincode_derive handle empty lines of docs correctly
* Made bincode_derive properly support const generics
* Added support for enums with variants with fixed values
2021-11-07 10:31:15 +01:00
Lena Hellström 99de47a6c8 Reintroduce varint optimizations 2021-10-24 16:44:36 +02:00
Victor Koenders 707d0d238f Made all encode and decode functions always require a Config, removed _with_config functions 2021-10-21 14:19:40 +02:00