Skip to main content

BluetoothUuidExt

Trait BluetoothUuidExt 

Source
pub trait BluetoothUuidExt: Sealed {
    // Required methods
    fn from_u16(uuid: u16) -> Self;
    fn from_u32(uuid: u32) -> Self;
    fn from_bluetooth_bytes(bytes: &[u8]) -> Self;
    fn is_u16_uuid(&self) -> bool;
    fn is_u32_uuid(&self) -> bool;
    fn try_to_u16(&self) -> Option<u16>;
    fn try_to_u32(&self) -> Option<u32>;
    fn as_bluetooth_bytes(&self) -> &[u8] ;
}
Expand description

Extension trait for Uuid with helper methods for dealing with Bluetooth 16-bit and 32-bit UUIDs

Required Methods§

Source

fn from_u16(uuid: u16) -> Self

Creates a 16-bit Bluetooth UUID

Source

fn from_u32(uuid: u32) -> Self

Creates a 32-bit Bluetooth UUID

Source

fn from_bluetooth_bytes(bytes: &[u8]) -> Self

Creates a UUID from bytes

§Panics

Panics if bytes.len() is not one of 2, 4, or 16

Source

fn is_u16_uuid(&self) -> bool

Returns true if self is a valid 16-bit Bluetooth UUID

Source

fn is_u32_uuid(&self) -> bool

Returns true if self is a valid 32-bit Bluetooth UUID

Source

fn try_to_u16(&self) -> Option<u16>

Tries to convert self into a 16-bit Bluetooth UUID

Source

fn try_to_u32(&self) -> Option<u32>

Tries to convert self into a 32-bit Bluetooth UUID

Source

fn as_bluetooth_bytes(&self) -> &[u8]

Returns a slice of octets representing the UUID. If the UUID is a valid 16- or 32-bit Bluetooth UUID, the returned slice will be 2 or 4 octets long, respectively. Otherwise the slice will be 16-octets in length.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§