Skip to main content

fidl_fuchsia_bluetooth_gatt2_common/
fidl_fuchsia_bluetooth_gatt2_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/// The amount of credits defined to be available for sending indications/notifications when a
12/// LocalService is first published.
13pub const INITIAL_VALUE_CHANGED_CREDITS: u32 = 10;
14
15pub const MAX_ATTRIBUTE_COUNT: u16 = 65535;
16
17pub const MAX_CHARACTERISTIC_COUNT: u16 = 32767;
18
19pub const MAX_DESCRIPTOR_COUNT: u16 = 65532;
20
21pub const MAX_SERVICE_COUNT: u16 = MAX_ATTRIBUTE_COUNT as u16;
22
23pub const MAX_VALUE_LENGTH: u16 = 512;
24
25bitflags! {
26    /// Possible values for the characteristic properties bitfield. These specify the
27    /// GATT procedures that are allowed for a particular characteristic.
28    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
29    pub struct CharacteristicPropertyBits: u16 {
30        const BROADCAST = 1;
31        const READ = 2;
32        const WRITE_WITHOUT_RESPONSE = 4;
33        const WRITE = 8;
34        const NOTIFY = 16;
35        const INDICATE = 32;
36        const AUTHENTICATED_SIGNED_WRITES = 64;
37        const RELIABLE_WRITE = 256;
38        const WRITABLE_AUXILIARIES = 512;
39    }
40}
41
42impl CharacteristicPropertyBits {}
43
44/// Errors that are returned by bluetooth.gatt2.* methods.
45///
46/// The values correspond with those in Bluetooth 5.2 Vol. 3 Part G Table 3.4,
47/// and Supplement to the Bluetooth Core Specification v9 Part B Table 1.1,
48/// but this is for ease of reference only.  Clients should *not* rely on these
49/// values remaining constant.  Omitted values from the spec are handled
50/// internally and will not be returned to clients.
51///
52/// Only certain errors can be returned by LocalService methods.  Those are noted
53/// in comments.
54#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
55#[repr(u32)]
56pub enum Error {
57    /// The attribute indicated by the handle is invalid. It may have been removed.
58    ///
59    /// This may be returned by a LocalService method.
60    InvalidHandle = 1,
61    /// This attribute is not readable.
62    ReadNotPermitted = 2,
63    /// This attribute is not writable.
64    WriteNotPermitted = 3,
65    /// Indicates that the response received from the server was invalid.
66    InvalidPdu = 4,
67    /// This attribute requires authentication, but the client is not authenticated.
68    InsufficientAuthentication = 5,
69    /// Indicates that the offset used in a read or write request exceeds the
70    /// bounds of the value.
71    ///
72    /// This may be returned by a LocalService method.
73    InvalidOffset = 7,
74    /// This attribute requires authorization, but the client is not authorized.
75    InsufficientAuthorization = 8,
76    /// This attribute requires a connection encrypted by a larger encryption key.
77    InsufficientEncryptionKeySize = 12,
78    /// Indicates that the value given in a write request would exceed the maximum
79    /// length allowed for the destionation characteristic or descriptor.
80    ///
81    /// This may be returned by a LocalService method.
82    InvalidAttributeValueLength = 13,
83    /// A general error occurred that can not be classified as one of the more
84    /// specific errors.
85    ///
86    /// This may be returned by a LocalService method.
87    UnlikelyError = 14,
88    /// This attribute requires encryption, but the connection is not encrypted.
89    InsufficientEncryption = 15,
90    /// The server had insufficient resources to complete the task.
91    ///
92    /// This may be returned by a LocalService method.
93    InsufficientResources = 17,
94    /// The value was not allowed.
95    ///
96    /// This may be returned by a LocalService method.
97    ValueNotAllowed = 19,
98    /// Application Errors.  The uses of these are specified at the application
99    /// level.
100    ///
101    /// These may all be returned by a LocalService method.
102    ApplicationError80 = 128,
103    ApplicationError81 = 129,
104    ApplicationError82 = 130,
105    ApplicationError83 = 131,
106    ApplicationError84 = 132,
107    ApplicationError85 = 133,
108    ApplicationError86 = 134,
109    ApplicationError87 = 135,
110    ApplicationError88 = 136,
111    ApplicationError89 = 137,
112    ApplicationError8A = 138,
113    ApplicationError8B = 139,
114    ApplicationError8C = 140,
115    ApplicationError8D = 141,
116    ApplicationError8E = 142,
117    ApplicationError8F = 143,
118    ApplicationError90 = 144,
119    ApplicationError91 = 145,
120    ApplicationError92 = 146,
121    ApplicationError93 = 147,
122    ApplicationError94 = 148,
123    ApplicationError95 = 149,
124    ApplicationError96 = 150,
125    ApplicationError97 = 151,
126    ApplicationError98 = 152,
127    ApplicationError99 = 153,
128    ApplicationError9A = 154,
129    ApplicationError9B = 155,
130    ApplicationError9C = 156,
131    ApplicationError9D = 157,
132    ApplicationError9E = 158,
133    ApplicationError9F = 159,
134    /// Write request was rejected at the profile or service level.
135    WriteRequestRejected = 252,
136    /// The Client Characteristic Configuration Descriptor was improperly
137    /// configured.
138    CccDescriptorImproperlyConfigured = 253,
139    /// Profile or service procedure already in progress.
140    ProcedureAlreadyInProgress = 254,
141    /// A value was out of range at the profile or service level.
142    OutOfRange = 255,
143    /// One or more of the FIDL call parameters are invalid. See the parameter
144    /// documentation.
145    InvalidParameters = 257,
146    /// Indicates that more results were read than can fit in a FIDL response.
147    /// Consider reading attributes individually.
148    TooManyResults = 258,
149}
150
151impl Error {
152    #[inline]
153    pub fn from_primitive(prim: u32) -> Option<Self> {
154        match prim {
155            1 => Some(Self::InvalidHandle),
156            2 => Some(Self::ReadNotPermitted),
157            3 => Some(Self::WriteNotPermitted),
158            4 => Some(Self::InvalidPdu),
159            5 => Some(Self::InsufficientAuthentication),
160            7 => Some(Self::InvalidOffset),
161            8 => Some(Self::InsufficientAuthorization),
162            12 => Some(Self::InsufficientEncryptionKeySize),
163            13 => Some(Self::InvalidAttributeValueLength),
164            14 => Some(Self::UnlikelyError),
165            15 => Some(Self::InsufficientEncryption),
166            17 => Some(Self::InsufficientResources),
167            19 => Some(Self::ValueNotAllowed),
168            128 => Some(Self::ApplicationError80),
169            129 => Some(Self::ApplicationError81),
170            130 => Some(Self::ApplicationError82),
171            131 => Some(Self::ApplicationError83),
172            132 => Some(Self::ApplicationError84),
173            133 => Some(Self::ApplicationError85),
174            134 => Some(Self::ApplicationError86),
175            135 => Some(Self::ApplicationError87),
176            136 => Some(Self::ApplicationError88),
177            137 => Some(Self::ApplicationError89),
178            138 => Some(Self::ApplicationError8A),
179            139 => Some(Self::ApplicationError8B),
180            140 => Some(Self::ApplicationError8C),
181            141 => Some(Self::ApplicationError8D),
182            142 => Some(Self::ApplicationError8E),
183            143 => Some(Self::ApplicationError8F),
184            144 => Some(Self::ApplicationError90),
185            145 => Some(Self::ApplicationError91),
186            146 => Some(Self::ApplicationError92),
187            147 => Some(Self::ApplicationError93),
188            148 => Some(Self::ApplicationError94),
189            149 => Some(Self::ApplicationError95),
190            150 => Some(Self::ApplicationError96),
191            151 => Some(Self::ApplicationError97),
192            152 => Some(Self::ApplicationError98),
193            153 => Some(Self::ApplicationError99),
194            154 => Some(Self::ApplicationError9A),
195            155 => Some(Self::ApplicationError9B),
196            156 => Some(Self::ApplicationError9C),
197            157 => Some(Self::ApplicationError9D),
198            158 => Some(Self::ApplicationError9E),
199            159 => Some(Self::ApplicationError9F),
200            252 => Some(Self::WriteRequestRejected),
201            253 => Some(Self::CccDescriptorImproperlyConfigured),
202            254 => Some(Self::ProcedureAlreadyInProgress),
203            255 => Some(Self::OutOfRange),
204            257 => Some(Self::InvalidParameters),
205            258 => Some(Self::TooManyResults),
206            _ => None,
207        }
208    }
209
210    #[inline]
211    pub const fn into_primitive(self) -> u32 {
212        self as u32
213    }
214}
215
216/// Errors that can occur during service publication.
217#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
218pub enum PublishServiceError {
219    /// The service handle is invalid or already in use on the Server publishing the service.
220    InvalidServiceHandle,
221    /// Invalid service UUID provided.
222    InvalidUuid,
223    /// The `ServiceInfo.characteristics` field was formatted invalidly or missing. If the service
224    /// is meant to be empty, the vector should be empty, but present.
225    InvalidCharacteristics,
226    /// A general error occurred that can not be classified as one of the more specific errors.
227    UnlikelyError,
228    #[doc(hidden)]
229    __SourceBreaking { unknown_ordinal: u32 },
230}
231
232/// Pattern that matches an unknown `PublishServiceError` member.
233#[macro_export]
234macro_rules! PublishServiceErrorUnknown {
235    () => {
236        _
237    };
238}
239
240impl PublishServiceError {
241    #[inline]
242    pub fn from_primitive(prim: u32) -> Option<Self> {
243        match prim {
244            1 => Some(Self::InvalidServiceHandle),
245            2 => Some(Self::InvalidUuid),
246            3 => Some(Self::InvalidCharacteristics),
247            4 => Some(Self::UnlikelyError),
248            _ => None,
249        }
250    }
251
252    #[inline]
253    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
254        match prim {
255            1 => Self::InvalidServiceHandle,
256            2 => Self::InvalidUuid,
257            3 => Self::InvalidCharacteristics,
258            4 => Self::UnlikelyError,
259            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
260        }
261    }
262
263    #[inline]
264    pub fn unknown() -> Self {
265        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
266    }
267
268    #[inline]
269    pub const fn into_primitive(self) -> u32 {
270        match self {
271            Self::InvalidServiceHandle => 1,
272            Self::InvalidUuid => 2,
273            Self::InvalidCharacteristics => 3,
274            Self::UnlikelyError => 4,
275            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
276        }
277    }
278
279    #[inline]
280    pub fn is_unknown(&self) -> bool {
281        match self {
282            Self::__SourceBreaking { unknown_ordinal: _ } => true,
283            _ => false,
284        }
285    }
286}
287
288/// The kind ("type") of a GATT Service as outlined in Bluetooth Core Spec v5.3 Vol. 1 Part A 6.5.1.
289#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
290#[repr(u32)]
291pub enum ServiceKind {
292    /// A "service that provides functionality of a device that can be used on its own" (Ibid)
293    Primary = 1,
294    /// A "service that provides additional functionality [...] in association with a primary
295    /// service and is included from at least one primary service" (Ibid)
296    Secondary = 2,
297}
298
299impl ServiceKind {
300    #[inline]
301    pub fn from_primitive(prim: u32) -> Option<Self> {
302        match prim {
303            1 => Some(Self::Primary),
304            2 => Some(Self::Secondary),
305            _ => None,
306        }
307    }
308
309    #[inline]
310    pub const fn into_primitive(self) -> u32 {
311        self as u32
312    }
313}
314
315/// Represents the supported write modes for writing characteristics &
316/// descriptors to the server.
317#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
318pub enum WriteMode {
319    /// In `DEFAULT` mode, wait for a response from the server before returning
320    /// and do not verify the echo response.
321    /// Supported for both characteristics and descriptors.
322    Default,
323    /// In `RELIABLE` mode, every value blob is verified against an echo
324    /// response from the server. The procedure is aborted if a value blob has
325    /// not been reliably delivered to the peer.
326    /// Only supported for characteristics.
327    Reliable,
328    /// In `WITHOUT_RESPONSE` mode, delivery will not be confirmed before
329    /// returning. Writing without a response is only supported for short
330    /// characteristics with the `WRITE_WITHOUT_RESPONSE` property. The value
331    /// must fit into a single message. It is guaranteed that at least 20 bytes
332    /// will fit into a single message. If the value does not fit, a `FAILURE`
333    /// error will be produced. The value will be written at offset 0.
334    /// Only supported for characteristics.
335    WithoutResponse,
336    #[doc(hidden)]
337    __SourceBreaking { unknown_ordinal: u32 },
338}
339
340/// Pattern that matches an unknown `WriteMode` member.
341#[macro_export]
342macro_rules! WriteModeUnknown {
343    () => {
344        _
345    };
346}
347
348impl WriteMode {
349    #[inline]
350    pub fn from_primitive(prim: u32) -> Option<Self> {
351        match prim {
352            1 => Some(Self::Default),
353            2 => Some(Self::Reliable),
354            3 => Some(Self::WithoutResponse),
355            _ => None,
356        }
357    }
358
359    #[inline]
360    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
361        match prim {
362            1 => Self::Default,
363            2 => Self::Reliable,
364            3 => Self::WithoutResponse,
365            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
366        }
367    }
368
369    #[inline]
370    pub fn unknown() -> Self {
371        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
372    }
373
374    #[inline]
375    pub const fn into_primitive(self) -> u32 {
376        match self {
377            Self::Default => 1,
378            Self::Reliable => 2,
379            Self::WithoutResponse => 3,
380            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
381        }
382    }
383
384    #[inline]
385    pub fn is_unknown(&self) -> bool {
386        match self {
387            Self::__SourceBreaking { unknown_ordinal: _ } => true,
388            _ => false,
389        }
390    }
391}
392
393#[derive(Clone, Debug, PartialEq)]
394pub struct CharacteristicNotifierOnNotificationRequest {
395    pub value: ReadValue,
396}
397
398impl fidl::Persistable for CharacteristicNotifierOnNotificationRequest {}
399
400#[derive(Clone, Debug, PartialEq)]
401pub struct ClientWatchServicesRequest {
402    pub uuids: Vec<fidl_fuchsia_bluetooth_common::Uuid>,
403}
404
405impl fidl::Persistable for ClientWatchServicesRequest {}
406
407#[derive(Clone, Debug, PartialEq)]
408pub struct ClientWatchServicesResponse {
409    pub updated: Vec<ServiceInfo>,
410    pub removed: Vec<Handle>,
411}
412
413impl fidl::Persistable for ClientWatchServicesResponse {}
414
415#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
416#[repr(C)]
417pub struct Handle {
418    pub value: u64,
419}
420
421impl fidl::Persistable for Handle {}
422
423#[derive(Clone, Debug, PartialEq)]
424pub struct LocalServiceCharacteristicConfigurationRequest {
425    pub peer_id: fidl_fuchsia_bluetooth_common::PeerId,
426    pub handle: Handle,
427    pub notify: bool,
428    pub indicate: bool,
429}
430
431impl fidl::Persistable for LocalServiceCharacteristicConfigurationRequest {}
432
433#[derive(Clone, Debug, PartialEq)]
434pub struct LocalServiceReadValueRequest {
435    pub peer_id: fidl_fuchsia_bluetooth_common::PeerId,
436    pub handle: Handle,
437    pub offset: i32,
438}
439
440impl fidl::Persistable for LocalServiceReadValueRequest {}
441
442#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
443#[repr(C)]
444pub struct LocalServiceValueChangedCreditRequest {
445    pub additional_credit: u8,
446}
447
448impl fidl::Persistable for LocalServiceValueChangedCreditRequest {}
449
450#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
451pub struct LocalServiceReadValueResponse {
452    pub value: Vec<u8>,
453}
454
455impl fidl::Persistable for LocalServiceReadValueResponse {}
456
457#[derive(Clone, Debug, PartialEq)]
458pub struct RemoteServiceDiscoverCharacteristicsResponse {
459    pub characteristics: Vec<Characteristic>,
460}
461
462impl fidl::Persistable for RemoteServiceDiscoverCharacteristicsResponse {}
463
464#[derive(Clone, Debug, PartialEq)]
465pub struct RemoteServiceReadByTypeRequest {
466    pub uuid: fidl_fuchsia_bluetooth_common::Uuid,
467}
468
469impl fidl::Persistable for RemoteServiceReadByTypeRequest {}
470
471#[derive(Clone, Debug, PartialEq)]
472pub struct RemoteServiceReadCharacteristicRequest {
473    pub handle: Handle,
474    pub options: ReadOptions,
475}
476
477impl fidl::Persistable for RemoteServiceReadCharacteristicRequest {}
478
479#[derive(Clone, Debug, PartialEq)]
480pub struct RemoteServiceReadDescriptorRequest {
481    pub handle: Handle,
482    pub options: ReadOptions,
483}
484
485impl fidl::Persistable for RemoteServiceReadDescriptorRequest {}
486
487#[derive(Clone, Debug, PartialEq)]
488pub struct RemoteServiceWriteCharacteristicRequest {
489    pub handle: Handle,
490    pub value: Vec<u8>,
491    pub options: WriteOptions,
492}
493
494impl fidl::Persistable for RemoteServiceWriteCharacteristicRequest {}
495
496#[derive(Clone, Debug, PartialEq)]
497pub struct RemoteServiceWriteDescriptorRequest {
498    pub handle: Handle,
499    pub value: Vec<u8>,
500    pub options: WriteOptions,
501}
502
503impl fidl::Persistable for RemoteServiceWriteDescriptorRequest {}
504
505#[derive(Clone, Debug, PartialEq)]
506pub struct RemoteServiceReadByTypeResponse {
507    pub results: Vec<ReadByTypeResult>,
508}
509
510impl fidl::Persistable for RemoteServiceReadByTypeResponse {}
511
512#[derive(Clone, Debug, PartialEq)]
513pub struct RemoteServiceReadCharacteristicResponse {
514    pub value: ReadValue,
515}
516
517impl fidl::Persistable for RemoteServiceReadCharacteristicResponse {}
518
519#[derive(Clone, Debug, PartialEq)]
520pub struct RemoteServiceReadDescriptorResponse {
521    pub value: ReadValue,
522}
523
524impl fidl::Persistable for RemoteServiceReadDescriptorResponse {}
525
526#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
527#[repr(C)]
528pub struct ServiceHandle {
529    pub value: u64,
530}
531
532impl fidl::Persistable for ServiceHandle {}
533
534/// Represents the options for reading a short characteristic or descriptor
535/// value from a server. Short values are those that fit in a single message,
536/// which is at least 22 bytes. This is an empty placeholder for now, as there
537/// are no options.
538#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
539pub struct ShortReadOptions;
540
541impl fidl::Persistable for ShortReadOptions {}
542
543/// Specifies the access permissions for a specific attribute value.
544#[derive(Clone, Debug, Default, PartialEq)]
545pub struct AttributePermissions {
546    /// Specifies whether an attribute has the read permission. If not present,
547    /// the attribute value cannot be read. Otherwise, it can be read only if the
548    /// permissions specified in the SecurityRequirements table are satisfied.
549    pub read: Option<SecurityRequirements>,
550    /// Specifies whether an attribute has the write permission. If not present,
551    /// the attribute value cannot be written. Otherwise, it can be written only
552    /// if the permissions specified in the SecurityRequirements table are satisfied.
553    pub write: Option<SecurityRequirements>,
554    /// Specifies the security requirements for a client to subscribe to
555    /// notifications or indications on a characteristic. A characteristic's
556    /// support for notifications or indiciations is specified using the NOTIFY and
557    /// INDICATE characteristic properties. If a local characteristic has one of
558    /// these properties then this field must be present. Otherwise, this field
559    /// must not be present.
560    ///
561    /// This field is ignored for Descriptors.
562    pub update: Option<SecurityRequirements>,
563    #[doc(hidden)]
564    pub __source_breaking: fidl::marker::SourceBreaking,
565}
566
567impl fidl::Persistable for AttributePermissions {}
568
569/// Represents a local or remote GATT characteristic.
570#[derive(Clone, Debug, Default, PartialEq)]
571pub struct Characteristic {
572    /// Uniquely identifies this characteristic within a service.
573    /// For local characteristics, the specified handle must be unique across
574    /// all characteristic and descriptor handles in this service.
575    ///
576    /// Always present. For local characteristics, this value is mandatory.
577    pub handle: Option<Handle>,
578    /// The UUID that identifies the type of this characteristic.
579    /// Always present. Mandatory for local characteristics.
580    pub type_: Option<fidl_fuchsia_bluetooth_common::Uuid>,
581    /// The characteristic properties bitfield.
582    /// Always present. Mandatory for local characteristics.
583    pub properties: Option<CharacteristicPropertyBits>,
584    /// The attribute permissions of this characteristic. For remote
585    /// characteristics, this value will not be present until the permissions are
586    /// discovered via read and write requests.
587    ///
588    /// For local characteristics, this value is mandatory.
589    pub permissions: Option<AttributePermissions>,
590    /// The descriptors of this characteristic.
591    /// Present only if non-empty. Optional for local characteristics.
592    pub descriptors: Option<Vec<Descriptor>>,
593    #[doc(hidden)]
594    pub __source_breaking: fidl::marker::SourceBreaking,
595}
596
597impl fidl::Persistable for Characteristic {}
598
599/// Represents a local or remote GATT characteristic descriptor.
600#[derive(Clone, Debug, Default, PartialEq)]
601pub struct Descriptor {
602    /// Uniquely identifies this descriptor within a service.
603    /// For local descriptors, the specified handle must be unique
604    /// across all characteristic and descriptor handles in this service.
605    ///
606    /// Always present. For local descriptors, this value is mandatory.
607    pub handle: Option<Handle>,
608    /// The UUID that identifies the type of this descriptor.
609    /// Always present. For local descriptors, this value is mandatory.
610    pub type_: Option<fidl_fuchsia_bluetooth_common::Uuid>,
611    /// The attribute permissions of this descriptor. For remote
612    /// descriptors, this value will not be present until the permissions are
613    /// discovered via read and write requests.
614    ///
615    /// For local descriptors, this value is mandatory.
616    pub permissions: Option<AttributePermissions>,
617    #[doc(hidden)]
618    pub __source_breaking: fidl::marker::SourceBreaking,
619}
620
621impl fidl::Persistable for Descriptor {}
622
623#[derive(Clone, Debug, Default, PartialEq)]
624pub struct LocalServicePeerUpdateRequest {
625    pub peer_id: Option<fidl_fuchsia_bluetooth_common::PeerId>,
626    pub mtu: Option<u16>,
627    #[doc(hidden)]
628    pub __source_breaking: fidl::marker::SourceBreaking,
629}
630
631impl fidl::Persistable for LocalServicePeerUpdateRequest {}
632
633#[derive(Clone, Debug, Default, PartialEq)]
634pub struct LocalServiceWriteValueRequest {
635    pub peer_id: Option<fidl_fuchsia_bluetooth_common::PeerId>,
636    pub handle: Option<Handle>,
637    pub offset: Option<u32>,
638    pub value: Option<Vec<u8>>,
639    #[doc(hidden)]
640    pub __source_breaking: fidl::marker::SourceBreaking,
641}
642
643impl fidl::Persistable for LocalServiceWriteValueRequest {}
644
645/// Represents the supported options to read a long characteristic or descriptor
646/// value from a server. Long values are those that may not fit in a single
647/// message (longer than 22 bytes).
648#[derive(Clone, Debug, Default, PartialEq)]
649pub struct LongReadOptions {
650    /// The byte to start the read at. Must be less than the length of the value.
651    /// Optional.
652    /// Default: 0
653    pub offset: Option<u16>,
654    /// The maximum number of bytes to read.
655    /// Optional.
656    /// Default: `MAX_VALUE_LENGTH`
657    pub max_bytes: Option<u16>,
658    #[doc(hidden)]
659    pub __source_breaking: fidl::marker::SourceBreaking,
660}
661
662impl fidl::Persistable for LongReadOptions {}
663
664/// A result returned by `RemoteService.ReadByType`.
665#[derive(Clone, Debug, Default, PartialEq)]
666pub struct ReadByTypeResult {
667    /// Characteristic or descriptor handle.
668    pub handle: Option<Handle>,
669    /// The value of the characteristic or descriptor, if it was read successfully.
670    pub value: Option<ReadValue>,
671    /// Reason the value could not be read, if reading it resulted in an error.
672    pub error: Option<Error>,
673    #[doc(hidden)]
674    pub __source_breaking: fidl::marker::SourceBreaking,
675}
676
677impl fidl::Persistable for ReadByTypeResult {}
678
679/// Wrapper around a possible truncated value received from the server.
680#[derive(Clone, Debug, Default, PartialEq)]
681pub struct ReadValue {
682    /// Characteristic or descriptor handle. Always present.
683    pub handle: Option<Handle>,
684    /// The value of the characteristic or descriptor. Always present.
685    pub value: Option<Vec<u8>>,
686    /// True if `value` might be truncated (the buffer was completely filled
687    /// by the server). `ReadCharacteristic` or `ReadDescriptor` should be used
688    /// to read the complete value.
689    /// Always present.
690    pub maybe_truncated: Option<bool>,
691    #[doc(hidden)]
692    pub __source_breaking: fidl::marker::SourceBreaking,
693}
694
695impl fidl::Persistable for ReadValue {}
696
697/// Represents encryption, authentication, and authorization permissions that can
698/// be assigned to a specific access permission.
699#[derive(Clone, Debug, Default, PartialEq)]
700pub struct SecurityRequirements {
701    /// If true, the physical link must be encrypted to access this attribute. If not present or
702    /// false, this attribute permits unencrypted access.
703    pub encryption_required: Option<bool>,
704    /// If true, the physical link must be authenticated to access this attribute. If not present or
705    /// false, this attribute permits unauthenticated access.
706    pub authentication_required: Option<bool>,
707    /// If true, the client needs to be authorized to access this attribute. If not present or
708    /// false, this attribute permits access without authorization.
709    pub authorization_required: Option<bool>,
710    #[doc(hidden)]
711    pub __source_breaking: fidl::marker::SourceBreaking,
712}
713
714impl fidl::Persistable for SecurityRequirements {}
715
716/// Represents a local or remote GATT service.
717#[derive(Clone, Debug, Default, PartialEq)]
718pub struct ServiceInfo {
719    /// Unique identifier for this GATT service.
720    /// Always present if this represents a remote service, in which case this is unique across the
721    /// Client that returned this ServiceInfo.
722    /// Required for local services, in which case this must be unique across all services published
723    /// to a single Server instance. Can be used in the `ServiceInfo.includes` of other
724    /// PublishService calls to the Server where this service is published.
725    pub handle: Option<ServiceHandle>,
726    /// Indicates whether this is a primary or secondary service.
727    /// Always present for remote services. Optional for local services
728    /// Default: ServiceKind::PRIMARY
729    pub kind: Option<ServiceKind>,
730    /// The UUID that identifies the type of this service.
731    /// There may be multiple services with the same UUID.
732    /// Always present for remote services. Required for local services.
733    pub type_: Option<fidl_fuchsia_bluetooth_common::Uuid>,
734    /// The characteristics of this service.
735    /// Required for local services. Never present for remote services.
736    pub characteristics: Option<Vec<Characteristic>>,
737    /// Handles of other services that are included by this service.
738    /// Optional for local services. Never present for remote services.
739    /// TODO(https://fxbug.dev/42147529): This is not currently supported for local services.
740    pub includes: Option<Vec<ServiceHandle>>,
741    #[doc(hidden)]
742    pub __source_breaking: fidl::marker::SourceBreaking,
743}
744
745impl fidl::Persistable for ServiceInfo {}
746
747/// The parameters used to signal a characteristic value change from a LocalService to a peer.
748#[derive(Clone, Debug, Default, PartialEq)]
749pub struct ValueChangedParameters {
750    /// The handle of the characteristic value being signalled.
751    /// Mandatory.
752    pub handle: Option<Handle>,
753    /// The updated value of the characteristic.
754    /// Note for clients using indications/notifications for high-throughput (not recommended):
755    /// While statically constrained to `MAX_VALUE_LENGTH`, the real limit depends on the specific
756    /// peer's configuration as notified by `LocalService.PeerUpdate`. Any bytes exceeding that
757    /// limit are truncated internally by the stack.
758    /// Mandatory.
759    pub value: Option<Vec<u8>>,
760    /// Only signal a subset of peers.
761    /// If not present or empty, all peers that can be updated are signaled.
762    /// If included, only the set of peers in this list will be signaled.
763    /// Peers are only signaled if they have configured updates or notifications per `LocalService.`
764    /// `CharacteristicConfiguration`; other peers in `peer_ids` will be ignored.
765    pub peer_ids: Option<Vec<fidl_fuchsia_bluetooth_common::PeerId>>,
766    #[doc(hidden)]
767    pub __source_breaking: fidl::marker::SourceBreaking,
768}
769
770impl fidl::Persistable for ValueChangedParameters {}
771
772/// Represents the supported options to write a characteristic/descriptor value
773/// to a server.
774#[derive(Clone, Debug, Default, PartialEq)]
775pub struct WriteOptions {
776    /// The mode of the write operation. For descriptors, only
777    /// [`WriteMode.DEFAULT`] is supported
778    /// Optional.
779    /// Default: [`WriteMode.DEFAULT`]
780    pub write_mode: Option<WriteMode>,
781    /// Request a write starting at the byte indicated.
782    /// Must be missing or 0 if `write_mode` is [`WriteMode.WITHOUT_RESPONSE`].
783    /// Optional.
784    /// Default: 0
785    pub offset: Option<u16>,
786    #[doc(hidden)]
787    pub __source_breaking: fidl::marker::SourceBreaking,
788}
789
790impl fidl::Persistable for WriteOptions {}
791
792/// Represents the supported options to read a characteristic or descriptor
793/// value from a server.
794#[derive(Clone, Debug)]
795pub enum ReadOptions {
796    /// Perform a short read, which may be truncated (as indicated by the
797    /// maybe_truncated in the result)
798    /// Most reads in GATT services are short reads (<= 22 bytes).
799    ShortRead(ShortReadOptions),
800    /// If present, perform a long read using the indicated options.
801    /// Optional.
802    /// Default: A short read will be performed.
803    LongRead(LongReadOptions),
804    #[doc(hidden)]
805    __SourceBreaking { unknown_ordinal: u64 },
806}
807
808/// Pattern that matches an unknown `ReadOptions` member.
809#[macro_export]
810macro_rules! ReadOptionsUnknown {
811    () => {
812        _
813    };
814}
815
816// Custom PartialEq so that unknown variants are not equal to themselves.
817impl PartialEq for ReadOptions {
818    fn eq(&self, other: &Self) -> bool {
819        match (self, other) {
820            (Self::ShortRead(x), Self::ShortRead(y)) => *x == *y,
821            (Self::LongRead(x), Self::LongRead(y)) => *x == *y,
822            _ => false,
823        }
824    }
825}
826
827impl ReadOptions {
828    #[inline]
829    pub fn ordinal(&self) -> u64 {
830        match *self {
831            Self::ShortRead(_) => 1,
832            Self::LongRead(_) => 2,
833            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
834        }
835    }
836
837    #[inline]
838    pub fn unknown_variant_for_testing() -> Self {
839        Self::__SourceBreaking { unknown_ordinal: 0 }
840    }
841
842    #[inline]
843    pub fn is_unknown(&self) -> bool {
844        match self {
845            Self::__SourceBreaking { .. } => true,
846            _ => false,
847        }
848    }
849}
850
851impl fidl::Persistable for ReadOptions {}
852
853pub mod characteristic_notifier_ordinals {
854    pub const ON_NOTIFICATION: u64 = 0x8edda1bd01f3c0a;
855}
856
857pub mod client_ordinals {
858    pub const WATCH_SERVICES: u64 = 0x23243a22d6f08640;
859    pub const CONNECT_TO_SERVICE: u64 = 0x61b59f2b6d075ff8;
860}
861
862pub mod local_service_ordinals {
863    pub const CHARACTERISTIC_CONFIGURATION: u64 = 0x431101fcd8d9ef15;
864    pub const READ_VALUE: u64 = 0x49e11d396625d104;
865    pub const WRITE_VALUE: u64 = 0x7d6ae631baf18260;
866    pub const PEER_UPDATE: u64 = 0x7e362177a04108b8;
867    pub const ON_SUPPRESS_DISCOVERY: u64 = 0x106d36281c3cfb66;
868    pub const ON_NOTIFY_VALUE: u64 = 0x190c1c528bfd0068;
869    pub const ON_INDICATE_VALUE: u64 = 0x59431c3653ac531f;
870    pub const VALUE_CHANGED_CREDIT: u64 = 0x7cf0931548318566;
871}
872
873pub mod remote_service_ordinals {
874    pub const DISCOVER_CHARACTERISTICS: u64 = 0x6cd730f12e402543;
875    pub const READ_BY_TYPE: u64 = 0x739bb1e313162bbc;
876    pub const READ_CHARACTERISTIC: u64 = 0x4d41757ed69a96cb;
877    pub const WRITE_CHARACTERISTIC: u64 = 0x7fc7511adecde8c;
878    pub const READ_DESCRIPTOR: u64 = 0x7ed7ce00457dcec1;
879    pub const WRITE_DESCRIPTOR: u64 = 0x21d9106bfd6b7351;
880    pub const REGISTER_CHARACTERISTIC_NOTIFIER: u64 = 0x35007a85245f5cc6;
881}
882
883pub mod server__ordinals {
884    pub const PUBLISH_SERVICE: u64 = 0x3110442f2077bfe2;
885}
886
887mod internal {
888    use super::*;
889    unsafe impl fidl::encoding::TypeMarker for CharacteristicPropertyBits {
890        type Owned = Self;
891
892        #[inline(always)]
893        fn inline_align(_context: fidl::encoding::Context) -> usize {
894            2
895        }
896
897        #[inline(always)]
898        fn inline_size(_context: fidl::encoding::Context) -> usize {
899            2
900        }
901    }
902
903    impl fidl::encoding::ValueTypeMarker for CharacteristicPropertyBits {
904        type Borrowed<'a> = Self;
905        #[inline(always)]
906        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
907            *value
908        }
909    }
910
911    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
912        for CharacteristicPropertyBits
913    {
914        #[inline]
915        unsafe fn encode(
916            self,
917            encoder: &mut fidl::encoding::Encoder<'_, D>,
918            offset: usize,
919            _depth: fidl::encoding::Depth,
920        ) -> fidl::Result<()> {
921            encoder.debug_check_bounds::<Self>(offset);
922            if self.bits() & Self::all().bits() != self.bits() {
923                return Err(fidl::Error::InvalidBitsValue);
924            }
925            encoder.write_num(self.bits(), offset);
926            Ok(())
927        }
928    }
929
930    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
931        for CharacteristicPropertyBits
932    {
933        #[inline(always)]
934        fn new_empty() -> Self {
935            Self::empty()
936        }
937
938        #[inline]
939        unsafe fn decode(
940            &mut self,
941            decoder: &mut fidl::encoding::Decoder<'_, D>,
942            offset: usize,
943            _depth: fidl::encoding::Depth,
944        ) -> fidl::Result<()> {
945            decoder.debug_check_bounds::<Self>(offset);
946            let prim = decoder.read_num::<u16>(offset);
947            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
948            Ok(())
949        }
950    }
951    unsafe impl fidl::encoding::TypeMarker for Error {
952        type Owned = Self;
953
954        #[inline(always)]
955        fn inline_align(_context: fidl::encoding::Context) -> usize {
956            std::mem::align_of::<u32>()
957        }
958
959        #[inline(always)]
960        fn inline_size(_context: fidl::encoding::Context) -> usize {
961            std::mem::size_of::<u32>()
962        }
963
964        #[inline(always)]
965        fn encode_is_copy() -> bool {
966            true
967        }
968
969        #[inline(always)]
970        fn decode_is_copy() -> bool {
971            false
972        }
973    }
974
975    impl fidl::encoding::ValueTypeMarker for Error {
976        type Borrowed<'a> = Self;
977        #[inline(always)]
978        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
979            *value
980        }
981    }
982
983    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
984        #[inline]
985        unsafe fn encode(
986            self,
987            encoder: &mut fidl::encoding::Encoder<'_, D>,
988            offset: usize,
989            _depth: fidl::encoding::Depth,
990        ) -> fidl::Result<()> {
991            encoder.debug_check_bounds::<Self>(offset);
992            encoder.write_num(self.into_primitive(), offset);
993            Ok(())
994        }
995    }
996
997    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
998        #[inline(always)]
999        fn new_empty() -> Self {
1000            Self::InvalidHandle
1001        }
1002
1003        #[inline]
1004        unsafe fn decode(
1005            &mut self,
1006            decoder: &mut fidl::encoding::Decoder<'_, D>,
1007            offset: usize,
1008            _depth: fidl::encoding::Depth,
1009        ) -> fidl::Result<()> {
1010            decoder.debug_check_bounds::<Self>(offset);
1011            let prim = decoder.read_num::<u32>(offset);
1012
1013            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1014            Ok(())
1015        }
1016    }
1017    unsafe impl fidl::encoding::TypeMarker for PublishServiceError {
1018        type Owned = Self;
1019
1020        #[inline(always)]
1021        fn inline_align(_context: fidl::encoding::Context) -> usize {
1022            std::mem::align_of::<u32>()
1023        }
1024
1025        #[inline(always)]
1026        fn inline_size(_context: fidl::encoding::Context) -> usize {
1027            std::mem::size_of::<u32>()
1028        }
1029
1030        #[inline(always)]
1031        fn encode_is_copy() -> bool {
1032            false
1033        }
1034
1035        #[inline(always)]
1036        fn decode_is_copy() -> bool {
1037            false
1038        }
1039    }
1040
1041    impl fidl::encoding::ValueTypeMarker for PublishServiceError {
1042        type Borrowed<'a> = Self;
1043        #[inline(always)]
1044        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1045            *value
1046        }
1047    }
1048
1049    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1050        for PublishServiceError
1051    {
1052        #[inline]
1053        unsafe fn encode(
1054            self,
1055            encoder: &mut fidl::encoding::Encoder<'_, D>,
1056            offset: usize,
1057            _depth: fidl::encoding::Depth,
1058        ) -> fidl::Result<()> {
1059            encoder.debug_check_bounds::<Self>(offset);
1060            encoder.write_num(self.into_primitive(), offset);
1061            Ok(())
1062        }
1063    }
1064
1065    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PublishServiceError {
1066        #[inline(always)]
1067        fn new_empty() -> Self {
1068            Self::unknown()
1069        }
1070
1071        #[inline]
1072        unsafe fn decode(
1073            &mut self,
1074            decoder: &mut fidl::encoding::Decoder<'_, D>,
1075            offset: usize,
1076            _depth: fidl::encoding::Depth,
1077        ) -> fidl::Result<()> {
1078            decoder.debug_check_bounds::<Self>(offset);
1079            let prim = decoder.read_num::<u32>(offset);
1080
1081            *self = Self::from_primitive_allow_unknown(prim);
1082            Ok(())
1083        }
1084    }
1085    unsafe impl fidl::encoding::TypeMarker for ServiceKind {
1086        type Owned = Self;
1087
1088        #[inline(always)]
1089        fn inline_align(_context: fidl::encoding::Context) -> usize {
1090            std::mem::align_of::<u32>()
1091        }
1092
1093        #[inline(always)]
1094        fn inline_size(_context: fidl::encoding::Context) -> usize {
1095            std::mem::size_of::<u32>()
1096        }
1097
1098        #[inline(always)]
1099        fn encode_is_copy() -> bool {
1100            true
1101        }
1102
1103        #[inline(always)]
1104        fn decode_is_copy() -> bool {
1105            false
1106        }
1107    }
1108
1109    impl fidl::encoding::ValueTypeMarker for ServiceKind {
1110        type Borrowed<'a> = Self;
1111        #[inline(always)]
1112        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1113            *value
1114        }
1115    }
1116
1117    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ServiceKind {
1118        #[inline]
1119        unsafe fn encode(
1120            self,
1121            encoder: &mut fidl::encoding::Encoder<'_, D>,
1122            offset: usize,
1123            _depth: fidl::encoding::Depth,
1124        ) -> fidl::Result<()> {
1125            encoder.debug_check_bounds::<Self>(offset);
1126            encoder.write_num(self.into_primitive(), offset);
1127            Ok(())
1128        }
1129    }
1130
1131    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ServiceKind {
1132        #[inline(always)]
1133        fn new_empty() -> Self {
1134            Self::Primary
1135        }
1136
1137        #[inline]
1138        unsafe fn decode(
1139            &mut self,
1140            decoder: &mut fidl::encoding::Decoder<'_, D>,
1141            offset: usize,
1142            _depth: fidl::encoding::Depth,
1143        ) -> fidl::Result<()> {
1144            decoder.debug_check_bounds::<Self>(offset);
1145            let prim = decoder.read_num::<u32>(offset);
1146
1147            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1148            Ok(())
1149        }
1150    }
1151    unsafe impl fidl::encoding::TypeMarker for WriteMode {
1152        type Owned = Self;
1153
1154        #[inline(always)]
1155        fn inline_align(_context: fidl::encoding::Context) -> usize {
1156            std::mem::align_of::<u32>()
1157        }
1158
1159        #[inline(always)]
1160        fn inline_size(_context: fidl::encoding::Context) -> usize {
1161            std::mem::size_of::<u32>()
1162        }
1163
1164        #[inline(always)]
1165        fn encode_is_copy() -> bool {
1166            false
1167        }
1168
1169        #[inline(always)]
1170        fn decode_is_copy() -> bool {
1171            false
1172        }
1173    }
1174
1175    impl fidl::encoding::ValueTypeMarker for WriteMode {
1176        type Borrowed<'a> = Self;
1177        #[inline(always)]
1178        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1179            *value
1180        }
1181    }
1182
1183    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for WriteMode {
1184        #[inline]
1185        unsafe fn encode(
1186            self,
1187            encoder: &mut fidl::encoding::Encoder<'_, D>,
1188            offset: usize,
1189            _depth: fidl::encoding::Depth,
1190        ) -> fidl::Result<()> {
1191            encoder.debug_check_bounds::<Self>(offset);
1192            encoder.write_num(self.into_primitive(), offset);
1193            Ok(())
1194        }
1195    }
1196
1197    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WriteMode {
1198        #[inline(always)]
1199        fn new_empty() -> Self {
1200            Self::unknown()
1201        }
1202
1203        #[inline]
1204        unsafe fn decode(
1205            &mut self,
1206            decoder: &mut fidl::encoding::Decoder<'_, D>,
1207            offset: usize,
1208            _depth: fidl::encoding::Depth,
1209        ) -> fidl::Result<()> {
1210            decoder.debug_check_bounds::<Self>(offset);
1211            let prim = decoder.read_num::<u32>(offset);
1212
1213            *self = Self::from_primitive_allow_unknown(prim);
1214            Ok(())
1215        }
1216    }
1217
1218    impl fidl::encoding::ValueTypeMarker for CharacteristicNotifierOnNotificationRequest {
1219        type Borrowed<'a> = &'a Self;
1220        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1221            value
1222        }
1223    }
1224
1225    unsafe impl fidl::encoding::TypeMarker for CharacteristicNotifierOnNotificationRequest {
1226        type Owned = Self;
1227
1228        #[inline(always)]
1229        fn inline_align(_context: fidl::encoding::Context) -> usize {
1230            8
1231        }
1232
1233        #[inline(always)]
1234        fn inline_size(_context: fidl::encoding::Context) -> usize {
1235            16
1236        }
1237    }
1238
1239    unsafe impl<D: fidl::encoding::ResourceDialect>
1240        fidl::encoding::Encode<CharacteristicNotifierOnNotificationRequest, D>
1241        for &CharacteristicNotifierOnNotificationRequest
1242    {
1243        #[inline]
1244        unsafe fn encode(
1245            self,
1246            encoder: &mut fidl::encoding::Encoder<'_, D>,
1247            offset: usize,
1248            _depth: fidl::encoding::Depth,
1249        ) -> fidl::Result<()> {
1250            encoder.debug_check_bounds::<CharacteristicNotifierOnNotificationRequest>(offset);
1251            // Delegate to tuple encoding.
1252            fidl::encoding::Encode::<CharacteristicNotifierOnNotificationRequest, D>::encode(
1253                (<ReadValue as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
1254                encoder,
1255                offset,
1256                _depth,
1257            )
1258        }
1259    }
1260    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ReadValue, D>>
1261        fidl::encoding::Encode<CharacteristicNotifierOnNotificationRequest, D> for (T0,)
1262    {
1263        #[inline]
1264        unsafe fn encode(
1265            self,
1266            encoder: &mut fidl::encoding::Encoder<'_, D>,
1267            offset: usize,
1268            depth: fidl::encoding::Depth,
1269        ) -> fidl::Result<()> {
1270            encoder.debug_check_bounds::<CharacteristicNotifierOnNotificationRequest>(offset);
1271            // Zero out padding regions. There's no need to apply masks
1272            // because the unmasked parts will be overwritten by fields.
1273            // Write the fields.
1274            self.0.encode(encoder, offset + 0, depth)?;
1275            Ok(())
1276        }
1277    }
1278
1279    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1280        for CharacteristicNotifierOnNotificationRequest
1281    {
1282        #[inline(always)]
1283        fn new_empty() -> Self {
1284            Self { value: fidl::new_empty!(ReadValue, D) }
1285        }
1286
1287        #[inline]
1288        unsafe fn decode(
1289            &mut self,
1290            decoder: &mut fidl::encoding::Decoder<'_, D>,
1291            offset: usize,
1292            _depth: fidl::encoding::Depth,
1293        ) -> fidl::Result<()> {
1294            decoder.debug_check_bounds::<Self>(offset);
1295            // Verify that padding bytes are zero.
1296            fidl::decode!(ReadValue, D, &mut self.value, decoder, offset + 0, _depth)?;
1297            Ok(())
1298        }
1299    }
1300
1301    impl fidl::encoding::ValueTypeMarker for ClientWatchServicesRequest {
1302        type Borrowed<'a> = &'a Self;
1303        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1304            value
1305        }
1306    }
1307
1308    unsafe impl fidl::encoding::TypeMarker for ClientWatchServicesRequest {
1309        type Owned = Self;
1310
1311        #[inline(always)]
1312        fn inline_align(_context: fidl::encoding::Context) -> usize {
1313            8
1314        }
1315
1316        #[inline(always)]
1317        fn inline_size(_context: fidl::encoding::Context) -> usize {
1318            16
1319        }
1320    }
1321
1322    unsafe impl<D: fidl::encoding::ResourceDialect>
1323        fidl::encoding::Encode<ClientWatchServicesRequest, D> for &ClientWatchServicesRequest
1324    {
1325        #[inline]
1326        unsafe fn encode(
1327            self,
1328            encoder: &mut fidl::encoding::Encoder<'_, D>,
1329            offset: usize,
1330            _depth: fidl::encoding::Depth,
1331        ) -> fidl::Result<()> {
1332            encoder.debug_check_bounds::<ClientWatchServicesRequest>(offset);
1333            // Delegate to tuple encoding.
1334            fidl::encoding::Encode::<ClientWatchServicesRequest, D>::encode(
1335                (
1336                    <fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_common::Uuid> as fidl::encoding::ValueTypeMarker>::borrow(&self.uuids),
1337                ),
1338                encoder, offset, _depth
1339            )
1340        }
1341    }
1342    unsafe impl<
1343        D: fidl::encoding::ResourceDialect,
1344        T0: fidl::encoding::Encode<
1345                fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_common::Uuid>,
1346                D,
1347            >,
1348    > fidl::encoding::Encode<ClientWatchServicesRequest, D> for (T0,)
1349    {
1350        #[inline]
1351        unsafe fn encode(
1352            self,
1353            encoder: &mut fidl::encoding::Encoder<'_, D>,
1354            offset: usize,
1355            depth: fidl::encoding::Depth,
1356        ) -> fidl::Result<()> {
1357            encoder.debug_check_bounds::<ClientWatchServicesRequest>(offset);
1358            // Zero out padding regions. There's no need to apply masks
1359            // because the unmasked parts will be overwritten by fields.
1360            // Write the fields.
1361            self.0.encode(encoder, offset + 0, depth)?;
1362            Ok(())
1363        }
1364    }
1365
1366    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1367        for ClientWatchServicesRequest
1368    {
1369        #[inline(always)]
1370        fn new_empty() -> Self {
1371            Self {
1372                uuids: fidl::new_empty!(
1373                    fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_common::Uuid>,
1374                    D
1375                ),
1376            }
1377        }
1378
1379        #[inline]
1380        unsafe fn decode(
1381            &mut self,
1382            decoder: &mut fidl::encoding::Decoder<'_, D>,
1383            offset: usize,
1384            _depth: fidl::encoding::Depth,
1385        ) -> fidl::Result<()> {
1386            decoder.debug_check_bounds::<Self>(offset);
1387            // Verify that padding bytes are zero.
1388            fidl::decode!(
1389                fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_common::Uuid>,
1390                D,
1391                &mut self.uuids,
1392                decoder,
1393                offset + 0,
1394                _depth
1395            )?;
1396            Ok(())
1397        }
1398    }
1399
1400    impl fidl::encoding::ValueTypeMarker for ClientWatchServicesResponse {
1401        type Borrowed<'a> = &'a Self;
1402        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1403            value
1404        }
1405    }
1406
1407    unsafe impl fidl::encoding::TypeMarker for ClientWatchServicesResponse {
1408        type Owned = Self;
1409
1410        #[inline(always)]
1411        fn inline_align(_context: fidl::encoding::Context) -> usize {
1412            8
1413        }
1414
1415        #[inline(always)]
1416        fn inline_size(_context: fidl::encoding::Context) -> usize {
1417            32
1418        }
1419    }
1420
1421    unsafe impl<D: fidl::encoding::ResourceDialect>
1422        fidl::encoding::Encode<ClientWatchServicesResponse, D> for &ClientWatchServicesResponse
1423    {
1424        #[inline]
1425        unsafe fn encode(
1426            self,
1427            encoder: &mut fidl::encoding::Encoder<'_, D>,
1428            offset: usize,
1429            _depth: fidl::encoding::Depth,
1430        ) -> fidl::Result<()> {
1431            encoder.debug_check_bounds::<ClientWatchServicesResponse>(offset);
1432            // Delegate to tuple encoding.
1433            fidl::encoding::Encode::<ClientWatchServicesResponse, D>::encode(
1434                (
1435                    <fidl::encoding::Vector<ServiceInfo, 65535> as fidl::encoding::ValueTypeMarker>::borrow(&self.updated),
1436                    <fidl::encoding::Vector<Handle, 65535> as fidl::encoding::ValueTypeMarker>::borrow(&self.removed),
1437                ),
1438                encoder, offset, _depth
1439            )
1440        }
1441    }
1442    unsafe impl<
1443        D: fidl::encoding::ResourceDialect,
1444        T0: fidl::encoding::Encode<fidl::encoding::Vector<ServiceInfo, 65535>, D>,
1445        T1: fidl::encoding::Encode<fidl::encoding::Vector<Handle, 65535>, D>,
1446    > fidl::encoding::Encode<ClientWatchServicesResponse, D> for (T0, T1)
1447    {
1448        #[inline]
1449        unsafe fn encode(
1450            self,
1451            encoder: &mut fidl::encoding::Encoder<'_, D>,
1452            offset: usize,
1453            depth: fidl::encoding::Depth,
1454        ) -> fidl::Result<()> {
1455            encoder.debug_check_bounds::<ClientWatchServicesResponse>(offset);
1456            // Zero out padding regions. There's no need to apply masks
1457            // because the unmasked parts will be overwritten by fields.
1458            // Write the fields.
1459            self.0.encode(encoder, offset + 0, depth)?;
1460            self.1.encode(encoder, offset + 16, depth)?;
1461            Ok(())
1462        }
1463    }
1464
1465    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1466        for ClientWatchServicesResponse
1467    {
1468        #[inline(always)]
1469        fn new_empty() -> Self {
1470            Self {
1471                updated: fidl::new_empty!(fidl::encoding::Vector<ServiceInfo, 65535>, D),
1472                removed: fidl::new_empty!(fidl::encoding::Vector<Handle, 65535>, D),
1473            }
1474        }
1475
1476        #[inline]
1477        unsafe fn decode(
1478            &mut self,
1479            decoder: &mut fidl::encoding::Decoder<'_, D>,
1480            offset: usize,
1481            _depth: fidl::encoding::Depth,
1482        ) -> fidl::Result<()> {
1483            decoder.debug_check_bounds::<Self>(offset);
1484            // Verify that padding bytes are zero.
1485            fidl::decode!(fidl::encoding::Vector<ServiceInfo, 65535>, D, &mut self.updated, decoder, offset + 0, _depth)?;
1486            fidl::decode!(fidl::encoding::Vector<Handle, 65535>, D, &mut self.removed, decoder, offset + 16, _depth)?;
1487            Ok(())
1488        }
1489    }
1490
1491    impl fidl::encoding::ValueTypeMarker for Handle {
1492        type Borrowed<'a> = &'a Self;
1493        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1494            value
1495        }
1496    }
1497
1498    unsafe impl fidl::encoding::TypeMarker for Handle {
1499        type Owned = Self;
1500
1501        #[inline(always)]
1502        fn inline_align(_context: fidl::encoding::Context) -> usize {
1503            8
1504        }
1505
1506        #[inline(always)]
1507        fn inline_size(_context: fidl::encoding::Context) -> usize {
1508            8
1509        }
1510        #[inline(always)]
1511        fn encode_is_copy() -> bool {
1512            true
1513        }
1514
1515        #[inline(always)]
1516        fn decode_is_copy() -> bool {
1517            true
1518        }
1519    }
1520
1521    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Handle, D> for &Handle {
1522        #[inline]
1523        unsafe fn encode(
1524            self,
1525            encoder: &mut fidl::encoding::Encoder<'_, D>,
1526            offset: usize,
1527            _depth: fidl::encoding::Depth,
1528        ) -> fidl::Result<()> {
1529            encoder.debug_check_bounds::<Handle>(offset);
1530            unsafe {
1531                // Copy the object into the buffer.
1532                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1533                (buf_ptr as *mut Handle).write_unaligned((self as *const Handle).read());
1534                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1535                // done second because the memcpy will write garbage to these bytes.
1536            }
1537            Ok(())
1538        }
1539    }
1540    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
1541        fidl::encoding::Encode<Handle, D> for (T0,)
1542    {
1543        #[inline]
1544        unsafe fn encode(
1545            self,
1546            encoder: &mut fidl::encoding::Encoder<'_, D>,
1547            offset: usize,
1548            depth: fidl::encoding::Depth,
1549        ) -> fidl::Result<()> {
1550            encoder.debug_check_bounds::<Handle>(offset);
1551            // Zero out padding regions. There's no need to apply masks
1552            // because the unmasked parts will be overwritten by fields.
1553            // Write the fields.
1554            self.0.encode(encoder, offset + 0, depth)?;
1555            Ok(())
1556        }
1557    }
1558
1559    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Handle {
1560        #[inline(always)]
1561        fn new_empty() -> Self {
1562            Self { value: fidl::new_empty!(u64, D) }
1563        }
1564
1565        #[inline]
1566        unsafe fn decode(
1567            &mut self,
1568            decoder: &mut fidl::encoding::Decoder<'_, D>,
1569            offset: usize,
1570            _depth: fidl::encoding::Depth,
1571        ) -> fidl::Result<()> {
1572            decoder.debug_check_bounds::<Self>(offset);
1573            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1574            // Verify that padding bytes are zero.
1575            // Copy from the buffer into the object.
1576            unsafe {
1577                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1578            }
1579            Ok(())
1580        }
1581    }
1582
1583    impl fidl::encoding::ValueTypeMarker for LocalServiceCharacteristicConfigurationRequest {
1584        type Borrowed<'a> = &'a Self;
1585        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1586            value
1587        }
1588    }
1589
1590    unsafe impl fidl::encoding::TypeMarker for LocalServiceCharacteristicConfigurationRequest {
1591        type Owned = Self;
1592
1593        #[inline(always)]
1594        fn inline_align(_context: fidl::encoding::Context) -> usize {
1595            8
1596        }
1597
1598        #[inline(always)]
1599        fn inline_size(_context: fidl::encoding::Context) -> usize {
1600            24
1601        }
1602    }
1603
1604    unsafe impl<D: fidl::encoding::ResourceDialect>
1605        fidl::encoding::Encode<LocalServiceCharacteristicConfigurationRequest, D>
1606        for &LocalServiceCharacteristicConfigurationRequest
1607    {
1608        #[inline]
1609        unsafe fn encode(
1610            self,
1611            encoder: &mut fidl::encoding::Encoder<'_, D>,
1612            offset: usize,
1613            _depth: fidl::encoding::Depth,
1614        ) -> fidl::Result<()> {
1615            encoder.debug_check_bounds::<LocalServiceCharacteristicConfigurationRequest>(offset);
1616            // Delegate to tuple encoding.
1617            fidl::encoding::Encode::<LocalServiceCharacteristicConfigurationRequest, D>::encode(
1618                (
1619                    <fidl_fuchsia_bluetooth_common::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.peer_id),
1620                    <Handle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
1621                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.notify),
1622                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.indicate),
1623                ),
1624                encoder, offset, _depth
1625            )
1626        }
1627    }
1628    unsafe impl<
1629        D: fidl::encoding::ResourceDialect,
1630        T0: fidl::encoding::Encode<fidl_fuchsia_bluetooth_common::PeerId, D>,
1631        T1: fidl::encoding::Encode<Handle, D>,
1632        T2: fidl::encoding::Encode<bool, D>,
1633        T3: fidl::encoding::Encode<bool, D>,
1634    > fidl::encoding::Encode<LocalServiceCharacteristicConfigurationRequest, D>
1635        for (T0, T1, T2, T3)
1636    {
1637        #[inline]
1638        unsafe fn encode(
1639            self,
1640            encoder: &mut fidl::encoding::Encoder<'_, D>,
1641            offset: usize,
1642            depth: fidl::encoding::Depth,
1643        ) -> fidl::Result<()> {
1644            encoder.debug_check_bounds::<LocalServiceCharacteristicConfigurationRequest>(offset);
1645            // Zero out padding regions. There's no need to apply masks
1646            // because the unmasked parts will be overwritten by fields.
1647            unsafe {
1648                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1649                (ptr as *mut u64).write_unaligned(0);
1650            }
1651            // Write the fields.
1652            self.0.encode(encoder, offset + 0, depth)?;
1653            self.1.encode(encoder, offset + 8, depth)?;
1654            self.2.encode(encoder, offset + 16, depth)?;
1655            self.3.encode(encoder, offset + 17, depth)?;
1656            Ok(())
1657        }
1658    }
1659
1660    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1661        for LocalServiceCharacteristicConfigurationRequest
1662    {
1663        #[inline(always)]
1664        fn new_empty() -> Self {
1665            Self {
1666                peer_id: fidl::new_empty!(fidl_fuchsia_bluetooth_common::PeerId, D),
1667                handle: fidl::new_empty!(Handle, D),
1668                notify: fidl::new_empty!(bool, D),
1669                indicate: fidl::new_empty!(bool, D),
1670            }
1671        }
1672
1673        #[inline]
1674        unsafe fn decode(
1675            &mut self,
1676            decoder: &mut fidl::encoding::Decoder<'_, D>,
1677            offset: usize,
1678            _depth: fidl::encoding::Depth,
1679        ) -> fidl::Result<()> {
1680            decoder.debug_check_bounds::<Self>(offset);
1681            // Verify that padding bytes are zero.
1682            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1683            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1684            let mask = 0xffffffffffff0000u64;
1685            let maskedval = padval & mask;
1686            if maskedval != 0 {
1687                return Err(fidl::Error::NonZeroPadding {
1688                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1689                });
1690            }
1691            fidl::decode!(
1692                fidl_fuchsia_bluetooth_common::PeerId,
1693                D,
1694                &mut self.peer_id,
1695                decoder,
1696                offset + 0,
1697                _depth
1698            )?;
1699            fidl::decode!(Handle, D, &mut self.handle, decoder, offset + 8, _depth)?;
1700            fidl::decode!(bool, D, &mut self.notify, decoder, offset + 16, _depth)?;
1701            fidl::decode!(bool, D, &mut self.indicate, decoder, offset + 17, _depth)?;
1702            Ok(())
1703        }
1704    }
1705
1706    impl fidl::encoding::ValueTypeMarker for LocalServiceReadValueRequest {
1707        type Borrowed<'a> = &'a Self;
1708        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1709            value
1710        }
1711    }
1712
1713    unsafe impl fidl::encoding::TypeMarker for LocalServiceReadValueRequest {
1714        type Owned = Self;
1715
1716        #[inline(always)]
1717        fn inline_align(_context: fidl::encoding::Context) -> usize {
1718            8
1719        }
1720
1721        #[inline(always)]
1722        fn inline_size(_context: fidl::encoding::Context) -> usize {
1723            24
1724        }
1725    }
1726
1727    unsafe impl<D: fidl::encoding::ResourceDialect>
1728        fidl::encoding::Encode<LocalServiceReadValueRequest, D> for &LocalServiceReadValueRequest
1729    {
1730        #[inline]
1731        unsafe fn encode(
1732            self,
1733            encoder: &mut fidl::encoding::Encoder<'_, D>,
1734            offset: usize,
1735            _depth: fidl::encoding::Depth,
1736        ) -> fidl::Result<()> {
1737            encoder.debug_check_bounds::<LocalServiceReadValueRequest>(offset);
1738            // Delegate to tuple encoding.
1739            fidl::encoding::Encode::<LocalServiceReadValueRequest, D>::encode(
1740                (
1741                    <fidl_fuchsia_bluetooth_common::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.peer_id),
1742                    <Handle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
1743                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset),
1744                ),
1745                encoder, offset, _depth
1746            )
1747        }
1748    }
1749    unsafe impl<
1750        D: fidl::encoding::ResourceDialect,
1751        T0: fidl::encoding::Encode<fidl_fuchsia_bluetooth_common::PeerId, D>,
1752        T1: fidl::encoding::Encode<Handle, D>,
1753        T2: fidl::encoding::Encode<i32, D>,
1754    > fidl::encoding::Encode<LocalServiceReadValueRequest, D> for (T0, T1, T2)
1755    {
1756        #[inline]
1757        unsafe fn encode(
1758            self,
1759            encoder: &mut fidl::encoding::Encoder<'_, D>,
1760            offset: usize,
1761            depth: fidl::encoding::Depth,
1762        ) -> fidl::Result<()> {
1763            encoder.debug_check_bounds::<LocalServiceReadValueRequest>(offset);
1764            // Zero out padding regions. There's no need to apply masks
1765            // because the unmasked parts will be overwritten by fields.
1766            unsafe {
1767                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1768                (ptr as *mut u64).write_unaligned(0);
1769            }
1770            // Write the fields.
1771            self.0.encode(encoder, offset + 0, depth)?;
1772            self.1.encode(encoder, offset + 8, depth)?;
1773            self.2.encode(encoder, offset + 16, depth)?;
1774            Ok(())
1775        }
1776    }
1777
1778    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1779        for LocalServiceReadValueRequest
1780    {
1781        #[inline(always)]
1782        fn new_empty() -> Self {
1783            Self {
1784                peer_id: fidl::new_empty!(fidl_fuchsia_bluetooth_common::PeerId, D),
1785                handle: fidl::new_empty!(Handle, D),
1786                offset: fidl::new_empty!(i32, D),
1787            }
1788        }
1789
1790        #[inline]
1791        unsafe fn decode(
1792            &mut self,
1793            decoder: &mut fidl::encoding::Decoder<'_, D>,
1794            offset: usize,
1795            _depth: fidl::encoding::Depth,
1796        ) -> fidl::Result<()> {
1797            decoder.debug_check_bounds::<Self>(offset);
1798            // Verify that padding bytes are zero.
1799            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1800            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1801            let mask = 0xffffffff00000000u64;
1802            let maskedval = padval & mask;
1803            if maskedval != 0 {
1804                return Err(fidl::Error::NonZeroPadding {
1805                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1806                });
1807            }
1808            fidl::decode!(
1809                fidl_fuchsia_bluetooth_common::PeerId,
1810                D,
1811                &mut self.peer_id,
1812                decoder,
1813                offset + 0,
1814                _depth
1815            )?;
1816            fidl::decode!(Handle, D, &mut self.handle, decoder, offset + 8, _depth)?;
1817            fidl::decode!(i32, D, &mut self.offset, decoder, offset + 16, _depth)?;
1818            Ok(())
1819        }
1820    }
1821
1822    impl fidl::encoding::ValueTypeMarker for LocalServiceValueChangedCreditRequest {
1823        type Borrowed<'a> = &'a Self;
1824        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1825            value
1826        }
1827    }
1828
1829    unsafe impl fidl::encoding::TypeMarker for LocalServiceValueChangedCreditRequest {
1830        type Owned = Self;
1831
1832        #[inline(always)]
1833        fn inline_align(_context: fidl::encoding::Context) -> usize {
1834            1
1835        }
1836
1837        #[inline(always)]
1838        fn inline_size(_context: fidl::encoding::Context) -> usize {
1839            1
1840        }
1841        #[inline(always)]
1842        fn encode_is_copy() -> bool {
1843            true
1844        }
1845
1846        #[inline(always)]
1847        fn decode_is_copy() -> bool {
1848            true
1849        }
1850    }
1851
1852    unsafe impl<D: fidl::encoding::ResourceDialect>
1853        fidl::encoding::Encode<LocalServiceValueChangedCreditRequest, D>
1854        for &LocalServiceValueChangedCreditRequest
1855    {
1856        #[inline]
1857        unsafe fn encode(
1858            self,
1859            encoder: &mut fidl::encoding::Encoder<'_, D>,
1860            offset: usize,
1861            _depth: fidl::encoding::Depth,
1862        ) -> fidl::Result<()> {
1863            encoder.debug_check_bounds::<LocalServiceValueChangedCreditRequest>(offset);
1864            unsafe {
1865                // Copy the object into the buffer.
1866                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1867                (buf_ptr as *mut LocalServiceValueChangedCreditRequest)
1868                    .write_unaligned((self as *const LocalServiceValueChangedCreditRequest).read());
1869                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1870                // done second because the memcpy will write garbage to these bytes.
1871            }
1872            Ok(())
1873        }
1874    }
1875    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
1876        fidl::encoding::Encode<LocalServiceValueChangedCreditRequest, D> for (T0,)
1877    {
1878        #[inline]
1879        unsafe fn encode(
1880            self,
1881            encoder: &mut fidl::encoding::Encoder<'_, D>,
1882            offset: usize,
1883            depth: fidl::encoding::Depth,
1884        ) -> fidl::Result<()> {
1885            encoder.debug_check_bounds::<LocalServiceValueChangedCreditRequest>(offset);
1886            // Zero out padding regions. There's no need to apply masks
1887            // because the unmasked parts will be overwritten by fields.
1888            // Write the fields.
1889            self.0.encode(encoder, offset + 0, depth)?;
1890            Ok(())
1891        }
1892    }
1893
1894    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1895        for LocalServiceValueChangedCreditRequest
1896    {
1897        #[inline(always)]
1898        fn new_empty() -> Self {
1899            Self { additional_credit: fidl::new_empty!(u8, D) }
1900        }
1901
1902        #[inline]
1903        unsafe fn decode(
1904            &mut self,
1905            decoder: &mut fidl::encoding::Decoder<'_, D>,
1906            offset: usize,
1907            _depth: fidl::encoding::Depth,
1908        ) -> fidl::Result<()> {
1909            decoder.debug_check_bounds::<Self>(offset);
1910            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1911            // Verify that padding bytes are zero.
1912            // Copy from the buffer into the object.
1913            unsafe {
1914                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
1915            }
1916            Ok(())
1917        }
1918    }
1919
1920    impl fidl::encoding::ValueTypeMarker for LocalServiceReadValueResponse {
1921        type Borrowed<'a> = &'a Self;
1922        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1923            value
1924        }
1925    }
1926
1927    unsafe impl fidl::encoding::TypeMarker for LocalServiceReadValueResponse {
1928        type Owned = Self;
1929
1930        #[inline(always)]
1931        fn inline_align(_context: fidl::encoding::Context) -> usize {
1932            8
1933        }
1934
1935        #[inline(always)]
1936        fn inline_size(_context: fidl::encoding::Context) -> usize {
1937            16
1938        }
1939    }
1940
1941    unsafe impl<D: fidl::encoding::ResourceDialect>
1942        fidl::encoding::Encode<LocalServiceReadValueResponse, D>
1943        for &LocalServiceReadValueResponse
1944    {
1945        #[inline]
1946        unsafe fn encode(
1947            self,
1948            encoder: &mut fidl::encoding::Encoder<'_, D>,
1949            offset: usize,
1950            _depth: fidl::encoding::Depth,
1951        ) -> fidl::Result<()> {
1952            encoder.debug_check_bounds::<LocalServiceReadValueResponse>(offset);
1953            // Delegate to tuple encoding.
1954            fidl::encoding::Encode::<LocalServiceReadValueResponse, D>::encode(
1955                (<fidl::encoding::Vector<u8, 512> as fidl::encoding::ValueTypeMarker>::borrow(
1956                    &self.value,
1957                ),),
1958                encoder,
1959                offset,
1960                _depth,
1961            )
1962        }
1963    }
1964    unsafe impl<
1965        D: fidl::encoding::ResourceDialect,
1966        T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 512>, D>,
1967    > fidl::encoding::Encode<LocalServiceReadValueResponse, D> for (T0,)
1968    {
1969        #[inline]
1970        unsafe fn encode(
1971            self,
1972            encoder: &mut fidl::encoding::Encoder<'_, D>,
1973            offset: usize,
1974            depth: fidl::encoding::Depth,
1975        ) -> fidl::Result<()> {
1976            encoder.debug_check_bounds::<LocalServiceReadValueResponse>(offset);
1977            // Zero out padding regions. There's no need to apply masks
1978            // because the unmasked parts will be overwritten by fields.
1979            // Write the fields.
1980            self.0.encode(encoder, offset + 0, depth)?;
1981            Ok(())
1982        }
1983    }
1984
1985    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1986        for LocalServiceReadValueResponse
1987    {
1988        #[inline(always)]
1989        fn new_empty() -> Self {
1990            Self { value: fidl::new_empty!(fidl::encoding::Vector<u8, 512>, D) }
1991        }
1992
1993        #[inline]
1994        unsafe fn decode(
1995            &mut self,
1996            decoder: &mut fidl::encoding::Decoder<'_, D>,
1997            offset: usize,
1998            _depth: fidl::encoding::Depth,
1999        ) -> fidl::Result<()> {
2000            decoder.debug_check_bounds::<Self>(offset);
2001            // Verify that padding bytes are zero.
2002            fidl::decode!(fidl::encoding::Vector<u8, 512>, D, &mut self.value, decoder, offset + 0, _depth)?;
2003            Ok(())
2004        }
2005    }
2006
2007    impl fidl::encoding::ValueTypeMarker for RemoteServiceDiscoverCharacteristicsResponse {
2008        type Borrowed<'a> = &'a Self;
2009        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2010            value
2011        }
2012    }
2013
2014    unsafe impl fidl::encoding::TypeMarker for RemoteServiceDiscoverCharacteristicsResponse {
2015        type Owned = Self;
2016
2017        #[inline(always)]
2018        fn inline_align(_context: fidl::encoding::Context) -> usize {
2019            8
2020        }
2021
2022        #[inline(always)]
2023        fn inline_size(_context: fidl::encoding::Context) -> usize {
2024            16
2025        }
2026    }
2027
2028    unsafe impl<D: fidl::encoding::ResourceDialect>
2029        fidl::encoding::Encode<RemoteServiceDiscoverCharacteristicsResponse, D>
2030        for &RemoteServiceDiscoverCharacteristicsResponse
2031    {
2032        #[inline]
2033        unsafe fn encode(
2034            self,
2035            encoder: &mut fidl::encoding::Encoder<'_, D>,
2036            offset: usize,
2037            _depth: fidl::encoding::Depth,
2038        ) -> fidl::Result<()> {
2039            encoder.debug_check_bounds::<RemoteServiceDiscoverCharacteristicsResponse>(offset);
2040            // Delegate to tuple encoding.
2041            fidl::encoding::Encode::<RemoteServiceDiscoverCharacteristicsResponse, D>::encode(
2042                (
2043                    <fidl::encoding::Vector<Characteristic, 32767> as fidl::encoding::ValueTypeMarker>::borrow(&self.characteristics),
2044                ),
2045                encoder, offset, _depth
2046            )
2047        }
2048    }
2049    unsafe impl<
2050        D: fidl::encoding::ResourceDialect,
2051        T0: fidl::encoding::Encode<fidl::encoding::Vector<Characteristic, 32767>, D>,
2052    > fidl::encoding::Encode<RemoteServiceDiscoverCharacteristicsResponse, D> for (T0,)
2053    {
2054        #[inline]
2055        unsafe fn encode(
2056            self,
2057            encoder: &mut fidl::encoding::Encoder<'_, D>,
2058            offset: usize,
2059            depth: fidl::encoding::Depth,
2060        ) -> fidl::Result<()> {
2061            encoder.debug_check_bounds::<RemoteServiceDiscoverCharacteristicsResponse>(offset);
2062            // Zero out padding regions. There's no need to apply masks
2063            // because the unmasked parts will be overwritten by fields.
2064            // Write the fields.
2065            self.0.encode(encoder, offset + 0, depth)?;
2066            Ok(())
2067        }
2068    }
2069
2070    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2071        for RemoteServiceDiscoverCharacteristicsResponse
2072    {
2073        #[inline(always)]
2074        fn new_empty() -> Self {
2075            Self {
2076                characteristics: fidl::new_empty!(fidl::encoding::Vector<Characteristic, 32767>, D),
2077            }
2078        }
2079
2080        #[inline]
2081        unsafe fn decode(
2082            &mut self,
2083            decoder: &mut fidl::encoding::Decoder<'_, D>,
2084            offset: usize,
2085            _depth: fidl::encoding::Depth,
2086        ) -> fidl::Result<()> {
2087            decoder.debug_check_bounds::<Self>(offset);
2088            // Verify that padding bytes are zero.
2089            fidl::decode!(fidl::encoding::Vector<Characteristic, 32767>, D, &mut self.characteristics, decoder, offset + 0, _depth)?;
2090            Ok(())
2091        }
2092    }
2093
2094    impl fidl::encoding::ValueTypeMarker for RemoteServiceReadByTypeRequest {
2095        type Borrowed<'a> = &'a Self;
2096        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2097            value
2098        }
2099    }
2100
2101    unsafe impl fidl::encoding::TypeMarker for RemoteServiceReadByTypeRequest {
2102        type Owned = Self;
2103
2104        #[inline(always)]
2105        fn inline_align(_context: fidl::encoding::Context) -> usize {
2106            1
2107        }
2108
2109        #[inline(always)]
2110        fn inline_size(_context: fidl::encoding::Context) -> usize {
2111            16
2112        }
2113    }
2114
2115    unsafe impl<D: fidl::encoding::ResourceDialect>
2116        fidl::encoding::Encode<RemoteServiceReadByTypeRequest, D>
2117        for &RemoteServiceReadByTypeRequest
2118    {
2119        #[inline]
2120        unsafe fn encode(
2121            self,
2122            encoder: &mut fidl::encoding::Encoder<'_, D>,
2123            offset: usize,
2124            _depth: fidl::encoding::Depth,
2125        ) -> fidl::Result<()> {
2126            encoder.debug_check_bounds::<RemoteServiceReadByTypeRequest>(offset);
2127            // Delegate to tuple encoding.
2128            fidl::encoding::Encode::<RemoteServiceReadByTypeRequest, D>::encode(
2129                (<fidl_fuchsia_bluetooth_common::Uuid as fidl::encoding::ValueTypeMarker>::borrow(
2130                    &self.uuid,
2131                ),),
2132                encoder,
2133                offset,
2134                _depth,
2135            )
2136        }
2137    }
2138    unsafe impl<
2139        D: fidl::encoding::ResourceDialect,
2140        T0: fidl::encoding::Encode<fidl_fuchsia_bluetooth_common::Uuid, D>,
2141    > fidl::encoding::Encode<RemoteServiceReadByTypeRequest, D> for (T0,)
2142    {
2143        #[inline]
2144        unsafe fn encode(
2145            self,
2146            encoder: &mut fidl::encoding::Encoder<'_, D>,
2147            offset: usize,
2148            depth: fidl::encoding::Depth,
2149        ) -> fidl::Result<()> {
2150            encoder.debug_check_bounds::<RemoteServiceReadByTypeRequest>(offset);
2151            // Zero out padding regions. There's no need to apply masks
2152            // because the unmasked parts will be overwritten by fields.
2153            // Write the fields.
2154            self.0.encode(encoder, offset + 0, depth)?;
2155            Ok(())
2156        }
2157    }
2158
2159    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2160        for RemoteServiceReadByTypeRequest
2161    {
2162        #[inline(always)]
2163        fn new_empty() -> Self {
2164            Self { uuid: fidl::new_empty!(fidl_fuchsia_bluetooth_common::Uuid, D) }
2165        }
2166
2167        #[inline]
2168        unsafe fn decode(
2169            &mut self,
2170            decoder: &mut fidl::encoding::Decoder<'_, D>,
2171            offset: usize,
2172            _depth: fidl::encoding::Depth,
2173        ) -> fidl::Result<()> {
2174            decoder.debug_check_bounds::<Self>(offset);
2175            // Verify that padding bytes are zero.
2176            fidl::decode!(
2177                fidl_fuchsia_bluetooth_common::Uuid,
2178                D,
2179                &mut self.uuid,
2180                decoder,
2181                offset + 0,
2182                _depth
2183            )?;
2184            Ok(())
2185        }
2186    }
2187
2188    impl fidl::encoding::ValueTypeMarker for RemoteServiceReadCharacteristicRequest {
2189        type Borrowed<'a> = &'a Self;
2190        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2191            value
2192        }
2193    }
2194
2195    unsafe impl fidl::encoding::TypeMarker for RemoteServiceReadCharacteristicRequest {
2196        type Owned = Self;
2197
2198        #[inline(always)]
2199        fn inline_align(_context: fidl::encoding::Context) -> usize {
2200            8
2201        }
2202
2203        #[inline(always)]
2204        fn inline_size(_context: fidl::encoding::Context) -> usize {
2205            24
2206        }
2207    }
2208
2209    unsafe impl<D: fidl::encoding::ResourceDialect>
2210        fidl::encoding::Encode<RemoteServiceReadCharacteristicRequest, D>
2211        for &RemoteServiceReadCharacteristicRequest
2212    {
2213        #[inline]
2214        unsafe fn encode(
2215            self,
2216            encoder: &mut fidl::encoding::Encoder<'_, D>,
2217            offset: usize,
2218            _depth: fidl::encoding::Depth,
2219        ) -> fidl::Result<()> {
2220            encoder.debug_check_bounds::<RemoteServiceReadCharacteristicRequest>(offset);
2221            // Delegate to tuple encoding.
2222            fidl::encoding::Encode::<RemoteServiceReadCharacteristicRequest, D>::encode(
2223                (
2224                    <Handle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
2225                    <ReadOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
2226                ),
2227                encoder,
2228                offset,
2229                _depth,
2230            )
2231        }
2232    }
2233    unsafe impl<
2234        D: fidl::encoding::ResourceDialect,
2235        T0: fidl::encoding::Encode<Handle, D>,
2236        T1: fidl::encoding::Encode<ReadOptions, D>,
2237    > fidl::encoding::Encode<RemoteServiceReadCharacteristicRequest, D> for (T0, T1)
2238    {
2239        #[inline]
2240        unsafe fn encode(
2241            self,
2242            encoder: &mut fidl::encoding::Encoder<'_, D>,
2243            offset: usize,
2244            depth: fidl::encoding::Depth,
2245        ) -> fidl::Result<()> {
2246            encoder.debug_check_bounds::<RemoteServiceReadCharacteristicRequest>(offset);
2247            // Zero out padding regions. There's no need to apply masks
2248            // because the unmasked parts will be overwritten by fields.
2249            // Write the fields.
2250            self.0.encode(encoder, offset + 0, depth)?;
2251            self.1.encode(encoder, offset + 8, depth)?;
2252            Ok(())
2253        }
2254    }
2255
2256    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2257        for RemoteServiceReadCharacteristicRequest
2258    {
2259        #[inline(always)]
2260        fn new_empty() -> Self {
2261            Self { handle: fidl::new_empty!(Handle, D), options: fidl::new_empty!(ReadOptions, D) }
2262        }
2263
2264        #[inline]
2265        unsafe fn decode(
2266            &mut self,
2267            decoder: &mut fidl::encoding::Decoder<'_, D>,
2268            offset: usize,
2269            _depth: fidl::encoding::Depth,
2270        ) -> fidl::Result<()> {
2271            decoder.debug_check_bounds::<Self>(offset);
2272            // Verify that padding bytes are zero.
2273            fidl::decode!(Handle, D, &mut self.handle, decoder, offset + 0, _depth)?;
2274            fidl::decode!(ReadOptions, D, &mut self.options, decoder, offset + 8, _depth)?;
2275            Ok(())
2276        }
2277    }
2278
2279    impl fidl::encoding::ValueTypeMarker for RemoteServiceReadDescriptorRequest {
2280        type Borrowed<'a> = &'a Self;
2281        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2282            value
2283        }
2284    }
2285
2286    unsafe impl fidl::encoding::TypeMarker for RemoteServiceReadDescriptorRequest {
2287        type Owned = Self;
2288
2289        #[inline(always)]
2290        fn inline_align(_context: fidl::encoding::Context) -> usize {
2291            8
2292        }
2293
2294        #[inline(always)]
2295        fn inline_size(_context: fidl::encoding::Context) -> usize {
2296            24
2297        }
2298    }
2299
2300    unsafe impl<D: fidl::encoding::ResourceDialect>
2301        fidl::encoding::Encode<RemoteServiceReadDescriptorRequest, D>
2302        for &RemoteServiceReadDescriptorRequest
2303    {
2304        #[inline]
2305        unsafe fn encode(
2306            self,
2307            encoder: &mut fidl::encoding::Encoder<'_, D>,
2308            offset: usize,
2309            _depth: fidl::encoding::Depth,
2310        ) -> fidl::Result<()> {
2311            encoder.debug_check_bounds::<RemoteServiceReadDescriptorRequest>(offset);
2312            // Delegate to tuple encoding.
2313            fidl::encoding::Encode::<RemoteServiceReadDescriptorRequest, D>::encode(
2314                (
2315                    <Handle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
2316                    <ReadOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
2317                ),
2318                encoder,
2319                offset,
2320                _depth,
2321            )
2322        }
2323    }
2324    unsafe impl<
2325        D: fidl::encoding::ResourceDialect,
2326        T0: fidl::encoding::Encode<Handle, D>,
2327        T1: fidl::encoding::Encode<ReadOptions, D>,
2328    > fidl::encoding::Encode<RemoteServiceReadDescriptorRequest, D> for (T0, T1)
2329    {
2330        #[inline]
2331        unsafe fn encode(
2332            self,
2333            encoder: &mut fidl::encoding::Encoder<'_, D>,
2334            offset: usize,
2335            depth: fidl::encoding::Depth,
2336        ) -> fidl::Result<()> {
2337            encoder.debug_check_bounds::<RemoteServiceReadDescriptorRequest>(offset);
2338            // Zero out padding regions. There's no need to apply masks
2339            // because the unmasked parts will be overwritten by fields.
2340            // Write the fields.
2341            self.0.encode(encoder, offset + 0, depth)?;
2342            self.1.encode(encoder, offset + 8, depth)?;
2343            Ok(())
2344        }
2345    }
2346
2347    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2348        for RemoteServiceReadDescriptorRequest
2349    {
2350        #[inline(always)]
2351        fn new_empty() -> Self {
2352            Self { handle: fidl::new_empty!(Handle, D), options: fidl::new_empty!(ReadOptions, D) }
2353        }
2354
2355        #[inline]
2356        unsafe fn decode(
2357            &mut self,
2358            decoder: &mut fidl::encoding::Decoder<'_, D>,
2359            offset: usize,
2360            _depth: fidl::encoding::Depth,
2361        ) -> fidl::Result<()> {
2362            decoder.debug_check_bounds::<Self>(offset);
2363            // Verify that padding bytes are zero.
2364            fidl::decode!(Handle, D, &mut self.handle, decoder, offset + 0, _depth)?;
2365            fidl::decode!(ReadOptions, D, &mut self.options, decoder, offset + 8, _depth)?;
2366            Ok(())
2367        }
2368    }
2369
2370    impl fidl::encoding::ValueTypeMarker for RemoteServiceWriteCharacteristicRequest {
2371        type Borrowed<'a> = &'a Self;
2372        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2373            value
2374        }
2375    }
2376
2377    unsafe impl fidl::encoding::TypeMarker for RemoteServiceWriteCharacteristicRequest {
2378        type Owned = Self;
2379
2380        #[inline(always)]
2381        fn inline_align(_context: fidl::encoding::Context) -> usize {
2382            8
2383        }
2384
2385        #[inline(always)]
2386        fn inline_size(_context: fidl::encoding::Context) -> usize {
2387            40
2388        }
2389    }
2390
2391    unsafe impl<D: fidl::encoding::ResourceDialect>
2392        fidl::encoding::Encode<RemoteServiceWriteCharacteristicRequest, D>
2393        for &RemoteServiceWriteCharacteristicRequest
2394    {
2395        #[inline]
2396        unsafe fn encode(
2397            self,
2398            encoder: &mut fidl::encoding::Encoder<'_, D>,
2399            offset: usize,
2400            _depth: fidl::encoding::Depth,
2401        ) -> fidl::Result<()> {
2402            encoder.debug_check_bounds::<RemoteServiceWriteCharacteristicRequest>(offset);
2403            // Delegate to tuple encoding.
2404            fidl::encoding::Encode::<RemoteServiceWriteCharacteristicRequest, D>::encode(
2405                (
2406                    <Handle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
2407                    <fidl::encoding::Vector<u8, 512> as fidl::encoding::ValueTypeMarker>::borrow(
2408                        &self.value,
2409                    ),
2410                    <WriteOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
2411                ),
2412                encoder,
2413                offset,
2414                _depth,
2415            )
2416        }
2417    }
2418    unsafe impl<
2419        D: fidl::encoding::ResourceDialect,
2420        T0: fidl::encoding::Encode<Handle, D>,
2421        T1: fidl::encoding::Encode<fidl::encoding::Vector<u8, 512>, D>,
2422        T2: fidl::encoding::Encode<WriteOptions, D>,
2423    > fidl::encoding::Encode<RemoteServiceWriteCharacteristicRequest, D> for (T0, T1, T2)
2424    {
2425        #[inline]
2426        unsafe fn encode(
2427            self,
2428            encoder: &mut fidl::encoding::Encoder<'_, D>,
2429            offset: usize,
2430            depth: fidl::encoding::Depth,
2431        ) -> fidl::Result<()> {
2432            encoder.debug_check_bounds::<RemoteServiceWriteCharacteristicRequest>(offset);
2433            // Zero out padding regions. There's no need to apply masks
2434            // because the unmasked parts will be overwritten by fields.
2435            // Write the fields.
2436            self.0.encode(encoder, offset + 0, depth)?;
2437            self.1.encode(encoder, offset + 8, depth)?;
2438            self.2.encode(encoder, offset + 24, depth)?;
2439            Ok(())
2440        }
2441    }
2442
2443    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2444        for RemoteServiceWriteCharacteristicRequest
2445    {
2446        #[inline(always)]
2447        fn new_empty() -> Self {
2448            Self {
2449                handle: fidl::new_empty!(Handle, D),
2450                value: fidl::new_empty!(fidl::encoding::Vector<u8, 512>, D),
2451                options: fidl::new_empty!(WriteOptions, D),
2452            }
2453        }
2454
2455        #[inline]
2456        unsafe fn decode(
2457            &mut self,
2458            decoder: &mut fidl::encoding::Decoder<'_, D>,
2459            offset: usize,
2460            _depth: fidl::encoding::Depth,
2461        ) -> fidl::Result<()> {
2462            decoder.debug_check_bounds::<Self>(offset);
2463            // Verify that padding bytes are zero.
2464            fidl::decode!(Handle, D, &mut self.handle, decoder, offset + 0, _depth)?;
2465            fidl::decode!(fidl::encoding::Vector<u8, 512>, D, &mut self.value, decoder, offset + 8, _depth)?;
2466            fidl::decode!(WriteOptions, D, &mut self.options, decoder, offset + 24, _depth)?;
2467            Ok(())
2468        }
2469    }
2470
2471    impl fidl::encoding::ValueTypeMarker for RemoteServiceWriteDescriptorRequest {
2472        type Borrowed<'a> = &'a Self;
2473        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2474            value
2475        }
2476    }
2477
2478    unsafe impl fidl::encoding::TypeMarker for RemoteServiceWriteDescriptorRequest {
2479        type Owned = Self;
2480
2481        #[inline(always)]
2482        fn inline_align(_context: fidl::encoding::Context) -> usize {
2483            8
2484        }
2485
2486        #[inline(always)]
2487        fn inline_size(_context: fidl::encoding::Context) -> usize {
2488            40
2489        }
2490    }
2491
2492    unsafe impl<D: fidl::encoding::ResourceDialect>
2493        fidl::encoding::Encode<RemoteServiceWriteDescriptorRequest, D>
2494        for &RemoteServiceWriteDescriptorRequest
2495    {
2496        #[inline]
2497        unsafe fn encode(
2498            self,
2499            encoder: &mut fidl::encoding::Encoder<'_, D>,
2500            offset: usize,
2501            _depth: fidl::encoding::Depth,
2502        ) -> fidl::Result<()> {
2503            encoder.debug_check_bounds::<RemoteServiceWriteDescriptorRequest>(offset);
2504            // Delegate to tuple encoding.
2505            fidl::encoding::Encode::<RemoteServiceWriteDescriptorRequest, D>::encode(
2506                (
2507                    <Handle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
2508                    <fidl::encoding::Vector<u8, 512> as fidl::encoding::ValueTypeMarker>::borrow(
2509                        &self.value,
2510                    ),
2511                    <WriteOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
2512                ),
2513                encoder,
2514                offset,
2515                _depth,
2516            )
2517        }
2518    }
2519    unsafe impl<
2520        D: fidl::encoding::ResourceDialect,
2521        T0: fidl::encoding::Encode<Handle, D>,
2522        T1: fidl::encoding::Encode<fidl::encoding::Vector<u8, 512>, D>,
2523        T2: fidl::encoding::Encode<WriteOptions, D>,
2524    > fidl::encoding::Encode<RemoteServiceWriteDescriptorRequest, D> for (T0, T1, T2)
2525    {
2526        #[inline]
2527        unsafe fn encode(
2528            self,
2529            encoder: &mut fidl::encoding::Encoder<'_, D>,
2530            offset: usize,
2531            depth: fidl::encoding::Depth,
2532        ) -> fidl::Result<()> {
2533            encoder.debug_check_bounds::<RemoteServiceWriteDescriptorRequest>(offset);
2534            // Zero out padding regions. There's no need to apply masks
2535            // because the unmasked parts will be overwritten by fields.
2536            // Write the fields.
2537            self.0.encode(encoder, offset + 0, depth)?;
2538            self.1.encode(encoder, offset + 8, depth)?;
2539            self.2.encode(encoder, offset + 24, depth)?;
2540            Ok(())
2541        }
2542    }
2543
2544    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2545        for RemoteServiceWriteDescriptorRequest
2546    {
2547        #[inline(always)]
2548        fn new_empty() -> Self {
2549            Self {
2550                handle: fidl::new_empty!(Handle, D),
2551                value: fidl::new_empty!(fidl::encoding::Vector<u8, 512>, D),
2552                options: fidl::new_empty!(WriteOptions, D),
2553            }
2554        }
2555
2556        #[inline]
2557        unsafe fn decode(
2558            &mut self,
2559            decoder: &mut fidl::encoding::Decoder<'_, D>,
2560            offset: usize,
2561            _depth: fidl::encoding::Depth,
2562        ) -> fidl::Result<()> {
2563            decoder.debug_check_bounds::<Self>(offset);
2564            // Verify that padding bytes are zero.
2565            fidl::decode!(Handle, D, &mut self.handle, decoder, offset + 0, _depth)?;
2566            fidl::decode!(fidl::encoding::Vector<u8, 512>, D, &mut self.value, decoder, offset + 8, _depth)?;
2567            fidl::decode!(WriteOptions, D, &mut self.options, decoder, offset + 24, _depth)?;
2568            Ok(())
2569        }
2570    }
2571
2572    impl fidl::encoding::ValueTypeMarker for RemoteServiceReadByTypeResponse {
2573        type Borrowed<'a> = &'a Self;
2574        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2575            value
2576        }
2577    }
2578
2579    unsafe impl fidl::encoding::TypeMarker for RemoteServiceReadByTypeResponse {
2580        type Owned = Self;
2581
2582        #[inline(always)]
2583        fn inline_align(_context: fidl::encoding::Context) -> usize {
2584            8
2585        }
2586
2587        #[inline(always)]
2588        fn inline_size(_context: fidl::encoding::Context) -> usize {
2589            16
2590        }
2591    }
2592
2593    unsafe impl<D: fidl::encoding::ResourceDialect>
2594        fidl::encoding::Encode<RemoteServiceReadByTypeResponse, D>
2595        for &RemoteServiceReadByTypeResponse
2596    {
2597        #[inline]
2598        unsafe fn encode(
2599            self,
2600            encoder: &mut fidl::encoding::Encoder<'_, D>,
2601            offset: usize,
2602            _depth: fidl::encoding::Depth,
2603        ) -> fidl::Result<()> {
2604            encoder.debug_check_bounds::<RemoteServiceReadByTypeResponse>(offset);
2605            // Delegate to tuple encoding.
2606            fidl::encoding::Encode::<RemoteServiceReadByTypeResponse, D>::encode(
2607                (
2608                    <fidl::encoding::Vector<ReadByTypeResult, 65535> as fidl::encoding::ValueTypeMarker>::borrow(&self.results),
2609                ),
2610                encoder, offset, _depth
2611            )
2612        }
2613    }
2614    unsafe impl<
2615        D: fidl::encoding::ResourceDialect,
2616        T0: fidl::encoding::Encode<fidl::encoding::Vector<ReadByTypeResult, 65535>, D>,
2617    > fidl::encoding::Encode<RemoteServiceReadByTypeResponse, D> for (T0,)
2618    {
2619        #[inline]
2620        unsafe fn encode(
2621            self,
2622            encoder: &mut fidl::encoding::Encoder<'_, D>,
2623            offset: usize,
2624            depth: fidl::encoding::Depth,
2625        ) -> fidl::Result<()> {
2626            encoder.debug_check_bounds::<RemoteServiceReadByTypeResponse>(offset);
2627            // Zero out padding regions. There's no need to apply masks
2628            // because the unmasked parts will be overwritten by fields.
2629            // Write the fields.
2630            self.0.encode(encoder, offset + 0, depth)?;
2631            Ok(())
2632        }
2633    }
2634
2635    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2636        for RemoteServiceReadByTypeResponse
2637    {
2638        #[inline(always)]
2639        fn new_empty() -> Self {
2640            Self { results: fidl::new_empty!(fidl::encoding::Vector<ReadByTypeResult, 65535>, D) }
2641        }
2642
2643        #[inline]
2644        unsafe fn decode(
2645            &mut self,
2646            decoder: &mut fidl::encoding::Decoder<'_, D>,
2647            offset: usize,
2648            _depth: fidl::encoding::Depth,
2649        ) -> fidl::Result<()> {
2650            decoder.debug_check_bounds::<Self>(offset);
2651            // Verify that padding bytes are zero.
2652            fidl::decode!(fidl::encoding::Vector<ReadByTypeResult, 65535>, D, &mut self.results, decoder, offset + 0, _depth)?;
2653            Ok(())
2654        }
2655    }
2656
2657    impl fidl::encoding::ValueTypeMarker for RemoteServiceReadCharacteristicResponse {
2658        type Borrowed<'a> = &'a Self;
2659        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2660            value
2661        }
2662    }
2663
2664    unsafe impl fidl::encoding::TypeMarker for RemoteServiceReadCharacteristicResponse {
2665        type Owned = Self;
2666
2667        #[inline(always)]
2668        fn inline_align(_context: fidl::encoding::Context) -> usize {
2669            8
2670        }
2671
2672        #[inline(always)]
2673        fn inline_size(_context: fidl::encoding::Context) -> usize {
2674            16
2675        }
2676    }
2677
2678    unsafe impl<D: fidl::encoding::ResourceDialect>
2679        fidl::encoding::Encode<RemoteServiceReadCharacteristicResponse, D>
2680        for &RemoteServiceReadCharacteristicResponse
2681    {
2682        #[inline]
2683        unsafe fn encode(
2684            self,
2685            encoder: &mut fidl::encoding::Encoder<'_, D>,
2686            offset: usize,
2687            _depth: fidl::encoding::Depth,
2688        ) -> fidl::Result<()> {
2689            encoder.debug_check_bounds::<RemoteServiceReadCharacteristicResponse>(offset);
2690            // Delegate to tuple encoding.
2691            fidl::encoding::Encode::<RemoteServiceReadCharacteristicResponse, D>::encode(
2692                (<ReadValue as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
2693                encoder,
2694                offset,
2695                _depth,
2696            )
2697        }
2698    }
2699    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ReadValue, D>>
2700        fidl::encoding::Encode<RemoteServiceReadCharacteristicResponse, D> for (T0,)
2701    {
2702        #[inline]
2703        unsafe fn encode(
2704            self,
2705            encoder: &mut fidl::encoding::Encoder<'_, D>,
2706            offset: usize,
2707            depth: fidl::encoding::Depth,
2708        ) -> fidl::Result<()> {
2709            encoder.debug_check_bounds::<RemoteServiceReadCharacteristicResponse>(offset);
2710            // Zero out padding regions. There's no need to apply masks
2711            // because the unmasked parts will be overwritten by fields.
2712            // Write the fields.
2713            self.0.encode(encoder, offset + 0, depth)?;
2714            Ok(())
2715        }
2716    }
2717
2718    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2719        for RemoteServiceReadCharacteristicResponse
2720    {
2721        #[inline(always)]
2722        fn new_empty() -> Self {
2723            Self { value: fidl::new_empty!(ReadValue, D) }
2724        }
2725
2726        #[inline]
2727        unsafe fn decode(
2728            &mut self,
2729            decoder: &mut fidl::encoding::Decoder<'_, D>,
2730            offset: usize,
2731            _depth: fidl::encoding::Depth,
2732        ) -> fidl::Result<()> {
2733            decoder.debug_check_bounds::<Self>(offset);
2734            // Verify that padding bytes are zero.
2735            fidl::decode!(ReadValue, D, &mut self.value, decoder, offset + 0, _depth)?;
2736            Ok(())
2737        }
2738    }
2739
2740    impl fidl::encoding::ValueTypeMarker for RemoteServiceReadDescriptorResponse {
2741        type Borrowed<'a> = &'a Self;
2742        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2743            value
2744        }
2745    }
2746
2747    unsafe impl fidl::encoding::TypeMarker for RemoteServiceReadDescriptorResponse {
2748        type Owned = Self;
2749
2750        #[inline(always)]
2751        fn inline_align(_context: fidl::encoding::Context) -> usize {
2752            8
2753        }
2754
2755        #[inline(always)]
2756        fn inline_size(_context: fidl::encoding::Context) -> usize {
2757            16
2758        }
2759    }
2760
2761    unsafe impl<D: fidl::encoding::ResourceDialect>
2762        fidl::encoding::Encode<RemoteServiceReadDescriptorResponse, D>
2763        for &RemoteServiceReadDescriptorResponse
2764    {
2765        #[inline]
2766        unsafe fn encode(
2767            self,
2768            encoder: &mut fidl::encoding::Encoder<'_, D>,
2769            offset: usize,
2770            _depth: fidl::encoding::Depth,
2771        ) -> fidl::Result<()> {
2772            encoder.debug_check_bounds::<RemoteServiceReadDescriptorResponse>(offset);
2773            // Delegate to tuple encoding.
2774            fidl::encoding::Encode::<RemoteServiceReadDescriptorResponse, D>::encode(
2775                (<ReadValue as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
2776                encoder,
2777                offset,
2778                _depth,
2779            )
2780        }
2781    }
2782    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ReadValue, D>>
2783        fidl::encoding::Encode<RemoteServiceReadDescriptorResponse, D> for (T0,)
2784    {
2785        #[inline]
2786        unsafe fn encode(
2787            self,
2788            encoder: &mut fidl::encoding::Encoder<'_, D>,
2789            offset: usize,
2790            depth: fidl::encoding::Depth,
2791        ) -> fidl::Result<()> {
2792            encoder.debug_check_bounds::<RemoteServiceReadDescriptorResponse>(offset);
2793            // Zero out padding regions. There's no need to apply masks
2794            // because the unmasked parts will be overwritten by fields.
2795            // Write the fields.
2796            self.0.encode(encoder, offset + 0, depth)?;
2797            Ok(())
2798        }
2799    }
2800
2801    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2802        for RemoteServiceReadDescriptorResponse
2803    {
2804        #[inline(always)]
2805        fn new_empty() -> Self {
2806            Self { value: fidl::new_empty!(ReadValue, D) }
2807        }
2808
2809        #[inline]
2810        unsafe fn decode(
2811            &mut self,
2812            decoder: &mut fidl::encoding::Decoder<'_, D>,
2813            offset: usize,
2814            _depth: fidl::encoding::Depth,
2815        ) -> fidl::Result<()> {
2816            decoder.debug_check_bounds::<Self>(offset);
2817            // Verify that padding bytes are zero.
2818            fidl::decode!(ReadValue, D, &mut self.value, decoder, offset + 0, _depth)?;
2819            Ok(())
2820        }
2821    }
2822
2823    impl fidl::encoding::ValueTypeMarker for ServiceHandle {
2824        type Borrowed<'a> = &'a Self;
2825        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2826            value
2827        }
2828    }
2829
2830    unsafe impl fidl::encoding::TypeMarker for ServiceHandle {
2831        type Owned = Self;
2832
2833        #[inline(always)]
2834        fn inline_align(_context: fidl::encoding::Context) -> usize {
2835            8
2836        }
2837
2838        #[inline(always)]
2839        fn inline_size(_context: fidl::encoding::Context) -> usize {
2840            8
2841        }
2842        #[inline(always)]
2843        fn encode_is_copy() -> bool {
2844            true
2845        }
2846
2847        #[inline(always)]
2848        fn decode_is_copy() -> bool {
2849            true
2850        }
2851    }
2852
2853    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ServiceHandle, D>
2854        for &ServiceHandle
2855    {
2856        #[inline]
2857        unsafe fn encode(
2858            self,
2859            encoder: &mut fidl::encoding::Encoder<'_, D>,
2860            offset: usize,
2861            _depth: fidl::encoding::Depth,
2862        ) -> fidl::Result<()> {
2863            encoder.debug_check_bounds::<ServiceHandle>(offset);
2864            unsafe {
2865                // Copy the object into the buffer.
2866                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2867                (buf_ptr as *mut ServiceHandle)
2868                    .write_unaligned((self as *const ServiceHandle).read());
2869                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2870                // done second because the memcpy will write garbage to these bytes.
2871            }
2872            Ok(())
2873        }
2874    }
2875    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
2876        fidl::encoding::Encode<ServiceHandle, D> for (T0,)
2877    {
2878        #[inline]
2879        unsafe fn encode(
2880            self,
2881            encoder: &mut fidl::encoding::Encoder<'_, D>,
2882            offset: usize,
2883            depth: fidl::encoding::Depth,
2884        ) -> fidl::Result<()> {
2885            encoder.debug_check_bounds::<ServiceHandle>(offset);
2886            // Zero out padding regions. There's no need to apply masks
2887            // because the unmasked parts will be overwritten by fields.
2888            // Write the fields.
2889            self.0.encode(encoder, offset + 0, depth)?;
2890            Ok(())
2891        }
2892    }
2893
2894    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ServiceHandle {
2895        #[inline(always)]
2896        fn new_empty() -> Self {
2897            Self { value: fidl::new_empty!(u64, D) }
2898        }
2899
2900        #[inline]
2901        unsafe fn decode(
2902            &mut self,
2903            decoder: &mut fidl::encoding::Decoder<'_, D>,
2904            offset: usize,
2905            _depth: fidl::encoding::Depth,
2906        ) -> fidl::Result<()> {
2907            decoder.debug_check_bounds::<Self>(offset);
2908            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2909            // Verify that padding bytes are zero.
2910            // Copy from the buffer into the object.
2911            unsafe {
2912                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
2913            }
2914            Ok(())
2915        }
2916    }
2917
2918    impl fidl::encoding::ValueTypeMarker for ShortReadOptions {
2919        type Borrowed<'a> = &'a Self;
2920        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2921            value
2922        }
2923    }
2924
2925    unsafe impl fidl::encoding::TypeMarker for ShortReadOptions {
2926        type Owned = Self;
2927
2928        #[inline(always)]
2929        fn inline_align(_context: fidl::encoding::Context) -> usize {
2930            1
2931        }
2932
2933        #[inline(always)]
2934        fn inline_size(_context: fidl::encoding::Context) -> usize {
2935            1
2936        }
2937    }
2938
2939    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ShortReadOptions, D>
2940        for &ShortReadOptions
2941    {
2942        #[inline]
2943        unsafe fn encode(
2944            self,
2945            encoder: &mut fidl::encoding::Encoder<'_, D>,
2946            offset: usize,
2947            _depth: fidl::encoding::Depth,
2948        ) -> fidl::Result<()> {
2949            encoder.debug_check_bounds::<ShortReadOptions>(offset);
2950            encoder.write_num(0u8, offset);
2951            Ok(())
2952        }
2953    }
2954
2955    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ShortReadOptions {
2956        #[inline(always)]
2957        fn new_empty() -> Self {
2958            Self
2959        }
2960
2961        #[inline]
2962        unsafe fn decode(
2963            &mut self,
2964            decoder: &mut fidl::encoding::Decoder<'_, D>,
2965            offset: usize,
2966            _depth: fidl::encoding::Depth,
2967        ) -> fidl::Result<()> {
2968            decoder.debug_check_bounds::<Self>(offset);
2969            match decoder.read_num::<u8>(offset) {
2970                0 => Ok(()),
2971                _ => Err(fidl::Error::Invalid),
2972            }
2973        }
2974    }
2975
2976    impl AttributePermissions {
2977        #[inline(always)]
2978        fn max_ordinal_present(&self) -> u64 {
2979            if let Some(_) = self.update {
2980                return 3;
2981            }
2982            if let Some(_) = self.write {
2983                return 2;
2984            }
2985            if let Some(_) = self.read {
2986                return 1;
2987            }
2988            0
2989        }
2990    }
2991
2992    impl fidl::encoding::ValueTypeMarker for AttributePermissions {
2993        type Borrowed<'a> = &'a Self;
2994        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2995            value
2996        }
2997    }
2998
2999    unsafe impl fidl::encoding::TypeMarker for AttributePermissions {
3000        type Owned = Self;
3001
3002        #[inline(always)]
3003        fn inline_align(_context: fidl::encoding::Context) -> usize {
3004            8
3005        }
3006
3007        #[inline(always)]
3008        fn inline_size(_context: fidl::encoding::Context) -> usize {
3009            16
3010        }
3011    }
3012
3013    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AttributePermissions, D>
3014        for &AttributePermissions
3015    {
3016        unsafe fn encode(
3017            self,
3018            encoder: &mut fidl::encoding::Encoder<'_, D>,
3019            offset: usize,
3020            mut depth: fidl::encoding::Depth,
3021        ) -> fidl::Result<()> {
3022            encoder.debug_check_bounds::<AttributePermissions>(offset);
3023            // Vector header
3024            let max_ordinal: u64 = self.max_ordinal_present();
3025            encoder.write_num(max_ordinal, offset);
3026            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3027            // Calling encoder.out_of_line_offset(0) is not allowed.
3028            if max_ordinal == 0 {
3029                return Ok(());
3030            }
3031            depth.increment()?;
3032            let envelope_size = 8;
3033            let bytes_len = max_ordinal as usize * envelope_size;
3034            #[allow(unused_variables)]
3035            let offset = encoder.out_of_line_offset(bytes_len);
3036            let mut _prev_end_offset: usize = 0;
3037            if 1 > max_ordinal {
3038                return Ok(());
3039            }
3040
3041            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3042            // are envelope_size bytes.
3043            let cur_offset: usize = (1 - 1) * envelope_size;
3044
3045            // Zero reserved fields.
3046            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3047
3048            // Safety:
3049            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3050            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3051            //   envelope_size bytes, there is always sufficient room.
3052            fidl::encoding::encode_in_envelope_optional::<SecurityRequirements, D>(
3053                self.read
3054                    .as_ref()
3055                    .map(<SecurityRequirements as fidl::encoding::ValueTypeMarker>::borrow),
3056                encoder,
3057                offset + cur_offset,
3058                depth,
3059            )?;
3060
3061            _prev_end_offset = cur_offset + envelope_size;
3062            if 2 > max_ordinal {
3063                return Ok(());
3064            }
3065
3066            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3067            // are envelope_size bytes.
3068            let cur_offset: usize = (2 - 1) * envelope_size;
3069
3070            // Zero reserved fields.
3071            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3072
3073            // Safety:
3074            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3075            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3076            //   envelope_size bytes, there is always sufficient room.
3077            fidl::encoding::encode_in_envelope_optional::<SecurityRequirements, D>(
3078                self.write
3079                    .as_ref()
3080                    .map(<SecurityRequirements as fidl::encoding::ValueTypeMarker>::borrow),
3081                encoder,
3082                offset + cur_offset,
3083                depth,
3084            )?;
3085
3086            _prev_end_offset = cur_offset + envelope_size;
3087            if 3 > max_ordinal {
3088                return Ok(());
3089            }
3090
3091            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3092            // are envelope_size bytes.
3093            let cur_offset: usize = (3 - 1) * envelope_size;
3094
3095            // Zero reserved fields.
3096            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3097
3098            // Safety:
3099            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3100            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3101            //   envelope_size bytes, there is always sufficient room.
3102            fidl::encoding::encode_in_envelope_optional::<SecurityRequirements, D>(
3103                self.update
3104                    .as_ref()
3105                    .map(<SecurityRequirements as fidl::encoding::ValueTypeMarker>::borrow),
3106                encoder,
3107                offset + cur_offset,
3108                depth,
3109            )?;
3110
3111            _prev_end_offset = cur_offset + envelope_size;
3112
3113            Ok(())
3114        }
3115    }
3116
3117    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AttributePermissions {
3118        #[inline(always)]
3119        fn new_empty() -> Self {
3120            Self::default()
3121        }
3122
3123        unsafe fn decode(
3124            &mut self,
3125            decoder: &mut fidl::encoding::Decoder<'_, D>,
3126            offset: usize,
3127            mut depth: fidl::encoding::Depth,
3128        ) -> fidl::Result<()> {
3129            decoder.debug_check_bounds::<Self>(offset);
3130            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3131                None => return Err(fidl::Error::NotNullable),
3132                Some(len) => len,
3133            };
3134            // Calling decoder.out_of_line_offset(0) is not allowed.
3135            if len == 0 {
3136                return Ok(());
3137            };
3138            depth.increment()?;
3139            let envelope_size = 8;
3140            let bytes_len = len * envelope_size;
3141            let offset = decoder.out_of_line_offset(bytes_len)?;
3142            // Decode the envelope for each type.
3143            let mut _next_ordinal_to_read = 0;
3144            let mut next_offset = offset;
3145            let end_offset = offset + bytes_len;
3146            _next_ordinal_to_read += 1;
3147            if next_offset >= end_offset {
3148                return Ok(());
3149            }
3150
3151            // Decode unknown envelopes for gaps in ordinals.
3152            while _next_ordinal_to_read < 1 {
3153                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3154                _next_ordinal_to_read += 1;
3155                next_offset += envelope_size;
3156            }
3157
3158            let next_out_of_line = decoder.next_out_of_line();
3159            let handles_before = decoder.remaining_handles();
3160            if let Some((inlined, num_bytes, num_handles)) =
3161                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3162            {
3163                let member_inline_size =
3164                    <SecurityRequirements as fidl::encoding::TypeMarker>::inline_size(
3165                        decoder.context,
3166                    );
3167                if inlined != (member_inline_size <= 4) {
3168                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3169                }
3170                let inner_offset;
3171                let mut inner_depth = depth.clone();
3172                if inlined {
3173                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3174                    inner_offset = next_offset;
3175                } else {
3176                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3177                    inner_depth.increment()?;
3178                }
3179                let val_ref =
3180                    self.read.get_or_insert_with(|| fidl::new_empty!(SecurityRequirements, D));
3181                fidl::decode!(
3182                    SecurityRequirements,
3183                    D,
3184                    val_ref,
3185                    decoder,
3186                    inner_offset,
3187                    inner_depth
3188                )?;
3189                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3190                {
3191                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3192                }
3193                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3194                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3195                }
3196            }
3197
3198            next_offset += envelope_size;
3199            _next_ordinal_to_read += 1;
3200            if next_offset >= end_offset {
3201                return Ok(());
3202            }
3203
3204            // Decode unknown envelopes for gaps in ordinals.
3205            while _next_ordinal_to_read < 2 {
3206                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3207                _next_ordinal_to_read += 1;
3208                next_offset += envelope_size;
3209            }
3210
3211            let next_out_of_line = decoder.next_out_of_line();
3212            let handles_before = decoder.remaining_handles();
3213            if let Some((inlined, num_bytes, num_handles)) =
3214                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3215            {
3216                let member_inline_size =
3217                    <SecurityRequirements as fidl::encoding::TypeMarker>::inline_size(
3218                        decoder.context,
3219                    );
3220                if inlined != (member_inline_size <= 4) {
3221                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3222                }
3223                let inner_offset;
3224                let mut inner_depth = depth.clone();
3225                if inlined {
3226                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3227                    inner_offset = next_offset;
3228                } else {
3229                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3230                    inner_depth.increment()?;
3231                }
3232                let val_ref =
3233                    self.write.get_or_insert_with(|| fidl::new_empty!(SecurityRequirements, D));
3234                fidl::decode!(
3235                    SecurityRequirements,
3236                    D,
3237                    val_ref,
3238                    decoder,
3239                    inner_offset,
3240                    inner_depth
3241                )?;
3242                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3243                {
3244                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3245                }
3246                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3247                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3248                }
3249            }
3250
3251            next_offset += envelope_size;
3252            _next_ordinal_to_read += 1;
3253            if next_offset >= end_offset {
3254                return Ok(());
3255            }
3256
3257            // Decode unknown envelopes for gaps in ordinals.
3258            while _next_ordinal_to_read < 3 {
3259                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3260                _next_ordinal_to_read += 1;
3261                next_offset += envelope_size;
3262            }
3263
3264            let next_out_of_line = decoder.next_out_of_line();
3265            let handles_before = decoder.remaining_handles();
3266            if let Some((inlined, num_bytes, num_handles)) =
3267                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3268            {
3269                let member_inline_size =
3270                    <SecurityRequirements as fidl::encoding::TypeMarker>::inline_size(
3271                        decoder.context,
3272                    );
3273                if inlined != (member_inline_size <= 4) {
3274                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3275                }
3276                let inner_offset;
3277                let mut inner_depth = depth.clone();
3278                if inlined {
3279                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3280                    inner_offset = next_offset;
3281                } else {
3282                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3283                    inner_depth.increment()?;
3284                }
3285                let val_ref =
3286                    self.update.get_or_insert_with(|| fidl::new_empty!(SecurityRequirements, D));
3287                fidl::decode!(
3288                    SecurityRequirements,
3289                    D,
3290                    val_ref,
3291                    decoder,
3292                    inner_offset,
3293                    inner_depth
3294                )?;
3295                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3296                {
3297                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3298                }
3299                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3300                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3301                }
3302            }
3303
3304            next_offset += envelope_size;
3305
3306            // Decode the remaining unknown envelopes.
3307            while next_offset < end_offset {
3308                _next_ordinal_to_read += 1;
3309                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3310                next_offset += envelope_size;
3311            }
3312
3313            Ok(())
3314        }
3315    }
3316
3317    impl Characteristic {
3318        #[inline(always)]
3319        fn max_ordinal_present(&self) -> u64 {
3320            if let Some(_) = self.descriptors {
3321                return 5;
3322            }
3323            if let Some(_) = self.permissions {
3324                return 4;
3325            }
3326            if let Some(_) = self.properties {
3327                return 3;
3328            }
3329            if let Some(_) = self.type_ {
3330                return 2;
3331            }
3332            if let Some(_) = self.handle {
3333                return 1;
3334            }
3335            0
3336        }
3337    }
3338
3339    impl fidl::encoding::ValueTypeMarker for Characteristic {
3340        type Borrowed<'a> = &'a Self;
3341        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3342            value
3343        }
3344    }
3345
3346    unsafe impl fidl::encoding::TypeMarker for Characteristic {
3347        type Owned = Self;
3348
3349        #[inline(always)]
3350        fn inline_align(_context: fidl::encoding::Context) -> usize {
3351            8
3352        }
3353
3354        #[inline(always)]
3355        fn inline_size(_context: fidl::encoding::Context) -> usize {
3356            16
3357        }
3358    }
3359
3360    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Characteristic, D>
3361        for &Characteristic
3362    {
3363        unsafe fn encode(
3364            self,
3365            encoder: &mut fidl::encoding::Encoder<'_, D>,
3366            offset: usize,
3367            mut depth: fidl::encoding::Depth,
3368        ) -> fidl::Result<()> {
3369            encoder.debug_check_bounds::<Characteristic>(offset);
3370            // Vector header
3371            let max_ordinal: u64 = self.max_ordinal_present();
3372            encoder.write_num(max_ordinal, offset);
3373            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3374            // Calling encoder.out_of_line_offset(0) is not allowed.
3375            if max_ordinal == 0 {
3376                return Ok(());
3377            }
3378            depth.increment()?;
3379            let envelope_size = 8;
3380            let bytes_len = max_ordinal as usize * envelope_size;
3381            #[allow(unused_variables)]
3382            let offset = encoder.out_of_line_offset(bytes_len);
3383            let mut _prev_end_offset: usize = 0;
3384            if 1 > max_ordinal {
3385                return Ok(());
3386            }
3387
3388            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3389            // are envelope_size bytes.
3390            let cur_offset: usize = (1 - 1) * envelope_size;
3391
3392            // Zero reserved fields.
3393            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3394
3395            // Safety:
3396            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3397            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3398            //   envelope_size bytes, there is always sufficient room.
3399            fidl::encoding::encode_in_envelope_optional::<Handle, D>(
3400                self.handle.as_ref().map(<Handle as fidl::encoding::ValueTypeMarker>::borrow),
3401                encoder,
3402                offset + cur_offset,
3403                depth,
3404            )?;
3405
3406            _prev_end_offset = cur_offset + envelope_size;
3407            if 2 > max_ordinal {
3408                return Ok(());
3409            }
3410
3411            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3412            // are envelope_size bytes.
3413            let cur_offset: usize = (2 - 1) * envelope_size;
3414
3415            // Zero reserved fields.
3416            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3417
3418            // Safety:
3419            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3420            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3421            //   envelope_size bytes, there is always sufficient room.
3422            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_common::Uuid, D>(
3423            self.type_.as_ref().map(<fidl_fuchsia_bluetooth_common::Uuid as fidl::encoding::ValueTypeMarker>::borrow),
3424            encoder, offset + cur_offset, depth
3425        )?;
3426
3427            _prev_end_offset = cur_offset + envelope_size;
3428            if 3 > max_ordinal {
3429                return Ok(());
3430            }
3431
3432            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3433            // are envelope_size bytes.
3434            let cur_offset: usize = (3 - 1) * envelope_size;
3435
3436            // Zero reserved fields.
3437            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3438
3439            // Safety:
3440            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3441            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3442            //   envelope_size bytes, there is always sufficient room.
3443            fidl::encoding::encode_in_envelope_optional::<CharacteristicPropertyBits, D>(
3444                self.properties
3445                    .as_ref()
3446                    .map(<CharacteristicPropertyBits as fidl::encoding::ValueTypeMarker>::borrow),
3447                encoder,
3448                offset + cur_offset,
3449                depth,
3450            )?;
3451
3452            _prev_end_offset = cur_offset + envelope_size;
3453            if 4 > max_ordinal {
3454                return Ok(());
3455            }
3456
3457            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3458            // are envelope_size bytes.
3459            let cur_offset: usize = (4 - 1) * envelope_size;
3460
3461            // Zero reserved fields.
3462            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3463
3464            // Safety:
3465            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3466            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3467            //   envelope_size bytes, there is always sufficient room.
3468            fidl::encoding::encode_in_envelope_optional::<AttributePermissions, D>(
3469                self.permissions
3470                    .as_ref()
3471                    .map(<AttributePermissions as fidl::encoding::ValueTypeMarker>::borrow),
3472                encoder,
3473                offset + cur_offset,
3474                depth,
3475            )?;
3476
3477            _prev_end_offset = cur_offset + envelope_size;
3478            if 5 > max_ordinal {
3479                return Ok(());
3480            }
3481
3482            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3483            // are envelope_size bytes.
3484            let cur_offset: usize = (5 - 1) * envelope_size;
3485
3486            // Zero reserved fields.
3487            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3488
3489            // Safety:
3490            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3491            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3492            //   envelope_size bytes, there is always sufficient room.
3493            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Descriptor, 65532>, D>(
3494            self.descriptors.as_ref().map(<fidl::encoding::Vector<Descriptor, 65532> as fidl::encoding::ValueTypeMarker>::borrow),
3495            encoder, offset + cur_offset, depth
3496        )?;
3497
3498            _prev_end_offset = cur_offset + envelope_size;
3499
3500            Ok(())
3501        }
3502    }
3503
3504    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Characteristic {
3505        #[inline(always)]
3506        fn new_empty() -> Self {
3507            Self::default()
3508        }
3509
3510        unsafe fn decode(
3511            &mut self,
3512            decoder: &mut fidl::encoding::Decoder<'_, D>,
3513            offset: usize,
3514            mut depth: fidl::encoding::Depth,
3515        ) -> fidl::Result<()> {
3516            decoder.debug_check_bounds::<Self>(offset);
3517            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3518                None => return Err(fidl::Error::NotNullable),
3519                Some(len) => len,
3520            };
3521            // Calling decoder.out_of_line_offset(0) is not allowed.
3522            if len == 0 {
3523                return Ok(());
3524            };
3525            depth.increment()?;
3526            let envelope_size = 8;
3527            let bytes_len = len * envelope_size;
3528            let offset = decoder.out_of_line_offset(bytes_len)?;
3529            // Decode the envelope for each type.
3530            let mut _next_ordinal_to_read = 0;
3531            let mut next_offset = offset;
3532            let end_offset = offset + bytes_len;
3533            _next_ordinal_to_read += 1;
3534            if next_offset >= end_offset {
3535                return Ok(());
3536            }
3537
3538            // Decode unknown envelopes for gaps in ordinals.
3539            while _next_ordinal_to_read < 1 {
3540                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3541                _next_ordinal_to_read += 1;
3542                next_offset += envelope_size;
3543            }
3544
3545            let next_out_of_line = decoder.next_out_of_line();
3546            let handles_before = decoder.remaining_handles();
3547            if let Some((inlined, num_bytes, num_handles)) =
3548                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3549            {
3550                let member_inline_size =
3551                    <Handle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3552                if inlined != (member_inline_size <= 4) {
3553                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3554                }
3555                let inner_offset;
3556                let mut inner_depth = depth.clone();
3557                if inlined {
3558                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3559                    inner_offset = next_offset;
3560                } else {
3561                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3562                    inner_depth.increment()?;
3563                }
3564                let val_ref = self.handle.get_or_insert_with(|| fidl::new_empty!(Handle, D));
3565                fidl::decode!(Handle, D, val_ref, decoder, inner_offset, inner_depth)?;
3566                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3567                {
3568                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3569                }
3570                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3571                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3572                }
3573            }
3574
3575            next_offset += envelope_size;
3576            _next_ordinal_to_read += 1;
3577            if next_offset >= end_offset {
3578                return Ok(());
3579            }
3580
3581            // Decode unknown envelopes for gaps in ordinals.
3582            while _next_ordinal_to_read < 2 {
3583                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3584                _next_ordinal_to_read += 1;
3585                next_offset += envelope_size;
3586            }
3587
3588            let next_out_of_line = decoder.next_out_of_line();
3589            let handles_before = decoder.remaining_handles();
3590            if let Some((inlined, num_bytes, num_handles)) =
3591                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3592            {
3593                let member_inline_size = <fidl_fuchsia_bluetooth_common::Uuid as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3594                if inlined != (member_inline_size <= 4) {
3595                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3596                }
3597                let inner_offset;
3598                let mut inner_depth = depth.clone();
3599                if inlined {
3600                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3601                    inner_offset = next_offset;
3602                } else {
3603                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3604                    inner_depth.increment()?;
3605                }
3606                let val_ref = self.type_.get_or_insert_with(|| {
3607                    fidl::new_empty!(fidl_fuchsia_bluetooth_common::Uuid, D)
3608                });
3609                fidl::decode!(
3610                    fidl_fuchsia_bluetooth_common::Uuid,
3611                    D,
3612                    val_ref,
3613                    decoder,
3614                    inner_offset,
3615                    inner_depth
3616                )?;
3617                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3618                {
3619                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3620                }
3621                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3622                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3623                }
3624            }
3625
3626            next_offset += envelope_size;
3627            _next_ordinal_to_read += 1;
3628            if next_offset >= end_offset {
3629                return Ok(());
3630            }
3631
3632            // Decode unknown envelopes for gaps in ordinals.
3633            while _next_ordinal_to_read < 3 {
3634                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3635                _next_ordinal_to_read += 1;
3636                next_offset += envelope_size;
3637            }
3638
3639            let next_out_of_line = decoder.next_out_of_line();
3640            let handles_before = decoder.remaining_handles();
3641            if let Some((inlined, num_bytes, num_handles)) =
3642                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3643            {
3644                let member_inline_size =
3645                    <CharacteristicPropertyBits as fidl::encoding::TypeMarker>::inline_size(
3646                        decoder.context,
3647                    );
3648                if inlined != (member_inline_size <= 4) {
3649                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3650                }
3651                let inner_offset;
3652                let mut inner_depth = depth.clone();
3653                if inlined {
3654                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3655                    inner_offset = next_offset;
3656                } else {
3657                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3658                    inner_depth.increment()?;
3659                }
3660                let val_ref = self
3661                    .properties
3662                    .get_or_insert_with(|| fidl::new_empty!(CharacteristicPropertyBits, D));
3663                fidl::decode!(
3664                    CharacteristicPropertyBits,
3665                    D,
3666                    val_ref,
3667                    decoder,
3668                    inner_offset,
3669                    inner_depth
3670                )?;
3671                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3672                {
3673                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3674                }
3675                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3676                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3677                }
3678            }
3679
3680            next_offset += envelope_size;
3681            _next_ordinal_to_read += 1;
3682            if next_offset >= end_offset {
3683                return Ok(());
3684            }
3685
3686            // Decode unknown envelopes for gaps in ordinals.
3687            while _next_ordinal_to_read < 4 {
3688                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3689                _next_ordinal_to_read += 1;
3690                next_offset += envelope_size;
3691            }
3692
3693            let next_out_of_line = decoder.next_out_of_line();
3694            let handles_before = decoder.remaining_handles();
3695            if let Some((inlined, num_bytes, num_handles)) =
3696                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3697            {
3698                let member_inline_size =
3699                    <AttributePermissions as fidl::encoding::TypeMarker>::inline_size(
3700                        decoder.context,
3701                    );
3702                if inlined != (member_inline_size <= 4) {
3703                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3704                }
3705                let inner_offset;
3706                let mut inner_depth = depth.clone();
3707                if inlined {
3708                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3709                    inner_offset = next_offset;
3710                } else {
3711                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3712                    inner_depth.increment()?;
3713                }
3714                let val_ref = self
3715                    .permissions
3716                    .get_or_insert_with(|| fidl::new_empty!(AttributePermissions, D));
3717                fidl::decode!(
3718                    AttributePermissions,
3719                    D,
3720                    val_ref,
3721                    decoder,
3722                    inner_offset,
3723                    inner_depth
3724                )?;
3725                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3726                {
3727                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3728                }
3729                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3730                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3731                }
3732            }
3733
3734            next_offset += envelope_size;
3735            _next_ordinal_to_read += 1;
3736            if next_offset >= end_offset {
3737                return Ok(());
3738            }
3739
3740            // Decode unknown envelopes for gaps in ordinals.
3741            while _next_ordinal_to_read < 5 {
3742                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3743                _next_ordinal_to_read += 1;
3744                next_offset += envelope_size;
3745            }
3746
3747            let next_out_of_line = decoder.next_out_of_line();
3748            let handles_before = decoder.remaining_handles();
3749            if let Some((inlined, num_bytes, num_handles)) =
3750                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3751            {
3752                let member_inline_size = <fidl::encoding::Vector<Descriptor, 65532> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3753                if inlined != (member_inline_size <= 4) {
3754                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3755                }
3756                let inner_offset;
3757                let mut inner_depth = depth.clone();
3758                if inlined {
3759                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3760                    inner_offset = next_offset;
3761                } else {
3762                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3763                    inner_depth.increment()?;
3764                }
3765                let val_ref = self.descriptors.get_or_insert_with(
3766                    || fidl::new_empty!(fidl::encoding::Vector<Descriptor, 65532>, D),
3767                );
3768                fidl::decode!(fidl::encoding::Vector<Descriptor, 65532>, D, val_ref, decoder, inner_offset, inner_depth)?;
3769                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3770                {
3771                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3772                }
3773                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3774                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3775                }
3776            }
3777
3778            next_offset += envelope_size;
3779
3780            // Decode the remaining unknown envelopes.
3781            while next_offset < end_offset {
3782                _next_ordinal_to_read += 1;
3783                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3784                next_offset += envelope_size;
3785            }
3786
3787            Ok(())
3788        }
3789    }
3790
3791    impl Descriptor {
3792        #[inline(always)]
3793        fn max_ordinal_present(&self) -> u64 {
3794            if let Some(_) = self.permissions {
3795                return 3;
3796            }
3797            if let Some(_) = self.type_ {
3798                return 2;
3799            }
3800            if let Some(_) = self.handle {
3801                return 1;
3802            }
3803            0
3804        }
3805    }
3806
3807    impl fidl::encoding::ValueTypeMarker for Descriptor {
3808        type Borrowed<'a> = &'a Self;
3809        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3810            value
3811        }
3812    }
3813
3814    unsafe impl fidl::encoding::TypeMarker for Descriptor {
3815        type Owned = Self;
3816
3817        #[inline(always)]
3818        fn inline_align(_context: fidl::encoding::Context) -> usize {
3819            8
3820        }
3821
3822        #[inline(always)]
3823        fn inline_size(_context: fidl::encoding::Context) -> usize {
3824            16
3825        }
3826    }
3827
3828    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Descriptor, D>
3829        for &Descriptor
3830    {
3831        unsafe fn encode(
3832            self,
3833            encoder: &mut fidl::encoding::Encoder<'_, D>,
3834            offset: usize,
3835            mut depth: fidl::encoding::Depth,
3836        ) -> fidl::Result<()> {
3837            encoder.debug_check_bounds::<Descriptor>(offset);
3838            // Vector header
3839            let max_ordinal: u64 = self.max_ordinal_present();
3840            encoder.write_num(max_ordinal, offset);
3841            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3842            // Calling encoder.out_of_line_offset(0) is not allowed.
3843            if max_ordinal == 0 {
3844                return Ok(());
3845            }
3846            depth.increment()?;
3847            let envelope_size = 8;
3848            let bytes_len = max_ordinal as usize * envelope_size;
3849            #[allow(unused_variables)]
3850            let offset = encoder.out_of_line_offset(bytes_len);
3851            let mut _prev_end_offset: usize = 0;
3852            if 1 > max_ordinal {
3853                return Ok(());
3854            }
3855
3856            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3857            // are envelope_size bytes.
3858            let cur_offset: usize = (1 - 1) * envelope_size;
3859
3860            // Zero reserved fields.
3861            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3862
3863            // Safety:
3864            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3865            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3866            //   envelope_size bytes, there is always sufficient room.
3867            fidl::encoding::encode_in_envelope_optional::<Handle, D>(
3868                self.handle.as_ref().map(<Handle as fidl::encoding::ValueTypeMarker>::borrow),
3869                encoder,
3870                offset + cur_offset,
3871                depth,
3872            )?;
3873
3874            _prev_end_offset = cur_offset + envelope_size;
3875            if 2 > max_ordinal {
3876                return Ok(());
3877            }
3878
3879            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3880            // are envelope_size bytes.
3881            let cur_offset: usize = (2 - 1) * envelope_size;
3882
3883            // Zero reserved fields.
3884            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3885
3886            // Safety:
3887            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3888            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3889            //   envelope_size bytes, there is always sufficient room.
3890            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_common::Uuid, D>(
3891            self.type_.as_ref().map(<fidl_fuchsia_bluetooth_common::Uuid as fidl::encoding::ValueTypeMarker>::borrow),
3892            encoder, offset + cur_offset, depth
3893        )?;
3894
3895            _prev_end_offset = cur_offset + envelope_size;
3896            if 3 > max_ordinal {
3897                return Ok(());
3898            }
3899
3900            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3901            // are envelope_size bytes.
3902            let cur_offset: usize = (3 - 1) * envelope_size;
3903
3904            // Zero reserved fields.
3905            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3906
3907            // Safety:
3908            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3909            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3910            //   envelope_size bytes, there is always sufficient room.
3911            fidl::encoding::encode_in_envelope_optional::<AttributePermissions, D>(
3912                self.permissions
3913                    .as_ref()
3914                    .map(<AttributePermissions as fidl::encoding::ValueTypeMarker>::borrow),
3915                encoder,
3916                offset + cur_offset,
3917                depth,
3918            )?;
3919
3920            _prev_end_offset = cur_offset + envelope_size;
3921
3922            Ok(())
3923        }
3924    }
3925
3926    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Descriptor {
3927        #[inline(always)]
3928        fn new_empty() -> Self {
3929            Self::default()
3930        }
3931
3932        unsafe fn decode(
3933            &mut self,
3934            decoder: &mut fidl::encoding::Decoder<'_, D>,
3935            offset: usize,
3936            mut depth: fidl::encoding::Depth,
3937        ) -> fidl::Result<()> {
3938            decoder.debug_check_bounds::<Self>(offset);
3939            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3940                None => return Err(fidl::Error::NotNullable),
3941                Some(len) => len,
3942            };
3943            // Calling decoder.out_of_line_offset(0) is not allowed.
3944            if len == 0 {
3945                return Ok(());
3946            };
3947            depth.increment()?;
3948            let envelope_size = 8;
3949            let bytes_len = len * envelope_size;
3950            let offset = decoder.out_of_line_offset(bytes_len)?;
3951            // Decode the envelope for each type.
3952            let mut _next_ordinal_to_read = 0;
3953            let mut next_offset = offset;
3954            let end_offset = offset + bytes_len;
3955            _next_ordinal_to_read += 1;
3956            if next_offset >= end_offset {
3957                return Ok(());
3958            }
3959
3960            // Decode unknown envelopes for gaps in ordinals.
3961            while _next_ordinal_to_read < 1 {
3962                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3963                _next_ordinal_to_read += 1;
3964                next_offset += envelope_size;
3965            }
3966
3967            let next_out_of_line = decoder.next_out_of_line();
3968            let handles_before = decoder.remaining_handles();
3969            if let Some((inlined, num_bytes, num_handles)) =
3970                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3971            {
3972                let member_inline_size =
3973                    <Handle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3974                if inlined != (member_inline_size <= 4) {
3975                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3976                }
3977                let inner_offset;
3978                let mut inner_depth = depth.clone();
3979                if inlined {
3980                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3981                    inner_offset = next_offset;
3982                } else {
3983                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3984                    inner_depth.increment()?;
3985                }
3986                let val_ref = self.handle.get_or_insert_with(|| fidl::new_empty!(Handle, D));
3987                fidl::decode!(Handle, D, val_ref, decoder, inner_offset, inner_depth)?;
3988                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3989                {
3990                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3991                }
3992                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3993                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3994                }
3995            }
3996
3997            next_offset += envelope_size;
3998            _next_ordinal_to_read += 1;
3999            if next_offset >= end_offset {
4000                return Ok(());
4001            }
4002
4003            // Decode unknown envelopes for gaps in ordinals.
4004            while _next_ordinal_to_read < 2 {
4005                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4006                _next_ordinal_to_read += 1;
4007                next_offset += envelope_size;
4008            }
4009
4010            let next_out_of_line = decoder.next_out_of_line();
4011            let handles_before = decoder.remaining_handles();
4012            if let Some((inlined, num_bytes, num_handles)) =
4013                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4014            {
4015                let member_inline_size = <fidl_fuchsia_bluetooth_common::Uuid as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4016                if inlined != (member_inline_size <= 4) {
4017                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4018                }
4019                let inner_offset;
4020                let mut inner_depth = depth.clone();
4021                if inlined {
4022                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4023                    inner_offset = next_offset;
4024                } else {
4025                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4026                    inner_depth.increment()?;
4027                }
4028                let val_ref = self.type_.get_or_insert_with(|| {
4029                    fidl::new_empty!(fidl_fuchsia_bluetooth_common::Uuid, D)
4030                });
4031                fidl::decode!(
4032                    fidl_fuchsia_bluetooth_common::Uuid,
4033                    D,
4034                    val_ref,
4035                    decoder,
4036                    inner_offset,
4037                    inner_depth
4038                )?;
4039                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4040                {
4041                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4042                }
4043                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4044                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4045                }
4046            }
4047
4048            next_offset += envelope_size;
4049            _next_ordinal_to_read += 1;
4050            if next_offset >= end_offset {
4051                return Ok(());
4052            }
4053
4054            // Decode unknown envelopes for gaps in ordinals.
4055            while _next_ordinal_to_read < 3 {
4056                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4057                _next_ordinal_to_read += 1;
4058                next_offset += envelope_size;
4059            }
4060
4061            let next_out_of_line = decoder.next_out_of_line();
4062            let handles_before = decoder.remaining_handles();
4063            if let Some((inlined, num_bytes, num_handles)) =
4064                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4065            {
4066                let member_inline_size =
4067                    <AttributePermissions as fidl::encoding::TypeMarker>::inline_size(
4068                        decoder.context,
4069                    );
4070                if inlined != (member_inline_size <= 4) {
4071                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4072                }
4073                let inner_offset;
4074                let mut inner_depth = depth.clone();
4075                if inlined {
4076                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4077                    inner_offset = next_offset;
4078                } else {
4079                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4080                    inner_depth.increment()?;
4081                }
4082                let val_ref = self
4083                    .permissions
4084                    .get_or_insert_with(|| fidl::new_empty!(AttributePermissions, D));
4085                fidl::decode!(
4086                    AttributePermissions,
4087                    D,
4088                    val_ref,
4089                    decoder,
4090                    inner_offset,
4091                    inner_depth
4092                )?;
4093                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4094                {
4095                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4096                }
4097                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4098                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4099                }
4100            }
4101
4102            next_offset += envelope_size;
4103
4104            // Decode the remaining unknown envelopes.
4105            while next_offset < end_offset {
4106                _next_ordinal_to_read += 1;
4107                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4108                next_offset += envelope_size;
4109            }
4110
4111            Ok(())
4112        }
4113    }
4114
4115    impl LocalServicePeerUpdateRequest {
4116        #[inline(always)]
4117        fn max_ordinal_present(&self) -> u64 {
4118            if let Some(_) = self.mtu {
4119                return 2;
4120            }
4121            if let Some(_) = self.peer_id {
4122                return 1;
4123            }
4124            0
4125        }
4126    }
4127
4128    impl fidl::encoding::ValueTypeMarker for LocalServicePeerUpdateRequest {
4129        type Borrowed<'a> = &'a Self;
4130        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4131            value
4132        }
4133    }
4134
4135    unsafe impl fidl::encoding::TypeMarker for LocalServicePeerUpdateRequest {
4136        type Owned = Self;
4137
4138        #[inline(always)]
4139        fn inline_align(_context: fidl::encoding::Context) -> usize {
4140            8
4141        }
4142
4143        #[inline(always)]
4144        fn inline_size(_context: fidl::encoding::Context) -> usize {
4145            16
4146        }
4147    }
4148
4149    unsafe impl<D: fidl::encoding::ResourceDialect>
4150        fidl::encoding::Encode<LocalServicePeerUpdateRequest, D>
4151        for &LocalServicePeerUpdateRequest
4152    {
4153        unsafe fn encode(
4154            self,
4155            encoder: &mut fidl::encoding::Encoder<'_, D>,
4156            offset: usize,
4157            mut depth: fidl::encoding::Depth,
4158        ) -> fidl::Result<()> {
4159            encoder.debug_check_bounds::<LocalServicePeerUpdateRequest>(offset);
4160            // Vector header
4161            let max_ordinal: u64 = self.max_ordinal_present();
4162            encoder.write_num(max_ordinal, offset);
4163            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4164            // Calling encoder.out_of_line_offset(0) is not allowed.
4165            if max_ordinal == 0 {
4166                return Ok(());
4167            }
4168            depth.increment()?;
4169            let envelope_size = 8;
4170            let bytes_len = max_ordinal as usize * envelope_size;
4171            #[allow(unused_variables)]
4172            let offset = encoder.out_of_line_offset(bytes_len);
4173            let mut _prev_end_offset: usize = 0;
4174            if 1 > max_ordinal {
4175                return Ok(());
4176            }
4177
4178            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4179            // are envelope_size bytes.
4180            let cur_offset: usize = (1 - 1) * envelope_size;
4181
4182            // Zero reserved fields.
4183            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4184
4185            // Safety:
4186            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4187            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4188            //   envelope_size bytes, there is always sufficient room.
4189            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_common::PeerId, D>(
4190            self.peer_id.as_ref().map(<fidl_fuchsia_bluetooth_common::PeerId as fidl::encoding::ValueTypeMarker>::borrow),
4191            encoder, offset + cur_offset, depth
4192        )?;
4193
4194            _prev_end_offset = cur_offset + envelope_size;
4195            if 2 > max_ordinal {
4196                return Ok(());
4197            }
4198
4199            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4200            // are envelope_size bytes.
4201            let cur_offset: usize = (2 - 1) * envelope_size;
4202
4203            // Zero reserved fields.
4204            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4205
4206            // Safety:
4207            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4208            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4209            //   envelope_size bytes, there is always sufficient room.
4210            fidl::encoding::encode_in_envelope_optional::<u16, D>(
4211                self.mtu.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
4212                encoder,
4213                offset + cur_offset,
4214                depth,
4215            )?;
4216
4217            _prev_end_offset = cur_offset + envelope_size;
4218
4219            Ok(())
4220        }
4221    }
4222
4223    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4224        for LocalServicePeerUpdateRequest
4225    {
4226        #[inline(always)]
4227        fn new_empty() -> Self {
4228            Self::default()
4229        }
4230
4231        unsafe fn decode(
4232            &mut self,
4233            decoder: &mut fidl::encoding::Decoder<'_, D>,
4234            offset: usize,
4235            mut depth: fidl::encoding::Depth,
4236        ) -> fidl::Result<()> {
4237            decoder.debug_check_bounds::<Self>(offset);
4238            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4239                None => return Err(fidl::Error::NotNullable),
4240                Some(len) => len,
4241            };
4242            // Calling decoder.out_of_line_offset(0) is not allowed.
4243            if len == 0 {
4244                return Ok(());
4245            };
4246            depth.increment()?;
4247            let envelope_size = 8;
4248            let bytes_len = len * envelope_size;
4249            let offset = decoder.out_of_line_offset(bytes_len)?;
4250            // Decode the envelope for each type.
4251            let mut _next_ordinal_to_read = 0;
4252            let mut next_offset = offset;
4253            let end_offset = offset + bytes_len;
4254            _next_ordinal_to_read += 1;
4255            if next_offset >= end_offset {
4256                return Ok(());
4257            }
4258
4259            // Decode unknown envelopes for gaps in ordinals.
4260            while _next_ordinal_to_read < 1 {
4261                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4262                _next_ordinal_to_read += 1;
4263                next_offset += envelope_size;
4264            }
4265
4266            let next_out_of_line = decoder.next_out_of_line();
4267            let handles_before = decoder.remaining_handles();
4268            if let Some((inlined, num_bytes, num_handles)) =
4269                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4270            {
4271                let member_inline_size = <fidl_fuchsia_bluetooth_common::PeerId as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4272                if inlined != (member_inline_size <= 4) {
4273                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4274                }
4275                let inner_offset;
4276                let mut inner_depth = depth.clone();
4277                if inlined {
4278                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4279                    inner_offset = next_offset;
4280                } else {
4281                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4282                    inner_depth.increment()?;
4283                }
4284                let val_ref = self.peer_id.get_or_insert_with(|| {
4285                    fidl::new_empty!(fidl_fuchsia_bluetooth_common::PeerId, D)
4286                });
4287                fidl::decode!(
4288                    fidl_fuchsia_bluetooth_common::PeerId,
4289                    D,
4290                    val_ref,
4291                    decoder,
4292                    inner_offset,
4293                    inner_depth
4294                )?;
4295                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4296                {
4297                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4298                }
4299                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4300                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4301                }
4302            }
4303
4304            next_offset += envelope_size;
4305            _next_ordinal_to_read += 1;
4306            if next_offset >= end_offset {
4307                return Ok(());
4308            }
4309
4310            // Decode unknown envelopes for gaps in ordinals.
4311            while _next_ordinal_to_read < 2 {
4312                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4313                _next_ordinal_to_read += 1;
4314                next_offset += envelope_size;
4315            }
4316
4317            let next_out_of_line = decoder.next_out_of_line();
4318            let handles_before = decoder.remaining_handles();
4319            if let Some((inlined, num_bytes, num_handles)) =
4320                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4321            {
4322                let member_inline_size =
4323                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4324                if inlined != (member_inline_size <= 4) {
4325                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4326                }
4327                let inner_offset;
4328                let mut inner_depth = depth.clone();
4329                if inlined {
4330                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4331                    inner_offset = next_offset;
4332                } else {
4333                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4334                    inner_depth.increment()?;
4335                }
4336                let val_ref = self.mtu.get_or_insert_with(|| fidl::new_empty!(u16, D));
4337                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
4338                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4339                {
4340                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4341                }
4342                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4343                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4344                }
4345            }
4346
4347            next_offset += envelope_size;
4348
4349            // Decode the remaining unknown envelopes.
4350            while next_offset < end_offset {
4351                _next_ordinal_to_read += 1;
4352                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4353                next_offset += envelope_size;
4354            }
4355
4356            Ok(())
4357        }
4358    }
4359
4360    impl LocalServiceWriteValueRequest {
4361        #[inline(always)]
4362        fn max_ordinal_present(&self) -> u64 {
4363            if let Some(_) = self.value {
4364                return 4;
4365            }
4366            if let Some(_) = self.offset {
4367                return 3;
4368            }
4369            if let Some(_) = self.handle {
4370                return 2;
4371            }
4372            if let Some(_) = self.peer_id {
4373                return 1;
4374            }
4375            0
4376        }
4377    }
4378
4379    impl fidl::encoding::ValueTypeMarker for LocalServiceWriteValueRequest {
4380        type Borrowed<'a> = &'a Self;
4381        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4382            value
4383        }
4384    }
4385
4386    unsafe impl fidl::encoding::TypeMarker for LocalServiceWriteValueRequest {
4387        type Owned = Self;
4388
4389        #[inline(always)]
4390        fn inline_align(_context: fidl::encoding::Context) -> usize {
4391            8
4392        }
4393
4394        #[inline(always)]
4395        fn inline_size(_context: fidl::encoding::Context) -> usize {
4396            16
4397        }
4398    }
4399
4400    unsafe impl<D: fidl::encoding::ResourceDialect>
4401        fidl::encoding::Encode<LocalServiceWriteValueRequest, D>
4402        for &LocalServiceWriteValueRequest
4403    {
4404        unsafe fn encode(
4405            self,
4406            encoder: &mut fidl::encoding::Encoder<'_, D>,
4407            offset: usize,
4408            mut depth: fidl::encoding::Depth,
4409        ) -> fidl::Result<()> {
4410            encoder.debug_check_bounds::<LocalServiceWriteValueRequest>(offset);
4411            // Vector header
4412            let max_ordinal: u64 = self.max_ordinal_present();
4413            encoder.write_num(max_ordinal, offset);
4414            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4415            // Calling encoder.out_of_line_offset(0) is not allowed.
4416            if max_ordinal == 0 {
4417                return Ok(());
4418            }
4419            depth.increment()?;
4420            let envelope_size = 8;
4421            let bytes_len = max_ordinal as usize * envelope_size;
4422            #[allow(unused_variables)]
4423            let offset = encoder.out_of_line_offset(bytes_len);
4424            let mut _prev_end_offset: usize = 0;
4425            if 1 > max_ordinal {
4426                return Ok(());
4427            }
4428
4429            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4430            // are envelope_size bytes.
4431            let cur_offset: usize = (1 - 1) * envelope_size;
4432
4433            // Zero reserved fields.
4434            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4435
4436            // Safety:
4437            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4438            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4439            //   envelope_size bytes, there is always sufficient room.
4440            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_common::PeerId, D>(
4441            self.peer_id.as_ref().map(<fidl_fuchsia_bluetooth_common::PeerId as fidl::encoding::ValueTypeMarker>::borrow),
4442            encoder, offset + cur_offset, depth
4443        )?;
4444
4445            _prev_end_offset = cur_offset + envelope_size;
4446            if 2 > max_ordinal {
4447                return Ok(());
4448            }
4449
4450            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4451            // are envelope_size bytes.
4452            let cur_offset: usize = (2 - 1) * envelope_size;
4453
4454            // Zero reserved fields.
4455            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4456
4457            // Safety:
4458            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4459            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4460            //   envelope_size bytes, there is always sufficient room.
4461            fidl::encoding::encode_in_envelope_optional::<Handle, D>(
4462                self.handle.as_ref().map(<Handle as fidl::encoding::ValueTypeMarker>::borrow),
4463                encoder,
4464                offset + cur_offset,
4465                depth,
4466            )?;
4467
4468            _prev_end_offset = cur_offset + envelope_size;
4469            if 3 > max_ordinal {
4470                return Ok(());
4471            }
4472
4473            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4474            // are envelope_size bytes.
4475            let cur_offset: usize = (3 - 1) * envelope_size;
4476
4477            // Zero reserved fields.
4478            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4479
4480            // Safety:
4481            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4482            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4483            //   envelope_size bytes, there is always sufficient room.
4484            fidl::encoding::encode_in_envelope_optional::<u32, D>(
4485                self.offset.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
4486                encoder,
4487                offset + cur_offset,
4488                depth,
4489            )?;
4490
4491            _prev_end_offset = cur_offset + envelope_size;
4492            if 4 > max_ordinal {
4493                return Ok(());
4494            }
4495
4496            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4497            // are envelope_size bytes.
4498            let cur_offset: usize = (4 - 1) * envelope_size;
4499
4500            // Zero reserved fields.
4501            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4502
4503            // Safety:
4504            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4505            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4506            //   envelope_size bytes, there is always sufficient room.
4507            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 512>, D>(
4508                self.value.as_ref().map(
4509                    <fidl::encoding::Vector<u8, 512> as fidl::encoding::ValueTypeMarker>::borrow,
4510                ),
4511                encoder,
4512                offset + cur_offset,
4513                depth,
4514            )?;
4515
4516            _prev_end_offset = cur_offset + envelope_size;
4517
4518            Ok(())
4519        }
4520    }
4521
4522    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4523        for LocalServiceWriteValueRequest
4524    {
4525        #[inline(always)]
4526        fn new_empty() -> Self {
4527            Self::default()
4528        }
4529
4530        unsafe fn decode(
4531            &mut self,
4532            decoder: &mut fidl::encoding::Decoder<'_, D>,
4533            offset: usize,
4534            mut depth: fidl::encoding::Depth,
4535        ) -> fidl::Result<()> {
4536            decoder.debug_check_bounds::<Self>(offset);
4537            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4538                None => return Err(fidl::Error::NotNullable),
4539                Some(len) => len,
4540            };
4541            // Calling decoder.out_of_line_offset(0) is not allowed.
4542            if len == 0 {
4543                return Ok(());
4544            };
4545            depth.increment()?;
4546            let envelope_size = 8;
4547            let bytes_len = len * envelope_size;
4548            let offset = decoder.out_of_line_offset(bytes_len)?;
4549            // Decode the envelope for each type.
4550            let mut _next_ordinal_to_read = 0;
4551            let mut next_offset = offset;
4552            let end_offset = offset + bytes_len;
4553            _next_ordinal_to_read += 1;
4554            if next_offset >= end_offset {
4555                return Ok(());
4556            }
4557
4558            // Decode unknown envelopes for gaps in ordinals.
4559            while _next_ordinal_to_read < 1 {
4560                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4561                _next_ordinal_to_read += 1;
4562                next_offset += envelope_size;
4563            }
4564
4565            let next_out_of_line = decoder.next_out_of_line();
4566            let handles_before = decoder.remaining_handles();
4567            if let Some((inlined, num_bytes, num_handles)) =
4568                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4569            {
4570                let member_inline_size = <fidl_fuchsia_bluetooth_common::PeerId as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4571                if inlined != (member_inline_size <= 4) {
4572                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4573                }
4574                let inner_offset;
4575                let mut inner_depth = depth.clone();
4576                if inlined {
4577                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4578                    inner_offset = next_offset;
4579                } else {
4580                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4581                    inner_depth.increment()?;
4582                }
4583                let val_ref = self.peer_id.get_or_insert_with(|| {
4584                    fidl::new_empty!(fidl_fuchsia_bluetooth_common::PeerId, D)
4585                });
4586                fidl::decode!(
4587                    fidl_fuchsia_bluetooth_common::PeerId,
4588                    D,
4589                    val_ref,
4590                    decoder,
4591                    inner_offset,
4592                    inner_depth
4593                )?;
4594                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4595                {
4596                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4597                }
4598                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4599                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4600                }
4601            }
4602
4603            next_offset += envelope_size;
4604            _next_ordinal_to_read += 1;
4605            if next_offset >= end_offset {
4606                return Ok(());
4607            }
4608
4609            // Decode unknown envelopes for gaps in ordinals.
4610            while _next_ordinal_to_read < 2 {
4611                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4612                _next_ordinal_to_read += 1;
4613                next_offset += envelope_size;
4614            }
4615
4616            let next_out_of_line = decoder.next_out_of_line();
4617            let handles_before = decoder.remaining_handles();
4618            if let Some((inlined, num_bytes, num_handles)) =
4619                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4620            {
4621                let member_inline_size =
4622                    <Handle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4623                if inlined != (member_inline_size <= 4) {
4624                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4625                }
4626                let inner_offset;
4627                let mut inner_depth = depth.clone();
4628                if inlined {
4629                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4630                    inner_offset = next_offset;
4631                } else {
4632                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4633                    inner_depth.increment()?;
4634                }
4635                let val_ref = self.handle.get_or_insert_with(|| fidl::new_empty!(Handle, D));
4636                fidl::decode!(Handle, D, val_ref, decoder, inner_offset, inner_depth)?;
4637                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4638                {
4639                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4640                }
4641                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4642                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4643                }
4644            }
4645
4646            next_offset += envelope_size;
4647            _next_ordinal_to_read += 1;
4648            if next_offset >= end_offset {
4649                return Ok(());
4650            }
4651
4652            // Decode unknown envelopes for gaps in ordinals.
4653            while _next_ordinal_to_read < 3 {
4654                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4655                _next_ordinal_to_read += 1;
4656                next_offset += envelope_size;
4657            }
4658
4659            let next_out_of_line = decoder.next_out_of_line();
4660            let handles_before = decoder.remaining_handles();
4661            if let Some((inlined, num_bytes, num_handles)) =
4662                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4663            {
4664                let member_inline_size =
4665                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4666                if inlined != (member_inline_size <= 4) {
4667                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4668                }
4669                let inner_offset;
4670                let mut inner_depth = depth.clone();
4671                if inlined {
4672                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4673                    inner_offset = next_offset;
4674                } else {
4675                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4676                    inner_depth.increment()?;
4677                }
4678                let val_ref = self.offset.get_or_insert_with(|| fidl::new_empty!(u32, D));
4679                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
4680                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4681                {
4682                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4683                }
4684                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4685                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4686                }
4687            }
4688
4689            next_offset += envelope_size;
4690            _next_ordinal_to_read += 1;
4691            if next_offset >= end_offset {
4692                return Ok(());
4693            }
4694
4695            // Decode unknown envelopes for gaps in ordinals.
4696            while _next_ordinal_to_read < 4 {
4697                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4698                _next_ordinal_to_read += 1;
4699                next_offset += envelope_size;
4700            }
4701
4702            let next_out_of_line = decoder.next_out_of_line();
4703            let handles_before = decoder.remaining_handles();
4704            if let Some((inlined, num_bytes, num_handles)) =
4705                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4706            {
4707                let member_inline_size =
4708                    <fidl::encoding::Vector<u8, 512> as fidl::encoding::TypeMarker>::inline_size(
4709                        decoder.context,
4710                    );
4711                if inlined != (member_inline_size <= 4) {
4712                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4713                }
4714                let inner_offset;
4715                let mut inner_depth = depth.clone();
4716                if inlined {
4717                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4718                    inner_offset = next_offset;
4719                } else {
4720                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4721                    inner_depth.increment()?;
4722                }
4723                let val_ref = self
4724                    .value
4725                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 512>, D));
4726                fidl::decode!(fidl::encoding::Vector<u8, 512>, D, val_ref, decoder, inner_offset, inner_depth)?;
4727                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4728                {
4729                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4730                }
4731                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4732                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4733                }
4734            }
4735
4736            next_offset += envelope_size;
4737
4738            // Decode the remaining unknown envelopes.
4739            while next_offset < end_offset {
4740                _next_ordinal_to_read += 1;
4741                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4742                next_offset += envelope_size;
4743            }
4744
4745            Ok(())
4746        }
4747    }
4748
4749    impl LongReadOptions {
4750        #[inline(always)]
4751        fn max_ordinal_present(&self) -> u64 {
4752            if let Some(_) = self.max_bytes {
4753                return 2;
4754            }
4755            if let Some(_) = self.offset {
4756                return 1;
4757            }
4758            0
4759        }
4760    }
4761
4762    impl fidl::encoding::ValueTypeMarker for LongReadOptions {
4763        type Borrowed<'a> = &'a Self;
4764        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4765            value
4766        }
4767    }
4768
4769    unsafe impl fidl::encoding::TypeMarker for LongReadOptions {
4770        type Owned = Self;
4771
4772        #[inline(always)]
4773        fn inline_align(_context: fidl::encoding::Context) -> usize {
4774            8
4775        }
4776
4777        #[inline(always)]
4778        fn inline_size(_context: fidl::encoding::Context) -> usize {
4779            16
4780        }
4781    }
4782
4783    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LongReadOptions, D>
4784        for &LongReadOptions
4785    {
4786        unsafe fn encode(
4787            self,
4788            encoder: &mut fidl::encoding::Encoder<'_, D>,
4789            offset: usize,
4790            mut depth: fidl::encoding::Depth,
4791        ) -> fidl::Result<()> {
4792            encoder.debug_check_bounds::<LongReadOptions>(offset);
4793            // Vector header
4794            let max_ordinal: u64 = self.max_ordinal_present();
4795            encoder.write_num(max_ordinal, offset);
4796            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4797            // Calling encoder.out_of_line_offset(0) is not allowed.
4798            if max_ordinal == 0 {
4799                return Ok(());
4800            }
4801            depth.increment()?;
4802            let envelope_size = 8;
4803            let bytes_len = max_ordinal as usize * envelope_size;
4804            #[allow(unused_variables)]
4805            let offset = encoder.out_of_line_offset(bytes_len);
4806            let mut _prev_end_offset: usize = 0;
4807            if 1 > max_ordinal {
4808                return Ok(());
4809            }
4810
4811            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4812            // are envelope_size bytes.
4813            let cur_offset: usize = (1 - 1) * envelope_size;
4814
4815            // Zero reserved fields.
4816            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4817
4818            // Safety:
4819            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4820            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4821            //   envelope_size bytes, there is always sufficient room.
4822            fidl::encoding::encode_in_envelope_optional::<u16, D>(
4823                self.offset.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
4824                encoder,
4825                offset + cur_offset,
4826                depth,
4827            )?;
4828
4829            _prev_end_offset = cur_offset + envelope_size;
4830            if 2 > max_ordinal {
4831                return Ok(());
4832            }
4833
4834            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4835            // are envelope_size bytes.
4836            let cur_offset: usize = (2 - 1) * envelope_size;
4837
4838            // Zero reserved fields.
4839            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4840
4841            // Safety:
4842            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4843            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4844            //   envelope_size bytes, there is always sufficient room.
4845            fidl::encoding::encode_in_envelope_optional::<u16, D>(
4846                self.max_bytes.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
4847                encoder,
4848                offset + cur_offset,
4849                depth,
4850            )?;
4851
4852            _prev_end_offset = cur_offset + envelope_size;
4853
4854            Ok(())
4855        }
4856    }
4857
4858    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LongReadOptions {
4859        #[inline(always)]
4860        fn new_empty() -> Self {
4861            Self::default()
4862        }
4863
4864        unsafe fn decode(
4865            &mut self,
4866            decoder: &mut fidl::encoding::Decoder<'_, D>,
4867            offset: usize,
4868            mut depth: fidl::encoding::Depth,
4869        ) -> fidl::Result<()> {
4870            decoder.debug_check_bounds::<Self>(offset);
4871            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4872                None => return Err(fidl::Error::NotNullable),
4873                Some(len) => len,
4874            };
4875            // Calling decoder.out_of_line_offset(0) is not allowed.
4876            if len == 0 {
4877                return Ok(());
4878            };
4879            depth.increment()?;
4880            let envelope_size = 8;
4881            let bytes_len = len * envelope_size;
4882            let offset = decoder.out_of_line_offset(bytes_len)?;
4883            // Decode the envelope for each type.
4884            let mut _next_ordinal_to_read = 0;
4885            let mut next_offset = offset;
4886            let end_offset = offset + bytes_len;
4887            _next_ordinal_to_read += 1;
4888            if next_offset >= end_offset {
4889                return Ok(());
4890            }
4891
4892            // Decode unknown envelopes for gaps in ordinals.
4893            while _next_ordinal_to_read < 1 {
4894                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4895                _next_ordinal_to_read += 1;
4896                next_offset += envelope_size;
4897            }
4898
4899            let next_out_of_line = decoder.next_out_of_line();
4900            let handles_before = decoder.remaining_handles();
4901            if let Some((inlined, num_bytes, num_handles)) =
4902                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4903            {
4904                let member_inline_size =
4905                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4906                if inlined != (member_inline_size <= 4) {
4907                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4908                }
4909                let inner_offset;
4910                let mut inner_depth = depth.clone();
4911                if inlined {
4912                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4913                    inner_offset = next_offset;
4914                } else {
4915                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4916                    inner_depth.increment()?;
4917                }
4918                let val_ref = self.offset.get_or_insert_with(|| fidl::new_empty!(u16, D));
4919                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
4920                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4921                {
4922                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4923                }
4924                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4925                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4926                }
4927            }
4928
4929            next_offset += envelope_size;
4930            _next_ordinal_to_read += 1;
4931            if next_offset >= end_offset {
4932                return Ok(());
4933            }
4934
4935            // Decode unknown envelopes for gaps in ordinals.
4936            while _next_ordinal_to_read < 2 {
4937                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4938                _next_ordinal_to_read += 1;
4939                next_offset += envelope_size;
4940            }
4941
4942            let next_out_of_line = decoder.next_out_of_line();
4943            let handles_before = decoder.remaining_handles();
4944            if let Some((inlined, num_bytes, num_handles)) =
4945                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4946            {
4947                let member_inline_size =
4948                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4949                if inlined != (member_inline_size <= 4) {
4950                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4951                }
4952                let inner_offset;
4953                let mut inner_depth = depth.clone();
4954                if inlined {
4955                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4956                    inner_offset = next_offset;
4957                } else {
4958                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4959                    inner_depth.increment()?;
4960                }
4961                let val_ref = self.max_bytes.get_or_insert_with(|| fidl::new_empty!(u16, D));
4962                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
4963                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4964                {
4965                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4966                }
4967                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4968                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4969                }
4970            }
4971
4972            next_offset += envelope_size;
4973
4974            // Decode the remaining unknown envelopes.
4975            while next_offset < end_offset {
4976                _next_ordinal_to_read += 1;
4977                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4978                next_offset += envelope_size;
4979            }
4980
4981            Ok(())
4982        }
4983    }
4984
4985    impl ReadByTypeResult {
4986        #[inline(always)]
4987        fn max_ordinal_present(&self) -> u64 {
4988            if let Some(_) = self.error {
4989                return 3;
4990            }
4991            if let Some(_) = self.value {
4992                return 2;
4993            }
4994            if let Some(_) = self.handle {
4995                return 1;
4996            }
4997            0
4998        }
4999    }
5000
5001    impl fidl::encoding::ValueTypeMarker for ReadByTypeResult {
5002        type Borrowed<'a> = &'a Self;
5003        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5004            value
5005        }
5006    }
5007
5008    unsafe impl fidl::encoding::TypeMarker for ReadByTypeResult {
5009        type Owned = Self;
5010
5011        #[inline(always)]
5012        fn inline_align(_context: fidl::encoding::Context) -> usize {
5013            8
5014        }
5015
5016        #[inline(always)]
5017        fn inline_size(_context: fidl::encoding::Context) -> usize {
5018            16
5019        }
5020    }
5021
5022    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ReadByTypeResult, D>
5023        for &ReadByTypeResult
5024    {
5025        unsafe fn encode(
5026            self,
5027            encoder: &mut fidl::encoding::Encoder<'_, D>,
5028            offset: usize,
5029            mut depth: fidl::encoding::Depth,
5030        ) -> fidl::Result<()> {
5031            encoder.debug_check_bounds::<ReadByTypeResult>(offset);
5032            // Vector header
5033            let max_ordinal: u64 = self.max_ordinal_present();
5034            encoder.write_num(max_ordinal, offset);
5035            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5036            // Calling encoder.out_of_line_offset(0) is not allowed.
5037            if max_ordinal == 0 {
5038                return Ok(());
5039            }
5040            depth.increment()?;
5041            let envelope_size = 8;
5042            let bytes_len = max_ordinal as usize * envelope_size;
5043            #[allow(unused_variables)]
5044            let offset = encoder.out_of_line_offset(bytes_len);
5045            let mut _prev_end_offset: usize = 0;
5046            if 1 > max_ordinal {
5047                return Ok(());
5048            }
5049
5050            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5051            // are envelope_size bytes.
5052            let cur_offset: usize = (1 - 1) * envelope_size;
5053
5054            // Zero reserved fields.
5055            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5056
5057            // Safety:
5058            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5059            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5060            //   envelope_size bytes, there is always sufficient room.
5061            fidl::encoding::encode_in_envelope_optional::<Handle, D>(
5062                self.handle.as_ref().map(<Handle as fidl::encoding::ValueTypeMarker>::borrow),
5063                encoder,
5064                offset + cur_offset,
5065                depth,
5066            )?;
5067
5068            _prev_end_offset = cur_offset + envelope_size;
5069            if 2 > max_ordinal {
5070                return Ok(());
5071            }
5072
5073            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5074            // are envelope_size bytes.
5075            let cur_offset: usize = (2 - 1) * envelope_size;
5076
5077            // Zero reserved fields.
5078            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5079
5080            // Safety:
5081            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5082            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5083            //   envelope_size bytes, there is always sufficient room.
5084            fidl::encoding::encode_in_envelope_optional::<ReadValue, D>(
5085                self.value.as_ref().map(<ReadValue as fidl::encoding::ValueTypeMarker>::borrow),
5086                encoder,
5087                offset + cur_offset,
5088                depth,
5089            )?;
5090
5091            _prev_end_offset = cur_offset + envelope_size;
5092            if 3 > max_ordinal {
5093                return Ok(());
5094            }
5095
5096            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5097            // are envelope_size bytes.
5098            let cur_offset: usize = (3 - 1) * envelope_size;
5099
5100            // Zero reserved fields.
5101            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5102
5103            // Safety:
5104            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5105            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5106            //   envelope_size bytes, there is always sufficient room.
5107            fidl::encoding::encode_in_envelope_optional::<Error, D>(
5108                self.error.as_ref().map(<Error as fidl::encoding::ValueTypeMarker>::borrow),
5109                encoder,
5110                offset + cur_offset,
5111                depth,
5112            )?;
5113
5114            _prev_end_offset = cur_offset + envelope_size;
5115
5116            Ok(())
5117        }
5118    }
5119
5120    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReadByTypeResult {
5121        #[inline(always)]
5122        fn new_empty() -> Self {
5123            Self::default()
5124        }
5125
5126        unsafe fn decode(
5127            &mut self,
5128            decoder: &mut fidl::encoding::Decoder<'_, D>,
5129            offset: usize,
5130            mut depth: fidl::encoding::Depth,
5131        ) -> fidl::Result<()> {
5132            decoder.debug_check_bounds::<Self>(offset);
5133            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5134                None => return Err(fidl::Error::NotNullable),
5135                Some(len) => len,
5136            };
5137            // Calling decoder.out_of_line_offset(0) is not allowed.
5138            if len == 0 {
5139                return Ok(());
5140            };
5141            depth.increment()?;
5142            let envelope_size = 8;
5143            let bytes_len = len * envelope_size;
5144            let offset = decoder.out_of_line_offset(bytes_len)?;
5145            // Decode the envelope for each type.
5146            let mut _next_ordinal_to_read = 0;
5147            let mut next_offset = offset;
5148            let end_offset = offset + bytes_len;
5149            _next_ordinal_to_read += 1;
5150            if next_offset >= end_offset {
5151                return Ok(());
5152            }
5153
5154            // Decode unknown envelopes for gaps in ordinals.
5155            while _next_ordinal_to_read < 1 {
5156                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5157                _next_ordinal_to_read += 1;
5158                next_offset += envelope_size;
5159            }
5160
5161            let next_out_of_line = decoder.next_out_of_line();
5162            let handles_before = decoder.remaining_handles();
5163            if let Some((inlined, num_bytes, num_handles)) =
5164                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5165            {
5166                let member_inline_size =
5167                    <Handle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5168                if inlined != (member_inline_size <= 4) {
5169                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5170                }
5171                let inner_offset;
5172                let mut inner_depth = depth.clone();
5173                if inlined {
5174                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5175                    inner_offset = next_offset;
5176                } else {
5177                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5178                    inner_depth.increment()?;
5179                }
5180                let val_ref = self.handle.get_or_insert_with(|| fidl::new_empty!(Handle, D));
5181                fidl::decode!(Handle, D, val_ref, decoder, inner_offset, inner_depth)?;
5182                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5183                {
5184                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5185                }
5186                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5187                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5188                }
5189            }
5190
5191            next_offset += envelope_size;
5192            _next_ordinal_to_read += 1;
5193            if next_offset >= end_offset {
5194                return Ok(());
5195            }
5196
5197            // Decode unknown envelopes for gaps in ordinals.
5198            while _next_ordinal_to_read < 2 {
5199                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5200                _next_ordinal_to_read += 1;
5201                next_offset += envelope_size;
5202            }
5203
5204            let next_out_of_line = decoder.next_out_of_line();
5205            let handles_before = decoder.remaining_handles();
5206            if let Some((inlined, num_bytes, num_handles)) =
5207                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5208            {
5209                let member_inline_size =
5210                    <ReadValue as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5211                if inlined != (member_inline_size <= 4) {
5212                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5213                }
5214                let inner_offset;
5215                let mut inner_depth = depth.clone();
5216                if inlined {
5217                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5218                    inner_offset = next_offset;
5219                } else {
5220                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5221                    inner_depth.increment()?;
5222                }
5223                let val_ref = self.value.get_or_insert_with(|| fidl::new_empty!(ReadValue, D));
5224                fidl::decode!(ReadValue, D, val_ref, decoder, inner_offset, inner_depth)?;
5225                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5226                {
5227                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5228                }
5229                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5230                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5231                }
5232            }
5233
5234            next_offset += envelope_size;
5235            _next_ordinal_to_read += 1;
5236            if next_offset >= end_offset {
5237                return Ok(());
5238            }
5239
5240            // Decode unknown envelopes for gaps in ordinals.
5241            while _next_ordinal_to_read < 3 {
5242                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5243                _next_ordinal_to_read += 1;
5244                next_offset += envelope_size;
5245            }
5246
5247            let next_out_of_line = decoder.next_out_of_line();
5248            let handles_before = decoder.remaining_handles();
5249            if let Some((inlined, num_bytes, num_handles)) =
5250                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5251            {
5252                let member_inline_size =
5253                    <Error as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5254                if inlined != (member_inline_size <= 4) {
5255                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5256                }
5257                let inner_offset;
5258                let mut inner_depth = depth.clone();
5259                if inlined {
5260                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5261                    inner_offset = next_offset;
5262                } else {
5263                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5264                    inner_depth.increment()?;
5265                }
5266                let val_ref = self.error.get_or_insert_with(|| fidl::new_empty!(Error, D));
5267                fidl::decode!(Error, D, val_ref, decoder, inner_offset, inner_depth)?;
5268                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5269                {
5270                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5271                }
5272                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5273                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5274                }
5275            }
5276
5277            next_offset += envelope_size;
5278
5279            // Decode the remaining unknown envelopes.
5280            while next_offset < end_offset {
5281                _next_ordinal_to_read += 1;
5282                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5283                next_offset += envelope_size;
5284            }
5285
5286            Ok(())
5287        }
5288    }
5289
5290    impl ReadValue {
5291        #[inline(always)]
5292        fn max_ordinal_present(&self) -> u64 {
5293            if let Some(_) = self.maybe_truncated {
5294                return 3;
5295            }
5296            if let Some(_) = self.value {
5297                return 2;
5298            }
5299            if let Some(_) = self.handle {
5300                return 1;
5301            }
5302            0
5303        }
5304    }
5305
5306    impl fidl::encoding::ValueTypeMarker for ReadValue {
5307        type Borrowed<'a> = &'a Self;
5308        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5309            value
5310        }
5311    }
5312
5313    unsafe impl fidl::encoding::TypeMarker for ReadValue {
5314        type Owned = Self;
5315
5316        #[inline(always)]
5317        fn inline_align(_context: fidl::encoding::Context) -> usize {
5318            8
5319        }
5320
5321        #[inline(always)]
5322        fn inline_size(_context: fidl::encoding::Context) -> usize {
5323            16
5324        }
5325    }
5326
5327    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ReadValue, D>
5328        for &ReadValue
5329    {
5330        unsafe fn encode(
5331            self,
5332            encoder: &mut fidl::encoding::Encoder<'_, D>,
5333            offset: usize,
5334            mut depth: fidl::encoding::Depth,
5335        ) -> fidl::Result<()> {
5336            encoder.debug_check_bounds::<ReadValue>(offset);
5337            // Vector header
5338            let max_ordinal: u64 = self.max_ordinal_present();
5339            encoder.write_num(max_ordinal, offset);
5340            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5341            // Calling encoder.out_of_line_offset(0) is not allowed.
5342            if max_ordinal == 0 {
5343                return Ok(());
5344            }
5345            depth.increment()?;
5346            let envelope_size = 8;
5347            let bytes_len = max_ordinal as usize * envelope_size;
5348            #[allow(unused_variables)]
5349            let offset = encoder.out_of_line_offset(bytes_len);
5350            let mut _prev_end_offset: usize = 0;
5351            if 1 > max_ordinal {
5352                return Ok(());
5353            }
5354
5355            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5356            // are envelope_size bytes.
5357            let cur_offset: usize = (1 - 1) * envelope_size;
5358
5359            // Zero reserved fields.
5360            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5361
5362            // Safety:
5363            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5364            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5365            //   envelope_size bytes, there is always sufficient room.
5366            fidl::encoding::encode_in_envelope_optional::<Handle, D>(
5367                self.handle.as_ref().map(<Handle as fidl::encoding::ValueTypeMarker>::borrow),
5368                encoder,
5369                offset + cur_offset,
5370                depth,
5371            )?;
5372
5373            _prev_end_offset = cur_offset + envelope_size;
5374            if 2 > max_ordinal {
5375                return Ok(());
5376            }
5377
5378            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5379            // are envelope_size bytes.
5380            let cur_offset: usize = (2 - 1) * envelope_size;
5381
5382            // Zero reserved fields.
5383            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5384
5385            // Safety:
5386            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5387            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5388            //   envelope_size bytes, there is always sufficient room.
5389            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 512>, D>(
5390                self.value.as_ref().map(
5391                    <fidl::encoding::Vector<u8, 512> as fidl::encoding::ValueTypeMarker>::borrow,
5392                ),
5393                encoder,
5394                offset + cur_offset,
5395                depth,
5396            )?;
5397
5398            _prev_end_offset = cur_offset + envelope_size;
5399            if 3 > max_ordinal {
5400                return Ok(());
5401            }
5402
5403            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5404            // are envelope_size bytes.
5405            let cur_offset: usize = (3 - 1) * envelope_size;
5406
5407            // Zero reserved fields.
5408            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5409
5410            // Safety:
5411            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5412            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5413            //   envelope_size bytes, there is always sufficient room.
5414            fidl::encoding::encode_in_envelope_optional::<bool, D>(
5415                self.maybe_truncated
5416                    .as_ref()
5417                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
5418                encoder,
5419                offset + cur_offset,
5420                depth,
5421            )?;
5422
5423            _prev_end_offset = cur_offset + envelope_size;
5424
5425            Ok(())
5426        }
5427    }
5428
5429    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReadValue {
5430        #[inline(always)]
5431        fn new_empty() -> Self {
5432            Self::default()
5433        }
5434
5435        unsafe fn decode(
5436            &mut self,
5437            decoder: &mut fidl::encoding::Decoder<'_, D>,
5438            offset: usize,
5439            mut depth: fidl::encoding::Depth,
5440        ) -> fidl::Result<()> {
5441            decoder.debug_check_bounds::<Self>(offset);
5442            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5443                None => return Err(fidl::Error::NotNullable),
5444                Some(len) => len,
5445            };
5446            // Calling decoder.out_of_line_offset(0) is not allowed.
5447            if len == 0 {
5448                return Ok(());
5449            };
5450            depth.increment()?;
5451            let envelope_size = 8;
5452            let bytes_len = len * envelope_size;
5453            let offset = decoder.out_of_line_offset(bytes_len)?;
5454            // Decode the envelope for each type.
5455            let mut _next_ordinal_to_read = 0;
5456            let mut next_offset = offset;
5457            let end_offset = offset + bytes_len;
5458            _next_ordinal_to_read += 1;
5459            if next_offset >= end_offset {
5460                return Ok(());
5461            }
5462
5463            // Decode unknown envelopes for gaps in ordinals.
5464            while _next_ordinal_to_read < 1 {
5465                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5466                _next_ordinal_to_read += 1;
5467                next_offset += envelope_size;
5468            }
5469
5470            let next_out_of_line = decoder.next_out_of_line();
5471            let handles_before = decoder.remaining_handles();
5472            if let Some((inlined, num_bytes, num_handles)) =
5473                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5474            {
5475                let member_inline_size =
5476                    <Handle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5477                if inlined != (member_inline_size <= 4) {
5478                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5479                }
5480                let inner_offset;
5481                let mut inner_depth = depth.clone();
5482                if inlined {
5483                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5484                    inner_offset = next_offset;
5485                } else {
5486                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5487                    inner_depth.increment()?;
5488                }
5489                let val_ref = self.handle.get_or_insert_with(|| fidl::new_empty!(Handle, D));
5490                fidl::decode!(Handle, D, val_ref, decoder, inner_offset, inner_depth)?;
5491                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5492                {
5493                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5494                }
5495                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5496                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5497                }
5498            }
5499
5500            next_offset += envelope_size;
5501            _next_ordinal_to_read += 1;
5502            if next_offset >= end_offset {
5503                return Ok(());
5504            }
5505
5506            // Decode unknown envelopes for gaps in ordinals.
5507            while _next_ordinal_to_read < 2 {
5508                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5509                _next_ordinal_to_read += 1;
5510                next_offset += envelope_size;
5511            }
5512
5513            let next_out_of_line = decoder.next_out_of_line();
5514            let handles_before = decoder.remaining_handles();
5515            if let Some((inlined, num_bytes, num_handles)) =
5516                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5517            {
5518                let member_inline_size =
5519                    <fidl::encoding::Vector<u8, 512> as fidl::encoding::TypeMarker>::inline_size(
5520                        decoder.context,
5521                    );
5522                if inlined != (member_inline_size <= 4) {
5523                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5524                }
5525                let inner_offset;
5526                let mut inner_depth = depth.clone();
5527                if inlined {
5528                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5529                    inner_offset = next_offset;
5530                } else {
5531                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5532                    inner_depth.increment()?;
5533                }
5534                let val_ref = self
5535                    .value
5536                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 512>, D));
5537                fidl::decode!(fidl::encoding::Vector<u8, 512>, D, val_ref, decoder, inner_offset, inner_depth)?;
5538                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5539                {
5540                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5541                }
5542                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5543                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5544                }
5545            }
5546
5547            next_offset += envelope_size;
5548            _next_ordinal_to_read += 1;
5549            if next_offset >= end_offset {
5550                return Ok(());
5551            }
5552
5553            // Decode unknown envelopes for gaps in ordinals.
5554            while _next_ordinal_to_read < 3 {
5555                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5556                _next_ordinal_to_read += 1;
5557                next_offset += envelope_size;
5558            }
5559
5560            let next_out_of_line = decoder.next_out_of_line();
5561            let handles_before = decoder.remaining_handles();
5562            if let Some((inlined, num_bytes, num_handles)) =
5563                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5564            {
5565                let member_inline_size =
5566                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5567                if inlined != (member_inline_size <= 4) {
5568                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5569                }
5570                let inner_offset;
5571                let mut inner_depth = depth.clone();
5572                if inlined {
5573                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5574                    inner_offset = next_offset;
5575                } else {
5576                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5577                    inner_depth.increment()?;
5578                }
5579                let val_ref = self.maybe_truncated.get_or_insert_with(|| fidl::new_empty!(bool, D));
5580                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
5581                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5582                {
5583                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5584                }
5585                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5586                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5587                }
5588            }
5589
5590            next_offset += envelope_size;
5591
5592            // Decode the remaining unknown envelopes.
5593            while next_offset < end_offset {
5594                _next_ordinal_to_read += 1;
5595                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5596                next_offset += envelope_size;
5597            }
5598
5599            Ok(())
5600        }
5601    }
5602
5603    impl SecurityRequirements {
5604        #[inline(always)]
5605        fn max_ordinal_present(&self) -> u64 {
5606            if let Some(_) = self.authorization_required {
5607                return 3;
5608            }
5609            if let Some(_) = self.authentication_required {
5610                return 2;
5611            }
5612            if let Some(_) = self.encryption_required {
5613                return 1;
5614            }
5615            0
5616        }
5617    }
5618
5619    impl fidl::encoding::ValueTypeMarker for SecurityRequirements {
5620        type Borrowed<'a> = &'a Self;
5621        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5622            value
5623        }
5624    }
5625
5626    unsafe impl fidl::encoding::TypeMarker for SecurityRequirements {
5627        type Owned = Self;
5628
5629        #[inline(always)]
5630        fn inline_align(_context: fidl::encoding::Context) -> usize {
5631            8
5632        }
5633
5634        #[inline(always)]
5635        fn inline_size(_context: fidl::encoding::Context) -> usize {
5636            16
5637        }
5638    }
5639
5640    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecurityRequirements, D>
5641        for &SecurityRequirements
5642    {
5643        unsafe fn encode(
5644            self,
5645            encoder: &mut fidl::encoding::Encoder<'_, D>,
5646            offset: usize,
5647            mut depth: fidl::encoding::Depth,
5648        ) -> fidl::Result<()> {
5649            encoder.debug_check_bounds::<SecurityRequirements>(offset);
5650            // Vector header
5651            let max_ordinal: u64 = self.max_ordinal_present();
5652            encoder.write_num(max_ordinal, offset);
5653            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5654            // Calling encoder.out_of_line_offset(0) is not allowed.
5655            if max_ordinal == 0 {
5656                return Ok(());
5657            }
5658            depth.increment()?;
5659            let envelope_size = 8;
5660            let bytes_len = max_ordinal as usize * envelope_size;
5661            #[allow(unused_variables)]
5662            let offset = encoder.out_of_line_offset(bytes_len);
5663            let mut _prev_end_offset: usize = 0;
5664            if 1 > max_ordinal {
5665                return Ok(());
5666            }
5667
5668            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5669            // are envelope_size bytes.
5670            let cur_offset: usize = (1 - 1) * envelope_size;
5671
5672            // Zero reserved fields.
5673            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5674
5675            // Safety:
5676            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5677            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5678            //   envelope_size bytes, there is always sufficient room.
5679            fidl::encoding::encode_in_envelope_optional::<bool, D>(
5680                self.encryption_required
5681                    .as_ref()
5682                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
5683                encoder,
5684                offset + cur_offset,
5685                depth,
5686            )?;
5687
5688            _prev_end_offset = cur_offset + envelope_size;
5689            if 2 > max_ordinal {
5690                return Ok(());
5691            }
5692
5693            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5694            // are envelope_size bytes.
5695            let cur_offset: usize = (2 - 1) * envelope_size;
5696
5697            // Zero reserved fields.
5698            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5699
5700            // Safety:
5701            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5702            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5703            //   envelope_size bytes, there is always sufficient room.
5704            fidl::encoding::encode_in_envelope_optional::<bool, D>(
5705                self.authentication_required
5706                    .as_ref()
5707                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
5708                encoder,
5709                offset + cur_offset,
5710                depth,
5711            )?;
5712
5713            _prev_end_offset = cur_offset + envelope_size;
5714            if 3 > max_ordinal {
5715                return Ok(());
5716            }
5717
5718            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5719            // are envelope_size bytes.
5720            let cur_offset: usize = (3 - 1) * envelope_size;
5721
5722            // Zero reserved fields.
5723            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5724
5725            // Safety:
5726            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5727            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5728            //   envelope_size bytes, there is always sufficient room.
5729            fidl::encoding::encode_in_envelope_optional::<bool, D>(
5730                self.authorization_required
5731                    .as_ref()
5732                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
5733                encoder,
5734                offset + cur_offset,
5735                depth,
5736            )?;
5737
5738            _prev_end_offset = cur_offset + envelope_size;
5739
5740            Ok(())
5741        }
5742    }
5743
5744    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecurityRequirements {
5745        #[inline(always)]
5746        fn new_empty() -> Self {
5747            Self::default()
5748        }
5749
5750        unsafe fn decode(
5751            &mut self,
5752            decoder: &mut fidl::encoding::Decoder<'_, D>,
5753            offset: usize,
5754            mut depth: fidl::encoding::Depth,
5755        ) -> fidl::Result<()> {
5756            decoder.debug_check_bounds::<Self>(offset);
5757            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5758                None => return Err(fidl::Error::NotNullable),
5759                Some(len) => len,
5760            };
5761            // Calling decoder.out_of_line_offset(0) is not allowed.
5762            if len == 0 {
5763                return Ok(());
5764            };
5765            depth.increment()?;
5766            let envelope_size = 8;
5767            let bytes_len = len * envelope_size;
5768            let offset = decoder.out_of_line_offset(bytes_len)?;
5769            // Decode the envelope for each type.
5770            let mut _next_ordinal_to_read = 0;
5771            let mut next_offset = offset;
5772            let end_offset = offset + bytes_len;
5773            _next_ordinal_to_read += 1;
5774            if next_offset >= end_offset {
5775                return Ok(());
5776            }
5777
5778            // Decode unknown envelopes for gaps in ordinals.
5779            while _next_ordinal_to_read < 1 {
5780                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5781                _next_ordinal_to_read += 1;
5782                next_offset += envelope_size;
5783            }
5784
5785            let next_out_of_line = decoder.next_out_of_line();
5786            let handles_before = decoder.remaining_handles();
5787            if let Some((inlined, num_bytes, num_handles)) =
5788                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5789            {
5790                let member_inline_size =
5791                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5792                if inlined != (member_inline_size <= 4) {
5793                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5794                }
5795                let inner_offset;
5796                let mut inner_depth = depth.clone();
5797                if inlined {
5798                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5799                    inner_offset = next_offset;
5800                } else {
5801                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5802                    inner_depth.increment()?;
5803                }
5804                let val_ref =
5805                    self.encryption_required.get_or_insert_with(|| fidl::new_empty!(bool, D));
5806                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
5807                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5808                {
5809                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5810                }
5811                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5812                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5813                }
5814            }
5815
5816            next_offset += envelope_size;
5817            _next_ordinal_to_read += 1;
5818            if next_offset >= end_offset {
5819                return Ok(());
5820            }
5821
5822            // Decode unknown envelopes for gaps in ordinals.
5823            while _next_ordinal_to_read < 2 {
5824                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5825                _next_ordinal_to_read += 1;
5826                next_offset += envelope_size;
5827            }
5828
5829            let next_out_of_line = decoder.next_out_of_line();
5830            let handles_before = decoder.remaining_handles();
5831            if let Some((inlined, num_bytes, num_handles)) =
5832                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5833            {
5834                let member_inline_size =
5835                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5836                if inlined != (member_inline_size <= 4) {
5837                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5838                }
5839                let inner_offset;
5840                let mut inner_depth = depth.clone();
5841                if inlined {
5842                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5843                    inner_offset = next_offset;
5844                } else {
5845                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5846                    inner_depth.increment()?;
5847                }
5848                let val_ref =
5849                    self.authentication_required.get_or_insert_with(|| fidl::new_empty!(bool, D));
5850                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
5851                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5852                {
5853                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5854                }
5855                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5856                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5857                }
5858            }
5859
5860            next_offset += envelope_size;
5861            _next_ordinal_to_read += 1;
5862            if next_offset >= end_offset {
5863                return Ok(());
5864            }
5865
5866            // Decode unknown envelopes for gaps in ordinals.
5867            while _next_ordinal_to_read < 3 {
5868                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5869                _next_ordinal_to_read += 1;
5870                next_offset += envelope_size;
5871            }
5872
5873            let next_out_of_line = decoder.next_out_of_line();
5874            let handles_before = decoder.remaining_handles();
5875            if let Some((inlined, num_bytes, num_handles)) =
5876                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5877            {
5878                let member_inline_size =
5879                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5880                if inlined != (member_inline_size <= 4) {
5881                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5882                }
5883                let inner_offset;
5884                let mut inner_depth = depth.clone();
5885                if inlined {
5886                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5887                    inner_offset = next_offset;
5888                } else {
5889                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5890                    inner_depth.increment()?;
5891                }
5892                let val_ref =
5893                    self.authorization_required.get_or_insert_with(|| fidl::new_empty!(bool, D));
5894                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
5895                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5896                {
5897                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5898                }
5899                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5900                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5901                }
5902            }
5903
5904            next_offset += envelope_size;
5905
5906            // Decode the remaining unknown envelopes.
5907            while next_offset < end_offset {
5908                _next_ordinal_to_read += 1;
5909                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5910                next_offset += envelope_size;
5911            }
5912
5913            Ok(())
5914        }
5915    }
5916
5917    impl ServiceInfo {
5918        #[inline(always)]
5919        fn max_ordinal_present(&self) -> u64 {
5920            if let Some(_) = self.includes {
5921                return 5;
5922            }
5923            if let Some(_) = self.characteristics {
5924                return 4;
5925            }
5926            if let Some(_) = self.type_ {
5927                return 3;
5928            }
5929            if let Some(_) = self.kind {
5930                return 2;
5931            }
5932            if let Some(_) = self.handle {
5933                return 1;
5934            }
5935            0
5936        }
5937    }
5938
5939    impl fidl::encoding::ValueTypeMarker for ServiceInfo {
5940        type Borrowed<'a> = &'a Self;
5941        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5942            value
5943        }
5944    }
5945
5946    unsafe impl fidl::encoding::TypeMarker for ServiceInfo {
5947        type Owned = Self;
5948
5949        #[inline(always)]
5950        fn inline_align(_context: fidl::encoding::Context) -> usize {
5951            8
5952        }
5953
5954        #[inline(always)]
5955        fn inline_size(_context: fidl::encoding::Context) -> usize {
5956            16
5957        }
5958    }
5959
5960    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ServiceInfo, D>
5961        for &ServiceInfo
5962    {
5963        unsafe fn encode(
5964            self,
5965            encoder: &mut fidl::encoding::Encoder<'_, D>,
5966            offset: usize,
5967            mut depth: fidl::encoding::Depth,
5968        ) -> fidl::Result<()> {
5969            encoder.debug_check_bounds::<ServiceInfo>(offset);
5970            // Vector header
5971            let max_ordinal: u64 = self.max_ordinal_present();
5972            encoder.write_num(max_ordinal, offset);
5973            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5974            // Calling encoder.out_of_line_offset(0) is not allowed.
5975            if max_ordinal == 0 {
5976                return Ok(());
5977            }
5978            depth.increment()?;
5979            let envelope_size = 8;
5980            let bytes_len = max_ordinal as usize * envelope_size;
5981            #[allow(unused_variables)]
5982            let offset = encoder.out_of_line_offset(bytes_len);
5983            let mut _prev_end_offset: usize = 0;
5984            if 1 > max_ordinal {
5985                return Ok(());
5986            }
5987
5988            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5989            // are envelope_size bytes.
5990            let cur_offset: usize = (1 - 1) * envelope_size;
5991
5992            // Zero reserved fields.
5993            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5994
5995            // Safety:
5996            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5997            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5998            //   envelope_size bytes, there is always sufficient room.
5999            fidl::encoding::encode_in_envelope_optional::<ServiceHandle, D>(
6000                self.handle
6001                    .as_ref()
6002                    .map(<ServiceHandle as fidl::encoding::ValueTypeMarker>::borrow),
6003                encoder,
6004                offset + cur_offset,
6005                depth,
6006            )?;
6007
6008            _prev_end_offset = cur_offset + envelope_size;
6009            if 2 > max_ordinal {
6010                return Ok(());
6011            }
6012
6013            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6014            // are envelope_size bytes.
6015            let cur_offset: usize = (2 - 1) * envelope_size;
6016
6017            // Zero reserved fields.
6018            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6019
6020            // Safety:
6021            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6022            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6023            //   envelope_size bytes, there is always sufficient room.
6024            fidl::encoding::encode_in_envelope_optional::<ServiceKind, D>(
6025                self.kind.as_ref().map(<ServiceKind as fidl::encoding::ValueTypeMarker>::borrow),
6026                encoder,
6027                offset + cur_offset,
6028                depth,
6029            )?;
6030
6031            _prev_end_offset = cur_offset + envelope_size;
6032            if 3 > max_ordinal {
6033                return Ok(());
6034            }
6035
6036            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6037            // are envelope_size bytes.
6038            let cur_offset: usize = (3 - 1) * envelope_size;
6039
6040            // Zero reserved fields.
6041            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6042
6043            // Safety:
6044            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6045            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6046            //   envelope_size bytes, there is always sufficient room.
6047            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_common::Uuid, D>(
6048            self.type_.as_ref().map(<fidl_fuchsia_bluetooth_common::Uuid as fidl::encoding::ValueTypeMarker>::borrow),
6049            encoder, offset + cur_offset, depth
6050        )?;
6051
6052            _prev_end_offset = cur_offset + envelope_size;
6053            if 4 > max_ordinal {
6054                return Ok(());
6055            }
6056
6057            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6058            // are envelope_size bytes.
6059            let cur_offset: usize = (4 - 1) * envelope_size;
6060
6061            // Zero reserved fields.
6062            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6063
6064            // Safety:
6065            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6066            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6067            //   envelope_size bytes, there is always sufficient room.
6068            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Characteristic, 32767>, D>(
6069            self.characteristics.as_ref().map(<fidl::encoding::Vector<Characteristic, 32767> as fidl::encoding::ValueTypeMarker>::borrow),
6070            encoder, offset + cur_offset, depth
6071        )?;
6072
6073            _prev_end_offset = cur_offset + envelope_size;
6074            if 5 > max_ordinal {
6075                return Ok(());
6076            }
6077
6078            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6079            // are envelope_size bytes.
6080            let cur_offset: usize = (5 - 1) * envelope_size;
6081
6082            // Zero reserved fields.
6083            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6084
6085            // Safety:
6086            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6087            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6088            //   envelope_size bytes, there is always sufficient room.
6089            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<ServiceHandle, 65535>, D>(
6090            self.includes.as_ref().map(<fidl::encoding::Vector<ServiceHandle, 65535> as fidl::encoding::ValueTypeMarker>::borrow),
6091            encoder, offset + cur_offset, depth
6092        )?;
6093
6094            _prev_end_offset = cur_offset + envelope_size;
6095
6096            Ok(())
6097        }
6098    }
6099
6100    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ServiceInfo {
6101        #[inline(always)]
6102        fn new_empty() -> Self {
6103            Self::default()
6104        }
6105
6106        unsafe fn decode(
6107            &mut self,
6108            decoder: &mut fidl::encoding::Decoder<'_, D>,
6109            offset: usize,
6110            mut depth: fidl::encoding::Depth,
6111        ) -> fidl::Result<()> {
6112            decoder.debug_check_bounds::<Self>(offset);
6113            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6114                None => return Err(fidl::Error::NotNullable),
6115                Some(len) => len,
6116            };
6117            // Calling decoder.out_of_line_offset(0) is not allowed.
6118            if len == 0 {
6119                return Ok(());
6120            };
6121            depth.increment()?;
6122            let envelope_size = 8;
6123            let bytes_len = len * envelope_size;
6124            let offset = decoder.out_of_line_offset(bytes_len)?;
6125            // Decode the envelope for each type.
6126            let mut _next_ordinal_to_read = 0;
6127            let mut next_offset = offset;
6128            let end_offset = offset + bytes_len;
6129            _next_ordinal_to_read += 1;
6130            if next_offset >= end_offset {
6131                return Ok(());
6132            }
6133
6134            // Decode unknown envelopes for gaps in ordinals.
6135            while _next_ordinal_to_read < 1 {
6136                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6137                _next_ordinal_to_read += 1;
6138                next_offset += envelope_size;
6139            }
6140
6141            let next_out_of_line = decoder.next_out_of_line();
6142            let handles_before = decoder.remaining_handles();
6143            if let Some((inlined, num_bytes, num_handles)) =
6144                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6145            {
6146                let member_inline_size =
6147                    <ServiceHandle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6148                if inlined != (member_inline_size <= 4) {
6149                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6150                }
6151                let inner_offset;
6152                let mut inner_depth = depth.clone();
6153                if inlined {
6154                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6155                    inner_offset = next_offset;
6156                } else {
6157                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6158                    inner_depth.increment()?;
6159                }
6160                let val_ref = self.handle.get_or_insert_with(|| fidl::new_empty!(ServiceHandle, D));
6161                fidl::decode!(ServiceHandle, D, val_ref, decoder, inner_offset, inner_depth)?;
6162                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6163                {
6164                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6165                }
6166                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6167                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6168                }
6169            }
6170
6171            next_offset += envelope_size;
6172            _next_ordinal_to_read += 1;
6173            if next_offset >= end_offset {
6174                return Ok(());
6175            }
6176
6177            // Decode unknown envelopes for gaps in ordinals.
6178            while _next_ordinal_to_read < 2 {
6179                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6180                _next_ordinal_to_read += 1;
6181                next_offset += envelope_size;
6182            }
6183
6184            let next_out_of_line = decoder.next_out_of_line();
6185            let handles_before = decoder.remaining_handles();
6186            if let Some((inlined, num_bytes, num_handles)) =
6187                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6188            {
6189                let member_inline_size =
6190                    <ServiceKind as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6191                if inlined != (member_inline_size <= 4) {
6192                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6193                }
6194                let inner_offset;
6195                let mut inner_depth = depth.clone();
6196                if inlined {
6197                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6198                    inner_offset = next_offset;
6199                } else {
6200                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6201                    inner_depth.increment()?;
6202                }
6203                let val_ref = self.kind.get_or_insert_with(|| fidl::new_empty!(ServiceKind, D));
6204                fidl::decode!(ServiceKind, D, val_ref, decoder, inner_offset, inner_depth)?;
6205                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6206                {
6207                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6208                }
6209                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6210                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6211                }
6212            }
6213
6214            next_offset += envelope_size;
6215            _next_ordinal_to_read += 1;
6216            if next_offset >= end_offset {
6217                return Ok(());
6218            }
6219
6220            // Decode unknown envelopes for gaps in ordinals.
6221            while _next_ordinal_to_read < 3 {
6222                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6223                _next_ordinal_to_read += 1;
6224                next_offset += envelope_size;
6225            }
6226
6227            let next_out_of_line = decoder.next_out_of_line();
6228            let handles_before = decoder.remaining_handles();
6229            if let Some((inlined, num_bytes, num_handles)) =
6230                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6231            {
6232                let member_inline_size = <fidl_fuchsia_bluetooth_common::Uuid as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6233                if inlined != (member_inline_size <= 4) {
6234                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6235                }
6236                let inner_offset;
6237                let mut inner_depth = depth.clone();
6238                if inlined {
6239                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6240                    inner_offset = next_offset;
6241                } else {
6242                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6243                    inner_depth.increment()?;
6244                }
6245                let val_ref = self.type_.get_or_insert_with(|| {
6246                    fidl::new_empty!(fidl_fuchsia_bluetooth_common::Uuid, D)
6247                });
6248                fidl::decode!(
6249                    fidl_fuchsia_bluetooth_common::Uuid,
6250                    D,
6251                    val_ref,
6252                    decoder,
6253                    inner_offset,
6254                    inner_depth
6255                )?;
6256                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6257                {
6258                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6259                }
6260                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6261                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6262                }
6263            }
6264
6265            next_offset += envelope_size;
6266            _next_ordinal_to_read += 1;
6267            if next_offset >= end_offset {
6268                return Ok(());
6269            }
6270
6271            // Decode unknown envelopes for gaps in ordinals.
6272            while _next_ordinal_to_read < 4 {
6273                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6274                _next_ordinal_to_read += 1;
6275                next_offset += envelope_size;
6276            }
6277
6278            let next_out_of_line = decoder.next_out_of_line();
6279            let handles_before = decoder.remaining_handles();
6280            if let Some((inlined, num_bytes, num_handles)) =
6281                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6282            {
6283                let member_inline_size = <fidl::encoding::Vector<Characteristic, 32767> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6284                if inlined != (member_inline_size <= 4) {
6285                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6286                }
6287                let inner_offset;
6288                let mut inner_depth = depth.clone();
6289                if inlined {
6290                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6291                    inner_offset = next_offset;
6292                } else {
6293                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6294                    inner_depth.increment()?;
6295                }
6296                let val_ref = self.characteristics.get_or_insert_with(
6297                    || fidl::new_empty!(fidl::encoding::Vector<Characteristic, 32767>, D),
6298                );
6299                fidl::decode!(fidl::encoding::Vector<Characteristic, 32767>, D, val_ref, decoder, inner_offset, inner_depth)?;
6300                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6301                {
6302                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6303                }
6304                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6305                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6306                }
6307            }
6308
6309            next_offset += envelope_size;
6310            _next_ordinal_to_read += 1;
6311            if next_offset >= end_offset {
6312                return Ok(());
6313            }
6314
6315            // Decode unknown envelopes for gaps in ordinals.
6316            while _next_ordinal_to_read < 5 {
6317                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6318                _next_ordinal_to_read += 1;
6319                next_offset += envelope_size;
6320            }
6321
6322            let next_out_of_line = decoder.next_out_of_line();
6323            let handles_before = decoder.remaining_handles();
6324            if let Some((inlined, num_bytes, num_handles)) =
6325                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6326            {
6327                let member_inline_size = <fidl::encoding::Vector<ServiceHandle, 65535> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6328                if inlined != (member_inline_size <= 4) {
6329                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6330                }
6331                let inner_offset;
6332                let mut inner_depth = depth.clone();
6333                if inlined {
6334                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6335                    inner_offset = next_offset;
6336                } else {
6337                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6338                    inner_depth.increment()?;
6339                }
6340                let val_ref = self.includes.get_or_insert_with(
6341                    || fidl::new_empty!(fidl::encoding::Vector<ServiceHandle, 65535>, D),
6342                );
6343                fidl::decode!(fidl::encoding::Vector<ServiceHandle, 65535>, D, val_ref, decoder, inner_offset, inner_depth)?;
6344                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6345                {
6346                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6347                }
6348                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6349                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6350                }
6351            }
6352
6353            next_offset += envelope_size;
6354
6355            // Decode the remaining unknown envelopes.
6356            while next_offset < end_offset {
6357                _next_ordinal_to_read += 1;
6358                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6359                next_offset += envelope_size;
6360            }
6361
6362            Ok(())
6363        }
6364    }
6365
6366    impl ValueChangedParameters {
6367        #[inline(always)]
6368        fn max_ordinal_present(&self) -> u64 {
6369            if let Some(_) = self.peer_ids {
6370                return 3;
6371            }
6372            if let Some(_) = self.value {
6373                return 2;
6374            }
6375            if let Some(_) = self.handle {
6376                return 1;
6377            }
6378            0
6379        }
6380    }
6381
6382    impl fidl::encoding::ValueTypeMarker for ValueChangedParameters {
6383        type Borrowed<'a> = &'a Self;
6384        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6385            value
6386        }
6387    }
6388
6389    unsafe impl fidl::encoding::TypeMarker for ValueChangedParameters {
6390        type Owned = Self;
6391
6392        #[inline(always)]
6393        fn inline_align(_context: fidl::encoding::Context) -> usize {
6394            8
6395        }
6396
6397        #[inline(always)]
6398        fn inline_size(_context: fidl::encoding::Context) -> usize {
6399            16
6400        }
6401    }
6402
6403    unsafe impl<D: fidl::encoding::ResourceDialect>
6404        fidl::encoding::Encode<ValueChangedParameters, D> for &ValueChangedParameters
6405    {
6406        unsafe fn encode(
6407            self,
6408            encoder: &mut fidl::encoding::Encoder<'_, D>,
6409            offset: usize,
6410            mut depth: fidl::encoding::Depth,
6411        ) -> fidl::Result<()> {
6412            encoder.debug_check_bounds::<ValueChangedParameters>(offset);
6413            // Vector header
6414            let max_ordinal: u64 = self.max_ordinal_present();
6415            encoder.write_num(max_ordinal, offset);
6416            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6417            // Calling encoder.out_of_line_offset(0) is not allowed.
6418            if max_ordinal == 0 {
6419                return Ok(());
6420            }
6421            depth.increment()?;
6422            let envelope_size = 8;
6423            let bytes_len = max_ordinal as usize * envelope_size;
6424            #[allow(unused_variables)]
6425            let offset = encoder.out_of_line_offset(bytes_len);
6426            let mut _prev_end_offset: usize = 0;
6427            if 1 > max_ordinal {
6428                return Ok(());
6429            }
6430
6431            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6432            // are envelope_size bytes.
6433            let cur_offset: usize = (1 - 1) * envelope_size;
6434
6435            // Zero reserved fields.
6436            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6437
6438            // Safety:
6439            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6440            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6441            //   envelope_size bytes, there is always sufficient room.
6442            fidl::encoding::encode_in_envelope_optional::<Handle, D>(
6443                self.handle.as_ref().map(<Handle as fidl::encoding::ValueTypeMarker>::borrow),
6444                encoder,
6445                offset + cur_offset,
6446                depth,
6447            )?;
6448
6449            _prev_end_offset = cur_offset + envelope_size;
6450            if 2 > max_ordinal {
6451                return Ok(());
6452            }
6453
6454            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6455            // are envelope_size bytes.
6456            let cur_offset: usize = (2 - 1) * envelope_size;
6457
6458            // Zero reserved fields.
6459            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6460
6461            // Safety:
6462            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6463            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6464            //   envelope_size bytes, there is always sufficient room.
6465            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 512>, D>(
6466                self.value.as_ref().map(
6467                    <fidl::encoding::Vector<u8, 512> as fidl::encoding::ValueTypeMarker>::borrow,
6468                ),
6469                encoder,
6470                offset + cur_offset,
6471                depth,
6472            )?;
6473
6474            _prev_end_offset = cur_offset + envelope_size;
6475            if 3 > max_ordinal {
6476                return Ok(());
6477            }
6478
6479            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6480            // are envelope_size bytes.
6481            let cur_offset: usize = (3 - 1) * envelope_size;
6482
6483            // Zero reserved fields.
6484            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6485
6486            // Safety:
6487            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6488            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6489            //   envelope_size bytes, there is always sufficient room.
6490            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_common::PeerId>, D>(
6491            self.peer_ids.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_common::PeerId> as fidl::encoding::ValueTypeMarker>::borrow),
6492            encoder, offset + cur_offset, depth
6493        )?;
6494
6495            _prev_end_offset = cur_offset + envelope_size;
6496
6497            Ok(())
6498        }
6499    }
6500
6501    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
6502        for ValueChangedParameters
6503    {
6504        #[inline(always)]
6505        fn new_empty() -> Self {
6506            Self::default()
6507        }
6508
6509        unsafe fn decode(
6510            &mut self,
6511            decoder: &mut fidl::encoding::Decoder<'_, D>,
6512            offset: usize,
6513            mut depth: fidl::encoding::Depth,
6514        ) -> fidl::Result<()> {
6515            decoder.debug_check_bounds::<Self>(offset);
6516            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6517                None => return Err(fidl::Error::NotNullable),
6518                Some(len) => len,
6519            };
6520            // Calling decoder.out_of_line_offset(0) is not allowed.
6521            if len == 0 {
6522                return Ok(());
6523            };
6524            depth.increment()?;
6525            let envelope_size = 8;
6526            let bytes_len = len * envelope_size;
6527            let offset = decoder.out_of_line_offset(bytes_len)?;
6528            // Decode the envelope for each type.
6529            let mut _next_ordinal_to_read = 0;
6530            let mut next_offset = offset;
6531            let end_offset = offset + bytes_len;
6532            _next_ordinal_to_read += 1;
6533            if next_offset >= end_offset {
6534                return Ok(());
6535            }
6536
6537            // Decode unknown envelopes for gaps in ordinals.
6538            while _next_ordinal_to_read < 1 {
6539                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6540                _next_ordinal_to_read += 1;
6541                next_offset += envelope_size;
6542            }
6543
6544            let next_out_of_line = decoder.next_out_of_line();
6545            let handles_before = decoder.remaining_handles();
6546            if let Some((inlined, num_bytes, num_handles)) =
6547                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6548            {
6549                let member_inline_size =
6550                    <Handle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6551                if inlined != (member_inline_size <= 4) {
6552                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6553                }
6554                let inner_offset;
6555                let mut inner_depth = depth.clone();
6556                if inlined {
6557                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6558                    inner_offset = next_offset;
6559                } else {
6560                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6561                    inner_depth.increment()?;
6562                }
6563                let val_ref = self.handle.get_or_insert_with(|| fidl::new_empty!(Handle, D));
6564                fidl::decode!(Handle, D, val_ref, decoder, inner_offset, inner_depth)?;
6565                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6566                {
6567                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6568                }
6569                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6570                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6571                }
6572            }
6573
6574            next_offset += envelope_size;
6575            _next_ordinal_to_read += 1;
6576            if next_offset >= end_offset {
6577                return Ok(());
6578            }
6579
6580            // Decode unknown envelopes for gaps in ordinals.
6581            while _next_ordinal_to_read < 2 {
6582                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6583                _next_ordinal_to_read += 1;
6584                next_offset += envelope_size;
6585            }
6586
6587            let next_out_of_line = decoder.next_out_of_line();
6588            let handles_before = decoder.remaining_handles();
6589            if let Some((inlined, num_bytes, num_handles)) =
6590                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6591            {
6592                let member_inline_size =
6593                    <fidl::encoding::Vector<u8, 512> as fidl::encoding::TypeMarker>::inline_size(
6594                        decoder.context,
6595                    );
6596                if inlined != (member_inline_size <= 4) {
6597                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6598                }
6599                let inner_offset;
6600                let mut inner_depth = depth.clone();
6601                if inlined {
6602                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6603                    inner_offset = next_offset;
6604                } else {
6605                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6606                    inner_depth.increment()?;
6607                }
6608                let val_ref = self
6609                    .value
6610                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 512>, D));
6611                fidl::decode!(fidl::encoding::Vector<u8, 512>, D, val_ref, decoder, inner_offset, inner_depth)?;
6612                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6613                {
6614                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6615                }
6616                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6617                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6618                }
6619            }
6620
6621            next_offset += envelope_size;
6622            _next_ordinal_to_read += 1;
6623            if next_offset >= end_offset {
6624                return Ok(());
6625            }
6626
6627            // Decode unknown envelopes for gaps in ordinals.
6628            while _next_ordinal_to_read < 3 {
6629                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6630                _next_ordinal_to_read += 1;
6631                next_offset += envelope_size;
6632            }
6633
6634            let next_out_of_line = decoder.next_out_of_line();
6635            let handles_before = decoder.remaining_handles();
6636            if let Some((inlined, num_bytes, num_handles)) =
6637                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6638            {
6639                let member_inline_size = <fidl::encoding::UnboundedVector<
6640                    fidl_fuchsia_bluetooth_common::PeerId,
6641                > as fidl::encoding::TypeMarker>::inline_size(
6642                    decoder.context
6643                );
6644                if inlined != (member_inline_size <= 4) {
6645                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6646                }
6647                let inner_offset;
6648                let mut inner_depth = depth.clone();
6649                if inlined {
6650                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6651                    inner_offset = next_offset;
6652                } else {
6653                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6654                    inner_depth.increment()?;
6655                }
6656                let val_ref = self.peer_ids.get_or_insert_with(|| {
6657                    fidl::new_empty!(
6658                        fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_common::PeerId>,
6659                        D
6660                    )
6661                });
6662                fidl::decode!(
6663                    fidl::encoding::UnboundedVector<fidl_fuchsia_bluetooth_common::PeerId>,
6664                    D,
6665                    val_ref,
6666                    decoder,
6667                    inner_offset,
6668                    inner_depth
6669                )?;
6670                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6671                {
6672                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6673                }
6674                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6675                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6676                }
6677            }
6678
6679            next_offset += envelope_size;
6680
6681            // Decode the remaining unknown envelopes.
6682            while next_offset < end_offset {
6683                _next_ordinal_to_read += 1;
6684                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6685                next_offset += envelope_size;
6686            }
6687
6688            Ok(())
6689        }
6690    }
6691
6692    impl WriteOptions {
6693        #[inline(always)]
6694        fn max_ordinal_present(&self) -> u64 {
6695            if let Some(_) = self.offset {
6696                return 2;
6697            }
6698            if let Some(_) = self.write_mode {
6699                return 1;
6700            }
6701            0
6702        }
6703    }
6704
6705    impl fidl::encoding::ValueTypeMarker for WriteOptions {
6706        type Borrowed<'a> = &'a Self;
6707        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6708            value
6709        }
6710    }
6711
6712    unsafe impl fidl::encoding::TypeMarker for WriteOptions {
6713        type Owned = Self;
6714
6715        #[inline(always)]
6716        fn inline_align(_context: fidl::encoding::Context) -> usize {
6717            8
6718        }
6719
6720        #[inline(always)]
6721        fn inline_size(_context: fidl::encoding::Context) -> usize {
6722            16
6723        }
6724    }
6725
6726    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WriteOptions, D>
6727        for &WriteOptions
6728    {
6729        unsafe fn encode(
6730            self,
6731            encoder: &mut fidl::encoding::Encoder<'_, D>,
6732            offset: usize,
6733            mut depth: fidl::encoding::Depth,
6734        ) -> fidl::Result<()> {
6735            encoder.debug_check_bounds::<WriteOptions>(offset);
6736            // Vector header
6737            let max_ordinal: u64 = self.max_ordinal_present();
6738            encoder.write_num(max_ordinal, offset);
6739            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6740            // Calling encoder.out_of_line_offset(0) is not allowed.
6741            if max_ordinal == 0 {
6742                return Ok(());
6743            }
6744            depth.increment()?;
6745            let envelope_size = 8;
6746            let bytes_len = max_ordinal as usize * envelope_size;
6747            #[allow(unused_variables)]
6748            let offset = encoder.out_of_line_offset(bytes_len);
6749            let mut _prev_end_offset: usize = 0;
6750            if 1 > max_ordinal {
6751                return Ok(());
6752            }
6753
6754            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6755            // are envelope_size bytes.
6756            let cur_offset: usize = (1 - 1) * envelope_size;
6757
6758            // Zero reserved fields.
6759            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6760
6761            // Safety:
6762            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6763            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6764            //   envelope_size bytes, there is always sufficient room.
6765            fidl::encoding::encode_in_envelope_optional::<WriteMode, D>(
6766                self.write_mode
6767                    .as_ref()
6768                    .map(<WriteMode as fidl::encoding::ValueTypeMarker>::borrow),
6769                encoder,
6770                offset + cur_offset,
6771                depth,
6772            )?;
6773
6774            _prev_end_offset = cur_offset + envelope_size;
6775            if 2 > max_ordinal {
6776                return Ok(());
6777            }
6778
6779            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6780            // are envelope_size bytes.
6781            let cur_offset: usize = (2 - 1) * envelope_size;
6782
6783            // Zero reserved fields.
6784            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6785
6786            // Safety:
6787            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6788            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6789            //   envelope_size bytes, there is always sufficient room.
6790            fidl::encoding::encode_in_envelope_optional::<u16, D>(
6791                self.offset.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
6792                encoder,
6793                offset + cur_offset,
6794                depth,
6795            )?;
6796
6797            _prev_end_offset = cur_offset + envelope_size;
6798
6799            Ok(())
6800        }
6801    }
6802
6803    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WriteOptions {
6804        #[inline(always)]
6805        fn new_empty() -> Self {
6806            Self::default()
6807        }
6808
6809        unsafe fn decode(
6810            &mut self,
6811            decoder: &mut fidl::encoding::Decoder<'_, D>,
6812            offset: usize,
6813            mut depth: fidl::encoding::Depth,
6814        ) -> fidl::Result<()> {
6815            decoder.debug_check_bounds::<Self>(offset);
6816            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6817                None => return Err(fidl::Error::NotNullable),
6818                Some(len) => len,
6819            };
6820            // Calling decoder.out_of_line_offset(0) is not allowed.
6821            if len == 0 {
6822                return Ok(());
6823            };
6824            depth.increment()?;
6825            let envelope_size = 8;
6826            let bytes_len = len * envelope_size;
6827            let offset = decoder.out_of_line_offset(bytes_len)?;
6828            // Decode the envelope for each type.
6829            let mut _next_ordinal_to_read = 0;
6830            let mut next_offset = offset;
6831            let end_offset = offset + bytes_len;
6832            _next_ordinal_to_read += 1;
6833            if next_offset >= end_offset {
6834                return Ok(());
6835            }
6836
6837            // Decode unknown envelopes for gaps in ordinals.
6838            while _next_ordinal_to_read < 1 {
6839                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6840                _next_ordinal_to_read += 1;
6841                next_offset += envelope_size;
6842            }
6843
6844            let next_out_of_line = decoder.next_out_of_line();
6845            let handles_before = decoder.remaining_handles();
6846            if let Some((inlined, num_bytes, num_handles)) =
6847                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6848            {
6849                let member_inline_size =
6850                    <WriteMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6851                if inlined != (member_inline_size <= 4) {
6852                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6853                }
6854                let inner_offset;
6855                let mut inner_depth = depth.clone();
6856                if inlined {
6857                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6858                    inner_offset = next_offset;
6859                } else {
6860                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6861                    inner_depth.increment()?;
6862                }
6863                let val_ref = self.write_mode.get_or_insert_with(|| fidl::new_empty!(WriteMode, D));
6864                fidl::decode!(WriteMode, D, val_ref, decoder, inner_offset, inner_depth)?;
6865                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6866                {
6867                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6868                }
6869                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6870                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6871                }
6872            }
6873
6874            next_offset += envelope_size;
6875            _next_ordinal_to_read += 1;
6876            if next_offset >= end_offset {
6877                return Ok(());
6878            }
6879
6880            // Decode unknown envelopes for gaps in ordinals.
6881            while _next_ordinal_to_read < 2 {
6882                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6883                _next_ordinal_to_read += 1;
6884                next_offset += envelope_size;
6885            }
6886
6887            let next_out_of_line = decoder.next_out_of_line();
6888            let handles_before = decoder.remaining_handles();
6889            if let Some((inlined, num_bytes, num_handles)) =
6890                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6891            {
6892                let member_inline_size =
6893                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6894                if inlined != (member_inline_size <= 4) {
6895                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6896                }
6897                let inner_offset;
6898                let mut inner_depth = depth.clone();
6899                if inlined {
6900                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6901                    inner_offset = next_offset;
6902                } else {
6903                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6904                    inner_depth.increment()?;
6905                }
6906                let val_ref = self.offset.get_or_insert_with(|| fidl::new_empty!(u16, D));
6907                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
6908                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6909                {
6910                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6911                }
6912                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6913                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6914                }
6915            }
6916
6917            next_offset += envelope_size;
6918
6919            // Decode the remaining unknown envelopes.
6920            while next_offset < end_offset {
6921                _next_ordinal_to_read += 1;
6922                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6923                next_offset += envelope_size;
6924            }
6925
6926            Ok(())
6927        }
6928    }
6929
6930    impl fidl::encoding::ValueTypeMarker for ReadOptions {
6931        type Borrowed<'a> = &'a Self;
6932        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6933            value
6934        }
6935    }
6936
6937    unsafe impl fidl::encoding::TypeMarker for ReadOptions {
6938        type Owned = Self;
6939
6940        #[inline(always)]
6941        fn inline_align(_context: fidl::encoding::Context) -> usize {
6942            8
6943        }
6944
6945        #[inline(always)]
6946        fn inline_size(_context: fidl::encoding::Context) -> usize {
6947            16
6948        }
6949    }
6950
6951    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ReadOptions, D>
6952        for &ReadOptions
6953    {
6954        #[inline]
6955        unsafe fn encode(
6956            self,
6957            encoder: &mut fidl::encoding::Encoder<'_, D>,
6958            offset: usize,
6959            _depth: fidl::encoding::Depth,
6960        ) -> fidl::Result<()> {
6961            encoder.debug_check_bounds::<ReadOptions>(offset);
6962            encoder.write_num::<u64>(self.ordinal(), offset);
6963            match self {
6964                ReadOptions::ShortRead(ref val) => {
6965                    fidl::encoding::encode_in_envelope::<ShortReadOptions, D>(
6966                        <ShortReadOptions as fidl::encoding::ValueTypeMarker>::borrow(val),
6967                        encoder,
6968                        offset + 8,
6969                        _depth,
6970                    )
6971                }
6972                ReadOptions::LongRead(ref val) => {
6973                    fidl::encoding::encode_in_envelope::<LongReadOptions, D>(
6974                        <LongReadOptions as fidl::encoding::ValueTypeMarker>::borrow(val),
6975                        encoder,
6976                        offset + 8,
6977                        _depth,
6978                    )
6979                }
6980                ReadOptions::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
6981            }
6982        }
6983    }
6984
6985    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReadOptions {
6986        #[inline(always)]
6987        fn new_empty() -> Self {
6988            Self::__SourceBreaking { unknown_ordinal: 0 }
6989        }
6990
6991        #[inline]
6992        unsafe fn decode(
6993            &mut self,
6994            decoder: &mut fidl::encoding::Decoder<'_, D>,
6995            offset: usize,
6996            mut depth: fidl::encoding::Depth,
6997        ) -> fidl::Result<()> {
6998            decoder.debug_check_bounds::<Self>(offset);
6999            #[allow(unused_variables)]
7000            let next_out_of_line = decoder.next_out_of_line();
7001            let handles_before = decoder.remaining_handles();
7002            let (ordinal, inlined, num_bytes, num_handles) =
7003                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
7004
7005            let member_inline_size = match ordinal {
7006                1 => <ShortReadOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context),
7007                2 => <LongReadOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context),
7008                0 => return Err(fidl::Error::UnknownUnionTag),
7009                _ => num_bytes as usize,
7010            };
7011
7012            if inlined != (member_inline_size <= 4) {
7013                return Err(fidl::Error::InvalidInlineBitInEnvelope);
7014            }
7015            let _inner_offset;
7016            if inlined {
7017                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
7018                _inner_offset = offset + 8;
7019            } else {
7020                depth.increment()?;
7021                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7022            }
7023            match ordinal {
7024                1 => {
7025                    #[allow(irrefutable_let_patterns)]
7026                    if let ReadOptions::ShortRead(_) = self {
7027                        // Do nothing, read the value into the object
7028                    } else {
7029                        // Initialize `self` to the right variant
7030                        *self = ReadOptions::ShortRead(fidl::new_empty!(ShortReadOptions, D));
7031                    }
7032                    #[allow(irrefutable_let_patterns)]
7033                    if let ReadOptions::ShortRead(ref mut val) = self {
7034                        fidl::decode!(ShortReadOptions, D, val, decoder, _inner_offset, depth)?;
7035                    } else {
7036                        unreachable!()
7037                    }
7038                }
7039                2 => {
7040                    #[allow(irrefutable_let_patterns)]
7041                    if let ReadOptions::LongRead(_) = self {
7042                        // Do nothing, read the value into the object
7043                    } else {
7044                        // Initialize `self` to the right variant
7045                        *self = ReadOptions::LongRead(fidl::new_empty!(LongReadOptions, D));
7046                    }
7047                    #[allow(irrefutable_let_patterns)]
7048                    if let ReadOptions::LongRead(ref mut val) = self {
7049                        fidl::decode!(LongReadOptions, D, val, decoder, _inner_offset, depth)?;
7050                    } else {
7051                        unreachable!()
7052                    }
7053                }
7054                #[allow(deprecated)]
7055                ordinal => {
7056                    for _ in 0..num_handles {
7057                        decoder.drop_next_handle()?;
7058                    }
7059                    *self = ReadOptions::__SourceBreaking { unknown_ordinal: ordinal };
7060                }
7061            }
7062            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
7063                return Err(fidl::Error::InvalidNumBytesInEnvelope);
7064            }
7065            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7066                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7067            }
7068            Ok(())
7069        }
7070    }
7071}