android (kotlin) < /h3>
На стороне Kotlin у меня есть следующая подпись функции: < /p>
Код: Выделить всё
package eu.mypackage.rust
class SomeName {
@Throws(IllegalArgumentException::class)
external fun checkAnswer(answerInput: String, answerList: List): Boolean
}
< /code>
, который я называю: < /p>
val isCorrect = sn.checkAnswer(answerInput, answerList)
< /code>
rust < /h3>
на стороне ржавчины у меня есть эта черновая функция: < /p>
#[cfg(target_os = "android")]
#[allow(non_snake_case)]
pub mod android {
extern crate jni;
// This is the interface to the JVM that we'll call the majority of our methods on.
// @See https://docs.rs/jni/latest/jni/
use self::jni::JNIEnv;
// These objects are what you should use as arguments to your native function.
// They carry extra lifetime information to prevent them escaping this context
// and getting used after being GC'd.
use self::jni::objects::{JClass, JString, JObject, JObjectArray}; // Not sure what is required
// This is just a pointer. We'll be returning it from our function.
// We can't return one of the objects with lifetime information
// because the lifetime checker won't let us.
use self::jni::sys::{jstring, jboolean, jobjectArray, jsize}; // Not sure what is required
fn kotlin_list_to_rust_vec_string(env: &JNIEnv, java_array: &jobjectArray) -> Vec {
// TODO function to convert
}
#[no_mangle] // This keeps Rust from "mangling" the name so it is unique (crate).
pub extern "system" fn Java_eu_surafusoft_rust_KanjiOrigin_checkAnswer,
// This is the class that owns our static method. It's not going to be used,
// but still must be present to match the expected signature of a static native method.
_class: JClass,
answerList: JObjectArray
Подробнее здесь: [url]https://stackoverflow.com/questions/79495562/android-kotlin-java-liststring-arraystring-rust-vecstring-conver[/url]