[−][src]Struct bluez_async::BluetoothSession
A connection to the Bluetooth daemon. This can be cheaply cloned and passed around to be used from different places. It is the main entry point to the library.
Fields
connection: Arc<SyncConnection>
Implementations
impl BluetoothSession
[src]
pub async fn new(
) -> Result<(impl Future<Output = Result<(), SpawnError>>, Self), BluetoothError>
[src]
) -> Result<(impl Future<Output = Result<(), SpawnError>>, Self), BluetoothError>
Establish a new D-Bus connection to communicate with BlueZ.
Returns a tuple of (join handle, Self). If the join handle ever completes then you're in trouble and should probably restart the process.
pub async fn start_discovery(&self) -> Result<(), BluetoothError>
[src]
Power on all Bluetooth adapters and start scanning for devices.
pub async fn get_devices(&self) -> Result<Vec<DeviceInfo>, BluetoothError>
[src]
Get a list of all Bluetooth devices which have been discovered so far.
pub async fn get_services(
&self,
device: &DeviceId
) -> Result<Vec<ServiceInfo>, BluetoothError>
[src]
&self,
device: &DeviceId
) -> Result<Vec<ServiceInfo>, BluetoothError>
Get a list of all GATT services which the given Bluetooth device offers.
Note that this won't be filled in until the device is connected.
pub async fn get_characteristics(
&self,
service: &ServiceId
) -> Result<Vec<CharacteristicInfo>, BluetoothError>
[src]
&self,
service: &ServiceId
) -> Result<Vec<CharacteristicInfo>, BluetoothError>
Get a list of all characteristics on the given GATT service.
pub async fn get_descriptors(
&self,
characteristic: &CharacteristicId
) -> Result<Vec<DescriptorInfo>, BluetoothError>
[src]
&self,
characteristic: &CharacteristicId
) -> Result<Vec<DescriptorInfo>, BluetoothError>
Get a list of all descriptors on the given GATT characteristic.
pub async fn get_service_by_uuid(
&self,
device: &DeviceId,
uuid: Uuid
) -> Result<ServiceInfo, BluetoothError>
[src]
&self,
device: &DeviceId,
uuid: Uuid
) -> Result<ServiceInfo, BluetoothError>
Find a GATT service with the given UUID advertised by the given device, if any.
Note that this generally won't work until the device is connected.
pub async fn get_characteristic_by_uuid(
&self,
service: &ServiceId,
uuid: Uuid
) -> Result<CharacteristicInfo, BluetoothError>
[src]
&self,
service: &ServiceId,
uuid: Uuid
) -> Result<CharacteristicInfo, BluetoothError>
Find a characteristic with the given UUID as part of the given GATT service advertised by a device, if there is any.
pub async fn get_service_characteristic_by_uuid(
&self,
device: &DeviceId,
service_uuid: Uuid,
characteristic_uuid: Uuid
) -> Result<CharacteristicInfo, BluetoothError>
[src]
&self,
device: &DeviceId,
service_uuid: Uuid,
characteristic_uuid: Uuid
) -> Result<CharacteristicInfo, BluetoothError>
Convenience method to get a GATT charactacteristic with the given UUID advertised by a device as part of the given service.
This is equivalent to calling get_service_by_uuid
and then get_characteristic_by_uuid
.
pub async fn get_service_info(
&self,
id: &ServiceId
) -> Result<ServiceInfo, BluetoothError>
[src]
&self,
id: &ServiceId
) -> Result<ServiceInfo, BluetoothError>
Get information about the given GATT service.
pub async fn get_characteristic_info(
&self,
id: &CharacteristicId
) -> Result<CharacteristicInfo, BluetoothError>
[src]
&self,
id: &CharacteristicId
) -> Result<CharacteristicInfo, BluetoothError>
Get information about the given GATT characteristic.
pub async fn get_descriptor_info(
&self,
id: &DescriptorId
) -> Result<DescriptorInfo, BluetoothError>
[src]
&self,
id: &DescriptorId
) -> Result<DescriptorInfo, BluetoothError>
Get information about the given GATT descriptor.
pub async fn connect(&self, id: &DeviceId) -> Result<(), BluetoothError>
[src]
Connect to the Bluetooth device with the given D-Bus object path.
pub async fn disconnect(&self, id: &DeviceId) -> Result<(), BluetoothError>
[src]
Disconnect from the Bluetooth device with the given D-Bus object path.
pub async fn read_characteristic_value(
&self,
id: &CharacteristicId
) -> Result<Vec<u8>, BluetoothError>
[src]
&self,
id: &CharacteristicId
) -> Result<Vec<u8>, BluetoothError>
Read the value of the given GATT characteristic.
pub async fn write_characteristic_value(
&self,
id: &CharacteristicId,
value: impl Into<Vec<u8>>
) -> Result<(), BluetoothError>
[src]
&self,
id: &CharacteristicId,
value: impl Into<Vec<u8>>
) -> Result<(), BluetoothError>
Write the given value to the given GATT characteristic.
pub async fn read_descriptor_value(
&self,
id: &DescriptorId
) -> Result<Vec<u8>, BluetoothError>
[src]
&self,
id: &DescriptorId
) -> Result<Vec<u8>, BluetoothError>
Read the value of the given GATT descriptor.
pub async fn write_descriptor_value(
&self,
id: &DescriptorId,
value: impl Into<Vec<u8>>
) -> Result<(), BluetoothError>
[src]
&self,
id: &DescriptorId,
value: impl Into<Vec<u8>>
) -> Result<(), BluetoothError>
Write the given value to the given GATT descriptor.
pub async fn start_notify(
&self,
id: &CharacteristicId
) -> Result<(), BluetoothError>
[src]
&self,
id: &CharacteristicId
) -> Result<(), BluetoothError>
Start notifications on the given GATT characteristic.
pub async fn stop_notify(
&self,
id: &CharacteristicId
) -> Result<(), BluetoothError>
[src]
&self,
id: &CharacteristicId
) -> Result<(), BluetoothError>
Stop notifications on the given GATT characteristic.
pub async fn event_stream(
&self
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
[src]
&self
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
Get a stream of events for all devices.
pub async fn device_event_stream(
&self,
device: &DeviceId
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
[src]
&self,
device: &DeviceId
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
Get a stream of events for a particular device. This includes events for all its characteristics.
pub async fn characteristic_event_stream(
&self,
characteristic: &CharacteristicId
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
[src]
&self,
characteristic: &CharacteristicId
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
Get a stream of events for a particular characteristic of a device.
Trait Implementations
impl Clone for BluetoothSession
[src]
pub fn clone(&self) -> BluetoothSession
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for BluetoothSession
[src]
Auto Trait Implementations
impl !RefUnwindSafe for BluetoothSession
[src]
impl Send for BluetoothSession
[src]
impl Sync for BluetoothSession
[src]
impl Unpin for BluetoothSession
[src]
impl !UnwindSafe for BluetoothSession
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,