Channel

Struct Channel 

Source
pub struct Channel(/* private fields */);
Expand description

An L2CAP channel identifier (CID).

Channels are basically like TCP ports. A Protocol can listen on a channel and is connected to a channel on the other device to which all responses are addressed.

A number of channel identifiers are reserved for predefined functions:

  • 0x0000: The null identifier. Must never be used as a destination endpoint.
  • 0x0001: L2CAP signaling channel (Classic Bluetooth only).
  • 0x0002: Connectionless channel (Classic Bluetooth only).
  • 0x0003: AMP manager (not relevant for Classic and LE Bluetooth).
  • 0x0004: Attribute protocol (ATT). BLE only.
  • 0x0005: LE L2CAP signaling channel.
  • 0x0006: LE Security Manager protocol.
  • 0x0007: Classic Bluetooth Security Manager protocol.
  • 0x0008-0x003E: Reserved.
  • 0x003F: AMP test manager (not relevant for Classic and LE Bluetooth).

For BLE, channels 0x0040-0x007F are dynamically allocated, while 0x0080 and beyond are reserved and should not be used (as of Bluetooth 4.2).

For classic Bluetooth, all channels 0x0040-0xFFFF are available for dynamic allocation.

Implementations§

Source§

impl Channel

Source

pub const NULL: Self

The null channel identifier. Must not be used as a destination endpoint.

Source

pub const ATT: Self

The channel used by the Attribute Protocol (ATT).

Source

pub const LE_SIGNALING: Self

LE L2CAP signaling channel (connectionless).

Source

pub const LE_SECURITY_MANAGER: Self

LE Security Manager channel.

Source

pub fn as_raw(&self) -> u16

Returns the channel identifier (CID) as a raw u16.

Source

pub fn is_connection_oriented(&self) -> bool

Returns whether this channel is connection-oriented.

L2CAP PDUs addressed to connection-oriented channels are called B-frames if the channel is in “Basic Mode”, and can be either S-frames or I-frames if the channel is in retransmission/flow control/streaming modes.

Source

pub fn is_connectionless(&self) -> bool

Returns whether this channel is connectionless.

L2CAP PDUs addressed to connectionless channels are called G-frames.

Trait Implementations§

Source§

impl Clone for Channel

Source§

fn clone(&self) -> Channel

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 Channel

Source§

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

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

impl FromBytes<'_> for Channel

Source§

fn from_bytes(bytes: &mut ByteReader<'_>) -> Result<Self, Error>

Decode a Self from a byte slice, advancing bytes to point past the data that was read. Read more
Source§

impl Hash for Channel

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Channel

Source§

fn eq(&self, other: &Channel) -> 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 ToBytes for Channel

Source§

fn to_bytes(&self, writer: &mut ByteWriter<'_>) -> Result<(), Error>

Converts self to bytes and writes them into writer, advancing writer to point past the encoded value. Read more
Source§

impl Copy for Channel

Source§

impl Eq for Channel

Source§

impl StructuralPartialEq for Channel

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> Same for T

Source§

type Output = T

Should always be Self
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.