From 90f2603de4790f7ac3a13096eae4e1cb3db9d7d4 Mon Sep 17 00:00:00 2001 From: zyansheep Date: Mon, 21 Mar 2022 12:08:46 -0400 Subject: [PATCH] upgrade rkyv to 0.7 --- Cargo.toml | 2 +- src/base/array_storage.rs | 16 ++++------------ src/base/dimension.rs | 8 +------- src/base/matrix.rs | 16 ++++------------ src/base/unit.rs | 16 ++++------------ src/geometry/isometry.rs | 23 ++++++----------------- src/geometry/quaternion.rs | 16 ++++------------ src/geometry/scale.rs | 16 ++++------------ src/geometry/translation.rs | 16 ++++------------ 9 files changed, 32 insertions(+), 97 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a629b554..907442cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,7 @@ alga = { version = "0.9", default-features = false, optional = true } rand_distr = { version = "0.4", default-features = false, optional = true } matrixmultiply = { version = "0.3", optional = true } serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true } -rkyv = { version = "~0.6.4", default-features = false, features = ["const_generics"], optional = true } +rkyv = { version = "~0.7.1", optional = true } mint = { version = "0.5", optional = true } quickcheck = { version = "1", optional = true } pest = { version = "2", optional = true } diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index b6bd236a..d6dab40a 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -277,23 +277,15 @@ unsafe impl by #[cfg(feature = "rkyv-serialize-no-std")] mod rkyv_impl { use super::ArrayStorage; - use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; + use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize}; impl Archive for ArrayStorage { type Archived = ArrayStorage; type Resolver = <[[T; R]; C] as Archive>::Resolver; - fn resolve( - &self, - pos: usize, - resolver: Self::Resolver, - out: &mut core::mem::MaybeUninit, - ) { - self.0.resolve( - pos + offset_of!(Self::Archived, 0), - resolver, - project_struct!(out: Self::Archived => 0), - ); + unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { + let (fp, fo) = out_field!(out.0); + self.0.resolve(pos + fp, resolver, fo); } } diff --git a/src/base/dimension.rs b/src/base/dimension.rs index de51339f..39e0459d 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -242,13 +242,7 @@ mod rkyv_impl { type Archived = Self; type Resolver = (); - fn resolve( - &self, - _: usize, - _: Self::Resolver, - _: &mut core::mem::MaybeUninit, - ) { - } + unsafe fn resolve(&self, _: usize, _: Self::Resolver, _: *mut Self::Archived) {} } impl Serialize for Const { diff --git a/src/base/matrix.rs b/src/base/matrix.rs index f12cb3fa..1b598952 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -292,23 +292,15 @@ where mod rkyv_impl { use super::Matrix; use core::marker::PhantomData; - use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; + use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize}; impl Archive for Matrix { type Archived = Matrix; type Resolver = S::Resolver; - fn resolve( - &self, - pos: usize, - resolver: Self::Resolver, - out: &mut core::mem::MaybeUninit, - ) { - self.data.resolve( - pos + offset_of!(Self::Archived, data), - resolver, - project_struct!(out: Self::Archived => data), - ); + unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { + let (fp, fo) = out_field!(out.data); + self.data.resolve(pos + fp, resolver, fo); } } diff --git a/src/base/unit.rs b/src/base/unit.rs index bb8b56a1..d82c67ec 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -61,23 +61,15 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Unit { #[cfg(feature = "rkyv-serialize-no-std")] mod rkyv_impl { use super::Unit; - use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; + use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize}; impl Archive for Unit { type Archived = Unit; type Resolver = T::Resolver; - fn resolve( - &self, - pos: usize, - resolver: Self::Resolver, - out: &mut ::core::mem::MaybeUninit, - ) { - self.value.resolve( - pos + offset_of!(Self::Archived, value), - resolver, - project_struct!(out: Self::Archived => value), - ); + unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { + let (fp, fo) = out_field!(out.value); + self.value.resolve(pos + fp, resolver, fo); } } diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index 0179f1ff..1b4eb26f 100755 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -77,7 +77,7 @@ pub struct Isometry { mod rkyv_impl { use super::Isometry; use crate::{base::Scalar, geometry::Translation}; - use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; + use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize}; impl Archive for Isometry where @@ -86,22 +86,11 @@ mod rkyv_impl { type Archived = Isometry; type Resolver = (R::Resolver, as Archive>::Resolver); - fn resolve( - &self, - pos: usize, - resolver: Self::Resolver, - out: &mut core::mem::MaybeUninit, - ) { - self.rotation.resolve( - pos + offset_of!(Self::Archived, rotation), - resolver.0, - project_struct!(out: Self::Archived => rotation), - ); - self.translation.resolve( - pos + offset_of!(Self::Archived, translation), - resolver.1, - project_struct!(out: Self::Archived => translation), - ); + unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { + let (fp, fo) = out_field!(out.rotation); + self.rotation.resolve(pos + fp, resolver.0, fo); + let (fp, fo) = out_field!(out.translation); + self.translation.resolve(pos + fp, resolver.1, fo); } } diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 987c9757..43f31e2e 100755 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -101,23 +101,15 @@ where mod rkyv_impl { use super::Quaternion; use crate::base::Vector4; - use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; + use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize}; impl Archive for Quaternion { type Archived = Quaternion; type Resolver = as Archive>::Resolver; - fn resolve( - &self, - pos: usize, - resolver: Self::Resolver, - out: &mut core::mem::MaybeUninit, - ) { - self.coords.resolve( - pos + offset_of!(Self::Archived, coords), - resolver, - project_struct!(out: Self::Archived => coords), - ); + unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { + let (fp, fo) = out_field!(out.coords); + self.coords.resolve(pos + fp, resolver, fo); } } diff --git a/src/geometry/scale.rs b/src/geometry/scale.rs index abaeeccc..23265bba 100755 --- a/src/geometry/scale.rs +++ b/src/geometry/scale.rs @@ -88,23 +88,15 @@ where mod rkyv_impl { use super::Scale; use crate::base::SVector; - use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; + use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize}; impl Archive for Scale { type Archived = Scale; type Resolver = as Archive>::Resolver; - fn resolve( - &self, - pos: usize, - resolver: Self::Resolver, - out: &mut core::mem::MaybeUninit, - ) { - self.vector.resolve( - pos + offset_of!(Self::Archived, vector), - resolver, - project_struct!(out: Self::Archived => vector), - ); + unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { + let (fp, fo) = out_field!(out.vector); + self.vector.resolve(pos + fp, resolver, fo); } } diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index e1921d0a..e7dc5ee8 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -88,23 +88,15 @@ where mod rkyv_impl { use super::Translation; use crate::base::SVector; - use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; + use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize}; impl Archive for Translation { type Archived = Translation; type Resolver = as Archive>::Resolver; - fn resolve( - &self, - pos: usize, - resolver: Self::Resolver, - out: &mut core::mem::MaybeUninit, - ) { - self.vector.resolve( - pos + offset_of!(Self::Archived, vector), - resolver, - project_struct!(out: Self::Archived => vector), - ); + unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) { + let (fp, fo) = out_field!(out.vector); + self.vector.resolve(pos + fp, resolver, fo); } }