bluez / bluer

BlueR — Official BlueZ Bindings for Rust
https://crates.io/crates/bluer
Other
321 stars 45 forks source link

examples/discover_devices.rs – struct `DiscoveryFilter` is private #91

Closed r-bt closed 1 year ago

r-bt commented 1 year ago

I'm attempting to run examples/discover_devices.rs in my own project. The steps were

  1. cargo new [project-name]
  2. As per https://github.com/bluez/bluer/issues/43 added the dependencies 2.1 cargo add -F full bluer 2.2 cargo add tokio 2.3 cargo add env_logger 2.4 cargo add futures
  3. Copy code from examples/discover_devices.rs into src/main.rs
  4. cargo run

However then I get:

error[E0603]: struct `DiscoveryFilter` is private

The full error log is blow:

error[E0603]: struct `DiscoveryFilter` is private
   --> src/main.rs:3:58
    |
3   | use bluer::{Adapter, AdapterEvent, Address, DeviceEvent, DiscoveryFilter, DiscoveryTransport};
    |                                                          ^^^^^^^^^^^^^^^ private struct
    |
note: the struct `DiscoveryFilter` is defined here
   --> /home/rbeattie/.cargo/registry/src/index.crates.io-1cd66030c949c28d/bluer-0.15.7/src/lib.rs:536:17
    |
536 | pub use crate::{adapter::*, device::*, session::*};
    |                 ^^^^^^^^^^

error[E0603]: enum `DiscoveryTransport` is private
   --> src/main.rs:3:75
    |
3   | use bluer::{Adapter, AdapterEvent, Address, DeviceEvent, DiscoveryFilter, DiscoveryTransport};
    |                                                                           ^^^^^^^^^^^^^^^^^^ private enum
    |
note: the enum `DiscoveryTransport` is defined here
   --> /home/rbeattie/.cargo/registry/src/index.crates.io-1cd66030c949c28d/bluer-0.15.7/src/lib.rs:536:17
    |
536 | pub use crate::{adapter::*, device::*, session::*};
    |                 ^^^^^^^^^^

error[E0599]: no method named `set_discovery_filter` found for struct `Adapter` in the current scope
  --> src/main.rs:58:13
   |
58 |     adapter.set_discovery_filter(filter).await?;
   |             ^^^^^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `set_discoverable`

error[E0599]: no method named `discovery_filter` found for struct `Adapter` in the current scope
  --> src/main.rs:59:60
   |
59 |     println!("Using discovery filter:\n{:#?}\n\n", adapter.discovery_filter().await);
   |                                                            ^^^^^^^^^^^^^^^^ method not found in `Adapter`

Some errors have detailed explanations: E0599, E0603.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `discover` (bin "discover") due to 5 previous errors

I wonder is this related to https://github.com/bluez/bluer/issues/90?

surban commented 1 year ago

DiscoveryFilter is public since version 0.16.0-pre1.

r-bt commented 1 year ago

Thanks, upgrading to 0.16.0-pre1 fixed the issue :)