Add rkyv implementations for a few types
This commit is contained in:
parent
511a51592f
commit
b48b104d57
|
@ -48,6 +48,8 @@ convert-bytemuck = [ "bytemuck" ]
|
||||||
serde-serialize-no-std = [ "serde", "num-complex/serde" ]
|
serde-serialize-no-std = [ "serde", "num-complex/serde" ]
|
||||||
serde-serialize = [ "serde-serialize-no-std", "serde/std" ]
|
serde-serialize = [ "serde-serialize-no-std", "serde/std" ]
|
||||||
abomonation-serialize = [ "abomonation" ]
|
abomonation-serialize = [ "abomonation" ]
|
||||||
|
rkyv-serialize-no-std = [ "rkyv" ]
|
||||||
|
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std" ]
|
||||||
|
|
||||||
# Randomness
|
# Randomness
|
||||||
## To use rand in a #[no-std] environment, enable the
|
## To use rand in a #[no-std] environment, enable the
|
||||||
|
@ -74,6 +76,7 @@ rand_distr = { version = "0.4", default-features = false, optional = true }
|
||||||
matrixmultiply = { version = "0.3", optional = true }
|
matrixmultiply = { version = "0.3", optional = true }
|
||||||
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
|
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
|
||||||
abomonation = { version = "0.7", optional = true }
|
abomonation = { version = "0.7", optional = true }
|
||||||
|
rkyv = { version = "~0.6.3", default-features = false, features = ["const_generics"], optional = true }
|
||||||
mint = { version = "0.5", optional = true }
|
mint = { version = "0.5", optional = true }
|
||||||
glam = { version = "0.13", optional = true }
|
glam = { version = "0.13", optional = true }
|
||||||
quickcheck = { version = "1", optional = true }
|
quickcheck = { version = "1", optional = true }
|
||||||
|
|
|
@ -18,6 +18,9 @@ use std::mem;
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use abomonation::Abomonation;
|
use abomonation::Abomonation;
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::default_allocator::DefaultAllocator;
|
use crate::base::default_allocator::DefaultAllocator;
|
||||||
use crate::base::dimension::{Const, ToTypenum};
|
use crate::base::dimension::{Const, ToTypenum};
|
||||||
|
@ -34,6 +37,7 @@ use crate::base::Scalar;
|
||||||
/// A array-based statically sized matrix data storage.
|
/// A array-based statically sized matrix data storage.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||||
pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
|
pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
|
||||||
|
|
||||||
// TODO: remove this once the stdlib implements Default for arrays.
|
// TODO: remove this once the stdlib implements Default for arrays.
|
||||||
|
|
|
@ -11,6 +11,9 @@ use typenum::{self, Diff, Max, Maximum, Min, Minimum, Prod, Quot, Sum, Unsigned}
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
|
||||||
/// Dim of dynamically-sized algebraic entities.
|
/// Dim of dynamically-sized algebraic entities.
|
||||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
||||||
pub struct Dynamic {
|
pub struct Dynamic {
|
||||||
|
@ -197,6 +200,7 @@ dim_ops!(
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||||
pub struct Const<const R: usize>;
|
pub struct Const<const R: usize>;
|
||||||
|
|
||||||
/// Trait implemented exclusively by type-level integers.
|
/// Trait implemented exclusively by type-level integers.
|
||||||
|
|
|
@ -16,6 +16,9 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use abomonation::Abomonation;
|
use abomonation::Abomonation;
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
|
||||||
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, Field, SupersetOf};
|
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, Field, SupersetOf};
|
||||||
use simba::simd::SimdPartialOrd;
|
use simba::simd::SimdPartialOrd;
|
||||||
|
|
||||||
|
@ -153,6 +156,7 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
||||||
/// some concrete types for `T` and a compatible data storage type `S`).
|
/// some concrete types for `T` and a compatible data storage type `S`).
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||||
pub struct Matrix<T, R, C, S> {
|
pub struct Matrix<T, R, C, S> {
|
||||||
/// The data storage that contains all the matrix components. Disappointed?
|
/// The data storage that contains all the matrix components. Disappointed?
|
||||||
///
|
///
|
||||||
|
|
|
@ -6,6 +6,9 @@ use std::ops::Deref;
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use abomonation::Abomonation;
|
use abomonation::Abomonation;
|
||||||
|
|
||||||
|
@ -26,6 +29,7 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
||||||
/// in their documentation, read their dedicated pages directly.
|
/// in their documentation, read their dedicated pages directly.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Hash, Debug, Copy)]
|
#[derive(Clone, Hash, Debug, Copy)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||||
pub struct Unit<T> {
|
pub struct Unit<T> {
|
||||||
pub(crate) value: T,
|
pub(crate) value: T,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ use std::io::{Result as IOResult, Write};
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use abomonation::Abomonation;
|
use abomonation::Abomonation;
|
||||||
|
|
||||||
|
@ -68,6 +71,7 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
||||||
DefaultAllocator: Allocator<T, Const<D>>,
|
DefaultAllocator: Allocator<T, Const<D>>,
|
||||||
Owned<T, Const<D>>: Deserialize<'de>"))
|
Owned<T, Const<D>>: Deserialize<'de>"))
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Serialize, Deserialize))]
|
||||||
pub struct Isometry<T: Scalar, R, const D: usize> {
|
pub struct Isometry<T: Scalar, R, const D: usize> {
|
||||||
/// The pure rotational part of this isometry.
|
/// The pure rotational part of this isometry.
|
||||||
pub rotation: R,
|
pub rotation: R,
|
||||||
|
|
|
@ -10,6 +10,9 @@ use crate::base::storage::Owned;
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use abomonation::Abomonation;
|
use abomonation::Abomonation;
|
||||||
|
|
||||||
|
@ -28,6 +31,7 @@ use crate::geometry::{Point3, Rotation};
|
||||||
/// that may be used as a rotation.
|
/// that may be used as a rotation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||||
pub struct Quaternion<T> {
|
pub struct Quaternion<T> {
|
||||||
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
|
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
|
||||||
pub coords: Vector4<T>,
|
pub coords: Vector4<T>,
|
||||||
|
|
|
@ -8,6 +8,9 @@ use std::io::{Result as IOResult, Write};
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use abomonation::Abomonation;
|
use abomonation::Abomonation;
|
||||||
|
|
||||||
|
@ -23,6 +26,7 @@ use crate::geometry::Point;
|
||||||
/// A translation.
|
/// A translation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||||
pub struct Translation<T, const D: usize> {
|
pub struct Translation<T, const D: usize> {
|
||||||
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is
|
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is
|
||||||
/// translated.
|
/// translated.
|
||||||
|
|
Loading…
Reference in New Issue