Skip to content

Commit cd6f18e

Browse files
committed
Future-proof external crate compatibility
1 parent 8c0311e commit cd6f18e

24 files changed

+123
-124
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
- bytecheck
5252
external:
5353
- ''
54-
- hashbrown indexmap smallvec smol_str_02 smol_str_03 arrayvec tinyvec uuid bytes thin-vec triomphe
54+
- hashbrown-0_14 indexmap-2 smallvec-1 smol_str-0_2 smol_str-0_3 arrayvec-0_7 tinyvec-1 uuid-1 bytes-1 thin-vec-0_2 triomphe-0_1
5555

5656
steps:
5757
- uses: actions/checkout@v4

.vscode/settings.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"rust-analyzer.cargo.features": [
3-
"hashbrown",
4-
"indexmap",
5-
"smallvec",
6-
"smol_str_02",
7-
"smol_str_03",
8-
"arrayvec",
9-
"tinyvec",
10-
"uuid",
11-
"bytes",
12-
"thin-vec",
13-
"triomphe",
3+
"arrayvec-0_7",
4+
"bytes-1",
5+
"hashbrown-0_14",
6+
"indexmap-2",
7+
"smallvec-1",
8+
"smol_str-0_2",
9+
"smol_str-0_3",
10+
"thin-vec-0_2",
11+
"tinyvec-1",
12+
"triomphe-0_1",
13+
"uuid-1"
1414
]
1515
}

release_checklist.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ cargo test --tests --no-default-features --features "big_endian unaligned pointe
5050
- none, `alloc`, `std`
5151
- none, `bytecheck`
5252
- none, all external crates
53-
- `hashbrown`
54-
- `indexmap`
55-
- `smallvec`
56-
- `smol_str_02`
57-
- `smol_str_03`
58-
- `arrayvec`
59-
- `tinyvec`
60-
- `uuid`
61-
- `bytes`
62-
- `thin-vec`
63-
- `triomphe`
53+
- `hashbrown-0_14`
54+
- `indexmap-2`
55+
- `smallvec-1`
56+
- `smol_str-0_2`
57+
- `smol_str-0_3`
58+
- `arrayvec-0_7`
59+
- `tinyvec-1`
60+
- `uuid-1`
61+
- `bytes-1`
62+
- `thin-vec-0_2`
63+
- `triomphe-0_1`
6464

6565
Builds:
6666

@@ -71,12 +71,12 @@ cargo test --tests --no-default-features --features "std" >> results.txt~
7171
cargo test --tests --no-default-features --features "bytecheck" >> results.txt~
7272
cargo test --tests --no-default-features --features "bytecheck alloc" >> results.txt~
7373
cargo test --tests --no-default-features --features "bytecheck std" >> results.txt~
74-
cargo test --tests --no-default-features --features "hashbrown indexmap smallvec smol_str_02 smol_str_03 arrayvec tinyvec uuid bytes thin-vec triomphe" >> results.txt~
75-
cargo test --tests --no-default-features --features "alloc hashbrown indexmap smallvec smol_str_02 smol_str_03 arrayvec tinyvec uuid bytes thin-vec triomphe" >> results.txt~
76-
cargo test --tests --no-default-features --features "std hashbrown indexmap smallvec smol_str_02 smol_str_03 arrayvec tinyvec uuid bytes thin-vec triomphe" >> results.txt~
77-
cargo test --tests --no-default-features --features "bytecheck hashbrown indexmap smallvec smol_str_02 smol_str_03 arrayvec tinyvec uuid bytes thin-vec triomphe" >> results.txt~
78-
cargo test --tests --no-default-features --features "bytecheck alloc hashbrown indexmap smallvec smol_str_02 smol_str_03 arrayvec tinyvec uuid bytes thin-vec triomphe" >> results.txt~
79-
cargo test --tests --no-default-features --features "bytecheck std hashbrown indexmap smallvec smol_str_02 smol_str_03 arrayvec tinyvec uuid bytes thin-vec triomphe" >> results.txt~
74+
cargo test --tests --no-default-features --features "hashbrown-0_14 indexmap-2 smallvec-1 smol_str-0_2 smol_str-0_3 arrayvec-0_7 tinyvec-1 uuid-1 bytes-1 thin-vec-0_2 triomphe-0_1" >> results.txt~
75+
cargo test --tests --no-default-features --features "alloc hashbrown-0_14 indexmap-2 smallvec-1 smol_str-0_2 smol_str-0_3 arrayvec-0_7 tinyvec-1 uuid-1 bytes-1 thin-vec-0_2 triomphe-0_1" >> results.txt~
76+
cargo test --tests --no-default-features --features "std hashbrown-0_14 indexmap-2 smallvec-1 smol_str-0_2 smol_str-0_3 arrayvec-0_7 tinyvec-1 uuid-1 bytes-1 thin-vec-0_2 triomphe-0_1" >> results.txt~
77+
cargo test --tests --no-default-features --features "bytecheck hashbrown-0_14 indexmap-2 smallvec-1 smol_str-0_2 smol_str-0_3 arrayvec-0_7 tinyvec-1 uuid-1 bytes-1 thin-vec-0_2 triomphe-0_1" >> results.txt~
78+
cargo test --tests --no-default-features --features "bytecheck alloc hashbrown-0_14 indexmap-2 smallvec-1 smol_str-0_2 smol_str-0_3 arrayvec-0_7 tinyvec-1 uuid-1 bytes-1 thin-vec-0_2 triomphe-0_1" >> results.txt~
79+
cargo test --tests --no-default-features --features "bytecheck std hashbrown-0_14 indexmap-2 smallvec-1 smol_str-0_2 smol_str-0_3 arrayvec-0_7 tinyvec-1 uuid-1 bytes-1 thin-vec-0_2 triomphe-0_1" >> results.txt~
8080
```
8181

8282
# Testing through MIRI

rkyv/Cargo.toml

+18-17
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,18 @@ rkyv_derive.workspace = true
3131
# Before adding support for another crate, please consider getting rkyv support
3232
# in the crate instead.
3333

34-
arrayvec = { version = "0.7", optional = true, default-features = false }
35-
bytes = { version = "1.4.0", optional = true, default-features = false }
36-
# hashbrown
37-
indexmap = { version = "2.2", optional = true, default-features = false }
38-
smallvec = { version = "1.7", optional = true, default-features = false }
39-
smol_str_02 = { version = "0.2", package = "smol_str", optional = true, default-features = false }
40-
smol_str_03 = { version = "0.3", package = "smol_str", optional = true, default-features = false }
41-
thin-vec = { version = "0.2.12", optional = true, default-features = false }
42-
tinyvec = { version = "1.5", optional = true, default-features = false }
43-
triomphe = { version = "0.1", optional = true, default-features = false }
44-
uuid = { version = "1.3", optional = true, default-features = false }
34+
arrayvec-0_7 = { package = "arrayvec", version = "0.7", optional = true, default-features = false }
35+
bytes-1 = { package = "bytes", version = "1", optional = true, default-features = false }
36+
# rkyv already depends on hashbrown 0.14, so we can't duplicate this, but we can expose it as a feature below
37+
# hashbrown-0_14 = { package = "hashbrown", version = "0.14", optional = true, default-features = false }
38+
indexmap-2 = { package = "indexmap", version = "2", optional = true, default-features = false }
39+
smallvec-1 = { package = "smallvec", version = "1", optional = true, default-features = false }
40+
smol_str-0_2 = { package = "smol_str", version = "0.2", optional = true, default-features = false }
41+
smol_str-0_3 = { package = "smol_str", version = "0.3", optional = true, default-features = false }
42+
thin-vec-0_2 = { package = "thin-vec", version = "0.2.12", optional = true, default-features = false }
43+
tinyvec-1 = { package = "tinyvec", version = "1", optional = true, default-features = false }
44+
triomphe-0_1 = { package = "triomphe", version = "0.1", optional = true, default-features = false }
45+
uuid-1 = { package = "uuid", version = "1", optional = true, default-features = false }
4546

4647
[features]
4748
default = ["std", "bytecheck"]
@@ -52,15 +53,15 @@ unaligned = []
5253
pointer_width_16 = []
5354
pointer_width_32 = []
5455
pointer_width_64 = []
55-
alloc = ["dep:hashbrown", "tinyvec?/alloc", "rancor/alloc"]
56-
std = ["alloc", "bytes?/std", "indexmap?/std", "ptr_meta/std", "uuid?/std"]
56+
alloc = ["dep:hashbrown", "tinyvec-1?/alloc", "rancor/alloc"]
57+
std = ["alloc", "bytes-1?/std", "indexmap-2?/std", "ptr_meta/std", "uuid-1?/std"]
5758
bytecheck = ["dep:bytecheck", "rend/bytecheck", "rkyv_derive/bytecheck"]
5859

5960
# External crate support
60-
hashbrown = ["dep:hashbrown"]
61-
indexmap = ["dep:indexmap", "alloc"]
62-
triomphe = ["dep:triomphe", "alloc"]
63-
uuid = ["dep:uuid", "bytecheck?/uuid"]
61+
hashbrown-0_14 = ["dep:hashbrown"]
62+
indexmap-2 = ["dep:indexmap-2", "alloc"]
63+
triomphe-0_1 = ["dep:triomphe-0_1", "alloc"]
64+
uuid-1 = ["dep:uuid-1", "bytecheck?/uuid"]
6465

6566
[package.metadata.docs.rs]
6667
features = ["bytecheck"]

rkyv/src/impls/arrayvec.rs rkyv/src/impls/ext/arrayvec_0_7.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use arrayvec::ArrayVec;
1+
use arrayvec_0_7::ArrayVec;
22
use rancor::Fallible;
33

44
use crate::{
@@ -77,8 +77,7 @@ where
7777

7878
#[cfg(test)]
7979
mod tests {
80-
use arrayvec::ArrayVec;
81-
80+
use super::ArrayVec;
8281
use crate::api::test::roundtrip_with;
8382

8483
#[test]

rkyv/src/impls/bytes.rs rkyv/src/impls/ext/bytes_1.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bytes::{Bytes, BytesMut};
1+
use bytes_1::{Bytes, BytesMut};
22
use rancor::Fallible;
33

44
use crate::{
@@ -36,7 +36,7 @@ impl<D: Fallible + ?Sized> Deserialize<Bytes, D> for ArchivedVec<Archived<u8>> {
3636

3737
impl<T: Archive> PartialEq<Bytes> for ArchivedVec<T>
3838
where
39-
bytes::Bytes: PartialEq<[T]>,
39+
Bytes: PartialEq<[T]>,
4040
{
4141
fn eq(&self, other: &Bytes) -> bool {
4242
other == self.as_slice()
@@ -45,8 +45,7 @@ where
4545

4646
#[cfg(test)]
4747
mod tests {
48-
use bytes::Bytes;
49-
48+
use super::Bytes;
5049
use crate::{alloc::vec, api::test::roundtrip};
5150

5251
#[test]
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mod hash_map;
2+
mod hash_set;
3+
mod with;
4+
5+
// NOTE: When hashbrown updates to 0.15 or later,
6+
// this module will need to be updated to use hashbrown_0_14
File renamed without changes.

rkyv/src/impls/indexmap/index_map.rs rkyv/src/impls/ext/indexmap_2/index_map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::hash::{BuildHasher, Hash};
22

3-
use indexmap::IndexMap;
3+
use indexmap_2::IndexMap;
44
use rancor::{Fallible, Source};
55

66
use crate::{
@@ -83,7 +83,7 @@ where
8383
mod tests {
8484
use core::hash::BuildHasherDefault;
8585

86-
use indexmap::IndexMap;
86+
use indexmap_2::IndexMap;
8787

8888
use crate::{
8989
alloc::string::String, api::test::roundtrip_with, hash::FxHasher64,

rkyv/src/impls/indexmap/index_set.rs rkyv/src/impls/ext/indexmap_2/index_set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::hash::{BuildHasher, Hash};
22

3-
use indexmap::IndexSet;
3+
use indexmap_2::IndexSet;
44
use rancor::{Fallible, Source};
55

66
use crate::{
@@ -68,7 +68,7 @@ impl<UK, K: PartialEq<UK>, S: BuildHasher> PartialEq<IndexSet<UK, S>>
6868
mod tests {
6969
use core::hash::BuildHasherDefault;
7070

71-
use indexmap::IndexSet;
71+
use indexmap_2::IndexSet;
7272

7373
use crate::{
7474
alloc::string::String, api::test::roundtrip_with, hash::FxHasher64,
File renamed without changes.

rkyv/src/impls/ext/mod.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Support for various common crates. These are primarily to get users off the
2+
// ground and build some momentum.
3+
4+
// These are NOT PLANNED to remain in rkyv for the final release. Much like
5+
// serde, these implementations should be moved into their respective crates
6+
// over time. Before adding support for another crate, please consider getting
7+
// rkyv support in the crate instead.
8+
9+
#[cfg(feature = "arrayvec-0_7")]
10+
mod arrayvec_0_7;
11+
#[cfg(feature = "bytes-1")]
12+
mod bytes_1;
13+
#[cfg(feature = "hashbrown-0_14")]
14+
mod hashbrown_0_14;
15+
#[cfg(feature = "indexmap-2")]
16+
mod indexmap_2;
17+
#[cfg(feature = "smallvec-1")]
18+
mod smallvec_1;
19+
#[cfg(feature = "smol_str-0_2")]
20+
mod smolstr_0_2;
21+
#[cfg(feature = "smol_str-0_3")]
22+
mod smolstr_0_3;
23+
#[cfg(feature = "thin-vec-0_2")]
24+
mod thin_vec_0_2;
25+
#[cfg(feature = "tinyvec-1")]
26+
mod tinyvec_1;
27+
#[cfg(feature = "triomphe-0_1")]
28+
mod triomphe_0_1;
29+
#[cfg(feature = "uuid-1")]
30+
mod uuid_1;

rkyv/src/impls/smallvec.rs rkyv/src/impls/ext/smallvec_1.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rancor::Fallible;
2-
use smallvec::{Array, SmallVec};
2+
use smallvec_1::{Array, SmallVec};
33

44
use crate::{
55
ser::{Allocator, Writer},
@@ -80,7 +80,7 @@ where
8080

8181
#[cfg(test)]
8282
mod tests {
83-
use smallvec::{smallvec, SmallVec};
83+
use smallvec_1::{smallvec, SmallVec};
8484

8585
use crate::api::test::roundtrip_with;
8686

rkyv/src/impls/smolstr_02.rs rkyv/src/impls/ext/smolstr_0_2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rancor::{Fallible, Source};
2-
use smol_str_02::SmolStr;
2+
use smol_str_0_2::SmolStr;
33

44
use crate::{
55
ser::{Allocator, Writer},

rkyv/src/impls/smolstr_03.rs rkyv/src/impls/ext/smolstr_0_3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rancor::{Fallible, Source};
2-
use smol_str_03::SmolStr;
2+
use smol_str_0_3::SmolStr;
33

44
use crate::{
55
ser::{Allocator, Writer},

rkyv/src/impls/thin_vec.rs rkyv/src/impls/ext/thin_vec_0_2.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rancor::Fallible;
2-
use thin_vec::ThinVec;
2+
use thin_vec_0_2::ThinVec;
33

44
use crate::{
55
ser::{Allocator, Writer},
@@ -73,8 +73,7 @@ where
7373

7474
#[cfg(test)]
7575
mod tests {
76-
use thin_vec::ThinVec;
77-
76+
use super::ThinVec;
7877
use crate::api::test::roundtrip_with;
7978

8079
#[test]

rkyv/src/impls/tinyvec.rs rkyv/src/impls/ext/tinyvec_1.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rancor::Fallible;
2-
#[cfg(all(feature = "tinyvec", feature = "alloc"))]
3-
use tinyvec::TinyVec;
4-
use tinyvec::{Array, ArrayVec, SliceVec};
2+
#[cfg(feature = "alloc")]
3+
use tinyvec_1::TinyVec;
4+
use tinyvec_1::{Array, ArrayVec, SliceVec};
55

66
use crate::{
77
ser::{Allocator, Writer},
@@ -84,7 +84,7 @@ where
8484

8585
// TinyVec
8686

87-
#[cfg(all(feature = "tinyvec", feature = "alloc"))]
87+
#[cfg(feature = "alloc")]
8888
impl<A: Array> Archive for TinyVec<A>
8989
where
9090
A::Item: Archive,
@@ -97,7 +97,7 @@ where
9797
}
9898
}
9999

100-
#[cfg(all(feature = "tinyvec", feature = "alloc"))]
100+
#[cfg(feature = "alloc")]
101101
impl<A, S> Serialize<S> for TinyVec<A>
102102
where
103103
A: Array,
@@ -112,7 +112,7 @@ where
112112
}
113113
}
114114

115-
#[cfg(all(feature = "tinyvec", feature = "alloc"))]
115+
#[cfg(feature = "alloc")]
116116
impl<A, D> Deserialize<TinyVec<A>, D> for ArchivedVec<Archived<A::Item>>
117117
where
118118
A: Array,
@@ -184,7 +184,7 @@ where
184184

185185
#[cfg(test)]
186186
mod tests {
187-
use tinyvec::{array_vec, Array, SliceVec};
187+
use tinyvec_1::{array_vec, Array, SliceVec};
188188

189189
use crate::api::test::{roundtrip_with, to_archived};
190190

@@ -209,10 +209,10 @@ mod tests {
209209
});
210210
}
211211

212-
#[cfg(all(feature = "tinyvec", feature = "alloc"))]
212+
#[cfg(feature = "alloc")]
213213
#[test]
214214
fn roundtrip_tiny_vec() {
215-
use tinyvec::tiny_vec;
215+
use tinyvec_1::tiny_vec;
216216

217217
use crate::alloc::vec;
218218

rkyv/src/impls/triomphe.rs rkyv/src/impls/ext/triomphe_0_1.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::{
55

66
use ptr_meta::Pointee;
77
use rancor::{Fallible, Source};
8-
use triomphe::Arc;
8+
use triomphe_0_1::Arc;
99

1010
use crate::{
1111
de::{Metadata, Pooling, PoolingExt, SharedPointer},
@@ -83,7 +83,7 @@ where
8383

8484
#[cfg(test)]
8585
mod tests {
86-
use triomphe::Arc;
86+
use triomphe_0_1::Arc;
8787

8888
use crate::api::test::roundtrip_with;
8989

0 commit comments

Comments
 (0)