Lena Hellström
cbad043a53
Fix CString compatibility with bincode v1 ( #502 )
2022-02-06 10:36:03 +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
20e4a02ea3
Added #[serde(untagged)] to the documentation of attributes that don't work ( #486 )
2022-01-23 10:05:54 +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
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
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
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
4be23b88de
Added Decode/Encode for HashMap<K, V> ( #438 )
2021-11-22 15:18:58 +01:00
Trangar
c4fd7efa49
Release 2.0.0-alpha.1 ( #435 )
2021-11-09 10:15:12 +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
Trangar
73616a3d62
Made the zigzag encoding examples compile and run ( #421 )
...
Made the zigzag encoding examples compile and run
2021-10-25 11:24:50 +02:00
Trangar
0c13c891c5
Updated readme.md and added a test for the examples ( #417 )
...
* Updated readme.md and added a test for the examples
* Removed tests/readme.rs and made the readme doctest a (hidden) part of lib.rs
2021-10-25 10:26:23 +02:00
Victor Koenders
382b2c7a8f
Fixed clippy lint, removed function that was only used in 1 place
2021-10-24 18:06:16 +02:00
Lena Hellström
99de47a6c8
Reintroduce varint optimizations
2021-10-24 16:44:36 +02:00
Lena Hellström
62b8f39f8f
Optimize performance of decoding u8 arrays
2021-10-22 14:47:44 +02:00
Lena Hellström
539906f441
Optimize performance of slice writing
2021-10-22 14:47:05 +02:00
Victor Koenders
bd994e354d
Updated documentation of Encode, added an example to lib.rs
2021-10-21 14:45:16 +02:00
Victor Koenders
dae645f675
Joined the 2 Sealed traits into a single one
2021-10-21 14:27:03 +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
Victor Koenders
dd7e8e8e43
Changed bincode version to 2.0.0-alpha.0
2021-10-21 13:39:45 +02:00
Victor Koenders
adc47b6895
Fixed a copy-paste error where RwLock would report to be a Mutex if it fails to lock
2021-10-21 13:31:13 +02:00
Victor Koenders
f70e94a427
Added dedicated error for `std::path::Path` encoding. Fixed broken link in documentation.
2021-10-21 13:29:03 +02:00
Victor Koenders
6ff33cd8c2
Replaced the decode implementation of [T; N] with the implementation from core
2021-10-21 12:54:37 +02:00
Victor Koenders
07b3c8cd76
Made the Decode of [T; N] properly drop all instances of T when an error has occured
2021-10-21 11:57:24 +02:00
Victor Koenders
151edf46d3
Included spec.md into cargo's documentation, fixed the issues, changed the [u8; N] implementations to [T; N]
2021-10-21 11:57:16 +02:00
Victor Koenders
4b25114c59
Processed some of the feedback
2021-10-18 10:18:47 +02:00
Lena Hellström
684f2562b1
Config rewrite ( #412 )
...
Rewrite the config system to be slightly more friendly to adding new options
2021-10-17 21:07:31 +02:00
Victor Koenders
2fd2a8d8e2
Made the varint decode_signed module report the correct errors
2021-10-17 17:23:44 +02:00
Victor Koenders
02a9b2cb71
Made the test stage throw an error on warnings
2021-10-17 17:23:28 +02:00
Victor Koenders
4807ea6be2
Added warning on unused lifetimes, fixed warnings
2021-10-17 16:43:18 +02:00
Lena Hellström
e232454936
Refactor and rename encoders
2021-10-17 16:22:14 +02:00
Victor Koenders
61c1e8a7cd
Added badges to the functions to indicate which features they require
2021-10-17 15:00:14 +02:00
Victor Koenders
1f261cede3
Added support for atomic integers
2021-10-16 14:49:18 +02:00
Victor Koenders
8ab730eb87
Added support for IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6
2021-10-16 14:28:06 +02:00
Victor Koenders
a0469e08ef
Added support for NonZero* types
2021-10-16 14:14:15 +02:00
Victor Koenders
9420d03762
Added support for Range<T>, RangeInclusive<T> and Bound<T>
2021-10-16 13:59:48 +02:00
Victor Koenders
26d7683719
Added support for Path and PathBuf
2021-10-16 13:47:48 +02:00
Victor Koenders
acbd385649
Added core::time::Duration and std::time::SystemTime
2021-10-16 13:32:12 +02:00
Victor Koenders
9cf577d9bc
Added support for String, Mutex<T> and RwLock<T>
2021-10-16 13:19:30 +02:00
Victor Koenders
33dd4f761d
Added support for CStr and CString
2021-10-16 12:59:38 +02:00
Victor Koenders
a322e0f1b3
Added support for BinaryHeap, BTreeMap, BTreeSet and VecDeque
2021-10-16 12:21:52 +02:00
Victor Koenders
4e1a72796c
Added support for Cow, Rc and Arc
2021-10-16 12:08:29 +02:00
Victor Koenders
1d6379e715
Added support for Cell and RefCell
2021-10-16 12:04:23 +02:00
Victor Koenders
07f49e878e
Added support for Vec<T>, Box<T> and Box<[T]>
2021-10-16 11:41:59 +02:00
Victor Koenders
82924aa96e
Added support for Option<T> and Result<T, U>
2021-10-16 11:03:25 +02:00
Victor Koenders
960b6066cd
Added an option to encode a fixed array length or to skip it
2021-10-14 21:31:47 +02:00
Victor Koenders
19fed15463
Added support for tuples with up to 8 values
2021-10-14 20:33:03 +02:00
Victor Koenders
e4e12c984b
Added support for the bool type
2021-10-14 19:34:35 +02:00
Victor Koenders
c4cb220fb2
Added support for char encoding/decoding
2021-10-14 19:28:28 +02:00
Victor Koenders
b480d2b3b3
Added documentation for the src/ module. Added warning for missing docs, fixed missing docs in src/de/mod.rs
2021-10-14 18:04:13 +02:00
Victor Koenders
7b85fc168e
Added documentation for the src/featyres module
2021-10-14 18:01:41 +02:00
Victor Koenders
bb98b8fcbd
Added documentation for the src/enc module
2021-10-14 17:59:23 +02:00
Victor Koenders
ea75220cd0
Added documentation for the src/de module
2021-10-14 17:30:52 +02:00
Victor Koenders
84344af2c6
Removed unneeded Config trait constraints
2021-10-12 18:23:39 +02:00
Victor Koenders
a8680ce1d8
Started working on documentation
2021-10-12 18:18:43 +02:00
Victor Koenders
c969622384
Added alloc and std tests
2021-10-12 16:13:21 +02:00
Trangar
a27b63b7fa
Make bincode_derive 0 dependencies ( #409 )
...
Removed `syn`, `quote` and `proc_macro2` dependency
2021-10-12 15:53:02 +02:00
Victor Koenders
8e99d580b8
Removed `allow` attributes, fixed some warnings
2021-09-26 09:19:39 +02:00
Lena Hellström
044942891f
Clean up the borrow crimes
2021-09-22 22:17:26 +02:00
Victor Koenders
254b87c6eb
Moved all feature flags to src/features, made the CI run tests on all feature combinations
2021-09-22 16:23:27 +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
ffb565c405
Added config options for endian and int_encoding, added full coverage for all basic integer types
2021-09-22 10:40:27 +02:00
Victor Koenders
78cb27f782
Added decode_ fns
2021-09-22 09:59:13 +02:00
Lena Hellström
c83c36333d
Add enum encode/decode derive
2021-09-20 23:06:25 +02:00
Lena Hellström
e414cabd33
Add derive for Decodeable
2021-09-20 16:35:36 +02:00
Victor Koenders
f914b3e580
Added unit tests for encode_signed
2021-09-19 11:24:42 +02:00
Victor Koenders
1313e989ad
Added unit tests for decoding errors
2021-09-19 11:02:33 +02:00
Victor Koenders
ca353b9882
Added decode_unsigned
2021-09-19 10:53:07 +02:00
Victor Koenders
ccca6ee49e
Split Error into EncodeError and DecodeError
2021-09-19 10:52:21 +02:00
Victor Koenders
723bdd312a
Turned Config::INT_ENCODING back into a const, made a ton of varint_encode functions
2021-09-19 09:25:47 +02:00
Victor Koenders
7448b7bb87
Moved Encoder to its own file
2021-09-19 08:34:14 +02:00
Victor Koenders
6802edc625
Renamed blob to slice
2021-09-19 08:30:28 +02:00
Victor Koenders
8a4eac82fb
Made the encoder respect intencoding, implemented FixintEncoding
2021-09-19 08:28:38 +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