ClientCharacteristicConfiguration

Struct ClientCharacteristicConfiguration 

Source
pub struct ClientCharacteristicConfiguration {
    pub configuration: u16,
}
Expand description

Client Characteristic Configuration.

Fields§

§configuration: u16

Characteristic Configuration Bits

Implementations§

Source§

impl ClientCharacteristicConfiguration

Source

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);
Source

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());
Source

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

Source§

fn clone(&self) -> ClientCharacteristicConfiguration

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientCharacteristicConfiguration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Into<GattClientCharacteristicConfigurationDescriptorValue> for ClientCharacteristicConfiguration

Available on Windows only.
Source§

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.
Source§

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

Source§

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

Source§

fn eq(&self, other: &ClientCharacteristicConfiguration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&GattClientCharacteristicConfigurationDescriptorValue> for ClientCharacteristicConfiguration

Available on Windows only.
Source§

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§

type Error = String

The type returned in the event of a conversion error.
Source§

impl TryFrom<&Vec<u8>> for ClientCharacteristicConfiguration

Source§

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§

type Error = String

The type returned in the event of a conversion error.
Source§

impl TryFrom<IBuffer> for ClientCharacteristicConfiguration

Available on Windows only.
Source§

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§

type Error = String

The type returned in the event of a conversion error.
Source§

impl Uuid16bit for ClientCharacteristicConfiguration

Source§

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());
Source§

impl StructuralPartialEq for ClientCharacteristicConfiguration

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.