synta-python-mtc 0.2.6

Python extension module for synta Merkle Tree Certificates types
Documentation
//! Python extension module for Merkle Tree Certificates (`synta._mtc`).
//!
//! Registers itself as `synta.mtc` in `sys.modules`.  Requires that
//! `synta._synta` is already loaded (i.e. `import synta` must precede
//! `import synta._mtc`).

use pyo3::prelude::*;
use synta_python_common::install_submodule;

pub mod mtc;

/// `synta._mtc` — Merkle Tree Certificates extension module.
///
/// Builds the `synta.mtc` submodule and registers it in `sys.modules`.
#[pymodule]
fn _mtc(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
    // synta._synta must already be loaded (import synta loads it first).
    let _base = py.import("synta._synta").map_err(|_| {
        pyo3::exceptions::PyImportError::new_err(
            "synta._mtc requires 'import synta' before 'import synta._mtc'",
        )
    })?;

    let mtc_m = PyModule::new(py, "synta.mtc")?;
    mtc::register_mtc_module(&mtc_m)?;
    install_submodule(
        m,
        &mtc_m,
        "synta.mtc",
        Some("Merkle Tree Certificate ASN.1 types (draft-ietf-plants-merkle-tree-certs)."),
    )?;

    m.add("__version__", env!("CARGO_PKG_VERSION"))?;
    Ok(())
}