Macro catalyst_entities::transmute_arkive
source · macro_rules! transmute_arkive { ($($name:ident($ty:ty => $repr:ty))*) => { ... }; ($name:ident, $ty:ty, $repr:ty) => { ... }; }
Expand description
Whevever ArckiveWith needs to be implemented on for example fieldless enum,
this macro can implement it by transmuting it to type that implements Archive.
use catalyst_entities::transmute_arkive;
use rkyv::{Archive, Serialize, Deserialize};
enum Foo {
A, B, B,
}
transmute_arkive! {
FooArchiver(Foo => u8),
}
#[derive(Archive, Serialize, Deserialize)]
struct Bar {
#[with(FooArchiver)]
foo: Foo,
}Note that this macro can be missued if type contains indirection, simpli transmuting references and pointers will almost certainly lead to UB upon deserialization.