You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a rust app that would be able to dynamically run python plugins. Such plugins should be able to access some of the types of the rust app and return instances of these types.
The question is, is it possible to get the rust and the python types to match such that I can write python functions that I could call from rust and that will return objects that I can convert to rust ?
What I tried was to create a rust lib containing a public type :
#[pyclass]pubstructRustStruct{#[pyo3(get, set)]value:usize,}#[pymethods]implRustStruct{#[new]pubfnnew(value:usize) -> Self{Self{ value }}}
I was able to build a wheel with maturin and install it on a local install of python.
The problem is when I try to call python from rust : I don't seem to be able to get back a rust object from a python-created one.
In a test module inside the rust library, I wrote this code :
The test fails because the types are not the same. However, when I give to python an instance of the right type, I am able to get the class and then create an instance that I can export to rust
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to write a rust app that would be able to dynamically run python plugins. Such plugins should be able to access some of the types of the rust app and return instances of these types.
The question is, is it possible to get the rust and the python types to match such that I can write python functions that I could call from rust and that will return objects that I can convert to rust ?
What I tried was to create a rust lib containing a public type :
I was able to build a wheel with
maturin
and install it on a local install of python.The problem is when I try to call python from rust : I don't seem to be able to get back a rust object from a python-created one.
In a test module inside the rust library, I wrote this code :
The test fails because the types are not the same. However, when I give to python an instance of the right type, I am able to get the class and then create an instance that I can export to rust
I asked the question on gitter two weeks ago, and I also found this previously asked question but it does not seem to be exactly the same problem.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions