arrow-message
arrow-message makes it possible to create a Message struct in Rust or Python and convert it into a single arrow::array::ArrayData without any copy. It's also possible to get back to the initial struct without any copy as well.
The resulting arrow::array::ArrayData can then be sent safely over the network, a mpsc channel or to a Python script thanks to the pyo3 crate and the pyarrow feature.
The project aims to be used in context where we want to send a single payload containing multiple large fields. Like a struct representing an image or a video frame. This is ideal for Robotics and AI applications.
Example
use *;
use *;
You can see an expanded version without the Derive macro here, and a more complex example here.
A python version here
=
=
=
=
:
:
:
:
:
:
=
=
=
Just run examples
We use a justfile to run examples:
Features
-
Fields supported
- Primitive types
- Optional Primitive Rust types
- Arrow Arrays for Rust, Numpy Arrays for Python
- Optional Arrow Arrays for Rust, Numpy Arrays for Python
- Rust structs that implement ArrowMessage, Python dataclasses that inherit from ArrowMessage for Python
- Rust simple enums that implement ArrowMessage for Rust, Python simple enums that inherit from ArrowMessage for Python
- Optional structs/classes that implement/inherit ArrowMessage
- Optional enums that implement/inherit ArrowMessage
- [?]
Enums with variant that implements/inherit ArrowMessage? I don't think it's possible, as an ArrowMessage should know it's exact datatype layout at compile time (only Option that are represented as NullArray when on runtime the value is None)
-
Operations supported
- Into/From ArrayData
- ArrayData Flattening
What's Next?
- Think about Vec/List support. is it possible and is it relevant?.
- Improved error handling and validation: too much panic! in arrow that we must catch.
- Make to python API fully Rust with PyO3 (may be hard because we use a lot of python runtime tricks)
- Enhanced documentation and examples
- Integration with other libraries and frameworks