Open lightsprint09 opened 3 years ago
Actually, I do have some C bindings in another repo (I use this project from an android), but the code there is not so polished, and I'm very short of time. I'm happy to provide you with the code, and would be nice if you can do a pull request with it! (I don't think it requires much rust knowledge)
Sounds good. I can not promise to find the time but will give it a try.
Here you go: download link Note that this is just the zip containing the bindings I wrote a lot of time ago to use this library from Android.
Unfortunately I don't have time to touch the code at all, so I didn't even try to hide random comments or useless logs. The code is not super nice, but you should be able to easily change it and use it from c.
What you can do is the following. You can find functions like:
#[no_mangle]
pub unsafe extern "C" fn Java_DataManagment_NavigatorBridge_00024Companion_getWalkTimeSeconds(
_: JNIEnv,
_: JClass,
meters: jint,
) -> jint {
RaptorNavigator::seconds_by_walk(meters as usize)
.try_into()
.unwrap()
}
the weird name is due to the need of android JNI. In your case, you can make the previous like:
#[no_mangle]
pub unsafe extern "C" fn getWalkTimeSeconds(
meters: i32,
) -> i32 {
RaptorNavigator::seconds_by_walk(meters as usize)
.try_into()
.unwrap()
}
and compile it. The build output should be a library easily usable from c.
Note that the crate in the zip depends on fastgtfs
being in the top level folder:
fastgtfs = {path = "../fastgtfs"}
P.S. I'm sure that there are better ways to create c bindings for rust code nowadays, automatically. (see https://github.com/rust-lang/rust-bindgen for example)
PR are welcomed :)
Hi,
I am not familiar with Rust but I have experience compiling rust to be used for Apple platform development (iOS, macOS etc). To do this I would like to see some C-Bindings for this awesome project.