monarch_hyperactor/
testing.rs1use pyo3::prelude::*;
15
16#[pyclass(name = "TestStruct", module = "monarch._src.actor.testing")]
17pub struct PyTestStruct {
18 value: i64,
19}
20
21#[pymethods]
22impl PyTestStruct {
23 #[new]
24 fn new(value: i64) -> Self {
25 Self { value }
26 }
27
28 fn rust_method(&self) -> i64 {
29 self.value
30 }
31
32 fn shared_method(&self) -> String {
33 "from_rust".to_string()
34 }
35}
36
37#[pyfunction]
38fn _make_test_struct(value: i64) -> PyTestStruct {
39 PyTestStruct { value }
40}
41
42pub fn register_python_bindings(module: &Bound<'_, PyModule>) -> PyResult<()> {
43 module.add_class::<PyTestStruct>()?;
44 module.add_function(wrap_pyfunction!(_make_test_struct, module)?)?;
45 Ok(())
46}