diff --git a/Cargo.toml b/Cargo.toml index 764c6bf..7732b4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ num-traits = { version = "0.2.14", default-features = false, features = ["libm"] zerocopy = { version = "0.6.0", default-features = false, optional = true } rand = { version = "0.8.5", default-features = false, optional = true } rand_distr = { version = "0.4.3", default-features = false, optional = true } +rkyv = { version = "0.7", optional = true } [target.'cfg(target_arch = "spirv")'.dependencies] crunchy = "0.2.2" diff --git a/src/bfloat.rs b/src/bfloat.rs index 2064afd..e311e20 100644 --- a/src/bfloat.rs +++ b/src/bfloat.rs @@ -36,6 +36,8 @@ pub(crate) mod convert; #[derive(Clone, Copy, Default)] #[repr(transparent)] #[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))] +#[cfg_attr(feature = "rkyv", archive(resolver = "Bf16Resolver"))] #[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))] #[cfg_attr(feature = "zerocopy", derive(AsBytes, FromBytes))] #[cfg_attr(kani, derive(kani::Arbitrary))] diff --git a/src/binary16.rs b/src/binary16.rs index d34dbfa..fc2373c 100644 --- a/src/binary16.rs +++ b/src/binary16.rs @@ -35,6 +35,8 @@ pub(crate) mod arch; #[derive(Clone, Copy, Default)] #[repr(transparent)] #[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))] +#[cfg_attr(feature = "rkyv", archive(resolver = "F16Resolver"))] #[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))] #[cfg_attr(feature = "zerocopy", derive(AsBytes, FromBytes))] #[cfg_attr(kani, derive(kani::Arbitrary))]