Skip to main content

fidl_fuchsia_wlan_ieee80211__common/
fidl_fuchsia_wlan_ieee80211__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// Corresponds to the Capability Information field defined by IEEE Std 802.11-2020, 9.4.1.4.
12/// This contains subfields that indicate support for requested or optional capabilities.
13///
14/// TODO(https://fxbug.dev/367315525) Consider making this a bitfield.
15pub type CapabilityInfo = u16;
16
17pub type MacAddr = [u8; 6];
18
19pub type Ssid = Vec<u8>;
20
21pub const CCMP_128_MIC_LEN: u32 = 8;
22
23pub const CCMP_256_MIC_LEN: u32 = 16;
24
25/// IEEE Std 802.11-2016 12.5.3.2
26pub const CCMP_HDR_LEN: u32 = 8;
27
28pub const CCMP_PN_LEN: u32 = 6;
29
30pub const HT_CAP_LEN: u8 = 26;
31
32pub const HT_OP_LEN: u8 = 22;
33
34pub const MAC_ADDR_LEN: u8 = 6;
35
36pub const MAX_KEY_LEN: u8 = 32;
37
38/// IEEE Std 802.11-2016, 9.4.2.99
39pub const MAX_MESH_ID_BYTE_LEN: u8 = 32;
40
41/// IEEE Std 802.11-2016, 9.3.3.2
42pub const MAX_MGMT_FRAME_MAC_HEADER_BYTE_LEN: u8 = 28;
43
44/// IEEE Std 802.11-2016, 9.2.4.7
45pub const MAX_MMPDU_BYTE_LEN: u16 = 2304;
46
47/// IEEE Std 802.11-2016, 9.4.2.2
48/// The maximum length of an SSID is 32 bytes, even when the SSID should be
49/// interpreted using UTF-8 encoding (see Table 9-135). While every length in
50/// the 802.11 standard is byte oriented, the word BYTE is included in the
51/// name of this constant to emphasize the importance that it not be applied
52/// to the length of a UTF-8 encoded string.
53pub const MAX_SSID_BYTE_LEN: u8 = 32;
54
55pub const MAX_SUPPORTED_BASIC_RATES: u8 = 12;
56
57/// The limit on the number of channels in a list of unique channel numbers is 256
58/// since a channel number in IEEE 802.11-2016 cannot exceed one octet. See
59/// IEEE 802.11-2016 9.4.2.18 Supported Channels element for an example element
60/// that assumes a channel number does not exceed one octet.
61pub const MAX_UNIQUE_CHANNEL_NUMBERS: u16 = 256;
62
63pub const MAX_VHT_MPDU_BYTE_LEN_0: u16 = 3895;
64
65pub const MAX_VHT_MPDU_BYTE_LEN_1: u16 = 7991;
66
67pub const MAX_VHT_MPDU_BYTE_LEN_2: u16 = 11454;
68
69pub const OUI_LEN: u8 = 3;
70
71/// The limit on the number of SSIDs is 84 because an SSID List IE can contain no
72/// more than 84 one byte SSIDs. (Specifying a zero byte SSID in an SSID List with
73/// more than one SSID is valid but unnecessary since it is the wildcard SSID.)
74pub const SSID_LIST_MAX: u8 = 84;
75
76/// IEEE Std 802.11-2016, 9.2.4.5
77pub const TIDS_MAX: u32 = 16;
78
79pub const VHT_CAP_LEN: u8 = 12;
80
81pub const VHT_OP_LEN: u8 = 5;
82
83pub const WLAN_IE_BODY_MAX_LEN: u32 = 255;
84
85/// IEEE Std 802.11-2016, 9.4.2.25.1
86/// IEEE mentions that an element body maximum length is 255 octets in the RSN element
87/// section, but not in a dedicated section.
88/// Since the IE header is two octets, the whole IE max length is 257 octets.
89pub const WLAN_IE_MAX_LEN: u32 = 257;
90
91/// IEEE Std 802.11-2016, Table 9-19
92pub const WLAN_MSDU_MAX_LEN: u32 = 2304;
93
94#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
95pub enum BssType {
96    Unknown,
97    Infrastructure,
98    Independent,
99    Mesh,
100    Personal,
101    #[doc(hidden)]
102    __SourceBreaking {
103        unknown_ordinal: u32,
104    },
105}
106
107/// Pattern that matches an unknown `BssType` member.
108#[macro_export]
109macro_rules! BssTypeUnknown {
110    () => {
111        _
112    };
113}
114
115impl BssType {
116    #[inline]
117    pub fn from_primitive(prim: u32) -> Option<Self> {
118        match prim {
119            0 => Some(Self::Unknown),
120            1 => Some(Self::Infrastructure),
121            2 => Some(Self::Independent),
122            3 => Some(Self::Mesh),
123            4 => Some(Self::Personal),
124            _ => None,
125        }
126    }
127
128    #[inline]
129    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
130        match prim {
131            0 => Self::Unknown,
132            1 => Self::Infrastructure,
133            2 => Self::Independent,
134            3 => Self::Mesh,
135            4 => Self::Personal,
136            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
137        }
138    }
139
140    #[inline]
141    pub fn unknown() -> Self {
142        Self::__SourceBreaking { unknown_ordinal: 0x0 }
143    }
144
145    #[inline]
146    pub const fn into_primitive(self) -> u32 {
147        match self {
148            Self::Unknown => 0,
149            Self::Infrastructure => 1,
150            Self::Independent => 2,
151            Self::Mesh => 3,
152            Self::Personal => 4,
153            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
154        }
155    }
156
157    #[inline]
158    pub fn is_unknown(&self) -> bool {
159        match self {
160            Self::__SourceBreaking { unknown_ordinal: _ } => true,
161            _ => false,
162        }
163    }
164}
165
166/// Channel width is derived from the HT operation and VHT operation IEs,
167/// or defaults to 20 MHz if not specified explicitly
168///
169/// IEEE Std 802.11-2016, Table 9-153 - HT/VHT Operation Information subfields
170#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
171pub enum ChannelBandwidth {
172    Cbw20,
173    Cbw40,
174    Cbw40Below,
175    Cbw80,
176    Cbw160,
177    Cbw80P80,
178    #[doc(hidden)]
179    __SourceBreaking {
180        unknown_ordinal: u32,
181    },
182}
183
184/// Pattern that matches an unknown `ChannelBandwidth` member.
185#[macro_export]
186macro_rules! ChannelBandwidthUnknown {
187    () => {
188        _
189    };
190}
191
192impl ChannelBandwidth {
193    #[inline]
194    pub fn from_primitive(prim: u32) -> Option<Self> {
195        match prim {
196            1 => Some(Self::Cbw20),
197            2 => Some(Self::Cbw40),
198            3 => Some(Self::Cbw40Below),
199            4 => Some(Self::Cbw80),
200            5 => Some(Self::Cbw160),
201            6 => Some(Self::Cbw80P80),
202            _ => None,
203        }
204    }
205
206    #[inline]
207    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
208        match prim {
209            1 => Self::Cbw20,
210            2 => Self::Cbw40,
211            3 => Self::Cbw40Below,
212            4 => Self::Cbw80,
213            5 => Self::Cbw160,
214            6 => Self::Cbw80P80,
215            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
216        }
217    }
218
219    #[inline]
220    pub fn unknown() -> Self {
221        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
222    }
223
224    #[inline]
225    pub const fn into_primitive(self) -> u32 {
226        match self {
227            Self::Cbw20 => 1,
228            Self::Cbw40 => 2,
229            Self::Cbw40Below => 3,
230            Self::Cbw80 => 4,
231            Self::Cbw160 => 5,
232            Self::Cbw80P80 => 6,
233            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
234        }
235    }
236
237    #[inline]
238    pub fn is_unknown(&self) -> bool {
239        match self {
240            Self::__SourceBreaking { unknown_ordinal: _ } => true,
241            _ => false,
242        }
243    }
244}
245
246/// IEEE Std 802.11-2016, 9.4.2.25.2
247#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
248pub enum CipherSuiteType {
249    UseGroup,
250    Wep40,
251    Tkip,
252    Reserved3,
253    Ccmp128,
254    Wep104,
255    BipCmac128,
256    GroupAddressedNotAllowed,
257    Gcmp128,
258    Gcmp256,
259    Ccmp256,
260    BipGmac128,
261    BipGmac256,
262    BipCmac256,
263    Reserved14To255,
264    #[doc(hidden)]
265    __SourceBreaking {
266        unknown_ordinal: u32,
267    },
268}
269
270/// Pattern that matches an unknown `CipherSuiteType` member.
271#[macro_export]
272macro_rules! CipherSuiteTypeUnknown {
273    () => {
274        _
275    };
276}
277
278impl CipherSuiteType {
279    #[inline]
280    pub fn from_primitive(prim: u32) -> Option<Self> {
281        match prim {
282            0 => Some(Self::UseGroup),
283            1 => Some(Self::Wep40),
284            2 => Some(Self::Tkip),
285            3 => Some(Self::Reserved3),
286            4 => Some(Self::Ccmp128),
287            5 => Some(Self::Wep104),
288            6 => Some(Self::BipCmac128),
289            7 => Some(Self::GroupAddressedNotAllowed),
290            8 => Some(Self::Gcmp128),
291            9 => Some(Self::Gcmp256),
292            10 => Some(Self::Ccmp256),
293            11 => Some(Self::BipGmac128),
294            12 => Some(Self::BipGmac256),
295            13 => Some(Self::BipCmac256),
296            14 => Some(Self::Reserved14To255),
297            _ => None,
298        }
299    }
300
301    #[inline]
302    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
303        match prim {
304            0 => Self::UseGroup,
305            1 => Self::Wep40,
306            2 => Self::Tkip,
307            3 => Self::Reserved3,
308            4 => Self::Ccmp128,
309            5 => Self::Wep104,
310            6 => Self::BipCmac128,
311            7 => Self::GroupAddressedNotAllowed,
312            8 => Self::Gcmp128,
313            9 => Self::Gcmp256,
314            10 => Self::Ccmp256,
315            11 => Self::BipGmac128,
316            12 => Self::BipGmac256,
317            13 => Self::BipCmac256,
318            14 => Self::Reserved14To255,
319            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
320        }
321    }
322
323    #[inline]
324    pub fn unknown() -> Self {
325        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
326    }
327
328    #[inline]
329    pub const fn into_primitive(self) -> u32 {
330        match self {
331            Self::UseGroup => 0,
332            Self::Wep40 => 1,
333            Self::Tkip => 2,
334            Self::Reserved3 => 3,
335            Self::Ccmp128 => 4,
336            Self::Wep104 => 5,
337            Self::BipCmac128 => 6,
338            Self::GroupAddressedNotAllowed => 7,
339            Self::Gcmp128 => 8,
340            Self::Gcmp256 => 9,
341            Self::Ccmp256 => 10,
342            Self::BipGmac128 => 11,
343            Self::BipGmac256 => 12,
344            Self::BipCmac256 => 13,
345            Self::Reserved14To255 => 14,
346            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
347        }
348    }
349
350    #[inline]
351    pub fn is_unknown(&self) -> bool {
352        match self {
353            Self::__SourceBreaking { unknown_ordinal: _ } => true,
354            _ => false,
355        }
356    }
357}
358
359/// HT and VHT guard interval.
360/// See IEEE 802.11-2016 Table 19-1 and Table 21-1.
361#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
362#[repr(u8)]
363pub enum GuardInterval {
364    LongGi = 1,
365    ShortGi = 2,
366}
367
368impl GuardInterval {
369    #[inline]
370    pub fn from_primitive(prim: u8) -> Option<Self> {
371        match prim {
372            1 => Some(Self::LongGi),
373            2 => Some(Self::ShortGi),
374            _ => None,
375        }
376    }
377
378    #[inline]
379    pub const fn into_primitive(self) -> u8 {
380        self as u8
381    }
382}
383
384#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
385pub enum KeyType {
386    Pairwise,
387    Group,
388    Igtk,
389    Peer,
390    #[doc(hidden)]
391    __SourceBreaking {
392        unknown_ordinal: u8,
393    },
394}
395
396/// Pattern that matches an unknown `KeyType` member.
397#[macro_export]
398macro_rules! KeyTypeUnknown {
399    () => {
400        _
401    };
402}
403
404impl KeyType {
405    #[inline]
406    pub fn from_primitive(prim: u8) -> Option<Self> {
407        match prim {
408            1 => Some(Self::Pairwise),
409            2 => Some(Self::Group),
410            3 => Some(Self::Igtk),
411            4 => Some(Self::Peer),
412            _ => None,
413        }
414    }
415
416    #[inline]
417    pub fn from_primitive_allow_unknown(prim: u8) -> Self {
418        match prim {
419            1 => Self::Pairwise,
420            2 => Self::Group,
421            3 => Self::Igtk,
422            4 => Self::Peer,
423            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
424        }
425    }
426
427    #[inline]
428    pub fn unknown() -> Self {
429        Self::__SourceBreaking { unknown_ordinal: 0xff }
430    }
431
432    #[inline]
433    pub const fn into_primitive(self) -> u8 {
434        match self {
435            Self::Pairwise => 1,
436            Self::Group => 2,
437            Self::Igtk => 3,
438            Self::Peer => 4,
439            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
440        }
441    }
442
443    #[inline]
444    pub fn is_unknown(&self) -> bool {
445        match self {
446            Self::__SourceBreaking { unknown_ordinal: _ } => true,
447            _ => false,
448        }
449    }
450}
451
452/// 802.11 reason codes.  These values are common throughout the standard.
453/// IEEE Std 802.11-2016, 9.4.1.7, Table 9-45
454#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
455pub enum ReasonCode {
456    UnspecifiedReason,
457    InvalidAuthentication,
458    LeavingNetworkDeauth,
459    ReasonInactivity,
460    NoMoreStas,
461    InvalidClass2Frame,
462    InvalidClass3Frame,
463    LeavingNetworkDisassoc,
464    NotAuthenticated,
465    UnacceptablePowerCapability,
466    UnacceptableSupportedChannels,
467    BssTransitionDisassoc,
468    ReasonInvalidElement,
469    MicFailure,
470    /// 15 is named "4WAY_HANDSHAKE_TIMEOUT" in 802.11-2016.
471    FourwayHandshakeTimeout,
472    GkHandshakeTimeout,
473    HandshakeElementMismatch,
474    ReasonInvalidGroupCipher,
475    ReasonInvalidPairwiseCipher,
476    ReasonInvalidAkmp,
477    UnsupportedRsneVersion,
478    InvalidRsneCapabilities,
479    /// 23 is named "802_1_X_AUTH_FAILED" in 802.11-2016.
480    Ieee8021XAuthFailed,
481    ReasonCipherOutOfPolicy,
482    TdlsPeerUnreachable,
483    TdlsUnspecifiedReason,
484    SspRequestedDisassoc,
485    NoSspRoamingAgreement,
486    BadCipherOrAkm,
487    NotAuthorizedThisLocation,
488    ServiceChangePrecludesTs,
489    UnspecifiedQosReason,
490    NotEnoughBandwidth,
491    MissingAcks,
492    ExceededTxop,
493    StaLeaving,
494    /// 37 is assigned to multiple names "END_TS", "END_BA", and "END_DLS" in 802.11-2016.
495    EndTsBaDls,
496    /// 38 is assigned to multiple names "UNKNOWN_TS" and "UNKNOWN_BA" in 802.11-2016.
497    UnknownTsBa,
498    Timeout,
499    PeerkeyMismatch,
500    PeerInitiated,
501    ApInitiated,
502    ReasonInvalidFtActionFrameCount,
503    ReasonInvalidPmkid,
504    ReasonInvalidMde,
505    ReasonInvalidFte,
506    MeshPeeringCanceled,
507    MeshMaxPeers,
508    MeshConfigurationPolicyViolation,
509    MeshCloseRcvd,
510    MeshMaxRetries,
511    MeshConfirmTimeout,
512    MeshInvalidGtk,
513    MeshInconsistentParameters,
514    MeshInvalidSecurityCapability,
515    MeshPathErrorNoProxyInformation,
516    MeshPathErrorNoForwardingInformation,
517    MeshPathErrorDestinationUnreachable,
518    MacAddressAlreadyExistsInMbss,
519    MeshChannelSwitchRegulatoryRequirements,
520    MeshChannelSwitchUnspecified,
521    /// -----
522    /// Values 67 to 127 are reserved by the IEEE protocol, and
523    /// values 128 to 65535 are reserved for platform use.
524    /// -----
525    /// MLME lost the link, usually caused by loss of signal with the AP.
526    MlmeLinkFailed,
527    /// Driver detected a stalled Rx path in FW.
528    FwRxStalled,
529    /// Driver detected high wme rx error rate in FW.
530    FwHighWmeRxErrRate,
531    #[doc(hidden)]
532    __SourceBreaking {
533        unknown_ordinal: u16,
534    },
535}
536
537/// Pattern that matches an unknown `ReasonCode` member.
538#[macro_export]
539macro_rules! ReasonCodeUnknown {
540    () => {
541        _
542    };
543}
544
545impl ReasonCode {
546    #[inline]
547    pub fn from_primitive(prim: u16) -> Option<Self> {
548        match prim {
549            1 => Some(Self::UnspecifiedReason),
550            2 => Some(Self::InvalidAuthentication),
551            3 => Some(Self::LeavingNetworkDeauth),
552            4 => Some(Self::ReasonInactivity),
553            5 => Some(Self::NoMoreStas),
554            6 => Some(Self::InvalidClass2Frame),
555            7 => Some(Self::InvalidClass3Frame),
556            8 => Some(Self::LeavingNetworkDisassoc),
557            9 => Some(Self::NotAuthenticated),
558            10 => Some(Self::UnacceptablePowerCapability),
559            11 => Some(Self::UnacceptableSupportedChannels),
560            12 => Some(Self::BssTransitionDisassoc),
561            13 => Some(Self::ReasonInvalidElement),
562            14 => Some(Self::MicFailure),
563            15 => Some(Self::FourwayHandshakeTimeout),
564            16 => Some(Self::GkHandshakeTimeout),
565            17 => Some(Self::HandshakeElementMismatch),
566            18 => Some(Self::ReasonInvalidGroupCipher),
567            19 => Some(Self::ReasonInvalidPairwiseCipher),
568            20 => Some(Self::ReasonInvalidAkmp),
569            21 => Some(Self::UnsupportedRsneVersion),
570            22 => Some(Self::InvalidRsneCapabilities),
571            23 => Some(Self::Ieee8021XAuthFailed),
572            24 => Some(Self::ReasonCipherOutOfPolicy),
573            25 => Some(Self::TdlsPeerUnreachable),
574            26 => Some(Self::TdlsUnspecifiedReason),
575            27 => Some(Self::SspRequestedDisassoc),
576            28 => Some(Self::NoSspRoamingAgreement),
577            29 => Some(Self::BadCipherOrAkm),
578            30 => Some(Self::NotAuthorizedThisLocation),
579            31 => Some(Self::ServiceChangePrecludesTs),
580            32 => Some(Self::UnspecifiedQosReason),
581            33 => Some(Self::NotEnoughBandwidth),
582            34 => Some(Self::MissingAcks),
583            35 => Some(Self::ExceededTxop),
584            36 => Some(Self::StaLeaving),
585            37 => Some(Self::EndTsBaDls),
586            38 => Some(Self::UnknownTsBa),
587            39 => Some(Self::Timeout),
588            45 => Some(Self::PeerkeyMismatch),
589            46 => Some(Self::PeerInitiated),
590            47 => Some(Self::ApInitiated),
591            48 => Some(Self::ReasonInvalidFtActionFrameCount),
592            49 => Some(Self::ReasonInvalidPmkid),
593            50 => Some(Self::ReasonInvalidMde),
594            51 => Some(Self::ReasonInvalidFte),
595            52 => Some(Self::MeshPeeringCanceled),
596            53 => Some(Self::MeshMaxPeers),
597            54 => Some(Self::MeshConfigurationPolicyViolation),
598            55 => Some(Self::MeshCloseRcvd),
599            56 => Some(Self::MeshMaxRetries),
600            57 => Some(Self::MeshConfirmTimeout),
601            58 => Some(Self::MeshInvalidGtk),
602            59 => Some(Self::MeshInconsistentParameters),
603            60 => Some(Self::MeshInvalidSecurityCapability),
604            61 => Some(Self::MeshPathErrorNoProxyInformation),
605            62 => Some(Self::MeshPathErrorNoForwardingInformation),
606            63 => Some(Self::MeshPathErrorDestinationUnreachable),
607            64 => Some(Self::MacAddressAlreadyExistsInMbss),
608            65 => Some(Self::MeshChannelSwitchRegulatoryRequirements),
609            66 => Some(Self::MeshChannelSwitchUnspecified),
610            128 => Some(Self::MlmeLinkFailed),
611            129 => Some(Self::FwRxStalled),
612            130 => Some(Self::FwHighWmeRxErrRate),
613            _ => None,
614        }
615    }
616
617    #[inline]
618    pub fn from_primitive_allow_unknown(prim: u16) -> Self {
619        match prim {
620            1 => Self::UnspecifiedReason,
621            2 => Self::InvalidAuthentication,
622            3 => Self::LeavingNetworkDeauth,
623            4 => Self::ReasonInactivity,
624            5 => Self::NoMoreStas,
625            6 => Self::InvalidClass2Frame,
626            7 => Self::InvalidClass3Frame,
627            8 => Self::LeavingNetworkDisassoc,
628            9 => Self::NotAuthenticated,
629            10 => Self::UnacceptablePowerCapability,
630            11 => Self::UnacceptableSupportedChannels,
631            12 => Self::BssTransitionDisassoc,
632            13 => Self::ReasonInvalidElement,
633            14 => Self::MicFailure,
634            15 => Self::FourwayHandshakeTimeout,
635            16 => Self::GkHandshakeTimeout,
636            17 => Self::HandshakeElementMismatch,
637            18 => Self::ReasonInvalidGroupCipher,
638            19 => Self::ReasonInvalidPairwiseCipher,
639            20 => Self::ReasonInvalidAkmp,
640            21 => Self::UnsupportedRsneVersion,
641            22 => Self::InvalidRsneCapabilities,
642            23 => Self::Ieee8021XAuthFailed,
643            24 => Self::ReasonCipherOutOfPolicy,
644            25 => Self::TdlsPeerUnreachable,
645            26 => Self::TdlsUnspecifiedReason,
646            27 => Self::SspRequestedDisassoc,
647            28 => Self::NoSspRoamingAgreement,
648            29 => Self::BadCipherOrAkm,
649            30 => Self::NotAuthorizedThisLocation,
650            31 => Self::ServiceChangePrecludesTs,
651            32 => Self::UnspecifiedQosReason,
652            33 => Self::NotEnoughBandwidth,
653            34 => Self::MissingAcks,
654            35 => Self::ExceededTxop,
655            36 => Self::StaLeaving,
656            37 => Self::EndTsBaDls,
657            38 => Self::UnknownTsBa,
658            39 => Self::Timeout,
659            45 => Self::PeerkeyMismatch,
660            46 => Self::PeerInitiated,
661            47 => Self::ApInitiated,
662            48 => Self::ReasonInvalidFtActionFrameCount,
663            49 => Self::ReasonInvalidPmkid,
664            50 => Self::ReasonInvalidMde,
665            51 => Self::ReasonInvalidFte,
666            52 => Self::MeshPeeringCanceled,
667            53 => Self::MeshMaxPeers,
668            54 => Self::MeshConfigurationPolicyViolation,
669            55 => Self::MeshCloseRcvd,
670            56 => Self::MeshMaxRetries,
671            57 => Self::MeshConfirmTimeout,
672            58 => Self::MeshInvalidGtk,
673            59 => Self::MeshInconsistentParameters,
674            60 => Self::MeshInvalidSecurityCapability,
675            61 => Self::MeshPathErrorNoProxyInformation,
676            62 => Self::MeshPathErrorNoForwardingInformation,
677            63 => Self::MeshPathErrorDestinationUnreachable,
678            64 => Self::MacAddressAlreadyExistsInMbss,
679            65 => Self::MeshChannelSwitchRegulatoryRequirements,
680            66 => Self::MeshChannelSwitchUnspecified,
681            128 => Self::MlmeLinkFailed,
682            129 => Self::FwRxStalled,
683            130 => Self::FwHighWmeRxErrRate,
684            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
685        }
686    }
687
688    #[inline]
689    pub fn unknown() -> Self {
690        Self::__SourceBreaking { unknown_ordinal: 0xffff }
691    }
692
693    #[inline]
694    pub const fn into_primitive(self) -> u16 {
695        match self {
696            Self::UnspecifiedReason => 1,
697            Self::InvalidAuthentication => 2,
698            Self::LeavingNetworkDeauth => 3,
699            Self::ReasonInactivity => 4,
700            Self::NoMoreStas => 5,
701            Self::InvalidClass2Frame => 6,
702            Self::InvalidClass3Frame => 7,
703            Self::LeavingNetworkDisassoc => 8,
704            Self::NotAuthenticated => 9,
705            Self::UnacceptablePowerCapability => 10,
706            Self::UnacceptableSupportedChannels => 11,
707            Self::BssTransitionDisassoc => 12,
708            Self::ReasonInvalidElement => 13,
709            Self::MicFailure => 14,
710            Self::FourwayHandshakeTimeout => 15,
711            Self::GkHandshakeTimeout => 16,
712            Self::HandshakeElementMismatch => 17,
713            Self::ReasonInvalidGroupCipher => 18,
714            Self::ReasonInvalidPairwiseCipher => 19,
715            Self::ReasonInvalidAkmp => 20,
716            Self::UnsupportedRsneVersion => 21,
717            Self::InvalidRsneCapabilities => 22,
718            Self::Ieee8021XAuthFailed => 23,
719            Self::ReasonCipherOutOfPolicy => 24,
720            Self::TdlsPeerUnreachable => 25,
721            Self::TdlsUnspecifiedReason => 26,
722            Self::SspRequestedDisassoc => 27,
723            Self::NoSspRoamingAgreement => 28,
724            Self::BadCipherOrAkm => 29,
725            Self::NotAuthorizedThisLocation => 30,
726            Self::ServiceChangePrecludesTs => 31,
727            Self::UnspecifiedQosReason => 32,
728            Self::NotEnoughBandwidth => 33,
729            Self::MissingAcks => 34,
730            Self::ExceededTxop => 35,
731            Self::StaLeaving => 36,
732            Self::EndTsBaDls => 37,
733            Self::UnknownTsBa => 38,
734            Self::Timeout => 39,
735            Self::PeerkeyMismatch => 45,
736            Self::PeerInitiated => 46,
737            Self::ApInitiated => 47,
738            Self::ReasonInvalidFtActionFrameCount => 48,
739            Self::ReasonInvalidPmkid => 49,
740            Self::ReasonInvalidMde => 50,
741            Self::ReasonInvalidFte => 51,
742            Self::MeshPeeringCanceled => 52,
743            Self::MeshMaxPeers => 53,
744            Self::MeshConfigurationPolicyViolation => 54,
745            Self::MeshCloseRcvd => 55,
746            Self::MeshMaxRetries => 56,
747            Self::MeshConfirmTimeout => 57,
748            Self::MeshInvalidGtk => 58,
749            Self::MeshInconsistentParameters => 59,
750            Self::MeshInvalidSecurityCapability => 60,
751            Self::MeshPathErrorNoProxyInformation => 61,
752            Self::MeshPathErrorNoForwardingInformation => 62,
753            Self::MeshPathErrorDestinationUnreachable => 63,
754            Self::MacAddressAlreadyExistsInMbss => 64,
755            Self::MeshChannelSwitchRegulatoryRequirements => 65,
756            Self::MeshChannelSwitchUnspecified => 66,
757            Self::MlmeLinkFailed => 128,
758            Self::FwRxStalled => 129,
759            Self::FwHighWmeRxErrRate => 130,
760            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
761        }
762    }
763
764    #[inline]
765    pub fn is_unknown(&self) -> bool {
766        match self {
767            Self::__SourceBreaking { unknown_ordinal: _ } => true,
768            _ => false,
769        }
770    }
771}
772
773/// 802.11 status codes.  These values are common throughout the standard.
774/// IEEE Std 802.11-2016, 9.4.1.9, Table 9-46
775#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
776pub enum StatusCode {
777    Success,
778    RefusedReasonUnspecified,
779    TdlsRejectedAlternativeProvided,
780    TdlsRejected,
781    /// 4 reserved.
782    SecurityDisabled,
783    UnacceptableLifetime,
784    NotInSameBss,
785    /// 8-9 reserved.
786    RefusedCapabilitiesMismatch,
787    DeniedNoAssociationExists,
788    DeniedOtherReason,
789    UnsupportedAuthAlgorithm,
790    TransactionSequenceError,
791    ChallengeFailure,
792    RejectedSequenceTimeout,
793    DeniedNoMoreStas,
794    RefusedBasicRatesMismatch,
795    DeniedNoShortPreambleSupport,
796    /// 20-21 reserved.
797    RejectedSpectrumManagementRequired,
798    RejectedBadPowerCapability,
799    RejectedBadSupportedChannels,
800    DeniedNoShortSlotTimeSupport,
801    /// 26 reserved.
802    DeniedNoHtSupport,
803    R0KhUnreachable,
804    DeniedPcoTimeNotSupported,
805    RefusedTemporarily,
806    RobustManagementPolicyViolation,
807    UnspecifiedQosFailure,
808    DeniedInsufficientBandwidth,
809    DeniedPoorChannelConditions,
810    DeniedQosNotSupported,
811    /// 36 reserved.
812    RequestDeclined,
813    InvalidParameters,
814    RejectedWithSuggestedChanges,
815    StatusInvalidElement,
816    StatusInvalidGroupCipher,
817    StatusInvalidPairwiseCipher,
818    StatusInvalidAkmp,
819    UnsupportedRsneVersion,
820    InvalidRsneCapabilities,
821    StatusCipherOutOfPolicy,
822    RejectedForDelayPeriod,
823    DlsNotAllowed,
824    NotPresent,
825    NotQosSta,
826    DeniedListenIntervalTooLarge,
827    StatusInvalidFtActionFrameCount,
828    StatusInvalidPmkid,
829    StatusInvalidMde,
830    StatusInvalidFte,
831    /// 56 is assigned to "REQUESTED_TCLAS_NOT_SUPPORTED_BY_AP" in 802.11-2016, duplicate with 80.
832    /// Name below is as listed in the 802.11 Assigned Numbers Authority database.
833    RequestedTclasNotSupportedByAp,
834    InsufficientTclasProcessingResources,
835    TryAnotherBss,
836    GasAdvertisementProtocolNotSupported,
837    NoOutstandingGasRequest,
838    GasResponseNotReceivedFromServer,
839    GasQueryTimeout,
840    GasQueryResponseTooLarge,
841    RejectedHomeWithSuggestedChanges,
842    ServerUnreachable,
843    /// 66 reserved.
844    RejectedForSspPermissions,
845    RefusedUnauthenticatedAccessNotSupported,
846    /// 69-71 reserved.
847    InvalidRsne,
848    UApsdCoexistanceNotSupported,
849    UApsdCoexModeNotSupported,
850    BadIntervalWithUApsdCoex,
851    AntiCloggingTokenRequired,
852    UnsupportedFiniteCyclicGroup,
853    CannotFindAlternativeTbtt,
854    TransmissionFailure,
855    /// See assignment for 56.
856    RequestedTclasNotSupported,
857    TclasResourcesExhausted,
858    RejectedWithSuggestedBssTransition,
859    RejectWithSchedule,
860    RejectNoWakeupSpecified,
861    SuccessPowerSaveMode,
862    PendingAdmittingFstSession,
863    PerformingFstNow,
864    PendingGapInBaWindow,
865    RejectUPidSetting,
866    /// 90-91 reserved.
867    RefusedExternalReason,
868    RefusedApOutOfMemory,
869    RejectedEmergencyServicesNotSupported,
870    QueryResponseOutstanding,
871    RejectDseBand,
872    TclasProcessingTerminated,
873    TsScheduleConflict,
874    DeniedWithSuggestedBandAndChannel,
875    MccaopReservationConflict,
876    MafLimitExceeded,
877    MccaTrackLimitExceeded,
878    DeniedDueToSpectrumManagement,
879    DeniedVhtNotSupported,
880    EnablementDenied,
881    RestrictionFromAuthorizedGdb,
882    AuthorizationDeenabled,
883    EnergyLimitedOperationNotSupported,
884    RejectedNdpBlockAckSuggested,
885    RejectedMaxAwayDurationUnacceptable,
886    FlowControlOperationSupported,
887    FilsAuthenticationFailure,
888    UnknownAuthenticationServer,
889    /// 114-115 reserved.
890    DeniedNotificationPeriodAllocation,
891    DeniedChannelSplitting,
892    DeniedAllocation,
893    CmmgFeaturesNotSupported,
894    GasFragmentNotAvailable,
895    SuccessCagVersionsMatch,
896    GlkNotAuthorized,
897    UnknownPasswordIdentifier,
898    /// 124 reserved.
899    DeniedLocalMacAddressPolicyViolation,
900    SaeHashToElement,
901    /// 127 reserved.
902    TclasProcessingTerminatedInsufficientQos,
903    TclasProcessingTerminatedPolicyConflict,
904    /// Reserved values we will use for our own purposes.
905    /// -----
906    /// Failure when joining the BSS.
907    JoinFailure,
908    /// Authenticate or associate fails due to spurious deauth or diassoc.
909    SpuriousDeauthOrDisassoc,
910    /// Connect attempt is canceled
911    Canceled,
912    /// Failure establishing security association
913    EstablishRsnaFailure,
914    /// Failure initiating OWE handshake or receiving public key from peer
915    OweHandshakeFailure,
916    #[doc(hidden)]
917    __SourceBreaking {
918        unknown_ordinal: u16,
919    },
920}
921
922/// Pattern that matches an unknown `StatusCode` member.
923#[macro_export]
924macro_rules! StatusCodeUnknown {
925    () => {
926        _
927    };
928}
929
930impl StatusCode {
931    #[inline]
932    pub fn from_primitive(prim: u16) -> Option<Self> {
933        match prim {
934            0 => Some(Self::Success),
935            1 => Some(Self::RefusedReasonUnspecified),
936            2 => Some(Self::TdlsRejectedAlternativeProvided),
937            3 => Some(Self::TdlsRejected),
938            5 => Some(Self::SecurityDisabled),
939            6 => Some(Self::UnacceptableLifetime),
940            7 => Some(Self::NotInSameBss),
941            10 => Some(Self::RefusedCapabilitiesMismatch),
942            11 => Some(Self::DeniedNoAssociationExists),
943            12 => Some(Self::DeniedOtherReason),
944            13 => Some(Self::UnsupportedAuthAlgorithm),
945            14 => Some(Self::TransactionSequenceError),
946            15 => Some(Self::ChallengeFailure),
947            16 => Some(Self::RejectedSequenceTimeout),
948            17 => Some(Self::DeniedNoMoreStas),
949            18 => Some(Self::RefusedBasicRatesMismatch),
950            19 => Some(Self::DeniedNoShortPreambleSupport),
951            22 => Some(Self::RejectedSpectrumManagementRequired),
952            23 => Some(Self::RejectedBadPowerCapability),
953            24 => Some(Self::RejectedBadSupportedChannels),
954            25 => Some(Self::DeniedNoShortSlotTimeSupport),
955            27 => Some(Self::DeniedNoHtSupport),
956            28 => Some(Self::R0KhUnreachable),
957            29 => Some(Self::DeniedPcoTimeNotSupported),
958            30 => Some(Self::RefusedTemporarily),
959            31 => Some(Self::RobustManagementPolicyViolation),
960            32 => Some(Self::UnspecifiedQosFailure),
961            33 => Some(Self::DeniedInsufficientBandwidth),
962            34 => Some(Self::DeniedPoorChannelConditions),
963            35 => Some(Self::DeniedQosNotSupported),
964            37 => Some(Self::RequestDeclined),
965            38 => Some(Self::InvalidParameters),
966            39 => Some(Self::RejectedWithSuggestedChanges),
967            40 => Some(Self::StatusInvalidElement),
968            41 => Some(Self::StatusInvalidGroupCipher),
969            42 => Some(Self::StatusInvalidPairwiseCipher),
970            43 => Some(Self::StatusInvalidAkmp),
971            44 => Some(Self::UnsupportedRsneVersion),
972            45 => Some(Self::InvalidRsneCapabilities),
973            46 => Some(Self::StatusCipherOutOfPolicy),
974            47 => Some(Self::RejectedForDelayPeriod),
975            48 => Some(Self::DlsNotAllowed),
976            49 => Some(Self::NotPresent),
977            50 => Some(Self::NotQosSta),
978            51 => Some(Self::DeniedListenIntervalTooLarge),
979            52 => Some(Self::StatusInvalidFtActionFrameCount),
980            53 => Some(Self::StatusInvalidPmkid),
981            54 => Some(Self::StatusInvalidMde),
982            55 => Some(Self::StatusInvalidFte),
983            56 => Some(Self::RequestedTclasNotSupportedByAp),
984            57 => Some(Self::InsufficientTclasProcessingResources),
985            58 => Some(Self::TryAnotherBss),
986            59 => Some(Self::GasAdvertisementProtocolNotSupported),
987            60 => Some(Self::NoOutstandingGasRequest),
988            61 => Some(Self::GasResponseNotReceivedFromServer),
989            62 => Some(Self::GasQueryTimeout),
990            63 => Some(Self::GasQueryResponseTooLarge),
991            64 => Some(Self::RejectedHomeWithSuggestedChanges),
992            65 => Some(Self::ServerUnreachable),
993            67 => Some(Self::RejectedForSspPermissions),
994            68 => Some(Self::RefusedUnauthenticatedAccessNotSupported),
995            72 => Some(Self::InvalidRsne),
996            73 => Some(Self::UApsdCoexistanceNotSupported),
997            74 => Some(Self::UApsdCoexModeNotSupported),
998            75 => Some(Self::BadIntervalWithUApsdCoex),
999            76 => Some(Self::AntiCloggingTokenRequired),
1000            77 => Some(Self::UnsupportedFiniteCyclicGroup),
1001            78 => Some(Self::CannotFindAlternativeTbtt),
1002            79 => Some(Self::TransmissionFailure),
1003            80 => Some(Self::RequestedTclasNotSupported),
1004            81 => Some(Self::TclasResourcesExhausted),
1005            82 => Some(Self::RejectedWithSuggestedBssTransition),
1006            83 => Some(Self::RejectWithSchedule),
1007            84 => Some(Self::RejectNoWakeupSpecified),
1008            85 => Some(Self::SuccessPowerSaveMode),
1009            86 => Some(Self::PendingAdmittingFstSession),
1010            87 => Some(Self::PerformingFstNow),
1011            88 => Some(Self::PendingGapInBaWindow),
1012            89 => Some(Self::RejectUPidSetting),
1013            92 => Some(Self::RefusedExternalReason),
1014            93 => Some(Self::RefusedApOutOfMemory),
1015            94 => Some(Self::RejectedEmergencyServicesNotSupported),
1016            95 => Some(Self::QueryResponseOutstanding),
1017            96 => Some(Self::RejectDseBand),
1018            97 => Some(Self::TclasProcessingTerminated),
1019            98 => Some(Self::TsScheduleConflict),
1020            99 => Some(Self::DeniedWithSuggestedBandAndChannel),
1021            100 => Some(Self::MccaopReservationConflict),
1022            101 => Some(Self::MafLimitExceeded),
1023            102 => Some(Self::MccaTrackLimitExceeded),
1024            103 => Some(Self::DeniedDueToSpectrumManagement),
1025            104 => Some(Self::DeniedVhtNotSupported),
1026            105 => Some(Self::EnablementDenied),
1027            106 => Some(Self::RestrictionFromAuthorizedGdb),
1028            107 => Some(Self::AuthorizationDeenabled),
1029            108 => Some(Self::EnergyLimitedOperationNotSupported),
1030            109 => Some(Self::RejectedNdpBlockAckSuggested),
1031            110 => Some(Self::RejectedMaxAwayDurationUnacceptable),
1032            111 => Some(Self::FlowControlOperationSupported),
1033            112 => Some(Self::FilsAuthenticationFailure),
1034            113 => Some(Self::UnknownAuthenticationServer),
1035            116 => Some(Self::DeniedNotificationPeriodAllocation),
1036            117 => Some(Self::DeniedChannelSplitting),
1037            118 => Some(Self::DeniedAllocation),
1038            119 => Some(Self::CmmgFeaturesNotSupported),
1039            120 => Some(Self::GasFragmentNotAvailable),
1040            121 => Some(Self::SuccessCagVersionsMatch),
1041            122 => Some(Self::GlkNotAuthorized),
1042            123 => Some(Self::UnknownPasswordIdentifier),
1043            125 => Some(Self::DeniedLocalMacAddressPolicyViolation),
1044            126 => Some(Self::SaeHashToElement),
1045            128 => Some(Self::TclasProcessingTerminatedInsufficientQos),
1046            129 => Some(Self::TclasProcessingTerminatedPolicyConflict),
1047            256 => Some(Self::JoinFailure),
1048            257 => Some(Self::SpuriousDeauthOrDisassoc),
1049            258 => Some(Self::Canceled),
1050            259 => Some(Self::EstablishRsnaFailure),
1051            260 => Some(Self::OweHandshakeFailure),
1052            _ => None,
1053        }
1054    }
1055
1056    #[inline]
1057    pub fn from_primitive_allow_unknown(prim: u16) -> Self {
1058        match prim {
1059            0 => Self::Success,
1060            1 => Self::RefusedReasonUnspecified,
1061            2 => Self::TdlsRejectedAlternativeProvided,
1062            3 => Self::TdlsRejected,
1063            5 => Self::SecurityDisabled,
1064            6 => Self::UnacceptableLifetime,
1065            7 => Self::NotInSameBss,
1066            10 => Self::RefusedCapabilitiesMismatch,
1067            11 => Self::DeniedNoAssociationExists,
1068            12 => Self::DeniedOtherReason,
1069            13 => Self::UnsupportedAuthAlgorithm,
1070            14 => Self::TransactionSequenceError,
1071            15 => Self::ChallengeFailure,
1072            16 => Self::RejectedSequenceTimeout,
1073            17 => Self::DeniedNoMoreStas,
1074            18 => Self::RefusedBasicRatesMismatch,
1075            19 => Self::DeniedNoShortPreambleSupport,
1076            22 => Self::RejectedSpectrumManagementRequired,
1077            23 => Self::RejectedBadPowerCapability,
1078            24 => Self::RejectedBadSupportedChannels,
1079            25 => Self::DeniedNoShortSlotTimeSupport,
1080            27 => Self::DeniedNoHtSupport,
1081            28 => Self::R0KhUnreachable,
1082            29 => Self::DeniedPcoTimeNotSupported,
1083            30 => Self::RefusedTemporarily,
1084            31 => Self::RobustManagementPolicyViolation,
1085            32 => Self::UnspecifiedQosFailure,
1086            33 => Self::DeniedInsufficientBandwidth,
1087            34 => Self::DeniedPoorChannelConditions,
1088            35 => Self::DeniedQosNotSupported,
1089            37 => Self::RequestDeclined,
1090            38 => Self::InvalidParameters,
1091            39 => Self::RejectedWithSuggestedChanges,
1092            40 => Self::StatusInvalidElement,
1093            41 => Self::StatusInvalidGroupCipher,
1094            42 => Self::StatusInvalidPairwiseCipher,
1095            43 => Self::StatusInvalidAkmp,
1096            44 => Self::UnsupportedRsneVersion,
1097            45 => Self::InvalidRsneCapabilities,
1098            46 => Self::StatusCipherOutOfPolicy,
1099            47 => Self::RejectedForDelayPeriod,
1100            48 => Self::DlsNotAllowed,
1101            49 => Self::NotPresent,
1102            50 => Self::NotQosSta,
1103            51 => Self::DeniedListenIntervalTooLarge,
1104            52 => Self::StatusInvalidFtActionFrameCount,
1105            53 => Self::StatusInvalidPmkid,
1106            54 => Self::StatusInvalidMde,
1107            55 => Self::StatusInvalidFte,
1108            56 => Self::RequestedTclasNotSupportedByAp,
1109            57 => Self::InsufficientTclasProcessingResources,
1110            58 => Self::TryAnotherBss,
1111            59 => Self::GasAdvertisementProtocolNotSupported,
1112            60 => Self::NoOutstandingGasRequest,
1113            61 => Self::GasResponseNotReceivedFromServer,
1114            62 => Self::GasQueryTimeout,
1115            63 => Self::GasQueryResponseTooLarge,
1116            64 => Self::RejectedHomeWithSuggestedChanges,
1117            65 => Self::ServerUnreachable,
1118            67 => Self::RejectedForSspPermissions,
1119            68 => Self::RefusedUnauthenticatedAccessNotSupported,
1120            72 => Self::InvalidRsne,
1121            73 => Self::UApsdCoexistanceNotSupported,
1122            74 => Self::UApsdCoexModeNotSupported,
1123            75 => Self::BadIntervalWithUApsdCoex,
1124            76 => Self::AntiCloggingTokenRequired,
1125            77 => Self::UnsupportedFiniteCyclicGroup,
1126            78 => Self::CannotFindAlternativeTbtt,
1127            79 => Self::TransmissionFailure,
1128            80 => Self::RequestedTclasNotSupported,
1129            81 => Self::TclasResourcesExhausted,
1130            82 => Self::RejectedWithSuggestedBssTransition,
1131            83 => Self::RejectWithSchedule,
1132            84 => Self::RejectNoWakeupSpecified,
1133            85 => Self::SuccessPowerSaveMode,
1134            86 => Self::PendingAdmittingFstSession,
1135            87 => Self::PerformingFstNow,
1136            88 => Self::PendingGapInBaWindow,
1137            89 => Self::RejectUPidSetting,
1138            92 => Self::RefusedExternalReason,
1139            93 => Self::RefusedApOutOfMemory,
1140            94 => Self::RejectedEmergencyServicesNotSupported,
1141            95 => Self::QueryResponseOutstanding,
1142            96 => Self::RejectDseBand,
1143            97 => Self::TclasProcessingTerminated,
1144            98 => Self::TsScheduleConflict,
1145            99 => Self::DeniedWithSuggestedBandAndChannel,
1146            100 => Self::MccaopReservationConflict,
1147            101 => Self::MafLimitExceeded,
1148            102 => Self::MccaTrackLimitExceeded,
1149            103 => Self::DeniedDueToSpectrumManagement,
1150            104 => Self::DeniedVhtNotSupported,
1151            105 => Self::EnablementDenied,
1152            106 => Self::RestrictionFromAuthorizedGdb,
1153            107 => Self::AuthorizationDeenabled,
1154            108 => Self::EnergyLimitedOperationNotSupported,
1155            109 => Self::RejectedNdpBlockAckSuggested,
1156            110 => Self::RejectedMaxAwayDurationUnacceptable,
1157            111 => Self::FlowControlOperationSupported,
1158            112 => Self::FilsAuthenticationFailure,
1159            113 => Self::UnknownAuthenticationServer,
1160            116 => Self::DeniedNotificationPeriodAllocation,
1161            117 => Self::DeniedChannelSplitting,
1162            118 => Self::DeniedAllocation,
1163            119 => Self::CmmgFeaturesNotSupported,
1164            120 => Self::GasFragmentNotAvailable,
1165            121 => Self::SuccessCagVersionsMatch,
1166            122 => Self::GlkNotAuthorized,
1167            123 => Self::UnknownPasswordIdentifier,
1168            125 => Self::DeniedLocalMacAddressPolicyViolation,
1169            126 => Self::SaeHashToElement,
1170            128 => Self::TclasProcessingTerminatedInsufficientQos,
1171            129 => Self::TclasProcessingTerminatedPolicyConflict,
1172            256 => Self::JoinFailure,
1173            257 => Self::SpuriousDeauthOrDisassoc,
1174            258 => Self::Canceled,
1175            259 => Self::EstablishRsnaFailure,
1176            260 => Self::OweHandshakeFailure,
1177            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
1178        }
1179    }
1180
1181    #[inline]
1182    pub fn unknown() -> Self {
1183        Self::__SourceBreaking { unknown_ordinal: 0xffff }
1184    }
1185
1186    #[inline]
1187    pub const fn into_primitive(self) -> u16 {
1188        match self {
1189            Self::Success => 0,
1190            Self::RefusedReasonUnspecified => 1,
1191            Self::TdlsRejectedAlternativeProvided => 2,
1192            Self::TdlsRejected => 3,
1193            Self::SecurityDisabled => 5,
1194            Self::UnacceptableLifetime => 6,
1195            Self::NotInSameBss => 7,
1196            Self::RefusedCapabilitiesMismatch => 10,
1197            Self::DeniedNoAssociationExists => 11,
1198            Self::DeniedOtherReason => 12,
1199            Self::UnsupportedAuthAlgorithm => 13,
1200            Self::TransactionSequenceError => 14,
1201            Self::ChallengeFailure => 15,
1202            Self::RejectedSequenceTimeout => 16,
1203            Self::DeniedNoMoreStas => 17,
1204            Self::RefusedBasicRatesMismatch => 18,
1205            Self::DeniedNoShortPreambleSupport => 19,
1206            Self::RejectedSpectrumManagementRequired => 22,
1207            Self::RejectedBadPowerCapability => 23,
1208            Self::RejectedBadSupportedChannels => 24,
1209            Self::DeniedNoShortSlotTimeSupport => 25,
1210            Self::DeniedNoHtSupport => 27,
1211            Self::R0KhUnreachable => 28,
1212            Self::DeniedPcoTimeNotSupported => 29,
1213            Self::RefusedTemporarily => 30,
1214            Self::RobustManagementPolicyViolation => 31,
1215            Self::UnspecifiedQosFailure => 32,
1216            Self::DeniedInsufficientBandwidth => 33,
1217            Self::DeniedPoorChannelConditions => 34,
1218            Self::DeniedQosNotSupported => 35,
1219            Self::RequestDeclined => 37,
1220            Self::InvalidParameters => 38,
1221            Self::RejectedWithSuggestedChanges => 39,
1222            Self::StatusInvalidElement => 40,
1223            Self::StatusInvalidGroupCipher => 41,
1224            Self::StatusInvalidPairwiseCipher => 42,
1225            Self::StatusInvalidAkmp => 43,
1226            Self::UnsupportedRsneVersion => 44,
1227            Self::InvalidRsneCapabilities => 45,
1228            Self::StatusCipherOutOfPolicy => 46,
1229            Self::RejectedForDelayPeriod => 47,
1230            Self::DlsNotAllowed => 48,
1231            Self::NotPresent => 49,
1232            Self::NotQosSta => 50,
1233            Self::DeniedListenIntervalTooLarge => 51,
1234            Self::StatusInvalidFtActionFrameCount => 52,
1235            Self::StatusInvalidPmkid => 53,
1236            Self::StatusInvalidMde => 54,
1237            Self::StatusInvalidFte => 55,
1238            Self::RequestedTclasNotSupportedByAp => 56,
1239            Self::InsufficientTclasProcessingResources => 57,
1240            Self::TryAnotherBss => 58,
1241            Self::GasAdvertisementProtocolNotSupported => 59,
1242            Self::NoOutstandingGasRequest => 60,
1243            Self::GasResponseNotReceivedFromServer => 61,
1244            Self::GasQueryTimeout => 62,
1245            Self::GasQueryResponseTooLarge => 63,
1246            Self::RejectedHomeWithSuggestedChanges => 64,
1247            Self::ServerUnreachable => 65,
1248            Self::RejectedForSspPermissions => 67,
1249            Self::RefusedUnauthenticatedAccessNotSupported => 68,
1250            Self::InvalidRsne => 72,
1251            Self::UApsdCoexistanceNotSupported => 73,
1252            Self::UApsdCoexModeNotSupported => 74,
1253            Self::BadIntervalWithUApsdCoex => 75,
1254            Self::AntiCloggingTokenRequired => 76,
1255            Self::UnsupportedFiniteCyclicGroup => 77,
1256            Self::CannotFindAlternativeTbtt => 78,
1257            Self::TransmissionFailure => 79,
1258            Self::RequestedTclasNotSupported => 80,
1259            Self::TclasResourcesExhausted => 81,
1260            Self::RejectedWithSuggestedBssTransition => 82,
1261            Self::RejectWithSchedule => 83,
1262            Self::RejectNoWakeupSpecified => 84,
1263            Self::SuccessPowerSaveMode => 85,
1264            Self::PendingAdmittingFstSession => 86,
1265            Self::PerformingFstNow => 87,
1266            Self::PendingGapInBaWindow => 88,
1267            Self::RejectUPidSetting => 89,
1268            Self::RefusedExternalReason => 92,
1269            Self::RefusedApOutOfMemory => 93,
1270            Self::RejectedEmergencyServicesNotSupported => 94,
1271            Self::QueryResponseOutstanding => 95,
1272            Self::RejectDseBand => 96,
1273            Self::TclasProcessingTerminated => 97,
1274            Self::TsScheduleConflict => 98,
1275            Self::DeniedWithSuggestedBandAndChannel => 99,
1276            Self::MccaopReservationConflict => 100,
1277            Self::MafLimitExceeded => 101,
1278            Self::MccaTrackLimitExceeded => 102,
1279            Self::DeniedDueToSpectrumManagement => 103,
1280            Self::DeniedVhtNotSupported => 104,
1281            Self::EnablementDenied => 105,
1282            Self::RestrictionFromAuthorizedGdb => 106,
1283            Self::AuthorizationDeenabled => 107,
1284            Self::EnergyLimitedOperationNotSupported => 108,
1285            Self::RejectedNdpBlockAckSuggested => 109,
1286            Self::RejectedMaxAwayDurationUnacceptable => 110,
1287            Self::FlowControlOperationSupported => 111,
1288            Self::FilsAuthenticationFailure => 112,
1289            Self::UnknownAuthenticationServer => 113,
1290            Self::DeniedNotificationPeriodAllocation => 116,
1291            Self::DeniedChannelSplitting => 117,
1292            Self::DeniedAllocation => 118,
1293            Self::CmmgFeaturesNotSupported => 119,
1294            Self::GasFragmentNotAvailable => 120,
1295            Self::SuccessCagVersionsMatch => 121,
1296            Self::GlkNotAuthorized => 122,
1297            Self::UnknownPasswordIdentifier => 123,
1298            Self::DeniedLocalMacAddressPolicyViolation => 125,
1299            Self::SaeHashToElement => 126,
1300            Self::TclasProcessingTerminatedInsufficientQos => 128,
1301            Self::TclasProcessingTerminatedPolicyConflict => 129,
1302            Self::JoinFailure => 256,
1303            Self::SpuriousDeauthOrDisassoc => 257,
1304            Self::Canceled => 258,
1305            Self::EstablishRsnaFailure => 259,
1306            Self::OweHandshakeFailure => 260,
1307            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
1308        }
1309    }
1310
1311    #[inline]
1312    pub fn is_unknown(&self) -> bool {
1313        match self {
1314            Self::__SourceBreaking { unknown_ordinal: _ } => true,
1315            _ => false,
1316        }
1317    }
1318}
1319
1320/// IEEE Std 802.11-2020 9.4.2.173
1321#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
1322#[repr(u32)]
1323pub enum WlanAccessCategory {
1324    Background = 1,
1325    BestEffort = 2,
1326    Video = 3,
1327    Voice = 4,
1328}
1329
1330impl WlanAccessCategory {
1331    #[inline]
1332    pub fn from_primitive(prim: u32) -> Option<Self> {
1333        match prim {
1334            1 => Some(Self::Background),
1335            2 => Some(Self::BestEffort),
1336            3 => Some(Self::Video),
1337            4 => Some(Self::Voice),
1338            _ => None,
1339        }
1340    }
1341
1342    #[inline]
1343    pub const fn into_primitive(self) -> u32 {
1344        self as u32
1345    }
1346}
1347
1348/// Identifies a frequency band in metadata of various operations.
1349///
1350/// Examples of this enum in use are labeling scan results or reporting
1351/// a driver capabilities from various frequency bands.
1352///
1353/// NOTE: This enum is similar to the Band ID field defined in
1354/// IEEE Std 802.11-2016 9.4.1.46, but its values are not the same.
1355///
1356/// TODO(https://fxbug.dev/376442944): Create a spec-compliant Band ID type
1357/// and migrate the platform to use it.
1358#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
1359pub enum WlanBand {
1360    TwoGhz,
1361    FiveGhz,
1362    #[doc(hidden)]
1363    __SourceBreaking {
1364        unknown_ordinal: u8,
1365    },
1366}
1367
1368/// Pattern that matches an unknown `WlanBand` member.
1369#[macro_export]
1370macro_rules! WlanBandUnknown {
1371    () => {
1372        _
1373    };
1374}
1375
1376impl WlanBand {
1377    #[inline]
1378    pub fn from_primitive(prim: u8) -> Option<Self> {
1379        match prim {
1380            0 => Some(Self::TwoGhz),
1381            1 => Some(Self::FiveGhz),
1382            _ => None,
1383        }
1384    }
1385
1386    #[inline]
1387    pub fn from_primitive_allow_unknown(prim: u8) -> Self {
1388        match prim {
1389            0 => Self::TwoGhz,
1390            1 => Self::FiveGhz,
1391            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
1392        }
1393    }
1394
1395    #[inline]
1396    pub fn unknown() -> Self {
1397        Self::__SourceBreaking { unknown_ordinal: 0xff }
1398    }
1399
1400    #[inline]
1401    pub const fn into_primitive(self) -> u8 {
1402        match self {
1403            Self::TwoGhz => 0,
1404            Self::FiveGhz => 1,
1405            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
1406        }
1407    }
1408
1409    #[inline]
1410    pub fn is_unknown(&self) -> bool {
1411        match self {
1412            Self::__SourceBreaking { unknown_ordinal: _ } => true,
1413            _ => false,
1414        }
1415    }
1416}
1417
1418#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
1419pub enum WlanPhyType {
1420    /// IEEE 802.11-2016 Clause 15:
1421    ///     Direct Sequence Spread Spectrum
1422    /// Supports 1, 2 Mbps.
1423    Dsss,
1424    /// IEEE 802.11-2016 Clause 16:
1425    ///     High Rate DSSS
1426    /// Supports 5.5, 11 Mbps.
1427    /// Also referred to as ERP-CCK
1428    Hr,
1429    /// IEEE 802.11a/g or IEEE 802.11-2016 Clause 17:
1430    ///     Orthogonal Frequency Division Multiplexing
1431    /// Supports 6, 9, 12, 18, 24, 36, 48, and 54 Mbps.
1432    Ofdm,
1433    /// IEEE 802.11g or IEEE 802.11-2016 Clause 18:
1434    ///     Extended Rate PHY
1435    /// Supports 1, 2, 5.5, 11, 12, 24 Mbps + optionally 6, 54 Mbps.
1436    /// Encompasses DSSS/HR/OFDM rates and modulation.
1437    Erp,
1438    /// IEEE 802.11n or IEEE 802.11-2016 Clause 19:
1439    ///     High Throughput PHY
1440    /// Supports rates up to 495 Mbps.
1441    Ht,
1442    /// 802.11ad or IEEE 802.11-2016 Clause 20:
1443    ///     Directional Multi-Gigabit PHY
1444    Dmg,
1445    /// IEEE 802.11ac or IEEE 802.11-2016 Clause 21:
1446    ///     Very High Throughput PHY
1447    /// Supports rates up to 6.9 Gbps.
1448    Vht,
1449    /// IEEE 802.11af or IEEE 802.11-2016 Clause 22:
1450    ///     Television Very High Throughput PHY
1451    /// Supports rates of up to 568.9 Mbps in TV spectrum
1452    Tvht,
1453    /// IEEE 802.11ah or IEEE 802.11-2020 Clause 23:
1454    ///     Sub 1-GHz PHY
1455    S1G,
1456    /// IEEE 802.11aj or IEEE 802.11-2020 Clause 24:
1457    ///     China Directional Multi-Gigabit PHY
1458    Cdmg,
1459    /// IEEE 802.11aj or IEEE 802.11-2020 Clause 25:
1460    ///     China Millimeter-wave Multi-Gigabit PHY
1461    Cmmg,
1462    /// IEEE 802.11ax: High Efficiency PHY
1463    /// Supports rates of up to 9.6 Gbps (whew!)
1464    He,
1465    #[doc(hidden)]
1466    __SourceBreaking { unknown_ordinal: u32 },
1467}
1468
1469/// Pattern that matches an unknown `WlanPhyType` member.
1470#[macro_export]
1471macro_rules! WlanPhyTypeUnknown {
1472    () => {
1473        _
1474    };
1475}
1476
1477impl WlanPhyType {
1478    #[inline]
1479    pub fn from_primitive(prim: u32) -> Option<Self> {
1480        match prim {
1481            1 => Some(Self::Dsss),
1482            2 => Some(Self::Hr),
1483            3 => Some(Self::Ofdm),
1484            4 => Some(Self::Erp),
1485            5 => Some(Self::Ht),
1486            6 => Some(Self::Dmg),
1487            7 => Some(Self::Vht),
1488            8 => Some(Self::Tvht),
1489            9 => Some(Self::S1G),
1490            10 => Some(Self::Cdmg),
1491            11 => Some(Self::Cmmg),
1492            12 => Some(Self::He),
1493            _ => None,
1494        }
1495    }
1496
1497    #[inline]
1498    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
1499        match prim {
1500            1 => Self::Dsss,
1501            2 => Self::Hr,
1502            3 => Self::Ofdm,
1503            4 => Self::Erp,
1504            5 => Self::Ht,
1505            6 => Self::Dmg,
1506            7 => Self::Vht,
1507            8 => Self::Tvht,
1508            9 => Self::S1G,
1509            10 => Self::Cdmg,
1510            11 => Self::Cmmg,
1511            12 => Self::He,
1512            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
1513        }
1514    }
1515
1516    #[inline]
1517    pub fn unknown() -> Self {
1518        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
1519    }
1520
1521    #[inline]
1522    pub const fn into_primitive(self) -> u32 {
1523        match self {
1524            Self::Dsss => 1,
1525            Self::Hr => 2,
1526            Self::Ofdm => 3,
1527            Self::Erp => 4,
1528            Self::Ht => 5,
1529            Self::Dmg => 6,
1530            Self::Vht => 7,
1531            Self::Tvht => 8,
1532            Self::S1G => 9,
1533            Self::Cdmg => 10,
1534            Self::Cmmg => 11,
1535            Self::He => 12,
1536            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
1537        }
1538    }
1539
1540    #[inline]
1541    pub fn is_unknown(&self) -> bool {
1542        match self {
1543            Self::__SourceBreaking { unknown_ordinal: _ } => true,
1544            _ => false,
1545        }
1546    }
1547}
1548
1549/// Type corresponding to a BSSDescription defined by IEEE Std 802.11-2020 6.3.3.3.2
1550///
1551/// This type only includes explicit fields for information frequently required
1552/// from a BSSDescription. All other fields are left in a raw buffer of IEs as
1553/// received in an advertisement from the AP, e.g., from a Beacon or Probe
1554/// Response frame.
1555///
1556/// The inclusion of a raw buffer of IEs ensures this type always includes all
1557/// the information an AP advertises, no matter the version of Fuchsia the
1558/// advertisement was received in.
1559#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1560pub struct BssDescription {
1561    pub bssid: [u8; 6],
1562    pub bss_type: BssType,
1563    pub beacon_period: u16,
1564    pub capability_info: u16,
1565    /// Buffer of IEs as received in an advertisement. E.g., from a Beacon
1566    /// or Probe Response frame.
1567    pub ies: Vec<u8>,
1568    /// Channel information for this BSS.
1569    pub channel: WlanChannel,
1570    /// The running average of received signal strength indicator in units of dBm.
1571    pub rssi_dbm: i8,
1572    /// The running average of snr in units of dB.
1573    pub snr_db: i8,
1574}
1575
1576impl fidl::Persistable for BssDescription {}
1577
1578#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1579#[repr(C)]
1580pub struct CSsid {
1581    pub len: u8,
1582    pub data: [u8; 32],
1583}
1584
1585impl fidl::Persistable for CSsid {}
1586
1587#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1588#[repr(C)]
1589pub struct HtCapabilities {
1590    pub bytes: [u8; 26],
1591}
1592
1593impl fidl::Persistable for HtCapabilities {}
1594
1595#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1596#[repr(C)]
1597pub struct HtOperation {
1598    pub bytes: [u8; 22],
1599}
1600
1601impl fidl::Persistable for HtOperation {}
1602
1603#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1604#[repr(C)]
1605pub struct VhtCapabilities {
1606    pub bytes: [u8; 12],
1607}
1608
1609impl fidl::Persistable for VhtCapabilities {}
1610
1611#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1612#[repr(C)]
1613pub struct VhtOperation {
1614    pub bytes: [u8; 5],
1615}
1616
1617impl fidl::Persistable for VhtOperation {}
1618
1619/// Channel information derived from the DSSS parameter set, HT operation,
1620/// and VHT operation IEs, as well as the primary channel on which a frame
1621/// is received.
1622///
1623/// IEEE Std 802.11-2016, 9.4.2.4 - DSSS Parameter Set element
1624/// IEEE Std 802.11-2016, 9.4.2.57 - HT Operation element
1625/// IEEE Std 802.11-2016, 9.4.2.159 - VHT Operation element
1626#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1627pub struct WlanChannel {
1628    pub primary: u8,
1629    pub cbw: ChannelBandwidth,
1630    pub secondary80: u8,
1631}
1632
1633impl fidl::Persistable for WlanChannel {}
1634
1635/// IEEE Std 802.11-2020 6.3.19.1.2
1636#[derive(Clone, Debug, Default, PartialEq)]
1637pub struct SetKeyDescriptor {
1638    /// The key value as bytes.
1639    /// 802.11 specifies a bit string for this field, but we represent it as a byte array for
1640    /// convenience.
1641    /// Required.
1642    pub key: Option<Vec<u8>>,
1643    /// Index for rotating keys, e.g. group keys.
1644    /// This value is always 0 for key types which aren't rotating, e.g. pairwise keys.
1645    /// Required.
1646    pub key_id: Option<u16>,
1647    /// Whether this key is a pairwise, group or peer key.
1648    /// Required.
1649    pub key_type: Option<KeyType>,
1650    /// The peer MAC address for pairwise and peer keys.
1651    /// For group keys this value is always the broadcast address.
1652    /// Required.
1653    pub peer_addr: Option<[u8; 6]>,
1654    /// Receive Sequence Counter for group keys only.
1655    /// In all other cases the RSC will be 0.
1656    /// Optional.
1657    pub rsc: Option<u64>,
1658    /// IEEE Cipher suite selector. See IEEE Std 802.11-2016, 9.4.2.25.2, Table 9-131
1659    /// Required.
1660    pub cipher_oui: Option<[u8; 3]>,
1661    /// The cipher type.
1662    /// Required.
1663    pub cipher_type: Option<CipherSuiteType>,
1664    #[doc(hidden)]
1665    pub __source_breaking: fidl::marker::SourceBreaking,
1666}
1667
1668impl fidl::Persistable for SetKeyDescriptor {}
1669
1670mod internal {
1671    use super::*;
1672    unsafe impl fidl::encoding::TypeMarker for BssType {
1673        type Owned = Self;
1674
1675        #[inline(always)]
1676        fn inline_align(_context: fidl::encoding::Context) -> usize {
1677            std::mem::align_of::<u32>()
1678        }
1679
1680        #[inline(always)]
1681        fn inline_size(_context: fidl::encoding::Context) -> usize {
1682            std::mem::size_of::<u32>()
1683        }
1684
1685        #[inline(always)]
1686        fn encode_is_copy() -> bool {
1687            false
1688        }
1689
1690        #[inline(always)]
1691        fn decode_is_copy() -> bool {
1692            false
1693        }
1694    }
1695
1696    impl fidl::encoding::ValueTypeMarker for BssType {
1697        type Borrowed<'a> = Self;
1698        #[inline(always)]
1699        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1700            *value
1701        }
1702    }
1703
1704    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for BssType {
1705        #[inline]
1706        unsafe fn encode(
1707            self,
1708            encoder: &mut fidl::encoding::Encoder<'_, D>,
1709            offset: usize,
1710            _depth: fidl::encoding::Depth,
1711        ) -> fidl::Result<()> {
1712            encoder.debug_check_bounds::<Self>(offset);
1713            encoder.write_num(self.into_primitive(), offset);
1714            Ok(())
1715        }
1716    }
1717
1718    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BssType {
1719        #[inline(always)]
1720        fn new_empty() -> Self {
1721            Self::unknown()
1722        }
1723
1724        #[inline]
1725        unsafe fn decode(
1726            &mut self,
1727            decoder: &mut fidl::encoding::Decoder<'_, D>,
1728            offset: usize,
1729            _depth: fidl::encoding::Depth,
1730        ) -> fidl::Result<()> {
1731            decoder.debug_check_bounds::<Self>(offset);
1732            let prim = decoder.read_num::<u32>(offset);
1733
1734            *self = Self::from_primitive_allow_unknown(prim);
1735            Ok(())
1736        }
1737    }
1738    unsafe impl fidl::encoding::TypeMarker for ChannelBandwidth {
1739        type Owned = Self;
1740
1741        #[inline(always)]
1742        fn inline_align(_context: fidl::encoding::Context) -> usize {
1743            std::mem::align_of::<u32>()
1744        }
1745
1746        #[inline(always)]
1747        fn inline_size(_context: fidl::encoding::Context) -> usize {
1748            std::mem::size_of::<u32>()
1749        }
1750
1751        #[inline(always)]
1752        fn encode_is_copy() -> bool {
1753            false
1754        }
1755
1756        #[inline(always)]
1757        fn decode_is_copy() -> bool {
1758            false
1759        }
1760    }
1761
1762    impl fidl::encoding::ValueTypeMarker for ChannelBandwidth {
1763        type Borrowed<'a> = Self;
1764        #[inline(always)]
1765        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1766            *value
1767        }
1768    }
1769
1770    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1771        for ChannelBandwidth
1772    {
1773        #[inline]
1774        unsafe fn encode(
1775            self,
1776            encoder: &mut fidl::encoding::Encoder<'_, D>,
1777            offset: usize,
1778            _depth: fidl::encoding::Depth,
1779        ) -> fidl::Result<()> {
1780            encoder.debug_check_bounds::<Self>(offset);
1781            encoder.write_num(self.into_primitive(), offset);
1782            Ok(())
1783        }
1784    }
1785
1786    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChannelBandwidth {
1787        #[inline(always)]
1788        fn new_empty() -> Self {
1789            Self::unknown()
1790        }
1791
1792        #[inline]
1793        unsafe fn decode(
1794            &mut self,
1795            decoder: &mut fidl::encoding::Decoder<'_, D>,
1796            offset: usize,
1797            _depth: fidl::encoding::Depth,
1798        ) -> fidl::Result<()> {
1799            decoder.debug_check_bounds::<Self>(offset);
1800            let prim = decoder.read_num::<u32>(offset);
1801
1802            *self = Self::from_primitive_allow_unknown(prim);
1803            Ok(())
1804        }
1805    }
1806    unsafe impl fidl::encoding::TypeMarker for CipherSuiteType {
1807        type Owned = Self;
1808
1809        #[inline(always)]
1810        fn inline_align(_context: fidl::encoding::Context) -> usize {
1811            std::mem::align_of::<u32>()
1812        }
1813
1814        #[inline(always)]
1815        fn inline_size(_context: fidl::encoding::Context) -> usize {
1816            std::mem::size_of::<u32>()
1817        }
1818
1819        #[inline(always)]
1820        fn encode_is_copy() -> bool {
1821            false
1822        }
1823
1824        #[inline(always)]
1825        fn decode_is_copy() -> bool {
1826            false
1827        }
1828    }
1829
1830    impl fidl::encoding::ValueTypeMarker for CipherSuiteType {
1831        type Borrowed<'a> = Self;
1832        #[inline(always)]
1833        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1834            *value
1835        }
1836    }
1837
1838    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1839        for CipherSuiteType
1840    {
1841        #[inline]
1842        unsafe fn encode(
1843            self,
1844            encoder: &mut fidl::encoding::Encoder<'_, D>,
1845            offset: usize,
1846            _depth: fidl::encoding::Depth,
1847        ) -> fidl::Result<()> {
1848            encoder.debug_check_bounds::<Self>(offset);
1849            encoder.write_num(self.into_primitive(), offset);
1850            Ok(())
1851        }
1852    }
1853
1854    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CipherSuiteType {
1855        #[inline(always)]
1856        fn new_empty() -> Self {
1857            Self::unknown()
1858        }
1859
1860        #[inline]
1861        unsafe fn decode(
1862            &mut self,
1863            decoder: &mut fidl::encoding::Decoder<'_, D>,
1864            offset: usize,
1865            _depth: fidl::encoding::Depth,
1866        ) -> fidl::Result<()> {
1867            decoder.debug_check_bounds::<Self>(offset);
1868            let prim = decoder.read_num::<u32>(offset);
1869
1870            *self = Self::from_primitive_allow_unknown(prim);
1871            Ok(())
1872        }
1873    }
1874    unsafe impl fidl::encoding::TypeMarker for GuardInterval {
1875        type Owned = Self;
1876
1877        #[inline(always)]
1878        fn inline_align(_context: fidl::encoding::Context) -> usize {
1879            std::mem::align_of::<u8>()
1880        }
1881
1882        #[inline(always)]
1883        fn inline_size(_context: fidl::encoding::Context) -> usize {
1884            std::mem::size_of::<u8>()
1885        }
1886
1887        #[inline(always)]
1888        fn encode_is_copy() -> bool {
1889            true
1890        }
1891
1892        #[inline(always)]
1893        fn decode_is_copy() -> bool {
1894            false
1895        }
1896    }
1897
1898    impl fidl::encoding::ValueTypeMarker for GuardInterval {
1899        type Borrowed<'a> = Self;
1900        #[inline(always)]
1901        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1902            *value
1903        }
1904    }
1905
1906    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for GuardInterval {
1907        #[inline]
1908        unsafe fn encode(
1909            self,
1910            encoder: &mut fidl::encoding::Encoder<'_, D>,
1911            offset: usize,
1912            _depth: fidl::encoding::Depth,
1913        ) -> fidl::Result<()> {
1914            encoder.debug_check_bounds::<Self>(offset);
1915            encoder.write_num(self.into_primitive(), offset);
1916            Ok(())
1917        }
1918    }
1919
1920    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GuardInterval {
1921        #[inline(always)]
1922        fn new_empty() -> Self {
1923            Self::LongGi
1924        }
1925
1926        #[inline]
1927        unsafe fn decode(
1928            &mut self,
1929            decoder: &mut fidl::encoding::Decoder<'_, D>,
1930            offset: usize,
1931            _depth: fidl::encoding::Depth,
1932        ) -> fidl::Result<()> {
1933            decoder.debug_check_bounds::<Self>(offset);
1934            let prim = decoder.read_num::<u8>(offset);
1935
1936            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1937            Ok(())
1938        }
1939    }
1940    unsafe impl fidl::encoding::TypeMarker for KeyType {
1941        type Owned = Self;
1942
1943        #[inline(always)]
1944        fn inline_align(_context: fidl::encoding::Context) -> usize {
1945            std::mem::align_of::<u8>()
1946        }
1947
1948        #[inline(always)]
1949        fn inline_size(_context: fidl::encoding::Context) -> usize {
1950            std::mem::size_of::<u8>()
1951        }
1952
1953        #[inline(always)]
1954        fn encode_is_copy() -> bool {
1955            false
1956        }
1957
1958        #[inline(always)]
1959        fn decode_is_copy() -> bool {
1960            false
1961        }
1962    }
1963
1964    impl fidl::encoding::ValueTypeMarker for KeyType {
1965        type Borrowed<'a> = Self;
1966        #[inline(always)]
1967        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1968            *value
1969        }
1970    }
1971
1972    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for KeyType {
1973        #[inline]
1974        unsafe fn encode(
1975            self,
1976            encoder: &mut fidl::encoding::Encoder<'_, D>,
1977            offset: usize,
1978            _depth: fidl::encoding::Depth,
1979        ) -> fidl::Result<()> {
1980            encoder.debug_check_bounds::<Self>(offset);
1981            encoder.write_num(self.into_primitive(), offset);
1982            Ok(())
1983        }
1984    }
1985
1986    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyType {
1987        #[inline(always)]
1988        fn new_empty() -> Self {
1989            Self::unknown()
1990        }
1991
1992        #[inline]
1993        unsafe fn decode(
1994            &mut self,
1995            decoder: &mut fidl::encoding::Decoder<'_, D>,
1996            offset: usize,
1997            _depth: fidl::encoding::Depth,
1998        ) -> fidl::Result<()> {
1999            decoder.debug_check_bounds::<Self>(offset);
2000            let prim = decoder.read_num::<u8>(offset);
2001
2002            *self = Self::from_primitive_allow_unknown(prim);
2003            Ok(())
2004        }
2005    }
2006    unsafe impl fidl::encoding::TypeMarker for ReasonCode {
2007        type Owned = Self;
2008
2009        #[inline(always)]
2010        fn inline_align(_context: fidl::encoding::Context) -> usize {
2011            std::mem::align_of::<u16>()
2012        }
2013
2014        #[inline(always)]
2015        fn inline_size(_context: fidl::encoding::Context) -> usize {
2016            std::mem::size_of::<u16>()
2017        }
2018
2019        #[inline(always)]
2020        fn encode_is_copy() -> bool {
2021            false
2022        }
2023
2024        #[inline(always)]
2025        fn decode_is_copy() -> bool {
2026            false
2027        }
2028    }
2029
2030    impl fidl::encoding::ValueTypeMarker for ReasonCode {
2031        type Borrowed<'a> = Self;
2032        #[inline(always)]
2033        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2034            *value
2035        }
2036    }
2037
2038    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ReasonCode {
2039        #[inline]
2040        unsafe fn encode(
2041            self,
2042            encoder: &mut fidl::encoding::Encoder<'_, D>,
2043            offset: usize,
2044            _depth: fidl::encoding::Depth,
2045        ) -> fidl::Result<()> {
2046            encoder.debug_check_bounds::<Self>(offset);
2047            encoder.write_num(self.into_primitive(), offset);
2048            Ok(())
2049        }
2050    }
2051
2052    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReasonCode {
2053        #[inline(always)]
2054        fn new_empty() -> Self {
2055            Self::unknown()
2056        }
2057
2058        #[inline]
2059        unsafe fn decode(
2060            &mut self,
2061            decoder: &mut fidl::encoding::Decoder<'_, D>,
2062            offset: usize,
2063            _depth: fidl::encoding::Depth,
2064        ) -> fidl::Result<()> {
2065            decoder.debug_check_bounds::<Self>(offset);
2066            let prim = decoder.read_num::<u16>(offset);
2067
2068            *self = Self::from_primitive_allow_unknown(prim);
2069            Ok(())
2070        }
2071    }
2072    unsafe impl fidl::encoding::TypeMarker for StatusCode {
2073        type Owned = Self;
2074
2075        #[inline(always)]
2076        fn inline_align(_context: fidl::encoding::Context) -> usize {
2077            std::mem::align_of::<u16>()
2078        }
2079
2080        #[inline(always)]
2081        fn inline_size(_context: fidl::encoding::Context) -> usize {
2082            std::mem::size_of::<u16>()
2083        }
2084
2085        #[inline(always)]
2086        fn encode_is_copy() -> bool {
2087            false
2088        }
2089
2090        #[inline(always)]
2091        fn decode_is_copy() -> bool {
2092            false
2093        }
2094    }
2095
2096    impl fidl::encoding::ValueTypeMarker for StatusCode {
2097        type Borrowed<'a> = Self;
2098        #[inline(always)]
2099        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2100            *value
2101        }
2102    }
2103
2104    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for StatusCode {
2105        #[inline]
2106        unsafe fn encode(
2107            self,
2108            encoder: &mut fidl::encoding::Encoder<'_, D>,
2109            offset: usize,
2110            _depth: fidl::encoding::Depth,
2111        ) -> fidl::Result<()> {
2112            encoder.debug_check_bounds::<Self>(offset);
2113            encoder.write_num(self.into_primitive(), offset);
2114            Ok(())
2115        }
2116    }
2117
2118    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StatusCode {
2119        #[inline(always)]
2120        fn new_empty() -> Self {
2121            Self::unknown()
2122        }
2123
2124        #[inline]
2125        unsafe fn decode(
2126            &mut self,
2127            decoder: &mut fidl::encoding::Decoder<'_, D>,
2128            offset: usize,
2129            _depth: fidl::encoding::Depth,
2130        ) -> fidl::Result<()> {
2131            decoder.debug_check_bounds::<Self>(offset);
2132            let prim = decoder.read_num::<u16>(offset);
2133
2134            *self = Self::from_primitive_allow_unknown(prim);
2135            Ok(())
2136        }
2137    }
2138    unsafe impl fidl::encoding::TypeMarker for WlanAccessCategory {
2139        type Owned = Self;
2140
2141        #[inline(always)]
2142        fn inline_align(_context: fidl::encoding::Context) -> usize {
2143            std::mem::align_of::<u32>()
2144        }
2145
2146        #[inline(always)]
2147        fn inline_size(_context: fidl::encoding::Context) -> usize {
2148            std::mem::size_of::<u32>()
2149        }
2150
2151        #[inline(always)]
2152        fn encode_is_copy() -> bool {
2153            true
2154        }
2155
2156        #[inline(always)]
2157        fn decode_is_copy() -> bool {
2158            false
2159        }
2160    }
2161
2162    impl fidl::encoding::ValueTypeMarker for WlanAccessCategory {
2163        type Borrowed<'a> = Self;
2164        #[inline(always)]
2165        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2166            *value
2167        }
2168    }
2169
2170    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
2171        for WlanAccessCategory
2172    {
2173        #[inline]
2174        unsafe fn encode(
2175            self,
2176            encoder: &mut fidl::encoding::Encoder<'_, D>,
2177            offset: usize,
2178            _depth: fidl::encoding::Depth,
2179        ) -> fidl::Result<()> {
2180            encoder.debug_check_bounds::<Self>(offset);
2181            encoder.write_num(self.into_primitive(), offset);
2182            Ok(())
2183        }
2184    }
2185
2186    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WlanAccessCategory {
2187        #[inline(always)]
2188        fn new_empty() -> Self {
2189            Self::Background
2190        }
2191
2192        #[inline]
2193        unsafe fn decode(
2194            &mut self,
2195            decoder: &mut fidl::encoding::Decoder<'_, D>,
2196            offset: usize,
2197            _depth: fidl::encoding::Depth,
2198        ) -> fidl::Result<()> {
2199            decoder.debug_check_bounds::<Self>(offset);
2200            let prim = decoder.read_num::<u32>(offset);
2201
2202            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
2203            Ok(())
2204        }
2205    }
2206    unsafe impl fidl::encoding::TypeMarker for WlanBand {
2207        type Owned = Self;
2208
2209        #[inline(always)]
2210        fn inline_align(_context: fidl::encoding::Context) -> usize {
2211            std::mem::align_of::<u8>()
2212        }
2213
2214        #[inline(always)]
2215        fn inline_size(_context: fidl::encoding::Context) -> usize {
2216            std::mem::size_of::<u8>()
2217        }
2218
2219        #[inline(always)]
2220        fn encode_is_copy() -> bool {
2221            false
2222        }
2223
2224        #[inline(always)]
2225        fn decode_is_copy() -> bool {
2226            false
2227        }
2228    }
2229
2230    impl fidl::encoding::ValueTypeMarker for WlanBand {
2231        type Borrowed<'a> = Self;
2232        #[inline(always)]
2233        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2234            *value
2235        }
2236    }
2237
2238    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for WlanBand {
2239        #[inline]
2240        unsafe fn encode(
2241            self,
2242            encoder: &mut fidl::encoding::Encoder<'_, D>,
2243            offset: usize,
2244            _depth: fidl::encoding::Depth,
2245        ) -> fidl::Result<()> {
2246            encoder.debug_check_bounds::<Self>(offset);
2247            encoder.write_num(self.into_primitive(), offset);
2248            Ok(())
2249        }
2250    }
2251
2252    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WlanBand {
2253        #[inline(always)]
2254        fn new_empty() -> Self {
2255            Self::unknown()
2256        }
2257
2258        #[inline]
2259        unsafe fn decode(
2260            &mut self,
2261            decoder: &mut fidl::encoding::Decoder<'_, D>,
2262            offset: usize,
2263            _depth: fidl::encoding::Depth,
2264        ) -> fidl::Result<()> {
2265            decoder.debug_check_bounds::<Self>(offset);
2266            let prim = decoder.read_num::<u8>(offset);
2267
2268            *self = Self::from_primitive_allow_unknown(prim);
2269            Ok(())
2270        }
2271    }
2272    unsafe impl fidl::encoding::TypeMarker for WlanPhyType {
2273        type Owned = Self;
2274
2275        #[inline(always)]
2276        fn inline_align(_context: fidl::encoding::Context) -> usize {
2277            std::mem::align_of::<u32>()
2278        }
2279
2280        #[inline(always)]
2281        fn inline_size(_context: fidl::encoding::Context) -> usize {
2282            std::mem::size_of::<u32>()
2283        }
2284
2285        #[inline(always)]
2286        fn encode_is_copy() -> bool {
2287            false
2288        }
2289
2290        #[inline(always)]
2291        fn decode_is_copy() -> bool {
2292            false
2293        }
2294    }
2295
2296    impl fidl::encoding::ValueTypeMarker for WlanPhyType {
2297        type Borrowed<'a> = Self;
2298        #[inline(always)]
2299        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2300            *value
2301        }
2302    }
2303
2304    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for WlanPhyType {
2305        #[inline]
2306        unsafe fn encode(
2307            self,
2308            encoder: &mut fidl::encoding::Encoder<'_, D>,
2309            offset: usize,
2310            _depth: fidl::encoding::Depth,
2311        ) -> fidl::Result<()> {
2312            encoder.debug_check_bounds::<Self>(offset);
2313            encoder.write_num(self.into_primitive(), offset);
2314            Ok(())
2315        }
2316    }
2317
2318    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WlanPhyType {
2319        #[inline(always)]
2320        fn new_empty() -> Self {
2321            Self::unknown()
2322        }
2323
2324        #[inline]
2325        unsafe fn decode(
2326            &mut self,
2327            decoder: &mut fidl::encoding::Decoder<'_, D>,
2328            offset: usize,
2329            _depth: fidl::encoding::Depth,
2330        ) -> fidl::Result<()> {
2331            decoder.debug_check_bounds::<Self>(offset);
2332            let prim = decoder.read_num::<u32>(offset);
2333
2334            *self = Self::from_primitive_allow_unknown(prim);
2335            Ok(())
2336        }
2337    }
2338
2339    impl fidl::encoding::ValueTypeMarker for BssDescription {
2340        type Borrowed<'a> = &'a Self;
2341        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2342            value
2343        }
2344    }
2345
2346    unsafe impl fidl::encoding::TypeMarker for BssDescription {
2347        type Owned = Self;
2348
2349        #[inline(always)]
2350        fn inline_align(_context: fidl::encoding::Context) -> usize {
2351            8
2352        }
2353
2354        #[inline(always)]
2355        fn inline_size(_context: fidl::encoding::Context) -> usize {
2356            48
2357        }
2358    }
2359
2360    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BssDescription, D>
2361        for &BssDescription
2362    {
2363        #[inline]
2364        unsafe fn encode(
2365            self,
2366            encoder: &mut fidl::encoding::Encoder<'_, D>,
2367            offset: usize,
2368            _depth: fidl::encoding::Depth,
2369        ) -> fidl::Result<()> {
2370            encoder.debug_check_bounds::<BssDescription>(offset);
2371            // Delegate to tuple encoding.
2372            fidl::encoding::Encode::<BssDescription, D>::encode(
2373                (
2374                    <fidl::encoding::Array<u8, 6> as fidl::encoding::ValueTypeMarker>::borrow(&self.bssid),
2375                    <BssType as fidl::encoding::ValueTypeMarker>::borrow(&self.bss_type),
2376                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.beacon_period),
2377                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.capability_info),
2378                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.ies),
2379                    <WlanChannel as fidl::encoding::ValueTypeMarker>::borrow(&self.channel),
2380                    <i8 as fidl::encoding::ValueTypeMarker>::borrow(&self.rssi_dbm),
2381                    <i8 as fidl::encoding::ValueTypeMarker>::borrow(&self.snr_db),
2382                ),
2383                encoder, offset, _depth
2384            )
2385        }
2386    }
2387    unsafe impl<
2388        D: fidl::encoding::ResourceDialect,
2389        T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 6>, D>,
2390        T1: fidl::encoding::Encode<BssType, D>,
2391        T2: fidl::encoding::Encode<u16, D>,
2392        T3: fidl::encoding::Encode<u16, D>,
2393        T4: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
2394        T5: fidl::encoding::Encode<WlanChannel, D>,
2395        T6: fidl::encoding::Encode<i8, D>,
2396        T7: fidl::encoding::Encode<i8, D>,
2397    > fidl::encoding::Encode<BssDescription, D> for (T0, T1, T2, T3, T4, T5, T6, T7)
2398    {
2399        #[inline]
2400        unsafe fn encode(
2401            self,
2402            encoder: &mut fidl::encoding::Encoder<'_, D>,
2403            offset: usize,
2404            depth: fidl::encoding::Depth,
2405        ) -> fidl::Result<()> {
2406            encoder.debug_check_bounds::<BssDescription>(offset);
2407            // Zero out padding regions. There's no need to apply masks
2408            // because the unmasked parts will be overwritten by fields.
2409            unsafe {
2410                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2411                (ptr as *mut u64).write_unaligned(0);
2412            }
2413            unsafe {
2414                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
2415                (ptr as *mut u64).write_unaligned(0);
2416            }
2417            // Write the fields.
2418            self.0.encode(encoder, offset + 0, depth)?;
2419            self.1.encode(encoder, offset + 8, depth)?;
2420            self.2.encode(encoder, offset + 12, depth)?;
2421            self.3.encode(encoder, offset + 14, depth)?;
2422            self.4.encode(encoder, offset + 16, depth)?;
2423            self.5.encode(encoder, offset + 32, depth)?;
2424            self.6.encode(encoder, offset + 44, depth)?;
2425            self.7.encode(encoder, offset + 45, depth)?;
2426            Ok(())
2427        }
2428    }
2429
2430    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BssDescription {
2431        #[inline(always)]
2432        fn new_empty() -> Self {
2433            Self {
2434                bssid: fidl::new_empty!(fidl::encoding::Array<u8, 6>, D),
2435                bss_type: fidl::new_empty!(BssType, D),
2436                beacon_period: fidl::new_empty!(u16, D),
2437                capability_info: fidl::new_empty!(u16, D),
2438                ies: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
2439                channel: fidl::new_empty!(WlanChannel, D),
2440                rssi_dbm: fidl::new_empty!(i8, D),
2441                snr_db: fidl::new_empty!(i8, D),
2442            }
2443        }
2444
2445        #[inline]
2446        unsafe fn decode(
2447            &mut self,
2448            decoder: &mut fidl::encoding::Decoder<'_, D>,
2449            offset: usize,
2450            _depth: fidl::encoding::Depth,
2451        ) -> fidl::Result<()> {
2452            decoder.debug_check_bounds::<Self>(offset);
2453            // Verify that padding bytes are zero.
2454            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2455            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2456            let mask = 0xffff000000000000u64;
2457            let maskedval = padval & mask;
2458            if maskedval != 0 {
2459                return Err(fidl::Error::NonZeroPadding {
2460                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2461                });
2462            }
2463            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
2464            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2465            let mask = 0xffff000000000000u64;
2466            let maskedval = padval & mask;
2467            if maskedval != 0 {
2468                return Err(fidl::Error::NonZeroPadding {
2469                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
2470                });
2471            }
2472            fidl::decode!(fidl::encoding::Array<u8, 6>, D, &mut self.bssid, decoder, offset + 0, _depth)?;
2473            fidl::decode!(BssType, D, &mut self.bss_type, decoder, offset + 8, _depth)?;
2474            fidl::decode!(u16, D, &mut self.beacon_period, decoder, offset + 12, _depth)?;
2475            fidl::decode!(u16, D, &mut self.capability_info, decoder, offset + 14, _depth)?;
2476            fidl::decode!(
2477                fidl::encoding::UnboundedVector<u8>,
2478                D,
2479                &mut self.ies,
2480                decoder,
2481                offset + 16,
2482                _depth
2483            )?;
2484            fidl::decode!(WlanChannel, D, &mut self.channel, decoder, offset + 32, _depth)?;
2485            fidl::decode!(i8, D, &mut self.rssi_dbm, decoder, offset + 44, _depth)?;
2486            fidl::decode!(i8, D, &mut self.snr_db, decoder, offset + 45, _depth)?;
2487            Ok(())
2488        }
2489    }
2490
2491    impl fidl::encoding::ValueTypeMarker for CSsid {
2492        type Borrowed<'a> = &'a Self;
2493        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2494            value
2495        }
2496    }
2497
2498    unsafe impl fidl::encoding::TypeMarker for CSsid {
2499        type Owned = Self;
2500
2501        #[inline(always)]
2502        fn inline_align(_context: fidl::encoding::Context) -> usize {
2503            1
2504        }
2505
2506        #[inline(always)]
2507        fn inline_size(_context: fidl::encoding::Context) -> usize {
2508            33
2509        }
2510        #[inline(always)]
2511        fn encode_is_copy() -> bool {
2512            true
2513        }
2514
2515        #[inline(always)]
2516        fn decode_is_copy() -> bool {
2517            true
2518        }
2519    }
2520
2521    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CSsid, D> for &CSsid {
2522        #[inline]
2523        unsafe fn encode(
2524            self,
2525            encoder: &mut fidl::encoding::Encoder<'_, D>,
2526            offset: usize,
2527            _depth: fidl::encoding::Depth,
2528        ) -> fidl::Result<()> {
2529            encoder.debug_check_bounds::<CSsid>(offset);
2530            unsafe {
2531                // Copy the object into the buffer.
2532                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2533                (buf_ptr as *mut CSsid).write_unaligned((self as *const CSsid).read());
2534                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2535                // done second because the memcpy will write garbage to these bytes.
2536            }
2537            Ok(())
2538        }
2539    }
2540    unsafe impl<
2541        D: fidl::encoding::ResourceDialect,
2542        T0: fidl::encoding::Encode<u8, D>,
2543        T1: fidl::encoding::Encode<fidl::encoding::Array<u8, 32>, D>,
2544    > fidl::encoding::Encode<CSsid, D> for (T0, T1)
2545    {
2546        #[inline]
2547        unsafe fn encode(
2548            self,
2549            encoder: &mut fidl::encoding::Encoder<'_, D>,
2550            offset: usize,
2551            depth: fidl::encoding::Depth,
2552        ) -> fidl::Result<()> {
2553            encoder.debug_check_bounds::<CSsid>(offset);
2554            // Zero out padding regions. There's no need to apply masks
2555            // because the unmasked parts will be overwritten by fields.
2556            // Write the fields.
2557            self.0.encode(encoder, offset + 0, depth)?;
2558            self.1.encode(encoder, offset + 1, depth)?;
2559            Ok(())
2560        }
2561    }
2562
2563    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CSsid {
2564        #[inline(always)]
2565        fn new_empty() -> Self {
2566            Self {
2567                len: fidl::new_empty!(u8, D),
2568                data: fidl::new_empty!(fidl::encoding::Array<u8, 32>, D),
2569            }
2570        }
2571
2572        #[inline]
2573        unsafe fn decode(
2574            &mut self,
2575            decoder: &mut fidl::encoding::Decoder<'_, D>,
2576            offset: usize,
2577            _depth: fidl::encoding::Depth,
2578        ) -> fidl::Result<()> {
2579            decoder.debug_check_bounds::<Self>(offset);
2580            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2581            // Verify that padding bytes are zero.
2582            // Copy from the buffer into the object.
2583            unsafe {
2584                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 33);
2585            }
2586            Ok(())
2587        }
2588    }
2589
2590    impl fidl::encoding::ValueTypeMarker for HtCapabilities {
2591        type Borrowed<'a> = &'a Self;
2592        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2593            value
2594        }
2595    }
2596
2597    unsafe impl fidl::encoding::TypeMarker for HtCapabilities {
2598        type Owned = Self;
2599
2600        #[inline(always)]
2601        fn inline_align(_context: fidl::encoding::Context) -> usize {
2602            1
2603        }
2604
2605        #[inline(always)]
2606        fn inline_size(_context: fidl::encoding::Context) -> usize {
2607            26
2608        }
2609        #[inline(always)]
2610        fn encode_is_copy() -> bool {
2611            true
2612        }
2613
2614        #[inline(always)]
2615        fn decode_is_copy() -> bool {
2616            true
2617        }
2618    }
2619
2620    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<HtCapabilities, D>
2621        for &HtCapabilities
2622    {
2623        #[inline]
2624        unsafe fn encode(
2625            self,
2626            encoder: &mut fidl::encoding::Encoder<'_, D>,
2627            offset: usize,
2628            _depth: fidl::encoding::Depth,
2629        ) -> fidl::Result<()> {
2630            encoder.debug_check_bounds::<HtCapabilities>(offset);
2631            unsafe {
2632                // Copy the object into the buffer.
2633                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2634                (buf_ptr as *mut HtCapabilities)
2635                    .write_unaligned((self as *const HtCapabilities).read());
2636                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2637                // done second because the memcpy will write garbage to these bytes.
2638            }
2639            Ok(())
2640        }
2641    }
2642    unsafe impl<
2643        D: fidl::encoding::ResourceDialect,
2644        T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 26>, D>,
2645    > fidl::encoding::Encode<HtCapabilities, D> for (T0,)
2646    {
2647        #[inline]
2648        unsafe fn encode(
2649            self,
2650            encoder: &mut fidl::encoding::Encoder<'_, D>,
2651            offset: usize,
2652            depth: fidl::encoding::Depth,
2653        ) -> fidl::Result<()> {
2654            encoder.debug_check_bounds::<HtCapabilities>(offset);
2655            // Zero out padding regions. There's no need to apply masks
2656            // because the unmasked parts will be overwritten by fields.
2657            // Write the fields.
2658            self.0.encode(encoder, offset + 0, depth)?;
2659            Ok(())
2660        }
2661    }
2662
2663    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HtCapabilities {
2664        #[inline(always)]
2665        fn new_empty() -> Self {
2666            Self { bytes: fidl::new_empty!(fidl::encoding::Array<u8, 26>, D) }
2667        }
2668
2669        #[inline]
2670        unsafe fn decode(
2671            &mut self,
2672            decoder: &mut fidl::encoding::Decoder<'_, D>,
2673            offset: usize,
2674            _depth: fidl::encoding::Depth,
2675        ) -> fidl::Result<()> {
2676            decoder.debug_check_bounds::<Self>(offset);
2677            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2678            // Verify that padding bytes are zero.
2679            // Copy from the buffer into the object.
2680            unsafe {
2681                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 26);
2682            }
2683            Ok(())
2684        }
2685    }
2686
2687    impl fidl::encoding::ValueTypeMarker for HtOperation {
2688        type Borrowed<'a> = &'a Self;
2689        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2690            value
2691        }
2692    }
2693
2694    unsafe impl fidl::encoding::TypeMarker for HtOperation {
2695        type Owned = Self;
2696
2697        #[inline(always)]
2698        fn inline_align(_context: fidl::encoding::Context) -> usize {
2699            1
2700        }
2701
2702        #[inline(always)]
2703        fn inline_size(_context: fidl::encoding::Context) -> usize {
2704            22
2705        }
2706        #[inline(always)]
2707        fn encode_is_copy() -> bool {
2708            true
2709        }
2710
2711        #[inline(always)]
2712        fn decode_is_copy() -> bool {
2713            true
2714        }
2715    }
2716
2717    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<HtOperation, D>
2718        for &HtOperation
2719    {
2720        #[inline]
2721        unsafe fn encode(
2722            self,
2723            encoder: &mut fidl::encoding::Encoder<'_, D>,
2724            offset: usize,
2725            _depth: fidl::encoding::Depth,
2726        ) -> fidl::Result<()> {
2727            encoder.debug_check_bounds::<HtOperation>(offset);
2728            unsafe {
2729                // Copy the object into the buffer.
2730                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2731                (buf_ptr as *mut HtOperation).write_unaligned((self as *const HtOperation).read());
2732                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2733                // done second because the memcpy will write garbage to these bytes.
2734            }
2735            Ok(())
2736        }
2737    }
2738    unsafe impl<
2739        D: fidl::encoding::ResourceDialect,
2740        T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 22>, D>,
2741    > fidl::encoding::Encode<HtOperation, D> for (T0,)
2742    {
2743        #[inline]
2744        unsafe fn encode(
2745            self,
2746            encoder: &mut fidl::encoding::Encoder<'_, D>,
2747            offset: usize,
2748            depth: fidl::encoding::Depth,
2749        ) -> fidl::Result<()> {
2750            encoder.debug_check_bounds::<HtOperation>(offset);
2751            // Zero out padding regions. There's no need to apply masks
2752            // because the unmasked parts will be overwritten by fields.
2753            // Write the fields.
2754            self.0.encode(encoder, offset + 0, depth)?;
2755            Ok(())
2756        }
2757    }
2758
2759    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HtOperation {
2760        #[inline(always)]
2761        fn new_empty() -> Self {
2762            Self { bytes: fidl::new_empty!(fidl::encoding::Array<u8, 22>, D) }
2763        }
2764
2765        #[inline]
2766        unsafe fn decode(
2767            &mut self,
2768            decoder: &mut fidl::encoding::Decoder<'_, D>,
2769            offset: usize,
2770            _depth: fidl::encoding::Depth,
2771        ) -> fidl::Result<()> {
2772            decoder.debug_check_bounds::<Self>(offset);
2773            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2774            // Verify that padding bytes are zero.
2775            // Copy from the buffer into the object.
2776            unsafe {
2777                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 22);
2778            }
2779            Ok(())
2780        }
2781    }
2782
2783    impl fidl::encoding::ValueTypeMarker for VhtCapabilities {
2784        type Borrowed<'a> = &'a Self;
2785        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2786            value
2787        }
2788    }
2789
2790    unsafe impl fidl::encoding::TypeMarker for VhtCapabilities {
2791        type Owned = Self;
2792
2793        #[inline(always)]
2794        fn inline_align(_context: fidl::encoding::Context) -> usize {
2795            1
2796        }
2797
2798        #[inline(always)]
2799        fn inline_size(_context: fidl::encoding::Context) -> usize {
2800            12
2801        }
2802        #[inline(always)]
2803        fn encode_is_copy() -> bool {
2804            true
2805        }
2806
2807        #[inline(always)]
2808        fn decode_is_copy() -> bool {
2809            true
2810        }
2811    }
2812
2813    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VhtCapabilities, D>
2814        for &VhtCapabilities
2815    {
2816        #[inline]
2817        unsafe fn encode(
2818            self,
2819            encoder: &mut fidl::encoding::Encoder<'_, D>,
2820            offset: usize,
2821            _depth: fidl::encoding::Depth,
2822        ) -> fidl::Result<()> {
2823            encoder.debug_check_bounds::<VhtCapabilities>(offset);
2824            unsafe {
2825                // Copy the object into the buffer.
2826                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2827                (buf_ptr as *mut VhtCapabilities)
2828                    .write_unaligned((self as *const VhtCapabilities).read());
2829                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2830                // done second because the memcpy will write garbage to these bytes.
2831            }
2832            Ok(())
2833        }
2834    }
2835    unsafe impl<
2836        D: fidl::encoding::ResourceDialect,
2837        T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 12>, D>,
2838    > fidl::encoding::Encode<VhtCapabilities, D> for (T0,)
2839    {
2840        #[inline]
2841        unsafe fn encode(
2842            self,
2843            encoder: &mut fidl::encoding::Encoder<'_, D>,
2844            offset: usize,
2845            depth: fidl::encoding::Depth,
2846        ) -> fidl::Result<()> {
2847            encoder.debug_check_bounds::<VhtCapabilities>(offset);
2848            // Zero out padding regions. There's no need to apply masks
2849            // because the unmasked parts will be overwritten by fields.
2850            // Write the fields.
2851            self.0.encode(encoder, offset + 0, depth)?;
2852            Ok(())
2853        }
2854    }
2855
2856    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VhtCapabilities {
2857        #[inline(always)]
2858        fn new_empty() -> Self {
2859            Self { bytes: fidl::new_empty!(fidl::encoding::Array<u8, 12>, D) }
2860        }
2861
2862        #[inline]
2863        unsafe fn decode(
2864            &mut self,
2865            decoder: &mut fidl::encoding::Decoder<'_, D>,
2866            offset: usize,
2867            _depth: fidl::encoding::Depth,
2868        ) -> fidl::Result<()> {
2869            decoder.debug_check_bounds::<Self>(offset);
2870            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2871            // Verify that padding bytes are zero.
2872            // Copy from the buffer into the object.
2873            unsafe {
2874                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 12);
2875            }
2876            Ok(())
2877        }
2878    }
2879
2880    impl fidl::encoding::ValueTypeMarker for VhtOperation {
2881        type Borrowed<'a> = &'a Self;
2882        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2883            value
2884        }
2885    }
2886
2887    unsafe impl fidl::encoding::TypeMarker for VhtOperation {
2888        type Owned = Self;
2889
2890        #[inline(always)]
2891        fn inline_align(_context: fidl::encoding::Context) -> usize {
2892            1
2893        }
2894
2895        #[inline(always)]
2896        fn inline_size(_context: fidl::encoding::Context) -> usize {
2897            5
2898        }
2899        #[inline(always)]
2900        fn encode_is_copy() -> bool {
2901            true
2902        }
2903
2904        #[inline(always)]
2905        fn decode_is_copy() -> bool {
2906            true
2907        }
2908    }
2909
2910    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VhtOperation, D>
2911        for &VhtOperation
2912    {
2913        #[inline]
2914        unsafe fn encode(
2915            self,
2916            encoder: &mut fidl::encoding::Encoder<'_, D>,
2917            offset: usize,
2918            _depth: fidl::encoding::Depth,
2919        ) -> fidl::Result<()> {
2920            encoder.debug_check_bounds::<VhtOperation>(offset);
2921            unsafe {
2922                // Copy the object into the buffer.
2923                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2924                (buf_ptr as *mut VhtOperation)
2925                    .write_unaligned((self as *const VhtOperation).read());
2926                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2927                // done second because the memcpy will write garbage to these bytes.
2928            }
2929            Ok(())
2930        }
2931    }
2932    unsafe impl<
2933        D: fidl::encoding::ResourceDialect,
2934        T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 5>, D>,
2935    > fidl::encoding::Encode<VhtOperation, D> for (T0,)
2936    {
2937        #[inline]
2938        unsafe fn encode(
2939            self,
2940            encoder: &mut fidl::encoding::Encoder<'_, D>,
2941            offset: usize,
2942            depth: fidl::encoding::Depth,
2943        ) -> fidl::Result<()> {
2944            encoder.debug_check_bounds::<VhtOperation>(offset);
2945            // Zero out padding regions. There's no need to apply masks
2946            // because the unmasked parts will be overwritten by fields.
2947            // Write the fields.
2948            self.0.encode(encoder, offset + 0, depth)?;
2949            Ok(())
2950        }
2951    }
2952
2953    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VhtOperation {
2954        #[inline(always)]
2955        fn new_empty() -> Self {
2956            Self { bytes: fidl::new_empty!(fidl::encoding::Array<u8, 5>, D) }
2957        }
2958
2959        #[inline]
2960        unsafe fn decode(
2961            &mut self,
2962            decoder: &mut fidl::encoding::Decoder<'_, D>,
2963            offset: usize,
2964            _depth: fidl::encoding::Depth,
2965        ) -> fidl::Result<()> {
2966            decoder.debug_check_bounds::<Self>(offset);
2967            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2968            // Verify that padding bytes are zero.
2969            // Copy from the buffer into the object.
2970            unsafe {
2971                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 5);
2972            }
2973            Ok(())
2974        }
2975    }
2976
2977    impl fidl::encoding::ValueTypeMarker for WlanChannel {
2978        type Borrowed<'a> = &'a Self;
2979        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2980            value
2981        }
2982    }
2983
2984    unsafe impl fidl::encoding::TypeMarker for WlanChannel {
2985        type Owned = Self;
2986
2987        #[inline(always)]
2988        fn inline_align(_context: fidl::encoding::Context) -> usize {
2989            4
2990        }
2991
2992        #[inline(always)]
2993        fn inline_size(_context: fidl::encoding::Context) -> usize {
2994            12
2995        }
2996    }
2997
2998    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WlanChannel, D>
2999        for &WlanChannel
3000    {
3001        #[inline]
3002        unsafe fn encode(
3003            self,
3004            encoder: &mut fidl::encoding::Encoder<'_, D>,
3005            offset: usize,
3006            _depth: fidl::encoding::Depth,
3007        ) -> fidl::Result<()> {
3008            encoder.debug_check_bounds::<WlanChannel>(offset);
3009            // Delegate to tuple encoding.
3010            fidl::encoding::Encode::<WlanChannel, D>::encode(
3011                (
3012                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.primary),
3013                    <ChannelBandwidth as fidl::encoding::ValueTypeMarker>::borrow(&self.cbw),
3014                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.secondary80),
3015                ),
3016                encoder,
3017                offset,
3018                _depth,
3019            )
3020        }
3021    }
3022    unsafe impl<
3023        D: fidl::encoding::ResourceDialect,
3024        T0: fidl::encoding::Encode<u8, D>,
3025        T1: fidl::encoding::Encode<ChannelBandwidth, D>,
3026        T2: fidl::encoding::Encode<u8, D>,
3027    > fidl::encoding::Encode<WlanChannel, D> for (T0, T1, T2)
3028    {
3029        #[inline]
3030        unsafe fn encode(
3031            self,
3032            encoder: &mut fidl::encoding::Encoder<'_, D>,
3033            offset: usize,
3034            depth: fidl::encoding::Depth,
3035        ) -> fidl::Result<()> {
3036            encoder.debug_check_bounds::<WlanChannel>(offset);
3037            // Zero out padding regions. There's no need to apply masks
3038            // because the unmasked parts will be overwritten by fields.
3039            unsafe {
3040                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3041                (ptr as *mut u32).write_unaligned(0);
3042            }
3043            unsafe {
3044                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
3045                (ptr as *mut u32).write_unaligned(0);
3046            }
3047            // Write the fields.
3048            self.0.encode(encoder, offset + 0, depth)?;
3049            self.1.encode(encoder, offset + 4, depth)?;
3050            self.2.encode(encoder, offset + 8, depth)?;
3051            Ok(())
3052        }
3053    }
3054
3055    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WlanChannel {
3056        #[inline(always)]
3057        fn new_empty() -> Self {
3058            Self {
3059                primary: fidl::new_empty!(u8, D),
3060                cbw: fidl::new_empty!(ChannelBandwidth, D),
3061                secondary80: fidl::new_empty!(u8, D),
3062            }
3063        }
3064
3065        #[inline]
3066        unsafe fn decode(
3067            &mut self,
3068            decoder: &mut fidl::encoding::Decoder<'_, D>,
3069            offset: usize,
3070            _depth: fidl::encoding::Depth,
3071        ) -> fidl::Result<()> {
3072            decoder.debug_check_bounds::<Self>(offset);
3073            // Verify that padding bytes are zero.
3074            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3075            let padval = unsafe { (ptr as *const u32).read_unaligned() };
3076            let mask = 0xffffff00u32;
3077            let maskedval = padval & mask;
3078            if maskedval != 0 {
3079                return Err(fidl::Error::NonZeroPadding {
3080                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3081                });
3082            }
3083            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
3084            let padval = unsafe { (ptr as *const u32).read_unaligned() };
3085            let mask = 0xffffff00u32;
3086            let maskedval = padval & mask;
3087            if maskedval != 0 {
3088                return Err(fidl::Error::NonZeroPadding {
3089                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
3090                });
3091            }
3092            fidl::decode!(u8, D, &mut self.primary, decoder, offset + 0, _depth)?;
3093            fidl::decode!(ChannelBandwidth, D, &mut self.cbw, decoder, offset + 4, _depth)?;
3094            fidl::decode!(u8, D, &mut self.secondary80, decoder, offset + 8, _depth)?;
3095            Ok(())
3096        }
3097    }
3098
3099    impl SetKeyDescriptor {
3100        #[inline(always)]
3101        fn max_ordinal_present(&self) -> u64 {
3102            if let Some(_) = self.cipher_type {
3103                return 7;
3104            }
3105            if let Some(_) = self.cipher_oui {
3106                return 6;
3107            }
3108            if let Some(_) = self.rsc {
3109                return 5;
3110            }
3111            if let Some(_) = self.peer_addr {
3112                return 4;
3113            }
3114            if let Some(_) = self.key_type {
3115                return 3;
3116            }
3117            if let Some(_) = self.key_id {
3118                return 2;
3119            }
3120            if let Some(_) = self.key {
3121                return 1;
3122            }
3123            0
3124        }
3125    }
3126
3127    impl fidl::encoding::ValueTypeMarker for SetKeyDescriptor {
3128        type Borrowed<'a> = &'a Self;
3129        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3130            value
3131        }
3132    }
3133
3134    unsafe impl fidl::encoding::TypeMarker for SetKeyDescriptor {
3135        type Owned = Self;
3136
3137        #[inline(always)]
3138        fn inline_align(_context: fidl::encoding::Context) -> usize {
3139            8
3140        }
3141
3142        #[inline(always)]
3143        fn inline_size(_context: fidl::encoding::Context) -> usize {
3144            16
3145        }
3146    }
3147
3148    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SetKeyDescriptor, D>
3149        for &SetKeyDescriptor
3150    {
3151        unsafe fn encode(
3152            self,
3153            encoder: &mut fidl::encoding::Encoder<'_, D>,
3154            offset: usize,
3155            mut depth: fidl::encoding::Depth,
3156        ) -> fidl::Result<()> {
3157            encoder.debug_check_bounds::<SetKeyDescriptor>(offset);
3158            // Vector header
3159            let max_ordinal: u64 = self.max_ordinal_present();
3160            encoder.write_num(max_ordinal, offset);
3161            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3162            // Calling encoder.out_of_line_offset(0) is not allowed.
3163            if max_ordinal == 0 {
3164                return Ok(());
3165            }
3166            depth.increment()?;
3167            let envelope_size = 8;
3168            let bytes_len = max_ordinal as usize * envelope_size;
3169            #[allow(unused_variables)]
3170            let offset = encoder.out_of_line_offset(bytes_len);
3171            let mut _prev_end_offset: usize = 0;
3172            if 1 > max_ordinal {
3173                return Ok(());
3174            }
3175
3176            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3177            // are envelope_size bytes.
3178            let cur_offset: usize = (1 - 1) * envelope_size;
3179
3180            // Zero reserved fields.
3181            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3182
3183            // Safety:
3184            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3185            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3186            //   envelope_size bytes, there is always sufficient room.
3187            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 32>, D>(
3188                self.key.as_ref().map(
3189                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow,
3190                ),
3191                encoder,
3192                offset + cur_offset,
3193                depth,
3194            )?;
3195
3196            _prev_end_offset = cur_offset + envelope_size;
3197            if 2 > max_ordinal {
3198                return Ok(());
3199            }
3200
3201            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3202            // are envelope_size bytes.
3203            let cur_offset: usize = (2 - 1) * envelope_size;
3204
3205            // Zero reserved fields.
3206            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3207
3208            // Safety:
3209            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3210            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3211            //   envelope_size bytes, there is always sufficient room.
3212            fidl::encoding::encode_in_envelope_optional::<u16, D>(
3213                self.key_id.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
3214                encoder,
3215                offset + cur_offset,
3216                depth,
3217            )?;
3218
3219            _prev_end_offset = cur_offset + envelope_size;
3220            if 3 > max_ordinal {
3221                return Ok(());
3222            }
3223
3224            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3225            // are envelope_size bytes.
3226            let cur_offset: usize = (3 - 1) * envelope_size;
3227
3228            // Zero reserved fields.
3229            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3230
3231            // Safety:
3232            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3233            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3234            //   envelope_size bytes, there is always sufficient room.
3235            fidl::encoding::encode_in_envelope_optional::<KeyType, D>(
3236                self.key_type.as_ref().map(<KeyType as fidl::encoding::ValueTypeMarker>::borrow),
3237                encoder,
3238                offset + cur_offset,
3239                depth,
3240            )?;
3241
3242            _prev_end_offset = cur_offset + envelope_size;
3243            if 4 > max_ordinal {
3244                return Ok(());
3245            }
3246
3247            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3248            // are envelope_size bytes.
3249            let cur_offset: usize = (4 - 1) * envelope_size;
3250
3251            // Zero reserved fields.
3252            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3253
3254            // Safety:
3255            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3256            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3257            //   envelope_size bytes, there is always sufficient room.
3258            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<u8, 6>, D>(
3259                self.peer_addr
3260                    .as_ref()
3261                    .map(<fidl::encoding::Array<u8, 6> as fidl::encoding::ValueTypeMarker>::borrow),
3262                encoder,
3263                offset + cur_offset,
3264                depth,
3265            )?;
3266
3267            _prev_end_offset = cur_offset + envelope_size;
3268            if 5 > max_ordinal {
3269                return Ok(());
3270            }
3271
3272            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3273            // are envelope_size bytes.
3274            let cur_offset: usize = (5 - 1) * envelope_size;
3275
3276            // Zero reserved fields.
3277            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3278
3279            // Safety:
3280            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3281            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3282            //   envelope_size bytes, there is always sufficient room.
3283            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3284                self.rsc.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3285                encoder,
3286                offset + cur_offset,
3287                depth,
3288            )?;
3289
3290            _prev_end_offset = cur_offset + envelope_size;
3291            if 6 > max_ordinal {
3292                return Ok(());
3293            }
3294
3295            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3296            // are envelope_size bytes.
3297            let cur_offset: usize = (6 - 1) * envelope_size;
3298
3299            // Zero reserved fields.
3300            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3301
3302            // Safety:
3303            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3304            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3305            //   envelope_size bytes, there is always sufficient room.
3306            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<u8, 3>, D>(
3307                self.cipher_oui
3308                    .as_ref()
3309                    .map(<fidl::encoding::Array<u8, 3> as fidl::encoding::ValueTypeMarker>::borrow),
3310                encoder,
3311                offset + cur_offset,
3312                depth,
3313            )?;
3314
3315            _prev_end_offset = cur_offset + envelope_size;
3316            if 7 > max_ordinal {
3317                return Ok(());
3318            }
3319
3320            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3321            // are envelope_size bytes.
3322            let cur_offset: usize = (7 - 1) * envelope_size;
3323
3324            // Zero reserved fields.
3325            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3326
3327            // Safety:
3328            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3329            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3330            //   envelope_size bytes, there is always sufficient room.
3331            fidl::encoding::encode_in_envelope_optional::<CipherSuiteType, D>(
3332                self.cipher_type
3333                    .as_ref()
3334                    .map(<CipherSuiteType as fidl::encoding::ValueTypeMarker>::borrow),
3335                encoder,
3336                offset + cur_offset,
3337                depth,
3338            )?;
3339
3340            _prev_end_offset = cur_offset + envelope_size;
3341
3342            Ok(())
3343        }
3344    }
3345
3346    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SetKeyDescriptor {
3347        #[inline(always)]
3348        fn new_empty() -> Self {
3349            Self::default()
3350        }
3351
3352        unsafe fn decode(
3353            &mut self,
3354            decoder: &mut fidl::encoding::Decoder<'_, D>,
3355            offset: usize,
3356            mut depth: fidl::encoding::Depth,
3357        ) -> fidl::Result<()> {
3358            decoder.debug_check_bounds::<Self>(offset);
3359            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3360                None => return Err(fidl::Error::NotNullable),
3361                Some(len) => len,
3362            };
3363            // Calling decoder.out_of_line_offset(0) is not allowed.
3364            if len == 0 {
3365                return Ok(());
3366            };
3367            depth.increment()?;
3368            let envelope_size = 8;
3369            let bytes_len = len * envelope_size;
3370            let offset = decoder.out_of_line_offset(bytes_len)?;
3371            // Decode the envelope for each type.
3372            let mut _next_ordinal_to_read = 0;
3373            let mut next_offset = offset;
3374            let end_offset = offset + bytes_len;
3375            _next_ordinal_to_read += 1;
3376            if next_offset >= end_offset {
3377                return Ok(());
3378            }
3379
3380            // Decode unknown envelopes for gaps in ordinals.
3381            while _next_ordinal_to_read < 1 {
3382                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3383                _next_ordinal_to_read += 1;
3384                next_offset += envelope_size;
3385            }
3386
3387            let next_out_of_line = decoder.next_out_of_line();
3388            let handles_before = decoder.remaining_handles();
3389            if let Some((inlined, num_bytes, num_handles)) =
3390                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3391            {
3392                let member_inline_size =
3393                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::TypeMarker>::inline_size(
3394                        decoder.context,
3395                    );
3396                if inlined != (member_inline_size <= 4) {
3397                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3398                }
3399                let inner_offset;
3400                let mut inner_depth = depth.clone();
3401                if inlined {
3402                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3403                    inner_offset = next_offset;
3404                } else {
3405                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3406                    inner_depth.increment()?;
3407                }
3408                let val_ref = self
3409                    .key
3410                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32>, D));
3411                fidl::decode!(fidl::encoding::Vector<u8, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
3412                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3413                {
3414                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3415                }
3416                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3417                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3418                }
3419            }
3420
3421            next_offset += envelope_size;
3422            _next_ordinal_to_read += 1;
3423            if next_offset >= end_offset {
3424                return Ok(());
3425            }
3426
3427            // Decode unknown envelopes for gaps in ordinals.
3428            while _next_ordinal_to_read < 2 {
3429                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3430                _next_ordinal_to_read += 1;
3431                next_offset += envelope_size;
3432            }
3433
3434            let next_out_of_line = decoder.next_out_of_line();
3435            let handles_before = decoder.remaining_handles();
3436            if let Some((inlined, num_bytes, num_handles)) =
3437                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3438            {
3439                let member_inline_size =
3440                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3441                if inlined != (member_inline_size <= 4) {
3442                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3443                }
3444                let inner_offset;
3445                let mut inner_depth = depth.clone();
3446                if inlined {
3447                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3448                    inner_offset = next_offset;
3449                } else {
3450                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3451                    inner_depth.increment()?;
3452                }
3453                let val_ref = self.key_id.get_or_insert_with(|| fidl::new_empty!(u16, D));
3454                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
3455                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3456                {
3457                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3458                }
3459                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3460                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3461                }
3462            }
3463
3464            next_offset += envelope_size;
3465            _next_ordinal_to_read += 1;
3466            if next_offset >= end_offset {
3467                return Ok(());
3468            }
3469
3470            // Decode unknown envelopes for gaps in ordinals.
3471            while _next_ordinal_to_read < 3 {
3472                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3473                _next_ordinal_to_read += 1;
3474                next_offset += envelope_size;
3475            }
3476
3477            let next_out_of_line = decoder.next_out_of_line();
3478            let handles_before = decoder.remaining_handles();
3479            if let Some((inlined, num_bytes, num_handles)) =
3480                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3481            {
3482                let member_inline_size =
3483                    <KeyType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3484                if inlined != (member_inline_size <= 4) {
3485                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3486                }
3487                let inner_offset;
3488                let mut inner_depth = depth.clone();
3489                if inlined {
3490                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3491                    inner_offset = next_offset;
3492                } else {
3493                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3494                    inner_depth.increment()?;
3495                }
3496                let val_ref = self.key_type.get_or_insert_with(|| fidl::new_empty!(KeyType, D));
3497                fidl::decode!(KeyType, D, val_ref, decoder, inner_offset, inner_depth)?;
3498                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3499                {
3500                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3501                }
3502                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3503                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3504                }
3505            }
3506
3507            next_offset += envelope_size;
3508            _next_ordinal_to_read += 1;
3509            if next_offset >= end_offset {
3510                return Ok(());
3511            }
3512
3513            // Decode unknown envelopes for gaps in ordinals.
3514            while _next_ordinal_to_read < 4 {
3515                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3516                _next_ordinal_to_read += 1;
3517                next_offset += envelope_size;
3518            }
3519
3520            let next_out_of_line = decoder.next_out_of_line();
3521            let handles_before = decoder.remaining_handles();
3522            if let Some((inlined, num_bytes, num_handles)) =
3523                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3524            {
3525                let member_inline_size =
3526                    <fidl::encoding::Array<u8, 6> as fidl::encoding::TypeMarker>::inline_size(
3527                        decoder.context,
3528                    );
3529                if inlined != (member_inline_size <= 4) {
3530                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3531                }
3532                let inner_offset;
3533                let mut inner_depth = depth.clone();
3534                if inlined {
3535                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3536                    inner_offset = next_offset;
3537                } else {
3538                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3539                    inner_depth.increment()?;
3540                }
3541                let val_ref = self
3542                    .peer_addr
3543                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<u8, 6>, D));
3544                fidl::decode!(fidl::encoding::Array<u8, 6>, D, val_ref, decoder, inner_offset, inner_depth)?;
3545                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3546                {
3547                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3548                }
3549                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3550                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3551                }
3552            }
3553
3554            next_offset += envelope_size;
3555            _next_ordinal_to_read += 1;
3556            if next_offset >= end_offset {
3557                return Ok(());
3558            }
3559
3560            // Decode unknown envelopes for gaps in ordinals.
3561            while _next_ordinal_to_read < 5 {
3562                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3563                _next_ordinal_to_read += 1;
3564                next_offset += envelope_size;
3565            }
3566
3567            let next_out_of_line = decoder.next_out_of_line();
3568            let handles_before = decoder.remaining_handles();
3569            if let Some((inlined, num_bytes, num_handles)) =
3570                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3571            {
3572                let member_inline_size =
3573                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3574                if inlined != (member_inline_size <= 4) {
3575                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3576                }
3577                let inner_offset;
3578                let mut inner_depth = depth.clone();
3579                if inlined {
3580                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3581                    inner_offset = next_offset;
3582                } else {
3583                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3584                    inner_depth.increment()?;
3585                }
3586                let val_ref = self.rsc.get_or_insert_with(|| fidl::new_empty!(u64, D));
3587                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
3588                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3589                {
3590                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3591                }
3592                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3593                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3594                }
3595            }
3596
3597            next_offset += envelope_size;
3598            _next_ordinal_to_read += 1;
3599            if next_offset >= end_offset {
3600                return Ok(());
3601            }
3602
3603            // Decode unknown envelopes for gaps in ordinals.
3604            while _next_ordinal_to_read < 6 {
3605                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3606                _next_ordinal_to_read += 1;
3607                next_offset += envelope_size;
3608            }
3609
3610            let next_out_of_line = decoder.next_out_of_line();
3611            let handles_before = decoder.remaining_handles();
3612            if let Some((inlined, num_bytes, num_handles)) =
3613                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3614            {
3615                let member_inline_size =
3616                    <fidl::encoding::Array<u8, 3> as fidl::encoding::TypeMarker>::inline_size(
3617                        decoder.context,
3618                    );
3619                if inlined != (member_inline_size <= 4) {
3620                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3621                }
3622                let inner_offset;
3623                let mut inner_depth = depth.clone();
3624                if inlined {
3625                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3626                    inner_offset = next_offset;
3627                } else {
3628                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3629                    inner_depth.increment()?;
3630                }
3631                let val_ref = self
3632                    .cipher_oui
3633                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<u8, 3>, D));
3634                fidl::decode!(fidl::encoding::Array<u8, 3>, D, val_ref, decoder, inner_offset, inner_depth)?;
3635                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3636                {
3637                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3638                }
3639                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3640                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3641                }
3642            }
3643
3644            next_offset += envelope_size;
3645            _next_ordinal_to_read += 1;
3646            if next_offset >= end_offset {
3647                return Ok(());
3648            }
3649
3650            // Decode unknown envelopes for gaps in ordinals.
3651            while _next_ordinal_to_read < 7 {
3652                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3653                _next_ordinal_to_read += 1;
3654                next_offset += envelope_size;
3655            }
3656
3657            let next_out_of_line = decoder.next_out_of_line();
3658            let handles_before = decoder.remaining_handles();
3659            if let Some((inlined, num_bytes, num_handles)) =
3660                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3661            {
3662                let member_inline_size =
3663                    <CipherSuiteType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3664                if inlined != (member_inline_size <= 4) {
3665                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3666                }
3667                let inner_offset;
3668                let mut inner_depth = depth.clone();
3669                if inlined {
3670                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3671                    inner_offset = next_offset;
3672                } else {
3673                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3674                    inner_depth.increment()?;
3675                }
3676                let val_ref =
3677                    self.cipher_type.get_or_insert_with(|| fidl::new_empty!(CipherSuiteType, D));
3678                fidl::decode!(CipherSuiteType, D, val_ref, decoder, inner_offset, inner_depth)?;
3679                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3680                {
3681                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3682                }
3683                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3684                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3685                }
3686            }
3687
3688            next_offset += envelope_size;
3689
3690            // Decode the remaining unknown envelopes.
3691            while next_offset < end_offset {
3692                _next_ordinal_to_read += 1;
3693                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3694                next_offset += envelope_size;
3695            }
3696
3697            Ok(())
3698        }
3699    }
3700}