Skip to content

kevin-june/rust-bindings-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Bindings Demo

An example of using Rust bindings.

This typically involves some specialized use of Rust's type system.

A C module is contained in the cmodule directory. build.rs compiles this C library and generates Rust bindings from the C header file.

Various Rust binaries in src/bin/ call into this API.

Examples are presented as "tests" in binaries.

Build

Build all the tests:

cargo build --tests

To check the tests without actually compiling:

cargo check --tests

Run

Run all tests using:

cargo test

Run tests in a specific binary using:

cargo test --bin const_char

To see what binaries are available, look for Rust files in src/bin/ or run:

cargo test --bin

TODO

  • transfer ownership from Rust to C
  • transfer ownership from C to Rust
  • cause crashes due to lifetime errors

Reading

About

Experiments and examples of using Rust's FFI with C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published