Skip to main content

Advertisement

Struct Advertisement 

Source
#[non_exhaustive]
pub struct Advertisement {
Show 29 fields pub flags: Option<Flags>, pub services: Vec<ServiceUuid>, pub solicited_services: Vec<Uuid>, pub local_name: Option<LocalName>, pub broadcast_name: Option<String>, pub tx_power: Option<i8>, pub appearance: Option<u16>, pub appearance_name: Option<String>, pub class_of_device: Option<u32>, pub device_id: Option<DeviceId>, pub service_data: Vec<ServiceData>, pub manufacturer_data: Vec<ManufacturerData>, pub peripheral_connection_interval: Option<(u16, u16)>, pub advertising_interval: Option<u32>, pub public_target_addresses: Vec<AddressBytes>, pub random_target_addresses: Vec<AddressBytes>, pub le_address: Option<(String, bool)>, pub le_role: Option<u8>, pub uri: Option<String>, pub le_supported_features: Option<Vec<u8>>, pub resolvable_set_identifier: Option<[u8; 6]>, pub sm_tk: Option<[u8; 16]>, pub sm_oob_flags: Option<u8>, pub le_sc_confirmation: Option<[u8; 16]>, pub le_sc_random: Option<[u8; 16]>, pub ssp_hash: Option<[u8; 16]>, pub ssp_randomizer: Option<[u8; 16]>, pub other: Vec<RawAd>, pub malformed: Option<Malformed>,
}
Expand description

Every field an advertisement (or a scan response, or both concatenated) can carry, read into typed values.

A field whose length is wrong for its type is kept in Advertisement::other instead, so nothing the device sent is lost.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§flags: Option<Flags>

Flags.

§services: Vec<ServiceUuid>

Service UUIDs, 16, 32 and 128-bit, complete and incomplete lists.

§solicited_services: Vec<Uuid>

Service Solicitation UUIDs.

§local_name: Option<LocalName>

Shortened or Complete Local Name (the complete one wins).

§broadcast_name: Option<String>

Broadcast_Name (LE Audio broadcasts).

§tx_power: Option<i8>

TX Power Level, dBm.

§appearance: Option<u16>

Appearance, raw.

§appearance_name: Option<String>

Appearance category and subcategory names.

§class_of_device: Option<u32>

Class of Device (BR/EDR), 24 bits.

§device_id: Option<DeviceId>

Device ID.

§service_data: Vec<ServiceData>

Service Data, 16, 32 and 128-bit.

§manufacturer_data: Vec<ManufacturerData>

Manufacturer Specific Data (more than one is allowed in practice).

§peripheral_connection_interval: Option<(u16, u16)>

Peripheral Connection Interval Range, in 1.25 ms units; 0xFFFF means no bound.

§advertising_interval: Option<u32>

Advertising Interval (or Advertising Interval - long), in 0.625 ms units.

§public_target_addresses: Vec<AddressBytes>

Public Target Addresses.

§random_target_addresses: Vec<AddressBytes>

Random Target Addresses.

§le_address: Option<(String, bool)>

LE Bluetooth Device Address: the address, and whether it is random.

§le_role: Option<u8>

LE Role: 0 peripheral only, 1 central only, 2 both preferring peripheral, 3 both preferring central.

§uri: Option<String>

URI, with its scheme expanded from the assigned numbers.

§le_supported_features: Option<Vec<u8>>

LE Supported Features (bit mask, octet 0 first).

§resolvable_set_identifier: Option<[u8; 6]>

Resolvable Set Identifier (Coordinated Set Identification).

§sm_tk: Option<[u8; 16]>

Security Manager TK Value (legacy OOB pairing).

§sm_oob_flags: Option<u8>

Security Manager Out of Band Flags.

§le_sc_confirmation: Option<[u8; 16]>

LE Secure Connections Confirmation Value (OOB).

§le_sc_random: Option<[u8; 16]>

LE Secure Connections Random Value (OOB).

§ssp_hash: Option<[u8; 16]>

Simple Pairing Hash C-192 or C-256 (BR/EDR OOB), the last one seen.

§ssp_randomizer: Option<[u8; 16]>

Simple Pairing Randomizer R-192 or R-256, the last one seen.

§other: Vec<RawAd>

Every other structure, by type, with its SIG name: Mesh, BIGInfo, Indoor Positioning, Transport Discovery, Encrypted Advertising Data, unassigned types, and any field whose length was wrong for its type.

§malformed: Option<Malformed>

Set when a structure’s length ran past the end of the data; every structure before it was still read.

Implementations§

Source§

impl Advertisement

Source

pub fn parse(data: &[u8]) -> Advertisement

Reads every AD structure in data. Never fails: what cannot be read is kept as bytes or marked Advertisement::malformed.

Source

pub fn extend(&mut self, data: &[u8])

Adds the structures in data (a scan response, say) to this advertisement.

Source

pub fn service_data_for(&self, uuid: impl Into<Uuid>) -> Option<&[u8]>

The service data for a UUID.

Source

pub fn manufacturer_data_for(&self, company_id: u16) -> Option<&[u8]>

The manufacturer data for a company.

Trait Implementations§

Source§

impl Clone for Advertisement

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Advertisement

Source§

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

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

impl Default for Advertisement

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Advertisement

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Advertisement

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Advertisement

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.