| 1 |
{%- if bindings == "pyo3" -%} |
| 2 |
use pyo3::prelude::*; |
| 3 |
|
| 4 |
/// Formats the sum of two numbers as string. |
| 5 |
#[pyfunction] |
| 6 |
fn sum_as_string(a: usize, b: usize) -> PyResult<String> { |
| 7 |
Ok((a + b).to_string()) |
| 8 |
} |
| 9 |
|
| 10 |
/// A Python module implemented in Rust. |
| 11 |
#[pymodule] |
| 12 |
fn {{crate_name}}(m: &Bound<'_, PyModule>) -> PyResult<()> { |
| 13 |
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; |
| 14 |
Ok(()) |
| 15 |
} |
| 16 |
{%- elif bindings == "uniffi" -%} |
| 17 |
fn add(a: u32, b: u32) -> u32 { |
| 18 |
a + b |
| 19 |
} |
| 20 |
|
| 21 |
uniffi::include_scaffolding!("example"); |
| 22 |
{%- endif %} |