@@ -315,36 +315,6 @@ pub fn read_manifest_entries(bs: &[u8]) -> PyManifest {
315
315
}
316
316
}
317
317
318
- #[ pyclass]
319
- // #[derive(Clone)]
320
- pub struct PartitionSpecProviderCallbackHolder {
321
- callback : Py < PyAny > ,
322
- }
323
-
324
- #[ pymethods]
325
- impl PartitionSpecProviderCallbackHolder {
326
- #[ new]
327
- fn new ( callback : Py < PyAny > ) -> Self {
328
- Self { callback }
329
- }
330
-
331
- fn trigger_from_python ( & self , id : i32 ) -> PyResult < String > {
332
- Self :: do_the_callback ( self , id)
333
- }
334
- }
335
-
336
- impl PartitionSpecProviderCallbackHolder {
337
- /// Simulate calling the Python callback from "pure Rust"
338
- pub fn do_the_callback ( & self , id : i32 ) -> PyResult < String > {
339
- Python :: with_gil ( |py| {
340
- let result = self . callback . call1 ( py, ( id, ) ) ?; // Call the Python function
341
- let string = result. extract :: < String > ( py) ?; // Try converting the result to a Rust String
342
- Ok ( string)
343
- } )
344
- }
345
- }
346
-
347
-
348
318
#[ pyclass]
349
319
pub struct PyManifestList {
350
320
inner : ManifestList ,
@@ -360,30 +330,9 @@ impl crate::manifest::PyManifestList {
360
330
361
331
362
332
#[ pyfunction]
363
- pub fn read_manifest_list ( bs : & [ u8 ] , cb : & PartitionSpecProviderCallbackHolder ) -> PyManifestList {
364
- // TODO: Some error handling
365
- let provider = move |_id| {
366
- let bound = cb. do_the_callback ( _id) . unwrap ( ) ;
367
- let json = bound. as_str ( ) ;
368
-
369
- // I don't fully comprehend the deserializer here,
370
- // it works for a Type, but not for a StructType
371
- // So I had to do some awkward stuff to make it work
372
- let res: Result < Type , _ > = serde_json:: from_str ( json) ;
373
-
374
- let result: Result < Option < StructType > , Error > = match res {
375
- Ok ( Type :: Struct ( s) ) => Ok ( Some ( s) ) ,
376
- _ => Err ( Error :: new (
377
- ErrorKind :: DataInvalid ,
378
- format ! ( "Invalid JSON: {}" , json) ,
379
- ) )
380
- } ;
381
-
382
- result
383
- } ;
384
-
333
+ pub fn read_manifest_list ( bs : & [ u8 ] ) -> PyManifestList {
385
334
PyManifestList {
386
- inner : ManifestList :: parse_with_version ( bs, FormatVersion :: V2 , provider ) . unwrap ( )
335
+ inner : ManifestList :: parse_with_version ( bs, FormatVersion :: V2 ) . unwrap ( )
387
336
}
388
337
}
389
338
@@ -392,7 +341,6 @@ pub fn register_module(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()>
392
341
393
342
this. add_function ( wrap_pyfunction ! ( read_manifest_entries, & this) ?) ?;
394
343
this. add_function ( wrap_pyfunction ! ( read_manifest_list, & this) ?) ?;
395
- this. add_class :: < PartitionSpecProviderCallbackHolder > ( ) ?;
396
344
397
345
m. add_submodule ( & this) ?;
398
346
py. import ( "sys" ) ?
0 commit comments