@@ -118,7 +118,7 @@ where
118
118
/// let mut new_store =
119
119
/// Store::create(&MAGIC_BYTES, &new_file_path).expect("must create new file");
120
120
/// if let Some(aggregated_changeset) = changeset {
121
- /// new_store.append(& aggregated_changeset)?;
121
+ /// new_store.append(aggregated_changeset.as_ref() )?;
122
122
/// }
123
123
/// // The following will overwrite the original file. You will loose the corrupted
124
124
/// // portion of the original file forever.
@@ -152,7 +152,7 @@ where
152
152
f. read_exact ( & mut magic_buf) ?;
153
153
if magic_buf != magic {
154
154
return Err ( StoreErrorWithDump {
155
- changeset : Option :: < C > :: None ,
155
+ changeset : Option :: < Box < C > > :: None ,
156
156
error : StoreError :: InvalidMagicBytes {
157
157
got : magic_buf,
158
158
expected : magic. to_vec ( ) ,
@@ -194,7 +194,7 @@ where
194
194
Ok ( aggregated_changeset)
195
195
}
196
196
Err ( iter_error) => Err ( StoreErrorWithDump {
197
- changeset : aggregated_changeset,
197
+ changeset : aggregated_changeset. map ( Box :: new ) ,
198
198
error : iter_error,
199
199
} ) ,
200
200
} ,
@@ -220,7 +220,7 @@ where
220
220
Self :: create ( magic, file_path)
221
221
. map ( |store| ( store, Option :: < C > :: None ) )
222
222
. map_err ( |err : StoreError | StoreErrorWithDump {
223
- changeset : Option :: < C > :: None ,
223
+ changeset : Option :: < Box < C > > :: None ,
224
224
error : err,
225
225
} )
226
226
}
@@ -257,7 +257,7 @@ where
257
257
#[ derive( Debug ) ]
258
258
pub struct StoreErrorWithDump < C > {
259
259
/// The partially-aggregated changeset.
260
- pub changeset : Option < C > ,
260
+ pub changeset : Option < Box < C > > ,
261
261
262
262
/// The [`StoreError`]
263
263
pub error : StoreError ,
@@ -266,7 +266,7 @@ pub struct StoreErrorWithDump<C> {
266
266
impl < C > From < io:: Error > for StoreErrorWithDump < C > {
267
267
fn from ( value : io:: Error ) -> Self {
268
268
Self {
269
- changeset : Option :: < C > :: None ,
269
+ changeset : Option :: < Box < C > > :: None ,
270
270
error : StoreError :: Io ( value) ,
271
271
}
272
272
}
@@ -371,7 +371,7 @@ mod test {
371
371
changeset,
372
372
error : StoreError :: Bincode ( _) ,
373
373
} ) => {
374
- assert_eq ! ( changeset, Some ( test_changesets) )
374
+ assert_eq ! ( changeset, Some ( Box :: new ( test_changesets) ) )
375
375
}
376
376
unexpected_res => panic ! ( "unexpected result: {unexpected_res:?}" ) ,
377
377
}
@@ -399,7 +399,7 @@ mod test {
399
399
changeset,
400
400
error : StoreError :: Bincode ( _) ,
401
401
} ) => {
402
- assert_eq ! ( changeset, Some ( test_changesets) )
402
+ assert_eq ! ( changeset, Some ( Box :: new ( test_changesets) ) )
403
403
}
404
404
unexpected_res => panic ! ( "unexpected result: {unexpected_res:?}" ) ,
405
405
}
@@ -500,10 +500,14 @@ mod test {
500
500
. expect_err ( "should fail to aggregate" ) ;
501
501
assert_eq ! (
502
502
err. changeset,
503
- changesets. iter( ) . cloned( ) . reduce( |mut acc, cs| {
504
- Merge :: merge( & mut acc, cs) ;
505
- acc
506
- } ) ,
503
+ changesets
504
+ . iter( )
505
+ . cloned( )
506
+ . reduce( |mut acc, cs| {
507
+ Merge :: merge( & mut acc, cs) ;
508
+ acc
509
+ } )
510
+ . map( Box :: new) ,
507
511
"should recover all changesets that are written in full" ,
508
512
) ;
509
513
// Remove file and start again
0 commit comments