Trait HciHeader

Source
pub trait HciHeader {
    const HEADER_LENGTH: usize;

    // Required methods
    fn new(opcode: Opcode, param_len: usize) -> Self;
    fn copy_into_slice(&self, buf: &mut [u8]);
}
Expand description

Trait to define a command packet header.

See the Bluetooth Specification Vol 2, Part E, section 5.4.1. The command packet header contains an opcode (comprising a 6-bit OGF and 10-bit OCF) and a 1-byte parameter length. The packet itself then contains various parameters as defined by the Bluetooth specification.

Before this command header, many (all?) Bluetooth implementations include a 1-byte packet type preceding the command header. This version of the HciHeader is implemented by uart::CommandHeader.

Required Associated Constants§

Source

const HEADER_LENGTH: usize

Defines the length of the packet header. With the packet byte, this is 4. Without it, the length shall be 3.

Required Methods§

Source

fn new(opcode: Opcode, param_len: usize) -> Self

Returns a new header with the given opcode and parameter length.

Source

fn copy_into_slice(&self, buf: &mut [u8])

Serialize the header into the given buffer, in Bluetooth byte order (little-endian).

§Panics

Panics if buf.len() < Self::HEADER_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§