Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 955 Bytes

README.md

File metadata and controls

31 lines (21 loc) · 955 Bytes

cgo-rust-ffi

Various experiments and demos relating to Golang talking to Rust via CGO. This gave me a good excuse to mess around with SHM_GET, SHM_OPEN, MMAP, and mkfifo.

Examples

  1. (DONE) Generate header from Rust API
  2. (DONE) Generate CGO from previously-generated header
  3. (DONE) Go calls Rust through CGO and streams bytes using FIFO file (named pipe)
  4. (DONE) Go calls Rust through CGO, sharing memory (uses SHM_OPEN + MMAP)
  5. (WIP) Go allocates slice in C heap, copies from Go heap and passes pointers to Rust
  6. (WIP) Go calls Rust through CGO and streams bytes over TCP socket

Tools

  1. Go buy a Mac: https://apple.com
  2. Install Rust: curl https://sh.rustup.rs -sSf | sh
  3. Install Golang: https://golang.org/dl/
  4. Install c-for-go: go get github.com/xlab/c-for-go

Caveats

  1. This software has been tested with OSX only

Build and Run Tests

To build and run demos:

  • cd hasher && make ; cd ..
  • go run main.go