@@ -20,22 +20,22 @@ pub enum Error {
2020 Io ( #[ from] std:: io:: Error ) ,
2121
2222 #[ error( "Redb error: {0}" ) ]
23- Redb ( # [ from ] redb:: Error ) ,
23+ Redb ( Box < redb:: Error > ) ,
2424
2525 #[ error( "Redb db error: {0}" ) ]
26- RedbDb ( # [ from ] redb:: DatabaseError ) ,
26+ RedbDb ( Box < redb:: DatabaseError > ) ,
2727
2828 #[ error( "Redb commit error: {0}" ) ]
29- RedbCommit ( # [ from ] redb:: CommitError ) ,
29+ RedbCommit ( Box < redb:: CommitError > ) ,
3030
3131 #[ error( "Redb transaction error: {0}" ) ]
32- RedbTransaction ( # [ from ] redb:: TransactionError ) ,
32+ RedbTransaction ( Box < redb:: TransactionError > ) ,
3333
3434 #[ error( "Redb table error: {0}" ) ]
35- RedbTable ( # [ from ] redb:: TableError ) ,
35+ RedbTable ( Box < redb:: TableError > ) ,
3636
3737 #[ error( "Redb storage error: {0}" ) ]
38- RedbStorage ( # [ from ] redb:: StorageError ) ,
38+ RedbStorage ( Box < redb:: StorageError > ) ,
3939
4040 #[ error( "FromHex error: {0}" ) ]
4141 FromHex ( #[ from] hex:: FromHexError ) ,
@@ -44,7 +44,43 @@ pub enum Error {
4444 DataNotFound ,
4545}
4646
47- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
47+ impl From < redb:: Error > for Error {
48+ fn from ( err : redb:: Error ) -> Self {
49+ Error :: Redb ( Box :: new ( err) )
50+ }
51+ }
52+
53+ impl From < redb:: DatabaseError > for Error {
54+ fn from ( err : redb:: DatabaseError ) -> Self {
55+ Error :: RedbDb ( Box :: new ( err) )
56+ }
57+ }
58+
59+ impl From < redb:: CommitError > for Error {
60+ fn from ( err : redb:: CommitError ) -> Self {
61+ Error :: RedbCommit ( Box :: new ( err) )
62+ }
63+ }
64+
65+ impl From < redb:: TransactionError > for Error {
66+ fn from ( err : redb:: TransactionError ) -> Self {
67+ Error :: RedbTransaction ( Box :: new ( err) )
68+ }
69+ }
70+
71+ impl From < redb:: TableError > for Error {
72+ fn from ( err : redb:: TableError ) -> Self {
73+ Error :: RedbTable ( Box :: new ( err) )
74+ }
75+ }
76+
77+ impl From < redb:: StorageError > for Error {
78+ fn from ( err : redb:: StorageError ) -> Self {
79+ Error :: RedbStorage ( Box :: new ( err) )
80+ }
81+ }
82+
83+ #[ derive( Debug , Clone , Serialize , Deserialize , bincode:: Encode , bincode:: Decode ) ]
4884struct ChainRecord {
4985 block_number : u64 ,
5086 slot_number : u64 ,
@@ -73,7 +109,8 @@ struct ChainRecord {
73109
74110impl Value for ChainRecord {
75111 type SelfType < ' a > = Self ;
76- type AsBytes < ' a > = Vec < u8 >
112+ type AsBytes < ' a >
113+ = Vec < u8 >
77114 where
78115 Self : ' a ;
79116
@@ -86,23 +123,23 @@ impl Value for ChainRecord {
86123 where
87124 Self : ' a ,
88125 {
89- bincode:: deserialize ( data) . unwrap ( )
126+ bincode:: decode_from_slice ( data, bincode :: config :: legacy ( ) ) . unwrap ( ) . 0
90127 }
91128
92129 fn as_bytes < ' a , ' b : ' a > ( value : & ' a Self :: SelfType < ' b > ) -> Self :: AsBytes < ' a >
93130 where
94131 Self : ' a ,
95132 Self : ' b ,
96133 {
97- bincode:: serialize ( value) . unwrap ( )
134+ bincode:: encode_to_vec ( value, bincode :: config :: legacy ( ) ) . unwrap ( )
98135 }
99136
100137 fn type_name ( ) -> TypeName {
101138 TypeName :: new ( stringify ! ( ChainRecord ) )
102139 }
103140}
104141
105- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
142+ #[ derive( Debug , Clone , Serialize , Deserialize , bincode :: Encode , bincode :: Decode ) ]
106143struct SlotsRecord {
107144 epoch : u64 ,
108145 pool_id : Vec < u8 > ,
@@ -113,7 +150,8 @@ struct SlotsRecord {
113150
114151impl Value for SlotsRecord {
115152 type SelfType < ' a > = Self ;
116- type AsBytes < ' a > = Vec < u8 >
153+ type AsBytes < ' a >
154+ = Vec < u8 >
117155 where
118156 Self : ' a ;
119157
@@ -126,15 +164,15 @@ impl Value for SlotsRecord {
126164 where
127165 Self : ' a ,
128166 {
129- bincode:: deserialize ( data) . unwrap ( )
167+ bincode:: decode_from_slice ( data, bincode :: config :: legacy ( ) ) . unwrap ( ) . 0
130168 }
131169
132170 fn as_bytes < ' a , ' b : ' a > ( value : & ' a Self :: SelfType < ' b > ) -> Self :: AsBytes < ' a >
133171 where
134172 Self : ' a ,
135173 Self : ' b ,
136174 {
137- bincode:: serialize ( value) . unwrap ( )
175+ bincode:: encode_to_vec ( value, bincode :: config :: legacy ( ) ) . unwrap ( )
138176 }
139177
140178 fn type_name ( ) -> TypeName {
0 commit comments