Skip to main content

_mtc/
lib.rs

1//! Python extension module for Merkle Tree Certificates (`synta._mtc`).
2//!
3//! Registers itself as `synta.mtc` in `sys.modules`.  Requires that
4//! `synta._synta` is already loaded (i.e. `import synta` must precede
5//! `import synta._mtc`).
6
7use pyo3::prelude::*;
8use synta_python_common::install_submodule;
9
10pub mod mtc;
11
12/// `synta._mtc` — Merkle Tree Certificates extension module.
13///
14/// Builds the `synta.mtc` submodule and registers it in `sys.modules`.
15#[pymodule]
16fn _mtc(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
17    // synta._synta must already be loaded (import synta loads it first).
18    let _base = py.import("synta._synta").map_err(|_| {
19        pyo3::exceptions::PyImportError::new_err(
20            "synta._mtc requires 'import synta' before 'import synta._mtc'",
21        )
22    })?;
23
24    let mtc_m = PyModule::new(py, "synta.mtc")?;
25    mtc::register_mtc_module(&mtc_m)?;
26    install_submodule(
27        m,
28        &mtc_m,
29        "synta.mtc",
30        Some("Merkle Tree Certificate ASN.1 types (draft-ietf-plants-merkle-tree-certs)."),
31    )?;
32
33    m.add("__version__", env!("CARGO_PKG_VERSION"))?;
34    Ok(())
35}