fn single_file_digests_to_bytes(
  py: Python,
  scheduler_ptr: PyScheduler,
  py_file_digests: PyList,
) -> CPyResult<PyList> {
  with_scheduler(py, scheduler_ptr, |scheduler| {
    let core = scheduler.core.clone();

    let digests: Vec<Digest> = py_file_digests
      .iter(py)
      .map(|item| crate::nodes::lift_file_digest(&core.types, &item))
      .collect::<Result<Vec<Digest>, _>>()
      .map_err(|e| PyErr::new::<exc::Exception, _>(py, (e,)))?;

    let digest_futures = digests.into_iter().map(|digest| {
      let store = core.store();
      async move {
        store
          .load_file_bytes_with(digest, |bytes| {
            let gil = Python::acquire_gil();
            let py = gil.python();
            externs::store_bytes(py, bytes)
          })
          .await
          .and_then(|maybe_bytes| {
            maybe_bytes.ok_or_else(|| format!("Error loading bytes from digest: {:?}", digest))
          })
      }
    });

    let bytes_values: Vec<PyObject> = py
      .allow_threads(|| {
        core.executor.block_on(
          future::try_join_all(digest_futures)
            .map_ok(|values: Vec<Value>| values.into_iter().map(|val| val.into()).collect()),
        )
      })
      .map_err(|e| PyErr::new::<exc::Exception, _>(py, (e,)))?;

    let output_list = PyList::new(py, &bytes_values);
    Ok(output_list)
  })
}
/// This functions assumes that the Digest in question represents the contents of a single File rather than a Directory,
/// and will fail on Digests representing a Directory.
This functions assumes that the Digest in question represents the contents of a single File rather than a Directory,
and will fail on Digests representing a Directory.
This functions assumes that the Digest in question represents the contents of a single File rather than a Directory and will fail on Digests representing a Directory .
fn single_file_digests_to_bytes(
  py: Python,
  scheduler_ptr: PyScheduler,
  py_file_digests: PyList,
) -> CPyResult<PyList> {
  with_scheduler(py, scheduler_ptr, |scheduler| {
    let core = scheduler.core.clone();
    let digests: Vec<Digest> = py_file_digests
      .iter(py)
      .map(|item| crate::nodes::lift_file_digest(&core.types, &item))
      .collect::<Result<Vec<Digest>, _>>()
      .map_err(|e| PyErr::new::<exc::Exception, _>(py, (e,)))?;
    let digest_futures = digests.into_iter().map(|digest| {
      let store = core.store();
      async move {
        store
          .load_file_bytes_with(digest, |bytes| {
            let gil = Python::acquire_gil();
            let py = gil.python();
            externs::store_bytes(py, bytes)
          })
          .await
          .and_then(|maybe_bytes| {
            maybe_bytes.ok_or_else(|| format!("Error loading bytes from digest: {:?}", digest))
          })
      }
    });
    let bytes_values: Vec<PyObject> = py
      .allow_threads(|| {
        core.executor.block_on(
          future::try_join_all(digest_futures)
            .map_ok(|values: Vec<Value>| values.into_iter().map(|val| val.into()).collect()),
        )
      })
      .map_err(|e| PyErr::new::<exc::Exception, _>(py, (e,)))?;
    let output_list = PyList::new(py, &bytes_values);
    Ok(output_list)
  })
}
fn single_file_digests_to_bytes ( py : Python , scheduler_ptr : PyScheduler , py_file_digests : PyList , ) -> CPyResult < PyList > { with_scheduler ( py , scheduler_ptr , | scheduler | { let core = scheduler . core . clone ( ) ; let digests : Vec < Digest > = py_file_digests . iter ( py ) . map ( | item | crate :: nodes :: lift_file_digest ( & core . types , & item ) ) . collect :: < Result < Vec < Digest > , _ > > ( ) . map_err ( | e | PyErr :: new :: < exc :: Exception , _ > ( py , ( e , ) ) ) ? ; let digest_futures = digests . into_iter ( ) . map ( | digest | { let store = core . store ( ) ; async move { store . load_file_bytes_with ( digest , | bytes | { let gil = Python :: acquire_gil ( ) ; let py = gil . python ( ) ; externs :: store_bytes ( py , bytes ) } ) . await . and_then ( | maybe_bytes | { maybe_bytes . ok_or_else ( | | format ! ( " " digest ) ) } ) } } ) ; let bytes_values : Vec < PyObject > = py . allow_threads ( | | { core . executor . block_on ( future :: try_join_all ( digest_futures ) . map_ok ( | values : Vec < Value > | values . into_iter ( ) . map ( | val | val . into ( ) ) . collect ( ) ) , ) } ) . map_err ( | e | PyErr :: new :: < exc :: Exception , _ > ( py , ( e , ) ) ) ? ; let output_list = PyList :: new ( py , & bytes_values ) ; Ok ( output_list ) } ) }
This functions assumes that the Digest in question represents the contents of a single File rather than a Directory,
and will fail on Digests representing a Directory.
This functions assumes that the Digest in question represents the contents of a single File rather than a Directory and will fail on Digests representing a Directory .
py
Python
scheduler_ptr
PyScheduler
py_file_digests
PyList
py
Python
scheduler_ptr
PyScheduler
py_file_digests
PyList