File tree 1 file changed +6
-10
lines changed 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -54,20 +54,16 @@ impl IndividualMetadata {
54
54
55
55
/// Decode mutation metadata generated in rust via the `bincode` crate.
56
56
#[ pyfunction]
57
- fn decode_bincode_mutation_metadata ( md : Vec < u8 > ) -> MutationMetadata {
58
- // NOTE: the unwrap here is not correct for production code
59
- // and a failure will crash the Python interpreter!
60
- let md = bincode:: deserialize_from ( md. as_slice ( ) ) . unwrap ( ) ;
61
- md
57
+ fn decode_bincode_mutation_metadata ( md : Vec < u8 > ) -> PyResult < MutationMetadata > {
58
+ bincode:: deserialize_from ( md. as_slice ( ) )
59
+ . map_err ( |_| pyo3:: exceptions:: PyValueError :: new_err ( "error decoding mutation metadata" ) )
62
60
}
63
61
64
62
/// Decode individual metadata generated in rust via the `bincode` crate.
65
63
#[ pyfunction]
66
- fn decode_bincode_individual_metadata ( md : Vec < u8 > ) -> IndividualMetadata {
67
- // NOTE: the unwrap here is not correct for production code
68
- // and a failure will crash the Python interpreter!
69
- let md = bincode:: deserialize_from ( md. as_slice ( ) ) . unwrap ( ) ;
70
- md
64
+ fn decode_bincode_individual_metadata ( md : Vec < u8 > ) -> PyResult < IndividualMetadata > {
65
+ bincode:: deserialize_from ( md. as_slice ( ) )
66
+ . map_err ( |_| pyo3:: exceptions:: PyValueError :: new_err ( "error decoding individual metadata" ) )
71
67
}
72
68
73
69
/// A Python module implemented in Rust.
You can’t perform that action at this time.
0 commit comments