Macro pyo3::raw_pycfunction [−][src]
macro_rules! raw_pycfunction {
($function_name : ident) => { ... };
}
Expand description
Returns the function that is called in the C-FFI.
Use this together with #[pyfunction]
and types::PyCFunction.
use pyo3::prelude::*;
use pyo3::types::PyCFunction;
use pyo3::raw_pycfunction;
#[pyfunction]
fn some_fun() -> PyResult<()> {
Ok(())
}
#[pymodule]
fn module(_py: Python, module: &PyModule) -> PyResult<()> {
let ffi_wrapper_fun = raw_pycfunction!(some_fun);
let docs = "Some documentation string with null-termination\0";
let py_cfunction =
PyCFunction::new_with_keywords(ffi_wrapper_fun, "function_name", docs, module.into())?;
module.add_function(py_cfunction)
}