Commit Graph

389 Commits

Author SHA1 Message Date
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
Taehyung Lim 0d046e7b0e fix typo (#392) 2021-06-13 13:25:37 -07: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
Lena Hellström 810086e473 fix linting ci error (#377) 2021-02-23 12:09:15 -08:00
Manu c1b91d5a74 Fixed a stray comment. (#360) 2021-02-23 05:48:04 -08:00
Andy Goetz 5d6dfa1fb9 Update docs to highlight differences between DefaultOptions and functions (#373)
Due to historical reasons, the default options used by bincode for the
helper functions at the root of the crate differ from the options in
the `config` module.

Changing the default options is a breaking change, so until a decision
is made, we can at least document the current behavior.
2021-02-23 05:33:55 -08:00
luben karavelov 5a134cf991 Fix `WithOtherTrailing` and `WithOtherIntEncoding` (#342)
They should be Copy/Clone as the rest of the Options

Closes #341
2020-07-20 10:22:30 -07:00
Lena Hellström 00c43bf3b1 fix logic error in fill_buffer (#336) 2020-06-23 23:41:55 -07:00
Alyssa Ross 4a57853a3b Fix Deserializer::{from_slice, with_reader} types (#332)
Having these in the impl block with a generic R paramter would make
them unusable, at least without type annotations:

    error[E0282]: type annotations needed
      --> msg_socket2/src/socket.rs:45:32
       |
    45 |         let mut deserializer = Deserializer::with_reader(bytes.as_slice(), DefaultOptions::new());
       |                                ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `R`

    error: aborting due to previous error

    For more information about this error, try `rustc --explain E0282`.

Moving these into separate impl blocks, which set the type of the
Deserializer to the return type of the functions, fixes this error.
2020-06-23 10:47:00 -07:00
Lena Hellström a822c09d93 bump version to 1.3.0 (#330) 2020-06-04 21:20:43 -07:00
Lena Hellström 752262a03d update documentation to reflect new config options (#329) 2020-06-04 21:20:00 -07:00
Lena Hellström e80f61b9da Reject trailing bytes (#198) 2020-05-26 12:40:04 -07:00
Lena Hellström f9faa33686 refactor config module (#323)
Break up the config module into one submodule per configuration
option. This commit also changes the default configuration with
the new options system to be varint (the old system still uses
fixint to preserve backwards compatibility).
2020-05-18 22:46:12 -07:00
Lena Hellström c27e9c6874 Varint enum tags and lengths (#306)
Adds varint encoding to all numbers, including sequence lengths and enum discriminants. Varints are encoded according to the following scheme

1. If `u < 251`, encode it as a single byte with that value.
2. If `251 <= u < 2**16`, encode it as a literal byte 251, followed by a u16 with value `u`.
3. If `2**16 <= u < 2**32`, encode it as a literal byte 252, followed by a u32 with value `u`.
4. If `2**32 <= u < 2**64`, encode it as a literal byte 253, followed by a u64 with value `u`.
5. If `2**64 <= u < 2**128`, encode it as a literal byte 254, followed by a u128 with value `u`.

Signed integers are first encoded using zigzag format (see docs for details)

Co-authored-by: Maciej Hirsz <maciej.hirsz@gmail.com>
Co-authored-by: Nicole Mazzuca <nicole@strega-nil.co>
2020-05-18 17:07:10 -07:00
Lena Hellström 2355e48a7b expose default options and serializers (#310)
Deprecate the old config system and make a refined version of the internal config system public. Doing allows the Serializer/Deserializer to be exposed since all of its generic type parameters are now public.
2020-04-16 15:23:07 -07:00
Lena Hellström 8839b0600d Modernize CI (#311)
Switches our CI from Travis-CI to Github Actions. At the same time this also turns on clippy and rustfmt linting.
2020-03-24 14:33:13 -07:00
Lena Hellström ae8c162d49 remove unsafe code in IoReader (#309) 2020-03-19 17:46:13 -07:00
Lena Hellström 15379ee5b2 Overoptimize slice reader (#308)
The default read implementation on slices was not generating efficient code. This custom implementation generates much smaller assembly with fewer function calls.
2020-03-18 14:54:54 -07:00
jean-airoldie 4aa2a44965 Added Debug impl to Config 2020-01-23 21:35:00 +00: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
jean-airoldie e2d8742743 Add contraints to {Serializer,Deserializer}Acceptor
This allows the user to retreive concrete types from the
serializer & deserializer output.
2020-01-23 09:23:48 +00:00
Joonatan Saarhelo 237e6852e9 remove unnecessary let in ReadReader 2020-01-21 09:21:43 +00:00
Joonatan Saarhelo 858cee9a22 deduplicate slicing logic SliceReader 2020-01-21 09:21:43 +00:00
Joonatan Saarhelo 28da4dbf56 improve documentation of BincodeRead 2020-01-21 09:21:43 +00:00
David Tolnay 6c4b23ce62 Release 1.2.1 2019-12-09 22:25:24 -08:00
David Tolnay 04cc5ba85f Merge pull request #281 from jstarry/fix-emscripten-builds
Fix emscripten build failures due to lack of i128 support
2019-12-09 22:25:00 -08:00
jean-airoldie a2d54866d4 Added Clone impl to Config 2019-11-04 07:46:43 -05:00
Josh Mcguigan c06b18abed improve safety of fill_buffer - see issue #260 2019-10-30 21:06:56 -04:00
Justin Starry 0215da2d29 Fix emscripten build failures due to lack of i128 support 2019-10-19 19:51:34 -04:00
Josh Matthews 293e9cea32 Release 1.2.0. 2019-09-24 14:16:47 -04:00
Josh Matthews d4d13aa37c Release 1.1.5. 2019-09-23 18:56:44 -04:00
alecmocatta ecbef8d1bb add remaining _seed variants of deserialize functions 2019-09-06 17:38:28 -04:00
David Tolnay 18da2c95d5 Release 1.1.4 2019-05-14 21:16:49 -07:00
David Tolnay 107a1930b5 Update documentation to 2018 edition 2019-04-30 01:18:32 -07:00
David Tolnay c954d3352c Remove unneeded ```rust from rustdoc 2019-04-30 01:15:01 -07:00
David Tolnay 0a67cf66e7 Release 1.1.3 2019-04-07 17:28:48 -07:00
David Tolnay f5af5b992b Define html_root_url 2019-02-16 11:28:17 -08:00
Diggory Hardy a04c750960 Make i128 support automatic for supporting Rustc versions
Uses autocfg
2019-01-28 09:59:18 -05:00
Jeff Muizelaar 20da2c841a Make config() inline(always)
Without this we end up generating code for all configs unless LTO is on.
2018-11-20 11:13:44 -05:00
Ty Overby d8704644d7 format 2018-09-04 16:25:10 -07:00
boxdot 5633935964 Introduce `Config::deserialize_seed` for exposing serde's statefull deser. 2018-09-04 16:22:50 -07:00
Ashley Mannix 2ef9a06894 add support for 128bit numbers 2018-05-30 09:44:38 -07:00
Ty Overby 72f002cc0a some comment fixes 2018-02-13 16:24:57 -08:00
Ty Overby 5081ac7c08 remove unused function type parameter 2018-02-07 20:23:07 -08:00
Ty Overby 24b007e194 public but hidden read types 2018-02-07 20:13:26 -08:00
Ty Overby 3c5b38097f hide with_deserializer and with_serializer 2018-02-07 19:46:25 -08:00
Ty Overby 76b7662dcd move to custom read implementation for deserialize_in_place 2018-02-07 19:39:27 -08:00
Ty Overby 68ca894b81 add deserialize_in_place 2018-02-07 18:32:10 -08: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
Kyle Huey 093bc24a13 Elide unnecessary copy when consuming a byte buffer. (#223) 2017-12-01 10:26:08 -08:00
Markus Westerlind 7464ba7272 Allow serialized types to use a more compact representation ... (#217)
... by utilizing that bincode is not human readable.

Uses the changes in https://github.com/serde-rs/serde/pull/1044 which
allows data formats to report that they are not human readable. This
lets certain types serialize themselves into a more compact form as they
know that the serialized form does not need to be readable.

Closes #215

BREAKING CHANGE

This changes how types serialize themselves if they detect the
`is_human_readable` state.
2017-11-20 09:55:34 -08:00
Ty Overby 1cc66df1d5 add documentation to utf8_char_width 2017-10-13 17:58:53 -07:00
Ty Overby 1cf9a0eb56 fix doc comment for deserializing function 2017-10-13 17:48:55 -07:00
Ty Overby 47b66f55ce switched type parameter on deserializer 2017-10-13 17:44:36 -07:00
Ty Overby 251bbe22d4 remove _types from read module 2017-10-13 17:42:09 -07:00
Ty Overby 40889ec016 capitalize Bincode 2017-10-13 17:38:36 -07:00
Ty Overby de942273a0 remove infinite terminology from SequenceMustHaveLength message 2017-10-13 17:32:04 -07:00
Ty Overby 94b3de8f3c remove decding terminology from sizelimit error message 2017-10-13 17:29:44 -07:00
Ty Overby c696aac206 fix mistake 2017-10-13 10:17:58 -07:00
Ty Overby 7dc7a94560 improve size limit error display 2017-10-13 08:59:08 -07:00
Ty Overby 3a24da087b cargo fmt source 2017-10-13 08:57:04 -07:00
Ty Overby c8f02e30aa 177 invalid encodings (#212)
* split out invalid encoding errors

* detail breaking changes
2017-10-12 09:04:14 -07:00
Ty Overby 45e70e297e add ErrorKind::DeserializeAnyNotSupported (#211) 2017-10-11 10:38:35 -07:00
Ty Overby d04ba007dc remove references to old type (#210) 2017-10-11 09:53:45 -07:00
Ty Overby a135fd44dc uncapitalize error messages (#209) 2017-10-11 09:53:36 -07:00
Ty Overby 62941544ea rename doc functions (#208)
* fix up docs
2017-10-10 16:41:27 -07:00
Ty Overby ab70e7d507 remove completely unused dependency 2017-10-10 10:32:18 -07:00
Jeff Muizelaar d033583700 Forward read_exact() as well as read(). (#207)
If we don't do this we end up using the generic read_exact method
which is not necessarily optimal. This is especially when
using a specialized Read implementation to go fast.
See https://github.com/TyOverby/bincode/issues/206
2017-10-10 10:20:34 -07:00
Thomas Schaller f20770a09f Correct error message
Spotted the mistake while skimming over the code.
2017-09-10 17:25:32 +02:00
Lena Hellström 4777efdfaa take reader and writer by value (#200) 2017-07-23 21:58:29 -07:00
Lena Hellström 34aba9acbe Internal type names (#199)
* Remove internal type names from api

* Rename IoReadReader to IoReader
2017-07-23 21:57:53 -07:00
David Tolnay 2f1ab0a0e5 Revert whitespace changes from #194 2017-07-22 13:35:13 -07:00
David Tolnay d44adb148e Correctly report the cause of IO error
This was fixed in #195 but unintentionally reverted in #194.
2017-07-22 13:34:29 -07:00
David Tolnay 815c44287a Merge pull request #194 from dgriffen/io-variant-names 2017-07-22 13:32:46 -07:00
Lena Hellström 18bcfc420e Seal SizeLimit and BincodeRead 2017-07-22 14:37:08 -05:00
Lena Hellström b6dbb08f92 Correctlly report the cause of IoError (#195) 2017-07-20 10:12:36 -07:00
Lena Hellström d55bbf150f Remove naming redundancy with IoError 2017-07-18 21:54:23 -07:00
Ty Overby 8be2e87415 factor out some common functionality 2017-04-20 22:20:56 -07:00
Ty Overby cb7e9f87eb fix buffer length bug 2017-04-20 22:11:28 -07:00
Ty Overby 6692674f43 WIP Implement nocopy support for bincode (#150)
* basic infrastructure

* use BincodeRead internally

* fix zero copy behavior

* rearrange module layout; remove pub(crate)

* add size-limit safety checks when deserializing str or bytes

* fix-up tests
2017-04-20 18:27:22 -07:00
David Tolnay 7eccffd783 Update to serde 1.0 branch (#149)
* Update to serde 1.0 branch

* The serde 1.0 branch merged
2017-04-19 16:05:59 -07:00
Ty Overby b3acb6ea60 remove read_bytes (#143) 2017-03-22 13:08:37 -07:00
Ty Overby c6fa2358e5 add docs to everything that was undocumented 2017-03-20 17:32:55 -07:00
Ty Overby 975f82cfb8 add size_hints 2017-03-20 08:29:26 -07:00