From e99e24e5ded73be1d009437b949abf3326bb6759 Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Thu, 30 Jan 2025 15:04:11 +0100 Subject: [PATCH 1/3] Prepare for 2.0.0 stable release --- .github/workflows/rust.yml | 6 +++--- Cargo.toml | 5 +++-- derive/Cargo.toml | 3 ++- docs/migration_guide.md | 22 +++++++++++----------- docs/spec.md | 14 +++++++------- src/lib.rs | 2 +- tests/std.rs | 4 ++-- 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 92b98c4e..cb514f42 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -25,8 +25,8 @@ "rust": [ "stable", "beta", - "nightly" - # "1.55.0" TODO: Pick latest stable version when we release 2.0 + "nightly", + "1.85.0" ] } }, @@ -81,7 +81,7 @@ ], "rust": [ "stable", - # "1.55.0" TODO: Pick latest stable version when we release 2.0 + "1.85.0" ], "features": [ "", diff --git a/Cargo.toml b/Cargo.toml index ab1fe808..9dd7e062 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,13 +3,14 @@ members = ["derive", "compatibility"] [package] name = "bincode" -version = "2.0.0-rc.3" # remember to update html_root_url and bincode_derive +version = "2.0.0" # remember to update html_root_url and bincode_derive authors = [ "Ty Overby ", "Zoey Riordan ", "Victor Koenders ", ] exclude = ["logo.svg", "examples/*", ".gitignore", ".github/"] +rust-version = "1.85.0" publish = true @@ -31,7 +32,7 @@ alloc = ["serde?/alloc"] derive = ["bincode_derive"] [dependencies] -bincode_derive = { path = "derive", version = "2.0.0-rc.3", optional = true } +bincode_derive = { path = "derive", version = "2.0.0", optional = true } serde = { version = "1.0", default-features = false, optional = true } unty = "0.0.3" diff --git a/derive/Cargo.toml b/derive/Cargo.toml index 327a7ced..444b194b 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "bincode_derive" -version = "2.0.0-rc.3" # remember to update bincode +version = "2.0.0" # remember to update bincode authors = [ "Zoey Riordan ", "Victor Koenders ", ] edition = "2021" +rust-version = "1.85.0" repository = "https://github.com/bincode-org/bincode" documentation = "https://docs.rs/bincode_derive" diff --git a/docs/migration_guide.md b/docs/migration_guide.md index cedba821..021a8df2 100644 --- a/docs/migration_guide.md +++ b/docs/migration_guide.md @@ -4,7 +4,7 @@ Bincode 2 now has an optional dependency on `serde`. You can either use `serde`, ## From `Options` to `Configuration` -Bincode 1 had the [Options](https://docs.rs/bincode/1/bincode/config/trait.Options.html) trait. This has been replaced with the [Configuration](https://docs.rs/bincode/2.0.0-rc/bincode/config/struct.Configuration.html) struct. +Bincode 1 had the [Options](https://docs.rs/bincode/1/bincode/config/trait.Options.html) trait. This has been replaced with the [Configuration](https://docs.rs/bincode/2.0.0/bincode/config/struct.Configuration.html) struct. If you're using `Options`, you can change it like this: @@ -46,10 +46,10 @@ If so, make sure to include bincode 2 with the `serde` feature enabled, and use ```toml [dependencies] -bincode = { version = "2.0.0-rc", features = ["serde"] } +bincode = { version = "2.0.0", features = ["serde"] } # Optionally you can disable the `derive` feature: -# bincode = { version = "2.0.0-rc", default-features = false, features = ["std", "serde"] } +# bincode = { version = "2.0.0", default-features = false, features = ["std", "serde"] } ``` Then replace the following functions: (`Configuration` is `bincode::config::legacy()` by default) @@ -70,13 +70,13 @@ Then replace the following functions: (`Configuration` is `bincode::config::lega ```toml,ignore [dependencies] -bincode = "2.0.0-rc" +bincode = "2.0.0" # If you need `no_std` with `alloc`: -# bincode = { version = "2.0.0-rc", default-features = false, features = ["derive", "alloc"] } +# bincode = { version = "2.0.0", default-features = false, features = ["derive", "alloc"] } # If you need `no_std` and no `alloc`: -# bincode = { version = "2.0.0-rc", default-features = false, features = ["derive"] } +# bincode = { version = "2.0.0", default-features = false, features = ["derive"] } ``` Replace or add the following attributes. You are able to use both `serde-derive` and `bincode-derive` side-by-side. @@ -86,7 +86,7 @@ Replace or add the following attributes. You are able to use both `serde-derive` | `#[derive(serde::Serialize)]` | `#[derive(bincode::Encode)]` | | `#[derive(serde::Deserialize)]` | `#[derive(bincode::Decode)]` | -**note:** To implement these traits manually, see the documentation of [Encode](https://docs.rs/bincode/2.0.0-rc/bincode/enc/trait.Encode.html) and [Decode](https://docs.rs/bincode/2.0.0-rc/bincode/de/trait.Decode.html). +**note:** To implement these traits manually, see the documentation of [Encode](https://docs.rs/bincode/2.0.0/bincode/enc/trait.Encode.html) and [Decode](https://docs.rs/bincode/2.0.0/bincode/de/trait.Decode.html). **note:** For more information on using `bincode-derive` with external libraries, see [below](#bincode-derive-and-libraries). @@ -107,10 +107,10 @@ Then replace the following functions: (`Configuration` is `bincode::config::lega Currently not many libraries support the traits `Encode` and `Decode`. There are a couple of options if you want to use `#[derive(bincode::Encode, bincode::Decode)]`: - Enable the `serde` feature and add a `#[bincode(with_serde)]` above each field that implements `serde::Serialize/Deserialize` but not `Encode/Decode` -- Enable the `serde` feature and wrap your field in [bincode::serde::Compat](https://docs.rs/bincode/2.0.0-rc/bincode/serde/struct.Compat.html) or [bincode::serde::BorrowCompat](https://docs.rs/bincode/2.0.0-rc/bincode/serde/struct.BorrowCompat.html) +- Enable the `serde` feature and wrap your field in [bincode::serde::Compat](https://docs.rs/bincode/2.0.0/bincode/serde/struct.Compat.html) or [bincode::serde::BorrowCompat](https://docs.rs/bincode/2.0.0/bincode/serde/struct.BorrowCompat.html) - Make a pull request to the library: - Make sure to be respectful, most of the developers are doing this in their free time. - - Add a dependency `bincode = { version = "2.0.0-rc", default-features = false, optional = true }` to the `Cargo.toml` - - Implement [Encode](https://docs.rs/bincode/2.0.0-rc/bincode/enc/trait.Encode.html) - - Implement [Decode](https://docs.rs/bincode/2.0.0-rc/bincode/de/trait.Decode.html) + - Add a dependency `bincode = { version = "2.0.0", default-features = false, optional = true }` to the `Cargo.toml` + - Implement [Encode](https://docs.rs/bincode/2.0.0/bincode/enc/trait.Encode.html) + - Implement [Decode](https://docs.rs/bincode/2.0.0/bincode/de/trait.Decode.html) - Make sure both of these implementations have a `#[cfg(feature = "bincode")]` attribute. diff --git a/docs/spec.md b/docs/spec.md index 5f844db8..01858cf5 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -15,8 +15,8 @@ By default, this serialization format uses little-endian byte order for basic nu Endianness can be configured with the following methods, allowing for big-endian serialization when required: -- [`with_big_endian`](https://docs.rs/bincode/2.0.0-rc/bincode/config/struct.Configuration.html#method.with_big_endian) -- [`with_little_endian`](https://docs.rs/bincode/2.0.0-rc/bincode/config/struct.Configuration.html#method.with_little_endian) +- [`with_big_endian`](https://docs.rs/bincode/2.0.0/bincode/config/struct.Configuration.html#method.with_big_endian) +- [`with_little_endian`](https://docs.rs/bincode/2.0.0/bincode/config/struct.Configuration.html#method.with_little_endian) ### Byte Order Considerations @@ -31,7 +31,7 @@ Endianness can be configured with the following methods, allowing for big-endian - Encoded as a single byte - `false` is represented by `0` - `true` is represented by `1` -- During deserialization, values other than 0 and 1 will result in an error [`DecodeError::InvalidBooleanValue`](https://docs.rs/bincode/2.0.0-rc/bincode/error/enum.DecodeError.html#variant.InvalidBooleanValue) +- During deserialization, values other than 0 and 1 will result in an error [`DecodeError::InvalidBooleanValue`](https://docs.rs/bincode/2.0.0/bincode/error/enum.DecodeError.html#variant.InvalidBooleanValue) ### Numeric Types @@ -62,7 +62,7 @@ Endianness can be configured with the following methods, allowing for big-endian - Surrogate code points (0xD800 to 0xDFFF) are not valid - Invalid Unicode characters can be acquired via unsafe code, this is handled as: - during serialization: data is written as-is - - during deserialization: an error is raised [`DecodeError::InvalidCharEncoding`](https://docs.rs/bincode/2.0.0-rc/bincode/error/enum.DecodeError.html#variant.InvalidCharEncoding) + - during deserialization: an error is raised [`DecodeError::InvalidCharEncoding`](https://docs.rs/bincode/2.0.0/bincode/error/enum.DecodeError.html#variant.InvalidCharEncoding) - No additional metadata or encoding scheme beyond the raw code point value All tuples have no additional bytes, and are encoded in their specified order, e.g. @@ -92,7 +92,7 @@ Encoding an unsigned integer v (of any type excepting u8/i8) works as follows: `usize` is being encoded/decoded as a `u64` and `isize` is being encoded/decoded as a `i64`. -See the documentation of [VarintEncoding](https://docs.rs/bincode/2.0.0-rc/bincode/config/struct.Configuration.html#method.with_variable_int_encoding) for more information. +See the documentation of [VarintEncoding](https://docs.rs/bincode/2.0.0/bincode/config/struct.Configuration.html#method.with_variable_int_encoding) for more information. ### FixintEncoding @@ -100,7 +100,7 @@ See the documentation of [VarintEncoding](https://docs.rs/bincode/2.0.0-rc/binco - Enum discriminants are encoded as u32 - Lengths and usize are encoded as u64 -See the documentation of [FixintEncoding](https://docs.rs/bincode/2.0.0-rc/bincode/config/struct.Configuration.html#method.with_fixed_int_encoding) for more information. +See the documentation of [FixintEncoding](https://docs.rs/bincode/2.0.0/bincode/config/struct.Configuration.html#method.with_fixed_int_encoding) for more information. ## Enums @@ -224,7 +224,7 @@ assert_eq!(encoded.as_slice(), &[ - During serialization, the string is encoded as a sequence of the given bytes. - Rust strings are UTF-8 encoded by default, but this is not enforced by bincode - No normalization or transformation of text -- If an invalid UTF-8 sequence is encountered during decoding, an [`DecodeError::Utf8`](https://docs.rs/bincode/2.0.0-rc/bincode/error/enum.DecodeError.html#variant.Utf8) error is raised +- If an invalid UTF-8 sequence is encountered during decoding, an [`DecodeError::Utf8`](https://docs.rs/bincode/2.0.0/bincode/error/enum.DecodeError.html#variant.Utf8) error is raised ```rust let str = "Hello 🌍"; // Mixed ASCII and Unicode diff --git a/src/lib.rs b/src/lib.rs index 4a0f532d..287f8b3c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,7 +71,7 @@ //! [`net::TcpStream`]: std::net::TcpStream //! -#![doc(html_root_url = "https://docs.rs/bincode/2.0.0-rc.3")] +#![doc(html_root_url = "https://docs.rs/bincode/2.0.0")] #![crate_name = "bincode"] #![crate_type = "rlib"] diff --git a/tests/std.rs b/tests/std.rs index e505fc8f..0c33c6f1 100644 --- a/tests/std.rs +++ b/tests/std.rs @@ -5,7 +5,7 @@ mod utils; use bincode::error::DecodeError; use std::{ - ffi::{CStr, CString}, + ffi::CString, io::{Cursor, Seek, SeekFrom}, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}, path::{Path, PathBuf}, @@ -128,7 +128,7 @@ fn test_std_commons() { let mut buffer = [0u8; 1024]; // &CStr - let cstr = CStr::from_bytes_with_nul(b"Hello world\0").unwrap(); + let cstr = c"Hello world"; let len = bincode::encode_into_slice(cstr, &mut buffer, config).unwrap(); let (decoded, len): (CString, usize) = bincode::decode_from_slice(&buffer[..len], config).unwrap(); From 73c6e2106ae327f005c795057311e4a83178db47 Mon Sep 17 00:00:00 2001 From: Zoey Riordan Date: Thu, 6 Mar 2025 17:44:22 +0100 Subject: [PATCH 2/3] Update MSRV documentation --- readme.md | 2 +- src/lib.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index fb5dfed6..0aeb6e8a 100644 --- a/readme.md +++ b/readme.md @@ -100,7 +100,7 @@ maximum size limit. Malicious inputs will fail upon deserialization. ### What is Bincode's MSRV (minimum supported Rust version)? -Bincode 2.0 is still in development and does not yet have a targeted MSRV. Once 2.0 is fully released the MSRV will be locked. After this point any changes to the MSRV are considered a breaking change for semver purposes. +Bincode 2.0 has an MSRV of 1.85.0. Any changes to the MSRV are considered a breaking change for semver purposes, except when certain features are enabled. Features affecting MSRV are documented in the crate root. ### Why does bincode not respect `#[repr(u8)]`? diff --git a/src/lib.rs b/src/lib.rs index 287f8b3c..ba1a9e46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,13 +15,13 @@ //! //! # Features //! -//! |Name |Default?|Supported types for Encode/Decode|Enabled methods |Other| -//! |------|--------|-----------------------------------------|-----------------------------------------------------------------|-----| -//! |std | Yes |`HashMap` and `HashSet`|`decode_from_std_read` and `encode_into_std_write`| -//! |alloc | Yes |All common containers in alloc, like `Vec`, `String`, `Box`|`encode_to_vec`| -//! |atomic| Yes |All `Atomic*` integer types, e.g. `AtomicUsize`, and `AtomicBool`|| -//! |derive| Yes |||Enables the `BorrowDecode`, `Decode` and `Encode` derive macros| -//! |serde | No |`Compat` and `BorrowCompat`, which will work for all types that implement serde's traits|serde-specific encode/decode functions in the [serde] module|Note: There are several [known issues](serde/index.html#known-issues) when using serde and bincode| +//! |Name |Default?|Affects MSRV?|Supported types for Encode/Decode|Enabled methods |Other| +//! |------|--------|-------------|-----------------------------------------|-----------------------------------------------------------------|-----| +//! |std | Yes | No |`HashMap` and `HashSet`|`decode_from_std_read` and `encode_into_std_write`| +//! |alloc | Yes | No |All common containers in alloc, like `Vec`, `String`, `Box`|`encode_to_vec`| +//! |atomic| Yes | No |All `Atomic*` integer types, e.g. `AtomicUsize`, and `AtomicBool`|| +//! |derive| Yes | No |||Enables the `BorrowDecode`, `Decode` and `Encode` derive macros| +//! |serde | No | Yes (MSRV reliant on serde)|`Compat` and `BorrowCompat`, which will work for all types that implement serde's traits|serde-specific encode/decode functions in the [serde] module|Note: There are several [known issues](serde/index.html#known-issues) when using serde and bincode| //! //! # Which functions to use //! From 1e92384ca753877626b114ea647bf7999dbbf8dd Mon Sep 17 00:00:00 2001 From: Zoey Riordan Date: Thu, 6 Mar 2025 17:46:34 +0100 Subject: [PATCH 3/3] Update fuzz Cargo.lock --- fuzz/Cargo.lock | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 6b8e0081..b1315013 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "arbitrary" @@ -19,10 +19,11 @@ dependencies = [ [[package]] name = "bincode" -version = "2.0.0-rc.3" +version = "2.0.0" dependencies = [ "bincode_derive", "serde", + "unty", ] [[package]] @@ -30,14 +31,14 @@ name = "bincode-fuzz" version = "0.0.0" dependencies = [ "bincode 1.3.3", - "bincode 2.0.0-rc.3", + "bincode 2.0.0", "libfuzzer-sys", "serde", ] [[package]] name = "bincode_derive" -version = "2.0.0-rc.3" +version = "2.0.0" dependencies = [ "virtue", ] @@ -120,8 +121,14 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +[[package]] +name = "unty" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a88342087869553c259588a3ec9ca73ce9b2d538b7051ba5789ff236b6c129" + [[package]] name = "virtue" -version = "0.0.13" +version = "0.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dcc60c0624df774c82a0ef104151231d37da4962957d691c011c852b2473314" +checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1"