Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Michael-F-Bryan/rust-ffi-guide
A guide for doing FFI using Rust
https://github.com/Michael-F-Bryan/rust-ffi-guide
ffi rust tutorial
Last synced: 1 day ago
JSON representation
A guide for doing FFI using Rust
- Host: GitHub
- URL: https://github.com/Michael-F-Bryan/rust-ffi-guide
- Owner: Michael-F-Bryan
- License: cc0-1.0
- Created: 2017-02-16T13:53:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-13T16:33:26.000Z (over 3 years ago)
- Last Synced: 2024-11-08T00:52:20.455Z (6 days ago)
- Topics: ffi, rust, tutorial
- Language: Rust
- Homepage: https://michael-f-bryan.github.io/rust-ffi-guide/
- Size: 1.48 MB
- Stars: 283
- Watchers: 11
- Forks: 18
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Using `unsafe` for Fun and Profit
[![Build Status](https://travis-ci.org/Michael-F-Bryan/rust-ffi-guide.svg?branch=master)](https://travis-ci.org/Michael-F-Bryan/rust-ffi-guide)
[![Creative Commons Zero License](https://img.shields.io/github/license/Michael-F-Bryan/rust-ffi-guide.svg)](https://creativecommons.org/publicdomain/zero/1.0/deed.en)A guide to traversing the FFI boundary between Rust and other languages. A
rendered version is available [here][gh-pages]. This guide is centred around the
idea of building a REST client using `Qt` (C++) for the GUI and `reqwest` (Rust)
for the business logic.## Building
Building and viewing the book locally is really easy. First you need to get the
source code:```bash
$ git clone https://github.com/Michael-F-Bryan/rust-ffi-guide
```Make sure you have `mdbook` installed:
```bash
$ cargo install mdbook
```Then tell `mdbook` to build and serve the book:
```bash
$ mdbook serve --open
```It should now be viewable at [http://localhost:3000/](http://localhost:3000/)
(if it didn't open up automatically).To build the application itself you'll need the following installed:
- qt5
- rust (install with [rustup])
- mdbook (`cargo install mdbook`)In this application we're using `cmake` as the build system. The
`ci/test.sh` script will make a `build/` directory and invoke `cmake` to
compile and test everything.```
$ ./ci/test.sh
```The final application should now be at `build/gui`.
Alternatively, if you don't want to install all the dependencies I've created a
docker image ([michaelfbryan/ffi-guide][docker]) for compiling Rust and Qt.```
$ docker run \
-v $(pwd):/code \
-v ~/.cargo:$HOME/.cargo \
-e CARGO_HOME=$HOME/.cargo \
--user $UID \
michaelfbryan/ffi-guide ci/test.sh
```## Contributing
If there's anything you feel is missing or could be
improved, please [create an issue][issues]. Pull requests are welcome too!### Contributors
- [Michael-F-Bryan](https://github.com/Michael-F-Bryan)
- [gurgalex](https://github.com/gurgalex)
- [adeschamps](https://github.com/adeschamps)[gh-pages]: https://michael-f-bryan.github.io/rust-ffi-guide/
[issues]: https://github.com/Michael-F-Bryan/rust-ffi-guide/issues/new
[rustup]: https://rustup.rs/
[docker]: https://hub.docker.com/r/michaelfbryan/ffi-guide/