3 ms·
> if called from the non-abstract horror of a language C, and the (partial) fix for that is really ugly looking low-level Rust crap that that took a _long_ time
by Aurornis 11mo ago
> if called from the non-abstract horror of a language C, and the (partial) fix for that is really ugly looking low-level Rust crap that that took a _long_ time to figure out and is the exact opposite of an abstraction,
In case it's not clear, the FFISafe abstraction is not a Rust standard library feature. It's a wrapper type that the author created within their library to bypass some compiler warnings:
https://github.com/memorysafety/rav1d/blob/25e5574/src/ffi_safe.rs#L11 https://github.com/memorysafety/rav1d/blob/25e5574/src/ffi_s...
If you want to call C functions from Rust it's as simple as writing an extern block and then calling the function, though you'll have to put the call in an unsafe block because obviously the Rust compiler can't make safety guarantees across that boundary.
The Rust docs for extern are concise: https://doc.rust-lang.org/std/keyword.extern.html https://doc.rust-lang.org/std/keyword.extern.html