Reputation: 913
I want to implement a system which consists of a Python UI and some Rust datastore and functions. The user executes the python code which in turn executes the Rust program in a subprocess. I want the Rust program to run in the background, waiting to exchange variables or function calls with the Python UI (for example every time a button is pressed).
My obstacles are:
I have tried to make a simple Rust FFI library that can be invoked with ctypes from Python but I don't know how this library will be able to communicate with the compiled rust program that is running on the background.
Another approach is to use PyO3 to make a python module using rust. But again I cannot understand how this will cooperate with the rust program to exchange data
Upvotes: 0
Views: 324
Reputation: 23244
Your Rust background process will need to expose some kind of RPC mechanism such as jsonrpc or msgpack-rpc.
Then any other application can call into your background process using the same RPC mechanism. For example for Python, there are libraries for jsonrpc and msgpack-rpc.
Upvotes: 1