Skip to content

Commit 0cf9155

Browse files
authored
Merge pull request #54 from serde-rs/bincode
Update examples to bincode 2
2 parents ade06cc + 82e4149 commit 0cf9155

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

.github/workflows/ci.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
rust: [nightly, beta, stable, 1.68.0]
22+
rust: [nightly, beta, stable, 1.85.0, 1.68.0]
2323
timeout-minutes: 45
2424
steps:
2525
- uses: actions/checkout@v4
2626
- uses: dtolnay/rust-toolchain@master
2727
with:
2828
toolchain: ${{matrix.rust}}
29-
- run: cargo test
3029
- run: cargo check --no-default-features
3130
- run: cargo check --no-default-features --features alloc
31+
- run: cargo test
32+
if: matrix.rust != '1.68.0'
3233
- uses: actions/upload-artifact@v4
3334
if: matrix.rust == 'nightly' && always()
3435
with:
@@ -77,4 +78,4 @@ jobs:
7778
- uses: actions/checkout@v4
7879
- uses: dtolnay/rust-toolchain@stable
7980
- uses: dtolnay/install@cargo-outdated
80-
- run: cargo outdated --workspace --ignore bincode --exit-code 1
81+
- run: cargo outdated --workspace --exit-code 1

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ alloc = ["serde/alloc"]
2020
serde = { version = "1.0.166", default-features = false }
2121

2222
[dev-dependencies]
23-
bincode = "1.3.3"
23+
bincode = { version = "2", features = ["serde"] }
2424
serde_derive = "1.0.166"
2525
serde_test = "1.0.166"
2626

src/bytearray.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ use serde::ser::{Serialize, Serializer};
1717
///
1818
/// use serde_bytes::ByteArray;
1919
///
20-
/// fn deserialize_bytearrays() -> bincode::Result<()> {
20+
/// fn deserialize_bytearrays() -> Result<(), bincode::error::DecodeError> {
2121
/// let example_data = [
2222
/// 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 116,
2323
/// 119, 111, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 111, 110, 101
2424
/// ];
2525
///
26-
/// let map: HashMap<u32, ByteArray<3>> = bincode::deserialize(&example_data[..])?;
26+
/// let map: HashMap<u32, ByteArray<3>>;
27+
/// (map, _) = bincode::serde::decode_from_slice(
28+
/// &example_data,
29+
/// bincode::config::legacy(),
30+
/// )?;
2731
///
2832
/// println!("{:?}", map);
2933
///

src/bytebuf.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ use crate::Bytes;
2424
///
2525
/// use serde_bytes::ByteBuf;
2626
///
27-
/// fn deserialize_bytebufs() -> bincode::Result<()> {
27+
/// fn deserialize_bytebufs() -> Result<(), bincode::error::DecodeError> {
2828
/// let example_data = [
2929
/// 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 116,
3030
/// 119, 111, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 111, 110, 101];
3131
///
32-
/// let map: HashMap<u32, ByteBuf> = bincode::deserialize(&example_data[..])?;
32+
/// let map: HashMap<u32, ByteBuf>;
33+
/// (map, _) = bincode::serde::decode_from_slice(
34+
/// &example_data,
35+
/// bincode::config::legacy(),
36+
/// )?;
3337
///
3438
/// println!("{:?}", map);
3539
///

src/bytes.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@ use serde::ser::{Serialize, Serializer};
2323
///
2424
/// use serde_bytes::Bytes;
2525
///
26-
/// fn print_encoded_cache() -> bincode::Result<()> {
26+
/// fn print_encoded_cache() -> Result<(), bincode::error::EncodeError> {
2727
/// let mut cache = HashMap::new();
2828
/// cache.insert(3, Bytes::new(b"three"));
2929
/// cache.insert(2, Bytes::new(b"two"));
3030
/// cache.insert(1, Bytes::new(b"one"));
3131
///
32-
/// bincode::serialize_into(&mut io::stdout(), &cache)
32+
/// bincode::serde::encode_into_std_write(
33+
/// &cache,
34+
/// &mut io::stdout(),
35+
/// bincode::config::legacy(),
36+
/// )?;
37+
///
38+
/// Ok(())
3339
/// }
3440
/// #
3541
/// # fn main() {

0 commit comments

Comments
 (0)