[][src]Struct rubble::link::advertising::Header

pub struct Header(_);

16-bit Advertising Channel PDU header preceding the Payload.

The header looks like this:

LSB                                                                     MSB
+------------+------------+---------+---------+--------------+------------+
|  PDU Type  |     -      |  TxAdd  |  RxAdd  |    Length    |     -      |
|  (4 bits)  |  (2 bits)  | (1 bit) | (1 bit) |   (6 bits)   |  (2 bits)  |
+------------+------------+---------+---------+--------------+------------+

The TxAdd and RxAdd field are only used for some payloads, for all others, they should be set to 0.

Length may be in range 6 to 37 (inclusive). With the 2-Byte header this is exactly the max. on-air packet size.

Methods

impl Header[src]

pub fn new(ty: PduType) -> Self[src]

Creates a new Advertising Channel PDU header specifying the Payload type ty.

pub fn parse(raw: &[u8]) -> Self[src]

pub fn to_u16(&self) -> u16[src]

Returns the raw representation of the header.

The returned u16 must be transmitted LSb first as the first 2 octets of the PDU.

pub fn type_(&self) -> PduType[src]

Returns the PDU type specified in the header.

pub fn tx_add(&self) -> bool[src]

Returns the state of the TxAdd field.

pub fn set_tx_add(&mut self, value: bool)[src]

Sets the TxAdd field's value.

pub fn rx_add(&self) -> bool[src]

Returns the state of the RxAdd field.

pub fn set_rx_add(&mut self, value: bool)[src]

Sets the RxAdd field's value.

pub fn payload_length(&self) -> u8[src]

Returns the length of the payload in octets as specified in the Length field.

According to the spec, the length must be in range 6...37, but this isn't checked by this function.

pub fn set_payload_length(&mut self, length: u8)[src]

Sets the payload length of this PDU.

The length must be in range 6...37, otherwise this function panics.

Trait Implementations

impl ToBytes for Header[src]

impl<'a> FromBytes<'a> for Header[src]

impl Copy for Header[src]

impl Debug for Header[src]

impl Clone for Header[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Header

impl Sync for Header

Blanket Implementations

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> From for T[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]