Struct bluest::Descriptor
source · pub struct Descriptor(/* private fields */);
Expand description
A Bluetooth GATT descriptor
Implementations§
source§impl Descriptor
impl Descriptor
sourcepub fn uuid(&self) -> Uuid
pub fn uuid(&self) -> Uuid
The Uuid
identifying the type of this GATT descriptor
Panics
On Linux, this method will panic if there is a current Tokio runtime and it is single-threaded, if there is no
current Tokio runtime and creating one fails, or if the underlying Descriptor::uuid_async()
method
fails.
sourcepub async fn uuid_async(&self) -> Result<Uuid>
pub async fn uuid_async(&self) -> Result<Uuid>
The Uuid
identifying the type of this GATT descriptor
sourcepub async fn value(&self) -> Result<Vec<u8>>
pub async fn value(&self) -> Result<Vec<u8>>
The cached value of this descriptor
If the value has not yet been read, this method may either return an error or perform a read of the value.
sourcepub async fn read(&self) -> Result<Vec<u8>>
pub async fn read(&self) -> Result<Vec<u8>>
Read the value of this descriptor from the device
Examples found in repository?
examples/connected.rs (line 46)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
async fn main() -> Result<(), Box<dyn Error>> {
use tracing_subscriber::prelude::*;
use tracing_subscriber::{fmt, EnvFilter};
tracing_subscriber::registry()
.with(fmt::layer())
.with(
EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy(),
)
.init();
let adapter = Adapter::default().await.ok_or("Bluetooth adapter not found")?;
adapter.wait_available().await?;
info!("getting connected devices");
let devices = adapter.connected_devices().await?;
for device in devices {
info!("found {:?}", device);
adapter.connect_device(&device).await?;
let services = device.services().await?;
for service in services {
info!(" {:?}", service);
let characteristics = service.characteristics().await?;
for characteristic in characteristics {
info!(" {:?}", characteristic);
let props = characteristic.properties().await?;
info!(" props: {:?}", props);
if props.read {
info!(" value: {:?}", characteristic.read().await);
}
if props.write_without_response {
info!(" max_write_len: {:?}", characteristic.max_write_len());
}
let descriptors = characteristic.descriptors().await?;
for descriptor in descriptors {
info!(" {:?}: {:?}", descriptor, descriptor.read().await);
}
}
}
}
info!("done");
Ok(())
}
Trait Implementations§
source§impl Clone for Descriptor
impl Clone for Descriptor
source§fn clone(&self) -> Descriptor
fn clone(&self) -> Descriptor
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Descriptor
impl Debug for Descriptor
source§impl PartialEq for Descriptor
impl PartialEq for Descriptor
source§fn eq(&self, other: &Descriptor) -> bool
fn eq(&self, other: &Descriptor) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for Descriptor
impl StructuralEq for Descriptor
impl StructuralPartialEq for Descriptor
Auto Trait Implementations§
impl RefUnwindSafe for Descriptor
impl Send for Descriptor
impl Sync for Descriptor
impl Unpin for Descriptor
impl UnwindSafe for Descriptor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more