2024-09-22 02:22:51 +02:00
|
|
|
use jni_toolbox::jni;
|
2024-09-16 00:20:03 +02:00
|
|
|
|
2024-09-25 13:14:52 +02:00
|
|
|
/// Gets the current version of the Rust crate.
|
|
|
|
#[jni(package = "mp.code", class = "Extensions")]
|
|
|
|
fn version() -> String {
|
2024-10-12 22:14:17 +02:00
|
|
|
crate::version().to_string()
|
2024-09-25 13:14:52 +02:00
|
|
|
}
|
|
|
|
|
2024-09-16 00:20:03 +02:00
|
|
|
/// Calculate the XXH3 hash for a given String.
|
2024-09-22 02:22:51 +02:00
|
|
|
#[jni(package = "mp.code", class = "Extensions")]
|
|
|
|
fn hash(content: String) -> i64 {
|
2024-09-16 00:20:03 +02:00
|
|
|
let hash = crate::ext::hash(content.as_bytes());
|
|
|
|
i64::from_ne_bytes(hash.to_ne_bytes())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Tells the [tokio] runtime how to drive the event loop.
|
2024-09-22 02:22:51 +02:00
|
|
|
#[jni(package = "mp.code", class = "Extensions")]
|
|
|
|
fn drive(block: bool) {
|
|
|
|
if block {
|
2024-09-16 00:20:03 +02:00
|
|
|
super::tokio().block_on(std::future::pending::<()>());
|
|
|
|
} else {
|
|
|
|
std::thread::spawn(|| {
|
|
|
|
super::tokio().block_on(std::future::pending::<()>());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-17 02:40:03 +02:00
|
|
|
/// Set up the tracing subscriber.
|
2024-09-23 00:26:11 +02:00
|
|
|
#[allow(non_snake_case)]
|
2024-09-22 02:22:51 +02:00
|
|
|
#[jni(package = "mp.code", class = "Extensions")]
|
|
|
|
fn setupTracing(path: Option<String>, debug: bool) {
|
|
|
|
super::setup_logger(debug, path);
|
2024-09-17 02:40:03 +02:00
|
|
|
}
|