Martin Pitt [Fri, 27 Aug 2021 12:49:22 +0000 (14:49 +0200)]
Call Rust function from C: Complex cases
Add three functions which take/return strings and string arrays. This
creates some interesting problems how to combine the C semantics of
returning a char** with the Rust semantics of freeing objects once they
go out of scope.
This now also relies on the Rust standard library, which needs a few
system libraries. Link them.
Martin Pitt [Fri, 27 Aug 2021 06:43:12 +0000 (08:43 +0200)]
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.