This repository has been archived on 2024-10-16. You can view files and clone it, but cannot push or open issues or pull requests.
2023-09-15 17:00:22 +02:00
|
|
|
use pyo3::prelude::*;
|
2023-09-29 13:42:37 +02:00
|
|
|
// FIXME: simply importing libpt causes maturin to fail,
|
|
|
|
// -> `liblibpt.so` not found
|
|
|
|
// It works without the import
|
|
|
|
use libpt;
|
2023-09-15 17:00:22 +02:00
|
|
|
|
2023-09-29 13:42:37 +02:00
|
|
|
/// Formats the sum of two numbers as string.
|
2023-09-15 17:00:22 +02:00
|
|
|
#[pyfunction]
|
2023-09-29 13:42:37 +02:00
|
|
|
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
|
|
|
|
Ok((a + b).to_string())
|
2023-09-15 17:00:22 +02:00
|
|
|
}
|
|
|
|
|
2023-09-29 13:42:37 +02:00
|
|
|
/// A Python module implemented in Rust.
|
2023-09-15 17:00:22 +02:00
|
|
|
#[pymodule]
|
2023-09-29 13:42:37 +02:00
|
|
|
fn _libpt(_py: Python, m: &PyModule) -> PyResult<()> {
|
|
|
|
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
|
2023-09-20 14:32:25 +02:00
|
|
|
Ok(())
|
|
|
|
}
|