* Added `[serde(tag)]` to the list of tags that are known to give issues
* Removed the old warning about serde and no-std. Added references to the documentation in the serde::DecodeError enum
This makes it match the implementation for Decode which is
already supports up to 16 fields.
Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
* 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
* Add impl Encode for [T], where T: Encode
Since Encode takes a reference, this allows us to encode &[T] directly
using this implementation. The encoding scheme is the same as for
Vec<T>.
This also makes the implementation for &[u8] superfluous, since we get
an implementation for [u8] by virtue of u8 implementing encode. This
also gives us free implementations for &[u16], &[u32], etc. which is
quite useful. Nonetheless, we keep the implementation for &[u8] around,
because the implementation can directly write a large number of bytes,
which can be more efficient than the generic implementation.
* Remove redundant Encode implementations
Since we've implemented Encode for [T], this makes the implementation
for Box<[T]> redundant (since we have a blanket implementation for
Box<T>), and ditto for &[T], which this change replaces by combining the
implementations for [T] and &T.
* Reinclude comment about Encode specialization for &[u8]
* 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
* 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
* 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>
* 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>
* 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
* Made the compat fuzzer ignore any LimitExceeded error
* Switched from deserialize to deserialize_from
Co-authored-by: Victor Koenders <git@trangar.com>
* 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
* 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]
* 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
* 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>
* 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