@@ -3,10 +3,10 @@ use rkyv::api::high::{HighSerializer, HighValidator};
33use rkyv:: de:: Pool ;
44use rkyv:: rancor:: Strategy ;
55use rkyv:: ser:: allocator:: ArenaHandle ;
6+ pub use rkyv:: util:: AlignedVec ;
67use rkyv:: { bytecheck, rancor, Archive , Deserialize , Serialize } ;
78use std:: error:: Error ;
89use std:: sync:: Arc ;
9- pub use rkyv:: util:: AlignedVec ;
1010
1111/// A codec that relies on `rkyv` to encode data in the msgpack format.
1212///
@@ -15,13 +15,13 @@ pub struct RkyvCodec;
1515
1616impl < T > Encoder < T > for RkyvCodec
1717where
18- T : for < ' a > Serialize < HighSerializer < AlignedVec , ArenaHandle < ' a > , rancor:: Error > > ,
18+ T : for < ' a > Serialize < HighSerializer < Vec < u8 > , ArenaHandle < ' a > , rancor:: Error > > ,
1919{
2020 type Error = rancor:: Error ;
21- type Encoded = AlignedVec ;
21+ type Encoded = Vec < u8 > ;
2222
2323 fn encode ( val : & T ) -> Result < Self :: Encoded , Self :: Error > {
24- rkyv:: api:: high:: to_bytes_in ( val, AlignedVec :: new ( ) )
24+ rkyv:: api:: high:: to_bytes_in ( val, Vec :: new ( ) )
2525 }
2626}
2727
@@ -33,16 +33,17 @@ where
3333 + Deserialize < T , Strategy < Pool , rancor:: Error > > ,
3434{
3535 type Error = Arc < dyn Error > ;
36- type Encoded = AlignedVec ;
36+ type Encoded = [ u8 ] ;
3737
3838 fn decode ( val : & Self :: Encoded ) -> Result < T , Self :: Error > {
39- rkyv:: from_bytes :: < T , rancor:: Error > ( val) . map_err ( |e| Arc :: new ( e) as Arc < dyn Error > )
39+ let mut aligned = AlignedVec :: < 16 > :: with_capacity ( val. len ( ) ) ;
40+ aligned. extend_from_slice ( val) ;
41+ rkyv:: from_bytes :: < T , rancor:: Error > ( & aligned) . map_err ( |e| Arc :: new ( e) as Arc < dyn Error > )
4042 }
4143}
4244
4345#[ cfg( test) ]
4446mod tests {
45- use rkyv:: util:: AlignedVec ;
4647 use super :: * ;
4748
4849 #[ test]
0 commit comments