trazaeo 0.5.2

Open-source provenance SDK and specification for verifiable EO and climate data workflows
Documentation
use super::util::{from_json, into_py_result, to_json};
use crate::python_facade as facade;
use pyo3::prelude::*;
use pyo3::types::PyModule;
use pyo3::wrap_pyfunction;

#[pyfunction]
pub(crate) fn build_dataset_bootstrap_bundle_json(input_json: &str) -> PyResult<String> {
    let input: facade::DatasetBootstrapWorkflowInput =
        from_json("parse dataset bootstrap workflow input", input_json)?;
    let bundle = into_py_result(facade::build_dataset_bootstrap_bundle(input))?;
    to_json("serialize dataset bootstrap bundle", &bundle)
}

#[pyfunction]
pub(crate) fn build_dataset_incremental_bundle_json(input_json: &str) -> PyResult<String> {
    let input: facade::DatasetIncrementalWorkflowInput =
        from_json("parse dataset incremental workflow input", input_json)?;
    let bundle = into_py_result(facade::build_dataset_incremental_bundle(input))?;
    to_json("serialize dataset incremental bundle", &bundle)
}

#[pyfunction]
pub(crate) fn build_dataset_delivery_proof_package_json(
    bundle_json: &str,
    range_proof_package_json: &str,
) -> PyResult<String> {
    let bundle: facade::DatasetProvenanceBundle =
        from_json("parse dataset provenance bundle", bundle_json)?;
    let range_proof_package: facade::RangeProofPackage =
        from_json("parse range proof package", range_proof_package_json)?;
    let package = into_py_result(facade::build_dataset_delivery_proof_package(
        &bundle,
        &range_proof_package,
    ))?;
    to_json("serialize dataset delivery proof package", &package)
}

pub(crate) fn register_dataset_workflow_bindings(m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(build_dataset_bootstrap_bundle_json, m)?)?;
    m.add_function(wrap_pyfunction!(build_dataset_incremental_bundle_json, m)?)?;
    m.add_function(wrap_pyfunction!(
        build_dataset_delivery_proof_package_json,
        m
    )?)?;
    Ok(())
}