Initial libmount function call from Rust
authorMartin Pitt <martin@piware.de>
Fri, 27 Aug 2021 06:43:12 +0000 (08:43 +0200)
committerMartin Pitt <martin@piware.de>
Fri, 27 Aug 2021 08:24:17 +0000 (10:24 +0200)
commit08dccd05a79d2cf2bdd4b6cd8ccaa8baa02b0a54
tree0b907b4d898907c617e672acee1b4661642467e5
parent225c6b2420e01dca1f3a570d3ed664b825cf883c
Initial libmount function call from Rust

Follow "A little C with your Rust" [1].

Set up cargo and main.rs skeleton and call one of the simplest possible
functions from libmount: mnt_get_fstab_path().

Use bindgen [1] to translate libmount's header file into a Rust
interface. This requires a few hacks:

 - bindgen does not accept the original header right away, as it can't
   find stdarg.h. Avoid this by dropping the (unnecessary) stdio.h
   include.
 - bindgen does not know about `size_t`. Hack around that with a typedef
   for now.
 - Suppress warnings about constant/identifier naming.

[1] https://rust-lang.github.io/rust-bindgen/command-line-usage.html
[2] https://docs.rust-embedded.org/book/interoperability/c-with-rust.html
.gitignore
call-c-from-rust/.cargo/config [new file with mode: 0644]
call-c-from-rust/Cargo.toml [new file with mode: 0644]
call-c-from-rust/Makefile
call-c-from-rust/src/main.rs [new file with mode: 0644]