Crates.io | jni_fn |
lib.rs | jni_fn |
version | 0.1.2 |
source | src |
created_at | 2021-11-08 07:29:01.369061 |
updated_at | 2023-08-14 19:02:47.573106 |
description | JNI-compatible method signature generator |
homepage | |
repository | https://gitlab.com/antonok/jni_fn |
max_upload_size | |
id | 478405 |
size | 17,780 |
jni_fn
is a JNI-compatible method signature generator for Rust libraries.
This crate was designed for use with the jni
crate, which exposes JNI-compatible type bindings.
Although it's possible to use jni
without jni_fn
, the procedural macro defined here will make it easier to write the method signatures correctly.
Check the jni
repo to get started with your first Rust JNI bindings.
Note the function signatures in the jni
example project, which must be transcribed 100% correctly to avoid runtime panics in your JVM project:
#[no_mangle]
pub extern "system" fn Java_HelloWorld_hello(
// ...
Instead, jni_fn
can automatically generate the correct function signature based on the package name (HelloWorld
) and function name (hello
):
use jni_fn::jni_fn;
#[jni_fn("HelloWorld")]
pub fn hello(
// ...
jni_fn
is especially useful in more complicated examples - you don't want to figure this out manually! With jni_fn
, all you need is:
#[jni_fn("org.signal.client.internal.Native")]
pub unsafe fn IdentityKeyPair_Deserialize(
// ...
Visit the docs for more instructions and examples.