MCPcopy Create free account
hub / github.com/astonbitecode/j4rs / to_rust_deserialized

Method to_rust_deserialized

rust/src/api/mod.rs:1363–1383  ·  view source on GitHub ↗
(&self, instance: Instance)

Source from the content-addressed store, hash-verified

1361 }
1362
1363 pub fn to_rust_deserialized<T>(&self, instance: Instance) -> errors::Result<T>
1364 where
1365 T: DeserializeOwned + Any,
1366 {
1367 unsafe {
1368 debug("Invoking the getJson method");
1369 // Call the getJson method. This returns a localref
1370 let json_instance = (opt_to_res(cache::get_jni_call_object_method())?)(
1371 self.jni_env,
1372 instance.jinstance,
1373 cache::get_get_json_method()?,
1374 );
1375 let _ = Self::do_return(self.jni_env, "")?;
1376 debug("Transforming jstring to rust String");
1377 let global_json_instance =
1378 jni_utils::create_global_ref_from_local_ref(json_instance, self.jni_env)?;
1379 let json = jni_utils::jstring_to_rust_string(self, global_json_instance as jstring)?;
1380 jni_utils::delete_java_ref(self.jni_env, global_json_instance);
1381 Self::do_return(self.jni_env, serde_json::from_str(&json)?)
1382 }
1383 }
1384
1385 /// Deploys an artifact in the default j4rs jars location.
1386 ///

Callers 2

use_to_rust_deserializedFunction · 0.80
to_rust_boxedMethod · 0.80

Calls 8

debugFunction · 0.85
opt_to_resFunction · 0.85
get_get_json_methodFunction · 0.85
do_returnFunction · 0.85
jstring_to_rust_stringFunction · 0.85
delete_java_refFunction · 0.85

Tested by

no test coverage detected