Commit Graph

44 Commits

Author SHA1 Message Date
Ross Lannen 6c1b0cd2c7 Implement core::error::Error for error types. (#780) 2025-05-09 07:40:37 +02:00
Richard Pringle 8f3f84ae94 Use const functions where possible (#684) 2023-12-14 11:56:51 +01: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
odysa cbf4d46073 feat: add DecodeError::Other (#602) 2022-11-21 13:33:52 +01: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
Trangar 36e45d26eb Added `std::error::Error::source` (#530) 2022-04-04 13:58:18 +02:00
Trangar 6693276e95 Added `additional` to the `UnexpectedEnd` decode error (#522) 2022-03-17 11:40:10 +01:00
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 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 c1e9828e7d Implemented the newly stabilized CString::from_vec_with_nul method (#473) 2022-01-13 20:52:51 +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 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
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 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 f70e94a427 Added dedicated error for `std::path::Path` encoding. Fixed broken link in documentation. 2021-10-21 13:29:03 +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 a0469e08ef Added support for NonZero* types 2021-10-16 14:14:15 +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 1d6379e715 Added support for Cell and RefCell 2021-10-16 12:04:23 +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 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 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
Victor Koenders 9c7fb85e0e Added support for slices, str, fixed size arrays. Added lifetime to Decode trait 2021-09-22 12:03:00 +02:00
Lena Hellström c83c36333d Add enum encode/decode derive 2021-09-20 23:06:25 +02:00
Victor Koenders ccca6ee49e Split Error into EncodeError and DecodeError 2021-09-19 10:52:21 +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
Leonard Kramer 3a3857ff38 Remove dyn 2020-01-23 09:25:41 +00:00
Leonard Kramer c48a064bad Fix compile warnings caused by deprecated macros. 2020-01-23 09:25:41 +00:00
Ty Overby d8704644d7 format 2018-09-04 16:25:10 -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