1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use pyo3::prelude::*;

#[pyclass]
#[derive(Default)]
pub struct ObjStore {
    obj: Vec<PyObject>,
}

#[pymethods]
impl ObjStore {
    #[new]
    fn new() -> Self {
        ObjStore::default()
    }

    fn push(&mut self, py: Python<'_>, obj: &Bound<'_, PyAny>) {
        self.obj.push(obj.to_object(py));
    }
}

#[pymodule]
pub fn objstore(m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add_class::<ObjStore>()
}