MCPcopy Create free account
hub / github.com/deviceplug/btleplug / fn_adapter

Function fn_adapter

src/droidplug/jni_utils/ops.rs:254–287  ·  view source on GitHub ↗
(
    env: &'b JNIEnv<'a>,
    f: impl for<'c, 'd> Fn(
        &'d JNIEnv<'c>,
        JObject<'c>,
        JObject<'c>,
        JObject<'c>,
        JObject<'c>,
    ) -> JObject<'c>
    + 'static,
 

Source from the content-addressed store, hash-verified

252}
253
254fn fn_adapter<'a: 'b, 'b>(
255 env: &'b JNIEnv<'a>,
256 f: impl for<'c, 'd> Fn(
257 &'d JNIEnv<'c>,
258 JObject<'c>,
259 JObject<'c>,
260 JObject<'c>,
261 JObject<'c>,
262 ) -> JObject<'c>
263 + 'static,
264 local: bool,
265) -> Result<JObject<'a>> {
266 let arc: Arc<
267 dyn for<'c, 'd> Fn(
268 &'d JNIEnv<'c>,
269 JObject<'c>,
270 JObject<'c>,
271 JObject<'c>,
272 JObject<'c>,
273 ) -> JObject<'c>,
274 > = Arc::from(f);
275
276 let obj = env.new_object(
277 JClass::from(
278 super::classcache::get_class("io/github/gedgygedgy/rust/ops/FnAdapter")
279 .unwrap()
280 .as_obj(),
281 ),
282 "(Z)V",
283 &[local.into()],
284 )?;
285 env.set_rust_field::<_, _, FnWrapper>(obj, "data", SendSyncWrapper(arc))?;
286 Ok(obj)
287}
288
289pub(crate) extern "C" fn fn_adapter_call_internal<'a>(
290 env: JNIEnv<'a>,

Callers 2

fn_once_adapterFunction · 0.85
fn_mut_adapterFunction · 0.85

Calls 2

get_classFunction · 0.85
SendSyncWrapperClass · 0.85

Tested by

no test coverage detected