Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IAsyncOperation<T> no longer Send for some T as of v0.29 #1391

Closed
qdot opened this issue Dec 19, 2021 · 2 comments · Fixed by #1423
Closed

IAsyncOperation<T> no longer Send for some T as of v0.29 #1391

qdot opened this issue Dec 19, 2021 · 2 comments · Fixed by #1423
Labels
bug Something isn't working

Comments

@qdot
Copy link

qdot commented Dec 19, 2021

Just updated to v0.29, tried to compile https://github.com/deviceplug/btleplug with no code changes otherwise, and I'm getting a bunch of errors about IAsyncOperations no longer working due to not implementing Send. v0.28 worked fine.

error: future cannot be sent between threads safely
  --> src\winrtble\manager.rs:34:54
   |
34 |       async fn adapters(&self) -> Result<Vec<Adapter>> {
   |  ______________________________________________________^
35 | |         let adapter_result = BluetoothAdapter::GetDefaultAsync().unwrap().await;
36 | |         let adapter = adapter_result.unwrap();
37 | |         info!("Adapter ID: {:?}", adapter.DeviceId());
...  |
48 | |         return Ok(result);
49 | |     }
   | |_____^ future created by async block is not `Send`
   |
   = help: within `impl futures::Future`, the trait `std::marker::Send` is not implemented for `NonNull<c_void>`
note: future is not `Send` as it awaits another future which is not `Send`
  --> src\winrtble\manager.rs:35:30
   |
35 |         let adapter_result = BluetoothAdapter::GetDefaultAsync().unwrap().await;
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `IAsyncOperation<BluetoothAdapter>`, which is not `Send`
   = note: required for the cast to the object type `dyn futures::Future<Output = std::result::Result<Vec<Adapter>, Error>> + std::marker::Send`

error: future cannot be sent between threads safely
   --> src\winrtble\peripheral.rs:355:43
    |
355 |       async fn connect(&self) -> Result<()> {
    |  ___________________________________________^
356 | |         let shared_clone = Arc::downgrade(&self.shared);
357 | |         let adapter_clone = self.shared.adapter.clone();
358 | |         let address = self.shared.address;
...   |
380 | |         Ok(())
381 | |     }
    | |_____^ future created by async block is not `Send`
    |
    = help: within `impl futures::Future`, the trait `std::marker::Send` is not implemented for `NonNull<c_void>`
note: future is not `Send` as it awaits another future which is not `Send`
   --> src\winrtble\ble\device.rs:71:30
    |
71  |         let service_result = async_op.await.map_err(winrt_error)?;
    |                              ^^^^^^^^ await occurs here on type `IAsyncOperation<GattDeviceServicesResult>`, which is not `Send`
    = note: required for the cast to the object type `dyn futures::Future<Output = std::result::Result<(), Error>> + std::marker::Send`

error: future cannot be sent between threads safely
   --> src\winrtble\peripheral.rs:392:53
    |
392 |       async fn discover_services(&self) -> Result<()> {
    |  _____________________________________________________^
393 | |         let device = self.shared.device.lock().await;
394 | |         if let Some(ref device) = *device {
395 | |             let gatt_services = device.discover_services().await?;
...   |
422 | |         Err(Error::NotConnected)
423 | |     }
    | |_____^ future created by async block is not `Send`
    |
    = help: within `impl futures::Future`, the trait `std::marker::Send` is not implemented for `NonNull<c_void>`
note: future is not `Send` as it awaits another future which is not `Send`
   --> src\winrtble\ble\device.rs:71:30
    |
71  |         let service_result = async_op.await.map_err(winrt_error)?;
    |                              ^^^^^^^^ await occurs here on type `IAsyncOperation<GattDeviceServicesResult>`, which is not `Send`
    = note: required for the cast to the object type `dyn futures::Future<Output = std::result::Result<(), Error>> + std::marker::Send`
@kennykerr
Copy link
Collaborator

I thought there were tests for this - will get it fixed asap.

@kennykerr
Copy link
Collaborator

Sorry for the delay! This fix is included with #1423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants