fix: bincode 2 ci errors & remaining _rc text

This commit is contained in:
ferris
2025-05-18 08:32:17 +02:00
committed by Vincent Herlemont
parent cf68ecfb19
commit 2a34adc35f
8 changed files with 36 additions and 36 deletions
+15 -15
View File
@@ -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)
}
}