fidl_fuchsia_sysmem2__common/
fidl_fuchsia_sysmem2__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
11pub const CPU_USAGE_READ: u32 = 1;
12
13pub const CPU_USAGE_READ_OFTEN: u32 = 2;
14
15pub const CPU_USAGE_WRITE: u32 = 4;
16
17pub const CPU_USAGE_WRITE_OFTEN: u32 = 8;
18
19pub const DISPLAY_USAGE_CURSOR: u32 = 2;
20
21pub const DISPLAY_USAGE_LAYER: u32 = 1;
22
23/// The max length in bytes of the `name` request field in
24/// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] and
25/// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
26pub const MAX_CLIENT_NAME_LENGTH: i32 = 256;
27
28/// The maximum size of
29/// [`fuchsia.sysmem2/BufferCollectionConstraints.image_format_constraints`].
30pub const MAX_COUNT_BUFFER_COLLECTION_CONSTRAINTS_IMAGE_FORMAT_CONSTRAINTS: u32 = 64;
31
32/// The maximum entries that can be in the
33/// [`fuchsia.sysmem2/BufferCollectionInfo.buffers`] field.
34pub const MAX_COUNT_BUFFER_COLLECTION_INFO_BUFFERS: u32 = 128;
35
36/// The maximum size of
37/// [`fuchsia.sysmem2/BufferMemoryConstraints.permitted_heaps`].
38pub const MAX_COUNT_BUFFER_MEMORY_CONSTRAINTS_PERMITTED_HEAPS: u32 = 64;
39
40/// The maximum number of token children of an OR group that can be created per
41/// call to [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`].
42///
43/// Actually creating this many children isn't recommended in most typical
44/// scenarios, but isn't prevented, for testing reasons, and just in case an
45/// unusual scenario needs it. Mitigation of potentially high time complexity in
46/// sysmem will limit the actual number of group child combinations considered
47/// in aggregation attempts to a separate maximum that is not settable via
48/// sysmem protocols. The maximum number of total nodes in a sysmem token tree
49/// is limited to a separate maximum that is not settable via these protocols.
50pub const MAX_COUNT_CREATE_CHILDREN: i32 = 64;
51
52pub const MAX_COUNT_DUPLICATES: u32 = 64;
53
54/// The maximum size of [`fuchsia.sysmem2/ImageFormatConstraints.color_spaces`].
55pub const MAX_COUNT_IMAGE_FORMAT_CONSTRAINTS_COLOR_SPACES: u32 = 32;
56
57pub const MAX_COUNT_IMAGE_FORMAT_CONSTRAINTS_REQUIRED_MAX_SIZE_LIST: u32 = 64;
58
59/// The maximum size of
60/// [`fuchsia.sysmem2/ImageFormatConstraints.pixel_format_and_modifiers`].
61pub const MAX_COUNT_PIXEL_FORMAT_AND_MODIFIERS: u32 = 64;
62
63pub const MAX_HEAPS_COUNT: u32 = 32;
64
65pub const MAX_RANGES_COUNT: u32 = 128;
66
67pub const NONE_USAGE: u32 = 1;
68
69pub const NONE_USAGE_PERMIT_ALLOCATION: u32 = 2;
70
71pub const VIDEO_USAGE_CAPTURE: u32 = 8;
72
73pub const VIDEO_USAGE_DECRYPTOR_OUTPUT: u32 = 16;
74
75pub const VIDEO_USAGE_HW_DECODER: u32 = 1;
76
77pub const VIDEO_USAGE_HW_DECODER_INTERNAL: u32 = 32;
78
79pub const VIDEO_USAGE_HW_ENCODER: u32 = 2;
80
81pub const VULKAN_BUFFER_USAGE_INDEX_BUFFER: u32 = 4194304;
82
83pub const VULKAN_BUFFER_USAGE_INDIRECT_BUFFER: u32 = 16777216;
84
85pub const VULKAN_BUFFER_USAGE_STORAGE_BUFFER: u32 = 2097152;
86
87pub const VULKAN_BUFFER_USAGE_STORAGE_TEXEL_BUFFER: u32 = 524288;
88
89pub const VULKAN_BUFFER_USAGE_TRANSFER_DST: u32 = 131072;
90
91pub const VULKAN_BUFFER_USAGE_TRANSFER_SRC: u32 = 65536;
92
93pub const VULKAN_BUFFER_USAGE_UNIFORM_BUFFER: u32 = 1048576;
94
95pub const VULKAN_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER: u32 = 262144;
96
97pub const VULKAN_BUFFER_USAGE_VERTEX_BUFFER: u32 = 8388608;
98
99pub const VULKAN_IMAGE_USAGE_COLOR_ATTACHMENT: u32 = 16;
100
101pub const VULKAN_IMAGE_USAGE_INPUT_ATTACHMENT: u32 = 128;
102
103pub const VULKAN_IMAGE_USAGE_SAMPLED: u32 = 4;
104
105pub const VULKAN_IMAGE_USAGE_STENCIL_ATTACHMENT: u32 = 32;
106
107pub const VULKAN_IMAGE_USAGE_STORAGE: u32 = 8;
108
109pub const VULKAN_IMAGE_USAGE_TRANSFER_DST: u32 = 2;
110
111pub const VULKAN_IMAGE_USAGE_TRANSFER_SRC: u32 = 1;
112
113pub const VULKAN_IMAGE_USAGE_TRANSIENT_ATTACHMENT: u32 = 64;
114
115/// `INACCESSIBLE` is only for cases where there is no CPU access to the
116/// buffers.
117///
118/// Device-local memory that isn't reachable from the CPU is `CoherencyDomain`
119/// `INACCESSIBLE`, even if it's possible to cause a device (physical or
120/// virtual) to copy the data from the `INACCESSIBLE` buffers to buffers that
121/// are visible to the CPU. In other words, INACCESSIBLE does not imply secure,
122/// but secure implies INACCESSIBLE.
123///
124/// `CPU` means producers must ensure that a consumer can read the produced data
125/// with the CPU without the consumer needing to do additional cache ops not
126/// already performed (as needed) by the producer.
127///
128/// `RAM` means producers must ensure that the produced data is entirely present
129/// in RAM, without any dirty CPU cache lines, and a consumer must invalidate
130/// (or flush and invalidate, typically) the CPU cache before reading data with
131/// the CPU. The `RAM` domain can be faster than the `CPU` domain when all
132/// access is via HW DMA, since in that case no CPU cache ops are required,
133/// since no participant is actually reading/writing using the CPU.
134#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
135pub enum CoherencyDomain {
136    Cpu,
137    Ram,
138    Inaccessible,
139    #[doc(hidden)]
140    __SourceBreaking {
141        unknown_ordinal: u32,
142    },
143}
144
145/// Pattern that matches an unknown `CoherencyDomain` member.
146#[macro_export]
147macro_rules! CoherencyDomainUnknown {
148    () => {
149        _
150    };
151}
152
153impl CoherencyDomain {
154    #[inline]
155    pub fn from_primitive(prim: u32) -> Option<Self> {
156        match prim {
157            0 => Some(Self::Cpu),
158            1 => Some(Self::Ram),
159            2 => Some(Self::Inaccessible),
160            _ => None,
161        }
162    }
163
164    #[inline]
165    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
166        match prim {
167            0 => Self::Cpu,
168            1 => Self::Ram,
169            2 => Self::Inaccessible,
170            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
171        }
172    }
173
174    #[inline]
175    pub fn unknown() -> Self {
176        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
177    }
178
179    #[inline]
180    pub const fn into_primitive(self) -> u32 {
181        match self {
182            Self::Cpu => 0,
183            Self::Ram => 1,
184            Self::Inaccessible => 2,
185            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
186        }
187    }
188
189    #[inline]
190    pub fn is_unknown(&self) -> bool {
191        match self {
192            Self::__SourceBreaking { unknown_ordinal: _ } => true,
193            _ => false,
194        }
195    }
196}
197
198/// Regardless of which error code, any client retries should be very limited in
199/// number, if any.
200///
201/// A Error value should never be stored in a zx_status_t, since positive values
202/// in zx_status_t are deprecated.
203#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
204pub enum Error {
205    /// This is not a valid error value in this error enum. The server will
206    /// never send this value as a failure code. This value is not treated as
207    /// "success". In some languages, a locally default-initialized Error
208    /// instance will have this value until it is initialized with a valid
209    /// positive error code.
210    Invalid,
211    /// Unspecified error.
212    ///
213    /// This error code is used when no other error code applies, and the error
214    /// is probably not due to problematic messages sent to the server via the
215    /// channel delivering this error.
216    ///
217    /// This error should be handled by the client as a generic error.
218    ///
219    /// As one example, this error is used when a different client channel has
220    /// closed from the client end unexpectedly (without sending
221    /// [`fuchsia.sysmem2/Node.Release`] first), thereby causing failure of any
222    /// nodes in the same tree or sub-tree. In this usage, the main thing that's
223    /// relevant is it isn't the receiving client's "fault" - no reason to be
224    /// more specific since there's probably nothing the receiving client could
225    /// do about the error, at least not directly.
226    ///
227    /// As another example, this error can be used if a syscall that is normally
228    /// expected to succeed fails unexpectedly, and there's no identified reason
229    /// to "blame" the client.
230    ///
231    /// A client should never require / depend on a particular cause of error
232    /// continuing to result in UNSPECIFIED, as any particular error cause can
233    /// potentially start resulting in a more specific error code in future.
234    Unspecified,
235    /// A required field wasn't set or a specified value was invalid. See the
236    /// log for more info.
237    ///
238    /// This is also used when a message is received from the client in the
239    /// wrong order or in some way inconsistent with protocol rules.
240    ProtocolDeviation,
241    /// A client-specified object or ID was not found.
242    NotFound,
243    /// The object handle doesn't have sufficient rights to perform the request.
244    HandleAccessDenied,
245    /// The allocation could not be satisfied due to lack of available memory.
246    ///
247    /// The memory exhaustion can be specific to the heap that was selected
248    /// during constraints aggregation, so in some cases, this error can happen
249    /// despite normal system RAM not being near exhaustion, depending on
250    /// configured and selected heap(s).
251    NoMemory,
252    /// The request is valid but cannot be satisfied, perhaps due to hardware
253    /// limitations. This happens if participants involved in this allocation
254    /// have incompatible constraints (empty intersection, roughly speaking).
255    /// See the log for more info. In cases where a participant could
256    /// potentially be treated as optional, see [`BufferCollectionTokenGroup`].
257    ///
258    /// This can also happen if there aren't enough buffers in a pre-existing
259    /// collection to satisfy an additional token (including sub-tree of derived
260    /// tokens) created with [`fuchsia.sysmem2/BufferCollection.AttachToken`].
261    ///
262    /// This can also happen if a client's node is under a group and a different
263    /// group child is selected instead.
264    ConstraintsIntersectionEmpty,
265    /// Allocation hasn't been attempted yet. Calling
266    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] would
267    /// (likely) block.
268    Pending,
269    /// Too many `BufferCollectionTokenGroup` child token selection combinations
270    /// exist and were considered, causing sysmem to give up on allocating
271    /// rather than enumerate the rest.
272    TooManyGroupChildCombinations,
273    #[doc(hidden)]
274    __SourceBreaking { unknown_ordinal: u32 },
275}
276
277/// Pattern that matches an unknown `Error` member.
278#[macro_export]
279macro_rules! ErrorUnknown {
280    () => {
281        _
282    };
283}
284
285impl Error {
286    #[inline]
287    pub fn from_primitive(prim: u32) -> Option<Self> {
288        match prim {
289            0 => Some(Self::Invalid),
290            1 => Some(Self::Unspecified),
291            2 => Some(Self::ProtocolDeviation),
292            3 => Some(Self::NotFound),
293            4 => Some(Self::HandleAccessDenied),
294            5 => Some(Self::NoMemory),
295            6 => Some(Self::ConstraintsIntersectionEmpty),
296            7 => Some(Self::Pending),
297            8 => Some(Self::TooManyGroupChildCombinations),
298            _ => None,
299        }
300    }
301
302    #[inline]
303    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
304        match prim {
305            0 => Self::Invalid,
306            1 => Self::Unspecified,
307            2 => Self::ProtocolDeviation,
308            3 => Self::NotFound,
309            4 => Self::HandleAccessDenied,
310            5 => Self::NoMemory,
311            6 => Self::ConstraintsIntersectionEmpty,
312            7 => Self::Pending,
313            8 => Self::TooManyGroupChildCombinations,
314            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
315        }
316    }
317
318    #[inline]
319    pub fn unknown() -> Self {
320        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
321    }
322
323    #[inline]
324    pub const fn into_primitive(self) -> u32 {
325        match self {
326            Self::Invalid => 0,
327            Self::Unspecified => 1,
328            Self::ProtocolDeviation => 2,
329            Self::NotFound => 3,
330            Self::HandleAccessDenied => 4,
331            Self::NoMemory => 5,
332            Self::ConstraintsIntersectionEmpty => 6,
333            Self::Pending => 7,
334            Self::TooManyGroupChildCombinations => 8,
335            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
336        }
337    }
338
339    #[inline]
340    pub fn is_unknown(&self) -> bool {
341        match self {
342            Self::__SourceBreaking { unknown_ordinal: _ } => true,
343            _ => false,
344        }
345    }
346}
347
348#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
349pub struct PixelFormatAndModifier {
350    /// When specified by a participant in a message to sysmem, this can be any
351    /// `PixelFormat` value that's acceptable to the participant. Specifying
352    /// `kInvalid` is not permitted.
353    ///
354    /// The participant can specify [`fuchsia.images2/PixelFormat.DO_NOT_CARE`]
355    /// if the participant needs to specify `ImageFormatConstraints` without
356    /// constraining the `pixel_format`.
357    pub pixel_format: fidl_fuchsia_images2__common::PixelFormat,
358    /// The participant can specify
359    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] if the participant
360    /// needs to specify `ImageFormatConstraints` without constraining the
361    /// `pixel_format_modifier`.
362    pub pixel_format_modifier: fidl_fuchsia_images2__common::PixelFormatModifier,
363}
364
365impl fidl::Persistable for PixelFormatAndModifier {}
366
367#[derive(Clone, Debug, Default, PartialEq)]
368pub struct AllocatorSetDebugClientInfoRequest {
369    pub name: Option<String>,
370    pub id: Option<u64>,
371    #[doc(hidden)]
372    pub __source_breaking: fidl::marker::SourceBreaking,
373}
374
375impl fidl::Persistable for AllocatorSetDebugClientInfoRequest {}
376
377#[derive(Clone, Debug, Default, PartialEq)]
378pub struct AllocatorValidateBufferCollectionTokenRequest {
379    pub token_server_koid: Option<u64>,
380    #[doc(hidden)]
381    pub __source_breaking: fidl::marker::SourceBreaking,
382}
383
384impl fidl::Persistable for AllocatorValidateBufferCollectionTokenRequest {}
385
386#[derive(Clone, Debug, Default, PartialEq)]
387pub struct AllocatorValidateBufferCollectionTokenResponse {
388    pub is_known: Option<bool>,
389    #[doc(hidden)]
390    pub __source_breaking: fidl::marker::SourceBreaking,
391}
392
393impl fidl::Persistable for AllocatorValidateBufferCollectionTokenResponse {}
394
395/// Constraints on allocated buffers and, optionally, constraints on images
396/// stored in the buffers. These constraints can be specified per-participant.
397/// The sysmem service implements aggregation of constraints from multiple
398/// participants.
399#[derive(Clone, Debug, Default, PartialEq)]
400pub struct BufferCollectionConstraints {
401    /// The `usage` is a hint to sysmem to potentially help choose a more
402    /// optimal [`fuchsia.images2/PixelFormat`] and/or `pixel_format_modifier`
403    /// when multiple compatible options exist.
404    ///
405    /// When aggregating [`fuchsia.sysmem2/BufferCollectionConstraints`], these
406    /// values bitwise-OR.
407    ///
408    /// At least one `usage` bit must be specified (however, it's permitted for
409    /// a [`fuchsia.sysmem2/BufferCollection.SetConstraints`] request to have
410    /// the request `constraints` field not set, in which case `kNoneUsage` is
411    /// the default, along with no constraints from the participant).
412    ///
413    /// When `kNoneUsage` is specified it must be the only set bit, and no VMOs
414    /// will be sent in response to
415    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
416    pub usage: Option<BufferUsage>,
417    /// Per-participant number of buffers that the participant may concurrently
418    /// hold for its exclusive use for more than a transient duration (camp on).
419    /// In this context, a "transient" duration is the time it takes to finish
420    /// running a small amount of non-blocking code that finishes transfering
421    /// away ownership of the buffer. Things like reading from storage, waiting
422    /// on hardware that isn't already known to be done, or doing things like
423    /// frame encode or decode are not considered transient durations, even if
424    /// they might sometimes complete quickly.
425    ///
426    /// For example, a video decoder would specify (at least) the maximum number
427    /// of reference frames + 1 frame currently being decoded into. But not 1
428    /// more for the code that runs async and quickly to deliver a previously
429    /// decoded frame, even though that frame can potentially be owned for a
430    /// transient duration concurrent with decode of the next frame.
431    ///
432    /// A participant must not camp on more buffers than specified here (except
433    /// for a transient duration) else processing may get stuck.
434    ///
435    /// When aggregating BufferCollectionConstraints, these values add.
436    ///
437    /// In testing scenarios, camping on more buffers than this for any
438    /// significant duration (one screen refresh period is "significant" in this
439    /// context) may (ideally will) be flagged as a failure.  In testing
440    /// scenarios, the participant may not be provided with more buffers than
441    /// this concurrently.
442    pub min_buffer_count_for_camping: Option<u32>,
443    /// Per-participant minimum number of buffers that are needed for slack
444    /// reasons, for better overlap of processing / better performance.
445    ///
446    /// When aggregating `BufferCollectionConstraints`, these values add.
447    ///
448    /// A participant should typically specify 0 or 1 here - typically 0 is
449    /// appropriate if `min_buffer_count_for_camping` is already enough to keep
450    /// the participant busy 100% of the time when the participant is slightly
451    /// behind, while 1 can be appropriate if 1 more buffer than strictly needed
452    /// for min-camping reasons gives enough slack to stay busy 100% of the time
453    /// (when slightly behind, vs. lower % without the extra buffer).
454    ///
455    /// In testing scenarios, this field may be forced to 0, and all
456    /// participants are expected to continue to work without getting stuck. If
457    /// a buffer is needed for forward progress reasons, that buffer should be
458    /// accounted for in `min_buffer_count_for_camping`.
459    pub min_buffer_count_for_dedicated_slack: Option<u32>,
460    /// Similar to `min_buffer_count_for_dedicated_slack`, except when
461    /// aggregating these values max (instead of add). The value here is not
462    /// shared with any participant's `min_buffer_count_for_dedicated_slack`.
463    ///
464    /// A participant can specify > 0 here if a participant would like to ensure
465    /// there's some slack overall, but doesn't need that slack to be dedicated.
466    ///
467    /// The choice whether to use `min_buffer_count_for_dedicated_slack` or
468    /// `min_buffer_count_for_shared_slack` (or both) will typically be about
469    /// the degree to which the extra slack improves performance.
470    ///
471    /// In testing scenarios, this field may be forced to 0, and all
472    /// participants are expected to continue to work without getting stuck. If
473    /// a buffer is needed for forward progress reasons, that buffer should be
474    /// accounted for in `min_buffer_count_for_camping`.
475    pub min_buffer_count_for_shared_slack: Option<u32>,
476    /// A particularly-picky participant may unfortunately need to demand a
477    /// tight range of `buffer_count`, or even a specific `buffer_count`. This
478    /// field should remain 0 unless a participant really must set this field to
479    /// constrain the overall `BufferCollectionInfo.buffer_count`. Any such
480    /// participant should still fill out the min_buffer_count_for_* fields as
481    /// appropriate.
482    ///
483    /// If this field is un-set, the logical `min_buffer_count` is 0.
484    pub min_buffer_count: Option<u32>,
485    /// A particularly-picky participant may unfortunately need to demand a
486    /// tight range of `buffer_count`, or even a specific `buffer_count`. This
487    /// field should remain 0 unless a participant really must set this field to
488    /// constrain the overall `BufferCollectionInfo.buffer_count`. Any such
489    /// participant should still fill out the min_buffer_count_for_* fields.
490    ///
491    /// If this field is un-set, the logical `max_buffer_count` is 0xFFFFFFFF.
492    pub max_buffer_count: Option<u32>,
493    /// Optional constraints on `BufferCollectionSettings.buffer_settings`.
494    ///
495    /// A participant that intends to set `image_format_constraints` will
496    /// typically specify the minimum buffer size implicitly via
497    /// `image_format_constraints`, and possibly specify only the max buffer
498    /// size via `buffer_memory_constraints`.
499    ///
500    /// If un-set, the client is specifying "don't care" re. any buffer memory
501    /// constraints.
502    pub buffer_memory_constraints: Option<BufferMemoryConstraints>,
503    /// Optional constraints on the image format parameters of an image stored
504    /// in a buffer of the collection. This includes
505    /// [`fuchsia.images2/PixelFormat`] and `pixel_format_modifier` (for tiling
506    /// and the like). These constraints can be specified separately per
507    /// `pixel_format` `pixel_format_modifier` pair. Duplicated `pixel_format`
508    /// `pixel_format_modifier` pairs aren't permitted.
509    ///
510    /// When aggregating, only `pixel_format` `pixel_format_modifier` pairs that
511    /// are specified by all participants with non-zero
512    /// `image_format_constraints` size (and non-null)
513    /// BufferCollectionConstraints) are retained.
514    ///
515    /// A participant can specify `pixel_format`
516    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] and/or
517    /// `pixel_format_modifier`
518    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] to permit any value
519    /// to be selected, but at least one participant must specify a specific
520    /// format for overall allocation to succeed.
521    ///
522    /// In a SetConstraints message, un-set or zero length means no image format
523    /// constraints; a raw buffer can be allocated if no other participants
524    /// specify any `image_format_constraints` entries.
525    pub image_format_constraints: Option<Vec<ImageFormatConstraints>>,
526    #[doc(hidden)]
527    pub __source_breaking: fidl::marker::SourceBreaking,
528}
529
530impl fidl::Persistable for BufferCollectionConstraints {}
531
532#[derive(Clone, Debug, Default, PartialEq)]
533pub struct BufferCollectionTokenDuplicateSyncRequest {
534    pub rights_attenuation_masks: Option<Vec<fidl::Rights>>,
535    #[doc(hidden)]
536    pub __source_breaking: fidl::marker::SourceBreaking,
537}
538
539impl fidl::Persistable for BufferCollectionTokenDuplicateSyncRequest {}
540
541#[derive(Clone, Debug, Default, PartialEq)]
542pub struct BufferCollectionTokenGroupCreateChildrenSyncRequest {
543    pub rights_attenuation_masks: Option<Vec<fidl::Rights>>,
544    #[doc(hidden)]
545    pub __source_breaking: fidl::marker::SourceBreaking,
546}
547
548impl fidl::Persistable for BufferCollectionTokenGroupCreateChildrenSyncRequest {}
549
550#[derive(Clone, Debug, Default, PartialEq)]
551pub struct BufferMemoryConstraints {
552    /// un-set is treated as 1
553    pub min_size_bytes: Option<u64>,
554    /// un-set is treated as 0xFFFFFFFFFFFFFFFF.
555    pub max_size_bytes: Option<u64>,
556    /// When false, physical pages of a buffer VMO can be non-contiguous. When
557    /// true, physical pages of a buffer VMO must be sequentially contiguous. A
558    /// client that doesn't require physically contiguous VMOs must still accept
559    /// physically contiguous VMOs or "physical" VMOs.
560    pub physically_contiguous_required: Option<bool>,
561    /// If true, the participant requires secure memory.
562    ///
563    /// When aggregating `BufferCollectionConstraints`, these values boolean-OR.
564    pub secure_required: Option<bool>,
565    /// When true (or when `BufferMemoryConstraints` is not present), the
566    /// participant is ok with sysmem selecting the CPU domain.
567    ///
568    /// If the CPU domain is selected, participants must ensure the CPU can read
569    /// or write data to the buffer without cache operations outside of the
570    /// participant.
571    ///
572    /// In other words, if a producer participant DMAs data directly to RAM on a
573    /// non-cache-coherent architecture such as arm, the producer must ensure
574    /// the CPU cache is clean wrt. the buffer before the DMA write, and
575    /// invalidate the CPU cache after the DMA write and before indicating that
576    /// the buffer is ready to any other participant. If a consumer participant
577    /// DMAs data directly from RAM on a non-cache-coherent architecture such as
578    /// arm, the consumer must flush the CPU cache wrt the buffer before the DMA
579    /// read.
580    ///
581    /// CPU-only participants that don't do any DMA can just write and read the
582    /// buffers (when they should) without needing to do any CPU cache ops.
583    pub cpu_domain_supported: Option<bool>,
584    /// When true, the participant is ok with sysmem selecting the RAM domain.
585    ///
586    /// If the RAM domain is selected, producer data must be available in RAM
587    /// (with CPU cache state such that the RAM data won't get corrupted by a
588    /// dirty CPU cache line writing incorrect data to RAM), and a consumer
589    /// reading using the CPU must invalidate CPU cache before reading (the
590    /// producer doesn't guarantee zero stale "clean" cache lines).
591    ///
592    /// In other words, if a producer participant uses the CPU to write data on
593    /// a non-cache-coherent architecture such as arm, the producer must flush
594    /// the data to RAM before indicating to another participant that the buffer
595    /// is ready. If a consumer participant uses the CPU to read data on a
596    /// non-cache-coherent architecture such as arm, the participant must
597    /// invalidate (typically flush+invalidate with knowledge that no cache
598    /// lines are dirty) the CPU cache before reading the buffer.
599    ///
600    /// RAM-only participants that don't do any CPU accesses to a buffer can
601    /// just do DMA to/from the buffers (when they should) without needing to
602    /// do any CPU cache ops.
603    pub ram_domain_supported: Option<bool>,
604    /// When true, the participant is ok with sysmem selecting the INACCESSIBLE
605    /// domain.
606    ///
607    /// If the INACCESSIBLE domain is selected, CPU reads and writes of the data
608    /// are prevented. Attempts to read/write the data with the CPU may result
609    /// in UB and/or process termination.
610    ///
611    /// If the INACCESSIBLE domain is selected, participants must only operate
612    /// on the data using DMAs performed by HW, or platform-specific DMA-like
613    /// requests to a secure environment (which will do the needed CPU cache ops
614    /// similar to how a RAM domain participant would operate).
615    ///
616    /// Secure heaps only support INACCESSIBLE domain, and will fail allocation
617    /// if any participant with `BufferUsage` other than `NONE_USAGE` does not
618    /// set inaccessible_domain_supported to true.
619    ///
620    /// When the INACCESSIBLE domain is selected, participants (outside of
621    /// secure/DRM environments) should not attempt to map buffers, and should
622    /// not attempt to perform any CPU cache ops. In this respect, this domain
623    /// is similar to RAM domain with all participants only doing DMA and no
624    /// participant(s) doing CPU accesses.
625    pub inaccessible_domain_supported: Option<bool>,
626    /// Which heaps are acceptable to the participant. Participants that don't
627    /// care which heap memory is allocated on should leave this field un-set. A
628    /// secure heap is only selected if all participants explicitly indicate
629    /// that the secure heap is acceptable via `heap_permitted`, or specify
630    /// `NONE_USAGE`.
631    pub permitted_heaps: Option<Vec<Heap>>,
632    #[doc(hidden)]
633    pub __source_breaking: fidl::marker::SourceBreaking,
634}
635
636impl fidl::Persistable for BufferMemoryConstraints {}
637
638/// These are memory-related settings for all buffers of a buffer collection.
639#[derive(Clone, Debug, Default, PartialEq)]
640pub struct BufferMemorySettings {
641    /// This field will always be set by sysmem.
642    ///
643    /// Rule for producers: For `BufferCollectionInfo` with
644    /// `ImageFormatConstraints`, storing an image of a given `ImageFormat` in a
645    /// buffer of that `BufferCollection` is only allowed if the result of
646    /// calling `ImageFormatImageSize` or a strictly equivalent computation is
647    /// less than or equal to `size_bytes`.
648    ///
649    /// Producer participants _must_ stay within `size_bytes` when determining
650    /// whether an image will fit in a buffer, even if the VMO's size is larger
651    /// than this.
652    ///
653    /// Failure of a producer to use `size_bytes` as the constraint (not VMO
654    /// size) when determining whether a given `ImageFormat` will fit in a
655    /// buffer will, in general, cause problems for any participant that has set
656    /// ImageFormatConstraints.pad_for_block_size to larger than {1, 1}, or
657    /// pad_beyond_image_size_bytes to greater than 0. Those participants rely
658    /// on the ability to access bytes in the VMO beyond the image size. Putting
659    /// an image in the VMO that exceeds `size_bytes` can potentially lead to
660    /// those participants trying to access an offset beyond the last page of
661    /// the VMO.
662    ///
663    /// Similarly, any future padding-only constraint which is irrelevant to a
664    /// non-padding participant when locating each valid pixel's valid data will
665    /// also be accounted for by checking `ImageFormatImageSize()` against
666    /// `size_bytes` instead of the VMO size.
667    ///
668    /// Following this rule allows producers to not need to worry about
669    /// arbitrary padding requirements of participants, including future-added
670    /// padding-only constraints.
671    ///
672    /// The `bytes_per_row` and rounding up to a tile size boundary are included
673    /// in `ImageFormatImageSize` and accounted for in `size_bytes`, even though
674    /// these two aspects are partially about padding. These two aspects are
675    /// included in the `ImageFormatImageSize` calculation because these two
676    /// aspects are also relevant to all participants that need to locate pixel
677    /// data. The `fuchsia.images2.ImageFormat` intentionally doesn't contain
678    /// any padding-only fields.
679    ///
680    /// Participants with a padding constraint (in addition to `bytes_per_row`
681    /// or tile size boundary), such as pad_for_block_size or
682    /// pad_beyond_image_size_bytes, are allowed to access, but not treat as
683    /// meaningful, bytes which are at offset `size_bytes` up to the max offset
684    /// implied by their own padding constraint, which will never exceed the VMO
685    /// size minus 1, as long as the `ImageFormatImageSize` is less than or
686    /// equal to `BufferMemorySettings.size_bytes` and other constraints under
687    /// `BufferCollectionInfo` aren't violated by the producer.
688    ///
689    /// The same `size_bytes` value is sent to all participants.
690    ///
691    /// This field is not page aligned. This value rounded up to
692    /// zx_system_page_size() boundary is guaranteed to be less than or equal
693    /// the buffer VMO size. In other words, the VMO can have more pages than
694    /// implied by this value, due to padding-only constraints from
695    /// participant(s).
696    pub size_bytes: Option<u64>,
697    /// This field will always be set by sysmem.
698    pub is_physically_contiguous: Option<bool>,
699    /// This field will always be set by sysmem.
700    pub is_secure: Option<bool>,
701    /// This field will always be set by sysmem.
702    pub coherency_domain: Option<CoherencyDomain>,
703    /// The specific heap from which buffers are allocated.
704    ///
705    /// This field will always be set by sysmem.
706    pub heap: Option<Heap>,
707    /// This is guaranteed to be equal to the VMO size obtained via
708    /// `zx_vmo_get_size`. This field is here because `pad_*` constraints can
709    /// result in the VMO size being larger than implied by `size_bytes`, and
710    /// for participants using `pad_*` constraints, it can be convenient to have
711    /// this field available rather than having to query for the VMO size.
712    ///
713    /// When checking with `ImageFormatImageSize` to see if an image will fit in
714    /// a buffer, use `size_bytes` as the threshold, not `raw_vmo_size`.
715    ///
716    /// Producers using `pad_*` constraints must still only put images in the
717    /// buffer which have `ImageFormatImageSize() <= size_bytes`. Participants
718    /// using `pad_*` constraints are allowed to access bytes beyond
719    /// `size_bytes` consistent with what the participant set for the pad_*
720    /// constriant(s), which will always fit within `raw_vmo_size` assuming
721    /// correct operation of the participant and sysmem. This field can be
722    /// useful for double-checking that accesses will be within the VMO.
723    ///
724    /// When setting up VMO mappings and VMO pins, a participant using `pad_*`
725    /// constraint(s) should use `raw_vmo_size` for the size of the mapping. In
726    /// contrast, a participant not using any pad_* constraint can use
727    /// `size_bytes` rounded up to a page size boundary or said participant can
728    /// use raw_vmo_size, but for that participant, using `size_bytes` rounded
729    /// up to the page size can avoid mapping a few pages.
730    pub raw_vmo_size: Option<u64>,
731    #[doc(hidden)]
732    pub __source_breaking: fidl::marker::SourceBreaking,
733}
734
735impl fidl::Persistable for BufferMemorySettings {}
736
737/// Describes how a client will access the contents of a buffer.
738#[derive(Clone, Debug, Default, PartialEq)]
739pub struct BufferUsage {
740    /// If the client sets this field, the client should not set any other
741    /// fields in the same table instance. The only valid bit in this field is
742    /// `NONE_USAGE` which must be set if this field is set. The point of this
743    /// field and the one bit set in this field is to essentially prove that the
744    /// client really means they aren't going to use the buffers, so don't need
745    /// any VMOs (didn't just fail to fill out the table).
746    pub none: Option<u32>,
747    /// If set, holds CPU usage bits. See `CPU_USAGE_*` flags in usages.fidl.
748    pub cpu: Option<u32>,
749    /// If set, holds vulkan usage bits. See `VULKAN_IMAGE_*` and
750    /// `VULKAN_BUFFER_*` bits in usages.fidl. The `VULKAN_USAGE_*` bit
751    /// definitions/names are deprecated.
752    pub vulkan: Option<u32>,
753    /// If set, holds display usage bits. See `DISPLAY_USAGE_*` bits in
754    /// usages.fidl.
755    pub display: Option<u32>,
756    /// If set, holds video usage bits. See `VIDEO_USAGE_*` bits in usages.fidl.
757    pub video: Option<u32>,
758    #[doc(hidden)]
759    pub __source_breaking: fidl::marker::SourceBreaking,
760}
761
762impl fidl::Persistable for BufferUsage {}
763
764/// This type is fidl::Persist()'ed in the sysmem_config.persistent_fidl file
765/// within the sysmem domain config by the assembly tool, and read by the sysmem
766/// driver.
767///
768/// Normally json[5] would be preferable for config, but we generate this config
769/// in rust using FIDL types (to avoid repetition and to take advantage of FIDL
770/// rust codegen), and there's no json schema for FIDL types.
771///
772/// Currently there is no mechanism to change anything in this config at runtime
773/// or from boot to boot. This config is static per run of the assembly tool.
774///
775/// See src/lib/assembly/config_schema/src/platform_config/sysmem_config.rs for
776/// aspects of sysmem config which are specified directly inline in board info
777/// or assembly platform config. The two parts of sysmem config don't
778/// (currently) overlap. The config here is for aspects of sysmem config which
779/// would be too verbose for direct inclusion in board info or assembly platform
780/// config. In addition, some/most of the pixel format cost entries are
781/// programmatically generated (as of this comment).
782///
783/// Prior to aggregation by assembly tool, there are multiple .persistent_fidl
784/// files each storing its own Config instance. The board info and assembly
785/// platform config lists the input persistent_fidl files, with board info
786/// logically before assembly platform config. The overall list of files is
787/// processed, which allows later files to override/replace info in prior files.
788///
789/// Because this type is only intended for use with persistent fidl, where the
790/// length of a serialized instance isn't bounded, we don't bound the internal
791/// vector element counts.
792#[derive(Clone, Debug, Default, PartialEq)]
793pub struct Config {
794    /// This is the ordered list of FormatCost entries which will be considered
795    /// by sysmem when breaking ties among formats supported by all participants
796    /// of a buffer collection.
797    ///
798    /// During config aggregation, if a later entry has matching FormatCostKey,
799    /// the earlier entry is omitted/removed. This allows later files to
800    /// override entries in earlier files, and allows files specified in
801    /// assembly platform config to override entries in files specified in the
802    /// board info.
803    ///
804    /// This vector will normally not have any two entries with matching
805    /// pixel_format, pixel_format_modifier, and buffer_usage_bits in the Config
806    /// instance loaded from sysmem_config.persistent_fidl by sysmem. If somehow
807    /// two entries do match in those fields, sysmem can ignore all but one of
808    /// the entries chosen arbitrarily.
809    pub format_costs: Option<Vec<FormatCostEntry>>,
810    #[doc(hidden)]
811    pub __source_breaking: fidl::marker::SourceBreaking,
812}
813
814impl fidl::Persistable for Config {}
815
816#[derive(Clone, Debug, Default, PartialEq)]
817pub struct DynamicSecureHeap {
818    pub heap: Option<Heap>,
819    #[doc(hidden)]
820    pub __source_breaking: fidl::marker::SourceBreaking,
821}
822
823impl fidl::Persistable for DynamicSecureHeap {}
824
825/// A FormatCostEntry can be used to influence which PixelFormatAndModifier is
826/// chosen for a buffer collection, optionally taking BufferUsage into account.
827///
828/// The default cost is f32::MAX, so any specified cost with a non-MAX value
829/// will prefer the specified format over any formats that don't have any
830/// FormatCost entry.
831///
832/// Entries which have the same pixel_format, pixel_format_modifier, and
833/// required_usage_bits as a previous entry will override that previous entry.
834/// For matching purposes, an absent pixel_format_modifier matches LINEAR, and
835/// an absent required_buffer_usage_bits matches all-0 usage bits.
836///
837/// Board info sysmem_defaults entries are logically before platform sysmem
838/// entries.
839///
840/// Sysmem uses the resulting aggregated list of FormatCostEntry(s) when
841/// breaking ties among the set of formats which are supported by all
842/// participants of a buffer collection. For each mutually-supported format,
843/// entries with non-matching format are ignored, and entries with extra
844/// buffer_usage_bits set are ignored. Among the remaining entries, the entry
845/// with the most usage bits in common with the aggregated participant usages is
846/// selected to determine the cost (if a tie, the later entry wins). Then the
847/// format with the lowest cost is chosen. If it's still a tie (equal cost), the
848/// tie is broken arbitrarily but not randomly.
849///
850/// This is not intended as a mechanism to disallow selection of a format that
851/// is supported by all participants of a buffer collection. If a participant
852/// claims support for a format but fails to handle that format correctly, it
853/// should be fixed to handle that format correctly or changed to stop claiming
854/// support for that format.
855///
856/// This mechanism is intended to influence format selection toward more
857/// efficient formats with better performance, lower memory bandwidth usage,
858/// etc, for a given set of usage bits, taking into account quirks that may be
859/// unique to a given board or overall platform config.
860#[derive(Clone, Debug, Default, PartialEq)]
861pub struct FormatCostEntry {
862    /// Must be set. If two entries have logically equal key (after field
863    /// defaults are applied), the later entry will override the earlier entry.
864    pub key: Option<FormatCostKey>,
865    /// Must be set. Lower costs win, but see also FormatCostKey fields re.
866    /// filtering entries by format and usage bits first.
867    ///
868    /// When two entries (each with format supported by all the participants of
869    /// a buffer collection) have different costs, the lower cost entry (and its
870    /// format) is chosen.
871    ///
872    /// For non-test scenarios, only use cost values > 0.0 (typically at least
873    /// 1.0 as of this comment), with 0.0 and negative values reserved for
874    /// testing.
875    pub cost: Option<f32>,
876    #[doc(hidden)]
877    pub __source_breaking: fidl::marker::SourceBreaking,
878}
879
880impl fidl::Persistable for FormatCostEntry {}
881
882/// Entries which have the same pixel_format, pixel_format_modifier, and
883/// required_usage_bits as a previous entry will override that previous entry.
884/// For matching purposes, an absent pixel_format_modifier matches LINEAR, and
885/// an absent required_buffer_usage_bits matches all-0 usage bits.
886#[derive(Clone, Debug, Default, PartialEq)]
887pub struct FormatCostKey {
888    /// The pixel_format and pixel_format_modifier are the format to which this
889    /// FormatCost entry applies.
890    ///
891    /// Must be set.
892    pub pixel_format: Option<fidl_fuchsia_images2__common::PixelFormat>,
893    /// The pixel_format and pixel_format_modifier are the format to which this
894    /// FormatCost entry applies.
895    ///
896    /// Un-set is equivalent to LINEAR.
897    pub pixel_format_modifier: Option<fidl_fuchsia_images2__common::PixelFormatModifier>,
898    /// If set, this entry is only considered if the buffer collection has at
899    /// least these usage bits set.
900    ///
901    /// The buffer collection has an aggregated BufferUsage which is the union
902    /// of per-participant BufferUsage bits. FormatCost entries with additional
903    /// set bits are ignored. Among the rest, the one with matching format and
904    /// the most usage bits set determines the cost of that format for that
905    /// buffer collection.
906    ///
907    /// Then the lowest-cost format is chosen for that buffer collection among
908    /// the formats that are mutually suppored by all the participants of that
909    /// buffer collection.
910    ///
911    /// The main intent of this field is to allow "waving off" a format that
912    /// works, but doesn't perform well, for a particular combination of usages.
913    /// In that case the cost can be set high when the problematic combination
914    /// of usage bits is set. The format will still be chosen if this format is
915    /// the only mutually-supported format among the participants of the buffer
916    /// collection.
917    ///
918    /// Un-set is equivalent to zero usage bits set, meaning the entry applies
919    /// to the format unless another entry with more specific usage applies.
920    ///
921    /// It can be reasonable in some cases for all entries to omit this field,
922    /// when/if format selection based on format cost alone, ignoring usage, is
923    /// sufficient.
924    pub buffer_usage_bits: Option<BufferUsage>,
925    #[doc(hidden)]
926    pub __source_breaking: fidl::marker::SourceBreaking,
927}
928
929impl fidl::Persistable for FormatCostKey {}
930
931/// This is the root of the persistent fidl in a format costs file. The format
932/// costs files are read by the assembly tool and merged into the single
933/// sysmem_config.persistent_fidl file in the sysmem domain config (see Config
934/// above).
935///
936/// Normally json[5] would be preferable for config, but we generate this config
937/// in rust using FIDL types (to avoid repetition and to take advantage of FIDL
938/// rust codegen), and there's no json schema for FIDL types.
939///
940/// While the resulting sysmem_config.persistent_fidl is a single file that can
941/// contain multiple aspects of sysmem config, in contrast a format costs file
942/// contains only format costs. We don't mind having more separate files during
943/// the build, but it's nice to get sysmem's domain config down to a single file
944/// on-device.
945#[derive(Clone, Debug, Default, PartialEq)]
946pub struct FormatCosts {
947    /// This is a chunk of entries that'll end up in
948    /// ['fuchsia.sysmem2.Config.format_costs'] (see above) unless overriden by
949    /// later entries (either in this same vector or in later-processed files
950    /// during aggregation by the assembly tool).
951    pub format_costs: Option<Vec<FormatCostEntry>>,
952    #[doc(hidden)]
953    pub __source_breaking: fidl::marker::SourceBreaking,
954}
955
956impl fidl::Persistable for FormatCosts {}
957
958/// A reference to a heap instance.
959///
960/// A given heap instance can have more than one `Heap` which can be used to
961/// refer to the heap instance. Comparing `Heap` tables without knowledge of
962/// these `Heap` aliases is not a reliable way to determine if two `Heap` tables
963/// refer to the same heap (matching means yes, but not matching means maybe).
964/// Allowing heap aliases makes renaming `Heap.type`(s) easier.
965#[derive(Clone, Debug, Default, PartialEq)]
966pub struct Heap {
967    /// The type of the heap, specified using a bind string defined per the
968    /// schema and mechanism described in comments in the
969    /// fuchsia.sysmem.heap.bind file.
970    ///
971    /// Examples:
972    /// * "fuchsia.sysmem.heap.HEAP_TYPE.SYSTEM_RAM"
973    /// * "fuchsia.goldfish.platform.sysmem.heap.HEAP_TYPE.HOST_VISIBLE"
974    pub heap_type: Option<String>,
975    /// The uint64 id of the heap. This is only required to be unique per (type,
976    /// boot) tuple. In other words, a given heap id is only meaningful within
977    /// the current boot of the machine (not across boots), and only within the
978    /// `Heap.type`.
979    ///
980    /// For `Heap.type`(s) that refer to a singleton heap, a participant
981    /// specifying the singleton heap in
982    /// [`fuchsia.sysmem2.BufferMemoryConstraints.permitted_heaps`] can leave
983    /// this field un-set, or set it to zero. Sysmem will always fill out this
984    /// field for the heap indicated in
985    /// [`fuchsia.sysmem2.BufferMemorySettings.heap`] (for a singleton heap the
986    /// `id` field will be set to 0 by sysmem).
987    pub id: Option<u64>,
988    #[doc(hidden)]
989    pub __source_breaking: fidl::marker::SourceBreaking,
990}
991
992impl fidl::Persistable for Heap {}
993
994/// Describes constraints on layout of image data in buffers.
995#[derive(Clone, Debug, Default, PartialEq)]
996pub struct ImageFormatConstraints {
997    /// The [`fuchsia.images2/PixelFormat`] for which the following constraints
998    /// apply.
999    ///
1000    /// The `pixel_format` and `pixel_format_modifier` fields together are
1001    /// treated by the server as one additional `pixel_format_and_modifiers`
1002    /// entry.
1003    ///
1004    /// A participant may have more than one
1005    /// [`fuchsia.sysmem2/PixelFormatAndModifier`] that's supported.
1006    ///
1007    /// * If image constraints are the same for different
1008    ///   `PixelFormatAndModifier`s, the participant may list additional
1009    ///   `PixelFormatAndModifier`s for which the constraints apply in the
1010    ///   `pixel_format_and_modifiers` field. This reduces the overall number of
1011    ///   `ImageFormatConstraints` that need to be sent, without changing the
1012    ///   meaning (vs for example sending a bunch of separate
1013    ///   `ImageFormatConstraints` that only differ by the `pixel_format` and
1014    ///   `pixel_format_modifier` which overall specify the same list of
1015    ///   `PixelFormatAndModifier`s).
1016    /// * If image constraints differ for different `PixelFormatAndModifier`s,
1017    ///   the participant can convey this using a separate
1018    ///   `ImageFormatConstraints` entry in `image_format_constraints` for each
1019    ///   set of `PixelFormatAndModifier`s that have different image
1020    ///   constraints.
1021    /// * It's ok for a participant to have two `image_format_constraints`
1022    ///   entries that only differ in their pixel_format_and_modifiers, but this
1023    ///   is isn't the most compact way to represent that situation since the
1024    ///   two entries could be combined by specifying two
1025    ///   `PixelFormatAndModifier`s within a single `ImageFormatConstraints`.
1026    ///
1027    /// It's not uncommon for the other fields of `ImageFormatConstraints` to
1028    /// vary by `pixel_format` or by `pixel_format_modifier` - for example for a
1029    /// linear format to support smaller max size than a tiled format.
1030    ///
1031    /// See also
1032    /// [`fuchsia.sysmem2/ImageFormatConstraints.pixel_format_and_modifiers`].
1033    ///
1034    /// Thie field must be set to a value other than
1035    /// [`fuchsia.images2/PixelFormat.INVALID`] unless
1036    /// `pixel_format_and_modifiers` is non-empty. In other words, there must be
1037    /// at least one `PixelFormatAndModifier` per `ImageFormatConstraints`. If
1038    /// `pixel_format_modifier` is set, this field must also be set.
1039    ///
1040    /// The participant can specify [`fuchsia.images2/PixelFormat.DO_NOT_CARE`]
1041    /// if the participant needs to specify `ImageFormatConstraints` without
1042    /// constraining the `pixel_format`.
1043    pub pixel_format: Option<fidl_fuchsia_images2__common::PixelFormat>,
1044    /// The pixel format modifier for which the following constraints apply.
1045    ///
1046    /// The `pixel_format` and `pixel_format_modifier` fields together are
1047    /// treated by the server as one additional `pixel_format_and_modifiers`
1048    /// entry.
1049    ///
1050    /// This is a [`fuchsia.images2/PixelFormatModifier`] that's acceptable to
1051    /// the participant in combination with the `pixel_format`.
1052    ///
1053    /// See also `pixel_format_and_modifiers`.
1054    ///
1055    /// If `pixel_format` is set but `pixel_format_modifier` is un-set, the
1056    /// default depends on other fields:
1057    ///
1058    /// * If `pixel_format` is [`fuchsia.images2/PixelFormat.DO_NOT_CARE`], the
1059    ///   pixel format modifier is implicitly
1060    ///   [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`].
1061    /// * else if `BufferCollectionConstraints.usage` isn't `NONE`, the pixel
1062    ///   format modifier is implicitly
1063    ///   [`fuchsia.images2/PixelFormatModifier.LINEAR`].
1064    /// * else the pixel format modifier is implicitly
1065    ///   [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`].
1066    pub pixel_format_modifier: Option<fidl_fuchsia_images2__common::PixelFormatModifier>,
1067    /// Empty is an error. Duplicate entries are an error. Arbitrary ordering is
1068    /// not an error.
1069    ///
1070    /// The client can specify a single entry
1071    /// [`fuchsia.sysmem2/ColorSpace.DO_NOT_CARE`] if the client doesn't want to
1072    /// constrain which `ColorSpace` is chosen. At least one participant must
1073    /// specify at least one `ColorSpace` value other than
1074    /// `ColorSpace.DO_NOT_CARE`, or allocation will fail.
1075    pub color_spaces: Option<Vec<fidl_fuchsia_images2__common::ColorSpace>>,
1076    /// Minimum permitted size in pixels.
1077    ///
1078    /// For example a video decoder participant may set this field to the
1079    /// minimum size that might potentially be specified by a stream. In
1080    /// contrast, `required_min_size` would be set to the current size specified
1081    /// by the stream. While `min_size` aggregates by taking the max,
1082    /// `required_min_size` aggregates by taking the min.
1083    ///
1084    /// When sending to sysmem, this field can be un-set if the participant is
1085    /// prepared to deal with the smallest possible non-zero image layout
1086    /// limited only by the constraints implicitly imposed by the `pixel_format`
1087    /// and `pixel_format_modifier`. Or this field can be set to the actual
1088    /// minimum size the participant can handle.
1089    ///
1090    /// Producers should set `min_size` and set both width and height to the
1091    /// actual non-zero smallest width and height that the producer might
1092    /// generate. For example, a video decoder can set the size of a single
1093    /// macroblock here.
1094    ///
1095    /// When receiving from sysmem, this field will always be set, and neither
1096    /// width nor height will be 0, because at least one participant must
1097    /// specify a non-zero minimum size (where both width and height aren't
1098    /// zero).
1099    ///
1100    /// See also `required_min_size`.
1101    pub min_size: Option<fidl_fuchsia_math__common::SizeU>,
1102    /// Maximum size in pixels. For example Scenic may set this field (directly
1103    /// or via sub-participants) to the maximum size that can be composited.
1104    ///
1105    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF, 0xFFFFFFFF.
1106    ///
1107    /// Receiving from sysmem, this field will always be set. For width and
1108    /// height separately, if there is no enforced max, that sub-field will be
1109    /// 0xFFFFFFFF.
1110    ///
1111    /// See also `required_max_size`.
1112    pub max_size: Option<fidl_fuchsia_math__common::SizeU>,
1113    /// The minimum number of bytes per row, including any padding beyond the
1114    /// last image data in a row.
1115    ///
1116    /// This is sometimes called the "stride in bytes" or the "line to line
1117    /// offset". For single-plane formats, this is the number of bytes per row
1118    /// of pixels. For multi-plane formats, this is the number of bytes per row
1119    /// of samples in plane 0 (for example, the number of bytes per row of luma
1120    /// samples in the case of a multi-plane YUV format). For multi-plane
1121    /// formats, the bytes per row in planes other than plane 0 is format
1122    /// specific, but always a specific relationship to the plane 0 bytes per
1123    /// row.
1124    ///
1125    /// When sending `ImageFormatConstraints` to sysmem, setting this field is
1126    /// optional. Not setting this field is recommended unless the participant
1127    /// needs to force the `bytes_per_row` to be larger than the minimum value
1128    /// implied by `min_size.width`, the "stride bytes per width pixel" of the
1129    /// `pixel_format` plus `pixel_format_modifier` (see also
1130    /// `ImageFormatStrideBytesPerWidthPixel`), and `bytes_per_row_divisor`.
1131    ///
1132    /// When this structure is received from sysmem, this field will always be
1133    /// set (when the parent structure is present), and will always be at least
1134    /// the value implied by `min_size.width`, the "stride bytes per width
1135    /// pixel" of the `pixel_format` plus `pixel_format_modifier`, and
1136    /// `bytes_per_row_divisor`.
1137    ///
1138    /// Some producer participants may prefer to simply set
1139    /// `ImageFormat.bytes_per_row` to
1140    /// `ImageFormatConstraints.min_bytes_per_row` since sysmem is guaranteeing
1141    /// that `min_bytes_per_row` is compatible with an image of width
1142    /// `min_size.width`. However, producer participants that need to have
1143    /// `size.width` > `min_size.width` can get a corresponding
1144    /// `min_bytes_per_row` from `ImageFormatMinimumRowBytes` (in C++), or can
1145    /// just calculate the `bytes_per_row` directly.
1146    pub min_bytes_per_row: Option<u32>,
1147    /// The maximum number of bytes per row, including any padding beyond the
1148    /// last image data in a row.
1149    ///
1150    /// When sent to sysmem, must be >= the value implied by `max_size.width`,
1151    /// "stride bytes per width pixel", and `bytes_per_row_divisor`, or
1152    /// constraints aggregation will fail. Un-set means the participant doesn't
1153    /// need/want to set a strict max.
1154    ///
1155    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF.
1156    ///
1157    /// When received from sysmem, this field will always be set. If the max is
1158    /// effectively infinite, the value will be 0xFFFFFFFF (not zero).
1159    pub max_bytes_per_row: Option<u32>,
1160    /// The maximum number of pixels.
1161    ///
1162    /// The max image area in pixels is limited indirectly via
1163    /// [`fuchsia.sysmem/BufferMemoryConstraints.max_size_bytes`] and the
1164    /// resulting [`fuchsia.sysmem/BufferSettings.size_bytes`], and can also be
1165    /// enforced directly via this field.
1166    ///
1167    /// In contrast to the [`fuchsia.sysmem2/ImageFormatConstraints.max_size`]
1168    /// field which limits width and height separately, this field limits the
1169    /// total number of pixels.
1170    ///
1171    /// In contrast to
1172    /// [`fuchsia.sysmem/BufferMemoryConstraints.max_size_bytes`], this field
1173    /// doesn't limit the number of non-pixel padding bytes after each row of
1174    /// pixels, and doesn't limit the number of non-pixel bytes in the case of
1175    /// tiled `pixel_format_modifier`.
1176    ///
1177    /// Very narrow or very short image aspect ratios can have worse performance
1178    /// per pixel in comparison to more typical aspect ratios. Padding and/or
1179    /// memory bandwidth overheads tend to increase for extreme aspect ratios.
1180    /// Participants can indicate lack of support for very narrow or very short
1181    /// dimensions using ['fuchsia.sysmem/ImageFormatConstraints.min_size`].
1182    ///
1183    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF.
1184    ///
1185    /// Receiving from sysmem, this field will always be set, and can be set to
1186    /// 0xFFFFFFFF.
1187    pub max_width_times_height: Option<u64>,
1188    /// Alignment requirements on the image `size`.
1189    ///
1190    /// * `size.width % size_alignment.width` must be 0.
1191    /// * `size.height % size_alignment.height` must be 0.
1192    ///
1193    /// Both `size_alignment.width` and `size_alignment.height` must be non-zero
1194    /// and a power of 2.
1195    ///
1196    /// Un-set is treated as 1, 1.
1197    pub size_alignment: Option<fidl_fuchsia_math__common::SizeU>,
1198    /// Alignment requirements on `display_rect`.
1199    ///
1200    /// * `display_rect.x % display_rect_alignment.width` must be 0.
1201    /// * `display_rect.y % display_rect_alignment.height` must be 0.
1202    /// * `display_rect.width % display_rect_alignment.width` must be 0.
1203    /// * `display_rect.height % display_rect_alignment.height` must be 0.
1204    ///
1205    /// Un-set is treated as 1, 1.
1206    pub display_rect_alignment: Option<fidl_fuchsia_math__common::SizeU>,
1207    /// These fields can be used to ensure the aggregated constraints have
1208    /// `min_size` and `max_size` such that both `required_min_size` and
1209    /// `required_max_size` (and anything in between that satisfies alignment
1210    /// requirements) are permitted values of `ImageFormat.size`.
1211    ///
1212    /// For example, a producer video decoder doesn't want to constrain the
1213    /// allowed `ImageFormat.size`, as a compressed stream can change dimensions
1214    /// mid-stream, but the producer video decoder needs to ensure that the
1215    /// aggregated constraints allow for at least the current dimensions of
1216    /// uncompressed frames at the current position in the stream.
1217    ///
1218    /// As another example, an initiator that's intending to decode video may
1219    /// know what the maximum expected size of frames in the stream(s) can be,
1220    /// so by setting `required_max_size`, can ensure that the allocated buffers
1221    /// are large enough to support that max `size`. In addition on successful
1222    /// allocation the initiator also knows that the consumer participants are
1223    /// ok with receiving up to that max `size`.
1224    ///
1225    /// It's much more common for a producer or initiator to set these fields
1226    /// than for a consumer to set these fields.
1227    ///
1228    /// While `min_size` and `max_size` aggregate by effectively taking the
1229    /// intersection, the `required_min_size` and `required_max_size` aggregate
1230    /// by effectively taking the union.
1231    ///
1232    /// This field aggregates by taking the min per component, and
1233    /// required_max_size aggregates by taking the max per component. In
1234    /// addition the aggregated required_max_size is included in the aggregated
1235    /// required_max_size_list.
1236    ///
1237    /// Un-set is treated as 0xFFFFFFFF, 0xFFFFFFFF.
1238    pub required_min_size: Option<fidl_fuchsia_math__common::SizeU>,
1239    /// This field is deprecated. The replacement is required_max_size_list.
1240    ///
1241    /// See also `required_min_size` and `required_max_size_list`. Un-set is
1242    /// treated as 0, 0.
1243    ///
1244    /// In the BufferCollectionInfo returned from sysmem, this field has the max
1245    /// across all participants' required_max_size fields, for width and height
1246    /// separately. In addition, the allocated buffer is large enough to store
1247    /// an image that is this max-of-all-widths by max-of-all-heights. This has
1248    /// the potential to allocate buffers that are larger than necessary, for
1249    /// example if the participant is trying to make sure the buffer can store
1250    /// both landscape and portrait images. In contrast, required_max_size_list
1251    /// allows listing those separately so they can be handled better by the
1252    /// server. See required_max_size_list and please switch to that field.
1253    ///
1254    /// When this field is set, the provided size is aggregated by taking max of
1255    /// across all participants' required_max_size fields, and that aggregated
1256    /// result is put in this field in the BufferCollectionInfo from the server,
1257    /// and is also treated as an additional item in the aggregated
1258    /// required_max_size_list (even if that field is not set by any client).
1259    /// See required_max_size_list. This behavior is for maintaining backward
1260    /// compatibility for clients using required_max_size before it was
1261    /// deprecated, and for overall compatibility with required_max_size_list,
1262    /// but this behavior is itself deprecated as well. Please switch to only
1263    /// using required_max_size_list.
1264    ///
1265    /// Please don't add additional usages of this field.
1266    pub required_max_size: Option<fidl_fuchsia_math__common::SizeU>,
1267    /// `fuchsia_images2.ImageFormat.bytes_per_row % bytes_per_row_divisor` must
1268    /// be 0. Un-set is treated as 1.
1269    ///
1270    /// Prefer to use `require_bytes_per_row_at_pixel_boundary` when the intent
1271    /// is to ensure that `bytes_per_row' will be a multiple of the pixel size
1272    /// in bytes.
1273    ///
1274    /// Prefer to use `size_alignment.width` when the intent is to ensure that
1275    /// the width in pixels is aligned. In contrast, this field can specify that
1276    /// the "stride in bytes" (byte offset from start of image to start of row n
1277    /// minus byte offset from start of image to start of row n-1, with result
1278    /// in bytes) needs to be aligned to the specified number of bytes. For
1279    /// example, when `PixelFormat.BGR24` (24 bit color; 3 bytes per pixel) is
1280    /// used, it's not uncommon for a participant to need each row of pixels to
1281    /// start at a 4 byte aligned offset from the start of the image, which can
1282    /// imply some padding bytes at the end of each row of pixels, before the
1283    /// start of the next row of pixels.
1284    ///
1285    /// While any value of `bytes_per_row_divisor` could instead be enforced by
1286    /// setting `size_alignment.width` to the least-common-multiple of the
1287    /// "stride bytes per width pixel" and the stride alignment requirement,
1288    /// enforcing the stride alignment requirement that way can lead to more
1289    /// padding than necessary (implying larger buffer than necessary), and can
1290    /// also result in a "fake" `size.width` values that other participants
1291    /// would need to care about; this field exists to avoid that situation.
1292    /// Instead, the stride alignment requirement in bytes is specified directly
1293    /// here.
1294    pub bytes_per_row_divisor: Option<u32>,
1295    /// `vmo_usable_start % start_offset_divisor` must be 0. Un-set is treated
1296    /// as 1.
1297    ///
1298    /// Producer participants are discouraged from setting non-zero image start
1299    /// offset (from the buffer base) unless actually required, as not all
1300    /// participants correctly handle non-zero image start offset.
1301    pub start_offset_divisor: Option<u32>,
1302    /// The (additional) [`fuchsia.sysmem2/PixelFormatAndModifier`]s for which
1303    /// the following constraints apply.
1304    ///
1305    /// As a non-limiting example, if a participant only wants to set a single
1306    /// `PixelFormatAndModifier` for this
1307    /// [`fuchsia.sysmem2/ImageFormatConstraints`], the participant can either
1308    /// (a) use `pixel_format` and `pixel_format_modifier` fields to specify the
1309    /// fields of the one `PixelFormatAndModifier` and leave
1310    /// `pixel_format_and_modifiers` un-set, or (b) leave `pixel_format` and
1311    /// `pixel_format_modifier` fields un-set and put the one
1312    /// `PixelFormatAndModifier` in `pixel_format_and_modifiers`.
1313    ///
1314    /// If `pixel_format` is set, the server will take pixel_format and
1315    /// pixel_format_modifier fields (un-setting them in the process), pack them
1316    /// into a `PixelFormatAndModifier`, and move it into this vector as one
1317    /// additional entry, with an overall size limit of
1318    /// `MAX_COUNT_PIXEL_FORMAT_AND_MODIFIERS + 1`.
1319    ///
1320    /// After the server moves `pixel_format`, `pixel_format_modifier` into one
1321    /// additional entry in this vector, this vector must not be empty. When the
1322    /// resulting list has more than 1 item, the entries in this vector are
1323    /// equivalent to (shorthand for) listing (size) separate
1324    /// `ImageFormatConstraints` entries, one per `pixel_format_and_modifiers`
1325    /// entry, each with one `PixelFormatAndModifier`, where all the separate
1326    /// `ImageFormatConstraints` entries have the same constraints (compared
1327    /// field by field, not including `pixel_format`, `pixel_format_modifier`,
1328    /// or `pixel_format_and_modifiers` fields).
1329    ///
1330    /// In `SetConstraints` message, each entry specifies a
1331    /// `PixelFormatAndModifier` which is acceptable to the participant
1332    /// (assuming the following constraints fields are also satisfied).
1333    ///
1334    /// In the response to `WaitForAllBuffersAllocated`, this field will be
1335    /// un-set and the one chosen `PixelFormatAndModifier` will be indicated
1336    /// using the `pixel_format` and `pixel_format_modifier` fields.
1337    ///
1338    /// All the `PixelFormatAndModifiers` in a `SetConstraints` message from a
1339    /// participant must be unique across all the entries under
1340    /// `image_format_constraints`. If
1341    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] is used in an entry, there
1342    /// must not be any other entry (considering all the entries under
1343    /// `image_format_constraints`) with matching `pixel_format_modifier`. If
1344    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] is used, there must
1345    /// not be any other entry (considering all the entries under
1346    /// `image_format_constraints`) with matching `pixel_format`.
1347    ///
1348    /// A `PixelFormatAndModifier` value with either
1349    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] or
1350    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] (but not both, for
1351    /// purposes of this example) can be combined with a
1352    /// `PixelFormatAndModifier` from a separate participant with the other
1353    /// field indicating "do not care", resulting in a complete
1354    /// `PixelFormatAndModifier` that can succeed allocation. However, at least
1355    /// for now, it's not permitted for a single participant to specify two
1356    /// separate `PixelFormatAndModifier` values which have "do not care" in
1357    /// different fields. This does not prohibit a single
1358    /// `PixelFormatAndModifier` with both `PixelFormat.DO_NOT_CARE` and
1359    /// `PixelFormatModifier.DO_NOT_CARE` (which is only a single
1360    /// `PixelFormatAndModifier` value). If a client really needs to specify
1361    /// some constraints relevant to `pixel_format`(s) with
1362    /// `pixel_format_modifier` `DO_NOT_CARE`, and other constraints relevant to
1363    /// `pixel_format_modifier`(s) with `pixel_format` `DO_NOT_CARE`, the client
1364    /// can do so by duplicating the token and using/driving two separate
1365    /// participants.
1366    ///
1367    /// See also `pixel_format` for more comments relevant to multiple
1368    /// `PixelFormatAndModifier`s in a single `ImageFormatConstraints`.
1369    pub pixel_format_and_modifiers: Option<Vec<PixelFormatAndModifier>>,
1370    /// Iff set and true, bytes_per_row_divisor in the resulting
1371    /// ImageFormatConstraints is guaranteed to be a value which requires
1372    /// bytes_per_row to be an integral number of pixels. This can result in
1373    /// more padding at the end of each row than when this field is not set to
1374    /// true, but ensures that the stride can be expressed as an integral number
1375    /// of pixels.
1376    ///
1377    /// For example, if the chosen `PixelFormat` is `B8G8R8`, if this field is
1378    /// set to true, the resulting bytes_per_row_divisor will be a multiple of
1379    /// 3. In this example, if another participant sets `bytes_per_row_divisor`
1380    /// to 4, the resulting `bytes_per_row_divisor` will be a multiple of 12.
1381    pub require_bytes_per_row_at_pixel_boundary: Option<bool>,
1382    /// If unset, any A channel of any format in this ImageFormatConstraints is
1383    /// is ignored or not ignored according to semantics conveyed out of band.
1384    ///
1385    /// If set to false, the A channel of any format in this
1386    /// ImageFormatConstraints is arbitrary values that don't mean anything.
1387    /// Producers don't need to ensure any particular values in the A channel
1388    /// and consumers should ignore the A channel. This is the same thing as
1389    /// calling the 'A' channel 'X' instead.
1390    ///
1391    /// If set to true, the A channel of any format in this
1392    /// ImageFormatConstraints is set to meaningful values. A producer should
1393    /// fill out the A values, and a consumer should pay attention to the A
1394    /// values as appropriate.
1395    ///
1396    /// If set values of this field don't match for the same pixel format and
1397    /// modifier, that format and modifier will be eliminated from
1398    /// consideration.
1399    ///
1400    /// A participant that knows that the semantics of the A channel are
1401    /// conveyed via out of band means can leave this field un-set, even if the
1402    /// out of band means is already known to specify alpha present or not
1403    /// present, but in this situation it's also ok to fill out this field for
1404    /// informational / debugging purposes.
1405    ///
1406    /// If no participant sets this field, the default is un-set.
1407    ///
1408    /// If the format chosen for allocation doesn't have an A channel, this
1409    /// field will be un-set in the allocation result.
1410    pub is_alpha_present: Option<bool>,
1411    /// If an entry in this list has width or height greater than max_size width
1412    /// or height respectively (evaluated both before and again after
1413    /// aggregation), allocation will fail.
1414    ///
1415    /// This field aggregates by appending the entries to an overall list, or in
1416    /// other words, this field does not aggregate; all entries from all
1417    /// participants must be satisfied by the allocated buffer(s) or the
1418    /// allocation will fail. This lack of aggregation is to avoid
1419    /// larger-than-necessary buffers if one participant specifies a large width
1420    /// and small height and another participant specifies a small width and
1421    /// large height, or more likely, if a single participant specifies those
1422    /// two entries (for example). In that case, the buffer's
1423    /// `BufferMemorySettings.size_bytes` needs to be large enough to store the
1424    /// larger (in bytes) of the specified sizes (given available ranges of
1425    /// other ImageFormatConstraints), but not the max width and max height
1426    /// across all specified sizes used as the width and height of a single
1427    /// image.
1428    ///
1429    /// Under the resulting `BufferCollectionInfo`, `max_size` is the max
1430    /// allowed value for each dimension separately, but this does not imply
1431    /// that an image of max_size can fit in the buffer (typically won't). In
1432    /// contrast, any image that's no bigger than an entry in the returned
1433    /// `required_max_size_list` will fit in the buffer. The returned list will
1434    /// have redundant entries removed, so a client's entry may not be present
1435    /// if another entry covers the client's entry; this also removes any
1436    /// duplicates. The correct way to check if an image will fit is to check
1437    /// that `ImageFormatImageSize()` is less than or equal to
1438    /// `BufferMemorySettings.size_bytes`.
1439    ///
1440    /// Until `required_max_size` is removed, the returned
1441    /// `required_max_size_list` will, if any participants specified
1442    /// `required_max_size`, ensure that the aggregated (using max width and max
1443    /// height) `required_max_size` will fit in the allocated buffer. This does
1444    /// not imply that there will necessarily be an entry that indicates this
1445    /// specific aggregated `required_max_size`, as that entry can be removed if
1446    /// it's covered by another entry.
1447    ///
1448    /// In contrast to `max_size`, an entry can be added to
1449    /// `required_max_size_list` to ensure the buffer actually has the capacity
1450    /// to store an image that has both width and height less than or equal to
1451    /// the entry's width and height respectively. See
1452    /// `BufferMemorySettings.size_bytes` for more on what "capacity" means
1453    /// here.
1454    ///
1455    /// A typical usage of more than one entry in this list would be specifying
1456    /// that each buffer needs to be able to store up to a given portrait size
1457    /// and also up to a given landscape size. In general, more than one entry
1458    /// makes sense if the participant needs to ensure that the buffer can be
1459    /// used to store images of a few different aspect ratios at up to the
1460    /// listed size per aspect ratio. In the response from the server, redundant
1461    /// entries are removed.
1462    pub required_max_size_list: Option<Vec<fidl_fuchsia_math__common::SizeU>>,
1463    /// `pad_for_block_size` ensures that a participant will be able to access
1464    /// pixel data in blocks of the specified size, even for the lower right
1465    /// pixel whose access block can extend beyond that pixel, sometimes
1466    /// requiring more page(s) in the VMO to avoid access fault or out-of-bounds
1467    /// DMA. The extra "pixel" data of blocks on the right and bottom will not
1468    /// overlap with any other pixel (or "pixel") data.
1469    ///
1470    /// At least for now this field is only accepted for linear single-plane
1471    /// formats. This corresponds to `PixelFormatModifier.Linear` and
1472    /// `ImageFormatPlaneByteOffset` returning false when plane is 1.
1473    ///
1474    /// This field being set is not accepted if the ImageFormatConstraints has
1475    /// PixelFormat.DO_NOT_CARE or PixelFormatModifier.DO_NOT_CARE.
1476    ///
1477    /// For linear single-plane formats, we don't need to force size_alignment
1478    /// to be the access block size, as (a) there's no intent by any participant
1479    /// to actually store more (valid) pixels in the buffer, and (b) no other
1480    /// non-block-accessing participant needs to know about block access by a
1481    /// different participant to correctly locate the data of any pixel. The
1482    /// accesses by the block-accessing participant just need to remain within
1483    /// the VMO, so that all accesses remain within the VMO's pages.
1484    ///
1485    /// This field ensures the VMO size is sufficient to store the lower right
1486    /// "pixel" of the lower right block, but by design, that "pixel" data is
1487    /// not necessarily within `BufferMemorySettings.size_bytes`. Participants
1488    /// specifying `pad_for_block_size` are allowed to access beyond
1489    /// `BufferMemorySettings.size_bytes`. Block access per `pad_for_block_size`
1490    /// will automatically be within the VMO sze (but participants may check as
1491    /// well of course).
1492    ///
1493    /// For a motivating example, see the top of pad_for_block_size_test.cc.
1494    ///
1495    /// If setting `pad_for_block_size.height` to a value greater than 1, the
1496    /// same participant must (enforced) set a `max_size.width` less than
1497    /// 0xFFFFFFFF (preferably no more than a small multiple of the expected
1498    /// actual max width). This helps in controlling the space overhead incurred
1499    /// by the participant's use of blocks. If not burdensome, any of the
1500    /// following can also help:
1501    ///   * `min_size.height` - any participant setting a value greater than 1
1502    ///   * `size_alignment.height` - any participant setting to a value greater
1503    ///     than 1
1504    pub pad_for_block_size: Option<fidl_fuchsia_math__common::SizeU>,
1505    /// pad_beyond_image_size_bytes ensures that there will be at least this
1506    /// many bytes in the VMO beyond the image size. Some SW video codecs need
1507    /// this for performance reasons.
1508    ///
1509    /// Some video decoders and encoders can require that a few more bytes be
1510    /// safe to access beyond the image's size as calculated by
1511    /// ImageFormatImageSize. This can sometimes require an additional page to
1512    /// be allocated. The padding specified by this field starts at byte 0 of
1513    /// the row beyond the last image row.
1514    ///
1515    /// This semantic is chosen because (a) it makes some video decoders used in
1516    /// ffmpeg happy (needs 16 bytes fully after the image as a run-out zone),
1517    /// and (b) it can serve as a not-particularly-wastful way to avoid adding
1518    /// pad_beyond_last_pixel_bytes as well, because this padding always starts
1519    /// at or beyond where that padding would without wasting more than
1520    /// bytes_per_row - pixel_stride_in_bytes * width which is very unlikely to
1521    /// result in wasting more than 1 page (and won't typically waste any
1522    /// pages).
1523    ///
1524    /// If the participant needs extra bytes beyond the image size to accomodate
1525    /// performance optimization(s), the number of extra bytes needed goes here.
1526    /// Do _not_ store valid pixels or metadata in these bytes; some or all of
1527    /// these bytes may be the same bytes requested via other participant's
1528    /// pad_* constraints.
1529    ///
1530    /// Do not write to these bytes outside time intervals during which
1531    /// writing to pixel data is permitted.
1532    pub pad_beyond_image_size_bytes: Option<u64>,
1533    #[doc(hidden)]
1534    pub __source_breaking: fidl::marker::SourceBreaking,
1535}
1536
1537impl fidl::Persistable for ImageFormatConstraints {}
1538
1539#[derive(Clone, Debug, Default, PartialEq)]
1540pub struct NodeSetDebugClientInfoRequest {
1541    pub name: Option<String>,
1542    pub id: Option<u64>,
1543    #[doc(hidden)]
1544    pub __source_breaking: fidl::marker::SourceBreaking,
1545}
1546
1547impl fidl::Persistable for NodeSetDebugClientInfoRequest {}
1548
1549#[derive(Clone, Debug, Default, PartialEq)]
1550pub struct NodeSetDebugTimeoutLogDeadlineRequest {
1551    pub deadline: Option<i64>,
1552    #[doc(hidden)]
1553    pub __source_breaking: fidl::marker::SourceBreaking,
1554}
1555
1556impl fidl::Persistable for NodeSetDebugTimeoutLogDeadlineRequest {}
1557
1558#[derive(Clone, Debug, Default, PartialEq)]
1559pub struct NodeSetNameRequest {
1560    pub priority: Option<u32>,
1561    pub name: Option<String>,
1562    #[doc(hidden)]
1563    pub __source_breaking: fidl::marker::SourceBreaking,
1564}
1565
1566impl fidl::Persistable for NodeSetNameRequest {}
1567
1568#[derive(Clone, Debug, Default, PartialEq)]
1569pub struct NodeGetBufferCollectionIdResponse {
1570    pub buffer_collection_id: Option<u64>,
1571    #[doc(hidden)]
1572    pub __source_breaking: fidl::marker::SourceBreaking,
1573}
1574
1575impl fidl::Persistable for NodeGetBufferCollectionIdResponse {}
1576
1577#[derive(Clone, Debug, Default, PartialEq)]
1578pub struct NodeIsAlternateForResponse {
1579    pub is_alternate: Option<bool>,
1580    #[doc(hidden)]
1581    pub __source_breaking: fidl::marker::SourceBreaking,
1582}
1583
1584impl fidl::Persistable for NodeIsAlternateForResponse {}
1585
1586#[derive(Clone, Debug, Default, PartialEq)]
1587pub struct SecureHeapAndRange {
1588    pub heap: Option<Heap>,
1589    pub range: Option<SecureHeapRange>,
1590    #[doc(hidden)]
1591    pub __source_breaking: fidl::marker::SourceBreaking,
1592}
1593
1594impl fidl::Persistable for SecureHeapAndRange {}
1595
1596#[derive(Clone, Debug, Default, PartialEq)]
1597pub struct SecureHeapAndRangeModification {
1598    pub heap: Option<Heap>,
1599    pub old_range: Option<SecureHeapRange>,
1600    pub new_range: Option<SecureHeapRange>,
1601    #[doc(hidden)]
1602    pub __source_breaking: fidl::marker::SourceBreaking,
1603}
1604
1605impl fidl::Persistable for SecureHeapAndRangeModification {}
1606
1607#[derive(Clone, Debug, Default, PartialEq)]
1608pub struct SecureHeapAndRanges {
1609    /// This is which secure/protected heap.
1610    pub heap: Option<Heap>,
1611    /// The list of physical ranges.  This list must be sorted by
1612    /// physical_address (lower first), and must not have any overlapping
1613    /// ranges.  Ranges that are directly adjacent are allowed (not
1614    /// overlapping).
1615    pub ranges: Option<Vec<SecureHeapRange>>,
1616    #[doc(hidden)]
1617    pub __source_breaking: fidl::marker::SourceBreaking,
1618}
1619
1620impl fidl::Persistable for SecureHeapAndRanges {}
1621
1622#[derive(Clone, Debug, Default, PartialEq)]
1623pub struct SecureHeapProperties {
1624    /// The Heap is repeated here for convenience.
1625    pub heap: Option<Heap>,
1626    /// If true, more than one call to SetPhysicalSecureHeap() for the same
1627    /// heap is allowed.  If false, only one SetPhyscialSecureHeap() call is
1628    /// allowed, and no calls to DeleteSecureHeapPhysicalRange() or
1629    /// ModifySecureHeapPhysicalRange() are allowed.  Even when this is false,
1630    /// the SecureMem server (driver) is still responsible for de-protecting
1631    /// just before warm reboot if protected ranges would not otherwise be
1632    /// cleaned up during a warm reboot.
1633    pub dynamic_protection_ranges: Option<bool>,
1634    /// The granularity of protection ranges.  If the granularity of start is
1635    /// different than granularity of end or length, then this is the max
1636    /// granularity value among those values.
1637    ///
1638    /// This must be a power of 2.  The client must not request ranges that
1639    /// specify smaller granularity.
1640    ///
1641    /// This must be at least zx_system_page_size() even if the HW can do
1642    /// smaller granularity.
1643    pub protected_range_granularity: Option<u32>,
1644    /// The SecureMem server should not count reserved ranges that the SecureMem
1645    /// server uses internally to get from range set A to range set B, if the
1646    /// SecureMem server needs to do any emulation of that sort.  Normally such
1647    /// emulation by the SecureMem server is unnecessary.  If any ranges are
1648    /// reserved by the SecureMem server, those reserved ranges are not
1649    /// available for use by the SecureMem client.
1650    ///
1651    /// If the number of ranges is limited only by available memory, it's ok for
1652    /// the SecureMem server to report 0xFFFFFFFFFFFFFFFF for this value.  The
1653    /// field must still be set.  As usual, the SecureMem server should ensure
1654    /// that SetPhysicalSecureHeapRanges() succeeds or fails atomically (either
1655    /// fully updates or rolls back before completing).
1656    pub max_protected_range_count: Option<u64>,
1657    /// Iff true, ModifySecureHeapPhysicalRange() is implemented.  Calling
1658    /// ModifySecureHeapPhysicalRange() when is_mod_protected_range_available
1659    /// is false is prohibited.  Don't attempt to detect availability of
1660    /// ModifySecureHeapPhysicalRange() by calling it to see if it fails; it
1661    /// may ZX_PANIC().
1662    pub is_mod_protected_range_available: Option<bool>,
1663    #[doc(hidden)]
1664    pub __source_breaking: fidl::marker::SourceBreaking,
1665}
1666
1667impl fidl::Persistable for SecureHeapProperties {}
1668
1669#[derive(Clone, Debug, Default, PartialEq)]
1670pub struct SecureHeapRange {
1671    /// Must be aligned to at least heap_range_granularity.
1672    pub physical_address: Option<u64>,
1673    /// Must be aligned to at least heap_range_granularity.
1674    pub size_bytes: Option<u64>,
1675    #[doc(hidden)]
1676    pub __source_breaking: fidl::marker::SourceBreaking,
1677}
1678
1679impl fidl::Persistable for SecureHeapRange {}
1680
1681#[derive(Clone, Debug, Default, PartialEq)]
1682pub struct SecureMemAddSecureHeapPhysicalRangeRequest {
1683    pub heap_range: Option<SecureHeapAndRange>,
1684    #[doc(hidden)]
1685    pub __source_breaking: fidl::marker::SourceBreaking,
1686}
1687
1688impl fidl::Persistable for SecureMemAddSecureHeapPhysicalRangeRequest {}
1689
1690#[derive(Clone, Debug, Default, PartialEq)]
1691pub struct SecureMemDeleteSecureHeapPhysicalRangeRequest {
1692    pub heap_range: Option<SecureHeapAndRange>,
1693    #[doc(hidden)]
1694    pub __source_breaking: fidl::marker::SourceBreaking,
1695}
1696
1697impl fidl::Persistable for SecureMemDeleteSecureHeapPhysicalRangeRequest {}
1698
1699#[derive(Clone, Debug, Default, PartialEq)]
1700pub struct SecureMemGetPhysicalSecureHeapPropertiesRequest {
1701    pub entire_heap: Option<SecureHeapAndRange>,
1702    #[doc(hidden)]
1703    pub __source_breaking: fidl::marker::SourceBreaking,
1704}
1705
1706impl fidl::Persistable for SecureMemGetPhysicalSecureHeapPropertiesRequest {}
1707
1708#[derive(Clone, Debug, Default, PartialEq)]
1709pub struct SecureMemModifySecureHeapPhysicalRangeRequest {
1710    pub range_modification: Option<SecureHeapAndRangeModification>,
1711    #[doc(hidden)]
1712    pub __source_breaking: fidl::marker::SourceBreaking,
1713}
1714
1715impl fidl::Persistable for SecureMemModifySecureHeapPhysicalRangeRequest {}
1716
1717#[derive(Clone, Debug, Default, PartialEq)]
1718pub struct SecureMemZeroSubRangeRequest {
1719    pub is_covering_range_explicit: Option<bool>,
1720    pub heap_range: Option<SecureHeapAndRange>,
1721    #[doc(hidden)]
1722    pub __source_breaking: fidl::marker::SourceBreaking,
1723}
1724
1725impl fidl::Persistable for SecureMemZeroSubRangeRequest {}
1726
1727#[derive(Clone, Debug, Default, PartialEq)]
1728pub struct SecureMemGetDynamicSecureHeapsResponse {
1729    pub heaps: Option<Vec<DynamicSecureHeap>>,
1730    #[doc(hidden)]
1731    pub __source_breaking: fidl::marker::SourceBreaking,
1732}
1733
1734impl fidl::Persistable for SecureMemGetDynamicSecureHeapsResponse {}
1735
1736#[derive(Clone, Debug, Default, PartialEq)]
1737pub struct SecureMemGetPhysicalSecureHeapPropertiesResponse {
1738    pub properties: Option<SecureHeapProperties>,
1739    #[doc(hidden)]
1740    pub __source_breaking: fidl::marker::SourceBreaking,
1741}
1742
1743impl fidl::Persistable for SecureMemGetPhysicalSecureHeapPropertiesResponse {}
1744
1745#[derive(Clone, Debug, Default, PartialEq)]
1746pub struct SecureMemGetPhysicalSecureHeapsResponse {
1747    pub heaps: Option<Vec<SecureHeapAndRanges>>,
1748    #[doc(hidden)]
1749    pub __source_breaking: fidl::marker::SourceBreaking,
1750}
1751
1752impl fidl::Persistable for SecureMemGetPhysicalSecureHeapsResponse {}
1753
1754/// These settings and constraints apply to all the buffers in the collection.
1755#[derive(Clone, Debug, Default, PartialEq)]
1756pub struct SingleBufferSettings {
1757    /// This field will always be set by sysmem.
1758    pub buffer_settings: Option<BufferMemorySettings>,
1759    /// Buffers holding data that is not uncompressed image data will not have
1760    /// this field set.  Buffers holding data that is uncompressed image data
1761    /// _may_ have this field set.
1762    ///
1763    /// At least for now, changing the PixelFormat requires re-allocating
1764    /// buffers.
1765    ///
1766    /// If un-set, there are no image format constraints.
1767    pub image_format_constraints: Option<ImageFormatConstraints>,
1768    #[doc(hidden)]
1769    pub __source_breaking: fidl::marker::SourceBreaking,
1770}
1771
1772impl fidl::Persistable for SingleBufferSettings {}
1773
1774pub mod allocator_ordinals {
1775    pub const ALLOCATE_NON_SHARED_COLLECTION: u64 = 0x5ca681f025a80e44;
1776    pub const ALLOCATE_SHARED_COLLECTION: u64 = 0x11a19ff51f0b49c1;
1777    pub const BIND_SHARED_COLLECTION: u64 = 0x550916b0dc1d5b4e;
1778    pub const VALIDATE_BUFFER_COLLECTION_TOKEN: u64 = 0x4c5ee91b02a7e68d;
1779    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x6f68f19a3f509c4d;
1780    pub const GET_VMO_INFO: u64 = 0x21a881120aa0ddf9;
1781}
1782
1783pub mod buffer_collection_ordinals {
1784    pub const SYNC: u64 = 0x11ac2555cf575b54;
1785    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1786    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1787    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1788    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1789    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1790    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1791    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1792    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1793    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1794    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1795    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1796    pub const SET_CONSTRAINTS: u64 = 0x1fde0f19d650197b;
1797    pub const WAIT_FOR_ALL_BUFFERS_ALLOCATED: u64 = 0x62300344b61404e;
1798    pub const CHECK_ALL_BUFFERS_ALLOCATED: u64 = 0x35a5fe77ce939c10;
1799    pub const ATTACH_TOKEN: u64 = 0x46ac7d0008492982;
1800    pub const ATTACH_LIFETIME_TRACKING: u64 = 0x3ecb510113116dcf;
1801}
1802
1803pub mod buffer_collection_token_ordinals {
1804    pub const SYNC: u64 = 0x11ac2555cf575b54;
1805    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1806    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1807    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1808    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1809    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1810    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1811    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1812    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1813    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1814    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1815    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1816    pub const DUPLICATE_SYNC: u64 = 0x1c1af9919d1ca45c;
1817    pub const DUPLICATE: u64 = 0x73e78f92ee7fb887;
1818    pub const SET_DISPENSABLE: u64 = 0x228acf979254df8b;
1819    pub const CREATE_BUFFER_COLLECTION_TOKEN_GROUP: u64 = 0x30f8d48e77bd36f2;
1820}
1821
1822pub mod buffer_collection_token_group_ordinals {
1823    pub const SYNC: u64 = 0x11ac2555cf575b54;
1824    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1825    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1826    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1827    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1828    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1829    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1830    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1831    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1832    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1833    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1834    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1835    pub const CREATE_CHILD: u64 = 0x41a0075d419f30c5;
1836    pub const CREATE_CHILDREN_SYNC: u64 = 0x15dea448c536070a;
1837    pub const ALL_CHILDREN_PRESENT: u64 = 0x5c327e4a23391312;
1838}
1839
1840pub mod node_ordinals {
1841    pub const SYNC: u64 = 0x11ac2555cf575b54;
1842    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1843    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1844    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1845    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1846    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1847    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1848    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1849    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1850    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1851    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1852    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1853}
1854
1855pub mod secure_mem_ordinals {
1856    pub const GET_PHYSICAL_SECURE_HEAPS: u64 = 0x38716300592073e3;
1857    pub const GET_DYNAMIC_SECURE_HEAPS: u64 = 0x1190847f99952834;
1858    pub const GET_PHYSICAL_SECURE_HEAP_PROPERTIES: u64 = 0xc6f06889009c7bc;
1859    pub const ADD_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0x35f695b9b6c7217a;
1860    pub const DELETE_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0xeaa58c650264c9e;
1861    pub const MODIFY_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0x60b7448aa1187734;
1862    pub const ZERO_SUB_RANGE: u64 = 0x5b25b7901a385ce5;
1863}
1864
1865mod internal {
1866    use super::*;
1867    unsafe impl fidl::encoding::TypeMarker for CoherencyDomain {
1868        type Owned = Self;
1869
1870        #[inline(always)]
1871        fn inline_align(_context: fidl::encoding::Context) -> usize {
1872            std::mem::align_of::<u32>()
1873        }
1874
1875        #[inline(always)]
1876        fn inline_size(_context: fidl::encoding::Context) -> usize {
1877            std::mem::size_of::<u32>()
1878        }
1879
1880        #[inline(always)]
1881        fn encode_is_copy() -> bool {
1882            false
1883        }
1884
1885        #[inline(always)]
1886        fn decode_is_copy() -> bool {
1887            false
1888        }
1889    }
1890
1891    impl fidl::encoding::ValueTypeMarker for CoherencyDomain {
1892        type Borrowed<'a> = Self;
1893        #[inline(always)]
1894        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1895            *value
1896        }
1897    }
1898
1899    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1900        for CoherencyDomain
1901    {
1902        #[inline]
1903        unsafe fn encode(
1904            self,
1905            encoder: &mut fidl::encoding::Encoder<'_, D>,
1906            offset: usize,
1907            _depth: fidl::encoding::Depth,
1908        ) -> fidl::Result<()> {
1909            encoder.debug_check_bounds::<Self>(offset);
1910            encoder.write_num(self.into_primitive(), offset);
1911            Ok(())
1912        }
1913    }
1914
1915    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CoherencyDomain {
1916        #[inline(always)]
1917        fn new_empty() -> Self {
1918            Self::unknown()
1919        }
1920
1921        #[inline]
1922        unsafe fn decode(
1923            &mut self,
1924            decoder: &mut fidl::encoding::Decoder<'_, D>,
1925            offset: usize,
1926            _depth: fidl::encoding::Depth,
1927        ) -> fidl::Result<()> {
1928            decoder.debug_check_bounds::<Self>(offset);
1929            let prim = decoder.read_num::<u32>(offset);
1930
1931            *self = Self::from_primitive_allow_unknown(prim);
1932            Ok(())
1933        }
1934    }
1935    unsafe impl fidl::encoding::TypeMarker for Error {
1936        type Owned = Self;
1937
1938        #[inline(always)]
1939        fn inline_align(_context: fidl::encoding::Context) -> usize {
1940            std::mem::align_of::<u32>()
1941        }
1942
1943        #[inline(always)]
1944        fn inline_size(_context: fidl::encoding::Context) -> usize {
1945            std::mem::size_of::<u32>()
1946        }
1947
1948        #[inline(always)]
1949        fn encode_is_copy() -> bool {
1950            false
1951        }
1952
1953        #[inline(always)]
1954        fn decode_is_copy() -> bool {
1955            false
1956        }
1957    }
1958
1959    impl fidl::encoding::ValueTypeMarker for Error {
1960        type Borrowed<'a> = Self;
1961        #[inline(always)]
1962        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1963            *value
1964        }
1965    }
1966
1967    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
1968        #[inline]
1969        unsafe fn encode(
1970            self,
1971            encoder: &mut fidl::encoding::Encoder<'_, D>,
1972            offset: usize,
1973            _depth: fidl::encoding::Depth,
1974        ) -> fidl::Result<()> {
1975            encoder.debug_check_bounds::<Self>(offset);
1976            encoder.write_num(self.into_primitive(), offset);
1977            Ok(())
1978        }
1979    }
1980
1981    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
1982        #[inline(always)]
1983        fn new_empty() -> Self {
1984            Self::unknown()
1985        }
1986
1987        #[inline]
1988        unsafe fn decode(
1989            &mut self,
1990            decoder: &mut fidl::encoding::Decoder<'_, D>,
1991            offset: usize,
1992            _depth: fidl::encoding::Depth,
1993        ) -> fidl::Result<()> {
1994            decoder.debug_check_bounds::<Self>(offset);
1995            let prim = decoder.read_num::<u32>(offset);
1996
1997            *self = Self::from_primitive_allow_unknown(prim);
1998            Ok(())
1999        }
2000    }
2001
2002    impl fidl::encoding::ValueTypeMarker for PixelFormatAndModifier {
2003        type Borrowed<'a> = &'a Self;
2004        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2005            value
2006        }
2007    }
2008
2009    unsafe impl fidl::encoding::TypeMarker for PixelFormatAndModifier {
2010        type Owned = Self;
2011
2012        #[inline(always)]
2013        fn inline_align(_context: fidl::encoding::Context) -> usize {
2014            8
2015        }
2016
2017        #[inline(always)]
2018        fn inline_size(_context: fidl::encoding::Context) -> usize {
2019            16
2020        }
2021    }
2022
2023    unsafe impl<D: fidl::encoding::ResourceDialect>
2024        fidl::encoding::Encode<PixelFormatAndModifier, D> for &PixelFormatAndModifier
2025    {
2026        #[inline]
2027        unsafe fn encode(
2028            self,
2029            encoder: &mut fidl::encoding::Encoder<'_, D>,
2030            offset: usize,
2031            _depth: fidl::encoding::Depth,
2032        ) -> fidl::Result<()> {
2033            encoder.debug_check_bounds::<PixelFormatAndModifier>(offset);
2034            // Delegate to tuple encoding.
2035            fidl::encoding::Encode::<PixelFormatAndModifier, D>::encode(
2036                (
2037                    <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format),
2038                    <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format_modifier),
2039                ),
2040                encoder, offset, _depth
2041            )
2042        }
2043    }
2044    unsafe impl<
2045        D: fidl::encoding::ResourceDialect,
2046        T0: fidl::encoding::Encode<fidl_fuchsia_images2__common::PixelFormat, D>,
2047        T1: fidl::encoding::Encode<fidl_fuchsia_images2__common::PixelFormatModifier, D>,
2048    > fidl::encoding::Encode<PixelFormatAndModifier, D> for (T0, T1)
2049    {
2050        #[inline]
2051        unsafe fn encode(
2052            self,
2053            encoder: &mut fidl::encoding::Encoder<'_, D>,
2054            offset: usize,
2055            depth: fidl::encoding::Depth,
2056        ) -> fidl::Result<()> {
2057            encoder.debug_check_bounds::<PixelFormatAndModifier>(offset);
2058            // Zero out padding regions. There's no need to apply masks
2059            // because the unmasked parts will be overwritten by fields.
2060            unsafe {
2061                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2062                (ptr as *mut u64).write_unaligned(0);
2063            }
2064            // Write the fields.
2065            self.0.encode(encoder, offset + 0, depth)?;
2066            self.1.encode(encoder, offset + 8, depth)?;
2067            Ok(())
2068        }
2069    }
2070
2071    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2072        for PixelFormatAndModifier
2073    {
2074        #[inline(always)]
2075        fn new_empty() -> Self {
2076            Self {
2077                pixel_format: fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D),
2078                pixel_format_modifier: fidl::new_empty!(
2079                    fidl_fuchsia_images2__common::PixelFormatModifier,
2080                    D
2081                ),
2082            }
2083        }
2084
2085        #[inline]
2086        unsafe fn decode(
2087            &mut self,
2088            decoder: &mut fidl::encoding::Decoder<'_, D>,
2089            offset: usize,
2090            _depth: fidl::encoding::Depth,
2091        ) -> fidl::Result<()> {
2092            decoder.debug_check_bounds::<Self>(offset);
2093            // Verify that padding bytes are zero.
2094            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2095            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2096            let mask = 0xffffffff00000000u64;
2097            let maskedval = padval & mask;
2098            if maskedval != 0 {
2099                return Err(fidl::Error::NonZeroPadding {
2100                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2101                });
2102            }
2103            fidl::decode!(
2104                fidl_fuchsia_images2__common::PixelFormat,
2105                D,
2106                &mut self.pixel_format,
2107                decoder,
2108                offset + 0,
2109                _depth
2110            )?;
2111            fidl::decode!(
2112                fidl_fuchsia_images2__common::PixelFormatModifier,
2113                D,
2114                &mut self.pixel_format_modifier,
2115                decoder,
2116                offset + 8,
2117                _depth
2118            )?;
2119            Ok(())
2120        }
2121    }
2122
2123    impl AllocatorSetDebugClientInfoRequest {
2124        #[inline(always)]
2125        fn max_ordinal_present(&self) -> u64 {
2126            if let Some(_) = self.id {
2127                return 2;
2128            }
2129            if let Some(_) = self.name {
2130                return 1;
2131            }
2132            0
2133        }
2134    }
2135
2136    impl fidl::encoding::ValueTypeMarker for AllocatorSetDebugClientInfoRequest {
2137        type Borrowed<'a> = &'a Self;
2138        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2139            value
2140        }
2141    }
2142
2143    unsafe impl fidl::encoding::TypeMarker for AllocatorSetDebugClientInfoRequest {
2144        type Owned = Self;
2145
2146        #[inline(always)]
2147        fn inline_align(_context: fidl::encoding::Context) -> usize {
2148            8
2149        }
2150
2151        #[inline(always)]
2152        fn inline_size(_context: fidl::encoding::Context) -> usize {
2153            16
2154        }
2155    }
2156
2157    unsafe impl<D: fidl::encoding::ResourceDialect>
2158        fidl::encoding::Encode<AllocatorSetDebugClientInfoRequest, D>
2159        for &AllocatorSetDebugClientInfoRequest
2160    {
2161        unsafe fn encode(
2162            self,
2163            encoder: &mut fidl::encoding::Encoder<'_, D>,
2164            offset: usize,
2165            mut depth: fidl::encoding::Depth,
2166        ) -> fidl::Result<()> {
2167            encoder.debug_check_bounds::<AllocatorSetDebugClientInfoRequest>(offset);
2168            // Vector header
2169            let max_ordinal: u64 = self.max_ordinal_present();
2170            encoder.write_num(max_ordinal, offset);
2171            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2172            // Calling encoder.out_of_line_offset(0) is not allowed.
2173            if max_ordinal == 0 {
2174                return Ok(());
2175            }
2176            depth.increment()?;
2177            let envelope_size = 8;
2178            let bytes_len = max_ordinal as usize * envelope_size;
2179            #[allow(unused_variables)]
2180            let offset = encoder.out_of_line_offset(bytes_len);
2181            let mut _prev_end_offset: usize = 0;
2182            if 1 > max_ordinal {
2183                return Ok(());
2184            }
2185
2186            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2187            // are envelope_size bytes.
2188            let cur_offset: usize = (1 - 1) * envelope_size;
2189
2190            // Zero reserved fields.
2191            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2192
2193            // Safety:
2194            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2195            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2196            //   envelope_size bytes, there is always sufficient room.
2197            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
2198                self.name.as_ref().map(
2199                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
2200                ),
2201                encoder,
2202                offset + cur_offset,
2203                depth,
2204            )?;
2205
2206            _prev_end_offset = cur_offset + envelope_size;
2207            if 2 > max_ordinal {
2208                return Ok(());
2209            }
2210
2211            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2212            // are envelope_size bytes.
2213            let cur_offset: usize = (2 - 1) * envelope_size;
2214
2215            // Zero reserved fields.
2216            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2217
2218            // Safety:
2219            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2220            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2221            //   envelope_size bytes, there is always sufficient room.
2222            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2223                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2224                encoder,
2225                offset + cur_offset,
2226                depth,
2227            )?;
2228
2229            _prev_end_offset = cur_offset + envelope_size;
2230
2231            Ok(())
2232        }
2233    }
2234
2235    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2236        for AllocatorSetDebugClientInfoRequest
2237    {
2238        #[inline(always)]
2239        fn new_empty() -> Self {
2240            Self::default()
2241        }
2242
2243        unsafe fn decode(
2244            &mut self,
2245            decoder: &mut fidl::encoding::Decoder<'_, D>,
2246            offset: usize,
2247            mut depth: fidl::encoding::Depth,
2248        ) -> fidl::Result<()> {
2249            decoder.debug_check_bounds::<Self>(offset);
2250            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2251                None => return Err(fidl::Error::NotNullable),
2252                Some(len) => len,
2253            };
2254            // Calling decoder.out_of_line_offset(0) is not allowed.
2255            if len == 0 {
2256                return Ok(());
2257            };
2258            depth.increment()?;
2259            let envelope_size = 8;
2260            let bytes_len = len * envelope_size;
2261            let offset = decoder.out_of_line_offset(bytes_len)?;
2262            // Decode the envelope for each type.
2263            let mut _next_ordinal_to_read = 0;
2264            let mut next_offset = offset;
2265            let end_offset = offset + bytes_len;
2266            _next_ordinal_to_read += 1;
2267            if next_offset >= end_offset {
2268                return Ok(());
2269            }
2270
2271            // Decode unknown envelopes for gaps in ordinals.
2272            while _next_ordinal_to_read < 1 {
2273                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2274                _next_ordinal_to_read += 1;
2275                next_offset += envelope_size;
2276            }
2277
2278            let next_out_of_line = decoder.next_out_of_line();
2279            let handles_before = decoder.remaining_handles();
2280            if let Some((inlined, num_bytes, num_handles)) =
2281                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2282            {
2283                let member_inline_size =
2284                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
2285                        decoder.context,
2286                    );
2287                if inlined != (member_inline_size <= 4) {
2288                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2289                }
2290                let inner_offset;
2291                let mut inner_depth = depth.clone();
2292                if inlined {
2293                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2294                    inner_offset = next_offset;
2295                } else {
2296                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2297                    inner_depth.increment()?;
2298                }
2299                let val_ref = self
2300                    .name
2301                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
2302                fidl::decode!(
2303                    fidl::encoding::BoundedString<256>,
2304                    D,
2305                    val_ref,
2306                    decoder,
2307                    inner_offset,
2308                    inner_depth
2309                )?;
2310                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2311                {
2312                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2313                }
2314                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2315                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2316                }
2317            }
2318
2319            next_offset += envelope_size;
2320            _next_ordinal_to_read += 1;
2321            if next_offset >= end_offset {
2322                return Ok(());
2323            }
2324
2325            // Decode unknown envelopes for gaps in ordinals.
2326            while _next_ordinal_to_read < 2 {
2327                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2328                _next_ordinal_to_read += 1;
2329                next_offset += envelope_size;
2330            }
2331
2332            let next_out_of_line = decoder.next_out_of_line();
2333            let handles_before = decoder.remaining_handles();
2334            if let Some((inlined, num_bytes, num_handles)) =
2335                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2336            {
2337                let member_inline_size =
2338                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2339                if inlined != (member_inline_size <= 4) {
2340                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2341                }
2342                let inner_offset;
2343                let mut inner_depth = depth.clone();
2344                if inlined {
2345                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2346                    inner_offset = next_offset;
2347                } else {
2348                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2349                    inner_depth.increment()?;
2350                }
2351                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
2352                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2353                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2354                {
2355                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2356                }
2357                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2358                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2359                }
2360            }
2361
2362            next_offset += envelope_size;
2363
2364            // Decode the remaining unknown envelopes.
2365            while next_offset < end_offset {
2366                _next_ordinal_to_read += 1;
2367                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2368                next_offset += envelope_size;
2369            }
2370
2371            Ok(())
2372        }
2373    }
2374
2375    impl AllocatorValidateBufferCollectionTokenRequest {
2376        #[inline(always)]
2377        fn max_ordinal_present(&self) -> u64 {
2378            if let Some(_) = self.token_server_koid {
2379                return 1;
2380            }
2381            0
2382        }
2383    }
2384
2385    impl fidl::encoding::ValueTypeMarker for AllocatorValidateBufferCollectionTokenRequest {
2386        type Borrowed<'a> = &'a Self;
2387        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2388            value
2389        }
2390    }
2391
2392    unsafe impl fidl::encoding::TypeMarker for AllocatorValidateBufferCollectionTokenRequest {
2393        type Owned = Self;
2394
2395        #[inline(always)]
2396        fn inline_align(_context: fidl::encoding::Context) -> usize {
2397            8
2398        }
2399
2400        #[inline(always)]
2401        fn inline_size(_context: fidl::encoding::Context) -> usize {
2402            16
2403        }
2404    }
2405
2406    unsafe impl<D: fidl::encoding::ResourceDialect>
2407        fidl::encoding::Encode<AllocatorValidateBufferCollectionTokenRequest, D>
2408        for &AllocatorValidateBufferCollectionTokenRequest
2409    {
2410        unsafe fn encode(
2411            self,
2412            encoder: &mut fidl::encoding::Encoder<'_, D>,
2413            offset: usize,
2414            mut depth: fidl::encoding::Depth,
2415        ) -> fidl::Result<()> {
2416            encoder.debug_check_bounds::<AllocatorValidateBufferCollectionTokenRequest>(offset);
2417            // Vector header
2418            let max_ordinal: u64 = self.max_ordinal_present();
2419            encoder.write_num(max_ordinal, offset);
2420            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2421            // Calling encoder.out_of_line_offset(0) is not allowed.
2422            if max_ordinal == 0 {
2423                return Ok(());
2424            }
2425            depth.increment()?;
2426            let envelope_size = 8;
2427            let bytes_len = max_ordinal as usize * envelope_size;
2428            #[allow(unused_variables)]
2429            let offset = encoder.out_of_line_offset(bytes_len);
2430            let mut _prev_end_offset: usize = 0;
2431            if 1 > max_ordinal {
2432                return Ok(());
2433            }
2434
2435            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2436            // are envelope_size bytes.
2437            let cur_offset: usize = (1 - 1) * envelope_size;
2438
2439            // Zero reserved fields.
2440            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2441
2442            // Safety:
2443            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2444            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2445            //   envelope_size bytes, there is always sufficient room.
2446            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2447                self.token_server_koid
2448                    .as_ref()
2449                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2450                encoder,
2451                offset + cur_offset,
2452                depth,
2453            )?;
2454
2455            _prev_end_offset = cur_offset + envelope_size;
2456
2457            Ok(())
2458        }
2459    }
2460
2461    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2462        for AllocatorValidateBufferCollectionTokenRequest
2463    {
2464        #[inline(always)]
2465        fn new_empty() -> Self {
2466            Self::default()
2467        }
2468
2469        unsafe fn decode(
2470            &mut self,
2471            decoder: &mut fidl::encoding::Decoder<'_, D>,
2472            offset: usize,
2473            mut depth: fidl::encoding::Depth,
2474        ) -> fidl::Result<()> {
2475            decoder.debug_check_bounds::<Self>(offset);
2476            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2477                None => return Err(fidl::Error::NotNullable),
2478                Some(len) => len,
2479            };
2480            // Calling decoder.out_of_line_offset(0) is not allowed.
2481            if len == 0 {
2482                return Ok(());
2483            };
2484            depth.increment()?;
2485            let envelope_size = 8;
2486            let bytes_len = len * envelope_size;
2487            let offset = decoder.out_of_line_offset(bytes_len)?;
2488            // Decode the envelope for each type.
2489            let mut _next_ordinal_to_read = 0;
2490            let mut next_offset = offset;
2491            let end_offset = offset + bytes_len;
2492            _next_ordinal_to_read += 1;
2493            if next_offset >= end_offset {
2494                return Ok(());
2495            }
2496
2497            // Decode unknown envelopes for gaps in ordinals.
2498            while _next_ordinal_to_read < 1 {
2499                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2500                _next_ordinal_to_read += 1;
2501                next_offset += envelope_size;
2502            }
2503
2504            let next_out_of_line = decoder.next_out_of_line();
2505            let handles_before = decoder.remaining_handles();
2506            if let Some((inlined, num_bytes, num_handles)) =
2507                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2508            {
2509                let member_inline_size =
2510                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2511                if inlined != (member_inline_size <= 4) {
2512                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2513                }
2514                let inner_offset;
2515                let mut inner_depth = depth.clone();
2516                if inlined {
2517                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2518                    inner_offset = next_offset;
2519                } else {
2520                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2521                    inner_depth.increment()?;
2522                }
2523                let val_ref =
2524                    self.token_server_koid.get_or_insert_with(|| fidl::new_empty!(u64, D));
2525                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2526                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2527                {
2528                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2529                }
2530                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2531                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2532                }
2533            }
2534
2535            next_offset += envelope_size;
2536
2537            // Decode the remaining unknown envelopes.
2538            while next_offset < end_offset {
2539                _next_ordinal_to_read += 1;
2540                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2541                next_offset += envelope_size;
2542            }
2543
2544            Ok(())
2545        }
2546    }
2547
2548    impl AllocatorValidateBufferCollectionTokenResponse {
2549        #[inline(always)]
2550        fn max_ordinal_present(&self) -> u64 {
2551            if let Some(_) = self.is_known {
2552                return 1;
2553            }
2554            0
2555        }
2556    }
2557
2558    impl fidl::encoding::ValueTypeMarker for AllocatorValidateBufferCollectionTokenResponse {
2559        type Borrowed<'a> = &'a Self;
2560        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2561            value
2562        }
2563    }
2564
2565    unsafe impl fidl::encoding::TypeMarker for AllocatorValidateBufferCollectionTokenResponse {
2566        type Owned = Self;
2567
2568        #[inline(always)]
2569        fn inline_align(_context: fidl::encoding::Context) -> usize {
2570            8
2571        }
2572
2573        #[inline(always)]
2574        fn inline_size(_context: fidl::encoding::Context) -> usize {
2575            16
2576        }
2577    }
2578
2579    unsafe impl<D: fidl::encoding::ResourceDialect>
2580        fidl::encoding::Encode<AllocatorValidateBufferCollectionTokenResponse, D>
2581        for &AllocatorValidateBufferCollectionTokenResponse
2582    {
2583        unsafe fn encode(
2584            self,
2585            encoder: &mut fidl::encoding::Encoder<'_, D>,
2586            offset: usize,
2587            mut depth: fidl::encoding::Depth,
2588        ) -> fidl::Result<()> {
2589            encoder.debug_check_bounds::<AllocatorValidateBufferCollectionTokenResponse>(offset);
2590            // Vector header
2591            let max_ordinal: u64 = self.max_ordinal_present();
2592            encoder.write_num(max_ordinal, offset);
2593            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2594            // Calling encoder.out_of_line_offset(0) is not allowed.
2595            if max_ordinal == 0 {
2596                return Ok(());
2597            }
2598            depth.increment()?;
2599            let envelope_size = 8;
2600            let bytes_len = max_ordinal as usize * envelope_size;
2601            #[allow(unused_variables)]
2602            let offset = encoder.out_of_line_offset(bytes_len);
2603            let mut _prev_end_offset: usize = 0;
2604            if 1 > max_ordinal {
2605                return Ok(());
2606            }
2607
2608            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2609            // are envelope_size bytes.
2610            let cur_offset: usize = (1 - 1) * envelope_size;
2611
2612            // Zero reserved fields.
2613            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2614
2615            // Safety:
2616            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2617            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2618            //   envelope_size bytes, there is always sufficient room.
2619            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2620                self.is_known.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2621                encoder,
2622                offset + cur_offset,
2623                depth,
2624            )?;
2625
2626            _prev_end_offset = cur_offset + envelope_size;
2627
2628            Ok(())
2629        }
2630    }
2631
2632    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2633        for AllocatorValidateBufferCollectionTokenResponse
2634    {
2635        #[inline(always)]
2636        fn new_empty() -> Self {
2637            Self::default()
2638        }
2639
2640        unsafe fn decode(
2641            &mut self,
2642            decoder: &mut fidl::encoding::Decoder<'_, D>,
2643            offset: usize,
2644            mut depth: fidl::encoding::Depth,
2645        ) -> fidl::Result<()> {
2646            decoder.debug_check_bounds::<Self>(offset);
2647            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2648                None => return Err(fidl::Error::NotNullable),
2649                Some(len) => len,
2650            };
2651            // Calling decoder.out_of_line_offset(0) is not allowed.
2652            if len == 0 {
2653                return Ok(());
2654            };
2655            depth.increment()?;
2656            let envelope_size = 8;
2657            let bytes_len = len * envelope_size;
2658            let offset = decoder.out_of_line_offset(bytes_len)?;
2659            // Decode the envelope for each type.
2660            let mut _next_ordinal_to_read = 0;
2661            let mut next_offset = offset;
2662            let end_offset = offset + bytes_len;
2663            _next_ordinal_to_read += 1;
2664            if next_offset >= end_offset {
2665                return Ok(());
2666            }
2667
2668            // Decode unknown envelopes for gaps in ordinals.
2669            while _next_ordinal_to_read < 1 {
2670                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2671                _next_ordinal_to_read += 1;
2672                next_offset += envelope_size;
2673            }
2674
2675            let next_out_of_line = decoder.next_out_of_line();
2676            let handles_before = decoder.remaining_handles();
2677            if let Some((inlined, num_bytes, num_handles)) =
2678                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2679            {
2680                let member_inline_size =
2681                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2682                if inlined != (member_inline_size <= 4) {
2683                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2684                }
2685                let inner_offset;
2686                let mut inner_depth = depth.clone();
2687                if inlined {
2688                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2689                    inner_offset = next_offset;
2690                } else {
2691                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2692                    inner_depth.increment()?;
2693                }
2694                let val_ref = self.is_known.get_or_insert_with(|| fidl::new_empty!(bool, D));
2695                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2696                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2697                {
2698                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2699                }
2700                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2701                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2702                }
2703            }
2704
2705            next_offset += envelope_size;
2706
2707            // Decode the remaining unknown envelopes.
2708            while next_offset < end_offset {
2709                _next_ordinal_to_read += 1;
2710                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2711                next_offset += envelope_size;
2712            }
2713
2714            Ok(())
2715        }
2716    }
2717
2718    impl BufferCollectionConstraints {
2719        #[inline(always)]
2720        fn max_ordinal_present(&self) -> u64 {
2721            if let Some(_) = self.image_format_constraints {
2722                return 8;
2723            }
2724            if let Some(_) = self.buffer_memory_constraints {
2725                return 7;
2726            }
2727            if let Some(_) = self.max_buffer_count {
2728                return 6;
2729            }
2730            if let Some(_) = self.min_buffer_count {
2731                return 5;
2732            }
2733            if let Some(_) = self.min_buffer_count_for_shared_slack {
2734                return 4;
2735            }
2736            if let Some(_) = self.min_buffer_count_for_dedicated_slack {
2737                return 3;
2738            }
2739            if let Some(_) = self.min_buffer_count_for_camping {
2740                return 2;
2741            }
2742            if let Some(_) = self.usage {
2743                return 1;
2744            }
2745            0
2746        }
2747    }
2748
2749    impl fidl::encoding::ValueTypeMarker for BufferCollectionConstraints {
2750        type Borrowed<'a> = &'a Self;
2751        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2752            value
2753        }
2754    }
2755
2756    unsafe impl fidl::encoding::TypeMarker for BufferCollectionConstraints {
2757        type Owned = Self;
2758
2759        #[inline(always)]
2760        fn inline_align(_context: fidl::encoding::Context) -> usize {
2761            8
2762        }
2763
2764        #[inline(always)]
2765        fn inline_size(_context: fidl::encoding::Context) -> usize {
2766            16
2767        }
2768    }
2769
2770    unsafe impl<D: fidl::encoding::ResourceDialect>
2771        fidl::encoding::Encode<BufferCollectionConstraints, D> for &BufferCollectionConstraints
2772    {
2773        unsafe fn encode(
2774            self,
2775            encoder: &mut fidl::encoding::Encoder<'_, D>,
2776            offset: usize,
2777            mut depth: fidl::encoding::Depth,
2778        ) -> fidl::Result<()> {
2779            encoder.debug_check_bounds::<BufferCollectionConstraints>(offset);
2780            // Vector header
2781            let max_ordinal: u64 = self.max_ordinal_present();
2782            encoder.write_num(max_ordinal, offset);
2783            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2784            // Calling encoder.out_of_line_offset(0) is not allowed.
2785            if max_ordinal == 0 {
2786                return Ok(());
2787            }
2788            depth.increment()?;
2789            let envelope_size = 8;
2790            let bytes_len = max_ordinal as usize * envelope_size;
2791            #[allow(unused_variables)]
2792            let offset = encoder.out_of_line_offset(bytes_len);
2793            let mut _prev_end_offset: usize = 0;
2794            if 1 > max_ordinal {
2795                return Ok(());
2796            }
2797
2798            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2799            // are envelope_size bytes.
2800            let cur_offset: usize = (1 - 1) * envelope_size;
2801
2802            // Zero reserved fields.
2803            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2804
2805            // Safety:
2806            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2807            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2808            //   envelope_size bytes, there is always sufficient room.
2809            fidl::encoding::encode_in_envelope_optional::<BufferUsage, D>(
2810                self.usage.as_ref().map(<BufferUsage as fidl::encoding::ValueTypeMarker>::borrow),
2811                encoder,
2812                offset + cur_offset,
2813                depth,
2814            )?;
2815
2816            _prev_end_offset = cur_offset + envelope_size;
2817            if 2 > max_ordinal {
2818                return Ok(());
2819            }
2820
2821            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2822            // are envelope_size bytes.
2823            let cur_offset: usize = (2 - 1) * envelope_size;
2824
2825            // Zero reserved fields.
2826            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2827
2828            // Safety:
2829            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2830            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2831            //   envelope_size bytes, there is always sufficient room.
2832            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2833                self.min_buffer_count_for_camping
2834                    .as_ref()
2835                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2836                encoder,
2837                offset + cur_offset,
2838                depth,
2839            )?;
2840
2841            _prev_end_offset = cur_offset + envelope_size;
2842            if 3 > max_ordinal {
2843                return Ok(());
2844            }
2845
2846            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2847            // are envelope_size bytes.
2848            let cur_offset: usize = (3 - 1) * envelope_size;
2849
2850            // Zero reserved fields.
2851            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2852
2853            // Safety:
2854            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2855            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2856            //   envelope_size bytes, there is always sufficient room.
2857            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2858                self.min_buffer_count_for_dedicated_slack
2859                    .as_ref()
2860                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2861                encoder,
2862                offset + cur_offset,
2863                depth,
2864            )?;
2865
2866            _prev_end_offset = cur_offset + envelope_size;
2867            if 4 > max_ordinal {
2868                return Ok(());
2869            }
2870
2871            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2872            // are envelope_size bytes.
2873            let cur_offset: usize = (4 - 1) * envelope_size;
2874
2875            // Zero reserved fields.
2876            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2877
2878            // Safety:
2879            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2880            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2881            //   envelope_size bytes, there is always sufficient room.
2882            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2883                self.min_buffer_count_for_shared_slack
2884                    .as_ref()
2885                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2886                encoder,
2887                offset + cur_offset,
2888                depth,
2889            )?;
2890
2891            _prev_end_offset = cur_offset + envelope_size;
2892            if 5 > max_ordinal {
2893                return Ok(());
2894            }
2895
2896            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2897            // are envelope_size bytes.
2898            let cur_offset: usize = (5 - 1) * envelope_size;
2899
2900            // Zero reserved fields.
2901            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2902
2903            // Safety:
2904            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2905            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2906            //   envelope_size bytes, there is always sufficient room.
2907            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2908                self.min_buffer_count
2909                    .as_ref()
2910                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2911                encoder,
2912                offset + cur_offset,
2913                depth,
2914            )?;
2915
2916            _prev_end_offset = cur_offset + envelope_size;
2917            if 6 > max_ordinal {
2918                return Ok(());
2919            }
2920
2921            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2922            // are envelope_size bytes.
2923            let cur_offset: usize = (6 - 1) * envelope_size;
2924
2925            // Zero reserved fields.
2926            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2927
2928            // Safety:
2929            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2930            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2931            //   envelope_size bytes, there is always sufficient room.
2932            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2933                self.max_buffer_count
2934                    .as_ref()
2935                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2936                encoder,
2937                offset + cur_offset,
2938                depth,
2939            )?;
2940
2941            _prev_end_offset = cur_offset + envelope_size;
2942            if 7 > max_ordinal {
2943                return Ok(());
2944            }
2945
2946            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2947            // are envelope_size bytes.
2948            let cur_offset: usize = (7 - 1) * envelope_size;
2949
2950            // Zero reserved fields.
2951            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2952
2953            // Safety:
2954            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2955            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2956            //   envelope_size bytes, there is always sufficient room.
2957            fidl::encoding::encode_in_envelope_optional::<BufferMemoryConstraints, D>(
2958                self.buffer_memory_constraints
2959                    .as_ref()
2960                    .map(<BufferMemoryConstraints as fidl::encoding::ValueTypeMarker>::borrow),
2961                encoder,
2962                offset + cur_offset,
2963                depth,
2964            )?;
2965
2966            _prev_end_offset = cur_offset + envelope_size;
2967            if 8 > max_ordinal {
2968                return Ok(());
2969            }
2970
2971            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2972            // are envelope_size bytes.
2973            let cur_offset: usize = (8 - 1) * envelope_size;
2974
2975            // Zero reserved fields.
2976            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2977
2978            // Safety:
2979            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2980            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2981            //   envelope_size bytes, there is always sufficient room.
2982            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<ImageFormatConstraints, 64>, D>(
2983            self.image_format_constraints.as_ref().map(<fidl::encoding::Vector<ImageFormatConstraints, 64> as fidl::encoding::ValueTypeMarker>::borrow),
2984            encoder, offset + cur_offset, depth
2985        )?;
2986
2987            _prev_end_offset = cur_offset + envelope_size;
2988
2989            Ok(())
2990        }
2991    }
2992
2993    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2994        for BufferCollectionConstraints
2995    {
2996        #[inline(always)]
2997        fn new_empty() -> Self {
2998            Self::default()
2999        }
3000
3001        unsafe fn decode(
3002            &mut self,
3003            decoder: &mut fidl::encoding::Decoder<'_, D>,
3004            offset: usize,
3005            mut depth: fidl::encoding::Depth,
3006        ) -> fidl::Result<()> {
3007            decoder.debug_check_bounds::<Self>(offset);
3008            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3009                None => return Err(fidl::Error::NotNullable),
3010                Some(len) => len,
3011            };
3012            // Calling decoder.out_of_line_offset(0) is not allowed.
3013            if len == 0 {
3014                return Ok(());
3015            };
3016            depth.increment()?;
3017            let envelope_size = 8;
3018            let bytes_len = len * envelope_size;
3019            let offset = decoder.out_of_line_offset(bytes_len)?;
3020            // Decode the envelope for each type.
3021            let mut _next_ordinal_to_read = 0;
3022            let mut next_offset = offset;
3023            let end_offset = offset + bytes_len;
3024            _next_ordinal_to_read += 1;
3025            if next_offset >= end_offset {
3026                return Ok(());
3027            }
3028
3029            // Decode unknown envelopes for gaps in ordinals.
3030            while _next_ordinal_to_read < 1 {
3031                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3032                _next_ordinal_to_read += 1;
3033                next_offset += envelope_size;
3034            }
3035
3036            let next_out_of_line = decoder.next_out_of_line();
3037            let handles_before = decoder.remaining_handles();
3038            if let Some((inlined, num_bytes, num_handles)) =
3039                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3040            {
3041                let member_inline_size =
3042                    <BufferUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3043                if inlined != (member_inline_size <= 4) {
3044                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3045                }
3046                let inner_offset;
3047                let mut inner_depth = depth.clone();
3048                if inlined {
3049                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3050                    inner_offset = next_offset;
3051                } else {
3052                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3053                    inner_depth.increment()?;
3054                }
3055                let val_ref = self.usage.get_or_insert_with(|| fidl::new_empty!(BufferUsage, D));
3056                fidl::decode!(BufferUsage, D, val_ref, decoder, inner_offset, inner_depth)?;
3057                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3058                {
3059                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3060                }
3061                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3062                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3063                }
3064            }
3065
3066            next_offset += envelope_size;
3067            _next_ordinal_to_read += 1;
3068            if next_offset >= end_offset {
3069                return Ok(());
3070            }
3071
3072            // Decode unknown envelopes for gaps in ordinals.
3073            while _next_ordinal_to_read < 2 {
3074                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3075                _next_ordinal_to_read += 1;
3076                next_offset += envelope_size;
3077            }
3078
3079            let next_out_of_line = decoder.next_out_of_line();
3080            let handles_before = decoder.remaining_handles();
3081            if let Some((inlined, num_bytes, num_handles)) =
3082                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3083            {
3084                let member_inline_size =
3085                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3086                if inlined != (member_inline_size <= 4) {
3087                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3088                }
3089                let inner_offset;
3090                let mut inner_depth = depth.clone();
3091                if inlined {
3092                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3093                    inner_offset = next_offset;
3094                } else {
3095                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3096                    inner_depth.increment()?;
3097                }
3098                let val_ref = self
3099                    .min_buffer_count_for_camping
3100                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3101                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3102                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3103                {
3104                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3105                }
3106                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3107                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3108                }
3109            }
3110
3111            next_offset += envelope_size;
3112            _next_ordinal_to_read += 1;
3113            if next_offset >= end_offset {
3114                return Ok(());
3115            }
3116
3117            // Decode unknown envelopes for gaps in ordinals.
3118            while _next_ordinal_to_read < 3 {
3119                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3120                _next_ordinal_to_read += 1;
3121                next_offset += envelope_size;
3122            }
3123
3124            let next_out_of_line = decoder.next_out_of_line();
3125            let handles_before = decoder.remaining_handles();
3126            if let Some((inlined, num_bytes, num_handles)) =
3127                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3128            {
3129                let member_inline_size =
3130                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3131                if inlined != (member_inline_size <= 4) {
3132                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3133                }
3134                let inner_offset;
3135                let mut inner_depth = depth.clone();
3136                if inlined {
3137                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3138                    inner_offset = next_offset;
3139                } else {
3140                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3141                    inner_depth.increment()?;
3142                }
3143                let val_ref = self
3144                    .min_buffer_count_for_dedicated_slack
3145                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3146                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3147                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3148                {
3149                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3150                }
3151                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3152                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3153                }
3154            }
3155
3156            next_offset += envelope_size;
3157            _next_ordinal_to_read += 1;
3158            if next_offset >= end_offset {
3159                return Ok(());
3160            }
3161
3162            // Decode unknown envelopes for gaps in ordinals.
3163            while _next_ordinal_to_read < 4 {
3164                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3165                _next_ordinal_to_read += 1;
3166                next_offset += envelope_size;
3167            }
3168
3169            let next_out_of_line = decoder.next_out_of_line();
3170            let handles_before = decoder.remaining_handles();
3171            if let Some((inlined, num_bytes, num_handles)) =
3172                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3173            {
3174                let member_inline_size =
3175                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3176                if inlined != (member_inline_size <= 4) {
3177                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3178                }
3179                let inner_offset;
3180                let mut inner_depth = depth.clone();
3181                if inlined {
3182                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3183                    inner_offset = next_offset;
3184                } else {
3185                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3186                    inner_depth.increment()?;
3187                }
3188                let val_ref = self
3189                    .min_buffer_count_for_shared_slack
3190                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3191                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3192                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3193                {
3194                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3195                }
3196                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3197                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3198                }
3199            }
3200
3201            next_offset += envelope_size;
3202            _next_ordinal_to_read += 1;
3203            if next_offset >= end_offset {
3204                return Ok(());
3205            }
3206
3207            // Decode unknown envelopes for gaps in ordinals.
3208            while _next_ordinal_to_read < 5 {
3209                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3210                _next_ordinal_to_read += 1;
3211                next_offset += envelope_size;
3212            }
3213
3214            let next_out_of_line = decoder.next_out_of_line();
3215            let handles_before = decoder.remaining_handles();
3216            if let Some((inlined, num_bytes, num_handles)) =
3217                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3218            {
3219                let member_inline_size =
3220                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3221                if inlined != (member_inline_size <= 4) {
3222                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3223                }
3224                let inner_offset;
3225                let mut inner_depth = depth.clone();
3226                if inlined {
3227                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3228                    inner_offset = next_offset;
3229                } else {
3230                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3231                    inner_depth.increment()?;
3232                }
3233                let val_ref = self.min_buffer_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
3234                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3235                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3236                {
3237                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3238                }
3239                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3240                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3241                }
3242            }
3243
3244            next_offset += envelope_size;
3245            _next_ordinal_to_read += 1;
3246            if next_offset >= end_offset {
3247                return Ok(());
3248            }
3249
3250            // Decode unknown envelopes for gaps in ordinals.
3251            while _next_ordinal_to_read < 6 {
3252                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3253                _next_ordinal_to_read += 1;
3254                next_offset += envelope_size;
3255            }
3256
3257            let next_out_of_line = decoder.next_out_of_line();
3258            let handles_before = decoder.remaining_handles();
3259            if let Some((inlined, num_bytes, num_handles)) =
3260                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3261            {
3262                let member_inline_size =
3263                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3264                if inlined != (member_inline_size <= 4) {
3265                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3266                }
3267                let inner_offset;
3268                let mut inner_depth = depth.clone();
3269                if inlined {
3270                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3271                    inner_offset = next_offset;
3272                } else {
3273                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3274                    inner_depth.increment()?;
3275                }
3276                let val_ref = self.max_buffer_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
3277                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3278                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3279                {
3280                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3281                }
3282                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3283                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3284                }
3285            }
3286
3287            next_offset += envelope_size;
3288            _next_ordinal_to_read += 1;
3289            if next_offset >= end_offset {
3290                return Ok(());
3291            }
3292
3293            // Decode unknown envelopes for gaps in ordinals.
3294            while _next_ordinal_to_read < 7 {
3295                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3296                _next_ordinal_to_read += 1;
3297                next_offset += envelope_size;
3298            }
3299
3300            let next_out_of_line = decoder.next_out_of_line();
3301            let handles_before = decoder.remaining_handles();
3302            if let Some((inlined, num_bytes, num_handles)) =
3303                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3304            {
3305                let member_inline_size =
3306                    <BufferMemoryConstraints as fidl::encoding::TypeMarker>::inline_size(
3307                        decoder.context,
3308                    );
3309                if inlined != (member_inline_size <= 4) {
3310                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3311                }
3312                let inner_offset;
3313                let mut inner_depth = depth.clone();
3314                if inlined {
3315                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3316                    inner_offset = next_offset;
3317                } else {
3318                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3319                    inner_depth.increment()?;
3320                }
3321                let val_ref = self
3322                    .buffer_memory_constraints
3323                    .get_or_insert_with(|| fidl::new_empty!(BufferMemoryConstraints, D));
3324                fidl::decode!(
3325                    BufferMemoryConstraints,
3326                    D,
3327                    val_ref,
3328                    decoder,
3329                    inner_offset,
3330                    inner_depth
3331                )?;
3332                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3333                {
3334                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3335                }
3336                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3337                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3338                }
3339            }
3340
3341            next_offset += envelope_size;
3342            _next_ordinal_to_read += 1;
3343            if next_offset >= end_offset {
3344                return Ok(());
3345            }
3346
3347            // Decode unknown envelopes for gaps in ordinals.
3348            while _next_ordinal_to_read < 8 {
3349                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3350                _next_ordinal_to_read += 1;
3351                next_offset += envelope_size;
3352            }
3353
3354            let next_out_of_line = decoder.next_out_of_line();
3355            let handles_before = decoder.remaining_handles();
3356            if let Some((inlined, num_bytes, num_handles)) =
3357                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3358            {
3359                let member_inline_size = <fidl::encoding::Vector<ImageFormatConstraints, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3360                if inlined != (member_inline_size <= 4) {
3361                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3362                }
3363                let inner_offset;
3364                let mut inner_depth = depth.clone();
3365                if inlined {
3366                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3367                    inner_offset = next_offset;
3368                } else {
3369                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3370                    inner_depth.increment()?;
3371                }
3372                let val_ref = self.image_format_constraints.get_or_insert_with(
3373                    || fidl::new_empty!(fidl::encoding::Vector<ImageFormatConstraints, 64>, D),
3374                );
3375                fidl::decode!(fidl::encoding::Vector<ImageFormatConstraints, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3376                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3377                {
3378                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3379                }
3380                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3381                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3382                }
3383            }
3384
3385            next_offset += envelope_size;
3386
3387            // Decode the remaining unknown envelopes.
3388            while next_offset < end_offset {
3389                _next_ordinal_to_read += 1;
3390                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3391                next_offset += envelope_size;
3392            }
3393
3394            Ok(())
3395        }
3396    }
3397
3398    impl BufferCollectionTokenDuplicateSyncRequest {
3399        #[inline(always)]
3400        fn max_ordinal_present(&self) -> u64 {
3401            if let Some(_) = self.rights_attenuation_masks {
3402                return 1;
3403            }
3404            0
3405        }
3406    }
3407
3408    impl fidl::encoding::ValueTypeMarker for BufferCollectionTokenDuplicateSyncRequest {
3409        type Borrowed<'a> = &'a Self;
3410        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3411            value
3412        }
3413    }
3414
3415    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncRequest {
3416        type Owned = Self;
3417
3418        #[inline(always)]
3419        fn inline_align(_context: fidl::encoding::Context) -> usize {
3420            8
3421        }
3422
3423        #[inline(always)]
3424        fn inline_size(_context: fidl::encoding::Context) -> usize {
3425            16
3426        }
3427    }
3428
3429    unsafe impl<D: fidl::encoding::ResourceDialect>
3430        fidl::encoding::Encode<BufferCollectionTokenDuplicateSyncRequest, D>
3431        for &BufferCollectionTokenDuplicateSyncRequest
3432    {
3433        unsafe fn encode(
3434            self,
3435            encoder: &mut fidl::encoding::Encoder<'_, D>,
3436            offset: usize,
3437            mut depth: fidl::encoding::Depth,
3438        ) -> fidl::Result<()> {
3439            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncRequest>(offset);
3440            // Vector header
3441            let max_ordinal: u64 = self.max_ordinal_present();
3442            encoder.write_num(max_ordinal, offset);
3443            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3444            // Calling encoder.out_of_line_offset(0) is not allowed.
3445            if max_ordinal == 0 {
3446                return Ok(());
3447            }
3448            depth.increment()?;
3449            let envelope_size = 8;
3450            let bytes_len = max_ordinal as usize * envelope_size;
3451            #[allow(unused_variables)]
3452            let offset = encoder.out_of_line_offset(bytes_len);
3453            let mut _prev_end_offset: usize = 0;
3454            if 1 > max_ordinal {
3455                return Ok(());
3456            }
3457
3458            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3459            // are envelope_size bytes.
3460            let cur_offset: usize = (1 - 1) * envelope_size;
3461
3462            // Zero reserved fields.
3463            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3464
3465            // Safety:
3466            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3467            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3468            //   envelope_size bytes, there is always sufficient room.
3469            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::Rights, 64>, D>(
3470            self.rights_attenuation_masks.as_ref().map(<fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3471            encoder, offset + cur_offset, depth
3472        )?;
3473
3474            _prev_end_offset = cur_offset + envelope_size;
3475
3476            Ok(())
3477        }
3478    }
3479
3480    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3481        for BufferCollectionTokenDuplicateSyncRequest
3482    {
3483        #[inline(always)]
3484        fn new_empty() -> Self {
3485            Self::default()
3486        }
3487
3488        unsafe fn decode(
3489            &mut self,
3490            decoder: &mut fidl::encoding::Decoder<'_, D>,
3491            offset: usize,
3492            mut depth: fidl::encoding::Depth,
3493        ) -> fidl::Result<()> {
3494            decoder.debug_check_bounds::<Self>(offset);
3495            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3496                None => return Err(fidl::Error::NotNullable),
3497                Some(len) => len,
3498            };
3499            // Calling decoder.out_of_line_offset(0) is not allowed.
3500            if len == 0 {
3501                return Ok(());
3502            };
3503            depth.increment()?;
3504            let envelope_size = 8;
3505            let bytes_len = len * envelope_size;
3506            let offset = decoder.out_of_line_offset(bytes_len)?;
3507            // Decode the envelope for each type.
3508            let mut _next_ordinal_to_read = 0;
3509            let mut next_offset = offset;
3510            let end_offset = offset + bytes_len;
3511            _next_ordinal_to_read += 1;
3512            if next_offset >= end_offset {
3513                return Ok(());
3514            }
3515
3516            // Decode unknown envelopes for gaps in ordinals.
3517            while _next_ordinal_to_read < 1 {
3518                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3519                _next_ordinal_to_read += 1;
3520                next_offset += envelope_size;
3521            }
3522
3523            let next_out_of_line = decoder.next_out_of_line();
3524            let handles_before = decoder.remaining_handles();
3525            if let Some((inlined, num_bytes, num_handles)) =
3526                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3527            {
3528                let member_inline_size = <fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3529                if inlined != (member_inline_size <= 4) {
3530                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3531                }
3532                let inner_offset;
3533                let mut inner_depth = depth.clone();
3534                if inlined {
3535                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3536                    inner_offset = next_offset;
3537                } else {
3538                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3539                    inner_depth.increment()?;
3540                }
3541                let val_ref = self.rights_attenuation_masks.get_or_insert_with(
3542                    || fidl::new_empty!(fidl::encoding::Vector<fidl::Rights, 64>, D),
3543                );
3544                fidl::decode!(fidl::encoding::Vector<fidl::Rights, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3545                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3546                {
3547                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3548                }
3549                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3550                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3551                }
3552            }
3553
3554            next_offset += envelope_size;
3555
3556            // Decode the remaining unknown envelopes.
3557            while next_offset < end_offset {
3558                _next_ordinal_to_read += 1;
3559                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3560                next_offset += envelope_size;
3561            }
3562
3563            Ok(())
3564        }
3565    }
3566
3567    impl BufferCollectionTokenGroupCreateChildrenSyncRequest {
3568        #[inline(always)]
3569        fn max_ordinal_present(&self) -> u64 {
3570            if let Some(_) = self.rights_attenuation_masks {
3571                return 1;
3572            }
3573            0
3574        }
3575    }
3576
3577    impl fidl::encoding::ValueTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncRequest {
3578        type Borrowed<'a> = &'a Self;
3579        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3580            value
3581        }
3582    }
3583
3584    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncRequest {
3585        type Owned = Self;
3586
3587        #[inline(always)]
3588        fn inline_align(_context: fidl::encoding::Context) -> usize {
3589            8
3590        }
3591
3592        #[inline(always)]
3593        fn inline_size(_context: fidl::encoding::Context) -> usize {
3594            16
3595        }
3596    }
3597
3598    unsafe impl<D: fidl::encoding::ResourceDialect>
3599        fidl::encoding::Encode<BufferCollectionTokenGroupCreateChildrenSyncRequest, D>
3600        for &BufferCollectionTokenGroupCreateChildrenSyncRequest
3601    {
3602        unsafe fn encode(
3603            self,
3604            encoder: &mut fidl::encoding::Encoder<'_, D>,
3605            offset: usize,
3606            mut depth: fidl::encoding::Depth,
3607        ) -> fidl::Result<()> {
3608            encoder
3609                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(offset);
3610            // Vector header
3611            let max_ordinal: u64 = self.max_ordinal_present();
3612            encoder.write_num(max_ordinal, offset);
3613            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3614            // Calling encoder.out_of_line_offset(0) is not allowed.
3615            if max_ordinal == 0 {
3616                return Ok(());
3617            }
3618            depth.increment()?;
3619            let envelope_size = 8;
3620            let bytes_len = max_ordinal as usize * envelope_size;
3621            #[allow(unused_variables)]
3622            let offset = encoder.out_of_line_offset(bytes_len);
3623            let mut _prev_end_offset: usize = 0;
3624            if 1 > max_ordinal {
3625                return Ok(());
3626            }
3627
3628            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3629            // are envelope_size bytes.
3630            let cur_offset: usize = (1 - 1) * envelope_size;
3631
3632            // Zero reserved fields.
3633            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3634
3635            // Safety:
3636            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3637            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3638            //   envelope_size bytes, there is always sufficient room.
3639            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::Rights, 64>, D>(
3640            self.rights_attenuation_masks.as_ref().map(<fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3641            encoder, offset + cur_offset, depth
3642        )?;
3643
3644            _prev_end_offset = cur_offset + envelope_size;
3645
3646            Ok(())
3647        }
3648    }
3649
3650    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3651        for BufferCollectionTokenGroupCreateChildrenSyncRequest
3652    {
3653        #[inline(always)]
3654        fn new_empty() -> Self {
3655            Self::default()
3656        }
3657
3658        unsafe fn decode(
3659            &mut self,
3660            decoder: &mut fidl::encoding::Decoder<'_, D>,
3661            offset: usize,
3662            mut depth: fidl::encoding::Depth,
3663        ) -> fidl::Result<()> {
3664            decoder.debug_check_bounds::<Self>(offset);
3665            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3666                None => return Err(fidl::Error::NotNullable),
3667                Some(len) => len,
3668            };
3669            // Calling decoder.out_of_line_offset(0) is not allowed.
3670            if len == 0 {
3671                return Ok(());
3672            };
3673            depth.increment()?;
3674            let envelope_size = 8;
3675            let bytes_len = len * envelope_size;
3676            let offset = decoder.out_of_line_offset(bytes_len)?;
3677            // Decode the envelope for each type.
3678            let mut _next_ordinal_to_read = 0;
3679            let mut next_offset = offset;
3680            let end_offset = offset + bytes_len;
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 < 1 {
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 = <fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3699                if inlined != (member_inline_size <= 4) {
3700                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3701                }
3702                let inner_offset;
3703                let mut inner_depth = depth.clone();
3704                if inlined {
3705                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3706                    inner_offset = next_offset;
3707                } else {
3708                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3709                    inner_depth.increment()?;
3710                }
3711                let val_ref = self.rights_attenuation_masks.get_or_insert_with(
3712                    || fidl::new_empty!(fidl::encoding::Vector<fidl::Rights, 64>, D),
3713                );
3714                fidl::decode!(fidl::encoding::Vector<fidl::Rights, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3715                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3716                {
3717                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3718                }
3719                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3720                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3721                }
3722            }
3723
3724            next_offset += envelope_size;
3725
3726            // Decode the remaining unknown envelopes.
3727            while next_offset < end_offset {
3728                _next_ordinal_to_read += 1;
3729                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3730                next_offset += envelope_size;
3731            }
3732
3733            Ok(())
3734        }
3735    }
3736
3737    impl BufferMemoryConstraints {
3738        #[inline(always)]
3739        fn max_ordinal_present(&self) -> u64 {
3740            if let Some(_) = self.permitted_heaps {
3741                return 8;
3742            }
3743            if let Some(_) = self.inaccessible_domain_supported {
3744                return 7;
3745            }
3746            if let Some(_) = self.ram_domain_supported {
3747                return 6;
3748            }
3749            if let Some(_) = self.cpu_domain_supported {
3750                return 5;
3751            }
3752            if let Some(_) = self.secure_required {
3753                return 4;
3754            }
3755            if let Some(_) = self.physically_contiguous_required {
3756                return 3;
3757            }
3758            if let Some(_) = self.max_size_bytes {
3759                return 2;
3760            }
3761            if let Some(_) = self.min_size_bytes {
3762                return 1;
3763            }
3764            0
3765        }
3766    }
3767
3768    impl fidl::encoding::ValueTypeMarker for BufferMemoryConstraints {
3769        type Borrowed<'a> = &'a Self;
3770        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3771            value
3772        }
3773    }
3774
3775    unsafe impl fidl::encoding::TypeMarker for BufferMemoryConstraints {
3776        type Owned = Self;
3777
3778        #[inline(always)]
3779        fn inline_align(_context: fidl::encoding::Context) -> usize {
3780            8
3781        }
3782
3783        #[inline(always)]
3784        fn inline_size(_context: fidl::encoding::Context) -> usize {
3785            16
3786        }
3787    }
3788
3789    unsafe impl<D: fidl::encoding::ResourceDialect>
3790        fidl::encoding::Encode<BufferMemoryConstraints, D> for &BufferMemoryConstraints
3791    {
3792        unsafe fn encode(
3793            self,
3794            encoder: &mut fidl::encoding::Encoder<'_, D>,
3795            offset: usize,
3796            mut depth: fidl::encoding::Depth,
3797        ) -> fidl::Result<()> {
3798            encoder.debug_check_bounds::<BufferMemoryConstraints>(offset);
3799            // Vector header
3800            let max_ordinal: u64 = self.max_ordinal_present();
3801            encoder.write_num(max_ordinal, offset);
3802            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3803            // Calling encoder.out_of_line_offset(0) is not allowed.
3804            if max_ordinal == 0 {
3805                return Ok(());
3806            }
3807            depth.increment()?;
3808            let envelope_size = 8;
3809            let bytes_len = max_ordinal as usize * envelope_size;
3810            #[allow(unused_variables)]
3811            let offset = encoder.out_of_line_offset(bytes_len);
3812            let mut _prev_end_offset: usize = 0;
3813            if 1 > max_ordinal {
3814                return Ok(());
3815            }
3816
3817            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3818            // are envelope_size bytes.
3819            let cur_offset: usize = (1 - 1) * envelope_size;
3820
3821            // Zero reserved fields.
3822            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3823
3824            // Safety:
3825            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3826            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3827            //   envelope_size bytes, there is always sufficient room.
3828            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3829                self.min_size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3830                encoder,
3831                offset + cur_offset,
3832                depth,
3833            )?;
3834
3835            _prev_end_offset = cur_offset + envelope_size;
3836            if 2 > max_ordinal {
3837                return Ok(());
3838            }
3839
3840            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3841            // are envelope_size bytes.
3842            let cur_offset: usize = (2 - 1) * envelope_size;
3843
3844            // Zero reserved fields.
3845            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3846
3847            // Safety:
3848            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3849            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3850            //   envelope_size bytes, there is always sufficient room.
3851            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3852                self.max_size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3853                encoder,
3854                offset + cur_offset,
3855                depth,
3856            )?;
3857
3858            _prev_end_offset = cur_offset + envelope_size;
3859            if 3 > max_ordinal {
3860                return Ok(());
3861            }
3862
3863            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3864            // are envelope_size bytes.
3865            let cur_offset: usize = (3 - 1) * envelope_size;
3866
3867            // Zero reserved fields.
3868            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3869
3870            // Safety:
3871            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3872            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3873            //   envelope_size bytes, there is always sufficient room.
3874            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3875                self.physically_contiguous_required
3876                    .as_ref()
3877                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3878                encoder,
3879                offset + cur_offset,
3880                depth,
3881            )?;
3882
3883            _prev_end_offset = cur_offset + envelope_size;
3884            if 4 > max_ordinal {
3885                return Ok(());
3886            }
3887
3888            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3889            // are envelope_size bytes.
3890            let cur_offset: usize = (4 - 1) * envelope_size;
3891
3892            // Zero reserved fields.
3893            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3894
3895            // Safety:
3896            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3897            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3898            //   envelope_size bytes, there is always sufficient room.
3899            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3900                self.secure_required
3901                    .as_ref()
3902                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3903                encoder,
3904                offset + cur_offset,
3905                depth,
3906            )?;
3907
3908            _prev_end_offset = cur_offset + envelope_size;
3909            if 5 > max_ordinal {
3910                return Ok(());
3911            }
3912
3913            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3914            // are envelope_size bytes.
3915            let cur_offset: usize = (5 - 1) * envelope_size;
3916
3917            // Zero reserved fields.
3918            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3919
3920            // Safety:
3921            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3922            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3923            //   envelope_size bytes, there is always sufficient room.
3924            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3925                self.cpu_domain_supported
3926                    .as_ref()
3927                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3928                encoder,
3929                offset + cur_offset,
3930                depth,
3931            )?;
3932
3933            _prev_end_offset = cur_offset + envelope_size;
3934            if 6 > max_ordinal {
3935                return Ok(());
3936            }
3937
3938            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3939            // are envelope_size bytes.
3940            let cur_offset: usize = (6 - 1) * envelope_size;
3941
3942            // Zero reserved fields.
3943            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3944
3945            // Safety:
3946            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3947            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3948            //   envelope_size bytes, there is always sufficient room.
3949            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3950                self.ram_domain_supported
3951                    .as_ref()
3952                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3953                encoder,
3954                offset + cur_offset,
3955                depth,
3956            )?;
3957
3958            _prev_end_offset = cur_offset + envelope_size;
3959            if 7 > max_ordinal {
3960                return Ok(());
3961            }
3962
3963            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3964            // are envelope_size bytes.
3965            let cur_offset: usize = (7 - 1) * envelope_size;
3966
3967            // Zero reserved fields.
3968            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3969
3970            // Safety:
3971            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3972            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3973            //   envelope_size bytes, there is always sufficient room.
3974            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3975                self.inaccessible_domain_supported
3976                    .as_ref()
3977                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3978                encoder,
3979                offset + cur_offset,
3980                depth,
3981            )?;
3982
3983            _prev_end_offset = cur_offset + envelope_size;
3984            if 8 > max_ordinal {
3985                return Ok(());
3986            }
3987
3988            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3989            // are envelope_size bytes.
3990            let cur_offset: usize = (8 - 1) * envelope_size;
3991
3992            // Zero reserved fields.
3993            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3994
3995            // Safety:
3996            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3997            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3998            //   envelope_size bytes, there is always sufficient room.
3999            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Heap, 64>, D>(
4000                self.permitted_heaps.as_ref().map(
4001                    <fidl::encoding::Vector<Heap, 64> as fidl::encoding::ValueTypeMarker>::borrow,
4002                ),
4003                encoder,
4004                offset + cur_offset,
4005                depth,
4006            )?;
4007
4008            _prev_end_offset = cur_offset + envelope_size;
4009
4010            Ok(())
4011        }
4012    }
4013
4014    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4015        for BufferMemoryConstraints
4016    {
4017        #[inline(always)]
4018        fn new_empty() -> Self {
4019            Self::default()
4020        }
4021
4022        unsafe fn decode(
4023            &mut self,
4024            decoder: &mut fidl::encoding::Decoder<'_, D>,
4025            offset: usize,
4026            mut depth: fidl::encoding::Depth,
4027        ) -> fidl::Result<()> {
4028            decoder.debug_check_bounds::<Self>(offset);
4029            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4030                None => return Err(fidl::Error::NotNullable),
4031                Some(len) => len,
4032            };
4033            // Calling decoder.out_of_line_offset(0) is not allowed.
4034            if len == 0 {
4035                return Ok(());
4036            };
4037            depth.increment()?;
4038            let envelope_size = 8;
4039            let bytes_len = len * envelope_size;
4040            let offset = decoder.out_of_line_offset(bytes_len)?;
4041            // Decode the envelope for each type.
4042            let mut _next_ordinal_to_read = 0;
4043            let mut next_offset = offset;
4044            let end_offset = offset + bytes_len;
4045            _next_ordinal_to_read += 1;
4046            if next_offset >= end_offset {
4047                return Ok(());
4048            }
4049
4050            // Decode unknown envelopes for gaps in ordinals.
4051            while _next_ordinal_to_read < 1 {
4052                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4053                _next_ordinal_to_read += 1;
4054                next_offset += envelope_size;
4055            }
4056
4057            let next_out_of_line = decoder.next_out_of_line();
4058            let handles_before = decoder.remaining_handles();
4059            if let Some((inlined, num_bytes, num_handles)) =
4060                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4061            {
4062                let member_inline_size =
4063                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4064                if inlined != (member_inline_size <= 4) {
4065                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4066                }
4067                let inner_offset;
4068                let mut inner_depth = depth.clone();
4069                if inlined {
4070                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4071                    inner_offset = next_offset;
4072                } else {
4073                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4074                    inner_depth.increment()?;
4075                }
4076                let val_ref = self.min_size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4077                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4078                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4079                {
4080                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4081                }
4082                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4083                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4084                }
4085            }
4086
4087            next_offset += envelope_size;
4088            _next_ordinal_to_read += 1;
4089            if next_offset >= end_offset {
4090                return Ok(());
4091            }
4092
4093            // Decode unknown envelopes for gaps in ordinals.
4094            while _next_ordinal_to_read < 2 {
4095                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4096                _next_ordinal_to_read += 1;
4097                next_offset += envelope_size;
4098            }
4099
4100            let next_out_of_line = decoder.next_out_of_line();
4101            let handles_before = decoder.remaining_handles();
4102            if let Some((inlined, num_bytes, num_handles)) =
4103                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4104            {
4105                let member_inline_size =
4106                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4107                if inlined != (member_inline_size <= 4) {
4108                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4109                }
4110                let inner_offset;
4111                let mut inner_depth = depth.clone();
4112                if inlined {
4113                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4114                    inner_offset = next_offset;
4115                } else {
4116                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4117                    inner_depth.increment()?;
4118                }
4119                let val_ref = self.max_size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4120                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4121                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4122                {
4123                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4124                }
4125                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4126                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4127                }
4128            }
4129
4130            next_offset += envelope_size;
4131            _next_ordinal_to_read += 1;
4132            if next_offset >= end_offset {
4133                return Ok(());
4134            }
4135
4136            // Decode unknown envelopes for gaps in ordinals.
4137            while _next_ordinal_to_read < 3 {
4138                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4139                _next_ordinal_to_read += 1;
4140                next_offset += envelope_size;
4141            }
4142
4143            let next_out_of_line = decoder.next_out_of_line();
4144            let handles_before = decoder.remaining_handles();
4145            if let Some((inlined, num_bytes, num_handles)) =
4146                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4147            {
4148                let member_inline_size =
4149                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4150                if inlined != (member_inline_size <= 4) {
4151                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4152                }
4153                let inner_offset;
4154                let mut inner_depth = depth.clone();
4155                if inlined {
4156                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4157                    inner_offset = next_offset;
4158                } else {
4159                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4160                    inner_depth.increment()?;
4161                }
4162                let val_ref = self
4163                    .physically_contiguous_required
4164                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
4165                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4166                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4167                {
4168                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4169                }
4170                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4171                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4172                }
4173            }
4174
4175            next_offset += envelope_size;
4176            _next_ordinal_to_read += 1;
4177            if next_offset >= end_offset {
4178                return Ok(());
4179            }
4180
4181            // Decode unknown envelopes for gaps in ordinals.
4182            while _next_ordinal_to_read < 4 {
4183                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4184                _next_ordinal_to_read += 1;
4185                next_offset += envelope_size;
4186            }
4187
4188            let next_out_of_line = decoder.next_out_of_line();
4189            let handles_before = decoder.remaining_handles();
4190            if let Some((inlined, num_bytes, num_handles)) =
4191                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4192            {
4193                let member_inline_size =
4194                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4195                if inlined != (member_inline_size <= 4) {
4196                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4197                }
4198                let inner_offset;
4199                let mut inner_depth = depth.clone();
4200                if inlined {
4201                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4202                    inner_offset = next_offset;
4203                } else {
4204                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4205                    inner_depth.increment()?;
4206                }
4207                let val_ref = self.secure_required.get_or_insert_with(|| fidl::new_empty!(bool, D));
4208                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4209                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4210                {
4211                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4212                }
4213                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4214                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4215                }
4216            }
4217
4218            next_offset += envelope_size;
4219            _next_ordinal_to_read += 1;
4220            if next_offset >= end_offset {
4221                return Ok(());
4222            }
4223
4224            // Decode unknown envelopes for gaps in ordinals.
4225            while _next_ordinal_to_read < 5 {
4226                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4227                _next_ordinal_to_read += 1;
4228                next_offset += envelope_size;
4229            }
4230
4231            let next_out_of_line = decoder.next_out_of_line();
4232            let handles_before = decoder.remaining_handles();
4233            if let Some((inlined, num_bytes, num_handles)) =
4234                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4235            {
4236                let member_inline_size =
4237                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4238                if inlined != (member_inline_size <= 4) {
4239                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4240                }
4241                let inner_offset;
4242                let mut inner_depth = depth.clone();
4243                if inlined {
4244                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4245                    inner_offset = next_offset;
4246                } else {
4247                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4248                    inner_depth.increment()?;
4249                }
4250                let val_ref =
4251                    self.cpu_domain_supported.get_or_insert_with(|| fidl::new_empty!(bool, D));
4252                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4253                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4254                {
4255                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4256                }
4257                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4258                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4259                }
4260            }
4261
4262            next_offset += envelope_size;
4263            _next_ordinal_to_read += 1;
4264            if next_offset >= end_offset {
4265                return Ok(());
4266            }
4267
4268            // Decode unknown envelopes for gaps in ordinals.
4269            while _next_ordinal_to_read < 6 {
4270                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4271                _next_ordinal_to_read += 1;
4272                next_offset += envelope_size;
4273            }
4274
4275            let next_out_of_line = decoder.next_out_of_line();
4276            let handles_before = decoder.remaining_handles();
4277            if let Some((inlined, num_bytes, num_handles)) =
4278                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4279            {
4280                let member_inline_size =
4281                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4282                if inlined != (member_inline_size <= 4) {
4283                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4284                }
4285                let inner_offset;
4286                let mut inner_depth = depth.clone();
4287                if inlined {
4288                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4289                    inner_offset = next_offset;
4290                } else {
4291                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4292                    inner_depth.increment()?;
4293                }
4294                let val_ref =
4295                    self.ram_domain_supported.get_or_insert_with(|| fidl::new_empty!(bool, D));
4296                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4297                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4298                {
4299                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4300                }
4301                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4302                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4303                }
4304            }
4305
4306            next_offset += envelope_size;
4307            _next_ordinal_to_read += 1;
4308            if next_offset >= end_offset {
4309                return Ok(());
4310            }
4311
4312            // Decode unknown envelopes for gaps in ordinals.
4313            while _next_ordinal_to_read < 7 {
4314                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4315                _next_ordinal_to_read += 1;
4316                next_offset += envelope_size;
4317            }
4318
4319            let next_out_of_line = decoder.next_out_of_line();
4320            let handles_before = decoder.remaining_handles();
4321            if let Some((inlined, num_bytes, num_handles)) =
4322                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4323            {
4324                let member_inline_size =
4325                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4326                if inlined != (member_inline_size <= 4) {
4327                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4328                }
4329                let inner_offset;
4330                let mut inner_depth = depth.clone();
4331                if inlined {
4332                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4333                    inner_offset = next_offset;
4334                } else {
4335                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4336                    inner_depth.increment()?;
4337                }
4338                let val_ref = self
4339                    .inaccessible_domain_supported
4340                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
4341                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4342                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4343                {
4344                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4345                }
4346                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4347                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4348                }
4349            }
4350
4351            next_offset += envelope_size;
4352            _next_ordinal_to_read += 1;
4353            if next_offset >= end_offset {
4354                return Ok(());
4355            }
4356
4357            // Decode unknown envelopes for gaps in ordinals.
4358            while _next_ordinal_to_read < 8 {
4359                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4360                _next_ordinal_to_read += 1;
4361                next_offset += envelope_size;
4362            }
4363
4364            let next_out_of_line = decoder.next_out_of_line();
4365            let handles_before = decoder.remaining_handles();
4366            if let Some((inlined, num_bytes, num_handles)) =
4367                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4368            {
4369                let member_inline_size =
4370                    <fidl::encoding::Vector<Heap, 64> as fidl::encoding::TypeMarker>::inline_size(
4371                        decoder.context,
4372                    );
4373                if inlined != (member_inline_size <= 4) {
4374                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4375                }
4376                let inner_offset;
4377                let mut inner_depth = depth.clone();
4378                if inlined {
4379                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4380                    inner_offset = next_offset;
4381                } else {
4382                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4383                    inner_depth.increment()?;
4384                }
4385                let val_ref = self
4386                    .permitted_heaps
4387                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Heap, 64>, D));
4388                fidl::decode!(fidl::encoding::Vector<Heap, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
4389                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4390                {
4391                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4392                }
4393                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4394                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4395                }
4396            }
4397
4398            next_offset += envelope_size;
4399
4400            // Decode the remaining unknown envelopes.
4401            while next_offset < end_offset {
4402                _next_ordinal_to_read += 1;
4403                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4404                next_offset += envelope_size;
4405            }
4406
4407            Ok(())
4408        }
4409    }
4410
4411    impl BufferMemorySettings {
4412        #[inline(always)]
4413        fn max_ordinal_present(&self) -> u64 {
4414            if let Some(_) = self.raw_vmo_size {
4415                return 6;
4416            }
4417            if let Some(_) = self.heap {
4418                return 5;
4419            }
4420            if let Some(_) = self.coherency_domain {
4421                return 4;
4422            }
4423            if let Some(_) = self.is_secure {
4424                return 3;
4425            }
4426            if let Some(_) = self.is_physically_contiguous {
4427                return 2;
4428            }
4429            if let Some(_) = self.size_bytes {
4430                return 1;
4431            }
4432            0
4433        }
4434    }
4435
4436    impl fidl::encoding::ValueTypeMarker for BufferMemorySettings {
4437        type Borrowed<'a> = &'a Self;
4438        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4439            value
4440        }
4441    }
4442
4443    unsafe impl fidl::encoding::TypeMarker for BufferMemorySettings {
4444        type Owned = Self;
4445
4446        #[inline(always)]
4447        fn inline_align(_context: fidl::encoding::Context) -> usize {
4448            8
4449        }
4450
4451        #[inline(always)]
4452        fn inline_size(_context: fidl::encoding::Context) -> usize {
4453            16
4454        }
4455    }
4456
4457    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BufferMemorySettings, D>
4458        for &BufferMemorySettings
4459    {
4460        unsafe fn encode(
4461            self,
4462            encoder: &mut fidl::encoding::Encoder<'_, D>,
4463            offset: usize,
4464            mut depth: fidl::encoding::Depth,
4465        ) -> fidl::Result<()> {
4466            encoder.debug_check_bounds::<BufferMemorySettings>(offset);
4467            // Vector header
4468            let max_ordinal: u64 = self.max_ordinal_present();
4469            encoder.write_num(max_ordinal, offset);
4470            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4471            // Calling encoder.out_of_line_offset(0) is not allowed.
4472            if max_ordinal == 0 {
4473                return Ok(());
4474            }
4475            depth.increment()?;
4476            let envelope_size = 8;
4477            let bytes_len = max_ordinal as usize * envelope_size;
4478            #[allow(unused_variables)]
4479            let offset = encoder.out_of_line_offset(bytes_len);
4480            let mut _prev_end_offset: usize = 0;
4481            if 1 > max_ordinal {
4482                return Ok(());
4483            }
4484
4485            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4486            // are envelope_size bytes.
4487            let cur_offset: usize = (1 - 1) * envelope_size;
4488
4489            // Zero reserved fields.
4490            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4491
4492            // Safety:
4493            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4494            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4495            //   envelope_size bytes, there is always sufficient room.
4496            fidl::encoding::encode_in_envelope_optional::<u64, D>(
4497                self.size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4498                encoder,
4499                offset + cur_offset,
4500                depth,
4501            )?;
4502
4503            _prev_end_offset = cur_offset + envelope_size;
4504            if 2 > max_ordinal {
4505                return Ok(());
4506            }
4507
4508            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4509            // are envelope_size bytes.
4510            let cur_offset: usize = (2 - 1) * envelope_size;
4511
4512            // Zero reserved fields.
4513            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4514
4515            // Safety:
4516            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4517            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4518            //   envelope_size bytes, there is always sufficient room.
4519            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4520                self.is_physically_contiguous
4521                    .as_ref()
4522                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4523                encoder,
4524                offset + cur_offset,
4525                depth,
4526            )?;
4527
4528            _prev_end_offset = cur_offset + envelope_size;
4529            if 3 > max_ordinal {
4530                return Ok(());
4531            }
4532
4533            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4534            // are envelope_size bytes.
4535            let cur_offset: usize = (3 - 1) * envelope_size;
4536
4537            // Zero reserved fields.
4538            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4539
4540            // Safety:
4541            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4542            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4543            //   envelope_size bytes, there is always sufficient room.
4544            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4545                self.is_secure.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4546                encoder,
4547                offset + cur_offset,
4548                depth,
4549            )?;
4550
4551            _prev_end_offset = cur_offset + envelope_size;
4552            if 4 > max_ordinal {
4553                return Ok(());
4554            }
4555
4556            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4557            // are envelope_size bytes.
4558            let cur_offset: usize = (4 - 1) * envelope_size;
4559
4560            // Zero reserved fields.
4561            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4562
4563            // Safety:
4564            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4565            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4566            //   envelope_size bytes, there is always sufficient room.
4567            fidl::encoding::encode_in_envelope_optional::<CoherencyDomain, D>(
4568                self.coherency_domain
4569                    .as_ref()
4570                    .map(<CoherencyDomain as fidl::encoding::ValueTypeMarker>::borrow),
4571                encoder,
4572                offset + cur_offset,
4573                depth,
4574            )?;
4575
4576            _prev_end_offset = cur_offset + envelope_size;
4577            if 5 > max_ordinal {
4578                return Ok(());
4579            }
4580
4581            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4582            // are envelope_size bytes.
4583            let cur_offset: usize = (5 - 1) * envelope_size;
4584
4585            // Zero reserved fields.
4586            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4587
4588            // Safety:
4589            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4590            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4591            //   envelope_size bytes, there is always sufficient room.
4592            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
4593                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
4594                encoder,
4595                offset + cur_offset,
4596                depth,
4597            )?;
4598
4599            _prev_end_offset = cur_offset + envelope_size;
4600            if 6 > max_ordinal {
4601                return Ok(());
4602            }
4603
4604            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4605            // are envelope_size bytes.
4606            let cur_offset: usize = (6 - 1) * envelope_size;
4607
4608            // Zero reserved fields.
4609            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4610
4611            // Safety:
4612            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4613            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4614            //   envelope_size bytes, there is always sufficient room.
4615            fidl::encoding::encode_in_envelope_optional::<u64, D>(
4616                self.raw_vmo_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4617                encoder,
4618                offset + cur_offset,
4619                depth,
4620            )?;
4621
4622            _prev_end_offset = cur_offset + envelope_size;
4623
4624            Ok(())
4625        }
4626    }
4627
4628    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferMemorySettings {
4629        #[inline(always)]
4630        fn new_empty() -> Self {
4631            Self::default()
4632        }
4633
4634        unsafe fn decode(
4635            &mut self,
4636            decoder: &mut fidl::encoding::Decoder<'_, D>,
4637            offset: usize,
4638            mut depth: fidl::encoding::Depth,
4639        ) -> fidl::Result<()> {
4640            decoder.debug_check_bounds::<Self>(offset);
4641            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4642                None => return Err(fidl::Error::NotNullable),
4643                Some(len) => len,
4644            };
4645            // Calling decoder.out_of_line_offset(0) is not allowed.
4646            if len == 0 {
4647                return Ok(());
4648            };
4649            depth.increment()?;
4650            let envelope_size = 8;
4651            let bytes_len = len * envelope_size;
4652            let offset = decoder.out_of_line_offset(bytes_len)?;
4653            // Decode the envelope for each type.
4654            let mut _next_ordinal_to_read = 0;
4655            let mut next_offset = offset;
4656            let end_offset = offset + bytes_len;
4657            _next_ordinal_to_read += 1;
4658            if next_offset >= end_offset {
4659                return Ok(());
4660            }
4661
4662            // Decode unknown envelopes for gaps in ordinals.
4663            while _next_ordinal_to_read < 1 {
4664                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4665                _next_ordinal_to_read += 1;
4666                next_offset += envelope_size;
4667            }
4668
4669            let next_out_of_line = decoder.next_out_of_line();
4670            let handles_before = decoder.remaining_handles();
4671            if let Some((inlined, num_bytes, num_handles)) =
4672                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4673            {
4674                let member_inline_size =
4675                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4676                if inlined != (member_inline_size <= 4) {
4677                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4678                }
4679                let inner_offset;
4680                let mut inner_depth = depth.clone();
4681                if inlined {
4682                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4683                    inner_offset = next_offset;
4684                } else {
4685                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4686                    inner_depth.increment()?;
4687                }
4688                let val_ref = self.size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4689                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4690                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4691                {
4692                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4693                }
4694                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4695                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4696                }
4697            }
4698
4699            next_offset += envelope_size;
4700            _next_ordinal_to_read += 1;
4701            if next_offset >= end_offset {
4702                return Ok(());
4703            }
4704
4705            // Decode unknown envelopes for gaps in ordinals.
4706            while _next_ordinal_to_read < 2 {
4707                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4708                _next_ordinal_to_read += 1;
4709                next_offset += envelope_size;
4710            }
4711
4712            let next_out_of_line = decoder.next_out_of_line();
4713            let handles_before = decoder.remaining_handles();
4714            if let Some((inlined, num_bytes, num_handles)) =
4715                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4716            {
4717                let member_inline_size =
4718                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4719                if inlined != (member_inline_size <= 4) {
4720                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4721                }
4722                let inner_offset;
4723                let mut inner_depth = depth.clone();
4724                if inlined {
4725                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4726                    inner_offset = next_offset;
4727                } else {
4728                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4729                    inner_depth.increment()?;
4730                }
4731                let val_ref =
4732                    self.is_physically_contiguous.get_or_insert_with(|| fidl::new_empty!(bool, D));
4733                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4734                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4735                {
4736                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4737                }
4738                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4739                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4740                }
4741            }
4742
4743            next_offset += envelope_size;
4744            _next_ordinal_to_read += 1;
4745            if next_offset >= end_offset {
4746                return Ok(());
4747            }
4748
4749            // Decode unknown envelopes for gaps in ordinals.
4750            while _next_ordinal_to_read < 3 {
4751                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4752                _next_ordinal_to_read += 1;
4753                next_offset += envelope_size;
4754            }
4755
4756            let next_out_of_line = decoder.next_out_of_line();
4757            let handles_before = decoder.remaining_handles();
4758            if let Some((inlined, num_bytes, num_handles)) =
4759                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4760            {
4761                let member_inline_size =
4762                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4763                if inlined != (member_inline_size <= 4) {
4764                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4765                }
4766                let inner_offset;
4767                let mut inner_depth = depth.clone();
4768                if inlined {
4769                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4770                    inner_offset = next_offset;
4771                } else {
4772                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4773                    inner_depth.increment()?;
4774                }
4775                let val_ref = self.is_secure.get_or_insert_with(|| fidl::new_empty!(bool, D));
4776                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4777                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4778                {
4779                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4780                }
4781                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4782                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4783                }
4784            }
4785
4786            next_offset += envelope_size;
4787            _next_ordinal_to_read += 1;
4788            if next_offset >= end_offset {
4789                return Ok(());
4790            }
4791
4792            // Decode unknown envelopes for gaps in ordinals.
4793            while _next_ordinal_to_read < 4 {
4794                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4795                _next_ordinal_to_read += 1;
4796                next_offset += envelope_size;
4797            }
4798
4799            let next_out_of_line = decoder.next_out_of_line();
4800            let handles_before = decoder.remaining_handles();
4801            if let Some((inlined, num_bytes, num_handles)) =
4802                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4803            {
4804                let member_inline_size =
4805                    <CoherencyDomain as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4806                if inlined != (member_inline_size <= 4) {
4807                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4808                }
4809                let inner_offset;
4810                let mut inner_depth = depth.clone();
4811                if inlined {
4812                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4813                    inner_offset = next_offset;
4814                } else {
4815                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4816                    inner_depth.increment()?;
4817                }
4818                let val_ref = self
4819                    .coherency_domain
4820                    .get_or_insert_with(|| fidl::new_empty!(CoherencyDomain, D));
4821                fidl::decode!(CoherencyDomain, D, val_ref, decoder, inner_offset, inner_depth)?;
4822                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4823                {
4824                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4825                }
4826                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4827                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4828                }
4829            }
4830
4831            next_offset += envelope_size;
4832            _next_ordinal_to_read += 1;
4833            if next_offset >= end_offset {
4834                return Ok(());
4835            }
4836
4837            // Decode unknown envelopes for gaps in ordinals.
4838            while _next_ordinal_to_read < 5 {
4839                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4840                _next_ordinal_to_read += 1;
4841                next_offset += envelope_size;
4842            }
4843
4844            let next_out_of_line = decoder.next_out_of_line();
4845            let handles_before = decoder.remaining_handles();
4846            if let Some((inlined, num_bytes, num_handles)) =
4847                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4848            {
4849                let member_inline_size =
4850                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4851                if inlined != (member_inline_size <= 4) {
4852                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4853                }
4854                let inner_offset;
4855                let mut inner_depth = depth.clone();
4856                if inlined {
4857                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4858                    inner_offset = next_offset;
4859                } else {
4860                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4861                    inner_depth.increment()?;
4862                }
4863                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
4864                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
4865                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4866                {
4867                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4868                }
4869                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4870                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4871                }
4872            }
4873
4874            next_offset += envelope_size;
4875            _next_ordinal_to_read += 1;
4876            if next_offset >= end_offset {
4877                return Ok(());
4878            }
4879
4880            // Decode unknown envelopes for gaps in ordinals.
4881            while _next_ordinal_to_read < 6 {
4882                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4883                _next_ordinal_to_read += 1;
4884                next_offset += envelope_size;
4885            }
4886
4887            let next_out_of_line = decoder.next_out_of_line();
4888            let handles_before = decoder.remaining_handles();
4889            if let Some((inlined, num_bytes, num_handles)) =
4890                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4891            {
4892                let member_inline_size =
4893                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4894                if inlined != (member_inline_size <= 4) {
4895                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4896                }
4897                let inner_offset;
4898                let mut inner_depth = depth.clone();
4899                if inlined {
4900                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4901                    inner_offset = next_offset;
4902                } else {
4903                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4904                    inner_depth.increment()?;
4905                }
4906                let val_ref = self.raw_vmo_size.get_or_insert_with(|| fidl::new_empty!(u64, D));
4907                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4908                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4909                {
4910                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4911                }
4912                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4913                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4914                }
4915            }
4916
4917            next_offset += envelope_size;
4918
4919            // Decode the remaining unknown envelopes.
4920            while next_offset < end_offset {
4921                _next_ordinal_to_read += 1;
4922                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4923                next_offset += envelope_size;
4924            }
4925
4926            Ok(())
4927        }
4928    }
4929
4930    impl BufferUsage {
4931        #[inline(always)]
4932        fn max_ordinal_present(&self) -> u64 {
4933            if let Some(_) = self.video {
4934                return 5;
4935            }
4936            if let Some(_) = self.display {
4937                return 4;
4938            }
4939            if let Some(_) = self.vulkan {
4940                return 3;
4941            }
4942            if let Some(_) = self.cpu {
4943                return 2;
4944            }
4945            if let Some(_) = self.none {
4946                return 1;
4947            }
4948            0
4949        }
4950    }
4951
4952    impl fidl::encoding::ValueTypeMarker for BufferUsage {
4953        type Borrowed<'a> = &'a Self;
4954        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4955            value
4956        }
4957    }
4958
4959    unsafe impl fidl::encoding::TypeMarker for BufferUsage {
4960        type Owned = Self;
4961
4962        #[inline(always)]
4963        fn inline_align(_context: fidl::encoding::Context) -> usize {
4964            8
4965        }
4966
4967        #[inline(always)]
4968        fn inline_size(_context: fidl::encoding::Context) -> usize {
4969            16
4970        }
4971    }
4972
4973    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BufferUsage, D>
4974        for &BufferUsage
4975    {
4976        unsafe fn encode(
4977            self,
4978            encoder: &mut fidl::encoding::Encoder<'_, D>,
4979            offset: usize,
4980            mut depth: fidl::encoding::Depth,
4981        ) -> fidl::Result<()> {
4982            encoder.debug_check_bounds::<BufferUsage>(offset);
4983            // Vector header
4984            let max_ordinal: u64 = self.max_ordinal_present();
4985            encoder.write_num(max_ordinal, offset);
4986            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4987            // Calling encoder.out_of_line_offset(0) is not allowed.
4988            if max_ordinal == 0 {
4989                return Ok(());
4990            }
4991            depth.increment()?;
4992            let envelope_size = 8;
4993            let bytes_len = max_ordinal as usize * envelope_size;
4994            #[allow(unused_variables)]
4995            let offset = encoder.out_of_line_offset(bytes_len);
4996            let mut _prev_end_offset: usize = 0;
4997            if 1 > max_ordinal {
4998                return Ok(());
4999            }
5000
5001            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5002            // are envelope_size bytes.
5003            let cur_offset: usize = (1 - 1) * envelope_size;
5004
5005            // Zero reserved fields.
5006            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5007
5008            // Safety:
5009            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5010            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5011            //   envelope_size bytes, there is always sufficient room.
5012            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5013                self.none.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5014                encoder,
5015                offset + cur_offset,
5016                depth,
5017            )?;
5018
5019            _prev_end_offset = cur_offset + envelope_size;
5020            if 2 > max_ordinal {
5021                return Ok(());
5022            }
5023
5024            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5025            // are envelope_size bytes.
5026            let cur_offset: usize = (2 - 1) * envelope_size;
5027
5028            // Zero reserved fields.
5029            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5030
5031            // Safety:
5032            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5033            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5034            //   envelope_size bytes, there is always sufficient room.
5035            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5036                self.cpu.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5037                encoder,
5038                offset + cur_offset,
5039                depth,
5040            )?;
5041
5042            _prev_end_offset = cur_offset + envelope_size;
5043            if 3 > max_ordinal {
5044                return Ok(());
5045            }
5046
5047            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5048            // are envelope_size bytes.
5049            let cur_offset: usize = (3 - 1) * envelope_size;
5050
5051            // Zero reserved fields.
5052            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5053
5054            // Safety:
5055            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5056            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5057            //   envelope_size bytes, there is always sufficient room.
5058            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5059                self.vulkan.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5060                encoder,
5061                offset + cur_offset,
5062                depth,
5063            )?;
5064
5065            _prev_end_offset = cur_offset + envelope_size;
5066            if 4 > max_ordinal {
5067                return Ok(());
5068            }
5069
5070            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5071            // are envelope_size bytes.
5072            let cur_offset: usize = (4 - 1) * envelope_size;
5073
5074            // Zero reserved fields.
5075            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5076
5077            // Safety:
5078            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5079            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5080            //   envelope_size bytes, there is always sufficient room.
5081            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5082                self.display.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5083                encoder,
5084                offset + cur_offset,
5085                depth,
5086            )?;
5087
5088            _prev_end_offset = cur_offset + envelope_size;
5089            if 5 > max_ordinal {
5090                return Ok(());
5091            }
5092
5093            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5094            // are envelope_size bytes.
5095            let cur_offset: usize = (5 - 1) * envelope_size;
5096
5097            // Zero reserved fields.
5098            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5099
5100            // Safety:
5101            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5102            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5103            //   envelope_size bytes, there is always sufficient room.
5104            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5105                self.video.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5106                encoder,
5107                offset + cur_offset,
5108                depth,
5109            )?;
5110
5111            _prev_end_offset = cur_offset + envelope_size;
5112
5113            Ok(())
5114        }
5115    }
5116
5117    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferUsage {
5118        #[inline(always)]
5119        fn new_empty() -> Self {
5120            Self::default()
5121        }
5122
5123        unsafe fn decode(
5124            &mut self,
5125            decoder: &mut fidl::encoding::Decoder<'_, D>,
5126            offset: usize,
5127            mut depth: fidl::encoding::Depth,
5128        ) -> fidl::Result<()> {
5129            decoder.debug_check_bounds::<Self>(offset);
5130            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5131                None => return Err(fidl::Error::NotNullable),
5132                Some(len) => len,
5133            };
5134            // Calling decoder.out_of_line_offset(0) is not allowed.
5135            if len == 0 {
5136                return Ok(());
5137            };
5138            depth.increment()?;
5139            let envelope_size = 8;
5140            let bytes_len = len * envelope_size;
5141            let offset = decoder.out_of_line_offset(bytes_len)?;
5142            // Decode the envelope for each type.
5143            let mut _next_ordinal_to_read = 0;
5144            let mut next_offset = offset;
5145            let end_offset = offset + bytes_len;
5146            _next_ordinal_to_read += 1;
5147            if next_offset >= end_offset {
5148                return Ok(());
5149            }
5150
5151            // Decode unknown envelopes for gaps in ordinals.
5152            while _next_ordinal_to_read < 1 {
5153                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5154                _next_ordinal_to_read += 1;
5155                next_offset += envelope_size;
5156            }
5157
5158            let next_out_of_line = decoder.next_out_of_line();
5159            let handles_before = decoder.remaining_handles();
5160            if let Some((inlined, num_bytes, num_handles)) =
5161                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5162            {
5163                let member_inline_size =
5164                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5165                if inlined != (member_inline_size <= 4) {
5166                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5167                }
5168                let inner_offset;
5169                let mut inner_depth = depth.clone();
5170                if inlined {
5171                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5172                    inner_offset = next_offset;
5173                } else {
5174                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5175                    inner_depth.increment()?;
5176                }
5177                let val_ref = self.none.get_or_insert_with(|| fidl::new_empty!(u32, D));
5178                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5179                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5180                {
5181                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5182                }
5183                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5184                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5185                }
5186            }
5187
5188            next_offset += envelope_size;
5189            _next_ordinal_to_read += 1;
5190            if next_offset >= end_offset {
5191                return Ok(());
5192            }
5193
5194            // Decode unknown envelopes for gaps in ordinals.
5195            while _next_ordinal_to_read < 2 {
5196                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5197                _next_ordinal_to_read += 1;
5198                next_offset += envelope_size;
5199            }
5200
5201            let next_out_of_line = decoder.next_out_of_line();
5202            let handles_before = decoder.remaining_handles();
5203            if let Some((inlined, num_bytes, num_handles)) =
5204                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5205            {
5206                let member_inline_size =
5207                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5208                if inlined != (member_inline_size <= 4) {
5209                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5210                }
5211                let inner_offset;
5212                let mut inner_depth = depth.clone();
5213                if inlined {
5214                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5215                    inner_offset = next_offset;
5216                } else {
5217                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5218                    inner_depth.increment()?;
5219                }
5220                let val_ref = self.cpu.get_or_insert_with(|| fidl::new_empty!(u32, D));
5221                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5222                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5223                {
5224                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5225                }
5226                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5227                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5228                }
5229            }
5230
5231            next_offset += envelope_size;
5232            _next_ordinal_to_read += 1;
5233            if next_offset >= end_offset {
5234                return Ok(());
5235            }
5236
5237            // Decode unknown envelopes for gaps in ordinals.
5238            while _next_ordinal_to_read < 3 {
5239                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5240                _next_ordinal_to_read += 1;
5241                next_offset += envelope_size;
5242            }
5243
5244            let next_out_of_line = decoder.next_out_of_line();
5245            let handles_before = decoder.remaining_handles();
5246            if let Some((inlined, num_bytes, num_handles)) =
5247                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5248            {
5249                let member_inline_size =
5250                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5251                if inlined != (member_inline_size <= 4) {
5252                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5253                }
5254                let inner_offset;
5255                let mut inner_depth = depth.clone();
5256                if inlined {
5257                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5258                    inner_offset = next_offset;
5259                } else {
5260                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5261                    inner_depth.increment()?;
5262                }
5263                let val_ref = self.vulkan.get_or_insert_with(|| fidl::new_empty!(u32, D));
5264                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5265                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5266                {
5267                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5268                }
5269                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5270                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5271                }
5272            }
5273
5274            next_offset += envelope_size;
5275            _next_ordinal_to_read += 1;
5276            if next_offset >= end_offset {
5277                return Ok(());
5278            }
5279
5280            // Decode unknown envelopes for gaps in ordinals.
5281            while _next_ordinal_to_read < 4 {
5282                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5283                _next_ordinal_to_read += 1;
5284                next_offset += envelope_size;
5285            }
5286
5287            let next_out_of_line = decoder.next_out_of_line();
5288            let handles_before = decoder.remaining_handles();
5289            if let Some((inlined, num_bytes, num_handles)) =
5290                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5291            {
5292                let member_inline_size =
5293                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5294                if inlined != (member_inline_size <= 4) {
5295                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5296                }
5297                let inner_offset;
5298                let mut inner_depth = depth.clone();
5299                if inlined {
5300                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5301                    inner_offset = next_offset;
5302                } else {
5303                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5304                    inner_depth.increment()?;
5305                }
5306                let val_ref = self.display.get_or_insert_with(|| fidl::new_empty!(u32, D));
5307                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5308                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5309                {
5310                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5311                }
5312                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5313                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5314                }
5315            }
5316
5317            next_offset += envelope_size;
5318            _next_ordinal_to_read += 1;
5319            if next_offset >= end_offset {
5320                return Ok(());
5321            }
5322
5323            // Decode unknown envelopes for gaps in ordinals.
5324            while _next_ordinal_to_read < 5 {
5325                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5326                _next_ordinal_to_read += 1;
5327                next_offset += envelope_size;
5328            }
5329
5330            let next_out_of_line = decoder.next_out_of_line();
5331            let handles_before = decoder.remaining_handles();
5332            if let Some((inlined, num_bytes, num_handles)) =
5333                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5334            {
5335                let member_inline_size =
5336                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5337                if inlined != (member_inline_size <= 4) {
5338                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5339                }
5340                let inner_offset;
5341                let mut inner_depth = depth.clone();
5342                if inlined {
5343                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5344                    inner_offset = next_offset;
5345                } else {
5346                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5347                    inner_depth.increment()?;
5348                }
5349                let val_ref = self.video.get_or_insert_with(|| fidl::new_empty!(u32, D));
5350                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5351                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5352                {
5353                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5354                }
5355                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5356                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5357                }
5358            }
5359
5360            next_offset += envelope_size;
5361
5362            // Decode the remaining unknown envelopes.
5363            while next_offset < end_offset {
5364                _next_ordinal_to_read += 1;
5365                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5366                next_offset += envelope_size;
5367            }
5368
5369            Ok(())
5370        }
5371    }
5372
5373    impl Config {
5374        #[inline(always)]
5375        fn max_ordinal_present(&self) -> u64 {
5376            if let Some(_) = self.format_costs {
5377                return 1;
5378            }
5379            0
5380        }
5381    }
5382
5383    impl fidl::encoding::ValueTypeMarker for Config {
5384        type Borrowed<'a> = &'a Self;
5385        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5386            value
5387        }
5388    }
5389
5390    unsafe impl fidl::encoding::TypeMarker for Config {
5391        type Owned = Self;
5392
5393        #[inline(always)]
5394        fn inline_align(_context: fidl::encoding::Context) -> usize {
5395            8
5396        }
5397
5398        #[inline(always)]
5399        fn inline_size(_context: fidl::encoding::Context) -> usize {
5400            16
5401        }
5402    }
5403
5404    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
5405        unsafe fn encode(
5406            self,
5407            encoder: &mut fidl::encoding::Encoder<'_, D>,
5408            offset: usize,
5409            mut depth: fidl::encoding::Depth,
5410        ) -> fidl::Result<()> {
5411            encoder.debug_check_bounds::<Config>(offset);
5412            // Vector header
5413            let max_ordinal: u64 = self.max_ordinal_present();
5414            encoder.write_num(max_ordinal, offset);
5415            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5416            // Calling encoder.out_of_line_offset(0) is not allowed.
5417            if max_ordinal == 0 {
5418                return Ok(());
5419            }
5420            depth.increment()?;
5421            let envelope_size = 8;
5422            let bytes_len = max_ordinal as usize * envelope_size;
5423            #[allow(unused_variables)]
5424            let offset = encoder.out_of_line_offset(bytes_len);
5425            let mut _prev_end_offset: usize = 0;
5426            if 1 > max_ordinal {
5427                return Ok(());
5428            }
5429
5430            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5431            // are envelope_size bytes.
5432            let cur_offset: usize = (1 - 1) * envelope_size;
5433
5434            // Zero reserved fields.
5435            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5436
5437            // Safety:
5438            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5439            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5440            //   envelope_size bytes, there is always sufficient room.
5441            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<FormatCostEntry>, D>(
5442            self.format_costs.as_ref().map(<fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::ValueTypeMarker>::borrow),
5443            encoder, offset + cur_offset, depth
5444        )?;
5445
5446            _prev_end_offset = cur_offset + envelope_size;
5447
5448            Ok(())
5449        }
5450    }
5451
5452    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
5453        #[inline(always)]
5454        fn new_empty() -> Self {
5455            Self::default()
5456        }
5457
5458        unsafe fn decode(
5459            &mut self,
5460            decoder: &mut fidl::encoding::Decoder<'_, D>,
5461            offset: usize,
5462            mut depth: fidl::encoding::Depth,
5463        ) -> fidl::Result<()> {
5464            decoder.debug_check_bounds::<Self>(offset);
5465            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5466                None => return Err(fidl::Error::NotNullable),
5467                Some(len) => len,
5468            };
5469            // Calling decoder.out_of_line_offset(0) is not allowed.
5470            if len == 0 {
5471                return Ok(());
5472            };
5473            depth.increment()?;
5474            let envelope_size = 8;
5475            let bytes_len = len * envelope_size;
5476            let offset = decoder.out_of_line_offset(bytes_len)?;
5477            // Decode the envelope for each type.
5478            let mut _next_ordinal_to_read = 0;
5479            let mut next_offset = offset;
5480            let end_offset = offset + bytes_len;
5481            _next_ordinal_to_read += 1;
5482            if next_offset >= end_offset {
5483                return Ok(());
5484            }
5485
5486            // Decode unknown envelopes for gaps in ordinals.
5487            while _next_ordinal_to_read < 1 {
5488                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5489                _next_ordinal_to_read += 1;
5490                next_offset += envelope_size;
5491            }
5492
5493            let next_out_of_line = decoder.next_out_of_line();
5494            let handles_before = decoder.remaining_handles();
5495            if let Some((inlined, num_bytes, num_handles)) =
5496                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5497            {
5498                let member_inline_size = <fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5499                if inlined != (member_inline_size <= 4) {
5500                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5501                }
5502                let inner_offset;
5503                let mut inner_depth = depth.clone();
5504                if inlined {
5505                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5506                    inner_offset = next_offset;
5507                } else {
5508                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5509                    inner_depth.increment()?;
5510                }
5511                let val_ref = self.format_costs.get_or_insert_with(|| {
5512                    fidl::new_empty!(fidl::encoding::UnboundedVector<FormatCostEntry>, D)
5513                });
5514                fidl::decode!(
5515                    fidl::encoding::UnboundedVector<FormatCostEntry>,
5516                    D,
5517                    val_ref,
5518                    decoder,
5519                    inner_offset,
5520                    inner_depth
5521                )?;
5522                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5523                {
5524                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5525                }
5526                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5527                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5528                }
5529            }
5530
5531            next_offset += envelope_size;
5532
5533            // Decode the remaining unknown envelopes.
5534            while next_offset < end_offset {
5535                _next_ordinal_to_read += 1;
5536                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5537                next_offset += envelope_size;
5538            }
5539
5540            Ok(())
5541        }
5542    }
5543
5544    impl DynamicSecureHeap {
5545        #[inline(always)]
5546        fn max_ordinal_present(&self) -> u64 {
5547            if let Some(_) = self.heap {
5548                return 1;
5549            }
5550            0
5551        }
5552    }
5553
5554    impl fidl::encoding::ValueTypeMarker for DynamicSecureHeap {
5555        type Borrowed<'a> = &'a Self;
5556        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5557            value
5558        }
5559    }
5560
5561    unsafe impl fidl::encoding::TypeMarker for DynamicSecureHeap {
5562        type Owned = Self;
5563
5564        #[inline(always)]
5565        fn inline_align(_context: fidl::encoding::Context) -> usize {
5566            8
5567        }
5568
5569        #[inline(always)]
5570        fn inline_size(_context: fidl::encoding::Context) -> usize {
5571            16
5572        }
5573    }
5574
5575    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DynamicSecureHeap, D>
5576        for &DynamicSecureHeap
5577    {
5578        unsafe fn encode(
5579            self,
5580            encoder: &mut fidl::encoding::Encoder<'_, D>,
5581            offset: usize,
5582            mut depth: fidl::encoding::Depth,
5583        ) -> fidl::Result<()> {
5584            encoder.debug_check_bounds::<DynamicSecureHeap>(offset);
5585            // Vector header
5586            let max_ordinal: u64 = self.max_ordinal_present();
5587            encoder.write_num(max_ordinal, offset);
5588            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5589            // Calling encoder.out_of_line_offset(0) is not allowed.
5590            if max_ordinal == 0 {
5591                return Ok(());
5592            }
5593            depth.increment()?;
5594            let envelope_size = 8;
5595            let bytes_len = max_ordinal as usize * envelope_size;
5596            #[allow(unused_variables)]
5597            let offset = encoder.out_of_line_offset(bytes_len);
5598            let mut _prev_end_offset: usize = 0;
5599            if 1 > max_ordinal {
5600                return Ok(());
5601            }
5602
5603            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5604            // are envelope_size bytes.
5605            let cur_offset: usize = (1 - 1) * envelope_size;
5606
5607            // Zero reserved fields.
5608            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5609
5610            // Safety:
5611            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5612            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5613            //   envelope_size bytes, there is always sufficient room.
5614            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
5615                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
5616                encoder,
5617                offset + cur_offset,
5618                depth,
5619            )?;
5620
5621            _prev_end_offset = cur_offset + envelope_size;
5622
5623            Ok(())
5624        }
5625    }
5626
5627    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DynamicSecureHeap {
5628        #[inline(always)]
5629        fn new_empty() -> Self {
5630            Self::default()
5631        }
5632
5633        unsafe fn decode(
5634            &mut self,
5635            decoder: &mut fidl::encoding::Decoder<'_, D>,
5636            offset: usize,
5637            mut depth: fidl::encoding::Depth,
5638        ) -> fidl::Result<()> {
5639            decoder.debug_check_bounds::<Self>(offset);
5640            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5641                None => return Err(fidl::Error::NotNullable),
5642                Some(len) => len,
5643            };
5644            // Calling decoder.out_of_line_offset(0) is not allowed.
5645            if len == 0 {
5646                return Ok(());
5647            };
5648            depth.increment()?;
5649            let envelope_size = 8;
5650            let bytes_len = len * envelope_size;
5651            let offset = decoder.out_of_line_offset(bytes_len)?;
5652            // Decode the envelope for each type.
5653            let mut _next_ordinal_to_read = 0;
5654            let mut next_offset = offset;
5655            let end_offset = offset + bytes_len;
5656            _next_ordinal_to_read += 1;
5657            if next_offset >= end_offset {
5658                return Ok(());
5659            }
5660
5661            // Decode unknown envelopes for gaps in ordinals.
5662            while _next_ordinal_to_read < 1 {
5663                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5664                _next_ordinal_to_read += 1;
5665                next_offset += envelope_size;
5666            }
5667
5668            let next_out_of_line = decoder.next_out_of_line();
5669            let handles_before = decoder.remaining_handles();
5670            if let Some((inlined, num_bytes, num_handles)) =
5671                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5672            {
5673                let member_inline_size =
5674                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5675                if inlined != (member_inline_size <= 4) {
5676                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5677                }
5678                let inner_offset;
5679                let mut inner_depth = depth.clone();
5680                if inlined {
5681                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5682                    inner_offset = next_offset;
5683                } else {
5684                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5685                    inner_depth.increment()?;
5686                }
5687                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
5688                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
5689                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5690                {
5691                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5692                }
5693                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5694                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5695                }
5696            }
5697
5698            next_offset += envelope_size;
5699
5700            // Decode the remaining unknown envelopes.
5701            while next_offset < end_offset {
5702                _next_ordinal_to_read += 1;
5703                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5704                next_offset += envelope_size;
5705            }
5706
5707            Ok(())
5708        }
5709    }
5710
5711    impl FormatCostEntry {
5712        #[inline(always)]
5713        fn max_ordinal_present(&self) -> u64 {
5714            if let Some(_) = self.cost {
5715                return 2;
5716            }
5717            if let Some(_) = self.key {
5718                return 1;
5719            }
5720            0
5721        }
5722    }
5723
5724    impl fidl::encoding::ValueTypeMarker for FormatCostEntry {
5725        type Borrowed<'a> = &'a Self;
5726        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5727            value
5728        }
5729    }
5730
5731    unsafe impl fidl::encoding::TypeMarker for FormatCostEntry {
5732        type Owned = Self;
5733
5734        #[inline(always)]
5735        fn inline_align(_context: fidl::encoding::Context) -> usize {
5736            8
5737        }
5738
5739        #[inline(always)]
5740        fn inline_size(_context: fidl::encoding::Context) -> usize {
5741            16
5742        }
5743    }
5744
5745    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCostEntry, D>
5746        for &FormatCostEntry
5747    {
5748        unsafe fn encode(
5749            self,
5750            encoder: &mut fidl::encoding::Encoder<'_, D>,
5751            offset: usize,
5752            mut depth: fidl::encoding::Depth,
5753        ) -> fidl::Result<()> {
5754            encoder.debug_check_bounds::<FormatCostEntry>(offset);
5755            // Vector header
5756            let max_ordinal: u64 = self.max_ordinal_present();
5757            encoder.write_num(max_ordinal, offset);
5758            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5759            // Calling encoder.out_of_line_offset(0) is not allowed.
5760            if max_ordinal == 0 {
5761                return Ok(());
5762            }
5763            depth.increment()?;
5764            let envelope_size = 8;
5765            let bytes_len = max_ordinal as usize * envelope_size;
5766            #[allow(unused_variables)]
5767            let offset = encoder.out_of_line_offset(bytes_len);
5768            let mut _prev_end_offset: usize = 0;
5769            if 1 > max_ordinal {
5770                return Ok(());
5771            }
5772
5773            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5774            // are envelope_size bytes.
5775            let cur_offset: usize = (1 - 1) * envelope_size;
5776
5777            // Zero reserved fields.
5778            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5779
5780            // Safety:
5781            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5782            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5783            //   envelope_size bytes, there is always sufficient room.
5784            fidl::encoding::encode_in_envelope_optional::<FormatCostKey, D>(
5785                self.key.as_ref().map(<FormatCostKey as fidl::encoding::ValueTypeMarker>::borrow),
5786                encoder,
5787                offset + cur_offset,
5788                depth,
5789            )?;
5790
5791            _prev_end_offset = cur_offset + envelope_size;
5792            if 2 > max_ordinal {
5793                return Ok(());
5794            }
5795
5796            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5797            // are envelope_size bytes.
5798            let cur_offset: usize = (2 - 1) * envelope_size;
5799
5800            // Zero reserved fields.
5801            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5802
5803            // Safety:
5804            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5805            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5806            //   envelope_size bytes, there is always sufficient room.
5807            fidl::encoding::encode_in_envelope_optional::<f32, D>(
5808                self.cost.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
5809                encoder,
5810                offset + cur_offset,
5811                depth,
5812            )?;
5813
5814            _prev_end_offset = cur_offset + envelope_size;
5815
5816            Ok(())
5817        }
5818    }
5819
5820    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCostEntry {
5821        #[inline(always)]
5822        fn new_empty() -> Self {
5823            Self::default()
5824        }
5825
5826        unsafe fn decode(
5827            &mut self,
5828            decoder: &mut fidl::encoding::Decoder<'_, D>,
5829            offset: usize,
5830            mut depth: fidl::encoding::Depth,
5831        ) -> fidl::Result<()> {
5832            decoder.debug_check_bounds::<Self>(offset);
5833            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5834                None => return Err(fidl::Error::NotNullable),
5835                Some(len) => len,
5836            };
5837            // Calling decoder.out_of_line_offset(0) is not allowed.
5838            if len == 0 {
5839                return Ok(());
5840            };
5841            depth.increment()?;
5842            let envelope_size = 8;
5843            let bytes_len = len * envelope_size;
5844            let offset = decoder.out_of_line_offset(bytes_len)?;
5845            // Decode the envelope for each type.
5846            let mut _next_ordinal_to_read = 0;
5847            let mut next_offset = offset;
5848            let end_offset = offset + bytes_len;
5849            _next_ordinal_to_read += 1;
5850            if next_offset >= end_offset {
5851                return Ok(());
5852            }
5853
5854            // Decode unknown envelopes for gaps in ordinals.
5855            while _next_ordinal_to_read < 1 {
5856                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5857                _next_ordinal_to_read += 1;
5858                next_offset += envelope_size;
5859            }
5860
5861            let next_out_of_line = decoder.next_out_of_line();
5862            let handles_before = decoder.remaining_handles();
5863            if let Some((inlined, num_bytes, num_handles)) =
5864                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5865            {
5866                let member_inline_size =
5867                    <FormatCostKey as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5868                if inlined != (member_inline_size <= 4) {
5869                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5870                }
5871                let inner_offset;
5872                let mut inner_depth = depth.clone();
5873                if inlined {
5874                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5875                    inner_offset = next_offset;
5876                } else {
5877                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5878                    inner_depth.increment()?;
5879                }
5880                let val_ref = self.key.get_or_insert_with(|| fidl::new_empty!(FormatCostKey, D));
5881                fidl::decode!(FormatCostKey, D, val_ref, decoder, inner_offset, inner_depth)?;
5882                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5883                {
5884                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5885                }
5886                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5887                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5888                }
5889            }
5890
5891            next_offset += envelope_size;
5892            _next_ordinal_to_read += 1;
5893            if next_offset >= end_offset {
5894                return Ok(());
5895            }
5896
5897            // Decode unknown envelopes for gaps in ordinals.
5898            while _next_ordinal_to_read < 2 {
5899                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5900                _next_ordinal_to_read += 1;
5901                next_offset += envelope_size;
5902            }
5903
5904            let next_out_of_line = decoder.next_out_of_line();
5905            let handles_before = decoder.remaining_handles();
5906            if let Some((inlined, num_bytes, num_handles)) =
5907                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5908            {
5909                let member_inline_size =
5910                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5911                if inlined != (member_inline_size <= 4) {
5912                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5913                }
5914                let inner_offset;
5915                let mut inner_depth = depth.clone();
5916                if inlined {
5917                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5918                    inner_offset = next_offset;
5919                } else {
5920                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5921                    inner_depth.increment()?;
5922                }
5923                let val_ref = self.cost.get_or_insert_with(|| fidl::new_empty!(f32, D));
5924                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
5925                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5926                {
5927                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5928                }
5929                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5930                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5931                }
5932            }
5933
5934            next_offset += envelope_size;
5935
5936            // Decode the remaining unknown envelopes.
5937            while next_offset < end_offset {
5938                _next_ordinal_to_read += 1;
5939                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5940                next_offset += envelope_size;
5941            }
5942
5943            Ok(())
5944        }
5945    }
5946
5947    impl FormatCostKey {
5948        #[inline(always)]
5949        fn max_ordinal_present(&self) -> u64 {
5950            if let Some(_) = self.buffer_usage_bits {
5951                return 3;
5952            }
5953            if let Some(_) = self.pixel_format_modifier {
5954                return 2;
5955            }
5956            if let Some(_) = self.pixel_format {
5957                return 1;
5958            }
5959            0
5960        }
5961    }
5962
5963    impl fidl::encoding::ValueTypeMarker for FormatCostKey {
5964        type Borrowed<'a> = &'a Self;
5965        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5966            value
5967        }
5968    }
5969
5970    unsafe impl fidl::encoding::TypeMarker for FormatCostKey {
5971        type Owned = Self;
5972
5973        #[inline(always)]
5974        fn inline_align(_context: fidl::encoding::Context) -> usize {
5975            8
5976        }
5977
5978        #[inline(always)]
5979        fn inline_size(_context: fidl::encoding::Context) -> usize {
5980            16
5981        }
5982    }
5983
5984    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCostKey, D>
5985        for &FormatCostKey
5986    {
5987        unsafe fn encode(
5988            self,
5989            encoder: &mut fidl::encoding::Encoder<'_, D>,
5990            offset: usize,
5991            mut depth: fidl::encoding::Depth,
5992        ) -> fidl::Result<()> {
5993            encoder.debug_check_bounds::<FormatCostKey>(offset);
5994            // Vector header
5995            let max_ordinal: u64 = self.max_ordinal_present();
5996            encoder.write_num(max_ordinal, offset);
5997            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5998            // Calling encoder.out_of_line_offset(0) is not allowed.
5999            if max_ordinal == 0 {
6000                return Ok(());
6001            }
6002            depth.increment()?;
6003            let envelope_size = 8;
6004            let bytes_len = max_ordinal as usize * envelope_size;
6005            #[allow(unused_variables)]
6006            let offset = encoder.out_of_line_offset(bytes_len);
6007            let mut _prev_end_offset: usize = 0;
6008            if 1 > max_ordinal {
6009                return Ok(());
6010            }
6011
6012            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6013            // are envelope_size bytes.
6014            let cur_offset: usize = (1 - 1) * envelope_size;
6015
6016            // Zero reserved fields.
6017            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6018
6019            // Safety:
6020            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6021            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6022            //   envelope_size bytes, there is always sufficient room.
6023            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormat, D>(
6024            self.pixel_format.as_ref().map(<fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow),
6025            encoder, offset + cur_offset, depth
6026        )?;
6027
6028            _prev_end_offset = cur_offset + envelope_size;
6029            if 2 > max_ordinal {
6030                return Ok(());
6031            }
6032
6033            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6034            // are envelope_size bytes.
6035            let cur_offset: usize = (2 - 1) * envelope_size;
6036
6037            // Zero reserved fields.
6038            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6039
6040            // Safety:
6041            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6042            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6043            //   envelope_size bytes, there is always sufficient room.
6044            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormatModifier, D>(
6045            self.pixel_format_modifier.as_ref().map(<fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow),
6046            encoder, offset + cur_offset, depth
6047        )?;
6048
6049            _prev_end_offset = cur_offset + envelope_size;
6050            if 3 > max_ordinal {
6051                return Ok(());
6052            }
6053
6054            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6055            // are envelope_size bytes.
6056            let cur_offset: usize = (3 - 1) * envelope_size;
6057
6058            // Zero reserved fields.
6059            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6060
6061            // Safety:
6062            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6063            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6064            //   envelope_size bytes, there is always sufficient room.
6065            fidl::encoding::encode_in_envelope_optional::<BufferUsage, D>(
6066                self.buffer_usage_bits
6067                    .as_ref()
6068                    .map(<BufferUsage as fidl::encoding::ValueTypeMarker>::borrow),
6069                encoder,
6070                offset + cur_offset,
6071                depth,
6072            )?;
6073
6074            _prev_end_offset = cur_offset + envelope_size;
6075
6076            Ok(())
6077        }
6078    }
6079
6080    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCostKey {
6081        #[inline(always)]
6082        fn new_empty() -> Self {
6083            Self::default()
6084        }
6085
6086        unsafe fn decode(
6087            &mut self,
6088            decoder: &mut fidl::encoding::Decoder<'_, D>,
6089            offset: usize,
6090            mut depth: fidl::encoding::Depth,
6091        ) -> fidl::Result<()> {
6092            decoder.debug_check_bounds::<Self>(offset);
6093            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6094                None => return Err(fidl::Error::NotNullable),
6095                Some(len) => len,
6096            };
6097            // Calling decoder.out_of_line_offset(0) is not allowed.
6098            if len == 0 {
6099                return Ok(());
6100            };
6101            depth.increment()?;
6102            let envelope_size = 8;
6103            let bytes_len = len * envelope_size;
6104            let offset = decoder.out_of_line_offset(bytes_len)?;
6105            // Decode the envelope for each type.
6106            let mut _next_ordinal_to_read = 0;
6107            let mut next_offset = offset;
6108            let end_offset = offset + bytes_len;
6109            _next_ordinal_to_read += 1;
6110            if next_offset >= end_offset {
6111                return Ok(());
6112            }
6113
6114            // Decode unknown envelopes for gaps in ordinals.
6115            while _next_ordinal_to_read < 1 {
6116                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6117                _next_ordinal_to_read += 1;
6118                next_offset += envelope_size;
6119            }
6120
6121            let next_out_of_line = decoder.next_out_of_line();
6122            let handles_before = decoder.remaining_handles();
6123            if let Some((inlined, num_bytes, num_handles)) =
6124                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6125            {
6126                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6127                if inlined != (member_inline_size <= 4) {
6128                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6129                }
6130                let inner_offset;
6131                let mut inner_depth = depth.clone();
6132                if inlined {
6133                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6134                    inner_offset = next_offset;
6135                } else {
6136                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6137                    inner_depth.increment()?;
6138                }
6139                let val_ref = self.pixel_format.get_or_insert_with(|| {
6140                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D)
6141                });
6142                fidl::decode!(
6143                    fidl_fuchsia_images2__common::PixelFormat,
6144                    D,
6145                    val_ref,
6146                    decoder,
6147                    inner_offset,
6148                    inner_depth
6149                )?;
6150                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6151                {
6152                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6153                }
6154                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6155                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6156                }
6157            }
6158
6159            next_offset += envelope_size;
6160            _next_ordinal_to_read += 1;
6161            if next_offset >= end_offset {
6162                return Ok(());
6163            }
6164
6165            // Decode unknown envelopes for gaps in ordinals.
6166            while _next_ordinal_to_read < 2 {
6167                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6168                _next_ordinal_to_read += 1;
6169                next_offset += envelope_size;
6170            }
6171
6172            let next_out_of_line = decoder.next_out_of_line();
6173            let handles_before = decoder.remaining_handles();
6174            if let Some((inlined, num_bytes, num_handles)) =
6175                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6176            {
6177                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6178                if inlined != (member_inline_size <= 4) {
6179                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6180                }
6181                let inner_offset;
6182                let mut inner_depth = depth.clone();
6183                if inlined {
6184                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6185                    inner_offset = next_offset;
6186                } else {
6187                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6188                    inner_depth.increment()?;
6189                }
6190                let val_ref = self.pixel_format_modifier.get_or_insert_with(|| {
6191                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormatModifier, D)
6192                });
6193                fidl::decode!(
6194                    fidl_fuchsia_images2__common::PixelFormatModifier,
6195                    D,
6196                    val_ref,
6197                    decoder,
6198                    inner_offset,
6199                    inner_depth
6200                )?;
6201                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6202                {
6203                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6204                }
6205                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6206                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6207                }
6208            }
6209
6210            next_offset += envelope_size;
6211            _next_ordinal_to_read += 1;
6212            if next_offset >= end_offset {
6213                return Ok(());
6214            }
6215
6216            // Decode unknown envelopes for gaps in ordinals.
6217            while _next_ordinal_to_read < 3 {
6218                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6219                _next_ordinal_to_read += 1;
6220                next_offset += envelope_size;
6221            }
6222
6223            let next_out_of_line = decoder.next_out_of_line();
6224            let handles_before = decoder.remaining_handles();
6225            if let Some((inlined, num_bytes, num_handles)) =
6226                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6227            {
6228                let member_inline_size =
6229                    <BufferUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6230                if inlined != (member_inline_size <= 4) {
6231                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6232                }
6233                let inner_offset;
6234                let mut inner_depth = depth.clone();
6235                if inlined {
6236                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6237                    inner_offset = next_offset;
6238                } else {
6239                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6240                    inner_depth.increment()?;
6241                }
6242                let val_ref =
6243                    self.buffer_usage_bits.get_or_insert_with(|| fidl::new_empty!(BufferUsage, D));
6244                fidl::decode!(BufferUsage, D, val_ref, decoder, inner_offset, inner_depth)?;
6245                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6246                {
6247                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6248                }
6249                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6250                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6251                }
6252            }
6253
6254            next_offset += envelope_size;
6255
6256            // Decode the remaining unknown envelopes.
6257            while next_offset < end_offset {
6258                _next_ordinal_to_read += 1;
6259                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6260                next_offset += envelope_size;
6261            }
6262
6263            Ok(())
6264        }
6265    }
6266
6267    impl FormatCosts {
6268        #[inline(always)]
6269        fn max_ordinal_present(&self) -> u64 {
6270            if let Some(_) = self.format_costs {
6271                return 1;
6272            }
6273            0
6274        }
6275    }
6276
6277    impl fidl::encoding::ValueTypeMarker for FormatCosts {
6278        type Borrowed<'a> = &'a Self;
6279        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6280            value
6281        }
6282    }
6283
6284    unsafe impl fidl::encoding::TypeMarker for FormatCosts {
6285        type Owned = Self;
6286
6287        #[inline(always)]
6288        fn inline_align(_context: fidl::encoding::Context) -> usize {
6289            8
6290        }
6291
6292        #[inline(always)]
6293        fn inline_size(_context: fidl::encoding::Context) -> usize {
6294            16
6295        }
6296    }
6297
6298    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCosts, D>
6299        for &FormatCosts
6300    {
6301        unsafe fn encode(
6302            self,
6303            encoder: &mut fidl::encoding::Encoder<'_, D>,
6304            offset: usize,
6305            mut depth: fidl::encoding::Depth,
6306        ) -> fidl::Result<()> {
6307            encoder.debug_check_bounds::<FormatCosts>(offset);
6308            // Vector header
6309            let max_ordinal: u64 = self.max_ordinal_present();
6310            encoder.write_num(max_ordinal, offset);
6311            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6312            // Calling encoder.out_of_line_offset(0) is not allowed.
6313            if max_ordinal == 0 {
6314                return Ok(());
6315            }
6316            depth.increment()?;
6317            let envelope_size = 8;
6318            let bytes_len = max_ordinal as usize * envelope_size;
6319            #[allow(unused_variables)]
6320            let offset = encoder.out_of_line_offset(bytes_len);
6321            let mut _prev_end_offset: usize = 0;
6322            if 1 > max_ordinal {
6323                return Ok(());
6324            }
6325
6326            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6327            // are envelope_size bytes.
6328            let cur_offset: usize = (1 - 1) * envelope_size;
6329
6330            // Zero reserved fields.
6331            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6332
6333            // Safety:
6334            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6335            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6336            //   envelope_size bytes, there is always sufficient room.
6337            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<FormatCostEntry>, D>(
6338            self.format_costs.as_ref().map(<fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::ValueTypeMarker>::borrow),
6339            encoder, offset + cur_offset, depth
6340        )?;
6341
6342            _prev_end_offset = cur_offset + envelope_size;
6343
6344            Ok(())
6345        }
6346    }
6347
6348    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCosts {
6349        #[inline(always)]
6350        fn new_empty() -> Self {
6351            Self::default()
6352        }
6353
6354        unsafe fn decode(
6355            &mut self,
6356            decoder: &mut fidl::encoding::Decoder<'_, D>,
6357            offset: usize,
6358            mut depth: fidl::encoding::Depth,
6359        ) -> fidl::Result<()> {
6360            decoder.debug_check_bounds::<Self>(offset);
6361            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6362                None => return Err(fidl::Error::NotNullable),
6363                Some(len) => len,
6364            };
6365            // Calling decoder.out_of_line_offset(0) is not allowed.
6366            if len == 0 {
6367                return Ok(());
6368            };
6369            depth.increment()?;
6370            let envelope_size = 8;
6371            let bytes_len = len * envelope_size;
6372            let offset = decoder.out_of_line_offset(bytes_len)?;
6373            // Decode the envelope for each type.
6374            let mut _next_ordinal_to_read = 0;
6375            let mut next_offset = offset;
6376            let end_offset = offset + bytes_len;
6377            _next_ordinal_to_read += 1;
6378            if next_offset >= end_offset {
6379                return Ok(());
6380            }
6381
6382            // Decode unknown envelopes for gaps in ordinals.
6383            while _next_ordinal_to_read < 1 {
6384                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6385                _next_ordinal_to_read += 1;
6386                next_offset += envelope_size;
6387            }
6388
6389            let next_out_of_line = decoder.next_out_of_line();
6390            let handles_before = decoder.remaining_handles();
6391            if let Some((inlined, num_bytes, num_handles)) =
6392                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6393            {
6394                let member_inline_size = <fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6395                if inlined != (member_inline_size <= 4) {
6396                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6397                }
6398                let inner_offset;
6399                let mut inner_depth = depth.clone();
6400                if inlined {
6401                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6402                    inner_offset = next_offset;
6403                } else {
6404                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6405                    inner_depth.increment()?;
6406                }
6407                let val_ref = self.format_costs.get_or_insert_with(|| {
6408                    fidl::new_empty!(fidl::encoding::UnboundedVector<FormatCostEntry>, D)
6409                });
6410                fidl::decode!(
6411                    fidl::encoding::UnboundedVector<FormatCostEntry>,
6412                    D,
6413                    val_ref,
6414                    decoder,
6415                    inner_offset,
6416                    inner_depth
6417                )?;
6418                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6419                {
6420                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6421                }
6422                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6423                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6424                }
6425            }
6426
6427            next_offset += envelope_size;
6428
6429            // Decode the remaining unknown envelopes.
6430            while next_offset < end_offset {
6431                _next_ordinal_to_read += 1;
6432                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6433                next_offset += envelope_size;
6434            }
6435
6436            Ok(())
6437        }
6438    }
6439
6440    impl Heap {
6441        #[inline(always)]
6442        fn max_ordinal_present(&self) -> u64 {
6443            if let Some(_) = self.id {
6444                return 2;
6445            }
6446            if let Some(_) = self.heap_type {
6447                return 1;
6448            }
6449            0
6450        }
6451    }
6452
6453    impl fidl::encoding::ValueTypeMarker for Heap {
6454        type Borrowed<'a> = &'a Self;
6455        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6456            value
6457        }
6458    }
6459
6460    unsafe impl fidl::encoding::TypeMarker for Heap {
6461        type Owned = Self;
6462
6463        #[inline(always)]
6464        fn inline_align(_context: fidl::encoding::Context) -> usize {
6465            8
6466        }
6467
6468        #[inline(always)]
6469        fn inline_size(_context: fidl::encoding::Context) -> usize {
6470            16
6471        }
6472    }
6473
6474    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Heap, D> for &Heap {
6475        unsafe fn encode(
6476            self,
6477            encoder: &mut fidl::encoding::Encoder<'_, D>,
6478            offset: usize,
6479            mut depth: fidl::encoding::Depth,
6480        ) -> fidl::Result<()> {
6481            encoder.debug_check_bounds::<Heap>(offset);
6482            // Vector header
6483            let max_ordinal: u64 = self.max_ordinal_present();
6484            encoder.write_num(max_ordinal, offset);
6485            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6486            // Calling encoder.out_of_line_offset(0) is not allowed.
6487            if max_ordinal == 0 {
6488                return Ok(());
6489            }
6490            depth.increment()?;
6491            let envelope_size = 8;
6492            let bytes_len = max_ordinal as usize * envelope_size;
6493            #[allow(unused_variables)]
6494            let offset = encoder.out_of_line_offset(bytes_len);
6495            let mut _prev_end_offset: usize = 0;
6496            if 1 > max_ordinal {
6497                return Ok(());
6498            }
6499
6500            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6501            // are envelope_size bytes.
6502            let cur_offset: usize = (1 - 1) * envelope_size;
6503
6504            // Zero reserved fields.
6505            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6506
6507            // Safety:
6508            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6509            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6510            //   envelope_size bytes, there is always sufficient room.
6511            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
6512                self.heap_type.as_ref().map(
6513                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
6514                ),
6515                encoder,
6516                offset + cur_offset,
6517                depth,
6518            )?;
6519
6520            _prev_end_offset = cur_offset + envelope_size;
6521            if 2 > max_ordinal {
6522                return Ok(());
6523            }
6524
6525            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6526            // are envelope_size bytes.
6527            let cur_offset: usize = (2 - 1) * envelope_size;
6528
6529            // Zero reserved fields.
6530            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6531
6532            // Safety:
6533            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6534            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6535            //   envelope_size bytes, there is always sufficient room.
6536            fidl::encoding::encode_in_envelope_optional::<u64, D>(
6537                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
6538                encoder,
6539                offset + cur_offset,
6540                depth,
6541            )?;
6542
6543            _prev_end_offset = cur_offset + envelope_size;
6544
6545            Ok(())
6546        }
6547    }
6548
6549    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Heap {
6550        #[inline(always)]
6551        fn new_empty() -> Self {
6552            Self::default()
6553        }
6554
6555        unsafe fn decode(
6556            &mut self,
6557            decoder: &mut fidl::encoding::Decoder<'_, D>,
6558            offset: usize,
6559            mut depth: fidl::encoding::Depth,
6560        ) -> fidl::Result<()> {
6561            decoder.debug_check_bounds::<Self>(offset);
6562            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6563                None => return Err(fidl::Error::NotNullable),
6564                Some(len) => len,
6565            };
6566            // Calling decoder.out_of_line_offset(0) is not allowed.
6567            if len == 0 {
6568                return Ok(());
6569            };
6570            depth.increment()?;
6571            let envelope_size = 8;
6572            let bytes_len = len * envelope_size;
6573            let offset = decoder.out_of_line_offset(bytes_len)?;
6574            // Decode the envelope for each type.
6575            let mut _next_ordinal_to_read = 0;
6576            let mut next_offset = offset;
6577            let end_offset = offset + bytes_len;
6578            _next_ordinal_to_read += 1;
6579            if next_offset >= end_offset {
6580                return Ok(());
6581            }
6582
6583            // Decode unknown envelopes for gaps in ordinals.
6584            while _next_ordinal_to_read < 1 {
6585                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6586                _next_ordinal_to_read += 1;
6587                next_offset += envelope_size;
6588            }
6589
6590            let next_out_of_line = decoder.next_out_of_line();
6591            let handles_before = decoder.remaining_handles();
6592            if let Some((inlined, num_bytes, num_handles)) =
6593                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6594            {
6595                let member_inline_size =
6596                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
6597                        decoder.context,
6598                    );
6599                if inlined != (member_inline_size <= 4) {
6600                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6601                }
6602                let inner_offset;
6603                let mut inner_depth = depth.clone();
6604                if inlined {
6605                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6606                    inner_offset = next_offset;
6607                } else {
6608                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6609                    inner_depth.increment()?;
6610                }
6611                let val_ref = self
6612                    .heap_type
6613                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
6614                fidl::decode!(
6615                    fidl::encoding::BoundedString<128>,
6616                    D,
6617                    val_ref,
6618                    decoder,
6619                    inner_offset,
6620                    inner_depth
6621                )?;
6622                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6623                {
6624                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6625                }
6626                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6627                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6628                }
6629            }
6630
6631            next_offset += envelope_size;
6632            _next_ordinal_to_read += 1;
6633            if next_offset >= end_offset {
6634                return Ok(());
6635            }
6636
6637            // Decode unknown envelopes for gaps in ordinals.
6638            while _next_ordinal_to_read < 2 {
6639                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6640                _next_ordinal_to_read += 1;
6641                next_offset += envelope_size;
6642            }
6643
6644            let next_out_of_line = decoder.next_out_of_line();
6645            let handles_before = decoder.remaining_handles();
6646            if let Some((inlined, num_bytes, num_handles)) =
6647                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6648            {
6649                let member_inline_size =
6650                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6651                if inlined != (member_inline_size <= 4) {
6652                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6653                }
6654                let inner_offset;
6655                let mut inner_depth = depth.clone();
6656                if inlined {
6657                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6658                    inner_offset = next_offset;
6659                } else {
6660                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6661                    inner_depth.increment()?;
6662                }
6663                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
6664                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
6665                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6666                {
6667                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6668                }
6669                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6670                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6671                }
6672            }
6673
6674            next_offset += envelope_size;
6675
6676            // Decode the remaining unknown envelopes.
6677            while next_offset < end_offset {
6678                _next_ordinal_to_read += 1;
6679                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6680                next_offset += envelope_size;
6681            }
6682
6683            Ok(())
6684        }
6685    }
6686
6687    impl ImageFormatConstraints {
6688        #[inline(always)]
6689        fn max_ordinal_present(&self) -> u64 {
6690            if let Some(_) = self.pad_beyond_image_size_bytes {
6691                return 20;
6692            }
6693            if let Some(_) = self.pad_for_block_size {
6694                return 19;
6695            }
6696            if let Some(_) = self.required_max_size_list {
6697                return 18;
6698            }
6699            if let Some(_) = self.is_alpha_present {
6700                return 17;
6701            }
6702            if let Some(_) = self.require_bytes_per_row_at_pixel_boundary {
6703                return 16;
6704            }
6705            if let Some(_) = self.pixel_format_and_modifiers {
6706                return 15;
6707            }
6708            if let Some(_) = self.start_offset_divisor {
6709                return 14;
6710            }
6711            if let Some(_) = self.bytes_per_row_divisor {
6712                return 13;
6713            }
6714            if let Some(_) = self.required_max_size {
6715                return 12;
6716            }
6717            if let Some(_) = self.required_min_size {
6718                return 11;
6719            }
6720            if let Some(_) = self.display_rect_alignment {
6721                return 10;
6722            }
6723            if let Some(_) = self.size_alignment {
6724                return 9;
6725            }
6726            if let Some(_) = self.max_width_times_height {
6727                return 8;
6728            }
6729            if let Some(_) = self.max_bytes_per_row {
6730                return 7;
6731            }
6732            if let Some(_) = self.min_bytes_per_row {
6733                return 6;
6734            }
6735            if let Some(_) = self.max_size {
6736                return 5;
6737            }
6738            if let Some(_) = self.min_size {
6739                return 4;
6740            }
6741            if let Some(_) = self.color_spaces {
6742                return 3;
6743            }
6744            if let Some(_) = self.pixel_format_modifier {
6745                return 2;
6746            }
6747            if let Some(_) = self.pixel_format {
6748                return 1;
6749            }
6750            0
6751        }
6752    }
6753
6754    impl fidl::encoding::ValueTypeMarker for ImageFormatConstraints {
6755        type Borrowed<'a> = &'a Self;
6756        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6757            value
6758        }
6759    }
6760
6761    unsafe impl fidl::encoding::TypeMarker for ImageFormatConstraints {
6762        type Owned = Self;
6763
6764        #[inline(always)]
6765        fn inline_align(_context: fidl::encoding::Context) -> usize {
6766            8
6767        }
6768
6769        #[inline(always)]
6770        fn inline_size(_context: fidl::encoding::Context) -> usize {
6771            16
6772        }
6773    }
6774
6775    unsafe impl<D: fidl::encoding::ResourceDialect>
6776        fidl::encoding::Encode<ImageFormatConstraints, D> for &ImageFormatConstraints
6777    {
6778        unsafe fn encode(
6779            self,
6780            encoder: &mut fidl::encoding::Encoder<'_, D>,
6781            offset: usize,
6782            mut depth: fidl::encoding::Depth,
6783        ) -> fidl::Result<()> {
6784            encoder.debug_check_bounds::<ImageFormatConstraints>(offset);
6785            // Vector header
6786            let max_ordinal: u64 = self.max_ordinal_present();
6787            encoder.write_num(max_ordinal, offset);
6788            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6789            // Calling encoder.out_of_line_offset(0) is not allowed.
6790            if max_ordinal == 0 {
6791                return Ok(());
6792            }
6793            depth.increment()?;
6794            let envelope_size = 8;
6795            let bytes_len = max_ordinal as usize * envelope_size;
6796            #[allow(unused_variables)]
6797            let offset = encoder.out_of_line_offset(bytes_len);
6798            let mut _prev_end_offset: usize = 0;
6799            if 1 > max_ordinal {
6800                return Ok(());
6801            }
6802
6803            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6804            // are envelope_size bytes.
6805            let cur_offset: usize = (1 - 1) * envelope_size;
6806
6807            // Zero reserved fields.
6808            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6809
6810            // Safety:
6811            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6812            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6813            //   envelope_size bytes, there is always sufficient room.
6814            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormat, D>(
6815            self.pixel_format.as_ref().map(<fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow),
6816            encoder, offset + cur_offset, depth
6817        )?;
6818
6819            _prev_end_offset = cur_offset + envelope_size;
6820            if 2 > max_ordinal {
6821                return Ok(());
6822            }
6823
6824            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6825            // are envelope_size bytes.
6826            let cur_offset: usize = (2 - 1) * envelope_size;
6827
6828            // Zero reserved fields.
6829            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6830
6831            // Safety:
6832            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6833            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6834            //   envelope_size bytes, there is always sufficient room.
6835            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormatModifier, D>(
6836            self.pixel_format_modifier.as_ref().map(<fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow),
6837            encoder, offset + cur_offset, depth
6838        )?;
6839
6840            _prev_end_offset = cur_offset + envelope_size;
6841            if 3 > max_ordinal {
6842                return Ok(());
6843            }
6844
6845            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6846            // are envelope_size bytes.
6847            let cur_offset: usize = (3 - 1) * envelope_size;
6848
6849            // Zero reserved fields.
6850            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6851
6852            // Safety:
6853            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6854            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6855            //   envelope_size bytes, there is always sufficient room.
6856            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D>(
6857            self.color_spaces.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32> as fidl::encoding::ValueTypeMarker>::borrow),
6858            encoder, offset + cur_offset, depth
6859        )?;
6860
6861            _prev_end_offset = cur_offset + envelope_size;
6862            if 4 > max_ordinal {
6863                return Ok(());
6864            }
6865
6866            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6867            // are envelope_size bytes.
6868            let cur_offset: usize = (4 - 1) * envelope_size;
6869
6870            // Zero reserved fields.
6871            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6872
6873            // Safety:
6874            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6875            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6876            //   envelope_size bytes, there is always sufficient room.
6877            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6878                self.min_size.as_ref().map(
6879                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6880                ),
6881                encoder,
6882                offset + cur_offset,
6883                depth,
6884            )?;
6885
6886            _prev_end_offset = cur_offset + envelope_size;
6887            if 5 > max_ordinal {
6888                return Ok(());
6889            }
6890
6891            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6892            // are envelope_size bytes.
6893            let cur_offset: usize = (5 - 1) * envelope_size;
6894
6895            // Zero reserved fields.
6896            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6897
6898            // Safety:
6899            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6900            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6901            //   envelope_size bytes, there is always sufficient room.
6902            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6903                self.max_size.as_ref().map(
6904                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6905                ),
6906                encoder,
6907                offset + cur_offset,
6908                depth,
6909            )?;
6910
6911            _prev_end_offset = cur_offset + envelope_size;
6912            if 6 > max_ordinal {
6913                return Ok(());
6914            }
6915
6916            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6917            // are envelope_size bytes.
6918            let cur_offset: usize = (6 - 1) * envelope_size;
6919
6920            // Zero reserved fields.
6921            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6922
6923            // Safety:
6924            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6925            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6926            //   envelope_size bytes, there is always sufficient room.
6927            fidl::encoding::encode_in_envelope_optional::<u32, D>(
6928                self.min_bytes_per_row
6929                    .as_ref()
6930                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
6931                encoder,
6932                offset + cur_offset,
6933                depth,
6934            )?;
6935
6936            _prev_end_offset = cur_offset + envelope_size;
6937            if 7 > max_ordinal {
6938                return Ok(());
6939            }
6940
6941            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6942            // are envelope_size bytes.
6943            let cur_offset: usize = (7 - 1) * envelope_size;
6944
6945            // Zero reserved fields.
6946            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6947
6948            // Safety:
6949            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6950            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6951            //   envelope_size bytes, there is always sufficient room.
6952            fidl::encoding::encode_in_envelope_optional::<u32, D>(
6953                self.max_bytes_per_row
6954                    .as_ref()
6955                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
6956                encoder,
6957                offset + cur_offset,
6958                depth,
6959            )?;
6960
6961            _prev_end_offset = cur_offset + envelope_size;
6962            if 8 > max_ordinal {
6963                return Ok(());
6964            }
6965
6966            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6967            // are envelope_size bytes.
6968            let cur_offset: usize = (8 - 1) * envelope_size;
6969
6970            // Zero reserved fields.
6971            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6972
6973            // Safety:
6974            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6975            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6976            //   envelope_size bytes, there is always sufficient room.
6977            fidl::encoding::encode_in_envelope_optional::<u64, D>(
6978                self.max_width_times_height
6979                    .as_ref()
6980                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
6981                encoder,
6982                offset + cur_offset,
6983                depth,
6984            )?;
6985
6986            _prev_end_offset = cur_offset + envelope_size;
6987            if 9 > max_ordinal {
6988                return Ok(());
6989            }
6990
6991            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6992            // are envelope_size bytes.
6993            let cur_offset: usize = (9 - 1) * envelope_size;
6994
6995            // Zero reserved fields.
6996            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6997
6998            // Safety:
6999            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7000            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7001            //   envelope_size bytes, there is always sufficient room.
7002            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7003                self.size_alignment.as_ref().map(
7004                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7005                ),
7006                encoder,
7007                offset + cur_offset,
7008                depth,
7009            )?;
7010
7011            _prev_end_offset = cur_offset + envelope_size;
7012            if 10 > max_ordinal {
7013                return Ok(());
7014            }
7015
7016            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7017            // are envelope_size bytes.
7018            let cur_offset: usize = (10 - 1) * envelope_size;
7019
7020            // Zero reserved fields.
7021            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7022
7023            // Safety:
7024            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7025            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7026            //   envelope_size bytes, there is always sufficient room.
7027            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7028                self.display_rect_alignment.as_ref().map(
7029                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7030                ),
7031                encoder,
7032                offset + cur_offset,
7033                depth,
7034            )?;
7035
7036            _prev_end_offset = cur_offset + envelope_size;
7037            if 11 > max_ordinal {
7038                return Ok(());
7039            }
7040
7041            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7042            // are envelope_size bytes.
7043            let cur_offset: usize = (11 - 1) * envelope_size;
7044
7045            // Zero reserved fields.
7046            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7047
7048            // Safety:
7049            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7050            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7051            //   envelope_size bytes, there is always sufficient room.
7052            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7053                self.required_min_size.as_ref().map(
7054                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7055                ),
7056                encoder,
7057                offset + cur_offset,
7058                depth,
7059            )?;
7060
7061            _prev_end_offset = cur_offset + envelope_size;
7062            if 12 > max_ordinal {
7063                return Ok(());
7064            }
7065
7066            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7067            // are envelope_size bytes.
7068            let cur_offset: usize = (12 - 1) * envelope_size;
7069
7070            // Zero reserved fields.
7071            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7072
7073            // Safety:
7074            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7075            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7076            //   envelope_size bytes, there is always sufficient room.
7077            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7078                self.required_max_size.as_ref().map(
7079                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7080                ),
7081                encoder,
7082                offset + cur_offset,
7083                depth,
7084            )?;
7085
7086            _prev_end_offset = cur_offset + envelope_size;
7087            if 13 > max_ordinal {
7088                return Ok(());
7089            }
7090
7091            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7092            // are envelope_size bytes.
7093            let cur_offset: usize = (13 - 1) * envelope_size;
7094
7095            // Zero reserved fields.
7096            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7097
7098            // Safety:
7099            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7100            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7101            //   envelope_size bytes, there is always sufficient room.
7102            fidl::encoding::encode_in_envelope_optional::<u32, D>(
7103                self.bytes_per_row_divisor
7104                    .as_ref()
7105                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7106                encoder,
7107                offset + cur_offset,
7108                depth,
7109            )?;
7110
7111            _prev_end_offset = cur_offset + envelope_size;
7112            if 14 > max_ordinal {
7113                return Ok(());
7114            }
7115
7116            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7117            // are envelope_size bytes.
7118            let cur_offset: usize = (14 - 1) * envelope_size;
7119
7120            // Zero reserved fields.
7121            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7122
7123            // Safety:
7124            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7125            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7126            //   envelope_size bytes, there is always sufficient room.
7127            fidl::encoding::encode_in_envelope_optional::<u32, D>(
7128                self.start_offset_divisor
7129                    .as_ref()
7130                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7131                encoder,
7132                offset + cur_offset,
7133                depth,
7134            )?;
7135
7136            _prev_end_offset = cur_offset + envelope_size;
7137            if 15 > max_ordinal {
7138                return Ok(());
7139            }
7140
7141            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7142            // are envelope_size bytes.
7143            let cur_offset: usize = (15 - 1) * envelope_size;
7144
7145            // Zero reserved fields.
7146            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7147
7148            // Safety:
7149            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7150            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7151            //   envelope_size bytes, there is always sufficient room.
7152            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<PixelFormatAndModifier, 64>, D>(
7153            self.pixel_format_and_modifiers.as_ref().map(<fidl::encoding::Vector<PixelFormatAndModifier, 64> as fidl::encoding::ValueTypeMarker>::borrow),
7154            encoder, offset + cur_offset, depth
7155        )?;
7156
7157            _prev_end_offset = cur_offset + envelope_size;
7158            if 16 > max_ordinal {
7159                return Ok(());
7160            }
7161
7162            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7163            // are envelope_size bytes.
7164            let cur_offset: usize = (16 - 1) * envelope_size;
7165
7166            // Zero reserved fields.
7167            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7168
7169            // Safety:
7170            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7171            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7172            //   envelope_size bytes, there is always sufficient room.
7173            fidl::encoding::encode_in_envelope_optional::<bool, D>(
7174                self.require_bytes_per_row_at_pixel_boundary
7175                    .as_ref()
7176                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
7177                encoder,
7178                offset + cur_offset,
7179                depth,
7180            )?;
7181
7182            _prev_end_offset = cur_offset + envelope_size;
7183            if 17 > max_ordinal {
7184                return Ok(());
7185            }
7186
7187            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7188            // are envelope_size bytes.
7189            let cur_offset: usize = (17 - 1) * envelope_size;
7190
7191            // Zero reserved fields.
7192            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7193
7194            // Safety:
7195            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7196            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7197            //   envelope_size bytes, there is always sufficient room.
7198            fidl::encoding::encode_in_envelope_optional::<bool, D>(
7199                self.is_alpha_present
7200                    .as_ref()
7201                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
7202                encoder,
7203                offset + cur_offset,
7204                depth,
7205            )?;
7206
7207            _prev_end_offset = cur_offset + envelope_size;
7208            if 18 > max_ordinal {
7209                return Ok(());
7210            }
7211
7212            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7213            // are envelope_size bytes.
7214            let cur_offset: usize = (18 - 1) * envelope_size;
7215
7216            // Zero reserved fields.
7217            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7218
7219            // Safety:
7220            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7221            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7222            //   envelope_size bytes, there is always sufficient room.
7223            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D>(
7224            self.required_max_size_list.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64> as fidl::encoding::ValueTypeMarker>::borrow),
7225            encoder, offset + cur_offset, depth
7226        )?;
7227
7228            _prev_end_offset = cur_offset + envelope_size;
7229            if 19 > max_ordinal {
7230                return Ok(());
7231            }
7232
7233            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7234            // are envelope_size bytes.
7235            let cur_offset: usize = (19 - 1) * envelope_size;
7236
7237            // Zero reserved fields.
7238            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7239
7240            // Safety:
7241            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7242            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7243            //   envelope_size bytes, there is always sufficient room.
7244            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7245                self.pad_for_block_size.as_ref().map(
7246                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7247                ),
7248                encoder,
7249                offset + cur_offset,
7250                depth,
7251            )?;
7252
7253            _prev_end_offset = cur_offset + envelope_size;
7254            if 20 > max_ordinal {
7255                return Ok(());
7256            }
7257
7258            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7259            // are envelope_size bytes.
7260            let cur_offset: usize = (20 - 1) * envelope_size;
7261
7262            // Zero reserved fields.
7263            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7264
7265            // Safety:
7266            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7267            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7268            //   envelope_size bytes, there is always sufficient room.
7269            fidl::encoding::encode_in_envelope_optional::<u64, D>(
7270                self.pad_beyond_image_size_bytes
7271                    .as_ref()
7272                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7273                encoder,
7274                offset + cur_offset,
7275                depth,
7276            )?;
7277
7278            _prev_end_offset = cur_offset + envelope_size;
7279
7280            Ok(())
7281        }
7282    }
7283
7284    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
7285        for ImageFormatConstraints
7286    {
7287        #[inline(always)]
7288        fn new_empty() -> Self {
7289            Self::default()
7290        }
7291
7292        unsafe fn decode(
7293            &mut self,
7294            decoder: &mut fidl::encoding::Decoder<'_, D>,
7295            offset: usize,
7296            mut depth: fidl::encoding::Depth,
7297        ) -> fidl::Result<()> {
7298            decoder.debug_check_bounds::<Self>(offset);
7299            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7300                None => return Err(fidl::Error::NotNullable),
7301                Some(len) => len,
7302            };
7303            // Calling decoder.out_of_line_offset(0) is not allowed.
7304            if len == 0 {
7305                return Ok(());
7306            };
7307            depth.increment()?;
7308            let envelope_size = 8;
7309            let bytes_len = len * envelope_size;
7310            let offset = decoder.out_of_line_offset(bytes_len)?;
7311            // Decode the envelope for each type.
7312            let mut _next_ordinal_to_read = 0;
7313            let mut next_offset = offset;
7314            let end_offset = offset + bytes_len;
7315            _next_ordinal_to_read += 1;
7316            if next_offset >= end_offset {
7317                return Ok(());
7318            }
7319
7320            // Decode unknown envelopes for gaps in ordinals.
7321            while _next_ordinal_to_read < 1 {
7322                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7323                _next_ordinal_to_read += 1;
7324                next_offset += envelope_size;
7325            }
7326
7327            let next_out_of_line = decoder.next_out_of_line();
7328            let handles_before = decoder.remaining_handles();
7329            if let Some((inlined, num_bytes, num_handles)) =
7330                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7331            {
7332                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7333                if inlined != (member_inline_size <= 4) {
7334                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7335                }
7336                let inner_offset;
7337                let mut inner_depth = depth.clone();
7338                if inlined {
7339                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7340                    inner_offset = next_offset;
7341                } else {
7342                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7343                    inner_depth.increment()?;
7344                }
7345                let val_ref = self.pixel_format.get_or_insert_with(|| {
7346                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D)
7347                });
7348                fidl::decode!(
7349                    fidl_fuchsia_images2__common::PixelFormat,
7350                    D,
7351                    val_ref,
7352                    decoder,
7353                    inner_offset,
7354                    inner_depth
7355                )?;
7356                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7357                {
7358                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7359                }
7360                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7361                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7362                }
7363            }
7364
7365            next_offset += envelope_size;
7366            _next_ordinal_to_read += 1;
7367            if next_offset >= end_offset {
7368                return Ok(());
7369            }
7370
7371            // Decode unknown envelopes for gaps in ordinals.
7372            while _next_ordinal_to_read < 2 {
7373                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7374                _next_ordinal_to_read += 1;
7375                next_offset += envelope_size;
7376            }
7377
7378            let next_out_of_line = decoder.next_out_of_line();
7379            let handles_before = decoder.remaining_handles();
7380            if let Some((inlined, num_bytes, num_handles)) =
7381                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7382            {
7383                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7384                if inlined != (member_inline_size <= 4) {
7385                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7386                }
7387                let inner_offset;
7388                let mut inner_depth = depth.clone();
7389                if inlined {
7390                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7391                    inner_offset = next_offset;
7392                } else {
7393                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7394                    inner_depth.increment()?;
7395                }
7396                let val_ref = self.pixel_format_modifier.get_or_insert_with(|| {
7397                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormatModifier, D)
7398                });
7399                fidl::decode!(
7400                    fidl_fuchsia_images2__common::PixelFormatModifier,
7401                    D,
7402                    val_ref,
7403                    decoder,
7404                    inner_offset,
7405                    inner_depth
7406                )?;
7407                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7408                {
7409                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7410                }
7411                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7412                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7413                }
7414            }
7415
7416            next_offset += envelope_size;
7417            _next_ordinal_to_read += 1;
7418            if next_offset >= end_offset {
7419                return Ok(());
7420            }
7421
7422            // Decode unknown envelopes for gaps in ordinals.
7423            while _next_ordinal_to_read < 3 {
7424                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7425                _next_ordinal_to_read += 1;
7426                next_offset += envelope_size;
7427            }
7428
7429            let next_out_of_line = decoder.next_out_of_line();
7430            let handles_before = decoder.remaining_handles();
7431            if let Some((inlined, num_bytes, num_handles)) =
7432                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7433            {
7434                let member_inline_size = <fidl::encoding::Vector<
7435                    fidl_fuchsia_images2__common::ColorSpace,
7436                    32,
7437                > as fidl::encoding::TypeMarker>::inline_size(
7438                    decoder.context
7439                );
7440                if inlined != (member_inline_size <= 4) {
7441                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7442                }
7443                let inner_offset;
7444                let mut inner_depth = depth.clone();
7445                if inlined {
7446                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7447                    inner_offset = next_offset;
7448                } else {
7449                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7450                    inner_depth.increment()?;
7451                }
7452                let val_ref =
7453                self.color_spaces.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D));
7454                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
7455                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7456                {
7457                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7458                }
7459                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7460                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7461                }
7462            }
7463
7464            next_offset += envelope_size;
7465            _next_ordinal_to_read += 1;
7466            if next_offset >= end_offset {
7467                return Ok(());
7468            }
7469
7470            // Decode unknown envelopes for gaps in ordinals.
7471            while _next_ordinal_to_read < 4 {
7472                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7473                _next_ordinal_to_read += 1;
7474                next_offset += envelope_size;
7475            }
7476
7477            let next_out_of_line = decoder.next_out_of_line();
7478            let handles_before = decoder.remaining_handles();
7479            if let Some((inlined, num_bytes, num_handles)) =
7480                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7481            {
7482                let member_inline_size =
7483                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7484                        decoder.context,
7485                    );
7486                if inlined != (member_inline_size <= 4) {
7487                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7488                }
7489                let inner_offset;
7490                let mut inner_depth = depth.clone();
7491                if inlined {
7492                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7493                    inner_offset = next_offset;
7494                } else {
7495                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7496                    inner_depth.increment()?;
7497                }
7498                let val_ref = self
7499                    .min_size
7500                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7501                fidl::decode!(
7502                    fidl_fuchsia_math__common::SizeU,
7503                    D,
7504                    val_ref,
7505                    decoder,
7506                    inner_offset,
7507                    inner_depth
7508                )?;
7509                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7510                {
7511                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7512                }
7513                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7514                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7515                }
7516            }
7517
7518            next_offset += envelope_size;
7519            _next_ordinal_to_read += 1;
7520            if next_offset >= end_offset {
7521                return Ok(());
7522            }
7523
7524            // Decode unknown envelopes for gaps in ordinals.
7525            while _next_ordinal_to_read < 5 {
7526                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7527                _next_ordinal_to_read += 1;
7528                next_offset += envelope_size;
7529            }
7530
7531            let next_out_of_line = decoder.next_out_of_line();
7532            let handles_before = decoder.remaining_handles();
7533            if let Some((inlined, num_bytes, num_handles)) =
7534                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7535            {
7536                let member_inline_size =
7537                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7538                        decoder.context,
7539                    );
7540                if inlined != (member_inline_size <= 4) {
7541                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7542                }
7543                let inner_offset;
7544                let mut inner_depth = depth.clone();
7545                if inlined {
7546                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7547                    inner_offset = next_offset;
7548                } else {
7549                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7550                    inner_depth.increment()?;
7551                }
7552                let val_ref = self
7553                    .max_size
7554                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7555                fidl::decode!(
7556                    fidl_fuchsia_math__common::SizeU,
7557                    D,
7558                    val_ref,
7559                    decoder,
7560                    inner_offset,
7561                    inner_depth
7562                )?;
7563                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7564                {
7565                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7566                }
7567                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7568                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7569                }
7570            }
7571
7572            next_offset += envelope_size;
7573            _next_ordinal_to_read += 1;
7574            if next_offset >= end_offset {
7575                return Ok(());
7576            }
7577
7578            // Decode unknown envelopes for gaps in ordinals.
7579            while _next_ordinal_to_read < 6 {
7580                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7581                _next_ordinal_to_read += 1;
7582                next_offset += envelope_size;
7583            }
7584
7585            let next_out_of_line = decoder.next_out_of_line();
7586            let handles_before = decoder.remaining_handles();
7587            if let Some((inlined, num_bytes, num_handles)) =
7588                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7589            {
7590                let member_inline_size =
7591                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7592                if inlined != (member_inline_size <= 4) {
7593                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7594                }
7595                let inner_offset;
7596                let mut inner_depth = depth.clone();
7597                if inlined {
7598                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7599                    inner_offset = next_offset;
7600                } else {
7601                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7602                    inner_depth.increment()?;
7603                }
7604                let val_ref =
7605                    self.min_bytes_per_row.get_or_insert_with(|| fidl::new_empty!(u32, D));
7606                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7607                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7608                {
7609                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7610                }
7611                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7612                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7613                }
7614            }
7615
7616            next_offset += envelope_size;
7617            _next_ordinal_to_read += 1;
7618            if next_offset >= end_offset {
7619                return Ok(());
7620            }
7621
7622            // Decode unknown envelopes for gaps in ordinals.
7623            while _next_ordinal_to_read < 7 {
7624                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7625                _next_ordinal_to_read += 1;
7626                next_offset += envelope_size;
7627            }
7628
7629            let next_out_of_line = decoder.next_out_of_line();
7630            let handles_before = decoder.remaining_handles();
7631            if let Some((inlined, num_bytes, num_handles)) =
7632                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7633            {
7634                let member_inline_size =
7635                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7636                if inlined != (member_inline_size <= 4) {
7637                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7638                }
7639                let inner_offset;
7640                let mut inner_depth = depth.clone();
7641                if inlined {
7642                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7643                    inner_offset = next_offset;
7644                } else {
7645                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7646                    inner_depth.increment()?;
7647                }
7648                let val_ref =
7649                    self.max_bytes_per_row.get_or_insert_with(|| fidl::new_empty!(u32, D));
7650                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7651                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7652                {
7653                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7654                }
7655                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7656                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7657                }
7658            }
7659
7660            next_offset += envelope_size;
7661            _next_ordinal_to_read += 1;
7662            if next_offset >= end_offset {
7663                return Ok(());
7664            }
7665
7666            // Decode unknown envelopes for gaps in ordinals.
7667            while _next_ordinal_to_read < 8 {
7668                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7669                _next_ordinal_to_read += 1;
7670                next_offset += envelope_size;
7671            }
7672
7673            let next_out_of_line = decoder.next_out_of_line();
7674            let handles_before = decoder.remaining_handles();
7675            if let Some((inlined, num_bytes, num_handles)) =
7676                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7677            {
7678                let member_inline_size =
7679                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7680                if inlined != (member_inline_size <= 4) {
7681                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7682                }
7683                let inner_offset;
7684                let mut inner_depth = depth.clone();
7685                if inlined {
7686                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7687                    inner_offset = next_offset;
7688                } else {
7689                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7690                    inner_depth.increment()?;
7691                }
7692                let val_ref =
7693                    self.max_width_times_height.get_or_insert_with(|| fidl::new_empty!(u64, D));
7694                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
7695                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7696                {
7697                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7698                }
7699                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7700                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7701                }
7702            }
7703
7704            next_offset += envelope_size;
7705            _next_ordinal_to_read += 1;
7706            if next_offset >= end_offset {
7707                return Ok(());
7708            }
7709
7710            // Decode unknown envelopes for gaps in ordinals.
7711            while _next_ordinal_to_read < 9 {
7712                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7713                _next_ordinal_to_read += 1;
7714                next_offset += envelope_size;
7715            }
7716
7717            let next_out_of_line = decoder.next_out_of_line();
7718            let handles_before = decoder.remaining_handles();
7719            if let Some((inlined, num_bytes, num_handles)) =
7720                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7721            {
7722                let member_inline_size =
7723                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7724                        decoder.context,
7725                    );
7726                if inlined != (member_inline_size <= 4) {
7727                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7728                }
7729                let inner_offset;
7730                let mut inner_depth = depth.clone();
7731                if inlined {
7732                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7733                    inner_offset = next_offset;
7734                } else {
7735                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7736                    inner_depth.increment()?;
7737                }
7738                let val_ref = self
7739                    .size_alignment
7740                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7741                fidl::decode!(
7742                    fidl_fuchsia_math__common::SizeU,
7743                    D,
7744                    val_ref,
7745                    decoder,
7746                    inner_offset,
7747                    inner_depth
7748                )?;
7749                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7750                {
7751                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7752                }
7753                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7754                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7755                }
7756            }
7757
7758            next_offset += envelope_size;
7759            _next_ordinal_to_read += 1;
7760            if next_offset >= end_offset {
7761                return Ok(());
7762            }
7763
7764            // Decode unknown envelopes for gaps in ordinals.
7765            while _next_ordinal_to_read < 10 {
7766                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7767                _next_ordinal_to_read += 1;
7768                next_offset += envelope_size;
7769            }
7770
7771            let next_out_of_line = decoder.next_out_of_line();
7772            let handles_before = decoder.remaining_handles();
7773            if let Some((inlined, num_bytes, num_handles)) =
7774                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7775            {
7776                let member_inline_size =
7777                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7778                        decoder.context,
7779                    );
7780                if inlined != (member_inline_size <= 4) {
7781                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7782                }
7783                let inner_offset;
7784                let mut inner_depth = depth.clone();
7785                if inlined {
7786                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7787                    inner_offset = next_offset;
7788                } else {
7789                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7790                    inner_depth.increment()?;
7791                }
7792                let val_ref = self
7793                    .display_rect_alignment
7794                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7795                fidl::decode!(
7796                    fidl_fuchsia_math__common::SizeU,
7797                    D,
7798                    val_ref,
7799                    decoder,
7800                    inner_offset,
7801                    inner_depth
7802                )?;
7803                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7804                {
7805                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7806                }
7807                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7808                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7809                }
7810            }
7811
7812            next_offset += envelope_size;
7813            _next_ordinal_to_read += 1;
7814            if next_offset >= end_offset {
7815                return Ok(());
7816            }
7817
7818            // Decode unknown envelopes for gaps in ordinals.
7819            while _next_ordinal_to_read < 11 {
7820                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7821                _next_ordinal_to_read += 1;
7822                next_offset += envelope_size;
7823            }
7824
7825            let next_out_of_line = decoder.next_out_of_line();
7826            let handles_before = decoder.remaining_handles();
7827            if let Some((inlined, num_bytes, num_handles)) =
7828                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7829            {
7830                let member_inline_size =
7831                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7832                        decoder.context,
7833                    );
7834                if inlined != (member_inline_size <= 4) {
7835                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7836                }
7837                let inner_offset;
7838                let mut inner_depth = depth.clone();
7839                if inlined {
7840                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7841                    inner_offset = next_offset;
7842                } else {
7843                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7844                    inner_depth.increment()?;
7845                }
7846                let val_ref = self
7847                    .required_min_size
7848                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7849                fidl::decode!(
7850                    fidl_fuchsia_math__common::SizeU,
7851                    D,
7852                    val_ref,
7853                    decoder,
7854                    inner_offset,
7855                    inner_depth
7856                )?;
7857                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7858                {
7859                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7860                }
7861                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7862                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7863                }
7864            }
7865
7866            next_offset += envelope_size;
7867            _next_ordinal_to_read += 1;
7868            if next_offset >= end_offset {
7869                return Ok(());
7870            }
7871
7872            // Decode unknown envelopes for gaps in ordinals.
7873            while _next_ordinal_to_read < 12 {
7874                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7875                _next_ordinal_to_read += 1;
7876                next_offset += envelope_size;
7877            }
7878
7879            let next_out_of_line = decoder.next_out_of_line();
7880            let handles_before = decoder.remaining_handles();
7881            if let Some((inlined, num_bytes, num_handles)) =
7882                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7883            {
7884                let member_inline_size =
7885                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7886                        decoder.context,
7887                    );
7888                if inlined != (member_inline_size <= 4) {
7889                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7890                }
7891                let inner_offset;
7892                let mut inner_depth = depth.clone();
7893                if inlined {
7894                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7895                    inner_offset = next_offset;
7896                } else {
7897                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7898                    inner_depth.increment()?;
7899                }
7900                let val_ref = self
7901                    .required_max_size
7902                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7903                fidl::decode!(
7904                    fidl_fuchsia_math__common::SizeU,
7905                    D,
7906                    val_ref,
7907                    decoder,
7908                    inner_offset,
7909                    inner_depth
7910                )?;
7911                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7912                {
7913                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7914                }
7915                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7916                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7917                }
7918            }
7919
7920            next_offset += envelope_size;
7921            _next_ordinal_to_read += 1;
7922            if next_offset >= end_offset {
7923                return Ok(());
7924            }
7925
7926            // Decode unknown envelopes for gaps in ordinals.
7927            while _next_ordinal_to_read < 13 {
7928                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7929                _next_ordinal_to_read += 1;
7930                next_offset += envelope_size;
7931            }
7932
7933            let next_out_of_line = decoder.next_out_of_line();
7934            let handles_before = decoder.remaining_handles();
7935            if let Some((inlined, num_bytes, num_handles)) =
7936                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7937            {
7938                let member_inline_size =
7939                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7940                if inlined != (member_inline_size <= 4) {
7941                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7942                }
7943                let inner_offset;
7944                let mut inner_depth = depth.clone();
7945                if inlined {
7946                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7947                    inner_offset = next_offset;
7948                } else {
7949                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7950                    inner_depth.increment()?;
7951                }
7952                let val_ref =
7953                    self.bytes_per_row_divisor.get_or_insert_with(|| fidl::new_empty!(u32, D));
7954                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7955                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7956                {
7957                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7958                }
7959                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7960                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7961                }
7962            }
7963
7964            next_offset += envelope_size;
7965            _next_ordinal_to_read += 1;
7966            if next_offset >= end_offset {
7967                return Ok(());
7968            }
7969
7970            // Decode unknown envelopes for gaps in ordinals.
7971            while _next_ordinal_to_read < 14 {
7972                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7973                _next_ordinal_to_read += 1;
7974                next_offset += envelope_size;
7975            }
7976
7977            let next_out_of_line = decoder.next_out_of_line();
7978            let handles_before = decoder.remaining_handles();
7979            if let Some((inlined, num_bytes, num_handles)) =
7980                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7981            {
7982                let member_inline_size =
7983                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7984                if inlined != (member_inline_size <= 4) {
7985                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7986                }
7987                let inner_offset;
7988                let mut inner_depth = depth.clone();
7989                if inlined {
7990                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7991                    inner_offset = next_offset;
7992                } else {
7993                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7994                    inner_depth.increment()?;
7995                }
7996                let val_ref =
7997                    self.start_offset_divisor.get_or_insert_with(|| fidl::new_empty!(u32, D));
7998                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7999                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8000                {
8001                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8002                }
8003                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8004                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8005                }
8006            }
8007
8008            next_offset += envelope_size;
8009            _next_ordinal_to_read += 1;
8010            if next_offset >= end_offset {
8011                return Ok(());
8012            }
8013
8014            // Decode unknown envelopes for gaps in ordinals.
8015            while _next_ordinal_to_read < 15 {
8016                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8017                _next_ordinal_to_read += 1;
8018                next_offset += envelope_size;
8019            }
8020
8021            let next_out_of_line = decoder.next_out_of_line();
8022            let handles_before = decoder.remaining_handles();
8023            if let Some((inlined, num_bytes, num_handles)) =
8024                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8025            {
8026                let member_inline_size = <fidl::encoding::Vector<PixelFormatAndModifier, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8027                if inlined != (member_inline_size <= 4) {
8028                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8029                }
8030                let inner_offset;
8031                let mut inner_depth = depth.clone();
8032                if inlined {
8033                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8034                    inner_offset = next_offset;
8035                } else {
8036                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8037                    inner_depth.increment()?;
8038                }
8039                let val_ref = self.pixel_format_and_modifiers.get_or_insert_with(
8040                    || fidl::new_empty!(fidl::encoding::Vector<PixelFormatAndModifier, 64>, D),
8041                );
8042                fidl::decode!(fidl::encoding::Vector<PixelFormatAndModifier, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
8043                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8044                {
8045                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8046                }
8047                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8048                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8049                }
8050            }
8051
8052            next_offset += envelope_size;
8053            _next_ordinal_to_read += 1;
8054            if next_offset >= end_offset {
8055                return Ok(());
8056            }
8057
8058            // Decode unknown envelopes for gaps in ordinals.
8059            while _next_ordinal_to_read < 16 {
8060                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8061                _next_ordinal_to_read += 1;
8062                next_offset += envelope_size;
8063            }
8064
8065            let next_out_of_line = decoder.next_out_of_line();
8066            let handles_before = decoder.remaining_handles();
8067            if let Some((inlined, num_bytes, num_handles)) =
8068                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8069            {
8070                let member_inline_size =
8071                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8072                if inlined != (member_inline_size <= 4) {
8073                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8074                }
8075                let inner_offset;
8076                let mut inner_depth = depth.clone();
8077                if inlined {
8078                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8079                    inner_offset = next_offset;
8080                } else {
8081                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8082                    inner_depth.increment()?;
8083                }
8084                let val_ref = self
8085                    .require_bytes_per_row_at_pixel_boundary
8086                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
8087                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
8088                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8089                {
8090                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8091                }
8092                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8093                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8094                }
8095            }
8096
8097            next_offset += envelope_size;
8098            _next_ordinal_to_read += 1;
8099            if next_offset >= end_offset {
8100                return Ok(());
8101            }
8102
8103            // Decode unknown envelopes for gaps in ordinals.
8104            while _next_ordinal_to_read < 17 {
8105                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8106                _next_ordinal_to_read += 1;
8107                next_offset += envelope_size;
8108            }
8109
8110            let next_out_of_line = decoder.next_out_of_line();
8111            let handles_before = decoder.remaining_handles();
8112            if let Some((inlined, num_bytes, num_handles)) =
8113                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8114            {
8115                let member_inline_size =
8116                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8117                if inlined != (member_inline_size <= 4) {
8118                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8119                }
8120                let inner_offset;
8121                let mut inner_depth = depth.clone();
8122                if inlined {
8123                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8124                    inner_offset = next_offset;
8125                } else {
8126                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8127                    inner_depth.increment()?;
8128                }
8129                let val_ref =
8130                    self.is_alpha_present.get_or_insert_with(|| fidl::new_empty!(bool, D));
8131                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
8132                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8133                {
8134                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8135                }
8136                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8137                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8138                }
8139            }
8140
8141            next_offset += envelope_size;
8142            _next_ordinal_to_read += 1;
8143            if next_offset >= end_offset {
8144                return Ok(());
8145            }
8146
8147            // Decode unknown envelopes for gaps in ordinals.
8148            while _next_ordinal_to_read < 18 {
8149                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8150                _next_ordinal_to_read += 1;
8151                next_offset += envelope_size;
8152            }
8153
8154            let next_out_of_line = decoder.next_out_of_line();
8155            let handles_before = decoder.remaining_handles();
8156            if let Some((inlined, num_bytes, num_handles)) =
8157                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8158            {
8159                let member_inline_size = <fidl::encoding::Vector<
8160                    fidl_fuchsia_math__common::SizeU,
8161                    64,
8162                > as fidl::encoding::TypeMarker>::inline_size(
8163                    decoder.context
8164                );
8165                if inlined != (member_inline_size <= 4) {
8166                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8167                }
8168                let inner_offset;
8169                let mut inner_depth = depth.clone();
8170                if inlined {
8171                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8172                    inner_offset = next_offset;
8173                } else {
8174                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8175                    inner_depth.increment()?;
8176                }
8177                let val_ref =
8178                self.required_max_size_list.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D));
8179                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
8180                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8181                {
8182                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8183                }
8184                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8185                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8186                }
8187            }
8188
8189            next_offset += envelope_size;
8190            _next_ordinal_to_read += 1;
8191            if next_offset >= end_offset {
8192                return Ok(());
8193            }
8194
8195            // Decode unknown envelopes for gaps in ordinals.
8196            while _next_ordinal_to_read < 19 {
8197                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8198                _next_ordinal_to_read += 1;
8199                next_offset += envelope_size;
8200            }
8201
8202            let next_out_of_line = decoder.next_out_of_line();
8203            let handles_before = decoder.remaining_handles();
8204            if let Some((inlined, num_bytes, num_handles)) =
8205                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8206            {
8207                let member_inline_size =
8208                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
8209                        decoder.context,
8210                    );
8211                if inlined != (member_inline_size <= 4) {
8212                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8213                }
8214                let inner_offset;
8215                let mut inner_depth = depth.clone();
8216                if inlined {
8217                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8218                    inner_offset = next_offset;
8219                } else {
8220                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8221                    inner_depth.increment()?;
8222                }
8223                let val_ref = self
8224                    .pad_for_block_size
8225                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
8226                fidl::decode!(
8227                    fidl_fuchsia_math__common::SizeU,
8228                    D,
8229                    val_ref,
8230                    decoder,
8231                    inner_offset,
8232                    inner_depth
8233                )?;
8234                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8235                {
8236                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8237                }
8238                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8239                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8240                }
8241            }
8242
8243            next_offset += envelope_size;
8244            _next_ordinal_to_read += 1;
8245            if next_offset >= end_offset {
8246                return Ok(());
8247            }
8248
8249            // Decode unknown envelopes for gaps in ordinals.
8250            while _next_ordinal_to_read < 20 {
8251                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8252                _next_ordinal_to_read += 1;
8253                next_offset += envelope_size;
8254            }
8255
8256            let next_out_of_line = decoder.next_out_of_line();
8257            let handles_before = decoder.remaining_handles();
8258            if let Some((inlined, num_bytes, num_handles)) =
8259                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8260            {
8261                let member_inline_size =
8262                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8263                if inlined != (member_inline_size <= 4) {
8264                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8265                }
8266                let inner_offset;
8267                let mut inner_depth = depth.clone();
8268                if inlined {
8269                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8270                    inner_offset = next_offset;
8271                } else {
8272                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8273                    inner_depth.increment()?;
8274                }
8275                let val_ref = self
8276                    .pad_beyond_image_size_bytes
8277                    .get_or_insert_with(|| fidl::new_empty!(u64, D));
8278                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
8279                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8280                {
8281                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8282                }
8283                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8284                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8285                }
8286            }
8287
8288            next_offset += envelope_size;
8289
8290            // Decode the remaining unknown envelopes.
8291            while next_offset < end_offset {
8292                _next_ordinal_to_read += 1;
8293                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8294                next_offset += envelope_size;
8295            }
8296
8297            Ok(())
8298        }
8299    }
8300
8301    impl NodeSetDebugClientInfoRequest {
8302        #[inline(always)]
8303        fn max_ordinal_present(&self) -> u64 {
8304            if let Some(_) = self.id {
8305                return 2;
8306            }
8307            if let Some(_) = self.name {
8308                return 1;
8309            }
8310            0
8311        }
8312    }
8313
8314    impl fidl::encoding::ValueTypeMarker for NodeSetDebugClientInfoRequest {
8315        type Borrowed<'a> = &'a Self;
8316        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8317            value
8318        }
8319    }
8320
8321    unsafe impl fidl::encoding::TypeMarker for NodeSetDebugClientInfoRequest {
8322        type Owned = Self;
8323
8324        #[inline(always)]
8325        fn inline_align(_context: fidl::encoding::Context) -> usize {
8326            8
8327        }
8328
8329        #[inline(always)]
8330        fn inline_size(_context: fidl::encoding::Context) -> usize {
8331            16
8332        }
8333    }
8334
8335    unsafe impl<D: fidl::encoding::ResourceDialect>
8336        fidl::encoding::Encode<NodeSetDebugClientInfoRequest, D>
8337        for &NodeSetDebugClientInfoRequest
8338    {
8339        unsafe fn encode(
8340            self,
8341            encoder: &mut fidl::encoding::Encoder<'_, D>,
8342            offset: usize,
8343            mut depth: fidl::encoding::Depth,
8344        ) -> fidl::Result<()> {
8345            encoder.debug_check_bounds::<NodeSetDebugClientInfoRequest>(offset);
8346            // Vector header
8347            let max_ordinal: u64 = self.max_ordinal_present();
8348            encoder.write_num(max_ordinal, offset);
8349            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8350            // Calling encoder.out_of_line_offset(0) is not allowed.
8351            if max_ordinal == 0 {
8352                return Ok(());
8353            }
8354            depth.increment()?;
8355            let envelope_size = 8;
8356            let bytes_len = max_ordinal as usize * envelope_size;
8357            #[allow(unused_variables)]
8358            let offset = encoder.out_of_line_offset(bytes_len);
8359            let mut _prev_end_offset: usize = 0;
8360            if 1 > max_ordinal {
8361                return Ok(());
8362            }
8363
8364            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8365            // are envelope_size bytes.
8366            let cur_offset: usize = (1 - 1) * envelope_size;
8367
8368            // Zero reserved fields.
8369            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8370
8371            // Safety:
8372            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8373            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8374            //   envelope_size bytes, there is always sufficient room.
8375            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
8376                self.name.as_ref().map(
8377                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
8378                ),
8379                encoder,
8380                offset + cur_offset,
8381                depth,
8382            )?;
8383
8384            _prev_end_offset = cur_offset + envelope_size;
8385            if 2 > max_ordinal {
8386                return Ok(());
8387            }
8388
8389            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8390            // are envelope_size bytes.
8391            let cur_offset: usize = (2 - 1) * envelope_size;
8392
8393            // Zero reserved fields.
8394            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8395
8396            // Safety:
8397            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8398            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8399            //   envelope_size bytes, there is always sufficient room.
8400            fidl::encoding::encode_in_envelope_optional::<u64, D>(
8401                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8402                encoder,
8403                offset + cur_offset,
8404                depth,
8405            )?;
8406
8407            _prev_end_offset = cur_offset + envelope_size;
8408
8409            Ok(())
8410        }
8411    }
8412
8413    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8414        for NodeSetDebugClientInfoRequest
8415    {
8416        #[inline(always)]
8417        fn new_empty() -> Self {
8418            Self::default()
8419        }
8420
8421        unsafe fn decode(
8422            &mut self,
8423            decoder: &mut fidl::encoding::Decoder<'_, D>,
8424            offset: usize,
8425            mut depth: fidl::encoding::Depth,
8426        ) -> fidl::Result<()> {
8427            decoder.debug_check_bounds::<Self>(offset);
8428            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8429                None => return Err(fidl::Error::NotNullable),
8430                Some(len) => len,
8431            };
8432            // Calling decoder.out_of_line_offset(0) is not allowed.
8433            if len == 0 {
8434                return Ok(());
8435            };
8436            depth.increment()?;
8437            let envelope_size = 8;
8438            let bytes_len = len * envelope_size;
8439            let offset = decoder.out_of_line_offset(bytes_len)?;
8440            // Decode the envelope for each type.
8441            let mut _next_ordinal_to_read = 0;
8442            let mut next_offset = offset;
8443            let end_offset = offset + bytes_len;
8444            _next_ordinal_to_read += 1;
8445            if next_offset >= end_offset {
8446                return Ok(());
8447            }
8448
8449            // Decode unknown envelopes for gaps in ordinals.
8450            while _next_ordinal_to_read < 1 {
8451                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8452                _next_ordinal_to_read += 1;
8453                next_offset += envelope_size;
8454            }
8455
8456            let next_out_of_line = decoder.next_out_of_line();
8457            let handles_before = decoder.remaining_handles();
8458            if let Some((inlined, num_bytes, num_handles)) =
8459                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8460            {
8461                let member_inline_size =
8462                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
8463                        decoder.context,
8464                    );
8465                if inlined != (member_inline_size <= 4) {
8466                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8467                }
8468                let inner_offset;
8469                let mut inner_depth = depth.clone();
8470                if inlined {
8471                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8472                    inner_offset = next_offset;
8473                } else {
8474                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8475                    inner_depth.increment()?;
8476                }
8477                let val_ref = self
8478                    .name
8479                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
8480                fidl::decode!(
8481                    fidl::encoding::BoundedString<256>,
8482                    D,
8483                    val_ref,
8484                    decoder,
8485                    inner_offset,
8486                    inner_depth
8487                )?;
8488                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8489                {
8490                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8491                }
8492                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8493                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8494                }
8495            }
8496
8497            next_offset += envelope_size;
8498            _next_ordinal_to_read += 1;
8499            if next_offset >= end_offset {
8500                return Ok(());
8501            }
8502
8503            // Decode unknown envelopes for gaps in ordinals.
8504            while _next_ordinal_to_read < 2 {
8505                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8506                _next_ordinal_to_read += 1;
8507                next_offset += envelope_size;
8508            }
8509
8510            let next_out_of_line = decoder.next_out_of_line();
8511            let handles_before = decoder.remaining_handles();
8512            if let Some((inlined, num_bytes, num_handles)) =
8513                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8514            {
8515                let member_inline_size =
8516                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8517                if inlined != (member_inline_size <= 4) {
8518                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8519                }
8520                let inner_offset;
8521                let mut inner_depth = depth.clone();
8522                if inlined {
8523                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8524                    inner_offset = next_offset;
8525                } else {
8526                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8527                    inner_depth.increment()?;
8528                }
8529                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
8530                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
8531                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8532                {
8533                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8534                }
8535                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8536                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8537                }
8538            }
8539
8540            next_offset += envelope_size;
8541
8542            // Decode the remaining unknown envelopes.
8543            while next_offset < end_offset {
8544                _next_ordinal_to_read += 1;
8545                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8546                next_offset += envelope_size;
8547            }
8548
8549            Ok(())
8550        }
8551    }
8552
8553    impl NodeSetDebugTimeoutLogDeadlineRequest {
8554        #[inline(always)]
8555        fn max_ordinal_present(&self) -> u64 {
8556            if let Some(_) = self.deadline {
8557                return 1;
8558            }
8559            0
8560        }
8561    }
8562
8563    impl fidl::encoding::ValueTypeMarker for NodeSetDebugTimeoutLogDeadlineRequest {
8564        type Borrowed<'a> = &'a Self;
8565        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8566            value
8567        }
8568    }
8569
8570    unsafe impl fidl::encoding::TypeMarker for NodeSetDebugTimeoutLogDeadlineRequest {
8571        type Owned = Self;
8572
8573        #[inline(always)]
8574        fn inline_align(_context: fidl::encoding::Context) -> usize {
8575            8
8576        }
8577
8578        #[inline(always)]
8579        fn inline_size(_context: fidl::encoding::Context) -> usize {
8580            16
8581        }
8582    }
8583
8584    unsafe impl<D: fidl::encoding::ResourceDialect>
8585        fidl::encoding::Encode<NodeSetDebugTimeoutLogDeadlineRequest, D>
8586        for &NodeSetDebugTimeoutLogDeadlineRequest
8587    {
8588        unsafe fn encode(
8589            self,
8590            encoder: &mut fidl::encoding::Encoder<'_, D>,
8591            offset: usize,
8592            mut depth: fidl::encoding::Depth,
8593        ) -> fidl::Result<()> {
8594            encoder.debug_check_bounds::<NodeSetDebugTimeoutLogDeadlineRequest>(offset);
8595            // Vector header
8596            let max_ordinal: u64 = self.max_ordinal_present();
8597            encoder.write_num(max_ordinal, offset);
8598            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8599            // Calling encoder.out_of_line_offset(0) is not allowed.
8600            if max_ordinal == 0 {
8601                return Ok(());
8602            }
8603            depth.increment()?;
8604            let envelope_size = 8;
8605            let bytes_len = max_ordinal as usize * envelope_size;
8606            #[allow(unused_variables)]
8607            let offset = encoder.out_of_line_offset(bytes_len);
8608            let mut _prev_end_offset: usize = 0;
8609            if 1 > max_ordinal {
8610                return Ok(());
8611            }
8612
8613            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8614            // are envelope_size bytes.
8615            let cur_offset: usize = (1 - 1) * envelope_size;
8616
8617            // Zero reserved fields.
8618            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8619
8620            // Safety:
8621            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8622            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8623            //   envelope_size bytes, there is always sufficient room.
8624            fidl::encoding::encode_in_envelope_optional::<i64, D>(
8625                self.deadline.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
8626                encoder,
8627                offset + cur_offset,
8628                depth,
8629            )?;
8630
8631            _prev_end_offset = cur_offset + envelope_size;
8632
8633            Ok(())
8634        }
8635    }
8636
8637    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8638        for NodeSetDebugTimeoutLogDeadlineRequest
8639    {
8640        #[inline(always)]
8641        fn new_empty() -> Self {
8642            Self::default()
8643        }
8644
8645        unsafe fn decode(
8646            &mut self,
8647            decoder: &mut fidl::encoding::Decoder<'_, D>,
8648            offset: usize,
8649            mut depth: fidl::encoding::Depth,
8650        ) -> fidl::Result<()> {
8651            decoder.debug_check_bounds::<Self>(offset);
8652            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8653                None => return Err(fidl::Error::NotNullable),
8654                Some(len) => len,
8655            };
8656            // Calling decoder.out_of_line_offset(0) is not allowed.
8657            if len == 0 {
8658                return Ok(());
8659            };
8660            depth.increment()?;
8661            let envelope_size = 8;
8662            let bytes_len = len * envelope_size;
8663            let offset = decoder.out_of_line_offset(bytes_len)?;
8664            // Decode the envelope for each type.
8665            let mut _next_ordinal_to_read = 0;
8666            let mut next_offset = offset;
8667            let end_offset = offset + bytes_len;
8668            _next_ordinal_to_read += 1;
8669            if next_offset >= end_offset {
8670                return Ok(());
8671            }
8672
8673            // Decode unknown envelopes for gaps in ordinals.
8674            while _next_ordinal_to_read < 1 {
8675                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8676                _next_ordinal_to_read += 1;
8677                next_offset += envelope_size;
8678            }
8679
8680            let next_out_of_line = decoder.next_out_of_line();
8681            let handles_before = decoder.remaining_handles();
8682            if let Some((inlined, num_bytes, num_handles)) =
8683                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8684            {
8685                let member_inline_size =
8686                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8687                if inlined != (member_inline_size <= 4) {
8688                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8689                }
8690                let inner_offset;
8691                let mut inner_depth = depth.clone();
8692                if inlined {
8693                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8694                    inner_offset = next_offset;
8695                } else {
8696                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8697                    inner_depth.increment()?;
8698                }
8699                let val_ref = self.deadline.get_or_insert_with(|| fidl::new_empty!(i64, D));
8700                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
8701                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8702                {
8703                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8704                }
8705                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8706                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8707                }
8708            }
8709
8710            next_offset += envelope_size;
8711
8712            // Decode the remaining unknown envelopes.
8713            while next_offset < end_offset {
8714                _next_ordinal_to_read += 1;
8715                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8716                next_offset += envelope_size;
8717            }
8718
8719            Ok(())
8720        }
8721    }
8722
8723    impl NodeSetNameRequest {
8724        #[inline(always)]
8725        fn max_ordinal_present(&self) -> u64 {
8726            if let Some(_) = self.name {
8727                return 2;
8728            }
8729            if let Some(_) = self.priority {
8730                return 1;
8731            }
8732            0
8733        }
8734    }
8735
8736    impl fidl::encoding::ValueTypeMarker for NodeSetNameRequest {
8737        type Borrowed<'a> = &'a Self;
8738        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8739            value
8740        }
8741    }
8742
8743    unsafe impl fidl::encoding::TypeMarker for NodeSetNameRequest {
8744        type Owned = Self;
8745
8746        #[inline(always)]
8747        fn inline_align(_context: fidl::encoding::Context) -> usize {
8748            8
8749        }
8750
8751        #[inline(always)]
8752        fn inline_size(_context: fidl::encoding::Context) -> usize {
8753            16
8754        }
8755    }
8756
8757    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NodeSetNameRequest, D>
8758        for &NodeSetNameRequest
8759    {
8760        unsafe fn encode(
8761            self,
8762            encoder: &mut fidl::encoding::Encoder<'_, D>,
8763            offset: usize,
8764            mut depth: fidl::encoding::Depth,
8765        ) -> fidl::Result<()> {
8766            encoder.debug_check_bounds::<NodeSetNameRequest>(offset);
8767            // Vector header
8768            let max_ordinal: u64 = self.max_ordinal_present();
8769            encoder.write_num(max_ordinal, offset);
8770            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8771            // Calling encoder.out_of_line_offset(0) is not allowed.
8772            if max_ordinal == 0 {
8773                return Ok(());
8774            }
8775            depth.increment()?;
8776            let envelope_size = 8;
8777            let bytes_len = max_ordinal as usize * envelope_size;
8778            #[allow(unused_variables)]
8779            let offset = encoder.out_of_line_offset(bytes_len);
8780            let mut _prev_end_offset: usize = 0;
8781            if 1 > max_ordinal {
8782                return Ok(());
8783            }
8784
8785            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8786            // are envelope_size bytes.
8787            let cur_offset: usize = (1 - 1) * envelope_size;
8788
8789            // Zero reserved fields.
8790            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8791
8792            // Safety:
8793            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8794            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8795            //   envelope_size bytes, there is always sufficient room.
8796            fidl::encoding::encode_in_envelope_optional::<u32, D>(
8797                self.priority.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
8798                encoder,
8799                offset + cur_offset,
8800                depth,
8801            )?;
8802
8803            _prev_end_offset = cur_offset + envelope_size;
8804            if 2 > max_ordinal {
8805                return Ok(());
8806            }
8807
8808            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8809            // are envelope_size bytes.
8810            let cur_offset: usize = (2 - 1) * envelope_size;
8811
8812            // Zero reserved fields.
8813            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8814
8815            // Safety:
8816            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8817            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8818            //   envelope_size bytes, there is always sufficient room.
8819            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<64>, D>(
8820                self.name.as_ref().map(
8821                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
8822                ),
8823                encoder,
8824                offset + cur_offset,
8825                depth,
8826            )?;
8827
8828            _prev_end_offset = cur_offset + envelope_size;
8829
8830            Ok(())
8831        }
8832    }
8833
8834    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NodeSetNameRequest {
8835        #[inline(always)]
8836        fn new_empty() -> Self {
8837            Self::default()
8838        }
8839
8840        unsafe fn decode(
8841            &mut self,
8842            decoder: &mut fidl::encoding::Decoder<'_, D>,
8843            offset: usize,
8844            mut depth: fidl::encoding::Depth,
8845        ) -> fidl::Result<()> {
8846            decoder.debug_check_bounds::<Self>(offset);
8847            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8848                None => return Err(fidl::Error::NotNullable),
8849                Some(len) => len,
8850            };
8851            // Calling decoder.out_of_line_offset(0) is not allowed.
8852            if len == 0 {
8853                return Ok(());
8854            };
8855            depth.increment()?;
8856            let envelope_size = 8;
8857            let bytes_len = len * envelope_size;
8858            let offset = decoder.out_of_line_offset(bytes_len)?;
8859            // Decode the envelope for each type.
8860            let mut _next_ordinal_to_read = 0;
8861            let mut next_offset = offset;
8862            let end_offset = offset + bytes_len;
8863            _next_ordinal_to_read += 1;
8864            if next_offset >= end_offset {
8865                return Ok(());
8866            }
8867
8868            // Decode unknown envelopes for gaps in ordinals.
8869            while _next_ordinal_to_read < 1 {
8870                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8871                _next_ordinal_to_read += 1;
8872                next_offset += envelope_size;
8873            }
8874
8875            let next_out_of_line = decoder.next_out_of_line();
8876            let handles_before = decoder.remaining_handles();
8877            if let Some((inlined, num_bytes, num_handles)) =
8878                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8879            {
8880                let member_inline_size =
8881                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8882                if inlined != (member_inline_size <= 4) {
8883                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8884                }
8885                let inner_offset;
8886                let mut inner_depth = depth.clone();
8887                if inlined {
8888                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8889                    inner_offset = next_offset;
8890                } else {
8891                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8892                    inner_depth.increment()?;
8893                }
8894                let val_ref = self.priority.get_or_insert_with(|| fidl::new_empty!(u32, D));
8895                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
8896                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8897                {
8898                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8899                }
8900                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8901                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8902                }
8903            }
8904
8905            next_offset += envelope_size;
8906            _next_ordinal_to_read += 1;
8907            if next_offset >= end_offset {
8908                return Ok(());
8909            }
8910
8911            // Decode unknown envelopes for gaps in ordinals.
8912            while _next_ordinal_to_read < 2 {
8913                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8914                _next_ordinal_to_read += 1;
8915                next_offset += envelope_size;
8916            }
8917
8918            let next_out_of_line = decoder.next_out_of_line();
8919            let handles_before = decoder.remaining_handles();
8920            if let Some((inlined, num_bytes, num_handles)) =
8921                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8922            {
8923                let member_inline_size =
8924                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
8925                        decoder.context,
8926                    );
8927                if inlined != (member_inline_size <= 4) {
8928                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8929                }
8930                let inner_offset;
8931                let mut inner_depth = depth.clone();
8932                if inlined {
8933                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8934                    inner_offset = next_offset;
8935                } else {
8936                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8937                    inner_depth.increment()?;
8938                }
8939                let val_ref = self
8940                    .name
8941                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<64>, D));
8942                fidl::decode!(
8943                    fidl::encoding::BoundedString<64>,
8944                    D,
8945                    val_ref,
8946                    decoder,
8947                    inner_offset,
8948                    inner_depth
8949                )?;
8950                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8951                {
8952                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8953                }
8954                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8955                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8956                }
8957            }
8958
8959            next_offset += envelope_size;
8960
8961            // Decode the remaining unknown envelopes.
8962            while next_offset < end_offset {
8963                _next_ordinal_to_read += 1;
8964                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8965                next_offset += envelope_size;
8966            }
8967
8968            Ok(())
8969        }
8970    }
8971
8972    impl NodeGetBufferCollectionIdResponse {
8973        #[inline(always)]
8974        fn max_ordinal_present(&self) -> u64 {
8975            if let Some(_) = self.buffer_collection_id {
8976                return 1;
8977            }
8978            0
8979        }
8980    }
8981
8982    impl fidl::encoding::ValueTypeMarker for NodeGetBufferCollectionIdResponse {
8983        type Borrowed<'a> = &'a Self;
8984        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8985            value
8986        }
8987    }
8988
8989    unsafe impl fidl::encoding::TypeMarker for NodeGetBufferCollectionIdResponse {
8990        type Owned = Self;
8991
8992        #[inline(always)]
8993        fn inline_align(_context: fidl::encoding::Context) -> usize {
8994            8
8995        }
8996
8997        #[inline(always)]
8998        fn inline_size(_context: fidl::encoding::Context) -> usize {
8999            16
9000        }
9001    }
9002
9003    unsafe impl<D: fidl::encoding::ResourceDialect>
9004        fidl::encoding::Encode<NodeGetBufferCollectionIdResponse, D>
9005        for &NodeGetBufferCollectionIdResponse
9006    {
9007        unsafe fn encode(
9008            self,
9009            encoder: &mut fidl::encoding::Encoder<'_, D>,
9010            offset: usize,
9011            mut depth: fidl::encoding::Depth,
9012        ) -> fidl::Result<()> {
9013            encoder.debug_check_bounds::<NodeGetBufferCollectionIdResponse>(offset);
9014            // Vector header
9015            let max_ordinal: u64 = self.max_ordinal_present();
9016            encoder.write_num(max_ordinal, offset);
9017            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9018            // Calling encoder.out_of_line_offset(0) is not allowed.
9019            if max_ordinal == 0 {
9020                return Ok(());
9021            }
9022            depth.increment()?;
9023            let envelope_size = 8;
9024            let bytes_len = max_ordinal as usize * envelope_size;
9025            #[allow(unused_variables)]
9026            let offset = encoder.out_of_line_offset(bytes_len);
9027            let mut _prev_end_offset: usize = 0;
9028            if 1 > max_ordinal {
9029                return Ok(());
9030            }
9031
9032            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9033            // are envelope_size bytes.
9034            let cur_offset: usize = (1 - 1) * envelope_size;
9035
9036            // Zero reserved fields.
9037            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9038
9039            // Safety:
9040            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9041            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9042            //   envelope_size bytes, there is always sufficient room.
9043            fidl::encoding::encode_in_envelope_optional::<u64, D>(
9044                self.buffer_collection_id
9045                    .as_ref()
9046                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9047                encoder,
9048                offset + cur_offset,
9049                depth,
9050            )?;
9051
9052            _prev_end_offset = cur_offset + envelope_size;
9053
9054            Ok(())
9055        }
9056    }
9057
9058    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9059        for NodeGetBufferCollectionIdResponse
9060    {
9061        #[inline(always)]
9062        fn new_empty() -> Self {
9063            Self::default()
9064        }
9065
9066        unsafe fn decode(
9067            &mut self,
9068            decoder: &mut fidl::encoding::Decoder<'_, D>,
9069            offset: usize,
9070            mut depth: fidl::encoding::Depth,
9071        ) -> fidl::Result<()> {
9072            decoder.debug_check_bounds::<Self>(offset);
9073            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9074                None => return Err(fidl::Error::NotNullable),
9075                Some(len) => len,
9076            };
9077            // Calling decoder.out_of_line_offset(0) is not allowed.
9078            if len == 0 {
9079                return Ok(());
9080            };
9081            depth.increment()?;
9082            let envelope_size = 8;
9083            let bytes_len = len * envelope_size;
9084            let offset = decoder.out_of_line_offset(bytes_len)?;
9085            // Decode the envelope for each type.
9086            let mut _next_ordinal_to_read = 0;
9087            let mut next_offset = offset;
9088            let end_offset = offset + bytes_len;
9089            _next_ordinal_to_read += 1;
9090            if next_offset >= end_offset {
9091                return Ok(());
9092            }
9093
9094            // Decode unknown envelopes for gaps in ordinals.
9095            while _next_ordinal_to_read < 1 {
9096                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9097                _next_ordinal_to_read += 1;
9098                next_offset += envelope_size;
9099            }
9100
9101            let next_out_of_line = decoder.next_out_of_line();
9102            let handles_before = decoder.remaining_handles();
9103            if let Some((inlined, num_bytes, num_handles)) =
9104                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9105            {
9106                let member_inline_size =
9107                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9108                if inlined != (member_inline_size <= 4) {
9109                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9110                }
9111                let inner_offset;
9112                let mut inner_depth = depth.clone();
9113                if inlined {
9114                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9115                    inner_offset = next_offset;
9116                } else {
9117                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9118                    inner_depth.increment()?;
9119                }
9120                let val_ref =
9121                    self.buffer_collection_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
9122                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
9123                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9124                {
9125                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9126                }
9127                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9128                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9129                }
9130            }
9131
9132            next_offset += envelope_size;
9133
9134            // Decode the remaining unknown envelopes.
9135            while next_offset < end_offset {
9136                _next_ordinal_to_read += 1;
9137                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9138                next_offset += envelope_size;
9139            }
9140
9141            Ok(())
9142        }
9143    }
9144
9145    impl NodeIsAlternateForResponse {
9146        #[inline(always)]
9147        fn max_ordinal_present(&self) -> u64 {
9148            if let Some(_) = self.is_alternate {
9149                return 1;
9150            }
9151            0
9152        }
9153    }
9154
9155    impl fidl::encoding::ValueTypeMarker for NodeIsAlternateForResponse {
9156        type Borrowed<'a> = &'a Self;
9157        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9158            value
9159        }
9160    }
9161
9162    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForResponse {
9163        type Owned = Self;
9164
9165        #[inline(always)]
9166        fn inline_align(_context: fidl::encoding::Context) -> usize {
9167            8
9168        }
9169
9170        #[inline(always)]
9171        fn inline_size(_context: fidl::encoding::Context) -> usize {
9172            16
9173        }
9174    }
9175
9176    unsafe impl<D: fidl::encoding::ResourceDialect>
9177        fidl::encoding::Encode<NodeIsAlternateForResponse, D> for &NodeIsAlternateForResponse
9178    {
9179        unsafe fn encode(
9180            self,
9181            encoder: &mut fidl::encoding::Encoder<'_, D>,
9182            offset: usize,
9183            mut depth: fidl::encoding::Depth,
9184        ) -> fidl::Result<()> {
9185            encoder.debug_check_bounds::<NodeIsAlternateForResponse>(offset);
9186            // Vector header
9187            let max_ordinal: u64 = self.max_ordinal_present();
9188            encoder.write_num(max_ordinal, offset);
9189            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9190            // Calling encoder.out_of_line_offset(0) is not allowed.
9191            if max_ordinal == 0 {
9192                return Ok(());
9193            }
9194            depth.increment()?;
9195            let envelope_size = 8;
9196            let bytes_len = max_ordinal as usize * envelope_size;
9197            #[allow(unused_variables)]
9198            let offset = encoder.out_of_line_offset(bytes_len);
9199            let mut _prev_end_offset: usize = 0;
9200            if 1 > max_ordinal {
9201                return Ok(());
9202            }
9203
9204            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9205            // are envelope_size bytes.
9206            let cur_offset: usize = (1 - 1) * envelope_size;
9207
9208            // Zero reserved fields.
9209            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9210
9211            // Safety:
9212            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9213            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9214            //   envelope_size bytes, there is always sufficient room.
9215            fidl::encoding::encode_in_envelope_optional::<bool, D>(
9216                self.is_alternate.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
9217                encoder,
9218                offset + cur_offset,
9219                depth,
9220            )?;
9221
9222            _prev_end_offset = cur_offset + envelope_size;
9223
9224            Ok(())
9225        }
9226    }
9227
9228    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9229        for NodeIsAlternateForResponse
9230    {
9231        #[inline(always)]
9232        fn new_empty() -> Self {
9233            Self::default()
9234        }
9235
9236        unsafe fn decode(
9237            &mut self,
9238            decoder: &mut fidl::encoding::Decoder<'_, D>,
9239            offset: usize,
9240            mut depth: fidl::encoding::Depth,
9241        ) -> fidl::Result<()> {
9242            decoder.debug_check_bounds::<Self>(offset);
9243            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9244                None => return Err(fidl::Error::NotNullable),
9245                Some(len) => len,
9246            };
9247            // Calling decoder.out_of_line_offset(0) is not allowed.
9248            if len == 0 {
9249                return Ok(());
9250            };
9251            depth.increment()?;
9252            let envelope_size = 8;
9253            let bytes_len = len * envelope_size;
9254            let offset = decoder.out_of_line_offset(bytes_len)?;
9255            // Decode the envelope for each type.
9256            let mut _next_ordinal_to_read = 0;
9257            let mut next_offset = offset;
9258            let end_offset = offset + bytes_len;
9259            _next_ordinal_to_read += 1;
9260            if next_offset >= end_offset {
9261                return Ok(());
9262            }
9263
9264            // Decode unknown envelopes for gaps in ordinals.
9265            while _next_ordinal_to_read < 1 {
9266                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9267                _next_ordinal_to_read += 1;
9268                next_offset += envelope_size;
9269            }
9270
9271            let next_out_of_line = decoder.next_out_of_line();
9272            let handles_before = decoder.remaining_handles();
9273            if let Some((inlined, num_bytes, num_handles)) =
9274                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9275            {
9276                let member_inline_size =
9277                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9278                if inlined != (member_inline_size <= 4) {
9279                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9280                }
9281                let inner_offset;
9282                let mut inner_depth = depth.clone();
9283                if inlined {
9284                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9285                    inner_offset = next_offset;
9286                } else {
9287                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9288                    inner_depth.increment()?;
9289                }
9290                let val_ref = self.is_alternate.get_or_insert_with(|| fidl::new_empty!(bool, D));
9291                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
9292                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9293                {
9294                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9295                }
9296                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9297                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9298                }
9299            }
9300
9301            next_offset += envelope_size;
9302
9303            // Decode the remaining unknown envelopes.
9304            while next_offset < end_offset {
9305                _next_ordinal_to_read += 1;
9306                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9307                next_offset += envelope_size;
9308            }
9309
9310            Ok(())
9311        }
9312    }
9313
9314    impl SecureHeapAndRange {
9315        #[inline(always)]
9316        fn max_ordinal_present(&self) -> u64 {
9317            if let Some(_) = self.range {
9318                return 2;
9319            }
9320            if let Some(_) = self.heap {
9321                return 1;
9322            }
9323            0
9324        }
9325    }
9326
9327    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRange {
9328        type Borrowed<'a> = &'a Self;
9329        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9330            value
9331        }
9332    }
9333
9334    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRange {
9335        type Owned = Self;
9336
9337        #[inline(always)]
9338        fn inline_align(_context: fidl::encoding::Context) -> usize {
9339            8
9340        }
9341
9342        #[inline(always)]
9343        fn inline_size(_context: fidl::encoding::Context) -> usize {
9344            16
9345        }
9346    }
9347
9348    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapAndRange, D>
9349        for &SecureHeapAndRange
9350    {
9351        unsafe fn encode(
9352            self,
9353            encoder: &mut fidl::encoding::Encoder<'_, D>,
9354            offset: usize,
9355            mut depth: fidl::encoding::Depth,
9356        ) -> fidl::Result<()> {
9357            encoder.debug_check_bounds::<SecureHeapAndRange>(offset);
9358            // Vector header
9359            let max_ordinal: u64 = self.max_ordinal_present();
9360            encoder.write_num(max_ordinal, offset);
9361            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9362            // Calling encoder.out_of_line_offset(0) is not allowed.
9363            if max_ordinal == 0 {
9364                return Ok(());
9365            }
9366            depth.increment()?;
9367            let envelope_size = 8;
9368            let bytes_len = max_ordinal as usize * envelope_size;
9369            #[allow(unused_variables)]
9370            let offset = encoder.out_of_line_offset(bytes_len);
9371            let mut _prev_end_offset: usize = 0;
9372            if 1 > max_ordinal {
9373                return Ok(());
9374            }
9375
9376            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9377            // are envelope_size bytes.
9378            let cur_offset: usize = (1 - 1) * envelope_size;
9379
9380            // Zero reserved fields.
9381            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9382
9383            // Safety:
9384            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9385            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9386            //   envelope_size bytes, there is always sufficient room.
9387            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9388                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9389                encoder,
9390                offset + cur_offset,
9391                depth,
9392            )?;
9393
9394            _prev_end_offset = cur_offset + envelope_size;
9395            if 2 > max_ordinal {
9396                return Ok(());
9397            }
9398
9399            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9400            // are envelope_size bytes.
9401            let cur_offset: usize = (2 - 1) * envelope_size;
9402
9403            // Zero reserved fields.
9404            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9405
9406            // Safety:
9407            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9408            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9409            //   envelope_size bytes, there is always sufficient room.
9410            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9411                self.range
9412                    .as_ref()
9413                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9414                encoder,
9415                offset + cur_offset,
9416                depth,
9417            )?;
9418
9419            _prev_end_offset = cur_offset + envelope_size;
9420
9421            Ok(())
9422        }
9423    }
9424
9425    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapAndRange {
9426        #[inline(always)]
9427        fn new_empty() -> Self {
9428            Self::default()
9429        }
9430
9431        unsafe fn decode(
9432            &mut self,
9433            decoder: &mut fidl::encoding::Decoder<'_, D>,
9434            offset: usize,
9435            mut depth: fidl::encoding::Depth,
9436        ) -> fidl::Result<()> {
9437            decoder.debug_check_bounds::<Self>(offset);
9438            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9439                None => return Err(fidl::Error::NotNullable),
9440                Some(len) => len,
9441            };
9442            // Calling decoder.out_of_line_offset(0) is not allowed.
9443            if len == 0 {
9444                return Ok(());
9445            };
9446            depth.increment()?;
9447            let envelope_size = 8;
9448            let bytes_len = len * envelope_size;
9449            let offset = decoder.out_of_line_offset(bytes_len)?;
9450            // Decode the envelope for each type.
9451            let mut _next_ordinal_to_read = 0;
9452            let mut next_offset = offset;
9453            let end_offset = offset + bytes_len;
9454            _next_ordinal_to_read += 1;
9455            if next_offset >= end_offset {
9456                return Ok(());
9457            }
9458
9459            // Decode unknown envelopes for gaps in ordinals.
9460            while _next_ordinal_to_read < 1 {
9461                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9462                _next_ordinal_to_read += 1;
9463                next_offset += envelope_size;
9464            }
9465
9466            let next_out_of_line = decoder.next_out_of_line();
9467            let handles_before = decoder.remaining_handles();
9468            if let Some((inlined, num_bytes, num_handles)) =
9469                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9470            {
9471                let member_inline_size =
9472                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9473                if inlined != (member_inline_size <= 4) {
9474                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9475                }
9476                let inner_offset;
9477                let mut inner_depth = depth.clone();
9478                if inlined {
9479                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9480                    inner_offset = next_offset;
9481                } else {
9482                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9483                    inner_depth.increment()?;
9484                }
9485                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9486                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9487                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9488                {
9489                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9490                }
9491                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9492                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9493                }
9494            }
9495
9496            next_offset += envelope_size;
9497            _next_ordinal_to_read += 1;
9498            if next_offset >= end_offset {
9499                return Ok(());
9500            }
9501
9502            // Decode unknown envelopes for gaps in ordinals.
9503            while _next_ordinal_to_read < 2 {
9504                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9505                _next_ordinal_to_read += 1;
9506                next_offset += envelope_size;
9507            }
9508
9509            let next_out_of_line = decoder.next_out_of_line();
9510            let handles_before = decoder.remaining_handles();
9511            if let Some((inlined, num_bytes, num_handles)) =
9512                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9513            {
9514                let member_inline_size =
9515                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9516                if inlined != (member_inline_size <= 4) {
9517                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9518                }
9519                let inner_offset;
9520                let mut inner_depth = depth.clone();
9521                if inlined {
9522                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9523                    inner_offset = next_offset;
9524                } else {
9525                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9526                    inner_depth.increment()?;
9527                }
9528                let val_ref =
9529                    self.range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9530                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9531                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9532                {
9533                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9534                }
9535                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9536                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9537                }
9538            }
9539
9540            next_offset += envelope_size;
9541
9542            // Decode the remaining unknown envelopes.
9543            while next_offset < end_offset {
9544                _next_ordinal_to_read += 1;
9545                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9546                next_offset += envelope_size;
9547            }
9548
9549            Ok(())
9550        }
9551    }
9552
9553    impl SecureHeapAndRangeModification {
9554        #[inline(always)]
9555        fn max_ordinal_present(&self) -> u64 {
9556            if let Some(_) = self.new_range {
9557                return 3;
9558            }
9559            if let Some(_) = self.old_range {
9560                return 2;
9561            }
9562            if let Some(_) = self.heap {
9563                return 1;
9564            }
9565            0
9566        }
9567    }
9568
9569    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRangeModification {
9570        type Borrowed<'a> = &'a Self;
9571        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9572            value
9573        }
9574    }
9575
9576    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRangeModification {
9577        type Owned = Self;
9578
9579        #[inline(always)]
9580        fn inline_align(_context: fidl::encoding::Context) -> usize {
9581            8
9582        }
9583
9584        #[inline(always)]
9585        fn inline_size(_context: fidl::encoding::Context) -> usize {
9586            16
9587        }
9588    }
9589
9590    unsafe impl<D: fidl::encoding::ResourceDialect>
9591        fidl::encoding::Encode<SecureHeapAndRangeModification, D>
9592        for &SecureHeapAndRangeModification
9593    {
9594        unsafe fn encode(
9595            self,
9596            encoder: &mut fidl::encoding::Encoder<'_, D>,
9597            offset: usize,
9598            mut depth: fidl::encoding::Depth,
9599        ) -> fidl::Result<()> {
9600            encoder.debug_check_bounds::<SecureHeapAndRangeModification>(offset);
9601            // Vector header
9602            let max_ordinal: u64 = self.max_ordinal_present();
9603            encoder.write_num(max_ordinal, offset);
9604            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9605            // Calling encoder.out_of_line_offset(0) is not allowed.
9606            if max_ordinal == 0 {
9607                return Ok(());
9608            }
9609            depth.increment()?;
9610            let envelope_size = 8;
9611            let bytes_len = max_ordinal as usize * envelope_size;
9612            #[allow(unused_variables)]
9613            let offset = encoder.out_of_line_offset(bytes_len);
9614            let mut _prev_end_offset: usize = 0;
9615            if 1 > max_ordinal {
9616                return Ok(());
9617            }
9618
9619            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9620            // are envelope_size bytes.
9621            let cur_offset: usize = (1 - 1) * envelope_size;
9622
9623            // Zero reserved fields.
9624            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9625
9626            // Safety:
9627            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9628            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9629            //   envelope_size bytes, there is always sufficient room.
9630            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9631                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9632                encoder,
9633                offset + cur_offset,
9634                depth,
9635            )?;
9636
9637            _prev_end_offset = cur_offset + envelope_size;
9638            if 2 > max_ordinal {
9639                return Ok(());
9640            }
9641
9642            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9643            // are envelope_size bytes.
9644            let cur_offset: usize = (2 - 1) * envelope_size;
9645
9646            // Zero reserved fields.
9647            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9648
9649            // Safety:
9650            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9651            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9652            //   envelope_size bytes, there is always sufficient room.
9653            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9654                self.old_range
9655                    .as_ref()
9656                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9657                encoder,
9658                offset + cur_offset,
9659                depth,
9660            )?;
9661
9662            _prev_end_offset = cur_offset + envelope_size;
9663            if 3 > max_ordinal {
9664                return Ok(());
9665            }
9666
9667            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9668            // are envelope_size bytes.
9669            let cur_offset: usize = (3 - 1) * envelope_size;
9670
9671            // Zero reserved fields.
9672            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9673
9674            // Safety:
9675            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9676            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9677            //   envelope_size bytes, there is always sufficient room.
9678            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9679                self.new_range
9680                    .as_ref()
9681                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9682                encoder,
9683                offset + cur_offset,
9684                depth,
9685            )?;
9686
9687            _prev_end_offset = cur_offset + envelope_size;
9688
9689            Ok(())
9690        }
9691    }
9692
9693    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9694        for SecureHeapAndRangeModification
9695    {
9696        #[inline(always)]
9697        fn new_empty() -> Self {
9698            Self::default()
9699        }
9700
9701        unsafe fn decode(
9702            &mut self,
9703            decoder: &mut fidl::encoding::Decoder<'_, D>,
9704            offset: usize,
9705            mut depth: fidl::encoding::Depth,
9706        ) -> fidl::Result<()> {
9707            decoder.debug_check_bounds::<Self>(offset);
9708            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9709                None => return Err(fidl::Error::NotNullable),
9710                Some(len) => len,
9711            };
9712            // Calling decoder.out_of_line_offset(0) is not allowed.
9713            if len == 0 {
9714                return Ok(());
9715            };
9716            depth.increment()?;
9717            let envelope_size = 8;
9718            let bytes_len = len * envelope_size;
9719            let offset = decoder.out_of_line_offset(bytes_len)?;
9720            // Decode the envelope for each type.
9721            let mut _next_ordinal_to_read = 0;
9722            let mut next_offset = offset;
9723            let end_offset = offset + bytes_len;
9724            _next_ordinal_to_read += 1;
9725            if next_offset >= end_offset {
9726                return Ok(());
9727            }
9728
9729            // Decode unknown envelopes for gaps in ordinals.
9730            while _next_ordinal_to_read < 1 {
9731                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9732                _next_ordinal_to_read += 1;
9733                next_offset += envelope_size;
9734            }
9735
9736            let next_out_of_line = decoder.next_out_of_line();
9737            let handles_before = decoder.remaining_handles();
9738            if let Some((inlined, num_bytes, num_handles)) =
9739                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9740            {
9741                let member_inline_size =
9742                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9743                if inlined != (member_inline_size <= 4) {
9744                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9745                }
9746                let inner_offset;
9747                let mut inner_depth = depth.clone();
9748                if inlined {
9749                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9750                    inner_offset = next_offset;
9751                } else {
9752                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9753                    inner_depth.increment()?;
9754                }
9755                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9756                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9757                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9758                {
9759                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9760                }
9761                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9762                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9763                }
9764            }
9765
9766            next_offset += envelope_size;
9767            _next_ordinal_to_read += 1;
9768            if next_offset >= end_offset {
9769                return Ok(());
9770            }
9771
9772            // Decode unknown envelopes for gaps in ordinals.
9773            while _next_ordinal_to_read < 2 {
9774                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9775                _next_ordinal_to_read += 1;
9776                next_offset += envelope_size;
9777            }
9778
9779            let next_out_of_line = decoder.next_out_of_line();
9780            let handles_before = decoder.remaining_handles();
9781            if let Some((inlined, num_bytes, num_handles)) =
9782                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9783            {
9784                let member_inline_size =
9785                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9786                if inlined != (member_inline_size <= 4) {
9787                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9788                }
9789                let inner_offset;
9790                let mut inner_depth = depth.clone();
9791                if inlined {
9792                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9793                    inner_offset = next_offset;
9794                } else {
9795                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9796                    inner_depth.increment()?;
9797                }
9798                let val_ref =
9799                    self.old_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9800                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9801                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9802                {
9803                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9804                }
9805                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9806                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9807                }
9808            }
9809
9810            next_offset += envelope_size;
9811            _next_ordinal_to_read += 1;
9812            if next_offset >= end_offset {
9813                return Ok(());
9814            }
9815
9816            // Decode unknown envelopes for gaps in ordinals.
9817            while _next_ordinal_to_read < 3 {
9818                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9819                _next_ordinal_to_read += 1;
9820                next_offset += envelope_size;
9821            }
9822
9823            let next_out_of_line = decoder.next_out_of_line();
9824            let handles_before = decoder.remaining_handles();
9825            if let Some((inlined, num_bytes, num_handles)) =
9826                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9827            {
9828                let member_inline_size =
9829                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9830                if inlined != (member_inline_size <= 4) {
9831                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9832                }
9833                let inner_offset;
9834                let mut inner_depth = depth.clone();
9835                if inlined {
9836                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9837                    inner_offset = next_offset;
9838                } else {
9839                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9840                    inner_depth.increment()?;
9841                }
9842                let val_ref =
9843                    self.new_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9844                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9845                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9846                {
9847                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9848                }
9849                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9850                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9851                }
9852            }
9853
9854            next_offset += envelope_size;
9855
9856            // Decode the remaining unknown envelopes.
9857            while next_offset < end_offset {
9858                _next_ordinal_to_read += 1;
9859                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9860                next_offset += envelope_size;
9861            }
9862
9863            Ok(())
9864        }
9865    }
9866
9867    impl SecureHeapAndRanges {
9868        #[inline(always)]
9869        fn max_ordinal_present(&self) -> u64 {
9870            if let Some(_) = self.ranges {
9871                return 2;
9872            }
9873            if let Some(_) = self.heap {
9874                return 1;
9875            }
9876            0
9877        }
9878    }
9879
9880    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRanges {
9881        type Borrowed<'a> = &'a Self;
9882        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9883            value
9884        }
9885    }
9886
9887    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRanges {
9888        type Owned = Self;
9889
9890        #[inline(always)]
9891        fn inline_align(_context: fidl::encoding::Context) -> usize {
9892            8
9893        }
9894
9895        #[inline(always)]
9896        fn inline_size(_context: fidl::encoding::Context) -> usize {
9897            16
9898        }
9899    }
9900
9901    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapAndRanges, D>
9902        for &SecureHeapAndRanges
9903    {
9904        unsafe fn encode(
9905            self,
9906            encoder: &mut fidl::encoding::Encoder<'_, D>,
9907            offset: usize,
9908            mut depth: fidl::encoding::Depth,
9909        ) -> fidl::Result<()> {
9910            encoder.debug_check_bounds::<SecureHeapAndRanges>(offset);
9911            // Vector header
9912            let max_ordinal: u64 = self.max_ordinal_present();
9913            encoder.write_num(max_ordinal, offset);
9914            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9915            // Calling encoder.out_of_line_offset(0) is not allowed.
9916            if max_ordinal == 0 {
9917                return Ok(());
9918            }
9919            depth.increment()?;
9920            let envelope_size = 8;
9921            let bytes_len = max_ordinal as usize * envelope_size;
9922            #[allow(unused_variables)]
9923            let offset = encoder.out_of_line_offset(bytes_len);
9924            let mut _prev_end_offset: usize = 0;
9925            if 1 > max_ordinal {
9926                return Ok(());
9927            }
9928
9929            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9930            // are envelope_size bytes.
9931            let cur_offset: usize = (1 - 1) * envelope_size;
9932
9933            // Zero reserved fields.
9934            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9935
9936            // Safety:
9937            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9938            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9939            //   envelope_size bytes, there is always sufficient room.
9940            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9941                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9942                encoder,
9943                offset + cur_offset,
9944                depth,
9945            )?;
9946
9947            _prev_end_offset = cur_offset + envelope_size;
9948            if 2 > max_ordinal {
9949                return Ok(());
9950            }
9951
9952            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9953            // are envelope_size bytes.
9954            let cur_offset: usize = (2 - 1) * envelope_size;
9955
9956            // Zero reserved fields.
9957            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9958
9959            // Safety:
9960            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9961            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9962            //   envelope_size bytes, there is always sufficient room.
9963            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SecureHeapRange, 128>, D>(
9964            self.ranges.as_ref().map(<fidl::encoding::Vector<SecureHeapRange, 128> as fidl::encoding::ValueTypeMarker>::borrow),
9965            encoder, offset + cur_offset, depth
9966        )?;
9967
9968            _prev_end_offset = cur_offset + envelope_size;
9969
9970            Ok(())
9971        }
9972    }
9973
9974    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapAndRanges {
9975        #[inline(always)]
9976        fn new_empty() -> Self {
9977            Self::default()
9978        }
9979
9980        unsafe fn decode(
9981            &mut self,
9982            decoder: &mut fidl::encoding::Decoder<'_, D>,
9983            offset: usize,
9984            mut depth: fidl::encoding::Depth,
9985        ) -> fidl::Result<()> {
9986            decoder.debug_check_bounds::<Self>(offset);
9987            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9988                None => return Err(fidl::Error::NotNullable),
9989                Some(len) => len,
9990            };
9991            // Calling decoder.out_of_line_offset(0) is not allowed.
9992            if len == 0 {
9993                return Ok(());
9994            };
9995            depth.increment()?;
9996            let envelope_size = 8;
9997            let bytes_len = len * envelope_size;
9998            let offset = decoder.out_of_line_offset(bytes_len)?;
9999            // Decode the envelope for each type.
10000            let mut _next_ordinal_to_read = 0;
10001            let mut next_offset = offset;
10002            let end_offset = offset + bytes_len;
10003            _next_ordinal_to_read += 1;
10004            if next_offset >= end_offset {
10005                return Ok(());
10006            }
10007
10008            // Decode unknown envelopes for gaps in ordinals.
10009            while _next_ordinal_to_read < 1 {
10010                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10011                _next_ordinal_to_read += 1;
10012                next_offset += envelope_size;
10013            }
10014
10015            let next_out_of_line = decoder.next_out_of_line();
10016            let handles_before = decoder.remaining_handles();
10017            if let Some((inlined, num_bytes, num_handles)) =
10018                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10019            {
10020                let member_inline_size =
10021                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10022                if inlined != (member_inline_size <= 4) {
10023                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10024                }
10025                let inner_offset;
10026                let mut inner_depth = depth.clone();
10027                if inlined {
10028                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10029                    inner_offset = next_offset;
10030                } else {
10031                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10032                    inner_depth.increment()?;
10033                }
10034                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
10035                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
10036                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10037                {
10038                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10039                }
10040                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10041                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10042                }
10043            }
10044
10045            next_offset += envelope_size;
10046            _next_ordinal_to_read += 1;
10047            if next_offset >= end_offset {
10048                return Ok(());
10049            }
10050
10051            // Decode unknown envelopes for gaps in ordinals.
10052            while _next_ordinal_to_read < 2 {
10053                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10054                _next_ordinal_to_read += 1;
10055                next_offset += envelope_size;
10056            }
10057
10058            let next_out_of_line = decoder.next_out_of_line();
10059            let handles_before = decoder.remaining_handles();
10060            if let Some((inlined, num_bytes, num_handles)) =
10061                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10062            {
10063                let member_inline_size = <fidl::encoding::Vector<SecureHeapRange, 128> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10064                if inlined != (member_inline_size <= 4) {
10065                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10066                }
10067                let inner_offset;
10068                let mut inner_depth = depth.clone();
10069                if inlined {
10070                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10071                    inner_offset = next_offset;
10072                } else {
10073                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10074                    inner_depth.increment()?;
10075                }
10076                let val_ref = self.ranges.get_or_insert_with(
10077                    || fidl::new_empty!(fidl::encoding::Vector<SecureHeapRange, 128>, D),
10078                );
10079                fidl::decode!(fidl::encoding::Vector<SecureHeapRange, 128>, D, val_ref, decoder, inner_offset, inner_depth)?;
10080                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10081                {
10082                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10083                }
10084                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10085                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10086                }
10087            }
10088
10089            next_offset += envelope_size;
10090
10091            // Decode the remaining unknown envelopes.
10092            while next_offset < end_offset {
10093                _next_ordinal_to_read += 1;
10094                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10095                next_offset += envelope_size;
10096            }
10097
10098            Ok(())
10099        }
10100    }
10101
10102    impl SecureHeapProperties {
10103        #[inline(always)]
10104        fn max_ordinal_present(&self) -> u64 {
10105            if let Some(_) = self.is_mod_protected_range_available {
10106                return 5;
10107            }
10108            if let Some(_) = self.max_protected_range_count {
10109                return 4;
10110            }
10111            if let Some(_) = self.protected_range_granularity {
10112                return 3;
10113            }
10114            if let Some(_) = self.dynamic_protection_ranges {
10115                return 2;
10116            }
10117            if let Some(_) = self.heap {
10118                return 1;
10119            }
10120            0
10121        }
10122    }
10123
10124    impl fidl::encoding::ValueTypeMarker for SecureHeapProperties {
10125        type Borrowed<'a> = &'a Self;
10126        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10127            value
10128        }
10129    }
10130
10131    unsafe impl fidl::encoding::TypeMarker for SecureHeapProperties {
10132        type Owned = Self;
10133
10134        #[inline(always)]
10135        fn inline_align(_context: fidl::encoding::Context) -> usize {
10136            8
10137        }
10138
10139        #[inline(always)]
10140        fn inline_size(_context: fidl::encoding::Context) -> usize {
10141            16
10142        }
10143    }
10144
10145    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapProperties, D>
10146        for &SecureHeapProperties
10147    {
10148        unsafe fn encode(
10149            self,
10150            encoder: &mut fidl::encoding::Encoder<'_, D>,
10151            offset: usize,
10152            mut depth: fidl::encoding::Depth,
10153        ) -> fidl::Result<()> {
10154            encoder.debug_check_bounds::<SecureHeapProperties>(offset);
10155            // Vector header
10156            let max_ordinal: u64 = self.max_ordinal_present();
10157            encoder.write_num(max_ordinal, offset);
10158            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10159            // Calling encoder.out_of_line_offset(0) is not allowed.
10160            if max_ordinal == 0 {
10161                return Ok(());
10162            }
10163            depth.increment()?;
10164            let envelope_size = 8;
10165            let bytes_len = max_ordinal as usize * envelope_size;
10166            #[allow(unused_variables)]
10167            let offset = encoder.out_of_line_offset(bytes_len);
10168            let mut _prev_end_offset: usize = 0;
10169            if 1 > max_ordinal {
10170                return Ok(());
10171            }
10172
10173            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10174            // are envelope_size bytes.
10175            let cur_offset: usize = (1 - 1) * envelope_size;
10176
10177            // Zero reserved fields.
10178            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10179
10180            // Safety:
10181            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10182            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10183            //   envelope_size bytes, there is always sufficient room.
10184            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
10185                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
10186                encoder,
10187                offset + cur_offset,
10188                depth,
10189            )?;
10190
10191            _prev_end_offset = cur_offset + envelope_size;
10192            if 2 > max_ordinal {
10193                return Ok(());
10194            }
10195
10196            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10197            // are envelope_size bytes.
10198            let cur_offset: usize = (2 - 1) * envelope_size;
10199
10200            // Zero reserved fields.
10201            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10202
10203            // Safety:
10204            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10205            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10206            //   envelope_size bytes, there is always sufficient room.
10207            fidl::encoding::encode_in_envelope_optional::<bool, D>(
10208                self.dynamic_protection_ranges
10209                    .as_ref()
10210                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
10211                encoder,
10212                offset + cur_offset,
10213                depth,
10214            )?;
10215
10216            _prev_end_offset = cur_offset + envelope_size;
10217            if 3 > max_ordinal {
10218                return Ok(());
10219            }
10220
10221            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10222            // are envelope_size bytes.
10223            let cur_offset: usize = (3 - 1) * envelope_size;
10224
10225            // Zero reserved fields.
10226            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10227
10228            // Safety:
10229            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10230            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10231            //   envelope_size bytes, there is always sufficient room.
10232            fidl::encoding::encode_in_envelope_optional::<u32, D>(
10233                self.protected_range_granularity
10234                    .as_ref()
10235                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
10236                encoder,
10237                offset + cur_offset,
10238                depth,
10239            )?;
10240
10241            _prev_end_offset = cur_offset + envelope_size;
10242            if 4 > max_ordinal {
10243                return Ok(());
10244            }
10245
10246            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10247            // are envelope_size bytes.
10248            let cur_offset: usize = (4 - 1) * envelope_size;
10249
10250            // Zero reserved fields.
10251            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10252
10253            // Safety:
10254            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10255            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10256            //   envelope_size bytes, there is always sufficient room.
10257            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10258                self.max_protected_range_count
10259                    .as_ref()
10260                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10261                encoder,
10262                offset + cur_offset,
10263                depth,
10264            )?;
10265
10266            _prev_end_offset = cur_offset + envelope_size;
10267            if 5 > max_ordinal {
10268                return Ok(());
10269            }
10270
10271            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10272            // are envelope_size bytes.
10273            let cur_offset: usize = (5 - 1) * envelope_size;
10274
10275            // Zero reserved fields.
10276            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10277
10278            // Safety:
10279            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10280            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10281            //   envelope_size bytes, there is always sufficient room.
10282            fidl::encoding::encode_in_envelope_optional::<bool, D>(
10283                self.is_mod_protected_range_available
10284                    .as_ref()
10285                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
10286                encoder,
10287                offset + cur_offset,
10288                depth,
10289            )?;
10290
10291            _prev_end_offset = cur_offset + envelope_size;
10292
10293            Ok(())
10294        }
10295    }
10296
10297    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapProperties {
10298        #[inline(always)]
10299        fn new_empty() -> Self {
10300            Self::default()
10301        }
10302
10303        unsafe fn decode(
10304            &mut self,
10305            decoder: &mut fidl::encoding::Decoder<'_, D>,
10306            offset: usize,
10307            mut depth: fidl::encoding::Depth,
10308        ) -> fidl::Result<()> {
10309            decoder.debug_check_bounds::<Self>(offset);
10310            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10311                None => return Err(fidl::Error::NotNullable),
10312                Some(len) => len,
10313            };
10314            // Calling decoder.out_of_line_offset(0) is not allowed.
10315            if len == 0 {
10316                return Ok(());
10317            };
10318            depth.increment()?;
10319            let envelope_size = 8;
10320            let bytes_len = len * envelope_size;
10321            let offset = decoder.out_of_line_offset(bytes_len)?;
10322            // Decode the envelope for each type.
10323            let mut _next_ordinal_to_read = 0;
10324            let mut next_offset = offset;
10325            let end_offset = offset + bytes_len;
10326            _next_ordinal_to_read += 1;
10327            if next_offset >= end_offset {
10328                return Ok(());
10329            }
10330
10331            // Decode unknown envelopes for gaps in ordinals.
10332            while _next_ordinal_to_read < 1 {
10333                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10334                _next_ordinal_to_read += 1;
10335                next_offset += envelope_size;
10336            }
10337
10338            let next_out_of_line = decoder.next_out_of_line();
10339            let handles_before = decoder.remaining_handles();
10340            if let Some((inlined, num_bytes, num_handles)) =
10341                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10342            {
10343                let member_inline_size =
10344                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10345                if inlined != (member_inline_size <= 4) {
10346                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10347                }
10348                let inner_offset;
10349                let mut inner_depth = depth.clone();
10350                if inlined {
10351                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10352                    inner_offset = next_offset;
10353                } else {
10354                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10355                    inner_depth.increment()?;
10356                }
10357                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
10358                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
10359                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10360                {
10361                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10362                }
10363                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10364                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10365                }
10366            }
10367
10368            next_offset += envelope_size;
10369            _next_ordinal_to_read += 1;
10370            if next_offset >= end_offset {
10371                return Ok(());
10372            }
10373
10374            // Decode unknown envelopes for gaps in ordinals.
10375            while _next_ordinal_to_read < 2 {
10376                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10377                _next_ordinal_to_read += 1;
10378                next_offset += envelope_size;
10379            }
10380
10381            let next_out_of_line = decoder.next_out_of_line();
10382            let handles_before = decoder.remaining_handles();
10383            if let Some((inlined, num_bytes, num_handles)) =
10384                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10385            {
10386                let member_inline_size =
10387                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10388                if inlined != (member_inline_size <= 4) {
10389                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10390                }
10391                let inner_offset;
10392                let mut inner_depth = depth.clone();
10393                if inlined {
10394                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10395                    inner_offset = next_offset;
10396                } else {
10397                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10398                    inner_depth.increment()?;
10399                }
10400                let val_ref =
10401                    self.dynamic_protection_ranges.get_or_insert_with(|| fidl::new_empty!(bool, D));
10402                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
10403                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10404                {
10405                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10406                }
10407                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10408                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10409                }
10410            }
10411
10412            next_offset += envelope_size;
10413            _next_ordinal_to_read += 1;
10414            if next_offset >= end_offset {
10415                return Ok(());
10416            }
10417
10418            // Decode unknown envelopes for gaps in ordinals.
10419            while _next_ordinal_to_read < 3 {
10420                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10421                _next_ordinal_to_read += 1;
10422                next_offset += envelope_size;
10423            }
10424
10425            let next_out_of_line = decoder.next_out_of_line();
10426            let handles_before = decoder.remaining_handles();
10427            if let Some((inlined, num_bytes, num_handles)) =
10428                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10429            {
10430                let member_inline_size =
10431                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10432                if inlined != (member_inline_size <= 4) {
10433                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10434                }
10435                let inner_offset;
10436                let mut inner_depth = depth.clone();
10437                if inlined {
10438                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10439                    inner_offset = next_offset;
10440                } else {
10441                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10442                    inner_depth.increment()?;
10443                }
10444                let val_ref = self
10445                    .protected_range_granularity
10446                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
10447                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
10448                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10449                {
10450                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10451                }
10452                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10453                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10454                }
10455            }
10456
10457            next_offset += envelope_size;
10458            _next_ordinal_to_read += 1;
10459            if next_offset >= end_offset {
10460                return Ok(());
10461            }
10462
10463            // Decode unknown envelopes for gaps in ordinals.
10464            while _next_ordinal_to_read < 4 {
10465                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10466                _next_ordinal_to_read += 1;
10467                next_offset += envelope_size;
10468            }
10469
10470            let next_out_of_line = decoder.next_out_of_line();
10471            let handles_before = decoder.remaining_handles();
10472            if let Some((inlined, num_bytes, num_handles)) =
10473                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10474            {
10475                let member_inline_size =
10476                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10477                if inlined != (member_inline_size <= 4) {
10478                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10479                }
10480                let inner_offset;
10481                let mut inner_depth = depth.clone();
10482                if inlined {
10483                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10484                    inner_offset = next_offset;
10485                } else {
10486                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10487                    inner_depth.increment()?;
10488                }
10489                let val_ref =
10490                    self.max_protected_range_count.get_or_insert_with(|| fidl::new_empty!(u64, D));
10491                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10492                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10493                {
10494                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10495                }
10496                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10497                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10498                }
10499            }
10500
10501            next_offset += envelope_size;
10502            _next_ordinal_to_read += 1;
10503            if next_offset >= end_offset {
10504                return Ok(());
10505            }
10506
10507            // Decode unknown envelopes for gaps in ordinals.
10508            while _next_ordinal_to_read < 5 {
10509                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10510                _next_ordinal_to_read += 1;
10511                next_offset += envelope_size;
10512            }
10513
10514            let next_out_of_line = decoder.next_out_of_line();
10515            let handles_before = decoder.remaining_handles();
10516            if let Some((inlined, num_bytes, num_handles)) =
10517                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10518            {
10519                let member_inline_size =
10520                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10521                if inlined != (member_inline_size <= 4) {
10522                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10523                }
10524                let inner_offset;
10525                let mut inner_depth = depth.clone();
10526                if inlined {
10527                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10528                    inner_offset = next_offset;
10529                } else {
10530                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10531                    inner_depth.increment()?;
10532                }
10533                let val_ref = self
10534                    .is_mod_protected_range_available
10535                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
10536                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
10537                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10538                {
10539                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10540                }
10541                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10542                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10543                }
10544            }
10545
10546            next_offset += envelope_size;
10547
10548            // Decode the remaining unknown envelopes.
10549            while next_offset < end_offset {
10550                _next_ordinal_to_read += 1;
10551                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10552                next_offset += envelope_size;
10553            }
10554
10555            Ok(())
10556        }
10557    }
10558
10559    impl SecureHeapRange {
10560        #[inline(always)]
10561        fn max_ordinal_present(&self) -> u64 {
10562            if let Some(_) = self.size_bytes {
10563                return 2;
10564            }
10565            if let Some(_) = self.physical_address {
10566                return 1;
10567            }
10568            0
10569        }
10570    }
10571
10572    impl fidl::encoding::ValueTypeMarker for SecureHeapRange {
10573        type Borrowed<'a> = &'a Self;
10574        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10575            value
10576        }
10577    }
10578
10579    unsafe impl fidl::encoding::TypeMarker for SecureHeapRange {
10580        type Owned = Self;
10581
10582        #[inline(always)]
10583        fn inline_align(_context: fidl::encoding::Context) -> usize {
10584            8
10585        }
10586
10587        #[inline(always)]
10588        fn inline_size(_context: fidl::encoding::Context) -> usize {
10589            16
10590        }
10591    }
10592
10593    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapRange, D>
10594        for &SecureHeapRange
10595    {
10596        unsafe fn encode(
10597            self,
10598            encoder: &mut fidl::encoding::Encoder<'_, D>,
10599            offset: usize,
10600            mut depth: fidl::encoding::Depth,
10601        ) -> fidl::Result<()> {
10602            encoder.debug_check_bounds::<SecureHeapRange>(offset);
10603            // Vector header
10604            let max_ordinal: u64 = self.max_ordinal_present();
10605            encoder.write_num(max_ordinal, offset);
10606            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10607            // Calling encoder.out_of_line_offset(0) is not allowed.
10608            if max_ordinal == 0 {
10609                return Ok(());
10610            }
10611            depth.increment()?;
10612            let envelope_size = 8;
10613            let bytes_len = max_ordinal as usize * envelope_size;
10614            #[allow(unused_variables)]
10615            let offset = encoder.out_of_line_offset(bytes_len);
10616            let mut _prev_end_offset: usize = 0;
10617            if 1 > max_ordinal {
10618                return Ok(());
10619            }
10620
10621            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10622            // are envelope_size bytes.
10623            let cur_offset: usize = (1 - 1) * envelope_size;
10624
10625            // Zero reserved fields.
10626            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10627
10628            // Safety:
10629            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10630            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10631            //   envelope_size bytes, there is always sufficient room.
10632            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10633                self.physical_address
10634                    .as_ref()
10635                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10636                encoder,
10637                offset + cur_offset,
10638                depth,
10639            )?;
10640
10641            _prev_end_offset = cur_offset + envelope_size;
10642            if 2 > max_ordinal {
10643                return Ok(());
10644            }
10645
10646            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10647            // are envelope_size bytes.
10648            let cur_offset: usize = (2 - 1) * envelope_size;
10649
10650            // Zero reserved fields.
10651            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10652
10653            // Safety:
10654            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10655            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10656            //   envelope_size bytes, there is always sufficient room.
10657            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10658                self.size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10659                encoder,
10660                offset + cur_offset,
10661                depth,
10662            )?;
10663
10664            _prev_end_offset = cur_offset + envelope_size;
10665
10666            Ok(())
10667        }
10668    }
10669
10670    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapRange {
10671        #[inline(always)]
10672        fn new_empty() -> Self {
10673            Self::default()
10674        }
10675
10676        unsafe fn decode(
10677            &mut self,
10678            decoder: &mut fidl::encoding::Decoder<'_, D>,
10679            offset: usize,
10680            mut depth: fidl::encoding::Depth,
10681        ) -> fidl::Result<()> {
10682            decoder.debug_check_bounds::<Self>(offset);
10683            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10684                None => return Err(fidl::Error::NotNullable),
10685                Some(len) => len,
10686            };
10687            // Calling decoder.out_of_line_offset(0) is not allowed.
10688            if len == 0 {
10689                return Ok(());
10690            };
10691            depth.increment()?;
10692            let envelope_size = 8;
10693            let bytes_len = len * envelope_size;
10694            let offset = decoder.out_of_line_offset(bytes_len)?;
10695            // Decode the envelope for each type.
10696            let mut _next_ordinal_to_read = 0;
10697            let mut next_offset = offset;
10698            let end_offset = offset + bytes_len;
10699            _next_ordinal_to_read += 1;
10700            if next_offset >= end_offset {
10701                return Ok(());
10702            }
10703
10704            // Decode unknown envelopes for gaps in ordinals.
10705            while _next_ordinal_to_read < 1 {
10706                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10707                _next_ordinal_to_read += 1;
10708                next_offset += envelope_size;
10709            }
10710
10711            let next_out_of_line = decoder.next_out_of_line();
10712            let handles_before = decoder.remaining_handles();
10713            if let Some((inlined, num_bytes, num_handles)) =
10714                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10715            {
10716                let member_inline_size =
10717                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10718                if inlined != (member_inline_size <= 4) {
10719                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10720                }
10721                let inner_offset;
10722                let mut inner_depth = depth.clone();
10723                if inlined {
10724                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10725                    inner_offset = next_offset;
10726                } else {
10727                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10728                    inner_depth.increment()?;
10729                }
10730                let val_ref = self.physical_address.get_or_insert_with(|| fidl::new_empty!(u64, D));
10731                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10732                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10733                {
10734                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10735                }
10736                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10737                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10738                }
10739            }
10740
10741            next_offset += envelope_size;
10742            _next_ordinal_to_read += 1;
10743            if next_offset >= end_offset {
10744                return Ok(());
10745            }
10746
10747            // Decode unknown envelopes for gaps in ordinals.
10748            while _next_ordinal_to_read < 2 {
10749                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10750                _next_ordinal_to_read += 1;
10751                next_offset += envelope_size;
10752            }
10753
10754            let next_out_of_line = decoder.next_out_of_line();
10755            let handles_before = decoder.remaining_handles();
10756            if let Some((inlined, num_bytes, num_handles)) =
10757                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10758            {
10759                let member_inline_size =
10760                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10761                if inlined != (member_inline_size <= 4) {
10762                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10763                }
10764                let inner_offset;
10765                let mut inner_depth = depth.clone();
10766                if inlined {
10767                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10768                    inner_offset = next_offset;
10769                } else {
10770                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10771                    inner_depth.increment()?;
10772                }
10773                let val_ref = self.size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
10774                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10775                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10776                {
10777                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10778                }
10779                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10780                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10781                }
10782            }
10783
10784            next_offset += envelope_size;
10785
10786            // Decode the remaining unknown envelopes.
10787            while next_offset < end_offset {
10788                _next_ordinal_to_read += 1;
10789                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10790                next_offset += envelope_size;
10791            }
10792
10793            Ok(())
10794        }
10795    }
10796
10797    impl SecureMemAddSecureHeapPhysicalRangeRequest {
10798        #[inline(always)]
10799        fn max_ordinal_present(&self) -> u64 {
10800            if let Some(_) = self.heap_range {
10801                return 1;
10802            }
10803            0
10804        }
10805    }
10806
10807    impl fidl::encoding::ValueTypeMarker for SecureMemAddSecureHeapPhysicalRangeRequest {
10808        type Borrowed<'a> = &'a Self;
10809        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10810            value
10811        }
10812    }
10813
10814    unsafe impl fidl::encoding::TypeMarker for SecureMemAddSecureHeapPhysicalRangeRequest {
10815        type Owned = Self;
10816
10817        #[inline(always)]
10818        fn inline_align(_context: fidl::encoding::Context) -> usize {
10819            8
10820        }
10821
10822        #[inline(always)]
10823        fn inline_size(_context: fidl::encoding::Context) -> usize {
10824            16
10825        }
10826    }
10827
10828    unsafe impl<D: fidl::encoding::ResourceDialect>
10829        fidl::encoding::Encode<SecureMemAddSecureHeapPhysicalRangeRequest, D>
10830        for &SecureMemAddSecureHeapPhysicalRangeRequest
10831    {
10832        unsafe fn encode(
10833            self,
10834            encoder: &mut fidl::encoding::Encoder<'_, D>,
10835            offset: usize,
10836            mut depth: fidl::encoding::Depth,
10837        ) -> fidl::Result<()> {
10838            encoder.debug_check_bounds::<SecureMemAddSecureHeapPhysicalRangeRequest>(offset);
10839            // Vector header
10840            let max_ordinal: u64 = self.max_ordinal_present();
10841            encoder.write_num(max_ordinal, offset);
10842            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10843            // Calling encoder.out_of_line_offset(0) is not allowed.
10844            if max_ordinal == 0 {
10845                return Ok(());
10846            }
10847            depth.increment()?;
10848            let envelope_size = 8;
10849            let bytes_len = max_ordinal as usize * envelope_size;
10850            #[allow(unused_variables)]
10851            let offset = encoder.out_of_line_offset(bytes_len);
10852            let mut _prev_end_offset: usize = 0;
10853            if 1 > max_ordinal {
10854                return Ok(());
10855            }
10856
10857            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10858            // are envelope_size bytes.
10859            let cur_offset: usize = (1 - 1) * envelope_size;
10860
10861            // Zero reserved fields.
10862            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10863
10864            // Safety:
10865            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10866            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10867            //   envelope_size bytes, there is always sufficient room.
10868            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
10869                self.heap_range
10870                    .as_ref()
10871                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
10872                encoder,
10873                offset + cur_offset,
10874                depth,
10875            )?;
10876
10877            _prev_end_offset = cur_offset + envelope_size;
10878
10879            Ok(())
10880        }
10881    }
10882
10883    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
10884        for SecureMemAddSecureHeapPhysicalRangeRequest
10885    {
10886        #[inline(always)]
10887        fn new_empty() -> Self {
10888            Self::default()
10889        }
10890
10891        unsafe fn decode(
10892            &mut self,
10893            decoder: &mut fidl::encoding::Decoder<'_, D>,
10894            offset: usize,
10895            mut depth: fidl::encoding::Depth,
10896        ) -> fidl::Result<()> {
10897            decoder.debug_check_bounds::<Self>(offset);
10898            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10899                None => return Err(fidl::Error::NotNullable),
10900                Some(len) => len,
10901            };
10902            // Calling decoder.out_of_line_offset(0) is not allowed.
10903            if len == 0 {
10904                return Ok(());
10905            };
10906            depth.increment()?;
10907            let envelope_size = 8;
10908            let bytes_len = len * envelope_size;
10909            let offset = decoder.out_of_line_offset(bytes_len)?;
10910            // Decode the envelope for each type.
10911            let mut _next_ordinal_to_read = 0;
10912            let mut next_offset = offset;
10913            let end_offset = offset + bytes_len;
10914            _next_ordinal_to_read += 1;
10915            if next_offset >= end_offset {
10916                return Ok(());
10917            }
10918
10919            // Decode unknown envelopes for gaps in ordinals.
10920            while _next_ordinal_to_read < 1 {
10921                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10922                _next_ordinal_to_read += 1;
10923                next_offset += envelope_size;
10924            }
10925
10926            let next_out_of_line = decoder.next_out_of_line();
10927            let handles_before = decoder.remaining_handles();
10928            if let Some((inlined, num_bytes, num_handles)) =
10929                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10930            {
10931                let member_inline_size =
10932                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
10933                        decoder.context,
10934                    );
10935                if inlined != (member_inline_size <= 4) {
10936                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10937                }
10938                let inner_offset;
10939                let mut inner_depth = depth.clone();
10940                if inlined {
10941                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10942                    inner_offset = next_offset;
10943                } else {
10944                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10945                    inner_depth.increment()?;
10946                }
10947                let val_ref =
10948                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
10949                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
10950                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10951                {
10952                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10953                }
10954                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10955                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10956                }
10957            }
10958
10959            next_offset += envelope_size;
10960
10961            // Decode the remaining unknown envelopes.
10962            while next_offset < end_offset {
10963                _next_ordinal_to_read += 1;
10964                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10965                next_offset += envelope_size;
10966            }
10967
10968            Ok(())
10969        }
10970    }
10971
10972    impl SecureMemDeleteSecureHeapPhysicalRangeRequest {
10973        #[inline(always)]
10974        fn max_ordinal_present(&self) -> u64 {
10975            if let Some(_) = self.heap_range {
10976                return 1;
10977            }
10978            0
10979        }
10980    }
10981
10982    impl fidl::encoding::ValueTypeMarker for SecureMemDeleteSecureHeapPhysicalRangeRequest {
10983        type Borrowed<'a> = &'a Self;
10984        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10985            value
10986        }
10987    }
10988
10989    unsafe impl fidl::encoding::TypeMarker for SecureMemDeleteSecureHeapPhysicalRangeRequest {
10990        type Owned = Self;
10991
10992        #[inline(always)]
10993        fn inline_align(_context: fidl::encoding::Context) -> usize {
10994            8
10995        }
10996
10997        #[inline(always)]
10998        fn inline_size(_context: fidl::encoding::Context) -> usize {
10999            16
11000        }
11001    }
11002
11003    unsafe impl<D: fidl::encoding::ResourceDialect>
11004        fidl::encoding::Encode<SecureMemDeleteSecureHeapPhysicalRangeRequest, D>
11005        for &SecureMemDeleteSecureHeapPhysicalRangeRequest
11006    {
11007        unsafe fn encode(
11008            self,
11009            encoder: &mut fidl::encoding::Encoder<'_, D>,
11010            offset: usize,
11011            mut depth: fidl::encoding::Depth,
11012        ) -> fidl::Result<()> {
11013            encoder.debug_check_bounds::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(offset);
11014            // Vector header
11015            let max_ordinal: u64 = self.max_ordinal_present();
11016            encoder.write_num(max_ordinal, offset);
11017            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11018            // Calling encoder.out_of_line_offset(0) is not allowed.
11019            if max_ordinal == 0 {
11020                return Ok(());
11021            }
11022            depth.increment()?;
11023            let envelope_size = 8;
11024            let bytes_len = max_ordinal as usize * envelope_size;
11025            #[allow(unused_variables)]
11026            let offset = encoder.out_of_line_offset(bytes_len);
11027            let mut _prev_end_offset: usize = 0;
11028            if 1 > max_ordinal {
11029                return Ok(());
11030            }
11031
11032            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11033            // are envelope_size bytes.
11034            let cur_offset: usize = (1 - 1) * envelope_size;
11035
11036            // Zero reserved fields.
11037            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11038
11039            // Safety:
11040            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11041            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11042            //   envelope_size bytes, there is always sufficient room.
11043            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11044                self.heap_range
11045                    .as_ref()
11046                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11047                encoder,
11048                offset + cur_offset,
11049                depth,
11050            )?;
11051
11052            _prev_end_offset = cur_offset + envelope_size;
11053
11054            Ok(())
11055        }
11056    }
11057
11058    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11059        for SecureMemDeleteSecureHeapPhysicalRangeRequest
11060    {
11061        #[inline(always)]
11062        fn new_empty() -> Self {
11063            Self::default()
11064        }
11065
11066        unsafe fn decode(
11067            &mut self,
11068            decoder: &mut fidl::encoding::Decoder<'_, D>,
11069            offset: usize,
11070            mut depth: fidl::encoding::Depth,
11071        ) -> fidl::Result<()> {
11072            decoder.debug_check_bounds::<Self>(offset);
11073            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11074                None => return Err(fidl::Error::NotNullable),
11075                Some(len) => len,
11076            };
11077            // Calling decoder.out_of_line_offset(0) is not allowed.
11078            if len == 0 {
11079                return Ok(());
11080            };
11081            depth.increment()?;
11082            let envelope_size = 8;
11083            let bytes_len = len * envelope_size;
11084            let offset = decoder.out_of_line_offset(bytes_len)?;
11085            // Decode the envelope for each type.
11086            let mut _next_ordinal_to_read = 0;
11087            let mut next_offset = offset;
11088            let end_offset = offset + bytes_len;
11089            _next_ordinal_to_read += 1;
11090            if next_offset >= end_offset {
11091                return Ok(());
11092            }
11093
11094            // Decode unknown envelopes for gaps in ordinals.
11095            while _next_ordinal_to_read < 1 {
11096                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11097                _next_ordinal_to_read += 1;
11098                next_offset += envelope_size;
11099            }
11100
11101            let next_out_of_line = decoder.next_out_of_line();
11102            let handles_before = decoder.remaining_handles();
11103            if let Some((inlined, num_bytes, num_handles)) =
11104                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11105            {
11106                let member_inline_size =
11107                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11108                        decoder.context,
11109                    );
11110                if inlined != (member_inline_size <= 4) {
11111                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11112                }
11113                let inner_offset;
11114                let mut inner_depth = depth.clone();
11115                if inlined {
11116                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11117                    inner_offset = next_offset;
11118                } else {
11119                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11120                    inner_depth.increment()?;
11121                }
11122                let val_ref =
11123                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11124                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11125                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11126                {
11127                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11128                }
11129                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11130                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11131                }
11132            }
11133
11134            next_offset += envelope_size;
11135
11136            // Decode the remaining unknown envelopes.
11137            while next_offset < end_offset {
11138                _next_ordinal_to_read += 1;
11139                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11140                next_offset += envelope_size;
11141            }
11142
11143            Ok(())
11144        }
11145    }
11146
11147    impl SecureMemGetPhysicalSecureHeapPropertiesRequest {
11148        #[inline(always)]
11149        fn max_ordinal_present(&self) -> u64 {
11150            if let Some(_) = self.entire_heap {
11151                return 1;
11152            }
11153            0
11154        }
11155    }
11156
11157    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapPropertiesRequest {
11158        type Borrowed<'a> = &'a Self;
11159        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11160            value
11161        }
11162    }
11163
11164    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapPropertiesRequest {
11165        type Owned = Self;
11166
11167        #[inline(always)]
11168        fn inline_align(_context: fidl::encoding::Context) -> usize {
11169            8
11170        }
11171
11172        #[inline(always)]
11173        fn inline_size(_context: fidl::encoding::Context) -> usize {
11174            16
11175        }
11176    }
11177
11178    unsafe impl<D: fidl::encoding::ResourceDialect>
11179        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapPropertiesRequest, D>
11180        for &SecureMemGetPhysicalSecureHeapPropertiesRequest
11181    {
11182        unsafe fn encode(
11183            self,
11184            encoder: &mut fidl::encoding::Encoder<'_, D>,
11185            offset: usize,
11186            mut depth: fidl::encoding::Depth,
11187        ) -> fidl::Result<()> {
11188            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(offset);
11189            // Vector header
11190            let max_ordinal: u64 = self.max_ordinal_present();
11191            encoder.write_num(max_ordinal, offset);
11192            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11193            // Calling encoder.out_of_line_offset(0) is not allowed.
11194            if max_ordinal == 0 {
11195                return Ok(());
11196            }
11197            depth.increment()?;
11198            let envelope_size = 8;
11199            let bytes_len = max_ordinal as usize * envelope_size;
11200            #[allow(unused_variables)]
11201            let offset = encoder.out_of_line_offset(bytes_len);
11202            let mut _prev_end_offset: usize = 0;
11203            if 1 > max_ordinal {
11204                return Ok(());
11205            }
11206
11207            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11208            // are envelope_size bytes.
11209            let cur_offset: usize = (1 - 1) * envelope_size;
11210
11211            // Zero reserved fields.
11212            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11213
11214            // Safety:
11215            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11216            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11217            //   envelope_size bytes, there is always sufficient room.
11218            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11219                self.entire_heap
11220                    .as_ref()
11221                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11222                encoder,
11223                offset + cur_offset,
11224                depth,
11225            )?;
11226
11227            _prev_end_offset = cur_offset + envelope_size;
11228
11229            Ok(())
11230        }
11231    }
11232
11233    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11234        for SecureMemGetPhysicalSecureHeapPropertiesRequest
11235    {
11236        #[inline(always)]
11237        fn new_empty() -> Self {
11238            Self::default()
11239        }
11240
11241        unsafe fn decode(
11242            &mut self,
11243            decoder: &mut fidl::encoding::Decoder<'_, D>,
11244            offset: usize,
11245            mut depth: fidl::encoding::Depth,
11246        ) -> fidl::Result<()> {
11247            decoder.debug_check_bounds::<Self>(offset);
11248            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11249                None => return Err(fidl::Error::NotNullable),
11250                Some(len) => len,
11251            };
11252            // Calling decoder.out_of_line_offset(0) is not allowed.
11253            if len == 0 {
11254                return Ok(());
11255            };
11256            depth.increment()?;
11257            let envelope_size = 8;
11258            let bytes_len = len * envelope_size;
11259            let offset = decoder.out_of_line_offset(bytes_len)?;
11260            // Decode the envelope for each type.
11261            let mut _next_ordinal_to_read = 0;
11262            let mut next_offset = offset;
11263            let end_offset = offset + bytes_len;
11264            _next_ordinal_to_read += 1;
11265            if next_offset >= end_offset {
11266                return Ok(());
11267            }
11268
11269            // Decode unknown envelopes for gaps in ordinals.
11270            while _next_ordinal_to_read < 1 {
11271                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11272                _next_ordinal_to_read += 1;
11273                next_offset += envelope_size;
11274            }
11275
11276            let next_out_of_line = decoder.next_out_of_line();
11277            let handles_before = decoder.remaining_handles();
11278            if let Some((inlined, num_bytes, num_handles)) =
11279                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11280            {
11281                let member_inline_size =
11282                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11283                        decoder.context,
11284                    );
11285                if inlined != (member_inline_size <= 4) {
11286                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11287                }
11288                let inner_offset;
11289                let mut inner_depth = depth.clone();
11290                if inlined {
11291                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11292                    inner_offset = next_offset;
11293                } else {
11294                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11295                    inner_depth.increment()?;
11296                }
11297                let val_ref =
11298                    self.entire_heap.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11299                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11300                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11301                {
11302                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11303                }
11304                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11305                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11306                }
11307            }
11308
11309            next_offset += envelope_size;
11310
11311            // Decode the remaining unknown envelopes.
11312            while next_offset < end_offset {
11313                _next_ordinal_to_read += 1;
11314                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11315                next_offset += envelope_size;
11316            }
11317
11318            Ok(())
11319        }
11320    }
11321
11322    impl SecureMemModifySecureHeapPhysicalRangeRequest {
11323        #[inline(always)]
11324        fn max_ordinal_present(&self) -> u64 {
11325            if let Some(_) = self.range_modification {
11326                return 1;
11327            }
11328            0
11329        }
11330    }
11331
11332    impl fidl::encoding::ValueTypeMarker for SecureMemModifySecureHeapPhysicalRangeRequest {
11333        type Borrowed<'a> = &'a Self;
11334        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11335            value
11336        }
11337    }
11338
11339    unsafe impl fidl::encoding::TypeMarker for SecureMemModifySecureHeapPhysicalRangeRequest {
11340        type Owned = Self;
11341
11342        #[inline(always)]
11343        fn inline_align(_context: fidl::encoding::Context) -> usize {
11344            8
11345        }
11346
11347        #[inline(always)]
11348        fn inline_size(_context: fidl::encoding::Context) -> usize {
11349            16
11350        }
11351    }
11352
11353    unsafe impl<D: fidl::encoding::ResourceDialect>
11354        fidl::encoding::Encode<SecureMemModifySecureHeapPhysicalRangeRequest, D>
11355        for &SecureMemModifySecureHeapPhysicalRangeRequest
11356    {
11357        unsafe fn encode(
11358            self,
11359            encoder: &mut fidl::encoding::Encoder<'_, D>,
11360            offset: usize,
11361            mut depth: fidl::encoding::Depth,
11362        ) -> fidl::Result<()> {
11363            encoder.debug_check_bounds::<SecureMemModifySecureHeapPhysicalRangeRequest>(offset);
11364            // Vector header
11365            let max_ordinal: u64 = self.max_ordinal_present();
11366            encoder.write_num(max_ordinal, offset);
11367            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11368            // Calling encoder.out_of_line_offset(0) is not allowed.
11369            if max_ordinal == 0 {
11370                return Ok(());
11371            }
11372            depth.increment()?;
11373            let envelope_size = 8;
11374            let bytes_len = max_ordinal as usize * envelope_size;
11375            #[allow(unused_variables)]
11376            let offset = encoder.out_of_line_offset(bytes_len);
11377            let mut _prev_end_offset: usize = 0;
11378            if 1 > max_ordinal {
11379                return Ok(());
11380            }
11381
11382            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11383            // are envelope_size bytes.
11384            let cur_offset: usize = (1 - 1) * envelope_size;
11385
11386            // Zero reserved fields.
11387            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11388
11389            // Safety:
11390            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11391            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11392            //   envelope_size bytes, there is always sufficient room.
11393            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRangeModification, D>(
11394                self.range_modification.as_ref().map(
11395                    <SecureHeapAndRangeModification as fidl::encoding::ValueTypeMarker>::borrow,
11396                ),
11397                encoder,
11398                offset + cur_offset,
11399                depth,
11400            )?;
11401
11402            _prev_end_offset = cur_offset + envelope_size;
11403
11404            Ok(())
11405        }
11406    }
11407
11408    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11409        for SecureMemModifySecureHeapPhysicalRangeRequest
11410    {
11411        #[inline(always)]
11412        fn new_empty() -> Self {
11413            Self::default()
11414        }
11415
11416        unsafe fn decode(
11417            &mut self,
11418            decoder: &mut fidl::encoding::Decoder<'_, D>,
11419            offset: usize,
11420            mut depth: fidl::encoding::Depth,
11421        ) -> fidl::Result<()> {
11422            decoder.debug_check_bounds::<Self>(offset);
11423            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11424                None => return Err(fidl::Error::NotNullable),
11425                Some(len) => len,
11426            };
11427            // Calling decoder.out_of_line_offset(0) is not allowed.
11428            if len == 0 {
11429                return Ok(());
11430            };
11431            depth.increment()?;
11432            let envelope_size = 8;
11433            let bytes_len = len * envelope_size;
11434            let offset = decoder.out_of_line_offset(bytes_len)?;
11435            // Decode the envelope for each type.
11436            let mut _next_ordinal_to_read = 0;
11437            let mut next_offset = offset;
11438            let end_offset = offset + bytes_len;
11439            _next_ordinal_to_read += 1;
11440            if next_offset >= end_offset {
11441                return Ok(());
11442            }
11443
11444            // Decode unknown envelopes for gaps in ordinals.
11445            while _next_ordinal_to_read < 1 {
11446                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11447                _next_ordinal_to_read += 1;
11448                next_offset += envelope_size;
11449            }
11450
11451            let next_out_of_line = decoder.next_out_of_line();
11452            let handles_before = decoder.remaining_handles();
11453            if let Some((inlined, num_bytes, num_handles)) =
11454                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11455            {
11456                let member_inline_size =
11457                    <SecureHeapAndRangeModification as fidl::encoding::TypeMarker>::inline_size(
11458                        decoder.context,
11459                    );
11460                if inlined != (member_inline_size <= 4) {
11461                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11462                }
11463                let inner_offset;
11464                let mut inner_depth = depth.clone();
11465                if inlined {
11466                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11467                    inner_offset = next_offset;
11468                } else {
11469                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11470                    inner_depth.increment()?;
11471                }
11472                let val_ref = self
11473                    .range_modification
11474                    .get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRangeModification, D));
11475                fidl::decode!(
11476                    SecureHeapAndRangeModification,
11477                    D,
11478                    val_ref,
11479                    decoder,
11480                    inner_offset,
11481                    inner_depth
11482                )?;
11483                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11484                {
11485                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11486                }
11487                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11488                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11489                }
11490            }
11491
11492            next_offset += envelope_size;
11493
11494            // Decode the remaining unknown envelopes.
11495            while next_offset < end_offset {
11496                _next_ordinal_to_read += 1;
11497                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11498                next_offset += envelope_size;
11499            }
11500
11501            Ok(())
11502        }
11503    }
11504
11505    impl SecureMemZeroSubRangeRequest {
11506        #[inline(always)]
11507        fn max_ordinal_present(&self) -> u64 {
11508            if let Some(_) = self.heap_range {
11509                return 2;
11510            }
11511            if let Some(_) = self.is_covering_range_explicit {
11512                return 1;
11513            }
11514            0
11515        }
11516    }
11517
11518    impl fidl::encoding::ValueTypeMarker for SecureMemZeroSubRangeRequest {
11519        type Borrowed<'a> = &'a Self;
11520        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11521            value
11522        }
11523    }
11524
11525    unsafe impl fidl::encoding::TypeMarker for SecureMemZeroSubRangeRequest {
11526        type Owned = Self;
11527
11528        #[inline(always)]
11529        fn inline_align(_context: fidl::encoding::Context) -> usize {
11530            8
11531        }
11532
11533        #[inline(always)]
11534        fn inline_size(_context: fidl::encoding::Context) -> usize {
11535            16
11536        }
11537    }
11538
11539    unsafe impl<D: fidl::encoding::ResourceDialect>
11540        fidl::encoding::Encode<SecureMemZeroSubRangeRequest, D> for &SecureMemZeroSubRangeRequest
11541    {
11542        unsafe fn encode(
11543            self,
11544            encoder: &mut fidl::encoding::Encoder<'_, D>,
11545            offset: usize,
11546            mut depth: fidl::encoding::Depth,
11547        ) -> fidl::Result<()> {
11548            encoder.debug_check_bounds::<SecureMemZeroSubRangeRequest>(offset);
11549            // Vector header
11550            let max_ordinal: u64 = self.max_ordinal_present();
11551            encoder.write_num(max_ordinal, offset);
11552            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11553            // Calling encoder.out_of_line_offset(0) is not allowed.
11554            if max_ordinal == 0 {
11555                return Ok(());
11556            }
11557            depth.increment()?;
11558            let envelope_size = 8;
11559            let bytes_len = max_ordinal as usize * envelope_size;
11560            #[allow(unused_variables)]
11561            let offset = encoder.out_of_line_offset(bytes_len);
11562            let mut _prev_end_offset: usize = 0;
11563            if 1 > max_ordinal {
11564                return Ok(());
11565            }
11566
11567            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11568            // are envelope_size bytes.
11569            let cur_offset: usize = (1 - 1) * envelope_size;
11570
11571            // Zero reserved fields.
11572            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11573
11574            // Safety:
11575            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11576            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11577            //   envelope_size bytes, there is always sufficient room.
11578            fidl::encoding::encode_in_envelope_optional::<bool, D>(
11579                self.is_covering_range_explicit
11580                    .as_ref()
11581                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11582                encoder,
11583                offset + cur_offset,
11584                depth,
11585            )?;
11586
11587            _prev_end_offset = cur_offset + envelope_size;
11588            if 2 > max_ordinal {
11589                return Ok(());
11590            }
11591
11592            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11593            // are envelope_size bytes.
11594            let cur_offset: usize = (2 - 1) * envelope_size;
11595
11596            // Zero reserved fields.
11597            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11598
11599            // Safety:
11600            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11601            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11602            //   envelope_size bytes, there is always sufficient room.
11603            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11604                self.heap_range
11605                    .as_ref()
11606                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11607                encoder,
11608                offset + cur_offset,
11609                depth,
11610            )?;
11611
11612            _prev_end_offset = cur_offset + envelope_size;
11613
11614            Ok(())
11615        }
11616    }
11617
11618    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11619        for SecureMemZeroSubRangeRequest
11620    {
11621        #[inline(always)]
11622        fn new_empty() -> Self {
11623            Self::default()
11624        }
11625
11626        unsafe fn decode(
11627            &mut self,
11628            decoder: &mut fidl::encoding::Decoder<'_, D>,
11629            offset: usize,
11630            mut depth: fidl::encoding::Depth,
11631        ) -> fidl::Result<()> {
11632            decoder.debug_check_bounds::<Self>(offset);
11633            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11634                None => return Err(fidl::Error::NotNullable),
11635                Some(len) => len,
11636            };
11637            // Calling decoder.out_of_line_offset(0) is not allowed.
11638            if len == 0 {
11639                return Ok(());
11640            };
11641            depth.increment()?;
11642            let envelope_size = 8;
11643            let bytes_len = len * envelope_size;
11644            let offset = decoder.out_of_line_offset(bytes_len)?;
11645            // Decode the envelope for each type.
11646            let mut _next_ordinal_to_read = 0;
11647            let mut next_offset = offset;
11648            let end_offset = offset + bytes_len;
11649            _next_ordinal_to_read += 1;
11650            if next_offset >= end_offset {
11651                return Ok(());
11652            }
11653
11654            // Decode unknown envelopes for gaps in ordinals.
11655            while _next_ordinal_to_read < 1 {
11656                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11657                _next_ordinal_to_read += 1;
11658                next_offset += envelope_size;
11659            }
11660
11661            let next_out_of_line = decoder.next_out_of_line();
11662            let handles_before = decoder.remaining_handles();
11663            if let Some((inlined, num_bytes, num_handles)) =
11664                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11665            {
11666                let member_inline_size =
11667                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11668                if inlined != (member_inline_size <= 4) {
11669                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11670                }
11671                let inner_offset;
11672                let mut inner_depth = depth.clone();
11673                if inlined {
11674                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11675                    inner_offset = next_offset;
11676                } else {
11677                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11678                    inner_depth.increment()?;
11679                }
11680                let val_ref = self
11681                    .is_covering_range_explicit
11682                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
11683                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
11684                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11685                {
11686                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11687                }
11688                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11689                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11690                }
11691            }
11692
11693            next_offset += envelope_size;
11694            _next_ordinal_to_read += 1;
11695            if next_offset >= end_offset {
11696                return Ok(());
11697            }
11698
11699            // Decode unknown envelopes for gaps in ordinals.
11700            while _next_ordinal_to_read < 2 {
11701                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11702                _next_ordinal_to_read += 1;
11703                next_offset += envelope_size;
11704            }
11705
11706            let next_out_of_line = decoder.next_out_of_line();
11707            let handles_before = decoder.remaining_handles();
11708            if let Some((inlined, num_bytes, num_handles)) =
11709                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11710            {
11711                let member_inline_size =
11712                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11713                        decoder.context,
11714                    );
11715                if inlined != (member_inline_size <= 4) {
11716                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11717                }
11718                let inner_offset;
11719                let mut inner_depth = depth.clone();
11720                if inlined {
11721                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11722                    inner_offset = next_offset;
11723                } else {
11724                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11725                    inner_depth.increment()?;
11726                }
11727                let val_ref =
11728                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11729                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11730                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11731                {
11732                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11733                }
11734                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11735                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11736                }
11737            }
11738
11739            next_offset += envelope_size;
11740
11741            // Decode the remaining unknown envelopes.
11742            while next_offset < end_offset {
11743                _next_ordinal_to_read += 1;
11744                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11745                next_offset += envelope_size;
11746            }
11747
11748            Ok(())
11749        }
11750    }
11751
11752    impl SecureMemGetDynamicSecureHeapsResponse {
11753        #[inline(always)]
11754        fn max_ordinal_present(&self) -> u64 {
11755            if let Some(_) = self.heaps {
11756                return 1;
11757            }
11758            0
11759        }
11760    }
11761
11762    impl fidl::encoding::ValueTypeMarker for SecureMemGetDynamicSecureHeapsResponse {
11763        type Borrowed<'a> = &'a Self;
11764        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11765            value
11766        }
11767    }
11768
11769    unsafe impl fidl::encoding::TypeMarker for SecureMemGetDynamicSecureHeapsResponse {
11770        type Owned = Self;
11771
11772        #[inline(always)]
11773        fn inline_align(_context: fidl::encoding::Context) -> usize {
11774            8
11775        }
11776
11777        #[inline(always)]
11778        fn inline_size(_context: fidl::encoding::Context) -> usize {
11779            16
11780        }
11781    }
11782
11783    unsafe impl<D: fidl::encoding::ResourceDialect>
11784        fidl::encoding::Encode<SecureMemGetDynamicSecureHeapsResponse, D>
11785        for &SecureMemGetDynamicSecureHeapsResponse
11786    {
11787        unsafe fn encode(
11788            self,
11789            encoder: &mut fidl::encoding::Encoder<'_, D>,
11790            offset: usize,
11791            mut depth: fidl::encoding::Depth,
11792        ) -> fidl::Result<()> {
11793            encoder.debug_check_bounds::<SecureMemGetDynamicSecureHeapsResponse>(offset);
11794            // Vector header
11795            let max_ordinal: u64 = self.max_ordinal_present();
11796            encoder.write_num(max_ordinal, offset);
11797            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11798            // Calling encoder.out_of_line_offset(0) is not allowed.
11799            if max_ordinal == 0 {
11800                return Ok(());
11801            }
11802            depth.increment()?;
11803            let envelope_size = 8;
11804            let bytes_len = max_ordinal as usize * envelope_size;
11805            #[allow(unused_variables)]
11806            let offset = encoder.out_of_line_offset(bytes_len);
11807            let mut _prev_end_offset: usize = 0;
11808            if 1 > max_ordinal {
11809                return Ok(());
11810            }
11811
11812            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11813            // are envelope_size bytes.
11814            let cur_offset: usize = (1 - 1) * envelope_size;
11815
11816            // Zero reserved fields.
11817            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11818
11819            // Safety:
11820            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11821            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11822            //   envelope_size bytes, there is always sufficient room.
11823            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<DynamicSecureHeap, 32>, D>(
11824            self.heaps.as_ref().map(<fidl::encoding::Vector<DynamicSecureHeap, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11825            encoder, offset + cur_offset, depth
11826        )?;
11827
11828            _prev_end_offset = cur_offset + envelope_size;
11829
11830            Ok(())
11831        }
11832    }
11833
11834    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11835        for SecureMemGetDynamicSecureHeapsResponse
11836    {
11837        #[inline(always)]
11838        fn new_empty() -> Self {
11839            Self::default()
11840        }
11841
11842        unsafe fn decode(
11843            &mut self,
11844            decoder: &mut fidl::encoding::Decoder<'_, D>,
11845            offset: usize,
11846            mut depth: fidl::encoding::Depth,
11847        ) -> fidl::Result<()> {
11848            decoder.debug_check_bounds::<Self>(offset);
11849            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11850                None => return Err(fidl::Error::NotNullable),
11851                Some(len) => len,
11852            };
11853            // Calling decoder.out_of_line_offset(0) is not allowed.
11854            if len == 0 {
11855                return Ok(());
11856            };
11857            depth.increment()?;
11858            let envelope_size = 8;
11859            let bytes_len = len * envelope_size;
11860            let offset = decoder.out_of_line_offset(bytes_len)?;
11861            // Decode the envelope for each type.
11862            let mut _next_ordinal_to_read = 0;
11863            let mut next_offset = offset;
11864            let end_offset = offset + bytes_len;
11865            _next_ordinal_to_read += 1;
11866            if next_offset >= end_offset {
11867                return Ok(());
11868            }
11869
11870            // Decode unknown envelopes for gaps in ordinals.
11871            while _next_ordinal_to_read < 1 {
11872                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11873                _next_ordinal_to_read += 1;
11874                next_offset += envelope_size;
11875            }
11876
11877            let next_out_of_line = decoder.next_out_of_line();
11878            let handles_before = decoder.remaining_handles();
11879            if let Some((inlined, num_bytes, num_handles)) =
11880                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11881            {
11882                let member_inline_size = <fidl::encoding::Vector<DynamicSecureHeap, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11883                if inlined != (member_inline_size <= 4) {
11884                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11885                }
11886                let inner_offset;
11887                let mut inner_depth = depth.clone();
11888                if inlined {
11889                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11890                    inner_offset = next_offset;
11891                } else {
11892                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11893                    inner_depth.increment()?;
11894                }
11895                let val_ref = self.heaps.get_or_insert_with(
11896                    || fidl::new_empty!(fidl::encoding::Vector<DynamicSecureHeap, 32>, D),
11897                );
11898                fidl::decode!(fidl::encoding::Vector<DynamicSecureHeap, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
11899                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11900                {
11901                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11902                }
11903                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11904                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11905                }
11906            }
11907
11908            next_offset += envelope_size;
11909
11910            // Decode the remaining unknown envelopes.
11911            while next_offset < end_offset {
11912                _next_ordinal_to_read += 1;
11913                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11914                next_offset += envelope_size;
11915            }
11916
11917            Ok(())
11918        }
11919    }
11920
11921    impl SecureMemGetPhysicalSecureHeapPropertiesResponse {
11922        #[inline(always)]
11923        fn max_ordinal_present(&self) -> u64 {
11924            if let Some(_) = self.properties {
11925                return 1;
11926            }
11927            0
11928        }
11929    }
11930
11931    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapPropertiesResponse {
11932        type Borrowed<'a> = &'a Self;
11933        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11934            value
11935        }
11936    }
11937
11938    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapPropertiesResponse {
11939        type Owned = Self;
11940
11941        #[inline(always)]
11942        fn inline_align(_context: fidl::encoding::Context) -> usize {
11943            8
11944        }
11945
11946        #[inline(always)]
11947        fn inline_size(_context: fidl::encoding::Context) -> usize {
11948            16
11949        }
11950    }
11951
11952    unsafe impl<D: fidl::encoding::ResourceDialect>
11953        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapPropertiesResponse, D>
11954        for &SecureMemGetPhysicalSecureHeapPropertiesResponse
11955    {
11956        unsafe fn encode(
11957            self,
11958            encoder: &mut fidl::encoding::Encoder<'_, D>,
11959            offset: usize,
11960            mut depth: fidl::encoding::Depth,
11961        ) -> fidl::Result<()> {
11962            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapPropertiesResponse>(offset);
11963            // Vector header
11964            let max_ordinal: u64 = self.max_ordinal_present();
11965            encoder.write_num(max_ordinal, offset);
11966            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11967            // Calling encoder.out_of_line_offset(0) is not allowed.
11968            if max_ordinal == 0 {
11969                return Ok(());
11970            }
11971            depth.increment()?;
11972            let envelope_size = 8;
11973            let bytes_len = max_ordinal as usize * envelope_size;
11974            #[allow(unused_variables)]
11975            let offset = encoder.out_of_line_offset(bytes_len);
11976            let mut _prev_end_offset: usize = 0;
11977            if 1 > max_ordinal {
11978                return Ok(());
11979            }
11980
11981            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11982            // are envelope_size bytes.
11983            let cur_offset: usize = (1 - 1) * envelope_size;
11984
11985            // Zero reserved fields.
11986            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11987
11988            // Safety:
11989            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11990            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11991            //   envelope_size bytes, there is always sufficient room.
11992            fidl::encoding::encode_in_envelope_optional::<SecureHeapProperties, D>(
11993                self.properties
11994                    .as_ref()
11995                    .map(<SecureHeapProperties as fidl::encoding::ValueTypeMarker>::borrow),
11996                encoder,
11997                offset + cur_offset,
11998                depth,
11999            )?;
12000
12001            _prev_end_offset = cur_offset + envelope_size;
12002
12003            Ok(())
12004        }
12005    }
12006
12007    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
12008        for SecureMemGetPhysicalSecureHeapPropertiesResponse
12009    {
12010        #[inline(always)]
12011        fn new_empty() -> Self {
12012            Self::default()
12013        }
12014
12015        unsafe fn decode(
12016            &mut self,
12017            decoder: &mut fidl::encoding::Decoder<'_, D>,
12018            offset: usize,
12019            mut depth: fidl::encoding::Depth,
12020        ) -> fidl::Result<()> {
12021            decoder.debug_check_bounds::<Self>(offset);
12022            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12023                None => return Err(fidl::Error::NotNullable),
12024                Some(len) => len,
12025            };
12026            // Calling decoder.out_of_line_offset(0) is not allowed.
12027            if len == 0 {
12028                return Ok(());
12029            };
12030            depth.increment()?;
12031            let envelope_size = 8;
12032            let bytes_len = len * envelope_size;
12033            let offset = decoder.out_of_line_offset(bytes_len)?;
12034            // Decode the envelope for each type.
12035            let mut _next_ordinal_to_read = 0;
12036            let mut next_offset = offset;
12037            let end_offset = offset + bytes_len;
12038            _next_ordinal_to_read += 1;
12039            if next_offset >= end_offset {
12040                return Ok(());
12041            }
12042
12043            // Decode unknown envelopes for gaps in ordinals.
12044            while _next_ordinal_to_read < 1 {
12045                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12046                _next_ordinal_to_read += 1;
12047                next_offset += envelope_size;
12048            }
12049
12050            let next_out_of_line = decoder.next_out_of_line();
12051            let handles_before = decoder.remaining_handles();
12052            if let Some((inlined, num_bytes, num_handles)) =
12053                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12054            {
12055                let member_inline_size =
12056                    <SecureHeapProperties as fidl::encoding::TypeMarker>::inline_size(
12057                        decoder.context,
12058                    );
12059                if inlined != (member_inline_size <= 4) {
12060                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12061                }
12062                let inner_offset;
12063                let mut inner_depth = depth.clone();
12064                if inlined {
12065                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12066                    inner_offset = next_offset;
12067                } else {
12068                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12069                    inner_depth.increment()?;
12070                }
12071                let val_ref = self
12072                    .properties
12073                    .get_or_insert_with(|| fidl::new_empty!(SecureHeapProperties, D));
12074                fidl::decode!(
12075                    SecureHeapProperties,
12076                    D,
12077                    val_ref,
12078                    decoder,
12079                    inner_offset,
12080                    inner_depth
12081                )?;
12082                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12083                {
12084                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12085                }
12086                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12087                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12088                }
12089            }
12090
12091            next_offset += envelope_size;
12092
12093            // Decode the remaining unknown envelopes.
12094            while next_offset < end_offset {
12095                _next_ordinal_to_read += 1;
12096                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12097                next_offset += envelope_size;
12098            }
12099
12100            Ok(())
12101        }
12102    }
12103
12104    impl SecureMemGetPhysicalSecureHeapsResponse {
12105        #[inline(always)]
12106        fn max_ordinal_present(&self) -> u64 {
12107            if let Some(_) = self.heaps {
12108                return 1;
12109            }
12110            0
12111        }
12112    }
12113
12114    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapsResponse {
12115        type Borrowed<'a> = &'a Self;
12116        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
12117            value
12118        }
12119    }
12120
12121    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapsResponse {
12122        type Owned = Self;
12123
12124        #[inline(always)]
12125        fn inline_align(_context: fidl::encoding::Context) -> usize {
12126            8
12127        }
12128
12129        #[inline(always)]
12130        fn inline_size(_context: fidl::encoding::Context) -> usize {
12131            16
12132        }
12133    }
12134
12135    unsafe impl<D: fidl::encoding::ResourceDialect>
12136        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapsResponse, D>
12137        for &SecureMemGetPhysicalSecureHeapsResponse
12138    {
12139        unsafe fn encode(
12140            self,
12141            encoder: &mut fidl::encoding::Encoder<'_, D>,
12142            offset: usize,
12143            mut depth: fidl::encoding::Depth,
12144        ) -> fidl::Result<()> {
12145            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapsResponse>(offset);
12146            // Vector header
12147            let max_ordinal: u64 = self.max_ordinal_present();
12148            encoder.write_num(max_ordinal, offset);
12149            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12150            // Calling encoder.out_of_line_offset(0) is not allowed.
12151            if max_ordinal == 0 {
12152                return Ok(());
12153            }
12154            depth.increment()?;
12155            let envelope_size = 8;
12156            let bytes_len = max_ordinal as usize * envelope_size;
12157            #[allow(unused_variables)]
12158            let offset = encoder.out_of_line_offset(bytes_len);
12159            let mut _prev_end_offset: usize = 0;
12160            if 1 > max_ordinal {
12161                return Ok(());
12162            }
12163
12164            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12165            // are envelope_size bytes.
12166            let cur_offset: usize = (1 - 1) * envelope_size;
12167
12168            // Zero reserved fields.
12169            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12170
12171            // Safety:
12172            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12173            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12174            //   envelope_size bytes, there is always sufficient room.
12175            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SecureHeapAndRanges, 32>, D>(
12176            self.heaps.as_ref().map(<fidl::encoding::Vector<SecureHeapAndRanges, 32> as fidl::encoding::ValueTypeMarker>::borrow),
12177            encoder, offset + cur_offset, depth
12178        )?;
12179
12180            _prev_end_offset = cur_offset + envelope_size;
12181
12182            Ok(())
12183        }
12184    }
12185
12186    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
12187        for SecureMemGetPhysicalSecureHeapsResponse
12188    {
12189        #[inline(always)]
12190        fn new_empty() -> Self {
12191            Self::default()
12192        }
12193
12194        unsafe fn decode(
12195            &mut self,
12196            decoder: &mut fidl::encoding::Decoder<'_, D>,
12197            offset: usize,
12198            mut depth: fidl::encoding::Depth,
12199        ) -> fidl::Result<()> {
12200            decoder.debug_check_bounds::<Self>(offset);
12201            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12202                None => return Err(fidl::Error::NotNullable),
12203                Some(len) => len,
12204            };
12205            // Calling decoder.out_of_line_offset(0) is not allowed.
12206            if len == 0 {
12207                return Ok(());
12208            };
12209            depth.increment()?;
12210            let envelope_size = 8;
12211            let bytes_len = len * envelope_size;
12212            let offset = decoder.out_of_line_offset(bytes_len)?;
12213            // Decode the envelope for each type.
12214            let mut _next_ordinal_to_read = 0;
12215            let mut next_offset = offset;
12216            let end_offset = offset + bytes_len;
12217            _next_ordinal_to_read += 1;
12218            if next_offset >= end_offset {
12219                return Ok(());
12220            }
12221
12222            // Decode unknown envelopes for gaps in ordinals.
12223            while _next_ordinal_to_read < 1 {
12224                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12225                _next_ordinal_to_read += 1;
12226                next_offset += envelope_size;
12227            }
12228
12229            let next_out_of_line = decoder.next_out_of_line();
12230            let handles_before = decoder.remaining_handles();
12231            if let Some((inlined, num_bytes, num_handles)) =
12232                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12233            {
12234                let member_inline_size = <fidl::encoding::Vector<SecureHeapAndRanges, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12235                if inlined != (member_inline_size <= 4) {
12236                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12237                }
12238                let inner_offset;
12239                let mut inner_depth = depth.clone();
12240                if inlined {
12241                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12242                    inner_offset = next_offset;
12243                } else {
12244                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12245                    inner_depth.increment()?;
12246                }
12247                let val_ref = self.heaps.get_or_insert_with(
12248                    || fidl::new_empty!(fidl::encoding::Vector<SecureHeapAndRanges, 32>, D),
12249                );
12250                fidl::decode!(fidl::encoding::Vector<SecureHeapAndRanges, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
12251                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12252                {
12253                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12254                }
12255                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12256                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12257                }
12258            }
12259
12260            next_offset += envelope_size;
12261
12262            // Decode the remaining unknown envelopes.
12263            while next_offset < end_offset {
12264                _next_ordinal_to_read += 1;
12265                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12266                next_offset += envelope_size;
12267            }
12268
12269            Ok(())
12270        }
12271    }
12272
12273    impl SingleBufferSettings {
12274        #[inline(always)]
12275        fn max_ordinal_present(&self) -> u64 {
12276            if let Some(_) = self.image_format_constraints {
12277                return 2;
12278            }
12279            if let Some(_) = self.buffer_settings {
12280                return 1;
12281            }
12282            0
12283        }
12284    }
12285
12286    impl fidl::encoding::ValueTypeMarker for SingleBufferSettings {
12287        type Borrowed<'a> = &'a Self;
12288        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
12289            value
12290        }
12291    }
12292
12293    unsafe impl fidl::encoding::TypeMarker for SingleBufferSettings {
12294        type Owned = Self;
12295
12296        #[inline(always)]
12297        fn inline_align(_context: fidl::encoding::Context) -> usize {
12298            8
12299        }
12300
12301        #[inline(always)]
12302        fn inline_size(_context: fidl::encoding::Context) -> usize {
12303            16
12304        }
12305    }
12306
12307    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SingleBufferSettings, D>
12308        for &SingleBufferSettings
12309    {
12310        unsafe fn encode(
12311            self,
12312            encoder: &mut fidl::encoding::Encoder<'_, D>,
12313            offset: usize,
12314            mut depth: fidl::encoding::Depth,
12315        ) -> fidl::Result<()> {
12316            encoder.debug_check_bounds::<SingleBufferSettings>(offset);
12317            // Vector header
12318            let max_ordinal: u64 = self.max_ordinal_present();
12319            encoder.write_num(max_ordinal, offset);
12320            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12321            // Calling encoder.out_of_line_offset(0) is not allowed.
12322            if max_ordinal == 0 {
12323                return Ok(());
12324            }
12325            depth.increment()?;
12326            let envelope_size = 8;
12327            let bytes_len = max_ordinal as usize * envelope_size;
12328            #[allow(unused_variables)]
12329            let offset = encoder.out_of_line_offset(bytes_len);
12330            let mut _prev_end_offset: usize = 0;
12331            if 1 > max_ordinal {
12332                return Ok(());
12333            }
12334
12335            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12336            // are envelope_size bytes.
12337            let cur_offset: usize = (1 - 1) * envelope_size;
12338
12339            // Zero reserved fields.
12340            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12341
12342            // Safety:
12343            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12344            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12345            //   envelope_size bytes, there is always sufficient room.
12346            fidl::encoding::encode_in_envelope_optional::<BufferMemorySettings, D>(
12347                self.buffer_settings
12348                    .as_ref()
12349                    .map(<BufferMemorySettings as fidl::encoding::ValueTypeMarker>::borrow),
12350                encoder,
12351                offset + cur_offset,
12352                depth,
12353            )?;
12354
12355            _prev_end_offset = cur_offset + envelope_size;
12356            if 2 > max_ordinal {
12357                return Ok(());
12358            }
12359
12360            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12361            // are envelope_size bytes.
12362            let cur_offset: usize = (2 - 1) * envelope_size;
12363
12364            // Zero reserved fields.
12365            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12366
12367            // Safety:
12368            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12369            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12370            //   envelope_size bytes, there is always sufficient room.
12371            fidl::encoding::encode_in_envelope_optional::<ImageFormatConstraints, D>(
12372                self.image_format_constraints
12373                    .as_ref()
12374                    .map(<ImageFormatConstraints as fidl::encoding::ValueTypeMarker>::borrow),
12375                encoder,
12376                offset + cur_offset,
12377                depth,
12378            )?;
12379
12380            _prev_end_offset = cur_offset + envelope_size;
12381
12382            Ok(())
12383        }
12384    }
12385
12386    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SingleBufferSettings {
12387        #[inline(always)]
12388        fn new_empty() -> Self {
12389            Self::default()
12390        }
12391
12392        unsafe fn decode(
12393            &mut self,
12394            decoder: &mut fidl::encoding::Decoder<'_, D>,
12395            offset: usize,
12396            mut depth: fidl::encoding::Depth,
12397        ) -> fidl::Result<()> {
12398            decoder.debug_check_bounds::<Self>(offset);
12399            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12400                None => return Err(fidl::Error::NotNullable),
12401                Some(len) => len,
12402            };
12403            // Calling decoder.out_of_line_offset(0) is not allowed.
12404            if len == 0 {
12405                return Ok(());
12406            };
12407            depth.increment()?;
12408            let envelope_size = 8;
12409            let bytes_len = len * envelope_size;
12410            let offset = decoder.out_of_line_offset(bytes_len)?;
12411            // Decode the envelope for each type.
12412            let mut _next_ordinal_to_read = 0;
12413            let mut next_offset = offset;
12414            let end_offset = offset + bytes_len;
12415            _next_ordinal_to_read += 1;
12416            if next_offset >= end_offset {
12417                return Ok(());
12418            }
12419
12420            // Decode unknown envelopes for gaps in ordinals.
12421            while _next_ordinal_to_read < 1 {
12422                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12423                _next_ordinal_to_read += 1;
12424                next_offset += envelope_size;
12425            }
12426
12427            let next_out_of_line = decoder.next_out_of_line();
12428            let handles_before = decoder.remaining_handles();
12429            if let Some((inlined, num_bytes, num_handles)) =
12430                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12431            {
12432                let member_inline_size =
12433                    <BufferMemorySettings as fidl::encoding::TypeMarker>::inline_size(
12434                        decoder.context,
12435                    );
12436                if inlined != (member_inline_size <= 4) {
12437                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12438                }
12439                let inner_offset;
12440                let mut inner_depth = depth.clone();
12441                if inlined {
12442                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12443                    inner_offset = next_offset;
12444                } else {
12445                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12446                    inner_depth.increment()?;
12447                }
12448                let val_ref = self
12449                    .buffer_settings
12450                    .get_or_insert_with(|| fidl::new_empty!(BufferMemorySettings, D));
12451                fidl::decode!(
12452                    BufferMemorySettings,
12453                    D,
12454                    val_ref,
12455                    decoder,
12456                    inner_offset,
12457                    inner_depth
12458                )?;
12459                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12460                {
12461                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12462                }
12463                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12464                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12465                }
12466            }
12467
12468            next_offset += envelope_size;
12469            _next_ordinal_to_read += 1;
12470            if next_offset >= end_offset {
12471                return Ok(());
12472            }
12473
12474            // Decode unknown envelopes for gaps in ordinals.
12475            while _next_ordinal_to_read < 2 {
12476                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12477                _next_ordinal_to_read += 1;
12478                next_offset += envelope_size;
12479            }
12480
12481            let next_out_of_line = decoder.next_out_of_line();
12482            let handles_before = decoder.remaining_handles();
12483            if let Some((inlined, num_bytes, num_handles)) =
12484                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12485            {
12486                let member_inline_size =
12487                    <ImageFormatConstraints as fidl::encoding::TypeMarker>::inline_size(
12488                        decoder.context,
12489                    );
12490                if inlined != (member_inline_size <= 4) {
12491                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12492                }
12493                let inner_offset;
12494                let mut inner_depth = depth.clone();
12495                if inlined {
12496                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12497                    inner_offset = next_offset;
12498                } else {
12499                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12500                    inner_depth.increment()?;
12501                }
12502                let val_ref = self
12503                    .image_format_constraints
12504                    .get_or_insert_with(|| fidl::new_empty!(ImageFormatConstraints, D));
12505                fidl::decode!(
12506                    ImageFormatConstraints,
12507                    D,
12508                    val_ref,
12509                    decoder,
12510                    inner_offset,
12511                    inner_depth
12512                )?;
12513                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12514                {
12515                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12516                }
12517                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12518                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12519                }
12520            }
12521
12522            next_offset += envelope_size;
12523
12524            // Decode the remaining unknown envelopes.
12525            while next_offset < end_offset {
12526                _next_ordinal_to_read += 1;
12527                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12528                next_offset += envelope_size;
12529            }
12530
12531            Ok(())
12532        }
12533    }
12534}