I have to be using it wrong
dwhiteddsoft opened this issue · 1 comments
off a trait impl I have this:
async fn connect() {
println!("connected iot_hub_device");
// create a thread
IotHubDeviceImpl::connect().await;
}
which gives me an error of:
future cannot be sent between threads safely
the trait Send
is not implemented for dyn std::error::Error
required for the cast to the object type dyn Future<Output = ()> + Send
pointing to the following line:
let iot_receiver = iot_client.get_receiver().await;
which I will be using poll_recv in a multi-threaded fashion. All available help says I need to add Send and Sync like it says and I can only implement it in my crate which is also a compile error for only implementing things in your own crate.
Seems pretty simple. I am going to spin the IoT Hub messaging on its own thread and cannot seem to overcome this
In case anyone is interested this is a scope issue on the compiler (if I understand it correctly) and they way around it is the following link from async trait https://github.com/dtolnay/async-trait#non-threadsafe-futures.
Closing issue