You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im trying to interact with an MQTT stream from the rust side, but it only accepts <Send + Sync + 'static>
When trying to add the trait to my callback; like so: fn MqttTopicManager::subscribe(&self, cb: Box<dyn MqttListener + Send + Sync + 'static>) -> Result<()>;
I receive the following error below.
Is this at all possible or do I need to find another way to do this?
rror[E0277]: `*mut *const jni_c_header::JNIInvokeInterface_` cannot be shared between threads safely
--> /home/java/target/debug/build/client-db63cdf19f965487/out/java_glue.rs:5948:9
|
5948 | Box::new(cb)
| ^^^^^^^^^^^^ `*mut *const jni_c_header::JNIInvokeInterface_` cannot be shared between threads safely
|
= help: within `JavaCallback`, the trait `Sync` is not implemented for `*mut *const jni_c_header::JNIInvokeInterface_`
= note: required because it appears within the type `JavaCallback`
= note: required for the cast to the object type `dyn classes::mqtt::MqttListener + Sync + std::marker::Send`
error[E0277]: `*mut jni_c_header::_jobject` cannot be shared between threads safely
--> /home/java/target/debug/build/client-db63cdf19f965487/out/java_glue.rs:5948:9
|
5948 | Box::new(cb)
| ^^^^^^^^^^^^ `*mut jni_c_header::_jobject` cannot be shared between threads safely
|
= help: within `JavaCallback`, the trait `Sync` is not implemented for `*mut jni_c_header::_jobject`
= note: required because it appears within the type `JavaCallback`
= note: required for the cast to the object type `dyn classes::mqtt::MqttListener + Sync + std::marker::Send`
error[E0277]: `*mut jni_c_header::_jmethodID` cannot be shared between threads safely
--> /home/java/target/debug/build/client-db63cdf19f965487/out/java_glue.rs:5948:9
|
5948 | Box::new(cb)
| ^^^^^^^^^^^^ `*mut jni_c_header::_jmethodID` cannot be shared between threads safely
|
= help: the trait `Sync` is not implemented for `*mut jni_c_header::_jmethodID`
= note: required because of the requirements on the impl of `Sync` for `Unique<*mut jni_c_header::_jmethodID>`
= note: required because it appears within the type `alloc::raw_vec::RawVec<*mut jni_c_header::_jmethodID>`
= note: required because it appears within the type `Vec<*mut jni_c_header::_jmethodID>`
= note: required because it appears within the type `JavaCallback`
= note: required for the cast to the object type `dyn classes::mqtt::MqttListener + Sync + std::marker::Send`
The text was updated successfully, but these errors were encountered:
to fix compilation error.
But I am not sure how "safe" it is, this is depend on how you implement subscribe method in Java.
If this method is ready to be called from several threads at the same time, then it should be safe.
Im trying to interact with an MQTT stream from the rust side, but it only accepts
<Send + Sync + 'static>
When trying to add the trait to my callback; like so:
fn MqttTopicManager::subscribe(&self, cb: Box<dyn MqttListener + Send + Sync + 'static>) -> Result<()>;
I receive the following error below.
Is this at all possible or do I need to find another way to do this?
The text was updated successfully, but these errors were encountered: