pub struct Passcode(/* private fields */);Expand description
27-bit Matter setup passcode (Matter Core Spec §5.1.7).
Constructors enforce the 27-bit range and exclude the disallowed-trivial
values from spec §5.1.7.1. The standard test passcode 20_202_021 is
permitted.
Implementations§
Source§impl Passcode
impl Passcode
Sourcepub fn new(value: u32) -> Result<Self>
pub fn new(value: u32) -> Result<Self>
Construct a setup passcode, enforcing Matter Core Spec §5.1.7.1: the
value SHALL be in 1..=99_999_998 (MAX_PASSCODE) and MUST NOT be one
of the trivial values in DISALLOWED_PASSCODES.
The wire field is 27 bits, but a value above MAX_PASSCODE (up to
2^27 - 1) is not a valid passcode — a setup code carrying one is
rejected by every spec-compliant commissioner, so we reject it here
rather than emit or accept an uncommissionable code.
§Errors
Returns Error::PasscodeDisallowedTrivial if value is one of the
spec-disallowed values in DISALLOWED_PASSCODES (this includes 0).
Returns Error::PasscodeOutOfRange if value > MAX_PASSCODE.