BluetoothDeviceList

Struct BluetoothDeviceList 

Source
pub struct BluetoothDeviceList { /* private fields */ }
Expand description

Bluetooth device list structure

This structure represents a list of up to 10 Bluetooth devices, including their configuration and connection status. Itโ€™s used for managing multiple Bluetooth devices in embedded systems.

ยงMemory Layout

The structure uses #[repr(C)] to ensure predictable memory layout, making it suitable for serialization and inter-process communication.

ยงSecurity Note

This structure may store sensitive pairing data. Ensure proper memory protection and secure storage mechanisms when persisting this data.

ยงFields

  • magic: Structure validation (0x42544C53)
  • devices: Array of up to 10 device configurations
  • device_count: Number of valid devices in the list
  • _padding: Ensures 4-byte alignment

ยงErrors

  • Error::DeviceListFull if adding more than 10 devices
  • Error::IndexOutOfBounds for invalid indices

ยงExamples

use renik::{BluetoothDeviceInfo, BluetoothDeviceList};

let mac_addr1 = [0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC];
let mac_addr2 = [0x98, 0x76, 0x54, 0x32, 0x10, 0xFE];
let device1 = BluetoothDeviceInfo::new(&mac_addr1, b"Device 1").unwrap();
let device2 = BluetoothDeviceInfo::new(&mac_addr2, b"Device 2").unwrap();
let mut device_list = BluetoothDeviceList::default();
device_list.add_device(device1).unwrap();
device_list.add_device(device2).unwrap();
assert_eq!(device_list.len(), 2);

Implementationsยง

Sourceยง

impl BluetoothDeviceList

Source

pub fn add_device( &mut self, device_config: BluetoothDeviceInfo, ) -> Result<(), Error>

Adds a Bluetooth device configuration to the list

ยงParameters
  • device_config: Bluetooth device configuration
ยงReturns
  • Ok(()) if the device was added successfully
  • Err(Error) if the device list is full
ยงErrors

Returns Error::DeviceListFull if the device list is already at maximum capacity.

Source

pub fn remove_device(&mut self, index: usize) -> Result<(), Error>

Removes a Bluetooth device configuration from the list

ยงParameters
  • index: Index of the device to remove (0-based)
ยงReturns
  • Ok(()) if the device was removed successfully
  • Err(Error) if the index is out of bounds
ยงErrors

Returns Error::IndexOutOfBounds if the specified index is not valid.

Source

pub fn device(&self, index: usize) -> Result<&BluetoothDeviceInfo, Error>

Returns a reference to a Bluetooth device configuration

ยงParameters
  • index: Index of the device to retrieve (0-based)
ยงReturns
  • Ok(&BluetoothDeviceInfo) if the index is valid
  • Err(Error) if the index is out of bounds
ยงErrors

Returns Error::IndexOutOfBounds if the specified index is not valid.

Source

pub fn len(&self) -> usize

Returns the number of devices in the list

ยงReturns

The current device count

Source

pub fn is_empty(&self) -> bool

Checks if the device list is empty

ยงReturns
  • true if there are no devices in the list
  • false otherwise

Trait Implementationsยง

Sourceยง

impl Clone for BluetoothDeviceList

Sourceยง

fn clone(&self) -> BluetoothDeviceList

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 BluetoothDeviceList

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Default for BluetoothDeviceList

Sourceยง

fn default() -> Self

Creates a new Bluetooth device list with default values

The structure is initialized with the correct magic number and an empty device list.

Sourceยง

impl Zeroable for BluetoothDeviceList

Sourceยง

impl Copy for BluetoothDeviceList

Sourceยง

impl Pod for BluetoothDeviceList

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> CheckedBitPattern for T
where T: AnyBitPattern,

Sourceยง

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Sourceยง

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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, 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.
Sourceยง

impl<T> AnyBitPattern for T
where T: Pod,

Sourceยง

impl<T> NoUninit for T
where T: Pod,