Skip to content

plissken-core::parser::pymodule

Rust

What PyO3 module functions register

A #[pymodule] function names a Python module and adds its classes and functions:

#[pymodule]
fn cloaca(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<bindings::runner::PyDefaultRunner>()?;
m.add_function(wrap_pyfunction!(loader::py_var, m)?)?;
register_authoring(m)?; // a helper adds more
let sub = PyModule::new(m.py(), "events")?;
sub.add_class::<Event>()?;
m.add_submodule(&sub)?; // the submodule cloaca.events
Ok(())
}

This module reads such a function, and any helper that gets a module as a parameter, into a PyModuleRegistrar. The synthesis of the Python API follows the calls from each #[pymodule] function.