There are a number of crates with Rust bindings to the Guile C API: 
https://lib.rs/search?q=guile

Most of them are just the result of running the bindgen tool, which 
autogenerates Rust bindings from C header files. A few of them have slightly 
more convenient wrapper but none is really well-developed AFAICS.

Honestly, I think the easiest at this time is to do the interfacing with Guile 
from C. Create a Rust module which exports a function through C FFI, and 
convert between C and Guile types in C. Alternatively, use the Guile FFI 
facilities for the conversion. It is probably simpler than doing these 
conversions in Rust. It is, in any case, safer, because I'm quite sure that the 
Rust compiler will be happy to do optimizations that defeat conservative GC, by 
hiding pointers in local variables (which Rust can more easily do, thanks to 
its aliasing guarantees).

Be careful with calling Guile code from Rust code. This is fraught, because 
Guile code can raise exceptions, which are basically propagated through 
longjmp, and it is UB in Rust to unwind through Rust code with longjmp. 
Basically, if you call Guile from Rust then it must be wrapped in exception 
handling. An exception must not propagate through Rust stack frames. call/cc 
would be a problem too, so you likely want to use with-continuation-barrier.

Reply via email to