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

Function get_poll_result

src/droidplug/peripheral.rs:54–155  ·  view source on GitHub ↗
(
    env: &'b JNIEnv<'a>,
    result: JPollResult<'a, 'b>,
)

Source from the content-addressed store, hash-verified

52}
53
54fn get_poll_result<'a: 'b, 'b>(
55 env: &'b JNIEnv<'a>,
56 result: JPollResult<'a, 'b>,
57) -> Result<JObject<'a>> {
58 try_block(env, || Ok(Ok(result.get()?)))
59 .catch(
60 JClass::from(
61 super::jni_utils::classcache::get_class(
62 "io/github/gedgygedgy/rust/future/FutureException",
63 )
64 .unwrap()
65 .as_obj(),
66 ),
67 |ex| {
68 let cause = env
69 .call_method(ex, "getCause", "()Ljava/lang/Throwable;", &[])?
70 .l()?;
71 if env.is_instance_of(
72 cause,
73 JClass::from(
74 super::jni_utils::classcache::get_class(
75 "com/nonpolynomial/btleplug/android/impl/NotConnectedException",
76 )
77 .unwrap()
78 .as_obj(),
79 ),
80 )? {
81 Ok(Err(Error::NotConnected))
82 } else if env.is_instance_of(
83 cause,
84 JClass::from(
85 super::jni_utils::classcache::get_class(
86 "com/nonpolynomial/btleplug/android/impl/PermissionDeniedException",
87 )
88 .unwrap()
89 .as_obj(),
90 ),
91 )? {
92 Ok(Err(Error::PermissionDenied))
93 } else if env.is_instance_of(
94 cause,
95 JClass::from(
96 super::jni_utils::classcache::get_class(
97 "com/nonpolynomial/btleplug/android/impl/UnexpectedCallbackException",
98 )
99 .unwrap()
100 .as_obj(),
101 ),
102 )? {
103 Ok(Err(Error::UnexpectedCallback))
104 } else if env.is_instance_of(
105 cause,
106 JClass::from(
107 super::jni_utils::classcache::get_class(
108 "com/nonpolynomial/btleplug/android/impl/UnexpectedCharacteristicException",
109 )
110 .unwrap()
111 .as_obj(),

Callers 9

connectMethod · 0.85
disconnectMethod · 0.85
discover_servicesMethod · 0.85
writeMethod · 0.85
readMethod · 0.85
read_rssiMethod · 0.85
write_descriptorMethod · 0.85
read_descriptorMethod · 0.85

Calls 5

try_blockFunction · 0.85
get_classFunction · 0.85
resultMethod · 0.80
catchMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected