I've toyed with writing library bindings in Rust before, and it wasn't difficult. Now, however, I'm stuck: I'm trying to write a binding for librsync, and some of its functions expect you to pass an open file handle (a FILE* in C).
For primitive types, there's a straightforward way to pass them into C, (the same for pointers to primitive types). And, to be clear, I'm aware that the libc crate implements fopen, which in turn gives me a mut FILE* (which would eventually do the job). However, I was wondering if there is something in the Rust standard library that gives me a FILE* to pass to librsync — maybe something analog to std::ffi::CString.
You could of course use a RawFd, transmute and call libc::funcs::posix88::stdio::fdopen(_, mode) with it. That would be highly unportable though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With