]> piware.de Git - learn-rust.git/commitdiff
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)
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


No differences found