From 22210f5d1b240fa52d741de2e7900bb3a760e917 Mon Sep 17 00:00:00 2001 From: quexeky Date: Thu, 21 Aug 2025 12:36:02 +1000 Subject: [PATCH] feat: Remove native_model_encode_downgrade Signed-off-by: quexeky --- libraries/native_model/Cargo.toml | 4 +-- .../native_model_macro/Cargo.toml | 2 +- .../native_model/native_model_macro/README.md | 2 +- .../native_model_macro/src/lib.rs | 4 +-- libraries/native_model/src/lib.rs | 32 +++++-------------- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/libraries/native_model/Cargo.toml b/libraries/native_model/Cargo.toml index 0fe4ad24..a943121a 100644 --- a/libraries/native_model/Cargo.toml +++ b/libraries/native_model/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "native_model" version = "0.6.2" -authors = ["Vincent Herlemont "] +authors = ["Vincent Herlemont ", "quexeky "] 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"] diff --git a/libraries/native_model/native_model_macro/Cargo.toml b/libraries/native_model/native_model_macro/Cargo.toml index 95b64d3d..17f64965 100644 --- a/libraries/native_model/native_model_macro/Cargo.toml +++ b/libraries/native_model/native_model_macro/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Vincent Herlemont "] 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" diff --git a/libraries/native_model/native_model_macro/README.md b/libraries/native_model/native_model_macro/README.md index 136027bb..45836a41 100644 --- a/libraries/native_model/native_model_macro/README.md +++ b/libraries/native_model/native_model_macro/README.md @@ -1 +1 @@ -A procedural macro for [native_model](https://github.com/vincent-herlemont/native_model). \ No newline at end of file +A procedural macro for [native_model](https://github.com/Drop-OSS/native_model). \ No newline at end of file diff --git a/libraries/native_model/native_model_macro/src/lib.rs b/libraries/native_model/native_model_macro/src/lib.rs index 2193d4de..b416a148 100644 --- a/libraries/native_model/native_model_macro/src/lib.rs +++ b/libraries/native_model/native_model_macro/src/lib.rs @@ -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 } diff --git a/libraries/native_model/src/lib.rs b/libraries/native_model/src/lib.rs index 443935f0..bc49f198 100644 --- a/libraries/native_model/src/lib.rs +++ b/libraries/native_model/src/lib.rs @@ -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`]. /// /// 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(model: &T) -> Result> { T::native_model_encode(model) } -/// Allows to encode a [`native_model`] into a [`Vec`] 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(model: T, version: u32) -> Result> { - T::native_model_encode_downgrade(model, version) -} - /// Allows to decode a [`native_model`] from a [`Vec`] 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>; - fn native_model_encode_downgrade_body(self, version: u32) -> Result>; - fn native_model_encode(&self) -> Result> { 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> { - 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) - } }