From e0ea884b53472a47445112197909561e18cc63e7 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 25 Sep 2024 13:14:52 +0200 Subject: [PATCH] chore(java): added glue for version method --- .gitignore | 1 + dist/java/src/mp/code/Extensions.java | 8 +++++++- src/ffi/java/ext.rs | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 11b3a99..5a6fc9f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ dist/java/bin/ dist/java/gradle/ dist/java/gradlew dist/java/gradlew.bat +dist/java/.factorypath diff --git a/dist/java/src/mp/code/Extensions.java b/dist/java/src/mp/code/Extensions.java index 93e141a..ff4a1b7 100644 --- a/dist/java/src/mp/code/Extensions.java +++ b/dist/java/src/mp/code/Extensions.java @@ -12,7 +12,13 @@ public final class Extensions { static final Cleaner CLEANER = Cleaner.create(); /** - * Hashes the given {@link String} using CodeMP's hashing algorithm (xxh3). + * Returns the version of the Rust crate as a String. + * @return the current version + */ + public static native String version(); + + /** + * Hashes the given String using CodeMP's hashing algorithm (xxh3). * @param input the string to hash * @return the hash */ diff --git a/src/ffi/java/ext.rs b/src/ffi/java/ext.rs index e509b64..2729e97 100644 --- a/src/ffi/java/ext.rs +++ b/src/ffi/java/ext.rs @@ -1,5 +1,12 @@ use jni_toolbox::jni; +/// Gets the current version of the Rust crate. +#[allow(non_snake_case)] +#[jni(package = "mp.code", class = "Extensions")] +fn version() -> String { + crate::version() +} + /// Calculate the XXH3 hash for a given String. #[jni(package = "mp.code", class = "Extensions")] fn hash(content: String) -> i64 {