[mio] fmt
This commit is contained in:
@@ -2,8 +2,8 @@ use std::net::ToSocketAddrs;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use jni::errors::Error;
|
use jni::errors::Error;
|
||||||
use jni::JNIEnv;
|
|
||||||
use jni::objects::JObject;
|
use jni::objects::JObject;
|
||||||
|
use jni::JNIEnv;
|
||||||
|
|
||||||
use vnt::channel::punch::PunchModel;
|
use vnt::channel::punch::PunchModel;
|
||||||
use vnt::cipher::CipherModel;
|
use vnt::cipher::CipherModel;
|
||||||
@@ -34,11 +34,12 @@ pub fn new_config(env: &mut JNIEnv, config: JObject) -> Result<Config, Error> {
|
|||||||
to_i32_array(env, &config, "ports")?.map(|v| v.into_iter().map(|v| v as u16).collect());
|
to_i32_array(env, &config, "ports")?.map(|v| v.into_iter().map(|v| v as u16).collect());
|
||||||
let ip = if let Some(ip) = to_string(env, &config, "ip")? {
|
let ip = if let Some(ip) = to_string(env, &config, "ip")? {
|
||||||
match ip.parse() {
|
match ip.parse() {
|
||||||
Ok(ip) => {
|
Ok(ip) => Some(ip),
|
||||||
Some(ip)
|
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
env.throw_new("java/lang/RuntimeException", format!("ip {} err: {}", ip, e))
|
env.throw_new(
|
||||||
|
"java/lang/RuntimeException",
|
||||||
|
format!("ip {} err: {}", ip, e),
|
||||||
|
)
|
||||||
.expect("throw");
|
.expect("throw");
|
||||||
return Err(Error::JavaException);
|
return Err(Error::JavaException);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
pub mod callback;
|
pub mod callback;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod vnt;
|
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
pub mod vnt;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use jni::errors::Error;
|
use jni::errors::Error;
|
||||||
use jni::JNIEnv;
|
|
||||||
use jni::objects::{JIntArray, JObject, JObjectArray, JString};
|
use jni::objects::{JIntArray, JObject, JObjectArray, JString};
|
||||||
|
use jni::JNIEnv;
|
||||||
|
|
||||||
pub fn to_string_not_null(
|
pub fn to_string_not_null(
|
||||||
env: &mut JNIEnv,
|
env: &mut JNIEnv,
|
||||||
@@ -93,7 +93,11 @@ pub fn to_string_array(
|
|||||||
Ok(Some(rs))
|
Ok(Some(rs))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_i32_array(env: &mut JNIEnv, config: &JObject, name: &str) -> Result<Option<Vec<i32>>, Error> {
|
pub fn to_i32_array(
|
||||||
|
env: &mut JNIEnv,
|
||||||
|
config: &JObject,
|
||||||
|
name: &str,
|
||||||
|
) -> Result<Option<Vec<i32>>, Error> {
|
||||||
let obj = env.get_field(&config, name, "[I")?.l()?;
|
let obj = env.get_field(&config, name, "[I")?.l()?;
|
||||||
if obj.is_null() {
|
if obj.is_null() {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
@@ -111,5 +115,7 @@ pub fn to_integer(env: &mut JNIEnv, config: &JObject, name: &str) -> Result<Opti
|
|||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
// 调用 intValue
|
// 调用 intValue
|
||||||
return Ok(Some(env.call_method(value,"intValue","()I",&[])?.i()? as _))
|
return Ok(Some(
|
||||||
|
env.call_method(value, "intValue", "()I", &[])?.i()? as _
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user