Skip to main content

OnboardingPayload

Struct OnboardingPayload 

Source
pub struct OnboardingPayload {
    pub vendor_id: VendorId,
    pub product_id: u16,
    pub custom_flow: CustomFlow,
    pub discovery: DiscoveryCapabilities,
    pub discriminator: u16,
    pub passcode: Passcode,
}
Expand description

Everything printed on a device’s label (§5.1.1).

Fields§

§vendor_id: VendorId

Who made it.

§product_id: u16

What it is.

§custom_flow: CustomFlow

Whether the user has to do something before commissioning can start.

§discovery: DiscoveryCapabilities

How to find it.

§discriminator: u16

A 12-bit value the device also advertises, so a commissioner can tell two otherwise identical devices apart (§5.1.1.5).

§passcode: Passcode

The shared secret PASE proves possession of.

Implementations§

Source§

impl OnboardingPayload

Source

pub fn new( vendor_id: VendorId, product_id: u16, discriminator: u16, passcode: Passcode, discovery: DiscoveryCapabilities, custom_flow: CustomFlow, ) -> Result<Self>

Builds a payload, checking the discriminator fits 12 bits.

Source

pub const fn short_discriminator(&self) -> u8

The top four bits of the discriminator — all a manual pairing code carries (§5.1.1.5).

Source

pub fn pack(&self) -> [u8; 11]

Packs the structure of Core Table 59 into 11 octets.

“The bits of each fixed-size value are placed in the packed binary data structure in order from least significant to most significant”, and the whole is “padded with ‘0’ bits at the end of the structure to the nearest byte boundary”.

Source

pub fn unpack(bytes: &[u8]) -> Result<Self>

Reads the packed structure back.

Source

pub fn to_qr(&self) -> Result<String<QR_LEN_NO_TLV>>

Renders the QR payload: MT: followed by the base-38 encoding.

Source

pub fn from_qr(text: &str) -> Result<Self>

Parses a QR payload.

Accepts the string with or without its MT: prefix; a camera app that strips it is common enough that refusing would be unhelpful.

Source

pub fn to_manual_code( &self, include_vid_pid: bool, ) -> Result<String<MANUAL_CODE_MAX_DIGITS>>

Renders the manual pairing code (§5.1.4).

include_vid_pid produces the 21-digit form. §5.1.4.1.2 ties this to the commissioning flow: a standard-flow device uses the short form, and a user-intent or custom-flow device “SHALL” use the long one — so this refuses the combination the specification forbids rather than producing a code a commissioner will misread as standard flow.

Source

pub fn from_manual_code(text: &str) -> Result<Self>

Parses a manual pairing code.

“The receiving application SHALL be robust against characters like dashes and spaces that may be included in the string” (§5.1.4.2), so those are stripped before anything else — a user who types 3497-011-2665 has typed a valid code.

The discriminator that comes back has only its top four bits set; the rest are zero, because a manual code does not carry them.

Trait Implementations§

Source§

impl Clone for OnboardingPayload

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 Copy for OnboardingPayload

Source§

impl Debug for OnboardingPayload

Source§

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

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

impl Eq for OnboardingPayload

Source§

impl PartialEq for OnboardingPayload

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 StructuralPartialEq for OnboardingPayload

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.