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 = [ "serde-serialize-no-std", "serde/std" ]
|
||||
abomonation-serialize = [ "abomonation" ]
|
||||
rkyv-serialize-no-std = [ "rkyv" ]
|
||||
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std" ]
|
||||
|
||||
# Randomness
|
||||
## 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 }
|
||||
serde = { version = "1.0", default-features = false, features = [ "derive" ], 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 }
|
||||
glam = { version = "0.13", optional = true }
|
||||
quickcheck = { version = "1", optional = true }
|
||||
|
@ -81,7 +84,7 @@ pest = { version = "2", optional = true }
|
|||
pest_derive = { version = "2", optional = true }
|
||||
bytemuck = { version = "1.5", optional = true }
|
||||
matrixcompare-core = { version = "0.1", optional = true }
|
||||
proptest = { version = "1", optional = true, default-features = false, features = ["std"] }
|
||||
proptest = { version = "1", optional = true, default-features = false, features = ["std"] }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0"
|
||||
|
|
|
@ -18,6 +18,9 @@ use std::mem;
|
|||
#[cfg(feature = "abomonation-serialize")]
|
||||
use abomonation::Abomonation;
|
||||
|
||||
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||
use rkyv::{Archive, Deserialize, Serialize};
|
||||
|
||||
use crate::base::allocator::Allocator;
|
||||
use crate::base::default_allocator::DefaultAllocator;
|
||||
use crate::base::dimension::{Const, ToTypenum};
|
||||
|
@ -34,6 +37,7 @@ use crate::base::Scalar;
|
|||
/// A array-based statically sized matrix data storage.
|
||||
#[repr(C)]
|
||||
#[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]);
|
||||
|
||||
// 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")]
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||
use rkyv::{Archive, Deserialize, Serialize};
|
||||
|
||||
/// Dim of dynamically-sized algebraic entities.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
||||
pub struct Dynamic {
|
||||
|
@ -197,6 +200,7 @@ dim_ops!(
|
|||
);
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||
pub struct Const<const R: usize>;
|
||||
|
||||
/// Trait implemented exclusively by type-level integers.
|
||||
|
|
|
@ -16,6 +16,9 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|||
#[cfg(feature = "abomonation-serialize")]
|
||||
use abomonation::Abomonation;
|
||||
|
||||
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||
use rkyv::{Archive, Deserialize, Serialize};
|
||||
|
||||
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, Field, SupersetOf};
|
||||
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`).
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||
pub struct Matrix<T, R, C, S> {
|
||||
/// The data storage that contains all the matrix components. Disappointed?
|
||||
///
|
||||
|
|
|
@ -6,6 +6,9 @@ use std::ops::Deref;
|
|||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||
use rkyv::{Archive, Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "abomonation-serialize")]
|
||||
use abomonation::Abomonation;
|
||||
|
||||
|
@ -26,6 +29,7 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
|||
/// in their documentation, read their dedicated pages directly.
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Hash, Debug, Copy)]
|
||||
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||
pub struct Unit<T> {
|
||||
pub(crate) value: T,
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ use std::io::{Result as IOResult, Write};
|
|||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||
use rkyv::{Archive, Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "abomonation-serialize")]
|
||||
use abomonation::Abomonation;
|
||||
|
||||
|
@ -68,6 +71,7 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
|||
DefaultAllocator: Allocator<T, Const<D>>,
|
||||
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> {
|
||||
/// The pure rotational part of this isometry.
|
||||
pub rotation: R,
|
||||
|
|
|
@ -10,6 +10,9 @@ use crate::base::storage::Owned;
|
|||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||
use rkyv::{Archive, Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "abomonation-serialize")]
|
||||
use abomonation::Abomonation;
|
||||
|
||||
|
@ -28,6 +31,7 @@ use crate::geometry::{Point3, Rotation};
|
|||
/// that may be used as a rotation.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||
pub struct Quaternion<T> {
|
||||
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
|
||||
pub coords: Vector4<T>,
|
||||
|
|
|
@ -8,6 +8,9 @@ use std::io::{Result as IOResult, Write};
|
|||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||
use rkyv::{Archive, Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "abomonation-serialize")]
|
||||
use abomonation::Abomonation;
|
||||
|
||||
|
@ -23,6 +26,7 @@ use crate::geometry::Point;
|
|||
/// A translation.
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "rkyv-serialize-no-std", derive(Archive, Deserialize, Serialize))]
|
||||
pub struct Translation<T, const D: usize> {
|
||||
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is
|
||||
/// translated.
|
||||
|
|
Loading…
Reference in New Issue