feat: Remove native_model_encode_downgrade
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
[package]
|
||||
name = "native_model"
|
||||
version = "0.6.2"
|
||||
authors = ["Vincent Herlemont <vincent@herlemont.fr>"]
|
||||
authors = ["Vincent Herlemont <vincent@herlemont.fr>", "quexeky <git@quexeky.dev>"]
|
||||
edition = "2021"
|
||||
description = "A thin wrapper around serialized data which add information of identity and version."
|
||||
license = "MIT"
|
||||
repository = "https://github.com/vincent-herlemont/native_model"
|
||||
repository = "https://github.com/Drop-OSS/native_model"
|
||||
readme = "README.md"
|
||||
keywords = ["serialization", "interoperability", "data-consistency", "flexibility", "performance"]
|
||||
categories = ["data-structures", "encoding", "rust-patterns"]
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Vincent Herlemont <vincent@herlemont.fr>"]
|
||||
edition = "2018"
|
||||
description = "A procedural macro for native_model"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/vincent-herlemont/native_model"
|
||||
repository = "https://github.com/Drop-OSS/native_model"
|
||||
readme = "README.md"
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
A procedural macro for [native_model](https://github.com/vincent-herlemont/native_model).
|
||||
A procedural macro for [native_model](https://github.com/Drop-OSS/native_model).
|
||||
@@ -93,7 +93,7 @@ impl Parse for TupleTryFrom {
|
||||
///
|
||||
/// See examples:
|
||||
/// - [Setup your data model](https://github.com/vincent-herlemont/native_model_private#setup-your-data-model).
|
||||
/// - other [examples](https://github.com/vincent-herlemont/native_model/tree/master/tests/example)
|
||||
/// - other [examples](https://github.com/Drop-OSS/native_model/tree/master/tests/example)
|
||||
#[proc_macro_attribute]
|
||||
pub fn native_model(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
let ast = parse_macro_input!(input as DeriveInput);
|
||||
@@ -106,7 +106,6 @@ pub fn native_model(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
let native_model_id_fn = generate_native_model_id(&attrs);
|
||||
let native_model_version_fn = generate_native_model_version(&attrs);
|
||||
let native_model_encode_body_fn = generate_native_model_encode_body(&attrs);
|
||||
let native_model_encode_downgrade_body_fn = generate_native_model_encode_downgrade_body(&attrs);
|
||||
let native_model_decode_body_fn = generate_native_model_decode_body(&attrs);
|
||||
let native_model_decode_upgrade_body_fn = generate_native_model_decode_upgrade_body(&attrs);
|
||||
|
||||
@@ -117,7 +116,6 @@ pub fn native_model(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
#native_model_id_fn
|
||||
#native_model_version_fn
|
||||
#native_model_encode_body_fn
|
||||
#native_model_encode_downgrade_body_fn
|
||||
#native_model_decode_body_fn
|
||||
#native_model_decode_upgrade_body_fn
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
//! - It aims to ensure:
|
||||
//! - **Interoperability**: Different applications can work together even if they use different data model versions.
|
||||
//! - **Data Consistency**: Ensures the data is processed as expected.
|
||||
//! - **Flexibility**: Allows the use of any serialization format. Mode details [here](https://github.com/vincent-herlemont/native_model#setup-your-serialization-format).
|
||||
//! - **Minimal Performance Overhead**: Current performance has a minimal overhead see [performance](https://github.com/vincent-herlemont/native_model#performance) section.
|
||||
//! - **Flexibility**: Allows the use of any serialization format. Mode details [here](https://github.com/Drop-OSS/native_model#setup-your-serialization-format).
|
||||
//! - **Minimal Performance Overhead**: Current performance has a minimal overhead see [performance](https://github.com/Drop-OSS/native_model#performance) section.
|
||||
//! - **Suitability**:
|
||||
//! - Suitable for applications that are written in Rust, evolve independently, store data locally, and require incremental upgrades.
|
||||
//! - Not suitable for non-Rust applications, systems not controlled by the user, or when human-readable formats are needed.
|
||||
//! - **Setup**:
|
||||
//! - Users must define their own serialization format and data model. Mode details [here](https://github.com/vincent-herlemont/native_model#setup-your-serialization-format).
|
||||
//! - Users must define their own serialization format and data model. Mode details [here](https://github.com/Drop-OSS/native_model#setup-your-serialization-format).
|
||||
//! - **Development Stage**:
|
||||
//! - The crate is in early development, and performance is expected to improve over time.
|
||||
//!
|
||||
//! See examples in the [README.md](https://github.com/vincent-herlemont/native_model) file.
|
||||
//! See examples in the [README.md](https://github.com/Drop-OSS/native_model) file.
|
||||
|
||||
#[cfg(doctest)]
|
||||
#[macro_use]
|
||||
@@ -121,8 +121,8 @@ pub struct DowngradeError {
|
||||
/// Allows to encode a [`native_model`] into a [`Vec<u8>`].
|
||||
///
|
||||
/// See examples:
|
||||
/// - [README.md](https://github.com/vincent-herlemont/native_model) file.
|
||||
/// - other [examples](https://github.com/vincent-herlemont/native_model/tree/master/tests/example)
|
||||
/// - [README.md](https://github.com/Drop-OSS/native_model) file.
|
||||
/// - other [examples](https://github.com/Drop-OSS/native_model/tree/master/tests/example)
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
@@ -132,18 +132,10 @@ pub fn encode<T: crate::Model>(model: &T) -> Result<Vec<u8>> {
|
||||
T::native_model_encode(model)
|
||||
}
|
||||
|
||||
/// Allows to encode a [`native_model`] into a [`Vec<u8>`] with a specific version.
|
||||
/// See examples:
|
||||
/// - [README.md](https://github.com/vincent-herlemont/native_model) file.
|
||||
/// - other [examples](https://github.com/vincent-herlemont/native_model/tree/master/tests/example)
|
||||
pub fn encode_downgrade<T: crate::Model>(model: T, version: u32) -> Result<Vec<u8>> {
|
||||
T::native_model_encode_downgrade(model, version)
|
||||
}
|
||||
|
||||
/// Allows to decode a [`native_model`] from a [`Vec<u8>`] and returns the version ([`u32`]).
|
||||
/// See examples:
|
||||
/// - [README.md](https://github.com/vincent-herlemont/native_model) file.
|
||||
/// - other [examples](https://github.com/vincent-herlemont/native_model/tree/master/tests/example)
|
||||
/// - [README.md](https://github.com/Drop-OSS/native_model) file.
|
||||
/// - other [examples](https://github.com/Drop-OSS/native_model/tree/master/tests/example)
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
@@ -180,8 +172,6 @@ pub trait Model: Sized {
|
||||
|
||||
fn native_model_encode_body(&self) -> EncodeResult<Vec<u8>>;
|
||||
|
||||
fn native_model_encode_downgrade_body(self, version: u32) -> Result<Vec<u8>>;
|
||||
|
||||
fn native_model_encode(&self) -> Result<Vec<u8>> {
|
||||
let mut data = self.native_model_encode_body()?;
|
||||
let data = crate::native_model_encode(
|
||||
@@ -191,10 +181,4 @@ pub trait Model: Sized {
|
||||
);
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
fn native_model_encode_downgrade(self, version: u32) -> Result<Vec<u8>> {
|
||||
let mut data = self.native_model_encode_downgrade_body(version)?;
|
||||
let data = crate::native_model_encode(&mut data, Self::native_model_id(), version);
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user