fix: bincode 2 ci errors & remaining _rc text
This commit is contained in:
committed by
Vincent Herlemont
parent
cf68ecfb19
commit
2a34adc35f
@@ -95,14 +95,14 @@ You can use default serialization formats via the feature flags, like:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
native_model = { version = "0.1", features = ["bincode_2_rc"] }
|
||||
native_model = { version = "0.1", features = ["bincode_2"] }
|
||||
```
|
||||
|
||||
Each feature flag corresponds to a specific minor version of the serialization format. In order to avoid breaking
|
||||
changes, the default serialization format is the oldest one.
|
||||
|
||||
- `bincode_1_3`: [bincode](https://docs.rs/bincode/1.3.3/bincode/) v1.3 (default)
|
||||
- `bincode_2_rc`: [bincode](https://docs.rs/bincode/2.0.0-rc.3/bincode/) v2.0.0-rc3
|
||||
- `bincode_2`: [bincode](https://docs.rs/bincode/2.0.0-rc.3/bincode/) v2.0.0-rc3
|
||||
- `postcard_1_0`: [postcard](https://docs.rs/postcard/1.0.0/postcard/) v1.0
|
||||
- `rpm_serde_1_3`: [rmp-serde](https://docs.rs/rmp-serde/1.3.0/rmp_serde/) v1.3
|
||||
|
||||
@@ -116,7 +116,7 @@ Full examples:
|
||||
|
||||
Others examples, see the default implementations:
|
||||
- [bincode v1.3](./src/codec/bincode_1_3.rs)
|
||||
- [bincode v2.0 (rc)](./src/codec/bincode_2_rc.rs)
|
||||
- [bincode v2.0 (rc)](./src/codec/bincode_2.rs)
|
||||
- [postcard v1.0](./src/codec/postcard_1_0.rs)
|
||||
- [rmp-serde v1.3](./src/codec/rmp_serde_1_3.rs)
|
||||
|
||||
@@ -235,7 +235,7 @@ impl TryFrom<DotV3> for DotV2 {
|
||||
- **Warning: This codec may not work with all serde-derived types.**
|
||||
|
||||
- [bincode 2.0.0-rc.3](https://crates.io/crates/bincode/2.0.0-rc.3)
|
||||
- Enable the `bincode_2_rc` feature and use the `native_model::bincode_2_rc::Bincode` attribute to have `native_db` use this crate for serializing & deserializing.
|
||||
- Enable the `bincode_2` feature and use the `native_model::bincode_2::Bincode` attribute to have `native_db` use this crate for serializing & deserializing.
|
||||
- **Warning: This codec may not work with all serde-derived types.**
|
||||
|
||||
- [postcard 1.0](https://crates.io/crates/postcard/1.0.8)
|
||||
|
||||
@@ -18,11 +18,11 @@ build_bincode_1_3:
|
||||
build_no_default_bincode_1_3:
|
||||
cargo build --no-default-features --features serde --features bincode_1_3
|
||||
|
||||
build_bincode_2_rc:
|
||||
cargo build --features bincode_2_rc
|
||||
build_bincode_2:
|
||||
cargo build --features bincode_2
|
||||
|
||||
build_no_default_bincode_2_rc:
|
||||
cargo build --no-default-features --features serde --features bincode_2_rc
|
||||
build_no_default_bincode_2:
|
||||
cargo build --no-default-features --features serde --features bincode_2
|
||||
|
||||
build_postcard_1_0:
|
||||
cargo build --features postcard_1_0
|
||||
@@ -30,7 +30,7 @@ build_postcard_1_0:
|
||||
build_no_default_postcard_1_0:
|
||||
cargo build --no-default-features --features serde --features postcard_1_0
|
||||
|
||||
build_all: build_no_default build_default build_serde build_bincode_1_3 build_no_default_bincode_1_3 build_bincode_2_rc build_no_default_bincode_2_rc build_postcard_1_0 build_no_default_postcard_1_0
|
||||
build_all: build_no_default build_default build_serde build_bincode_1_3 build_no_default_bincode_1_3 build_bincode_2 build_no_default_bincode_2 build_postcard_1_0 build_no_default_postcard_1_0
|
||||
|
||||
_tests_crate args='':
|
||||
cd tests_crate; \
|
||||
@@ -45,8 +45,8 @@ test_default:
|
||||
test_bincode_1_3:
|
||||
@just _tests_crate '--features bincode_1_3'
|
||||
|
||||
test_bincode_2_rc:
|
||||
@just _tests_crate '--features bincode_2_rc'
|
||||
test_bincode_2:
|
||||
@just _tests_crate '--features bincode_2'
|
||||
|
||||
test_postcard_1_0:
|
||||
@just _tests_crate '--features postcard_1_0'
|
||||
@@ -54,7 +54,7 @@ test_postcard_1_0:
|
||||
test_docs:
|
||||
cargo test --doc --all-features
|
||||
|
||||
test_all: test_docs test_no_default test_default test_bincode_1_3 test_bincode_2_rc test_postcard_1_0
|
||||
test_all: test_docs test_no_default test_default test_bincode_1_3 test_bincode_2 test_postcard_1_0
|
||||
|
||||
bench_overhead:
|
||||
cargo bench --bench overhead
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
//! [bincode 2.0.0-rc.3](https://crates.io/crates/bincode/2.0.0-rc.3) ·
|
||||
//! Enable the `bincode_2_rc` feature and annotate your type with
|
||||
//! `native_model::bincode_2_rc::Bincode` to have `native_db` use this crate for
|
||||
//! [bincode 2.0](https://crates.io/crates/bincode/2.0.1) ·
|
||||
//! Enable the `bincode_2` feature and annotate your type with
|
||||
//! `native_model::bincode_2::Bincode` to have `native_db` use this crate for
|
||||
//! serializing & deserializing.
|
||||
|
||||
/// Used to specify the
|
||||
/// [bincode 2.0.0-rc.3](https://crates.io/crates/bincode/2.0.0-rc.3)
|
||||
/// [bincode 2.0](https://crates.io/crates/bincode/2.0.1)
|
||||
/// crate for serialization & deserialization.
|
||||
///
|
||||
/// # Warning
|
||||
///
|
||||
/// `bincode` [does not implement](https://docs.rs/bincode/2.0.0-rc.3/bincode/serde/index.html#known-issues)
|
||||
/// `bincode` [does not implement](https://docs.rs/bincode/2.0.1/bincode/serde/index.html#known-issues)
|
||||
/// all [serde](https://crates.io/crates/serde) features. Errors may be
|
||||
/// encountered when using this with some types.
|
||||
///
|
||||
@@ -18,7 +18,7 @@
|
||||
///
|
||||
/// # Basic usage
|
||||
///
|
||||
/// After enabling the `bincode_2_rc` feature in your `Cargo.toml`, use the
|
||||
/// After enabling the `bincode_2` feature in your `Cargo.toml`, use the
|
||||
/// [`with`](crate::native_model) attribute on your type to instruct
|
||||
/// `native_model` to use `Bincode` for serialization & deserialization.
|
||||
///
|
||||
@@ -27,7 +27,7 @@
|
||||
/// ```rust
|
||||
/// # use native_model::*;
|
||||
/// #[derive(Clone, Default, serde::Deserialize, serde::Serialize)]
|
||||
/// #[native_model(id = 1, version = 1, with = native_model::bincode_2_rc::Bincode)]
|
||||
/// #[native_model(id = 1, version = 1, with = native_model::bincode_2::Bincode)]
|
||||
/// struct MyStruct {
|
||||
/// my_string: String
|
||||
/// }
|
||||
@@ -35,20 +35,20 @@
|
||||
|
||||
pub struct Bincode;
|
||||
|
||||
#[cfg(all(feature = "serde", feature = "bincode_2_rc"))]
|
||||
#[cfg(all(feature = "serde", feature = "bincode_2"))]
|
||||
impl<T: serde::Serialize> super::Encode<T> for Bincode {
|
||||
type Error = bincode_2_rc::error::EncodeError;
|
||||
/// Serializes a type into bytes using the `bincode` `2.0.0-rc.3` crate.
|
||||
type Error = bincode_2::error::EncodeError;
|
||||
/// Serializes a type into bytes using the `bincode` `2.0` crate.
|
||||
fn encode(obj: &T) -> Result<Vec<u8>, Self::Error> {
|
||||
bincode_2_rc::serde::encode_to_vec(obj, bincode_2_rc::config::standard())
|
||||
bincode_2::serde::encode_to_vec(obj, bincode_2::config::standard())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "serde", feature = "bincode_2_rc"))]
|
||||
#[cfg(all(feature = "serde", feature = "bincode_2"))]
|
||||
impl<T: for<'de> serde::Deserialize<'de>> super::Decode<T> for Bincode {
|
||||
type Error = bincode_2_rc::error::DecodeError;
|
||||
/// Deserializes a type from bytes using the `bincode` `2.0.0-rc.3` crate.
|
||||
type Error = bincode_2::error::DecodeError;
|
||||
/// Deserializes a type from bytes using the `bincode` `2.0` crate.
|
||||
fn decode(data: Vec<u8>) -> Result<T, Self::Error> {
|
||||
Ok(bincode_2_rc::serde::decode_from_slice(&data, bincode_2_rc::config::standard())?.0)
|
||||
Ok(bincode_2::serde::decode_from_slice(&data, bincode_2::config::standard())?.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ pub mod rmp_serde_1_3;
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// use bincode_2_rc::{error::EncodeError,serde::encode_to_vec, config::standard};
|
||||
/// use bincode_2::{error::EncodeError,serde::encode_to_vec, config::standard};
|
||||
/// use serde::Serialize;
|
||||
/// pub struct Bincode;
|
||||
///
|
||||
@@ -32,7 +32,7 @@ pub trait Encode<T> {
|
||||
/// # Errors
|
||||
///
|
||||
/// The errors returned from this function depend on the trait implementor
|
||||
/// (the serializer), i.e. `bincode_2_rc`.
|
||||
/// (the serializer), i.e. `bincode_2`.
|
||||
fn encode(obj: &T) -> Result<Vec<u8>, Self::Error>;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ pub trait Encode<T> {
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// use bincode_2_rc::{error::DecodeError,serde::decode_from_slice, config::standard};
|
||||
/// use bincode_2::{error::DecodeError,serde::decode_from_slice, config::standard};
|
||||
/// use serde::Deserialize;
|
||||
/// pub struct Bincode;
|
||||
///
|
||||
@@ -57,6 +57,6 @@ pub trait Decode<T> {
|
||||
/// # Errors
|
||||
///
|
||||
/// The errors returned from this function depend on the trait implementor
|
||||
/// (the deserializer), i.e. `bincode_2_rc`.
|
||||
/// (the deserializer), i.e. `bincode_2`.
|
||||
fn decode(data: Vec<u8>) -> Result<T, Self::Error>;
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@ anyhow = "1.0.82"
|
||||
[features]
|
||||
default = ["bincode_1_3"]
|
||||
bincode_1_3 = ["serde", "native_model/bincode_1_3"]
|
||||
bincode_2_rc = ["serde", "native_model/bincode_2_rc", "bincode"]
|
||||
bincode_2 = ["serde", "native_model/bincode_2", "bincode"]
|
||||
postcard_1_0 = ["serde", "native_model/postcard_1_0", "postcard"]
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
#![cfg(feature = "bincode_2_rc")]
|
||||
#![cfg(feature = "bincode_2")]
|
||||
use native_model::{native_model};
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||
#[native_model(id = 1, version = 1, with = native_model::bincode_2_rc::Bincode)]
|
||||
#[native_model(id = 1, version = 1, with = native_model::bincode_2::Bincode)]
|
||||
struct Example {
|
||||
a: u32,
|
||||
b: u32,
|
||||
@@ -1,4 +1,4 @@
|
||||
mod default;
|
||||
mod bincode_1_3;
|
||||
mod bincode_2_rc;
|
||||
mod bincode_2;
|
||||
mod postcard_1_0;
|
||||
@@ -11,7 +11,7 @@ impl<T: bincode::Encode> native_model::Encode<T> for Bincode {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: bincode::Decode> native_model::Decode<T> for Bincode {
|
||||
impl<T: bincode::Decode<()>> native_model::Decode<T> for Bincode {
|
||||
type Error = bincode::error::DecodeError;
|
||||
fn decode(data: Vec<u8>) -> Result<T, bincode::error::DecodeError> {
|
||||
bincode::decode_from_slice(&data, config::standard()).map(|(result, _)| result)
|
||||
|
||||
Reference in New Issue
Block a user