Skip to main content

fidl_fuchsia_bluetooth_affordances__common/
fidl_fuchsia_bluetooth_affordances__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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12#[repr(u32)]
13pub enum Error {
14    /// Operation failed (check logs).
15    Internal = 1,
16    /// Operation timed out.
17    Timeout = 2,
18    /// Invalid parameters. This usually means that one or more required fields were not set.
19    InvalidParameters = 3,
20}
21
22impl Error {
23    #[inline]
24    pub fn from_primitive(prim: u32) -> Option<Self> {
25        match prim {
26            1 => Some(Self::Internal),
27            2 => Some(Self::Timeout),
28            3 => Some(Self::InvalidParameters),
29            _ => None,
30        }
31    }
32
33    #[inline]
34    pub const fn into_primitive(self) -> u32 {
35        self as u32
36    }
37}
38
39#[derive(Clone, Debug, Default, PartialEq)]
40pub struct HostControllerSetDeviceClassRequest {
41    /// Required. The device class to assign to the host. See [`fuchsia.bluetooth.DeviceClass`].
42    pub device_class: Option<fidl_fuchsia_bluetooth__common::DeviceClass>,
43    #[doc(hidden)]
44    pub __source_breaking: fidl::marker::SourceBreaking,
45}
46
47impl fidl::Persistable for HostControllerSetDeviceClassRequest {}
48
49#[derive(Clone, Debug, Default, PartialEq)]
50pub struct HostControllerSetDiscoverabilityRequest {
51    /// Required. Set to true if making discoverable or false if revoking discoverability.
52    pub discoverable: Option<bool>,
53    #[doc(hidden)]
54    pub __source_breaking: fidl::marker::SourceBreaking,
55}
56
57impl fidl::Persistable for HostControllerSetDiscoverabilityRequest {}
58
59#[derive(Clone, Debug, Default, PartialEq)]
60pub struct HostControllerSetLocalNameRequest {
61    pub name: Option<String>,
62    #[doc(hidden)]
63    pub __source_breaking: fidl::marker::SourceBreaking,
64}
65
66impl fidl::Persistable for HostControllerSetLocalNameRequest {}
67
68#[derive(Clone, Debug, Default, PartialEq)]
69pub struct HostControllerStartPairingDelegateRequest {
70    /// Required. Set based on the ability of the host to enter responses to pairing requests.
71    /// See [`fuchsia.bluetooth.sys/InputCapability`].
72    pub input_capability: Option<fidl_fuchsia_bluetooth_sys__common::InputCapability>,
73    /// Required. Set based on the ability of the host to display information to the user
74    /// initiating or accepting a pairing. See [`fuchsia.bluetooth.sys/OutputCapability`].
75    pub output_capability: Option<fidl_fuchsia_bluetooth_sys__common::OutputCapability>,
76    #[doc(hidden)]
77    pub __source_breaking: fidl::marker::SourceBreaking,
78}
79
80impl fidl::Persistable for HostControllerStartPairingDelegateRequest {}
81
82#[derive(Clone, Debug, Default, PartialEq)]
83pub struct HostControllerGetHostsResponse {
84    pub hosts: Option<Vec<fidl_fuchsia_bluetooth_sys__common::HostInfo>>,
85    #[doc(hidden)]
86    pub __source_breaking: fidl::marker::SourceBreaking,
87}
88
89impl fidl::Persistable for HostControllerGetHostsResponse {}
90
91#[derive(Clone, Debug, Default, PartialEq)]
92pub struct PeerControllerPairRequest {
93    /// Required. Defines which peer to initiate pairing with.
94    pub selector: Option<PeerSelector>,
95    /// Required. The configuration options to use for this pairing request.
96    pub options: Option<fidl_fuchsia_bluetooth_sys__common::PairingOptions>,
97    #[doc(hidden)]
98    pub __source_breaking: fidl::marker::SourceBreaking,
99}
100
101impl fidl::Persistable for PeerControllerPairRequest {}
102
103#[derive(Clone, Debug, Default, PartialEq)]
104pub struct PeerControllerSetDiscoveryRequest {
105    /// Required. Set to true if starting discovery or false if stopping discovery.
106    pub discovery: Option<bool>,
107    #[doc(hidden)]
108    pub __source_breaking: fidl::marker::SourceBreaking,
109}
110
111impl fidl::Persistable for PeerControllerSetDiscoveryRequest {}
112
113#[derive(Clone, Debug, Default, PartialEq)]
114pub struct PeerControllerGetKnownPeersResponse {
115    pub peers: Option<Vec<fidl_fuchsia_bluetooth_sys__common::Peer>>,
116    #[doc(hidden)]
117    pub __source_breaking: fidl::marker::SourceBreaking,
118}
119
120impl fidl::Persistable for PeerControllerGetKnownPeersResponse {}
121
122/// Defines how to find a peer to perform an operation on. At least one field must be present.
123#[derive(Clone, Debug, Default, PartialEq)]
124pub struct PeerSelector {
125    /// The ID of the peer to act on.
126    pub id: Option<fidl_fuchsia_bluetooth__common::PeerId>,
127    #[doc(hidden)]
128    pub __source_breaking: fidl::marker::SourceBreaking,
129}
130
131impl fidl::Persistable for PeerSelector {}
132
133#[derive(Clone, Debug, Default, PartialEq)]
134pub struct PeripheralControllerAdvertiseRequest {
135    /// Required. Advertising parameters.
136    pub parameters: Option<fidl_fuchsia_bluetooth_le__common::AdvertisingParameters>,
137    /// Required. Timeout for advertising in seconds.
138    pub timeout: Option<u64>,
139    #[doc(hidden)]
140    pub __source_breaking: fidl::marker::SourceBreaking,
141}
142
143impl fidl::Persistable for PeripheralControllerAdvertiseRequest {}
144
145#[derive(Clone, Debug, Default, PartialEq)]
146pub struct PeripheralControllerAdvertiseResponse {
147    /// The ID of the peer that connected.
148    pub peer_id: Option<fidl_fuchsia_bluetooth__common::PeerId>,
149    #[doc(hidden)]
150    pub __source_breaking: fidl::marker::SourceBreaking,
151}
152
153impl fidl::Persistable for PeripheralControllerAdvertiseResponse {}
154
155pub mod host_controller_ordinals {
156    pub const GET_HOSTS: u64 = 0x167d2522684d453d;
157    pub const SET_DISCOVERABILITY: u64 = 0x1e977b538b94b08b;
158    pub const SET_LOCAL_NAME: u64 = 0x357714c7aa252336;
159    pub const START_PAIRING_DELEGATE: u64 = 0x155c20cb1b9c1ed2;
160    pub const STOP_PAIRING_DELEGATE: u64 = 0x5caaee1192a8172c;
161    pub const SET_DEVICE_CLASS: u64 = 0x34dcc9ed479692dc;
162}
163
164pub mod peer_controller_ordinals {
165    pub const GET_KNOWN_PEERS: u64 = 0x482cf3745bab65f6;
166    pub const CONNECT_PEER: u64 = 0x13fbb990835acf66;
167    pub const DISCONNECT_PEER: u64 = 0x5f9992f066c664ad;
168    pub const PAIR: u64 = 0x1991671d4d7eff26;
169    pub const FORGET_PEER: u64 = 0x26011dbbd834f8c6;
170    pub const SET_DISCOVERY: u64 = 0x3269624c9e1d6ab3;
171}
172
173pub mod peripheral_controller_ordinals {
174    pub const ADVERTISE: u64 = 0x59079a81362a66f3;
175}
176
177mod internal {
178    use super::*;
179    unsafe impl fidl::encoding::TypeMarker for Error {
180        type Owned = Self;
181
182        #[inline(always)]
183        fn inline_align(_context: fidl::encoding::Context) -> usize {
184            std::mem::align_of::<u32>()
185        }
186
187        #[inline(always)]
188        fn inline_size(_context: fidl::encoding::Context) -> usize {
189            std::mem::size_of::<u32>()
190        }
191
192        #[inline(always)]
193        fn encode_is_copy() -> bool {
194            true
195        }
196
197        #[inline(always)]
198        fn decode_is_copy() -> bool {
199            false
200        }
201    }
202
203    impl fidl::encoding::ValueTypeMarker for Error {
204        type Borrowed<'a> = Self;
205        #[inline(always)]
206        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
207            *value
208        }
209    }
210
211    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
212        #[inline]
213        unsafe fn encode(
214            self,
215            encoder: &mut fidl::encoding::Encoder<'_, D>,
216            offset: usize,
217            _depth: fidl::encoding::Depth,
218        ) -> fidl::Result<()> {
219            encoder.debug_check_bounds::<Self>(offset);
220            encoder.write_num(self.into_primitive(), offset);
221            Ok(())
222        }
223    }
224
225    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
226        #[inline(always)]
227        fn new_empty() -> Self {
228            Self::Internal
229        }
230
231        #[inline]
232        unsafe fn decode(
233            &mut self,
234            decoder: &mut fidl::encoding::Decoder<'_, D>,
235            offset: usize,
236            _depth: fidl::encoding::Depth,
237        ) -> fidl::Result<()> {
238            decoder.debug_check_bounds::<Self>(offset);
239            let prim = decoder.read_num::<u32>(offset);
240
241            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
242            Ok(())
243        }
244    }
245
246    impl HostControllerSetDeviceClassRequest {
247        #[inline(always)]
248        fn max_ordinal_present(&self) -> u64 {
249            if let Some(_) = self.device_class {
250                return 1;
251            }
252            0
253        }
254    }
255
256    impl fidl::encoding::ValueTypeMarker for HostControllerSetDeviceClassRequest {
257        type Borrowed<'a> = &'a Self;
258        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
259            value
260        }
261    }
262
263    unsafe impl fidl::encoding::TypeMarker for HostControllerSetDeviceClassRequest {
264        type Owned = Self;
265
266        #[inline(always)]
267        fn inline_align(_context: fidl::encoding::Context) -> usize {
268            8
269        }
270
271        #[inline(always)]
272        fn inline_size(_context: fidl::encoding::Context) -> usize {
273            16
274        }
275    }
276
277    unsafe impl<D: fidl::encoding::ResourceDialect>
278        fidl::encoding::Encode<HostControllerSetDeviceClassRequest, D>
279        for &HostControllerSetDeviceClassRequest
280    {
281        unsafe fn encode(
282            self,
283            encoder: &mut fidl::encoding::Encoder<'_, D>,
284            offset: usize,
285            mut depth: fidl::encoding::Depth,
286        ) -> fidl::Result<()> {
287            encoder.debug_check_bounds::<HostControllerSetDeviceClassRequest>(offset);
288            // Vector header
289            let max_ordinal: u64 = self.max_ordinal_present();
290            encoder.write_num(max_ordinal, offset);
291            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
292            // Calling encoder.out_of_line_offset(0) is not allowed.
293            if max_ordinal == 0 {
294                return Ok(());
295            }
296            depth.increment()?;
297            let envelope_size = 8;
298            let bytes_len = max_ordinal as usize * envelope_size;
299            #[allow(unused_variables)]
300            let offset = encoder.out_of_line_offset(bytes_len);
301            let mut _prev_end_offset: usize = 0;
302            if 1 > max_ordinal {
303                return Ok(());
304            }
305
306            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
307            // are envelope_size bytes.
308            let cur_offset: usize = (1 - 1) * envelope_size;
309
310            // Zero reserved fields.
311            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
312
313            // Safety:
314            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
315            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
316            //   envelope_size bytes, there is always sufficient room.
317            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth__common::DeviceClass, D>(
318            self.device_class.as_ref().map(<fidl_fuchsia_bluetooth__common::DeviceClass as fidl::encoding::ValueTypeMarker>::borrow),
319            encoder, offset + cur_offset, depth
320        )?;
321
322            _prev_end_offset = cur_offset + envelope_size;
323
324            Ok(())
325        }
326    }
327
328    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
329        for HostControllerSetDeviceClassRequest
330    {
331        #[inline(always)]
332        fn new_empty() -> Self {
333            Self::default()
334        }
335
336        unsafe fn decode(
337            &mut self,
338            decoder: &mut fidl::encoding::Decoder<'_, D>,
339            offset: usize,
340            mut depth: fidl::encoding::Depth,
341        ) -> fidl::Result<()> {
342            decoder.debug_check_bounds::<Self>(offset);
343            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
344                None => return Err(fidl::Error::NotNullable),
345                Some(len) => len,
346            };
347            // Calling decoder.out_of_line_offset(0) is not allowed.
348            if len == 0 {
349                return Ok(());
350            };
351            depth.increment()?;
352            let envelope_size = 8;
353            let bytes_len = len * envelope_size;
354            let offset = decoder.out_of_line_offset(bytes_len)?;
355            // Decode the envelope for each type.
356            let mut _next_ordinal_to_read = 0;
357            let mut next_offset = offset;
358            let end_offset = offset + bytes_len;
359            _next_ordinal_to_read += 1;
360            if next_offset >= end_offset {
361                return Ok(());
362            }
363
364            // Decode unknown envelopes for gaps in ordinals.
365            while _next_ordinal_to_read < 1 {
366                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
367                _next_ordinal_to_read += 1;
368                next_offset += envelope_size;
369            }
370
371            let next_out_of_line = decoder.next_out_of_line();
372            let handles_before = decoder.remaining_handles();
373            if let Some((inlined, num_bytes, num_handles)) =
374                fidl::encoding::decode_envelope_header(decoder, next_offset)?
375            {
376                let member_inline_size = <fidl_fuchsia_bluetooth__common::DeviceClass as fidl::encoding::TypeMarker>::inline_size(decoder.context);
377                if inlined != (member_inline_size <= 4) {
378                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
379                }
380                let inner_offset;
381                let mut inner_depth = depth.clone();
382                if inlined {
383                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
384                    inner_offset = next_offset;
385                } else {
386                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
387                    inner_depth.increment()?;
388                }
389                let val_ref = self.device_class.get_or_insert_with(|| {
390                    fidl::new_empty!(fidl_fuchsia_bluetooth__common::DeviceClass, D)
391                });
392                fidl::decode!(
393                    fidl_fuchsia_bluetooth__common::DeviceClass,
394                    D,
395                    val_ref,
396                    decoder,
397                    inner_offset,
398                    inner_depth
399                )?;
400                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
401                {
402                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
403                }
404                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
405                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
406                }
407            }
408
409            next_offset += envelope_size;
410
411            // Decode the remaining unknown envelopes.
412            while next_offset < end_offset {
413                _next_ordinal_to_read += 1;
414                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
415                next_offset += envelope_size;
416            }
417
418            Ok(())
419        }
420    }
421
422    impl HostControllerSetDiscoverabilityRequest {
423        #[inline(always)]
424        fn max_ordinal_present(&self) -> u64 {
425            if let Some(_) = self.discoverable {
426                return 1;
427            }
428            0
429        }
430    }
431
432    impl fidl::encoding::ValueTypeMarker for HostControllerSetDiscoverabilityRequest {
433        type Borrowed<'a> = &'a Self;
434        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
435            value
436        }
437    }
438
439    unsafe impl fidl::encoding::TypeMarker for HostControllerSetDiscoverabilityRequest {
440        type Owned = Self;
441
442        #[inline(always)]
443        fn inline_align(_context: fidl::encoding::Context) -> usize {
444            8
445        }
446
447        #[inline(always)]
448        fn inline_size(_context: fidl::encoding::Context) -> usize {
449            16
450        }
451    }
452
453    unsafe impl<D: fidl::encoding::ResourceDialect>
454        fidl::encoding::Encode<HostControllerSetDiscoverabilityRequest, D>
455        for &HostControllerSetDiscoverabilityRequest
456    {
457        unsafe fn encode(
458            self,
459            encoder: &mut fidl::encoding::Encoder<'_, D>,
460            offset: usize,
461            mut depth: fidl::encoding::Depth,
462        ) -> fidl::Result<()> {
463            encoder.debug_check_bounds::<HostControllerSetDiscoverabilityRequest>(offset);
464            // Vector header
465            let max_ordinal: u64 = self.max_ordinal_present();
466            encoder.write_num(max_ordinal, offset);
467            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
468            // Calling encoder.out_of_line_offset(0) is not allowed.
469            if max_ordinal == 0 {
470                return Ok(());
471            }
472            depth.increment()?;
473            let envelope_size = 8;
474            let bytes_len = max_ordinal as usize * envelope_size;
475            #[allow(unused_variables)]
476            let offset = encoder.out_of_line_offset(bytes_len);
477            let mut _prev_end_offset: usize = 0;
478            if 1 > max_ordinal {
479                return Ok(());
480            }
481
482            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
483            // are envelope_size bytes.
484            let cur_offset: usize = (1 - 1) * envelope_size;
485
486            // Zero reserved fields.
487            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
488
489            // Safety:
490            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
491            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
492            //   envelope_size bytes, there is always sufficient room.
493            fidl::encoding::encode_in_envelope_optional::<bool, D>(
494                self.discoverable.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
495                encoder,
496                offset + cur_offset,
497                depth,
498            )?;
499
500            _prev_end_offset = cur_offset + envelope_size;
501
502            Ok(())
503        }
504    }
505
506    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
507        for HostControllerSetDiscoverabilityRequest
508    {
509        #[inline(always)]
510        fn new_empty() -> Self {
511            Self::default()
512        }
513
514        unsafe fn decode(
515            &mut self,
516            decoder: &mut fidl::encoding::Decoder<'_, D>,
517            offset: usize,
518            mut depth: fidl::encoding::Depth,
519        ) -> fidl::Result<()> {
520            decoder.debug_check_bounds::<Self>(offset);
521            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
522                None => return Err(fidl::Error::NotNullable),
523                Some(len) => len,
524            };
525            // Calling decoder.out_of_line_offset(0) is not allowed.
526            if len == 0 {
527                return Ok(());
528            };
529            depth.increment()?;
530            let envelope_size = 8;
531            let bytes_len = len * envelope_size;
532            let offset = decoder.out_of_line_offset(bytes_len)?;
533            // Decode the envelope for each type.
534            let mut _next_ordinal_to_read = 0;
535            let mut next_offset = offset;
536            let end_offset = offset + bytes_len;
537            _next_ordinal_to_read += 1;
538            if next_offset >= end_offset {
539                return Ok(());
540            }
541
542            // Decode unknown envelopes for gaps in ordinals.
543            while _next_ordinal_to_read < 1 {
544                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
545                _next_ordinal_to_read += 1;
546                next_offset += envelope_size;
547            }
548
549            let next_out_of_line = decoder.next_out_of_line();
550            let handles_before = decoder.remaining_handles();
551            if let Some((inlined, num_bytes, num_handles)) =
552                fidl::encoding::decode_envelope_header(decoder, next_offset)?
553            {
554                let member_inline_size =
555                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
556                if inlined != (member_inline_size <= 4) {
557                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
558                }
559                let inner_offset;
560                let mut inner_depth = depth.clone();
561                if inlined {
562                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
563                    inner_offset = next_offset;
564                } else {
565                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
566                    inner_depth.increment()?;
567                }
568                let val_ref = self.discoverable.get_or_insert_with(|| fidl::new_empty!(bool, D));
569                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
570                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
571                {
572                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
573                }
574                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
575                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
576                }
577            }
578
579            next_offset += envelope_size;
580
581            // Decode the remaining unknown envelopes.
582            while next_offset < end_offset {
583                _next_ordinal_to_read += 1;
584                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
585                next_offset += envelope_size;
586            }
587
588            Ok(())
589        }
590    }
591
592    impl HostControllerSetLocalNameRequest {
593        #[inline(always)]
594        fn max_ordinal_present(&self) -> u64 {
595            if let Some(_) = self.name {
596                return 1;
597            }
598            0
599        }
600    }
601
602    impl fidl::encoding::ValueTypeMarker for HostControllerSetLocalNameRequest {
603        type Borrowed<'a> = &'a Self;
604        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
605            value
606        }
607    }
608
609    unsafe impl fidl::encoding::TypeMarker for HostControllerSetLocalNameRequest {
610        type Owned = Self;
611
612        #[inline(always)]
613        fn inline_align(_context: fidl::encoding::Context) -> usize {
614            8
615        }
616
617        #[inline(always)]
618        fn inline_size(_context: fidl::encoding::Context) -> usize {
619            16
620        }
621    }
622
623    unsafe impl<D: fidl::encoding::ResourceDialect>
624        fidl::encoding::Encode<HostControllerSetLocalNameRequest, D>
625        for &HostControllerSetLocalNameRequest
626    {
627        unsafe fn encode(
628            self,
629            encoder: &mut fidl::encoding::Encoder<'_, D>,
630            offset: usize,
631            mut depth: fidl::encoding::Depth,
632        ) -> fidl::Result<()> {
633            encoder.debug_check_bounds::<HostControllerSetLocalNameRequest>(offset);
634            // Vector header
635            let max_ordinal: u64 = self.max_ordinal_present();
636            encoder.write_num(max_ordinal, offset);
637            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
638            // Calling encoder.out_of_line_offset(0) is not allowed.
639            if max_ordinal == 0 {
640                return Ok(());
641            }
642            depth.increment()?;
643            let envelope_size = 8;
644            let bytes_len = max_ordinal as usize * envelope_size;
645            #[allow(unused_variables)]
646            let offset = encoder.out_of_line_offset(bytes_len);
647            let mut _prev_end_offset: usize = 0;
648            if 1 > max_ordinal {
649                return Ok(());
650            }
651
652            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
653            // are envelope_size bytes.
654            let cur_offset: usize = (1 - 1) * envelope_size;
655
656            // Zero reserved fields.
657            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
658
659            // Safety:
660            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
661            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
662            //   envelope_size bytes, there is always sufficient room.
663            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<248>, D>(
664                self.name.as_ref().map(
665                    <fidl::encoding::BoundedString<248> as fidl::encoding::ValueTypeMarker>::borrow,
666                ),
667                encoder,
668                offset + cur_offset,
669                depth,
670            )?;
671
672            _prev_end_offset = cur_offset + envelope_size;
673
674            Ok(())
675        }
676    }
677
678    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
679        for HostControllerSetLocalNameRequest
680    {
681        #[inline(always)]
682        fn new_empty() -> Self {
683            Self::default()
684        }
685
686        unsafe fn decode(
687            &mut self,
688            decoder: &mut fidl::encoding::Decoder<'_, D>,
689            offset: usize,
690            mut depth: fidl::encoding::Depth,
691        ) -> fidl::Result<()> {
692            decoder.debug_check_bounds::<Self>(offset);
693            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
694                None => return Err(fidl::Error::NotNullable),
695                Some(len) => len,
696            };
697            // Calling decoder.out_of_line_offset(0) is not allowed.
698            if len == 0 {
699                return Ok(());
700            };
701            depth.increment()?;
702            let envelope_size = 8;
703            let bytes_len = len * envelope_size;
704            let offset = decoder.out_of_line_offset(bytes_len)?;
705            // Decode the envelope for each type.
706            let mut _next_ordinal_to_read = 0;
707            let mut next_offset = offset;
708            let end_offset = offset + bytes_len;
709            _next_ordinal_to_read += 1;
710            if next_offset >= end_offset {
711                return Ok(());
712            }
713
714            // Decode unknown envelopes for gaps in ordinals.
715            while _next_ordinal_to_read < 1 {
716                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
717                _next_ordinal_to_read += 1;
718                next_offset += envelope_size;
719            }
720
721            let next_out_of_line = decoder.next_out_of_line();
722            let handles_before = decoder.remaining_handles();
723            if let Some((inlined, num_bytes, num_handles)) =
724                fidl::encoding::decode_envelope_header(decoder, next_offset)?
725            {
726                let member_inline_size =
727                    <fidl::encoding::BoundedString<248> as fidl::encoding::TypeMarker>::inline_size(
728                        decoder.context,
729                    );
730                if inlined != (member_inline_size <= 4) {
731                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
732                }
733                let inner_offset;
734                let mut inner_depth = depth.clone();
735                if inlined {
736                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
737                    inner_offset = next_offset;
738                } else {
739                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
740                    inner_depth.increment()?;
741                }
742                let val_ref = self
743                    .name
744                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<248>, D));
745                fidl::decode!(
746                    fidl::encoding::BoundedString<248>,
747                    D,
748                    val_ref,
749                    decoder,
750                    inner_offset,
751                    inner_depth
752                )?;
753                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
754                {
755                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
756                }
757                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
758                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
759                }
760            }
761
762            next_offset += envelope_size;
763
764            // Decode the remaining unknown envelopes.
765            while next_offset < end_offset {
766                _next_ordinal_to_read += 1;
767                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
768                next_offset += envelope_size;
769            }
770
771            Ok(())
772        }
773    }
774
775    impl HostControllerStartPairingDelegateRequest {
776        #[inline(always)]
777        fn max_ordinal_present(&self) -> u64 {
778            if let Some(_) = self.output_capability {
779                return 2;
780            }
781            if let Some(_) = self.input_capability {
782                return 1;
783            }
784            0
785        }
786    }
787
788    impl fidl::encoding::ValueTypeMarker for HostControllerStartPairingDelegateRequest {
789        type Borrowed<'a> = &'a Self;
790        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
791            value
792        }
793    }
794
795    unsafe impl fidl::encoding::TypeMarker for HostControllerStartPairingDelegateRequest {
796        type Owned = Self;
797
798        #[inline(always)]
799        fn inline_align(_context: fidl::encoding::Context) -> usize {
800            8
801        }
802
803        #[inline(always)]
804        fn inline_size(_context: fidl::encoding::Context) -> usize {
805            16
806        }
807    }
808
809    unsafe impl<D: fidl::encoding::ResourceDialect>
810        fidl::encoding::Encode<HostControllerStartPairingDelegateRequest, D>
811        for &HostControllerStartPairingDelegateRequest
812    {
813        unsafe fn encode(
814            self,
815            encoder: &mut fidl::encoding::Encoder<'_, D>,
816            offset: usize,
817            mut depth: fidl::encoding::Depth,
818        ) -> fidl::Result<()> {
819            encoder.debug_check_bounds::<HostControllerStartPairingDelegateRequest>(offset);
820            // Vector header
821            let max_ordinal: u64 = self.max_ordinal_present();
822            encoder.write_num(max_ordinal, offset);
823            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
824            // Calling encoder.out_of_line_offset(0) is not allowed.
825            if max_ordinal == 0 {
826                return Ok(());
827            }
828            depth.increment()?;
829            let envelope_size = 8;
830            let bytes_len = max_ordinal as usize * envelope_size;
831            #[allow(unused_variables)]
832            let offset = encoder.out_of_line_offset(bytes_len);
833            let mut _prev_end_offset: usize = 0;
834            if 1 > max_ordinal {
835                return Ok(());
836            }
837
838            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
839            // are envelope_size bytes.
840            let cur_offset: usize = (1 - 1) * envelope_size;
841
842            // Zero reserved fields.
843            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
844
845            // Safety:
846            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
847            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
848            //   envelope_size bytes, there is always sufficient room.
849            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_sys__common::InputCapability, D>(
850            self.input_capability.as_ref().map(<fidl_fuchsia_bluetooth_sys__common::InputCapability as fidl::encoding::ValueTypeMarker>::borrow),
851            encoder, offset + cur_offset, depth
852        )?;
853
854            _prev_end_offset = cur_offset + envelope_size;
855            if 2 > max_ordinal {
856                return Ok(());
857            }
858
859            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
860            // are envelope_size bytes.
861            let cur_offset: usize = (2 - 1) * envelope_size;
862
863            // Zero reserved fields.
864            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
865
866            // Safety:
867            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
868            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
869            //   envelope_size bytes, there is always sufficient room.
870            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_sys__common::OutputCapability, D>(
871            self.output_capability.as_ref().map(<fidl_fuchsia_bluetooth_sys__common::OutputCapability as fidl::encoding::ValueTypeMarker>::borrow),
872            encoder, offset + cur_offset, depth
873        )?;
874
875            _prev_end_offset = cur_offset + envelope_size;
876
877            Ok(())
878        }
879    }
880
881    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
882        for HostControllerStartPairingDelegateRequest
883    {
884        #[inline(always)]
885        fn new_empty() -> Self {
886            Self::default()
887        }
888
889        unsafe fn decode(
890            &mut self,
891            decoder: &mut fidl::encoding::Decoder<'_, D>,
892            offset: usize,
893            mut depth: fidl::encoding::Depth,
894        ) -> fidl::Result<()> {
895            decoder.debug_check_bounds::<Self>(offset);
896            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
897                None => return Err(fidl::Error::NotNullable),
898                Some(len) => len,
899            };
900            // Calling decoder.out_of_line_offset(0) is not allowed.
901            if len == 0 {
902                return Ok(());
903            };
904            depth.increment()?;
905            let envelope_size = 8;
906            let bytes_len = len * envelope_size;
907            let offset = decoder.out_of_line_offset(bytes_len)?;
908            // Decode the envelope for each type.
909            let mut _next_ordinal_to_read = 0;
910            let mut next_offset = offset;
911            let end_offset = offset + bytes_len;
912            _next_ordinal_to_read += 1;
913            if next_offset >= end_offset {
914                return Ok(());
915            }
916
917            // Decode unknown envelopes for gaps in ordinals.
918            while _next_ordinal_to_read < 1 {
919                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
920                _next_ordinal_to_read += 1;
921                next_offset += envelope_size;
922            }
923
924            let next_out_of_line = decoder.next_out_of_line();
925            let handles_before = decoder.remaining_handles();
926            if let Some((inlined, num_bytes, num_handles)) =
927                fidl::encoding::decode_envelope_header(decoder, next_offset)?
928            {
929                let member_inline_size = <fidl_fuchsia_bluetooth_sys__common::InputCapability as fidl::encoding::TypeMarker>::inline_size(decoder.context);
930                if inlined != (member_inline_size <= 4) {
931                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
932                }
933                let inner_offset;
934                let mut inner_depth = depth.clone();
935                if inlined {
936                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
937                    inner_offset = next_offset;
938                } else {
939                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
940                    inner_depth.increment()?;
941                }
942                let val_ref = self.input_capability.get_or_insert_with(|| {
943                    fidl::new_empty!(fidl_fuchsia_bluetooth_sys__common::InputCapability, D)
944                });
945                fidl::decode!(
946                    fidl_fuchsia_bluetooth_sys__common::InputCapability,
947                    D,
948                    val_ref,
949                    decoder,
950                    inner_offset,
951                    inner_depth
952                )?;
953                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
954                {
955                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
956                }
957                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
958                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
959                }
960            }
961
962            next_offset += envelope_size;
963            _next_ordinal_to_read += 1;
964            if next_offset >= end_offset {
965                return Ok(());
966            }
967
968            // Decode unknown envelopes for gaps in ordinals.
969            while _next_ordinal_to_read < 2 {
970                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
971                _next_ordinal_to_read += 1;
972                next_offset += envelope_size;
973            }
974
975            let next_out_of_line = decoder.next_out_of_line();
976            let handles_before = decoder.remaining_handles();
977            if let Some((inlined, num_bytes, num_handles)) =
978                fidl::encoding::decode_envelope_header(decoder, next_offset)?
979            {
980                let member_inline_size = <fidl_fuchsia_bluetooth_sys__common::OutputCapability as fidl::encoding::TypeMarker>::inline_size(decoder.context);
981                if inlined != (member_inline_size <= 4) {
982                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
983                }
984                let inner_offset;
985                let mut inner_depth = depth.clone();
986                if inlined {
987                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
988                    inner_offset = next_offset;
989                } else {
990                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
991                    inner_depth.increment()?;
992                }
993                let val_ref = self.output_capability.get_or_insert_with(|| {
994                    fidl::new_empty!(fidl_fuchsia_bluetooth_sys__common::OutputCapability, D)
995                });
996                fidl::decode!(
997                    fidl_fuchsia_bluetooth_sys__common::OutputCapability,
998                    D,
999                    val_ref,
1000                    decoder,
1001                    inner_offset,
1002                    inner_depth
1003                )?;
1004                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1005                {
1006                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1007                }
1008                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1009                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1010                }
1011            }
1012
1013            next_offset += envelope_size;
1014
1015            // Decode the remaining unknown envelopes.
1016            while next_offset < end_offset {
1017                _next_ordinal_to_read += 1;
1018                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1019                next_offset += envelope_size;
1020            }
1021
1022            Ok(())
1023        }
1024    }
1025
1026    impl HostControllerGetHostsResponse {
1027        #[inline(always)]
1028        fn max_ordinal_present(&self) -> u64 {
1029            if let Some(_) = self.hosts {
1030                return 1;
1031            }
1032            0
1033        }
1034    }
1035
1036    impl fidl::encoding::ValueTypeMarker for HostControllerGetHostsResponse {
1037        type Borrowed<'a> = &'a Self;
1038        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1039            value
1040        }
1041    }
1042
1043    unsafe impl fidl::encoding::TypeMarker for HostControllerGetHostsResponse {
1044        type Owned = Self;
1045
1046        #[inline(always)]
1047        fn inline_align(_context: fidl::encoding::Context) -> usize {
1048            8
1049        }
1050
1051        #[inline(always)]
1052        fn inline_size(_context: fidl::encoding::Context) -> usize {
1053            16
1054        }
1055    }
1056
1057    unsafe impl<D: fidl::encoding::ResourceDialect>
1058        fidl::encoding::Encode<HostControllerGetHostsResponse, D>
1059        for &HostControllerGetHostsResponse
1060    {
1061        unsafe fn encode(
1062            self,
1063            encoder: &mut fidl::encoding::Encoder<'_, D>,
1064            offset: usize,
1065            mut depth: fidl::encoding::Depth,
1066        ) -> fidl::Result<()> {
1067            encoder.debug_check_bounds::<HostControllerGetHostsResponse>(offset);
1068            // Vector header
1069            let max_ordinal: u64 = self.max_ordinal_present();
1070            encoder.write_num(max_ordinal, offset);
1071            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1072            // Calling encoder.out_of_line_offset(0) is not allowed.
1073            if max_ordinal == 0 {
1074                return Ok(());
1075            }
1076            depth.increment()?;
1077            let envelope_size = 8;
1078            let bytes_len = max_ordinal as usize * envelope_size;
1079            #[allow(unused_variables)]
1080            let offset = encoder.out_of_line_offset(bytes_len);
1081            let mut _prev_end_offset: usize = 0;
1082            if 1 > max_ordinal {
1083                return Ok(());
1084            }
1085
1086            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1087            // are envelope_size bytes.
1088            let cur_offset: usize = (1 - 1) * envelope_size;
1089
1090            // Zero reserved fields.
1091            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1092
1093            // Safety:
1094            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1095            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1096            //   envelope_size bytes, there is always sufficient room.
1097            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_sys__common::HostInfo>, D>(
1098            self.hosts.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_sys__common::HostInfo> as fidl::encoding::ValueTypeMarker>::borrow),
1099            encoder, offset + cur_offset, depth
1100        )?;
1101
1102            _prev_end_offset = cur_offset + envelope_size;
1103
1104            Ok(())
1105        }
1106    }
1107
1108    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1109        for HostControllerGetHostsResponse
1110    {
1111        #[inline(always)]
1112        fn new_empty() -> Self {
1113            Self::default()
1114        }
1115
1116        unsafe fn decode(
1117            &mut self,
1118            decoder: &mut fidl::encoding::Decoder<'_, D>,
1119            offset: usize,
1120            mut depth: fidl::encoding::Depth,
1121        ) -> fidl::Result<()> {
1122            decoder.debug_check_bounds::<Self>(offset);
1123            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1124                None => return Err(fidl::Error::NotNullable),
1125                Some(len) => len,
1126            };
1127            // Calling decoder.out_of_line_offset(0) is not allowed.
1128            if len == 0 {
1129                return Ok(());
1130            };
1131            depth.increment()?;
1132            let envelope_size = 8;
1133            let bytes_len = len * envelope_size;
1134            let offset = decoder.out_of_line_offset(bytes_len)?;
1135            // Decode the envelope for each type.
1136            let mut _next_ordinal_to_read = 0;
1137            let mut next_offset = offset;
1138            let end_offset = offset + bytes_len;
1139            _next_ordinal_to_read += 1;
1140            if next_offset >= end_offset {
1141                return Ok(());
1142            }
1143
1144            // Decode unknown envelopes for gaps in ordinals.
1145            while _next_ordinal_to_read < 1 {
1146                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1147                _next_ordinal_to_read += 1;
1148                next_offset += envelope_size;
1149            }
1150
1151            let next_out_of_line = decoder.next_out_of_line();
1152            let handles_before = decoder.remaining_handles();
1153            if let Some((inlined, num_bytes, num_handles)) =
1154                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1155            {
1156                let member_inline_size = <fidl::encoding::UnboundedVector<
1157                    fidl_fuchsia_bluetooth_sys__common::HostInfo,
1158                > as fidl::encoding::TypeMarker>::inline_size(
1159                    decoder.context
1160                );
1161                if inlined != (member_inline_size <= 4) {
1162                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1163                }
1164                let inner_offset;
1165                let mut inner_depth = depth.clone();
1166                if inlined {
1167                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1168                    inner_offset = next_offset;
1169                } else {
1170                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1171                    inner_depth.increment()?;
1172                }
1173                let val_ref = self.hosts.get_or_insert_with(|| {
1174                    fidl::new_empty!(
1175                        fidl::encoding::UnboundedVector<
1176                            fidl_fuchsia_bluetooth_sys__common::HostInfo,
1177                        >,
1178                        D
1179                    )
1180                });
1181                fidl::decode!(
1182                    fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_sys__common::HostInfo>,
1183                    D,
1184                    val_ref,
1185                    decoder,
1186                    inner_offset,
1187                    inner_depth
1188                )?;
1189                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1190                {
1191                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1192                }
1193                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1194                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1195                }
1196            }
1197
1198            next_offset += envelope_size;
1199
1200            // Decode the remaining unknown envelopes.
1201            while next_offset < end_offset {
1202                _next_ordinal_to_read += 1;
1203                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1204                next_offset += envelope_size;
1205            }
1206
1207            Ok(())
1208        }
1209    }
1210
1211    impl PeerControllerPairRequest {
1212        #[inline(always)]
1213        fn max_ordinal_present(&self) -> u64 {
1214            if let Some(_) = self.options {
1215                return 2;
1216            }
1217            if let Some(_) = self.selector {
1218                return 1;
1219            }
1220            0
1221        }
1222    }
1223
1224    impl fidl::encoding::ValueTypeMarker for PeerControllerPairRequest {
1225        type Borrowed<'a> = &'a Self;
1226        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1227            value
1228        }
1229    }
1230
1231    unsafe impl fidl::encoding::TypeMarker for PeerControllerPairRequest {
1232        type Owned = Self;
1233
1234        #[inline(always)]
1235        fn inline_align(_context: fidl::encoding::Context) -> usize {
1236            8
1237        }
1238
1239        #[inline(always)]
1240        fn inline_size(_context: fidl::encoding::Context) -> usize {
1241            16
1242        }
1243    }
1244
1245    unsafe impl<D: fidl::encoding::ResourceDialect>
1246        fidl::encoding::Encode<PeerControllerPairRequest, D> for &PeerControllerPairRequest
1247    {
1248        unsafe fn encode(
1249            self,
1250            encoder: &mut fidl::encoding::Encoder<'_, D>,
1251            offset: usize,
1252            mut depth: fidl::encoding::Depth,
1253        ) -> fidl::Result<()> {
1254            encoder.debug_check_bounds::<PeerControllerPairRequest>(offset);
1255            // Vector header
1256            let max_ordinal: u64 = self.max_ordinal_present();
1257            encoder.write_num(max_ordinal, offset);
1258            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1259            // Calling encoder.out_of_line_offset(0) is not allowed.
1260            if max_ordinal == 0 {
1261                return Ok(());
1262            }
1263            depth.increment()?;
1264            let envelope_size = 8;
1265            let bytes_len = max_ordinal as usize * envelope_size;
1266            #[allow(unused_variables)]
1267            let offset = encoder.out_of_line_offset(bytes_len);
1268            let mut _prev_end_offset: usize = 0;
1269            if 1 > max_ordinal {
1270                return Ok(());
1271            }
1272
1273            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1274            // are envelope_size bytes.
1275            let cur_offset: usize = (1 - 1) * envelope_size;
1276
1277            // Zero reserved fields.
1278            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1279
1280            // Safety:
1281            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1282            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1283            //   envelope_size bytes, there is always sufficient room.
1284            fidl::encoding::encode_in_envelope_optional::<PeerSelector, D>(
1285                self.selector
1286                    .as_ref()
1287                    .map(<PeerSelector as fidl::encoding::ValueTypeMarker>::borrow),
1288                encoder,
1289                offset + cur_offset,
1290                depth,
1291            )?;
1292
1293            _prev_end_offset = cur_offset + envelope_size;
1294            if 2 > max_ordinal {
1295                return Ok(());
1296            }
1297
1298            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1299            // are envelope_size bytes.
1300            let cur_offset: usize = (2 - 1) * envelope_size;
1301
1302            // Zero reserved fields.
1303            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1304
1305            // Safety:
1306            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1307            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1308            //   envelope_size bytes, there is always sufficient room.
1309            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_sys__common::PairingOptions, D>(
1310            self.options.as_ref().map(<fidl_fuchsia_bluetooth_sys__common::PairingOptions as fidl::encoding::ValueTypeMarker>::borrow),
1311            encoder, offset + cur_offset, depth
1312        )?;
1313
1314            _prev_end_offset = cur_offset + envelope_size;
1315
1316            Ok(())
1317        }
1318    }
1319
1320    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1321        for PeerControllerPairRequest
1322    {
1323        #[inline(always)]
1324        fn new_empty() -> Self {
1325            Self::default()
1326        }
1327
1328        unsafe fn decode(
1329            &mut self,
1330            decoder: &mut fidl::encoding::Decoder<'_, D>,
1331            offset: usize,
1332            mut depth: fidl::encoding::Depth,
1333        ) -> fidl::Result<()> {
1334            decoder.debug_check_bounds::<Self>(offset);
1335            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1336                None => return Err(fidl::Error::NotNullable),
1337                Some(len) => len,
1338            };
1339            // Calling decoder.out_of_line_offset(0) is not allowed.
1340            if len == 0 {
1341                return Ok(());
1342            };
1343            depth.increment()?;
1344            let envelope_size = 8;
1345            let bytes_len = len * envelope_size;
1346            let offset = decoder.out_of_line_offset(bytes_len)?;
1347            // Decode the envelope for each type.
1348            let mut _next_ordinal_to_read = 0;
1349            let mut next_offset = offset;
1350            let end_offset = offset + bytes_len;
1351            _next_ordinal_to_read += 1;
1352            if next_offset >= end_offset {
1353                return Ok(());
1354            }
1355
1356            // Decode unknown envelopes for gaps in ordinals.
1357            while _next_ordinal_to_read < 1 {
1358                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1359                _next_ordinal_to_read += 1;
1360                next_offset += envelope_size;
1361            }
1362
1363            let next_out_of_line = decoder.next_out_of_line();
1364            let handles_before = decoder.remaining_handles();
1365            if let Some((inlined, num_bytes, num_handles)) =
1366                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1367            {
1368                let member_inline_size =
1369                    <PeerSelector as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1370                if inlined != (member_inline_size <= 4) {
1371                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1372                }
1373                let inner_offset;
1374                let mut inner_depth = depth.clone();
1375                if inlined {
1376                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1377                    inner_offset = next_offset;
1378                } else {
1379                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1380                    inner_depth.increment()?;
1381                }
1382                let val_ref =
1383                    self.selector.get_or_insert_with(|| fidl::new_empty!(PeerSelector, D));
1384                fidl::decode!(PeerSelector, D, val_ref, decoder, inner_offset, inner_depth)?;
1385                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1386                {
1387                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1388                }
1389                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1390                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1391                }
1392            }
1393
1394            next_offset += envelope_size;
1395            _next_ordinal_to_read += 1;
1396            if next_offset >= end_offset {
1397                return Ok(());
1398            }
1399
1400            // Decode unknown envelopes for gaps in ordinals.
1401            while _next_ordinal_to_read < 2 {
1402                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1403                _next_ordinal_to_read += 1;
1404                next_offset += envelope_size;
1405            }
1406
1407            let next_out_of_line = decoder.next_out_of_line();
1408            let handles_before = decoder.remaining_handles();
1409            if let Some((inlined, num_bytes, num_handles)) =
1410                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1411            {
1412                let member_inline_size = <fidl_fuchsia_bluetooth_sys__common::PairingOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1413                if inlined != (member_inline_size <= 4) {
1414                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1415                }
1416                let inner_offset;
1417                let mut inner_depth = depth.clone();
1418                if inlined {
1419                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1420                    inner_offset = next_offset;
1421                } else {
1422                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1423                    inner_depth.increment()?;
1424                }
1425                let val_ref = self.options.get_or_insert_with(|| {
1426                    fidl::new_empty!(fidl_fuchsia_bluetooth_sys__common::PairingOptions, D)
1427                });
1428                fidl::decode!(
1429                    fidl_fuchsia_bluetooth_sys__common::PairingOptions,
1430                    D,
1431                    val_ref,
1432                    decoder,
1433                    inner_offset,
1434                    inner_depth
1435                )?;
1436                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1437                {
1438                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1439                }
1440                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1441                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1442                }
1443            }
1444
1445            next_offset += envelope_size;
1446
1447            // Decode the remaining unknown envelopes.
1448            while next_offset < end_offset {
1449                _next_ordinal_to_read += 1;
1450                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1451                next_offset += envelope_size;
1452            }
1453
1454            Ok(())
1455        }
1456    }
1457
1458    impl PeerControllerSetDiscoveryRequest {
1459        #[inline(always)]
1460        fn max_ordinal_present(&self) -> u64 {
1461            if let Some(_) = self.discovery {
1462                return 1;
1463            }
1464            0
1465        }
1466    }
1467
1468    impl fidl::encoding::ValueTypeMarker for PeerControllerSetDiscoveryRequest {
1469        type Borrowed<'a> = &'a Self;
1470        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1471            value
1472        }
1473    }
1474
1475    unsafe impl fidl::encoding::TypeMarker for PeerControllerSetDiscoveryRequest {
1476        type Owned = Self;
1477
1478        #[inline(always)]
1479        fn inline_align(_context: fidl::encoding::Context) -> usize {
1480            8
1481        }
1482
1483        #[inline(always)]
1484        fn inline_size(_context: fidl::encoding::Context) -> usize {
1485            16
1486        }
1487    }
1488
1489    unsafe impl<D: fidl::encoding::ResourceDialect>
1490        fidl::encoding::Encode<PeerControllerSetDiscoveryRequest, D>
1491        for &PeerControllerSetDiscoveryRequest
1492    {
1493        unsafe fn encode(
1494            self,
1495            encoder: &mut fidl::encoding::Encoder<'_, D>,
1496            offset: usize,
1497            mut depth: fidl::encoding::Depth,
1498        ) -> fidl::Result<()> {
1499            encoder.debug_check_bounds::<PeerControllerSetDiscoveryRequest>(offset);
1500            // Vector header
1501            let max_ordinal: u64 = self.max_ordinal_present();
1502            encoder.write_num(max_ordinal, offset);
1503            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1504            // Calling encoder.out_of_line_offset(0) is not allowed.
1505            if max_ordinal == 0 {
1506                return Ok(());
1507            }
1508            depth.increment()?;
1509            let envelope_size = 8;
1510            let bytes_len = max_ordinal as usize * envelope_size;
1511            #[allow(unused_variables)]
1512            let offset = encoder.out_of_line_offset(bytes_len);
1513            let mut _prev_end_offset: usize = 0;
1514            if 1 > max_ordinal {
1515                return Ok(());
1516            }
1517
1518            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1519            // are envelope_size bytes.
1520            let cur_offset: usize = (1 - 1) * envelope_size;
1521
1522            // Zero reserved fields.
1523            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1524
1525            // Safety:
1526            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1527            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1528            //   envelope_size bytes, there is always sufficient room.
1529            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1530                self.discovery.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1531                encoder,
1532                offset + cur_offset,
1533                depth,
1534            )?;
1535
1536            _prev_end_offset = cur_offset + envelope_size;
1537
1538            Ok(())
1539        }
1540    }
1541
1542    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1543        for PeerControllerSetDiscoveryRequest
1544    {
1545        #[inline(always)]
1546        fn new_empty() -> Self {
1547            Self::default()
1548        }
1549
1550        unsafe fn decode(
1551            &mut self,
1552            decoder: &mut fidl::encoding::Decoder<'_, D>,
1553            offset: usize,
1554            mut depth: fidl::encoding::Depth,
1555        ) -> fidl::Result<()> {
1556            decoder.debug_check_bounds::<Self>(offset);
1557            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1558                None => return Err(fidl::Error::NotNullable),
1559                Some(len) => len,
1560            };
1561            // Calling decoder.out_of_line_offset(0) is not allowed.
1562            if len == 0 {
1563                return Ok(());
1564            };
1565            depth.increment()?;
1566            let envelope_size = 8;
1567            let bytes_len = len * envelope_size;
1568            let offset = decoder.out_of_line_offset(bytes_len)?;
1569            // Decode the envelope for each type.
1570            let mut _next_ordinal_to_read = 0;
1571            let mut next_offset = offset;
1572            let end_offset = offset + bytes_len;
1573            _next_ordinal_to_read += 1;
1574            if next_offset >= end_offset {
1575                return Ok(());
1576            }
1577
1578            // Decode unknown envelopes for gaps in ordinals.
1579            while _next_ordinal_to_read < 1 {
1580                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1581                _next_ordinal_to_read += 1;
1582                next_offset += envelope_size;
1583            }
1584
1585            let next_out_of_line = decoder.next_out_of_line();
1586            let handles_before = decoder.remaining_handles();
1587            if let Some((inlined, num_bytes, num_handles)) =
1588                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1589            {
1590                let member_inline_size =
1591                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1592                if inlined != (member_inline_size <= 4) {
1593                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1594                }
1595                let inner_offset;
1596                let mut inner_depth = depth.clone();
1597                if inlined {
1598                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1599                    inner_offset = next_offset;
1600                } else {
1601                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1602                    inner_depth.increment()?;
1603                }
1604                let val_ref = self.discovery.get_or_insert_with(|| fidl::new_empty!(bool, D));
1605                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1606                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1607                {
1608                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1609                }
1610                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1611                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1612                }
1613            }
1614
1615            next_offset += envelope_size;
1616
1617            // Decode the remaining unknown envelopes.
1618            while next_offset < end_offset {
1619                _next_ordinal_to_read += 1;
1620                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1621                next_offset += envelope_size;
1622            }
1623
1624            Ok(())
1625        }
1626    }
1627
1628    impl PeerControllerGetKnownPeersResponse {
1629        #[inline(always)]
1630        fn max_ordinal_present(&self) -> u64 {
1631            if let Some(_) = self.peers {
1632                return 1;
1633            }
1634            0
1635        }
1636    }
1637
1638    impl fidl::encoding::ValueTypeMarker for PeerControllerGetKnownPeersResponse {
1639        type Borrowed<'a> = &'a Self;
1640        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1641            value
1642        }
1643    }
1644
1645    unsafe impl fidl::encoding::TypeMarker for PeerControllerGetKnownPeersResponse {
1646        type Owned = Self;
1647
1648        #[inline(always)]
1649        fn inline_align(_context: fidl::encoding::Context) -> usize {
1650            8
1651        }
1652
1653        #[inline(always)]
1654        fn inline_size(_context: fidl::encoding::Context) -> usize {
1655            16
1656        }
1657    }
1658
1659    unsafe impl<D: fidl::encoding::ResourceDialect>
1660        fidl::encoding::Encode<PeerControllerGetKnownPeersResponse, D>
1661        for &PeerControllerGetKnownPeersResponse
1662    {
1663        unsafe fn encode(
1664            self,
1665            encoder: &mut fidl::encoding::Encoder<'_, D>,
1666            offset: usize,
1667            mut depth: fidl::encoding::Depth,
1668        ) -> fidl::Result<()> {
1669            encoder.debug_check_bounds::<PeerControllerGetKnownPeersResponse>(offset);
1670            // Vector header
1671            let max_ordinal: u64 = self.max_ordinal_present();
1672            encoder.write_num(max_ordinal, offset);
1673            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1674            // Calling encoder.out_of_line_offset(0) is not allowed.
1675            if max_ordinal == 0 {
1676                return Ok(());
1677            }
1678            depth.increment()?;
1679            let envelope_size = 8;
1680            let bytes_len = max_ordinal as usize * envelope_size;
1681            #[allow(unused_variables)]
1682            let offset = encoder.out_of_line_offset(bytes_len);
1683            let mut _prev_end_offset: usize = 0;
1684            if 1 > max_ordinal {
1685                return Ok(());
1686            }
1687
1688            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1689            // are envelope_size bytes.
1690            let cur_offset: usize = (1 - 1) * envelope_size;
1691
1692            // Zero reserved fields.
1693            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1694
1695            // Safety:
1696            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1697            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1698            //   envelope_size bytes, there is always sufficient room.
1699            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_sys__common::Peer>, D>(
1700            self.peers.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_sys__common::Peer> as fidl::encoding::ValueTypeMarker>::borrow),
1701            encoder, offset + cur_offset, depth
1702        )?;
1703
1704            _prev_end_offset = cur_offset + envelope_size;
1705
1706            Ok(())
1707        }
1708    }
1709
1710    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1711        for PeerControllerGetKnownPeersResponse
1712    {
1713        #[inline(always)]
1714        fn new_empty() -> Self {
1715            Self::default()
1716        }
1717
1718        unsafe fn decode(
1719            &mut self,
1720            decoder: &mut fidl::encoding::Decoder<'_, D>,
1721            offset: usize,
1722            mut depth: fidl::encoding::Depth,
1723        ) -> fidl::Result<()> {
1724            decoder.debug_check_bounds::<Self>(offset);
1725            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1726                None => return Err(fidl::Error::NotNullable),
1727                Some(len) => len,
1728            };
1729            // Calling decoder.out_of_line_offset(0) is not allowed.
1730            if len == 0 {
1731                return Ok(());
1732            };
1733            depth.increment()?;
1734            let envelope_size = 8;
1735            let bytes_len = len * envelope_size;
1736            let offset = decoder.out_of_line_offset(bytes_len)?;
1737            // Decode the envelope for each type.
1738            let mut _next_ordinal_to_read = 0;
1739            let mut next_offset = offset;
1740            let end_offset = offset + bytes_len;
1741            _next_ordinal_to_read += 1;
1742            if next_offset >= end_offset {
1743                return Ok(());
1744            }
1745
1746            // Decode unknown envelopes for gaps in ordinals.
1747            while _next_ordinal_to_read < 1 {
1748                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1749                _next_ordinal_to_read += 1;
1750                next_offset += envelope_size;
1751            }
1752
1753            let next_out_of_line = decoder.next_out_of_line();
1754            let handles_before = decoder.remaining_handles();
1755            if let Some((inlined, num_bytes, num_handles)) =
1756                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1757            {
1758                let member_inline_size = <fidl::encoding::UnboundedVector<
1759                    fidl_fuchsia_bluetooth_sys__common::Peer,
1760                > as fidl::encoding::TypeMarker>::inline_size(
1761                    decoder.context
1762                );
1763                if inlined != (member_inline_size <= 4) {
1764                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1765                }
1766                let inner_offset;
1767                let mut inner_depth = depth.clone();
1768                if inlined {
1769                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1770                    inner_offset = next_offset;
1771                } else {
1772                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1773                    inner_depth.increment()?;
1774                }
1775                let val_ref = self.peers.get_or_insert_with(|| {
1776                    fidl::new_empty!(
1777                        fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_sys__common::Peer>,
1778                        D
1779                    )
1780                });
1781                fidl::decode!(
1782                    fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_sys__common::Peer>,
1783                    D,
1784                    val_ref,
1785                    decoder,
1786                    inner_offset,
1787                    inner_depth
1788                )?;
1789                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1790                {
1791                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1792                }
1793                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1794                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1795                }
1796            }
1797
1798            next_offset += envelope_size;
1799
1800            // Decode the remaining unknown envelopes.
1801            while next_offset < end_offset {
1802                _next_ordinal_to_read += 1;
1803                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1804                next_offset += envelope_size;
1805            }
1806
1807            Ok(())
1808        }
1809    }
1810
1811    impl PeerSelector {
1812        #[inline(always)]
1813        fn max_ordinal_present(&self) -> u64 {
1814            if let Some(_) = self.id {
1815                return 1;
1816            }
1817            0
1818        }
1819    }
1820
1821    impl fidl::encoding::ValueTypeMarker for PeerSelector {
1822        type Borrowed<'a> = &'a Self;
1823        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1824            value
1825        }
1826    }
1827
1828    unsafe impl fidl::encoding::TypeMarker for PeerSelector {
1829        type Owned = Self;
1830
1831        #[inline(always)]
1832        fn inline_align(_context: fidl::encoding::Context) -> usize {
1833            8
1834        }
1835
1836        #[inline(always)]
1837        fn inline_size(_context: fidl::encoding::Context) -> usize {
1838            16
1839        }
1840    }
1841
1842    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PeerSelector, D>
1843        for &PeerSelector
1844    {
1845        unsafe fn encode(
1846            self,
1847            encoder: &mut fidl::encoding::Encoder<'_, D>,
1848            offset: usize,
1849            mut depth: fidl::encoding::Depth,
1850        ) -> fidl::Result<()> {
1851            encoder.debug_check_bounds::<PeerSelector>(offset);
1852            // Vector header
1853            let max_ordinal: u64 = self.max_ordinal_present();
1854            encoder.write_num(max_ordinal, offset);
1855            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1856            // Calling encoder.out_of_line_offset(0) is not allowed.
1857            if max_ordinal == 0 {
1858                return Ok(());
1859            }
1860            depth.increment()?;
1861            let envelope_size = 8;
1862            let bytes_len = max_ordinal as usize * envelope_size;
1863            #[allow(unused_variables)]
1864            let offset = encoder.out_of_line_offset(bytes_len);
1865            let mut _prev_end_offset: usize = 0;
1866            if 1 > max_ordinal {
1867                return Ok(());
1868            }
1869
1870            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1871            // are envelope_size bytes.
1872            let cur_offset: usize = (1 - 1) * envelope_size;
1873
1874            // Zero reserved fields.
1875            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1876
1877            // Safety:
1878            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1879            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1880            //   envelope_size bytes, there is always sufficient room.
1881            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth__common::PeerId, D>(
1882            self.id.as_ref().map(<fidl_fuchsia_bluetooth__common::PeerId as fidl::encoding::ValueTypeMarker>::borrow),
1883            encoder, offset + cur_offset, depth
1884        )?;
1885
1886            _prev_end_offset = cur_offset + envelope_size;
1887
1888            Ok(())
1889        }
1890    }
1891
1892    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PeerSelector {
1893        #[inline(always)]
1894        fn new_empty() -> Self {
1895            Self::default()
1896        }
1897
1898        unsafe fn decode(
1899            &mut self,
1900            decoder: &mut fidl::encoding::Decoder<'_, D>,
1901            offset: usize,
1902            mut depth: fidl::encoding::Depth,
1903        ) -> fidl::Result<()> {
1904            decoder.debug_check_bounds::<Self>(offset);
1905            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1906                None => return Err(fidl::Error::NotNullable),
1907                Some(len) => len,
1908            };
1909            // Calling decoder.out_of_line_offset(0) is not allowed.
1910            if len == 0 {
1911                return Ok(());
1912            };
1913            depth.increment()?;
1914            let envelope_size = 8;
1915            let bytes_len = len * envelope_size;
1916            let offset = decoder.out_of_line_offset(bytes_len)?;
1917            // Decode the envelope for each type.
1918            let mut _next_ordinal_to_read = 0;
1919            let mut next_offset = offset;
1920            let end_offset = offset + bytes_len;
1921            _next_ordinal_to_read += 1;
1922            if next_offset >= end_offset {
1923                return Ok(());
1924            }
1925
1926            // Decode unknown envelopes for gaps in ordinals.
1927            while _next_ordinal_to_read < 1 {
1928                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1929                _next_ordinal_to_read += 1;
1930                next_offset += envelope_size;
1931            }
1932
1933            let next_out_of_line = decoder.next_out_of_line();
1934            let handles_before = decoder.remaining_handles();
1935            if let Some((inlined, num_bytes, num_handles)) =
1936                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1937            {
1938                let member_inline_size = <fidl_fuchsia_bluetooth__common::PeerId as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1939                if inlined != (member_inline_size <= 4) {
1940                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1941                }
1942                let inner_offset;
1943                let mut inner_depth = depth.clone();
1944                if inlined {
1945                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1946                    inner_offset = next_offset;
1947                } else {
1948                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1949                    inner_depth.increment()?;
1950                }
1951                let val_ref = self.id.get_or_insert_with(|| {
1952                    fidl::new_empty!(fidl_fuchsia_bluetooth__common::PeerId, D)
1953                });
1954                fidl::decode!(
1955                    fidl_fuchsia_bluetooth__common::PeerId,
1956                    D,
1957                    val_ref,
1958                    decoder,
1959                    inner_offset,
1960                    inner_depth
1961                )?;
1962                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1963                {
1964                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1965                }
1966                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1967                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1968                }
1969            }
1970
1971            next_offset += envelope_size;
1972
1973            // Decode the remaining unknown envelopes.
1974            while next_offset < end_offset {
1975                _next_ordinal_to_read += 1;
1976                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1977                next_offset += envelope_size;
1978            }
1979
1980            Ok(())
1981        }
1982    }
1983
1984    impl PeripheralControllerAdvertiseRequest {
1985        #[inline(always)]
1986        fn max_ordinal_present(&self) -> u64 {
1987            if let Some(_) = self.timeout {
1988                return 2;
1989            }
1990            if let Some(_) = self.parameters {
1991                return 1;
1992            }
1993            0
1994        }
1995    }
1996
1997    impl fidl::encoding::ValueTypeMarker for PeripheralControllerAdvertiseRequest {
1998        type Borrowed<'a> = &'a Self;
1999        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2000            value
2001        }
2002    }
2003
2004    unsafe impl fidl::encoding::TypeMarker for PeripheralControllerAdvertiseRequest {
2005        type Owned = Self;
2006
2007        #[inline(always)]
2008        fn inline_align(_context: fidl::encoding::Context) -> usize {
2009            8
2010        }
2011
2012        #[inline(always)]
2013        fn inline_size(_context: fidl::encoding::Context) -> usize {
2014            16
2015        }
2016    }
2017
2018    unsafe impl<D: fidl::encoding::ResourceDialect>
2019        fidl::encoding::Encode<PeripheralControllerAdvertiseRequest, D>
2020        for &PeripheralControllerAdvertiseRequest
2021    {
2022        unsafe fn encode(
2023            self,
2024            encoder: &mut fidl::encoding::Encoder<'_, D>,
2025            offset: usize,
2026            mut depth: fidl::encoding::Depth,
2027        ) -> fidl::Result<()> {
2028            encoder.debug_check_bounds::<PeripheralControllerAdvertiseRequest>(offset);
2029            // Vector header
2030            let max_ordinal: u64 = self.max_ordinal_present();
2031            encoder.write_num(max_ordinal, offset);
2032            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2033            // Calling encoder.out_of_line_offset(0) is not allowed.
2034            if max_ordinal == 0 {
2035                return Ok(());
2036            }
2037            depth.increment()?;
2038            let envelope_size = 8;
2039            let bytes_len = max_ordinal as usize * envelope_size;
2040            #[allow(unused_variables)]
2041            let offset = encoder.out_of_line_offset(bytes_len);
2042            let mut _prev_end_offset: usize = 0;
2043            if 1 > max_ordinal {
2044                return Ok(());
2045            }
2046
2047            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2048            // are envelope_size bytes.
2049            let cur_offset: usize = (1 - 1) * envelope_size;
2050
2051            // Zero reserved fields.
2052            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2053
2054            // Safety:
2055            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2056            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2057            //   envelope_size bytes, there is always sufficient room.
2058            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_le__common::AdvertisingParameters, D>(
2059            self.parameters.as_ref().map(<fidl_fuchsia_bluetooth_le__common::AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow),
2060            encoder, offset + cur_offset, depth
2061        )?;
2062
2063            _prev_end_offset = cur_offset + envelope_size;
2064            if 2 > max_ordinal {
2065                return Ok(());
2066            }
2067
2068            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2069            // are envelope_size bytes.
2070            let cur_offset: usize = (2 - 1) * envelope_size;
2071
2072            // Zero reserved fields.
2073            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2074
2075            // Safety:
2076            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2077            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2078            //   envelope_size bytes, there is always sufficient room.
2079            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2080                self.timeout.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2081                encoder,
2082                offset + cur_offset,
2083                depth,
2084            )?;
2085
2086            _prev_end_offset = cur_offset + envelope_size;
2087
2088            Ok(())
2089        }
2090    }
2091
2092    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2093        for PeripheralControllerAdvertiseRequest
2094    {
2095        #[inline(always)]
2096        fn new_empty() -> Self {
2097            Self::default()
2098        }
2099
2100        unsafe fn decode(
2101            &mut self,
2102            decoder: &mut fidl::encoding::Decoder<'_, D>,
2103            offset: usize,
2104            mut depth: fidl::encoding::Depth,
2105        ) -> fidl::Result<()> {
2106            decoder.debug_check_bounds::<Self>(offset);
2107            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2108                None => return Err(fidl::Error::NotNullable),
2109                Some(len) => len,
2110            };
2111            // Calling decoder.out_of_line_offset(0) is not allowed.
2112            if len == 0 {
2113                return Ok(());
2114            };
2115            depth.increment()?;
2116            let envelope_size = 8;
2117            let bytes_len = len * envelope_size;
2118            let offset = decoder.out_of_line_offset(bytes_len)?;
2119            // Decode the envelope for each type.
2120            let mut _next_ordinal_to_read = 0;
2121            let mut next_offset = offset;
2122            let end_offset = offset + bytes_len;
2123            _next_ordinal_to_read += 1;
2124            if next_offset >= end_offset {
2125                return Ok(());
2126            }
2127
2128            // Decode unknown envelopes for gaps in ordinals.
2129            while _next_ordinal_to_read < 1 {
2130                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2131                _next_ordinal_to_read += 1;
2132                next_offset += envelope_size;
2133            }
2134
2135            let next_out_of_line = decoder.next_out_of_line();
2136            let handles_before = decoder.remaining_handles();
2137            if let Some((inlined, num_bytes, num_handles)) =
2138                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2139            {
2140                let member_inline_size = <fidl_fuchsia_bluetooth_le__common::AdvertisingParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2141                if inlined != (member_inline_size <= 4) {
2142                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2143                }
2144                let inner_offset;
2145                let mut inner_depth = depth.clone();
2146                if inlined {
2147                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2148                    inner_offset = next_offset;
2149                } else {
2150                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2151                    inner_depth.increment()?;
2152                }
2153                let val_ref = self.parameters.get_or_insert_with(|| {
2154                    fidl::new_empty!(fidl_fuchsia_bluetooth_le__common::AdvertisingParameters, D)
2155                });
2156                fidl::decode!(
2157                    fidl_fuchsia_bluetooth_le__common::AdvertisingParameters,
2158                    D,
2159                    val_ref,
2160                    decoder,
2161                    inner_offset,
2162                    inner_depth
2163                )?;
2164                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2165                {
2166                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2167                }
2168                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2169                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2170                }
2171            }
2172
2173            next_offset += envelope_size;
2174            _next_ordinal_to_read += 1;
2175            if next_offset >= end_offset {
2176                return Ok(());
2177            }
2178
2179            // Decode unknown envelopes for gaps in ordinals.
2180            while _next_ordinal_to_read < 2 {
2181                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2182                _next_ordinal_to_read += 1;
2183                next_offset += envelope_size;
2184            }
2185
2186            let next_out_of_line = decoder.next_out_of_line();
2187            let handles_before = decoder.remaining_handles();
2188            if let Some((inlined, num_bytes, num_handles)) =
2189                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2190            {
2191                let member_inline_size =
2192                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2193                if inlined != (member_inline_size <= 4) {
2194                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2195                }
2196                let inner_offset;
2197                let mut inner_depth = depth.clone();
2198                if inlined {
2199                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2200                    inner_offset = next_offset;
2201                } else {
2202                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2203                    inner_depth.increment()?;
2204                }
2205                let val_ref = self.timeout.get_or_insert_with(|| fidl::new_empty!(u64, D));
2206                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2207                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2208                {
2209                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2210                }
2211                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2212                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2213                }
2214            }
2215
2216            next_offset += envelope_size;
2217
2218            // Decode the remaining unknown envelopes.
2219            while next_offset < end_offset {
2220                _next_ordinal_to_read += 1;
2221                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2222                next_offset += envelope_size;
2223            }
2224
2225            Ok(())
2226        }
2227    }
2228
2229    impl PeripheralControllerAdvertiseResponse {
2230        #[inline(always)]
2231        fn max_ordinal_present(&self) -> u64 {
2232            if let Some(_) = self.peer_id {
2233                return 1;
2234            }
2235            0
2236        }
2237    }
2238
2239    impl fidl::encoding::ValueTypeMarker for PeripheralControllerAdvertiseResponse {
2240        type Borrowed<'a> = &'a Self;
2241        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2242            value
2243        }
2244    }
2245
2246    unsafe impl fidl::encoding::TypeMarker for PeripheralControllerAdvertiseResponse {
2247        type Owned = Self;
2248
2249        #[inline(always)]
2250        fn inline_align(_context: fidl::encoding::Context) -> usize {
2251            8
2252        }
2253
2254        #[inline(always)]
2255        fn inline_size(_context: fidl::encoding::Context) -> usize {
2256            16
2257        }
2258    }
2259
2260    unsafe impl<D: fidl::encoding::ResourceDialect>
2261        fidl::encoding::Encode<PeripheralControllerAdvertiseResponse, D>
2262        for &PeripheralControllerAdvertiseResponse
2263    {
2264        unsafe fn encode(
2265            self,
2266            encoder: &mut fidl::encoding::Encoder<'_, D>,
2267            offset: usize,
2268            mut depth: fidl::encoding::Depth,
2269        ) -> fidl::Result<()> {
2270            encoder.debug_check_bounds::<PeripheralControllerAdvertiseResponse>(offset);
2271            // Vector header
2272            let max_ordinal: u64 = self.max_ordinal_present();
2273            encoder.write_num(max_ordinal, offset);
2274            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2275            // Calling encoder.out_of_line_offset(0) is not allowed.
2276            if max_ordinal == 0 {
2277                return Ok(());
2278            }
2279            depth.increment()?;
2280            let envelope_size = 8;
2281            let bytes_len = max_ordinal as usize * envelope_size;
2282            #[allow(unused_variables)]
2283            let offset = encoder.out_of_line_offset(bytes_len);
2284            let mut _prev_end_offset: usize = 0;
2285            if 1 > max_ordinal {
2286                return Ok(());
2287            }
2288
2289            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2290            // are envelope_size bytes.
2291            let cur_offset: usize = (1 - 1) * envelope_size;
2292
2293            // Zero reserved fields.
2294            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2295
2296            // Safety:
2297            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2298            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2299            //   envelope_size bytes, there is always sufficient room.
2300            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth__common::PeerId, D>(
2301            self.peer_id.as_ref().map(<fidl_fuchsia_bluetooth__common::PeerId as fidl::encoding::ValueTypeMarker>::borrow),
2302            encoder, offset + cur_offset, depth
2303        )?;
2304
2305            _prev_end_offset = cur_offset + envelope_size;
2306
2307            Ok(())
2308        }
2309    }
2310
2311    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2312        for PeripheralControllerAdvertiseResponse
2313    {
2314        #[inline(always)]
2315        fn new_empty() -> Self {
2316            Self::default()
2317        }
2318
2319        unsafe fn decode(
2320            &mut self,
2321            decoder: &mut fidl::encoding::Decoder<'_, D>,
2322            offset: usize,
2323            mut depth: fidl::encoding::Depth,
2324        ) -> fidl::Result<()> {
2325            decoder.debug_check_bounds::<Self>(offset);
2326            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2327                None => return Err(fidl::Error::NotNullable),
2328                Some(len) => len,
2329            };
2330            // Calling decoder.out_of_line_offset(0) is not allowed.
2331            if len == 0 {
2332                return Ok(());
2333            };
2334            depth.increment()?;
2335            let envelope_size = 8;
2336            let bytes_len = len * envelope_size;
2337            let offset = decoder.out_of_line_offset(bytes_len)?;
2338            // Decode the envelope for each type.
2339            let mut _next_ordinal_to_read = 0;
2340            let mut next_offset = offset;
2341            let end_offset = offset + bytes_len;
2342            _next_ordinal_to_read += 1;
2343            if next_offset >= end_offset {
2344                return Ok(());
2345            }
2346
2347            // Decode unknown envelopes for gaps in ordinals.
2348            while _next_ordinal_to_read < 1 {
2349                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2350                _next_ordinal_to_read += 1;
2351                next_offset += envelope_size;
2352            }
2353
2354            let next_out_of_line = decoder.next_out_of_line();
2355            let handles_before = decoder.remaining_handles();
2356            if let Some((inlined, num_bytes, num_handles)) =
2357                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2358            {
2359                let member_inline_size = <fidl_fuchsia_bluetooth__common::PeerId as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2360                if inlined != (member_inline_size <= 4) {
2361                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2362                }
2363                let inner_offset;
2364                let mut inner_depth = depth.clone();
2365                if inlined {
2366                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2367                    inner_offset = next_offset;
2368                } else {
2369                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2370                    inner_depth.increment()?;
2371                }
2372                let val_ref = self.peer_id.get_or_insert_with(|| {
2373                    fidl::new_empty!(fidl_fuchsia_bluetooth__common::PeerId, D)
2374                });
2375                fidl::decode!(
2376                    fidl_fuchsia_bluetooth__common::PeerId,
2377                    D,
2378                    val_ref,
2379                    decoder,
2380                    inner_offset,
2381                    inner_depth
2382                )?;
2383                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2384                {
2385                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2386                }
2387                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2388                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2389                }
2390            }
2391
2392            next_offset += envelope_size;
2393
2394            // Decode the remaining unknown envelopes.
2395            while next_offset < end_offset {
2396                _next_ordinal_to_read += 1;
2397                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2398                next_offset += envelope_size;
2399            }
2400
2401            Ok(())
2402        }
2403    }
2404}