File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -54,20 +54,16 @@ impl IndividualMetadata {
5454
5555/// Decode mutation metadata generated in rust via the `bincode` crate.
5656#[ 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" ) )
6260}
6361
6462/// Decode individual metadata generated in rust via the `bincode` crate.
6563#[ 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" ) )
7167}
7268
7369/// A Python module implemented in Rust.
You can’t perform that action at this time.
0 commit comments