cartesi / dave

Cartesi fraud-proof system
Apache License 2.0
13 stars 11 forks source link

Add `machine-emulator` native bindings for Rust #25

Closed the-sofi-uwu closed 4 months ago

the-sofi-uwu commented 5 months ago

Nice work!

What are the best practices with FFIs in Rust? Should we commit the bindings.rs, or generate them in a build script (build.rs)? If it's the build script route, I guess we'd have to include the header files somewhere. I don't mind committing it for now, and later pulling it from a submodule.

I can never remember, what is the recommendation for committing Cargo.lock in Rust workspaces? Considering whether there are executables or just libs?

Executables should commit the Cargo.toml, libraries shouldn't so I removed them.

I think that we can only generate the bindings using build.rs if we have the include files of libcartesi somewhere, I generated them from inside of the image so I think that's bad if we are developing outside of the image to generate it. I'm not sure of the conventions but I think that if can generate it without bloating the crate with a lot of header files it's better than keeping the generated file like that.