Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] react native - rust interop #258

Open
pzoltowski opened this issue Oct 25, 2024 · 1 comment
Open

[Feature] react native - rust interop #258

pzoltowski opened this issue Oct 25, 2024 · 1 comment

Comments

@pzoltowski
Copy link

FWIW, came across this repo:
https://github.com/getditto/rn-jsi-rust-bridging
and accompanying article:
https://ditto.live/blog/bridging-react-native-and-rust-via-jsi
and some other of their related repos:
https://github.com/getditto/react-ditto
https://github.com/getditto/react-native-sample-app

where they are bridging react native to rust (for both old and new architecture). I know almost nothing about rust (so cannot help) but curious if nitro could simplify the process for such react native - rust bindings?

It would probably open a new world of possibilities since there is plenty of truely multiplatoform (mobile include) libraries in rust land and rust cargo is a godsend comparing to cmake - there is a lot of c++ libraries that officially don't support mobile but mostly because of build issues.

In rust there is plenty of nice gems that have functionality missing in react native (or are not as good):

opencv-rust - [autogenerated opencv + opencv_contrib bindings] https://github.com/twistedfall/opencv-rust
Cv-convert - [conversion between cv and different image libs ndarray] https://crates.io/crates/cv-convert
cpal - [realtime audio i/o processing] https://github.com/RustAudio/cpal
midir - [midi i/o] https://github.com/Boddlnagg/midir
wmidi or rimd - [midi encoding / decoding]
Peertalk-rst [ios - usb communication] https://github.com/AstroHQ/peertalk-rs
rust-sdl2 - [gamecontrollers, IMU sensors, audio, etc] https://github.com/Rust-SDL2/rust-sdl2
rodio - [audio player] https://github.com/RustAudio/rodio

Maybe worth to contact those guys from ditto.live to invite for collaboration? (they might not know about Nitro), they seem have big clients in Aviation industry so they probably know what they are doing.

@mrousavy
Copy link
Owner

Ha, it's funny how much of my code is in that repo/article. From the JSI integration, to even the error messages.

Anyways - yea this article isn't very relevant as of right now because it mostly showcases the JSI integration part, and then exposing a simple Rust function as an external C function.
We use C++, and classes and inheritance, this would not be supported by Rust.

So if you know how to use Rust, it'd be quite easy to just expose your Rust functions to C++, and then call them in Nitro.

This also goes for all of the libraries you shared - you can expose them as C decls and call them from C++.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants