pub struct ClientCharacteristicConfiguration {
pub configuration: u16,
}Expand description
Client Characteristic Configuration.
Fields§
§configuration: u16Characteristic Configuration Bits
Implementations§
Source§impl ClientCharacteristicConfiguration
impl ClientCharacteristicConfiguration
Sourcepub fn new(configuration: u16) -> Self
pub fn new(configuration: u16) -> Self
Create ClientCharacteristicConfiguration from Characteristic Configuration Bit.
§Examples
use ble_data_struct::descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
};
let result = ClientCharacteristicConfiguration::new(NOTIFICATION);
assert_eq!(NOTIFICATION, result.configuration);Sourcepub fn is_notification(&self) -> bool
pub fn is_notification(&self) -> bool
check Notification configuration.
§Examples
use ble_data_struct::descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
};
let result = ClientCharacteristicConfiguration::new(NOTIFICATION);
assert!(result.is_notification());
assert!(!result.is_indication());Sourcepub fn is_indication(&self) -> bool
pub fn is_indication(&self) -> bool
check Inidication configuration.
§Examples
use ble_data_struct::descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
};
let result = ClientCharacteristicConfiguration::new(INDICATION);
assert!(!result.is_notification());
assert!(result.is_indication());Trait Implementations§
Source§impl Clone for ClientCharacteristicConfiguration
impl Clone for ClientCharacteristicConfiguration
Source§fn clone(&self) -> ClientCharacteristicConfiguration
fn clone(&self) -> ClientCharacteristicConfiguration
Returns a duplicate 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 Into<GattClientCharacteristicConfigurationDescriptorValue> for ClientCharacteristicConfiguration
Available on Windows only.
impl Into<GattClientCharacteristicConfigurationDescriptorValue> for ClientCharacteristicConfiguration
Available on Windows only.
Source§fn into(self) -> GattClientCharacteristicConfigurationDescriptorValue
fn into(self) -> GattClientCharacteristicConfigurationDescriptorValue
Create [GattClientCharacteristicConfigurationDescriptorValue] from ClientCharacteristicConfiguration.
§Examples
use windows::{
Devices::Bluetooth::GenericAttributeProfile::GattClientCharacteristicConfigurationDescriptorValue,
Storage::Streams::DataWriter,
};
use ble_data_struct::descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
};
let value: GattClientCharacteristicConfigurationDescriptorValue =
ClientCharacteristicConfiguration::new(0).into();
assert_eq!(
GattClientCharacteristicConfigurationDescriptorValue::None,
value
);
let value: GattClientCharacteristicConfigurationDescriptorValue =
ClientCharacteristicConfiguration::new(NOTIFICATION).into();
assert_eq!(
GattClientCharacteristicConfigurationDescriptorValue::Notify,
value
);
let value: GattClientCharacteristicConfigurationDescriptorValue =
ClientCharacteristicConfiguration::new(INDICATION).into();
assert_eq!(
GattClientCharacteristicConfigurationDescriptorValue::Indicate,
value
);Source§impl Into<IBuffer> for ClientCharacteristicConfiguration
Available on Windows only.
impl Into<IBuffer> for ClientCharacteristicConfiguration
Available on Windows only.
Source§fn into(self) -> IBuffer
fn into(self) -> IBuffer
Create [IBuffer] from ClientCharacteristicConfiguration.
§Examples
use windows::{
Devices::Bluetooth::GenericAttributeProfile::GattClientCharacteristicConfigurationDescriptorValue,
Storage::Streams::{DataWriter, IBuffer},
};
use ble_data_struct::{
descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
},
windows::buffer::i_buffer_to_vec,
};
let value = ClientCharacteristicConfiguration::new(0);
let buffer: IBuffer = value.clone().into();
let vec: Vec<u8> = value.into();
assert_eq!(vec, i_buffer_to_vec(buffer).unwrap());
let value = ClientCharacteristicConfiguration::new(NOTIFICATION);
let buffer: IBuffer = value.clone().into();
let vec: Vec<u8> = value.into();
assert_eq!(vec, i_buffer_to_vec(buffer).unwrap());
let value = ClientCharacteristicConfiguration::new(INDICATION);
let buffer: IBuffer = value.clone().into();
let vec: Vec<u8> = value.into();
assert_eq!(vec, i_buffer_to_vec(buffer).unwrap());Source§impl Into<Vec<u8>> for ClientCharacteristicConfiguration
impl Into<Vec<u8>> for ClientCharacteristicConfiguration
Source§fn into(self) -> Vec<u8> ⓘ
fn into(self) -> Vec<u8> ⓘ
Create Vec<u8> from ClientCharacteristicConfiguration.
§Examples
use ble_data_struct::descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
};
let configuration = NOTIFICATION.to_le_bytes().to_vec();
let result = ClientCharacteristicConfiguration::new(NOTIFICATION);
let into_data: Vec<u8> = result.into();
assert_eq!(configuration, into_data);
let configuration = INDICATION.to_le_bytes().to_vec();
let result = ClientCharacteristicConfiguration::new(INDICATION);
let into_data: Vec<u8> = result.into();
assert_eq!(configuration, into_data);Source§impl PartialEq for ClientCharacteristicConfiguration
impl PartialEq for ClientCharacteristicConfiguration
Source§fn eq(&self, other: &ClientCharacteristicConfiguration) -> bool
fn eq(&self, other: &ClientCharacteristicConfiguration) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl TryFrom<&GattClientCharacteristicConfigurationDescriptorValue> for ClientCharacteristicConfiguration
Available on Windows only.
impl TryFrom<&GattClientCharacteristicConfigurationDescriptorValue> for ClientCharacteristicConfiguration
Available on Windows only.
Source§fn try_from(
value: &GattClientCharacteristicConfigurationDescriptorValue,
) -> Result<Self, String>
fn try_from( value: &GattClientCharacteristicConfigurationDescriptorValue, ) -> Result<Self, String>
Create ClientCharacteristicConfiguration from [GattClientCharacteristicConfigurationDescriptorValue].
§Examples
use windows::{
Devices::Bluetooth::GenericAttributeProfile::GattClientCharacteristicConfigurationDescriptorValue,
Storage::Streams::DataWriter,
};
use ble_data_struct::descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
};
let result = ClientCharacteristicConfiguration::try_from(
&GattClientCharacteristicConfigurationDescriptorValue::None,
);
assert!(result.is_ok());
let value = result.unwrap();
assert!(!value.is_notification());
assert!(!value.is_indication());
let result = ClientCharacteristicConfiguration::try_from(
&GattClientCharacteristicConfigurationDescriptorValue::Notify,
);
assert!(result.is_ok());
let value = result.unwrap();
assert!(value.is_notification());
assert!(!value.is_indication());
let result = ClientCharacteristicConfiguration::try_from(
&GattClientCharacteristicConfigurationDescriptorValue::Indicate,
);
assert!(result.is_ok());
let value = result.unwrap();
assert!(!value.is_notification());
assert!(value.is_indication());Source§impl TryFrom<&Vec<u8>> for ClientCharacteristicConfiguration
impl TryFrom<&Vec<u8>> for ClientCharacteristicConfiguration
Source§fn try_from(value: &Vec<u8>) -> Result<Self, String>
fn try_from(value: &Vec<u8>) -> Result<Self, String>
Create ClientCharacteristicConfiguration from Vec<u8>.
§Examples
use ble_data_struct::descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
};
let configuration = NOTIFICATION.to_le_bytes().to_vec();
let result = ClientCharacteristicConfiguration::try_from(&configuration);
assert!(result.is_ok());
assert_eq!(NOTIFICATION, result.unwrap().configuration);
let configuration = INDICATION.to_le_bytes().to_vec();
let result = ClientCharacteristicConfiguration::try_from(&configuration);
assert!(result.is_ok());
assert_eq!(INDICATION, result.unwrap().configuration);
let configuration = Vec::new();
let result = ClientCharacteristicConfiguration::try_from(&configuration);
assert!(!result.is_ok());Source§impl TryFrom<IBuffer> for ClientCharacteristicConfiguration
Available on Windows only.
impl TryFrom<IBuffer> for ClientCharacteristicConfiguration
Available on Windows only.
Source§fn try_from(value: IBuffer) -> Result<Self, String>
fn try_from(value: IBuffer) -> Result<Self, String>
Create ClientCharacteristicConfiguration from [IBuffer].
§Examples
use windows::Storage::Streams::{DataWriter, IBuffer};
use ble_data_struct::descriptors::client_characteristic_configuration::{
ClientCharacteristicConfiguration, INDICATION, NOTIFICATION,
};
let client_characteristic_configuration =
ClientCharacteristicConfiguration::new(NOTIFICATION);
let data_writer = DataWriter::new().unwrap();
let ble_packet: Vec<u8> = client_characteristic_configuration.into();
data_writer.WriteBytes(&ble_packet).unwrap();
let buffer = data_writer.DetachBuffer().unwrap();
let result = ClientCharacteristicConfiguration::try_from(buffer);
assert!(result.is_ok());
let value = result.unwrap();
assert!(value.is_notification());Source§impl Uuid16bit for ClientCharacteristicConfiguration
impl Uuid16bit for ClientCharacteristicConfiguration
Source§fn uuid_16bit() -> u16
fn uuid_16bit() -> u16
return 0x2902.
§Examples
use ble_data_struct::Uuid16bit;
use ble_data_struct::descriptors::client_characteristic_configuration::ClientCharacteristicConfiguration;
assert_eq!(0x2902, ClientCharacteristicConfiguration::uuid_16bit());impl StructuralPartialEq for ClientCharacteristicConfiguration
Auto Trait Implementations§
impl Freeze for ClientCharacteristicConfiguration
impl RefUnwindSafe for ClientCharacteristicConfiguration
impl Send for ClientCharacteristicConfiguration
impl Sync for ClientCharacteristicConfiguration
impl Unpin for ClientCharacteristicConfiguration
impl UnwindSafe for ClientCharacteristicConfiguration
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