mirror of
https://github.com/RoboSats/robo-identities.git
synced 2025-07-26 04:33:15 +00:00
Last commit
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -964,14 +964,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "robo-identities-java"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"jni",
|
|
||||||
"robonames",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "robo-identities-wasm"
|
name = "robo-identities-wasm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
members = [
|
members = [
|
||||||
"robohash",
|
"robohash",
|
||||||
"robonames",
|
"robonames",
|
||||||
"robo-identities-wasm",
|
"robo-identities-wasm"
|
||||||
"robo-identities-java"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
version: '3.4'
|
version: '3.4'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# rust_wasm:
|
rust_wasm:
|
||||||
# build:
|
build:
|
||||||
# context: .
|
context: .
|
||||||
# dockerfile: ./robo-identities-wasm/Dockerfile
|
dockerfile: ./robo-identities-wasm/Dockerfile
|
||||||
# volumes:
|
volumes:
|
||||||
# - ./builds/wasm/:/app/robo-identities-wasm/pkg/:rw
|
- ./builds/wasm/:/app/robo-identities-wasm/pkg/:rw
|
||||||
# command: wasm-pack build
|
command: wasm-pack build
|
||||||
# rust_java_robonames:
|
rust_java_robonames:
|
||||||
# build:
|
build:
|
||||||
# context: .
|
context: .
|
||||||
# dockerfile: ./Dockerfile
|
dockerfile: ./Dockerfile
|
||||||
# target: robonames
|
target: robonames
|
||||||
# volumes:
|
volumes:
|
||||||
# - ./builds/java/robonames:/root/target/:rw
|
- ./builds/java/robonames:/root/target/:rw
|
||||||
# command: cargo ndk -t armeabi-v7a -t arm64-v8a -o ./target build --release
|
command: cargo ndk -t armeabi-v7a -t arm64-v8a -o ./target build --release
|
||||||
rust_java_robohash:
|
rust_java_robohash:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
|
2
robo-identities-java/.gitignore
vendored
2
robo-identities-java/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
/target
|
|
||||||
Cargo.lock
|
|
@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "robo-identities-java"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["rlib", "dylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
jni = "0.21.1"
|
|
||||||
robonames = { path = "../robonames" }
|
|
@ -1,61 +0,0 @@
|
|||||||
#[allow(non_snake_case)]
|
|
||||||
pub mod android {
|
|
||||||
use jni::JNIEnv;
|
|
||||||
use jni::objects::{JClass, JString};
|
|
||||||
use jni::sys::jstring;
|
|
||||||
|
|
||||||
use robonames::generate_short_nickname;
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "system" fn Java_com_robosats_RoboIdentities_nativeHello<'local>(mut env: JNIEnv<'local>,
|
|
||||||
// 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<'local>,
|
|
||||||
input: JString<'local>)
|
|
||||||
-> jstring {
|
|
||||||
// First, we have to get the string out of Java. Check jstring `strings`
|
|
||||||
// module for more info on how this works.
|
|
||||||
let input: String =
|
|
||||||
env.get_string(&input).expect("Couldn't get java string!").into();
|
|
||||||
|
|
||||||
// Then we have to create a new Java string to return. Again, more info
|
|
||||||
// in the `strings` module.
|
|
||||||
let output = env.new_string(format!("Hello, {}!", input))
|
|
||||||
.expect("Couldn't create java string!");
|
|
||||||
|
|
||||||
// Finally, extract the raw pointer to return.
|
|
||||||
output.into_raw()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "system" fn Java_com_robosats_RoboIdentities_nativeGenerateRoboname<'local>(mut env: JNIEnv<'local>,
|
|
||||||
// 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<'local>,
|
|
||||||
initial_string: JString<'local>)
|
|
||||||
-> jstring {
|
|
||||||
|
|
||||||
let initial_string: String =
|
|
||||||
env.get_string(&initial_string).expect("Couldn't get java string!").into();
|
|
||||||
|
|
||||||
|
|
||||||
match initial_string.split_once(';') {
|
|
||||||
Some((_initial_string, size)) => {
|
|
||||||
// Generate Robot Nickname synchronousl. Returns a nickname string.
|
|
||||||
let nickname = generate_short_nickname(initial_string);
|
|
||||||
match nickname {
|
|
||||||
Ok(nick) => {
|
|
||||||
let output = env.new_string(nickname)
|
|
||||||
.expect("Couldn't create java string!");
|
|
||||||
// Finally, extract the raw pointer to return.
|
|
||||||
output.into_raw()
|
|
||||||
},
|
|
||||||
Err(_) => todo!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => todo!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user