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    /// Note: The VMO's zx_vmo_get_stream_size / ZX_PROP_VMO_CONTENT_SIZE are
654    /// not usable for this purpose, as that can't be set (and get returns
655    /// 0) for all VMO types that sysmem actually allocates (at least so far).
656    /// In any case zx_vmo_get_stream_size is about current content size not max
657    /// permitted content size.
658    ///
659    /// Any future padding-only constraint which is irrelevant to a non-padding
660    /// participant when locating each valid pixel's valid data will be
661    /// accounted for by checking ImageFormatImageSize() against `size_bytes`
662    /// instead of the VMO size.
663    ///
664    /// Following this rule allows producers to not need to worry about
665    /// arbitrary padding requirements of other participants, including
666    /// future-added padding-only constraints.
667    ///
668    /// The `bytes_per_row` and rounding up to a tile size boundary are included
669    /// in ImageFormatImageSize and accounted for in `size_bytes`, even though
670    /// these two aspects are partially about padding. These two aspects are
671    /// included in the `ImageFormatImageSize` calculation because these two
672    /// aspects are also relevant to all participants that need to locate pixel
673    /// data.
674    ///
675    /// With the exception of `bytes_per_row` and rounding up to a tile size
676    /// boundary when not PixelFormatModifier.Linear (and no other exceptions),
677    /// this field does not include any extra VMO size padding that is added
678    /// because of participant-specific padding constraint(s).
679    ///
680    /// The same `size_bytes` value is sent to all participants.
681    ///
682    /// This field is not page aligned. This value rounded up to
683    /// zx_system_page_size() boundary is guaranteed to be less than or equal
684    /// the buffer VMO size. In other words, the VMO is allowed to have more
685    /// pages than implied by this value.
686    pub size_bytes: Option<u64>,
687    /// This field will always be set by sysmem.
688    pub is_physically_contiguous: Option<bool>,
689    /// This field will always be set by sysmem.
690    pub is_secure: Option<bool>,
691    /// This field will always be set by sysmem.
692    pub coherency_domain: Option<CoherencyDomain>,
693    /// The specific heap from which buffers are allocated.
694    ///
695    /// This field will always be set by sysmem.
696    pub heap: Option<Heap>,
697    #[doc(hidden)]
698    pub __source_breaking: fidl::marker::SourceBreaking,
699}
700
701impl fidl::Persistable for BufferMemorySettings {}
702
703/// Describes how a client will access the contents of a buffer.
704#[derive(Clone, Debug, Default, PartialEq)]
705pub struct BufferUsage {
706    /// If the client sets this field, the client should not set any other
707    /// fields in the same table instance. The only valid bit in this field is
708    /// `NONE_USAGE` which must be set if this field is set. The point of this
709    /// field and the one bit set in this field is to essentially prove that the
710    /// client really means they aren't going to use the buffers, so don't need
711    /// any VMOs (didn't just fail to fill out the table).
712    pub none: Option<u32>,
713    /// If set, holds CPU usage bits. See `CPU_USAGE_*` flags in usages.fidl.
714    pub cpu: Option<u32>,
715    /// If set, holds vulkan usage bits. See `VULKAN_IMAGE_*` and
716    /// `VULKAN_BUFFER_*` bits in usages.fidl. The `VULKAN_USAGE_*` bit
717    /// definitions/names are deprecated.
718    pub vulkan: Option<u32>,
719    /// If set, holds display usage bits. See `DISPLAY_USAGE_*` bits in
720    /// usages.fidl.
721    pub display: Option<u32>,
722    /// If set, holds video usage bits. See `VIDEO_USAGE_*` bits in usages.fidl.
723    pub video: Option<u32>,
724    #[doc(hidden)]
725    pub __source_breaking: fidl::marker::SourceBreaking,
726}
727
728impl fidl::Persistable for BufferUsage {}
729
730/// This type is fidl::Persist()'ed in the sysmem_config.persistent_fidl file
731/// within the sysmem domain config by the assembly tool, and read by the sysmem
732/// driver.
733///
734/// Normally json[5] would be preferable for config, but we generate this config
735/// in rust using FIDL types (to avoid repetition and to take advantage of FIDL
736/// rust codegen), and there's no json schema for FIDL types.
737///
738/// Currently there is no mechanism to change anything in this config at runtime
739/// or from boot to boot. This config is static per run of the assembly tool.
740///
741/// See src/lib/assembly/config_schema/src/platform_config/sysmem_config.rs for
742/// aspects of sysmem config which are specified directly inline in board info
743/// or assembly platform config. The two parts of sysmem config don't
744/// (currently) overlap. The config here is for aspects of sysmem config which
745/// would be too verbose for direct inclusion in board info or assembly platform
746/// config. In addition, some/most of the pixel format cost entries are
747/// programmatically generated (as of this comment).
748///
749/// Prior to aggregation by assembly tool, there are multiple .persistent_fidl
750/// files each storing its own Config instance. The board info and assembly
751/// platform config lists the input persistent_fidl files, with board info
752/// logically before assembly platform config. The overall list of files is
753/// processed, which allows later files to override/replace info in prior files.
754///
755/// Because this type is only intended for use with persistent fidl, where the
756/// length of a serialized instance isn't bounded, we don't bound the internal
757/// vector element counts.
758#[derive(Clone, Debug, Default, PartialEq)]
759pub struct Config {
760    /// This is the ordered list of FormatCost entries which will be considered
761    /// by sysmem when breaking ties among formats supported by all participants
762    /// of a buffer collection.
763    ///
764    /// During config aggregation, if a later entry has matching FormatCostKey,
765    /// the earlier entry is omitted/removed. This allows later files to
766    /// override entries in earlier files, and allows files specified in
767    /// assembly platform config to override entries in files specified in the
768    /// board info.
769    ///
770    /// This vector will normally not have any two entries with matching
771    /// pixel_format, pixel_format_modifier, and buffer_usage_bits in the Config
772    /// instance loaded from sysmem_config.persistent_fidl by sysmem. If somehow
773    /// two entries do match in those fields, sysmem can ignore all but one of
774    /// the entries chosen arbitrarily.
775    pub format_costs: Option<Vec<FormatCostEntry>>,
776    #[doc(hidden)]
777    pub __source_breaking: fidl::marker::SourceBreaking,
778}
779
780impl fidl::Persistable for Config {}
781
782#[derive(Clone, Debug, Default, PartialEq)]
783pub struct DynamicSecureHeap {
784    pub heap: Option<Heap>,
785    #[doc(hidden)]
786    pub __source_breaking: fidl::marker::SourceBreaking,
787}
788
789impl fidl::Persistable for DynamicSecureHeap {}
790
791/// A FormatCostEntry can be used to influence which PixelFormatAndModifier is
792/// chosen for a buffer collection, optionally taking BufferUsage into account.
793///
794/// The default cost is f32::MAX, so any specified cost with a non-MAX value
795/// will prefer the specified format over any formats that don't have any
796/// FormatCost entry.
797///
798/// Entries which have the same pixel_format, pixel_format_modifier, and
799/// required_usage_bits as a previous entry will override that previous entry.
800/// For matching purposes, an absent pixel_format_modifier matches LINEAR, and
801/// an absent required_buffer_usage_bits matches all-0 usage bits.
802///
803/// Board info sysmem_defaults entries are logically before platform sysmem
804/// entries.
805///
806/// Sysmem uses the resulting aggregated list of FormatCostEntry(s) when
807/// breaking ties among the set of formats which are supported by all
808/// participants of a buffer collection. For each mutually-supported format,
809/// entries with non-matching format are ignored, and entries with extra
810/// buffer_usage_bits set are ignored. Among the remaining entries, the entry
811/// with the most usage bits in common with the aggregated participant usages is
812/// selected to determine the cost (if a tie, the later entry wins). Then the
813/// format with the lowest cost is chosen. If it's still a tie (equal cost), the
814/// tie is broken arbitrarily but not randomly.
815///
816/// This is not intended as a mechanism to disallow selection of a format that
817/// is supported by all participants of a buffer collection. If a participant
818/// claims support for a format but fails to handle that format correctly, it
819/// should be fixed to handle that format correctly or changed to stop claiming
820/// support for that format.
821///
822/// This mechanism is intended to influence format selection toward more
823/// efficient formats with better performance, lower memory bandwidth usage,
824/// etc, for a given set of usage bits, taking into account quirks that may be
825/// unique to a given board or overall platform config.
826#[derive(Clone, Debug, Default, PartialEq)]
827pub struct FormatCostEntry {
828    /// Must be set. If two entries have logically equal key (after field
829    /// defaults are applied), the later entry will override the earlier entry.
830    pub key: Option<FormatCostKey>,
831    /// Must be set. Lower costs win, but see also FormatCostKey fields re.
832    /// filtering entries by format and usage bits first.
833    ///
834    /// When two entries (each with format supported by all the participants of
835    /// a buffer collection) have different costs, the lower cost entry (and its
836    /// format) is chosen.
837    ///
838    /// For non-test scenarios, only use cost values > 0.0 (typically at least
839    /// 1.0 as of this comment), with 0.0 and negative values reserved for
840    /// testing.
841    pub cost: Option<f32>,
842    #[doc(hidden)]
843    pub __source_breaking: fidl::marker::SourceBreaking,
844}
845
846impl fidl::Persistable for FormatCostEntry {}
847
848/// Entries which have the same pixel_format, pixel_format_modifier, and
849/// required_usage_bits as a previous entry will override that previous entry.
850/// For matching purposes, an absent pixel_format_modifier matches LINEAR, and
851/// an absent required_buffer_usage_bits matches all-0 usage bits.
852#[derive(Clone, Debug, Default, PartialEq)]
853pub struct FormatCostKey {
854    /// The pixel_format and pixel_format_modifier are the format to which this
855    /// FormatCost entry applies.
856    ///
857    /// Must be set.
858    pub pixel_format: Option<fidl_fuchsia_images2__common::PixelFormat>,
859    /// The pixel_format and pixel_format_modifier are the format to which this
860    /// FormatCost entry applies.
861    ///
862    /// Un-set is equivalent to LINEAR.
863    pub pixel_format_modifier: Option<fidl_fuchsia_images2__common::PixelFormatModifier>,
864    /// If set, this entry is only considered if the buffer collection has at
865    /// least these usage bits set.
866    ///
867    /// The buffer collection has an aggregated BufferUsage which is the union
868    /// of per-participant BufferUsage bits. FormatCost entries with additional
869    /// set bits are ignored. Among the rest, the one with matching format and
870    /// the most usage bits set determines the cost of that format for that
871    /// buffer collection.
872    ///
873    /// Then the lowest-cost format is chosen for that buffer collection among
874    /// the formats that are mutually suppored by all the participants of that
875    /// buffer collection.
876    ///
877    /// The main intent of this field is to allow "waving off" a format that
878    /// works, but doesn't perform well, for a particular combination of usages.
879    /// In that case the cost can be set high when the problematic combination
880    /// of usage bits is set. The format will still be chosen if this format is
881    /// the only mutually-supported format among the participants of the buffer
882    /// collection.
883    ///
884    /// Un-set is equivalent to zero usage bits set, meaning the entry applies
885    /// to the format unless another entry with more specific usage applies.
886    ///
887    /// It can be reasonable in some cases for all entries to omit this field,
888    /// when/if format selection based on format cost alone, ignoring usage, is
889    /// sufficient.
890    pub buffer_usage_bits: Option<BufferUsage>,
891    #[doc(hidden)]
892    pub __source_breaking: fidl::marker::SourceBreaking,
893}
894
895impl fidl::Persistable for FormatCostKey {}
896
897/// This is the root of the persistent fidl in a format costs file. The format
898/// costs files are read by the assembly tool and merged into the single
899/// sysmem_config.persistent_fidl file in the sysmem domain config (see Config
900/// above).
901///
902/// Normally json[5] would be preferable for config, but we generate this config
903/// in rust using FIDL types (to avoid repetition and to take advantage of FIDL
904/// rust codegen), and there's no json schema for FIDL types.
905///
906/// While the resulting sysmem_config.persistent_fidl is a single file that can
907/// contain multiple aspects of sysmem config, in contrast a format costs file
908/// contains only format costs. We don't mind having more separate files during
909/// the build, but it's nice to get sysmem's domain config down to a single file
910/// on-device.
911#[derive(Clone, Debug, Default, PartialEq)]
912pub struct FormatCosts {
913    /// This is a chunk of entries that'll end up in
914    /// ['fuchsia.sysmem2.Config.format_costs'] (see above) unless overriden by
915    /// later entries (either in this same vector or in later-processed files
916    /// during aggregation by the assembly tool).
917    pub format_costs: Option<Vec<FormatCostEntry>>,
918    #[doc(hidden)]
919    pub __source_breaking: fidl::marker::SourceBreaking,
920}
921
922impl fidl::Persistable for FormatCosts {}
923
924/// A reference to a heap instance.
925///
926/// A given heap instance can have more than one `Heap` which can be used to
927/// refer to the heap instance. Comparing `Heap` tables without knowledge of
928/// these `Heap` aliases is not a reliable way to determine if two `Heap` tables
929/// refer to the same heap (matching means yes, but not matching means maybe).
930/// Allowing heap aliases makes renaming `Heap.type`(s) easier.
931#[derive(Clone, Debug, Default, PartialEq)]
932pub struct Heap {
933    /// The type of the heap, specified using a bind string defined per the
934    /// schema and mechanism described in comments in the
935    /// fuchsia.sysmem.heap.bind file.
936    ///
937    /// Examples:
938    /// * "fuchsia.sysmem.heap.HEAP_TYPE.SYSTEM_RAM"
939    /// * "fuchsia.goldfish.platform.sysmem.heap.HEAP_TYPE.HOST_VISIBLE"
940    pub heap_type: Option<String>,
941    /// The uint64 id of the heap. This is only required to be unique per (type,
942    /// boot) tuple. In other words, a given heap id is only meaningful within
943    /// the current boot of the machine (not across boots), and only within the
944    /// `Heap.type`.
945    ///
946    /// For `Heap.type`(s) that refer to a singleton heap, a participant
947    /// specifying the singleton heap in
948    /// [`fuchsia.sysmem2.BufferMemoryConstraints.permitted_heaps`] can leave
949    /// this field un-set, or set it to zero. Sysmem will always fill out this
950    /// field for the heap indicated in
951    /// [`fuchsia.sysmem2.BufferMemorySettings.heap`] (for a singleton heap the
952    /// `id` field will be set to 0 by sysmem).
953    pub id: Option<u64>,
954    #[doc(hidden)]
955    pub __source_breaking: fidl::marker::SourceBreaking,
956}
957
958impl fidl::Persistable for Heap {}
959
960/// Describes constraints on layout of image data in buffers.
961#[derive(Clone, Debug, Default, PartialEq)]
962pub struct ImageFormatConstraints {
963    /// The [`fuchsia.images2/PixelFormat`] for which the following constraints
964    /// apply.
965    ///
966    /// The `pixel_format` and `pixel_format_modifier` fields together are
967    /// treated by the server as one additional `pixel_format_and_modifiers`
968    /// entry.
969    ///
970    /// A participant may have more than one
971    /// [`fuchsia.sysmem2/PixelFormatAndModifier`] that's supported.
972    ///
973    /// * If image constraints are the same for different
974    ///   `PixelFormatAndModifier`s, the participant may list additional
975    ///   `PixelFormatAndModifier`s for which the constraints apply in the
976    ///   `pixel_format_and_modifiers` field. This reduces the overall number of
977    ///   `ImageFormatConstraints` that need to be sent, without changing the
978    ///   meaning (vs for example sending a bunch of separate
979    ///   `ImageFormatConstraints` that only differ by the `pixel_format` and
980    ///   `pixel_format_modifier` which overall specify the same list of
981    ///   `PixelFormatAndModifier`s).
982    /// * If image constraints differ for different `PixelFormatAndModifier`s,
983    ///   the participant can convey this using a separate
984    ///   `ImageFormatConstraints` entry in `image_format_constraints` for each
985    ///   set of `PixelFormatAndModifier`s that have different image
986    ///   constraints.
987    /// * It's ok for a participant to have two `image_format_constraints`
988    ///   entries that only differ in their pixel_format_and_modifiers, but this
989    ///   is isn't the most compact way to represent that situation since the
990    ///   two entries could be combined by specifying two
991    ///   `PixelFormatAndModifier`s within a single `ImageFormatConstraints`.
992    ///
993    /// It's not uncommon for the other fields of `ImageFormatConstraints` to
994    /// vary by `pixel_format` or by `pixel_format_modifier` - for example for a
995    /// linear format to support smaller max size than a tiled format.
996    ///
997    /// See also
998    /// [`fuchsia.sysmem2/ImageFormatConstraints.pixel_format_and_modifiers`].
999    ///
1000    /// Thie field must be set to a value other than
1001    /// [`fuchsia.images2/PixelFormat.INVALID`] unless
1002    /// `pixel_format_and_modifiers` is non-empty. In other words, there must be
1003    /// at least one `PixelFormatAndModifier` per `ImageFormatConstraints`. If
1004    /// `pixel_format_modifier` is set, this field must also be set.
1005    ///
1006    /// The participant can specify [`fuchsia.images2/PixelFormat.DO_NOT_CARE`]
1007    /// if the participant needs to specify `ImageFormatConstraints` without
1008    /// constraining the `pixel_format`.
1009    pub pixel_format: Option<fidl_fuchsia_images2__common::PixelFormat>,
1010    /// The pixel format modifier for which the following constraints apply.
1011    ///
1012    /// The `pixel_format` and `pixel_format_modifier` fields together are
1013    /// treated by the server as one additional `pixel_format_and_modifiers`
1014    /// entry.
1015    ///
1016    /// This is a [`fuchsia.images2/PixelFormatModifier`] that's acceptable to
1017    /// the participant in combination with the `pixel_format`.
1018    ///
1019    /// See also `pixel_format_and_modifiers`.
1020    ///
1021    /// If `pixel_format` is set but `pixel_format_modifier` is un-set, the
1022    /// default depends on other fields:
1023    ///
1024    /// * If `pixel_format` is [`fuchsia.images2/PixelFormat.DO_NOT_CARE`], the
1025    ///   pixel format modifier is implicitly
1026    ///   [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`].
1027    /// * else if `BufferCollectionConstraints.usage` isn't `NONE`, the pixel
1028    ///   format modifier is implicitly
1029    ///   [`fuchsia.images2/PixelFormatModifier.LINEAR`].
1030    /// * else the pixel format modifier is implicitly
1031    ///   [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`].
1032    pub pixel_format_modifier: Option<fidl_fuchsia_images2__common::PixelFormatModifier>,
1033    /// Empty is an error. Duplicate entries are an error. Arbitrary ordering is
1034    /// not an error.
1035    ///
1036    /// The client can specify a single entry
1037    /// [`fuchsia.sysmem2/ColorSpace.DO_NOT_CARE`] if the client doesn't want to
1038    /// constrain which `ColorSpace` is chosen. At least one participant must
1039    /// specify at least one `ColorSpace` value other than
1040    /// `ColorSpace.DO_NOT_CARE`, or allocation will fail.
1041    pub color_spaces: Option<Vec<fidl_fuchsia_images2__common::ColorSpace>>,
1042    /// Minimum permitted size in pixels.
1043    ///
1044    /// For example a video decoder participant may set this field to the
1045    /// minimum size that might potentially be specified by a stream. In
1046    /// contrast, `required_min_size` would be set to the current size specified
1047    /// by the stream. While `min_size` aggregates by taking the max,
1048    /// `required_min_size` aggregates by taking the min.
1049    ///
1050    /// When sending to sysmem, this field can be un-set if the participant is
1051    /// prepared to deal with the smallest possible non-zero image layout
1052    /// limited only by the constraints implicitly imposed by the `pixel_format`
1053    /// and `pixel_format_modifier`. Or this field can be set to the actual
1054    /// minimum size the participant can handle.
1055    ///
1056    /// Producers should set `min_size` and set both width and height to the
1057    /// actual non-zero smallest width and height that the producer might
1058    /// generate. For example, a video decoder can set the size of a single
1059    /// macroblock here.
1060    ///
1061    /// When receiving from sysmem, this field will always be set, and neither
1062    /// width nor height will be 0, because at least one participant must
1063    /// specify a non-zero minimum size (where both width and height aren't
1064    /// zero).
1065    ///
1066    /// See also `required_min_size`.
1067    pub min_size: Option<fidl_fuchsia_math__common::SizeU>,
1068    /// Maximum size in pixels. For example Scenic may set this field (directly
1069    /// or via sub-participants) to the maximum size that can be composited.
1070    ///
1071    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF, 0xFFFFFFFF.
1072    ///
1073    /// Receiving from sysmem, this field will always be set. For width and
1074    /// height separately, if there is no enforced max, that sub-field will be
1075    /// 0xFFFFFFFF.
1076    ///
1077    /// See also `required_max_size`.
1078    pub max_size: Option<fidl_fuchsia_math__common::SizeU>,
1079    /// The minimum number of bytes per row, including any padding beyond the
1080    /// last image data in a row.
1081    ///
1082    /// This is sometimes called the "stride in bytes" or the "line to line
1083    /// offset". For single-plane formats, this is the number of bytes per row
1084    /// of pixels. For multi-plane formats, this is the number of bytes per row
1085    /// of samples in plane 0 (for example, the number of bytes per row of luma
1086    /// samples in the case of a multi-plane YUV format). For multi-plane
1087    /// formats, the bytes per row in planes other than plane 0 is format
1088    /// specific, but always a specific relationship to the plane 0 bytes per
1089    /// row.
1090    ///
1091    /// When sending `ImageFormatConstraints` to sysmem, setting this field is
1092    /// optional. Not setting this field is recommended unless the participant
1093    /// needs to force the `bytes_per_row` to be larger than the minimum value
1094    /// implied by `min_size.width`, the "stride bytes per width pixel" of the
1095    /// `pixel_format` plus `pixel_format_modifier` (see also
1096    /// `ImageFormatStrideBytesPerWidthPixel`), and `bytes_per_row_divisor`.
1097    ///
1098    /// When this structure is received from sysmem, this field will always be
1099    /// set (when the parent structure is present), and will always be at least
1100    /// the value implied by `min_size.width`, the "stride bytes per width
1101    /// pixel" of the `pixel_format` plus `pixel_format_modifier`, and
1102    /// `bytes_per_row_divisor`.
1103    ///
1104    /// Some producer participants may prefer to simply set
1105    /// `ImageFormat.bytes_per_row` to
1106    /// `ImageFormatConstraints.min_bytes_per_row` since sysmem is guaranteeing
1107    /// that `min_bytes_per_row` is compatible with an image of width
1108    /// `min_size.width`. However, producer participants that need to have
1109    /// `size.width` > `min_size.width` can get a corresponding
1110    /// `min_bytes_per_row` from `ImageFormatMinimumRowBytes` (in C++), or can
1111    /// just calculate the `bytes_per_row` directly.
1112    pub min_bytes_per_row: Option<u32>,
1113    /// The maximum number of bytes per row, including any padding beyond the
1114    /// last image data in a row.
1115    ///
1116    /// When sent to sysmem, must be >= the value implied by `max_size.width`,
1117    /// "stride bytes per width pixel", and `bytes_per_row_divisor`, or
1118    /// constraints aggregation will fail. Un-set means the participant doesn't
1119    /// need/want to set a strict max.
1120    ///
1121    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF.
1122    ///
1123    /// When received from sysmem, this field will always be set. If the max is
1124    /// effectively infinite, the value will be 0xFFFFFFFF (not zero).
1125    pub max_bytes_per_row: Option<u32>,
1126    /// The maximum number of pixels.
1127    ///
1128    /// The max image area in pixels is limited indirectly via
1129    /// [`fuchsia.sysmem/BufferMemoryConstraints.max_size_bytes`] and the
1130    /// resulting [`fuchsia.sysmem/BufferSettings.size_bytes`], and can also be
1131    /// enforced directly via this field.
1132    ///
1133    /// In contrast to the [`fuchsia.sysmem2/ImageFormatConstraints.max_size`]
1134    /// field which limits width and height separately, this field limits the
1135    /// total number of pixels.
1136    ///
1137    /// In contrast to
1138    /// [`fuchsia.sysmem/BufferMemoryConstraints.max_size_bytes`], this field
1139    /// doesn't limit the number of non-pixel padding bytes after each row of
1140    /// pixels, and doesn't limit the number of non-pixel bytes in the case of
1141    /// tiled `pixel_format_modifier`.
1142    ///
1143    /// Very narrow or very short image aspect ratios can have worse performance
1144    /// per pixel in comparison to more typical aspect ratios. Padding and/or
1145    /// memory bandwidth overheads tend to increase for extreme aspect ratios.
1146    /// Participants can indicate lack of support for very narrow or very short
1147    /// dimensions using ['fuchsia.sysmem/ImageFormatConstraints.min_size`].
1148    ///
1149    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF.
1150    ///
1151    /// Receiving from sysmem, this field will always be set, and can be set to
1152    /// 0xFFFFFFFF.
1153    pub max_width_times_height: Option<u64>,
1154    /// Alignment requirements on the image `size`.
1155    ///
1156    /// * `size.width % size_alignment.width` must be 0.
1157    /// * `size.height % size_alignment.height` must be 0.
1158    ///
1159    /// Un-set is treated as 1, 1.
1160    pub size_alignment: Option<fidl_fuchsia_math__common::SizeU>,
1161    /// Alignment requirements on `display_rect`.
1162    ///
1163    /// * `display_rect.x % display_rect_alignment.width` must be 0.
1164    /// * `display_rect.y % display_rect_alignment.height` must be 0.
1165    /// * `display_rect.width % display_rect_alignment.width` must be 0.
1166    /// * `display_rect.height % display_rect_alignment.height` must be 0.
1167    ///
1168    /// Un-set is treated as 1, 1.
1169    pub display_rect_alignment: Option<fidl_fuchsia_math__common::SizeU>,
1170    /// These fields can be used to ensure the aggregated constraints have
1171    /// `min_size` and `max_size` such that both `required_min_size` and
1172    /// `required_max_size` (and anything in between that satisfies alignment
1173    /// requirements) are permitted values of `ImageFormat.size`.
1174    ///
1175    /// For example, a producer video decoder doesn't want to constrain the
1176    /// allowed `ImageFormat.size`, as a compressed stream can change dimensions
1177    /// mid-stream, but the producer video decoder needs to ensure that the
1178    /// aggregated constraints allow for at least the current dimensions of
1179    /// uncompressed frames at the current position in the stream.
1180    ///
1181    /// As another example, an initiator that's intending to decode video may
1182    /// know what the maximum expected size of frames in the stream(s) can be,
1183    /// so by setting `required_max_size`, can ensure that the allocated buffers
1184    /// are large enough to support that max `size`. In addition on successful
1185    /// allocation the initiator also knows that the consumer participants are
1186    /// ok with receiving up to that max `size`.
1187    ///
1188    /// It's much more common for a producer or initiator to set these fields
1189    /// than for a consumer to set these fields.
1190    ///
1191    /// While `min_size` and `max_size` aggregate by effectively taking the
1192    /// intersection, the `required_min_size` and `required_max_size` aggregate
1193    /// by effectively taking the union.
1194    ///
1195    /// This field aggregates by taking the min per component, and
1196    /// required_max_size aggregates by taking the max per component. In
1197    /// addition the aggregated required_max_size is included in the aggregated
1198    /// required_max_size_list.
1199    ///
1200    /// Un-set is treated as 0xFFFFFFFF, 0xFFFFFFFF.
1201    pub required_min_size: Option<fidl_fuchsia_math__common::SizeU>,
1202    /// This field is deprecated. The replacement is required_max_size_list.
1203    ///
1204    /// See also `required_min_size` and `required_max_size_list`. Un-set is
1205    /// treated as 0, 0.
1206    ///
1207    /// In the BufferCollectionInfo returned from sysmem, this field has the max
1208    /// across all participants' required_max_size fields, for width and height
1209    /// separately. In addition, the allocated buffer is large enough to store
1210    /// an image that is this max-of-all-widths by max-of-all-heights. This has
1211    /// the potential to allocate buffers that are larger than necessary, for
1212    /// example if the participant is trying to make sure the buffer can store
1213    /// both landscape and portrait images. In contrast, required_max_size_list
1214    /// allows listing those separately so they can be handled better by the
1215    /// server. See required_max_size_list and please switch to that field.
1216    ///
1217    /// When this field is set, the provided size is aggregated by taking max of
1218    /// across all participants' required_max_size fields, and that aggregated
1219    /// result is put in this field in the BufferCollectionInfo from the server,
1220    /// and is also treated as an additional item in the aggregated
1221    /// required_max_size_list (even if that field is not set by any client).
1222    /// See required_max_size_list. This behavior is for maintaining backward
1223    /// compatibility for clients using required_max_size before it was
1224    /// deprecated, and for overall compatibility with required_max_size_list,
1225    /// but this behavior is itself deprecated as well. Please switch to only
1226    /// using required_max_size_list.
1227    ///
1228    /// Please don't add additional usages of this field.
1229    pub required_max_size: Option<fidl_fuchsia_math__common::SizeU>,
1230    /// `fuchsia_images2.ImageFormat.bytes_per_row % bytes_per_row_divisor` must
1231    /// be 0. Un-set is treated as 1.
1232    ///
1233    /// Prefer to use `require_bytes_per_row_at_pixel_boundary` when the intent
1234    /// is to ensure that `bytes_per_row' will be a multiple of the pixel size
1235    /// in bytes.
1236    ///
1237    /// Prefer to use `size_alignment.width` when the intent is to ensure that
1238    /// the width in pixels is aligned. In contrast, this field can specify that
1239    /// the "stride in bytes" (byte offset from start of image to start of row n
1240    /// minus byte offset from start of image to start of row n-1, with result
1241    /// in bytes) needs to be aligned to the specified number of bytes. For
1242    /// example, when `PixelFormat.BGR24` (24 bit color; 3 bytes per pixel) is
1243    /// used, it's not uncommon for a participant to need each row of pixels to
1244    /// start at a 4 byte aligned offset from the start of the image, which can
1245    /// imply some padding bytes at the end of each row of pixels, before the
1246    /// start of the next row of pixels.
1247    ///
1248    /// While any value of `bytes_per_row_divisor` could instead be enforced by
1249    /// setting `size_alignment.width` to the least-common-multiple of the
1250    /// "stride bytes per width pixel" and the stride alignment requirement,
1251    /// enforcing the stride alignment requirement that way can lead to more
1252    /// padding than necessary (implying larger buffer than necessary), and can
1253    /// also result in a "fake" `size.width`; this field exists to avoid that
1254    /// situation. Instead, the stride alignment requirement in bytes is
1255    /// specified directly here.
1256    pub bytes_per_row_divisor: Option<u32>,
1257    /// `vmo_usable_start % start_offset_divisor` must be 0. Un-set is treated
1258    /// as 1.
1259    ///
1260    /// Producer participants are discouraged from setting non-zero image start
1261    /// offset (from the buffer base) unless actually required, as not all
1262    /// participants correctly handle non-zero image start offset.
1263    pub start_offset_divisor: Option<u32>,
1264    /// The (additional) [`fuchsia.sysmem2/PixelFormatAndModifier`]s for which
1265    /// the following constraints apply.
1266    ///
1267    /// As a non-limiting example, if a participant only wants to set a single
1268    /// `PixelFormatAndModifier` for this
1269    /// [`fuchsia.sysmem2/ImageFormatConstraints`], the participant can either
1270    /// (a) use `pixel_format` and `pixel_format_modifier` fields to specify the
1271    /// fields of the one `PixelFormatAndModifier` and leave
1272    /// `pixel_format_and_modifiers` un-set, or (b) leave `pixel_format` and
1273    /// `pixel_format_modifier` fields un-set and put the one
1274    /// `PixelFormatAndModifier` in `pixel_format_and_modifiers`.
1275    ///
1276    /// If `pixel_format` is set, the server will take pixel_format and
1277    /// pixel_format_modifier fields (un-setting them in the process), pack them
1278    /// into a `PixelFormatAndModifier`, and move it into this vector as one
1279    /// additional entry, with an overall size limit of
1280    /// `MAX_COUNT_PIXEL_FORMAT_AND_MODIFIERS + 1`.
1281    ///
1282    /// After the server moves `pixel_format`, `pixel_format_modifier` into one
1283    /// additional entry in this vector, this vector must not be empty. When the
1284    /// resulting list has more than 1 item, the entries in this vector are
1285    /// equivalent to (shorthand for) listing (size) separate
1286    /// `ImageFormatConstraints` entries, one per `pixel_format_and_modifiers`
1287    /// entry, each with one `PixelFormatAndModifier`, where all the separate
1288    /// `ImageFormatConstraints` entries have the same constraints (compared
1289    /// field by field, not including `pixel_format`, `pixel_format_modifier`,
1290    /// or `pixel_format_and_modifiers` fields).
1291    ///
1292    /// In `SetConstraints` message, each entry specifies a
1293    /// `PixelFormatAndModifier` which is acceptable to the participant
1294    /// (assuming the following constraints fields are also satisfied).
1295    ///
1296    /// In the response to `WaitForAllBuffersAllocated`, this field will be
1297    /// un-set and the one chosen `PixelFormatAndModifier` will be indicated
1298    /// using the `pixel_format` and `pixel_format_modifier` fields.
1299    ///
1300    /// All the `PixelFormatAndModifiers` in a `SetConstraints` message from a
1301    /// participant must be unique across all the entries under
1302    /// `image_format_constraints`. If
1303    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] is used in an entry, there
1304    /// must not be any other entry (considering all the entries under
1305    /// `image_format_constraints`) with matching `pixel_format_modifier`. If
1306    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] is used, there must
1307    /// not be any other entry (considering all the entries under
1308    /// `image_format_constraints`) with matching `pixel_format`.
1309    ///
1310    /// A `PixelFormatAndModifier` value with either
1311    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] or
1312    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] (but not both, for
1313    /// purposes of this example) can be combined with a
1314    /// `PixelFormatAndModifier` from a separate participant with the other
1315    /// field indicating "do not care", resulting in a complete
1316    /// `PixelFormatAndModifier` that can succeed allocation. However, at least
1317    /// for now, it's not permitted for a single participant to specify two
1318    /// separate `PixelFormatAndModifier` values which have "do not care" in
1319    /// different fields. This does not prohibit a single
1320    /// `PixelFormatAndModifier` with both `PixelFormat.DO_NOT_CARE` and
1321    /// `PixelFormatModifier.DO_NOT_CARE` (which is only a single
1322    /// `PixelFormatAndModifier` value). If a client really needs to specify
1323    /// some constraints relevant to `pixel_format`(s) with
1324    /// `pixel_format_modifier` `DO_NOT_CARE`, and other constraints relevant to
1325    /// `pixel_format_modifier`(s) with `pixel_format` `DO_NOT_CARE`, the client
1326    /// can do so by duplicating the token and using/driving two separate
1327    /// participants.
1328    ///
1329    /// See also `pixel_format` for more comments relevant to multiple
1330    /// `PixelFormatAndModifier`s in a single `ImageFormatConstraints`.
1331    pub pixel_format_and_modifiers: Option<Vec<PixelFormatAndModifier>>,
1332    /// Iff set and true, bytes_per_row_divisor in the resulting
1333    /// ImageFormatConstraints is guaranteed to be a value which requires
1334    /// bytes_per_row to be an integral number of pixels. This can result in
1335    /// more padding at the end of each row than when this field is not set to
1336    /// true, but ensures that the stride can be expressed as an integral number
1337    /// of pixels.
1338    ///
1339    /// For example, if the chosen `PixelFormat` is `B8G8R8`, if this field is
1340    /// set to true, the resulting bytes_per_row_divisor will be a multiple of
1341    /// 3. In this example, if another participant sets `bytes_per_row_divisor`
1342    /// to 4, the resulting `bytes_per_row_divisor` will be a multiple of 12.
1343    pub require_bytes_per_row_at_pixel_boundary: Option<bool>,
1344    /// If unset, any A channel of any format in this ImageFormatConstraints is
1345    /// is ignored or not ignored according to semantics conveyed out of band.
1346    ///
1347    /// If set to false, the A channel of any format in this
1348    /// ImageFormatConstraints is arbitrary values that don't mean anything.
1349    /// Producers don't need to ensure any particular values in the A channel
1350    /// and consumers should ignore the A channel. This is the same thing as
1351    /// calling the 'A' channel 'X' instead.
1352    ///
1353    /// If set to true, the A channel of any format in this
1354    /// ImageFormatConstraints is set to meaningful values. A producer should
1355    /// fill out the A values, and a consumer should pay attention to the A
1356    /// values as appropriate.
1357    ///
1358    /// If set values of this field don't match for the same pixel format and
1359    /// modifier, that format and modifier will be eliminated from
1360    /// consideration.
1361    ///
1362    /// A participant that knows that the semantics of the A channel are
1363    /// conveyed via out of band means can leave this field un-set, even if the
1364    /// out of band means is already known to specify alpha present or not
1365    /// present, but in this situation it's also ok to fill out this field for
1366    /// informational / debugging purposes.
1367    ///
1368    /// If no participant sets this field, the default is un-set.
1369    ///
1370    /// If the format chosen for allocation doesn't have an A channel, this
1371    /// field will be un-set in the allocation result.
1372    pub is_alpha_present: Option<bool>,
1373    /// If an entry in this list has width or height greater than max_size width
1374    /// or height respectively (evaluated both before and again after
1375    /// aggregation), allocation will fail.
1376    ///
1377    /// This field aggregates by appending the entries to an overall list, or in
1378    /// other words, this field does not aggregate; all entries from all
1379    /// participants must be satisfied by the allocated buffer(s) or the
1380    /// allocation will fail. This lack of aggregation is to avoid
1381    /// larger-than-necessary buffers if one participant specifies a large width
1382    /// and small height and another participant specifies a small width and
1383    /// large height, or more likely, if a single participant specifies those
1384    /// two entries (for example). In that case, the buffer's
1385    /// `BufferMemorySettings.size_bytes` needs to be large enough to store the
1386    /// larger (in bytes) of the specified sizes (given available ranges of
1387    /// other ImageFormatConstraints), but not the max width and max height
1388    /// across all specified sizes used as the width and height of a single
1389    /// image.
1390    ///
1391    /// Under the resulting `BufferCollectionInfo`, `max_size` is the max
1392    /// allowed value for each dimension separately, but this does not imply
1393    /// that an image of max_size can fit in the buffer (typically won't). In
1394    /// contrast, any image that's no bigger than an entry in the returned
1395    /// `required_max_size_list` will fit in the buffer. The returned list will
1396    /// have redundant entries removed, so a client's entry may not be present
1397    /// if another entry covers the client's entry; this also removes any
1398    /// duplicates. The correct way to check if an image will fit is to check
1399    /// that `ImageFormatImageSize()` is less than or equal to
1400    /// `BufferMemorySettings.size_bytes`.
1401    ///
1402    /// Until `required_max_size` is removed, the returned
1403    /// `required_max_size_list` will, if any participants specified
1404    /// `required_max_size`, ensure that the aggregated (using max width and max
1405    /// height) `required_max_size` will fit in the allocated buffer. This does
1406    /// not imply that there will necessarily be an entry that indicates this
1407    /// specific aggregated `required_max_size`, as that entry can be removed if
1408    /// it's covered by another entry.
1409    ///
1410    /// In contrast to `max_size`, an entry can be added to
1411    /// `required_max_size_list` to ensure the buffer actually has the capacity
1412    /// to store an image that has both width and height less than or equal to
1413    /// the entry's width and height respectively. See
1414    /// `BufferMemorySettings.size_bytes` for more on what "capacity" means
1415    /// here.
1416    ///
1417    /// A typical usage of more than one entry in this list would be specifying
1418    /// that each buffer needs to be able to store up to a given portrait size
1419    /// and also up to a given landscape size. In general, more than one entry
1420    /// makes sense if the participant needs to ensure that the buffer can be
1421    /// used to store images of a few different aspect ratios at up to the
1422    /// listed size per aspect ratio. In the response from the server, redundant
1423    /// entries are removed.
1424    pub required_max_size_list: Option<Vec<fidl_fuchsia_math__common::SizeU>>,
1425    #[doc(hidden)]
1426    pub __source_breaking: fidl::marker::SourceBreaking,
1427}
1428
1429impl fidl::Persistable for ImageFormatConstraints {}
1430
1431#[derive(Clone, Debug, Default, PartialEq)]
1432pub struct NodeSetDebugClientInfoRequest {
1433    pub name: Option<String>,
1434    pub id: Option<u64>,
1435    #[doc(hidden)]
1436    pub __source_breaking: fidl::marker::SourceBreaking,
1437}
1438
1439impl fidl::Persistable for NodeSetDebugClientInfoRequest {}
1440
1441#[derive(Clone, Debug, Default, PartialEq)]
1442pub struct NodeSetDebugTimeoutLogDeadlineRequest {
1443    pub deadline: Option<i64>,
1444    #[doc(hidden)]
1445    pub __source_breaking: fidl::marker::SourceBreaking,
1446}
1447
1448impl fidl::Persistable for NodeSetDebugTimeoutLogDeadlineRequest {}
1449
1450#[derive(Clone, Debug, Default, PartialEq)]
1451pub struct NodeSetNameRequest {
1452    pub priority: Option<u32>,
1453    pub name: Option<String>,
1454    #[doc(hidden)]
1455    pub __source_breaking: fidl::marker::SourceBreaking,
1456}
1457
1458impl fidl::Persistable for NodeSetNameRequest {}
1459
1460#[derive(Clone, Debug, Default, PartialEq)]
1461pub struct NodeGetBufferCollectionIdResponse {
1462    pub buffer_collection_id: Option<u64>,
1463    #[doc(hidden)]
1464    pub __source_breaking: fidl::marker::SourceBreaking,
1465}
1466
1467impl fidl::Persistable for NodeGetBufferCollectionIdResponse {}
1468
1469#[derive(Clone, Debug, Default, PartialEq)]
1470pub struct NodeIsAlternateForResponse {
1471    pub is_alternate: Option<bool>,
1472    #[doc(hidden)]
1473    pub __source_breaking: fidl::marker::SourceBreaking,
1474}
1475
1476impl fidl::Persistable for NodeIsAlternateForResponse {}
1477
1478#[derive(Clone, Debug, Default, PartialEq)]
1479pub struct SecureHeapAndRange {
1480    pub heap: Option<Heap>,
1481    pub range: Option<SecureHeapRange>,
1482    #[doc(hidden)]
1483    pub __source_breaking: fidl::marker::SourceBreaking,
1484}
1485
1486impl fidl::Persistable for SecureHeapAndRange {}
1487
1488#[derive(Clone, Debug, Default, PartialEq)]
1489pub struct SecureHeapAndRangeModification {
1490    pub heap: Option<Heap>,
1491    pub old_range: Option<SecureHeapRange>,
1492    pub new_range: Option<SecureHeapRange>,
1493    #[doc(hidden)]
1494    pub __source_breaking: fidl::marker::SourceBreaking,
1495}
1496
1497impl fidl::Persistable for SecureHeapAndRangeModification {}
1498
1499#[derive(Clone, Debug, Default, PartialEq)]
1500pub struct SecureHeapAndRanges {
1501    /// This is which secure/protected heap.
1502    pub heap: Option<Heap>,
1503    /// The list of physical ranges.  This list must be sorted by
1504    /// physical_address (lower first), and must not have any overlapping
1505    /// ranges.  Ranges that are directly adjacent are allowed (not
1506    /// overlapping).
1507    pub ranges: Option<Vec<SecureHeapRange>>,
1508    #[doc(hidden)]
1509    pub __source_breaking: fidl::marker::SourceBreaking,
1510}
1511
1512impl fidl::Persistable for SecureHeapAndRanges {}
1513
1514#[derive(Clone, Debug, Default, PartialEq)]
1515pub struct SecureHeapProperties {
1516    /// The Heap is repeated here for convenience.
1517    pub heap: Option<Heap>,
1518    /// If true, more than one call to SetPhysicalSecureHeap() for the same
1519    /// heap is allowed.  If false, only one SetPhyscialSecureHeap() call is
1520    /// allowed, and no calls to DeleteSecureHeapPhysicalRange() or
1521    /// ModifySecureHeapPhysicalRange() are allowed.  Even when this is false,
1522    /// the SecureMem server (driver) is still responsible for de-protecting
1523    /// just before warm reboot if protected ranges would not otherwise be
1524    /// cleaned up during a warm reboot.
1525    pub dynamic_protection_ranges: Option<bool>,
1526    /// The granularity of protection ranges.  If the granularity of start is
1527    /// different than granularity of end or length, then this is the max
1528    /// granularity value among those values.
1529    ///
1530    /// This must be a power of 2.  The client must not request ranges that
1531    /// specify smaller granularity.
1532    ///
1533    /// This must be at least zx_system_page_size() even if the HW can do
1534    /// smaller granularity.
1535    pub protected_range_granularity: Option<u32>,
1536    /// The SecureMem server should not count reserved ranges that the SecureMem
1537    /// server uses internally to get from range set A to range set B, if the
1538    /// SecureMem server needs to do any emulation of that sort.  Normally such
1539    /// emulation by the SecureMem server is unnecessary.  If any ranges are
1540    /// reserved by the SecureMem server, those reserved ranges are not
1541    /// available for use by the SecureMem client.
1542    ///
1543    /// If the number of ranges is limited only by available memory, it's ok for
1544    /// the SecureMem server to report 0xFFFFFFFFFFFFFFFF for this value.  The
1545    /// field must still be set.  As usual, the SecureMem server should ensure
1546    /// that SetPhysicalSecureHeapRanges() succeeds or fails atomically (either
1547    /// fully updates or rolls back before completing).
1548    pub max_protected_range_count: Option<u64>,
1549    /// Iff true, ModifySecureHeapPhysicalRange() is implemented.  Calling
1550    /// ModifySecureHeapPhysicalRange() when is_mod_protected_range_available
1551    /// is false is prohibited.  Don't attempt to detect availability of
1552    /// ModifySecureHeapPhysicalRange() by calling it to see if it fails; it
1553    /// may ZX_PANIC().
1554    pub is_mod_protected_range_available: Option<bool>,
1555    #[doc(hidden)]
1556    pub __source_breaking: fidl::marker::SourceBreaking,
1557}
1558
1559impl fidl::Persistable for SecureHeapProperties {}
1560
1561#[derive(Clone, Debug, Default, PartialEq)]
1562pub struct SecureHeapRange {
1563    /// Must be aligned to at least heap_range_granularity.
1564    pub physical_address: Option<u64>,
1565    /// Must be aligned to at least heap_range_granularity.
1566    pub size_bytes: Option<u64>,
1567    #[doc(hidden)]
1568    pub __source_breaking: fidl::marker::SourceBreaking,
1569}
1570
1571impl fidl::Persistable for SecureHeapRange {}
1572
1573#[derive(Clone, Debug, Default, PartialEq)]
1574pub struct SecureMemAddSecureHeapPhysicalRangeRequest {
1575    pub heap_range: Option<SecureHeapAndRange>,
1576    #[doc(hidden)]
1577    pub __source_breaking: fidl::marker::SourceBreaking,
1578}
1579
1580impl fidl::Persistable for SecureMemAddSecureHeapPhysicalRangeRequest {}
1581
1582#[derive(Clone, Debug, Default, PartialEq)]
1583pub struct SecureMemDeleteSecureHeapPhysicalRangeRequest {
1584    pub heap_range: Option<SecureHeapAndRange>,
1585    #[doc(hidden)]
1586    pub __source_breaking: fidl::marker::SourceBreaking,
1587}
1588
1589impl fidl::Persistable for SecureMemDeleteSecureHeapPhysicalRangeRequest {}
1590
1591#[derive(Clone, Debug, Default, PartialEq)]
1592pub struct SecureMemGetPhysicalSecureHeapPropertiesRequest {
1593    pub entire_heap: Option<SecureHeapAndRange>,
1594    #[doc(hidden)]
1595    pub __source_breaking: fidl::marker::SourceBreaking,
1596}
1597
1598impl fidl::Persistable for SecureMemGetPhysicalSecureHeapPropertiesRequest {}
1599
1600#[derive(Clone, Debug, Default, PartialEq)]
1601pub struct SecureMemModifySecureHeapPhysicalRangeRequest {
1602    pub range_modification: Option<SecureHeapAndRangeModification>,
1603    #[doc(hidden)]
1604    pub __source_breaking: fidl::marker::SourceBreaking,
1605}
1606
1607impl fidl::Persistable for SecureMemModifySecureHeapPhysicalRangeRequest {}
1608
1609#[derive(Clone, Debug, Default, PartialEq)]
1610pub struct SecureMemZeroSubRangeRequest {
1611    pub is_covering_range_explicit: Option<bool>,
1612    pub heap_range: Option<SecureHeapAndRange>,
1613    #[doc(hidden)]
1614    pub __source_breaking: fidl::marker::SourceBreaking,
1615}
1616
1617impl fidl::Persistable for SecureMemZeroSubRangeRequest {}
1618
1619#[derive(Clone, Debug, Default, PartialEq)]
1620pub struct SecureMemGetDynamicSecureHeapsResponse {
1621    pub heaps: Option<Vec<DynamicSecureHeap>>,
1622    #[doc(hidden)]
1623    pub __source_breaking: fidl::marker::SourceBreaking,
1624}
1625
1626impl fidl::Persistable for SecureMemGetDynamicSecureHeapsResponse {}
1627
1628#[derive(Clone, Debug, Default, PartialEq)]
1629pub struct SecureMemGetPhysicalSecureHeapPropertiesResponse {
1630    pub properties: Option<SecureHeapProperties>,
1631    #[doc(hidden)]
1632    pub __source_breaking: fidl::marker::SourceBreaking,
1633}
1634
1635impl fidl::Persistable for SecureMemGetPhysicalSecureHeapPropertiesResponse {}
1636
1637#[derive(Clone, Debug, Default, PartialEq)]
1638pub struct SecureMemGetPhysicalSecureHeapsResponse {
1639    pub heaps: Option<Vec<SecureHeapAndRanges>>,
1640    #[doc(hidden)]
1641    pub __source_breaking: fidl::marker::SourceBreaking,
1642}
1643
1644impl fidl::Persistable for SecureMemGetPhysicalSecureHeapsResponse {}
1645
1646/// These settings and constraints apply to all the buffers in the collection.
1647#[derive(Clone, Debug, Default, PartialEq)]
1648pub struct SingleBufferSettings {
1649    /// This field will always be set by sysmem.
1650    pub buffer_settings: Option<BufferMemorySettings>,
1651    /// Buffers holding data that is not uncompressed image data will not have
1652    /// this field set.  Buffers holding data that is uncompressed image data
1653    /// _may_ have this field set.
1654    ///
1655    /// At least for now, changing the PixelFormat requires re-allocating
1656    /// buffers.
1657    ///
1658    /// If un-set, there are no image format constraints.
1659    pub image_format_constraints: Option<ImageFormatConstraints>,
1660    #[doc(hidden)]
1661    pub __source_breaking: fidl::marker::SourceBreaking,
1662}
1663
1664impl fidl::Persistable for SingleBufferSettings {}
1665
1666pub mod allocator_ordinals {
1667    pub const ALLOCATE_NON_SHARED_COLLECTION: u64 = 0x5ca681f025a80e44;
1668    pub const ALLOCATE_SHARED_COLLECTION: u64 = 0x11a19ff51f0b49c1;
1669    pub const BIND_SHARED_COLLECTION: u64 = 0x550916b0dc1d5b4e;
1670    pub const VALIDATE_BUFFER_COLLECTION_TOKEN: u64 = 0x4c5ee91b02a7e68d;
1671    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x6f68f19a3f509c4d;
1672    pub const GET_VMO_INFO: u64 = 0x21a881120aa0ddf9;
1673}
1674
1675pub mod buffer_collection_ordinals {
1676    pub const SYNC: u64 = 0x11ac2555cf575b54;
1677    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1678    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1679    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1680    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1681    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1682    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1683    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1684    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1685    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1686    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1687    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1688    pub const SET_CONSTRAINTS: u64 = 0x1fde0f19d650197b;
1689    pub const WAIT_FOR_ALL_BUFFERS_ALLOCATED: u64 = 0x62300344b61404e;
1690    pub const CHECK_ALL_BUFFERS_ALLOCATED: u64 = 0x35a5fe77ce939c10;
1691    pub const ATTACH_TOKEN: u64 = 0x46ac7d0008492982;
1692    pub const ATTACH_LIFETIME_TRACKING: u64 = 0x3ecb510113116dcf;
1693}
1694
1695pub mod buffer_collection_token_ordinals {
1696    pub const SYNC: u64 = 0x11ac2555cf575b54;
1697    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1698    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1699    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1700    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1701    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1702    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1703    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1704    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1705    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1706    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1707    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1708    pub const DUPLICATE_SYNC: u64 = 0x1c1af9919d1ca45c;
1709    pub const DUPLICATE: u64 = 0x73e78f92ee7fb887;
1710    pub const SET_DISPENSABLE: u64 = 0x228acf979254df8b;
1711    pub const CREATE_BUFFER_COLLECTION_TOKEN_GROUP: u64 = 0x30f8d48e77bd36f2;
1712}
1713
1714pub mod buffer_collection_token_group_ordinals {
1715    pub const SYNC: u64 = 0x11ac2555cf575b54;
1716    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1717    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1718    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1719    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1720    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1721    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1722    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1723    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1724    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1725    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1726    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1727    pub const CREATE_CHILD: u64 = 0x41a0075d419f30c5;
1728    pub const CREATE_CHILDREN_SYNC: u64 = 0x15dea448c536070a;
1729    pub const ALL_CHILDREN_PRESENT: u64 = 0x5c327e4a23391312;
1730}
1731
1732pub mod node_ordinals {
1733    pub const SYNC: u64 = 0x11ac2555cf575b54;
1734    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1735    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1736    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1737    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1738    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1739    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1740    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1741    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1742    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1743    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1744    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1745}
1746
1747pub mod secure_mem_ordinals {
1748    pub const GET_PHYSICAL_SECURE_HEAPS: u64 = 0x38716300592073e3;
1749    pub const GET_DYNAMIC_SECURE_HEAPS: u64 = 0x1190847f99952834;
1750    pub const GET_PHYSICAL_SECURE_HEAP_PROPERTIES: u64 = 0xc6f06889009c7bc;
1751    pub const ADD_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0x35f695b9b6c7217a;
1752    pub const DELETE_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0xeaa58c650264c9e;
1753    pub const MODIFY_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0x60b7448aa1187734;
1754    pub const ZERO_SUB_RANGE: u64 = 0x5b25b7901a385ce5;
1755}
1756
1757mod internal {
1758    use super::*;
1759    unsafe impl fidl::encoding::TypeMarker for CoherencyDomain {
1760        type Owned = Self;
1761
1762        #[inline(always)]
1763        fn inline_align(_context: fidl::encoding::Context) -> usize {
1764            std::mem::align_of::<u32>()
1765        }
1766
1767        #[inline(always)]
1768        fn inline_size(_context: fidl::encoding::Context) -> usize {
1769            std::mem::size_of::<u32>()
1770        }
1771
1772        #[inline(always)]
1773        fn encode_is_copy() -> bool {
1774            false
1775        }
1776
1777        #[inline(always)]
1778        fn decode_is_copy() -> bool {
1779            false
1780        }
1781    }
1782
1783    impl fidl::encoding::ValueTypeMarker for CoherencyDomain {
1784        type Borrowed<'a> = Self;
1785        #[inline(always)]
1786        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1787            *value
1788        }
1789    }
1790
1791    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1792        for CoherencyDomain
1793    {
1794        #[inline]
1795        unsafe fn encode(
1796            self,
1797            encoder: &mut fidl::encoding::Encoder<'_, D>,
1798            offset: usize,
1799            _depth: fidl::encoding::Depth,
1800        ) -> fidl::Result<()> {
1801            encoder.debug_check_bounds::<Self>(offset);
1802            encoder.write_num(self.into_primitive(), offset);
1803            Ok(())
1804        }
1805    }
1806
1807    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CoherencyDomain {
1808        #[inline(always)]
1809        fn new_empty() -> Self {
1810            Self::unknown()
1811        }
1812
1813        #[inline]
1814        unsafe fn decode(
1815            &mut self,
1816            decoder: &mut fidl::encoding::Decoder<'_, D>,
1817            offset: usize,
1818            _depth: fidl::encoding::Depth,
1819        ) -> fidl::Result<()> {
1820            decoder.debug_check_bounds::<Self>(offset);
1821            let prim = decoder.read_num::<u32>(offset);
1822
1823            *self = Self::from_primitive_allow_unknown(prim);
1824            Ok(())
1825        }
1826    }
1827    unsafe impl fidl::encoding::TypeMarker for Error {
1828        type Owned = Self;
1829
1830        #[inline(always)]
1831        fn inline_align(_context: fidl::encoding::Context) -> usize {
1832            std::mem::align_of::<u32>()
1833        }
1834
1835        #[inline(always)]
1836        fn inline_size(_context: fidl::encoding::Context) -> usize {
1837            std::mem::size_of::<u32>()
1838        }
1839
1840        #[inline(always)]
1841        fn encode_is_copy() -> bool {
1842            false
1843        }
1844
1845        #[inline(always)]
1846        fn decode_is_copy() -> bool {
1847            false
1848        }
1849    }
1850
1851    impl fidl::encoding::ValueTypeMarker for Error {
1852        type Borrowed<'a> = Self;
1853        #[inline(always)]
1854        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1855            *value
1856        }
1857    }
1858
1859    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
1860        #[inline]
1861        unsafe fn encode(
1862            self,
1863            encoder: &mut fidl::encoding::Encoder<'_, D>,
1864            offset: usize,
1865            _depth: fidl::encoding::Depth,
1866        ) -> fidl::Result<()> {
1867            encoder.debug_check_bounds::<Self>(offset);
1868            encoder.write_num(self.into_primitive(), offset);
1869            Ok(())
1870        }
1871    }
1872
1873    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
1874        #[inline(always)]
1875        fn new_empty() -> Self {
1876            Self::unknown()
1877        }
1878
1879        #[inline]
1880        unsafe fn decode(
1881            &mut self,
1882            decoder: &mut fidl::encoding::Decoder<'_, D>,
1883            offset: usize,
1884            _depth: fidl::encoding::Depth,
1885        ) -> fidl::Result<()> {
1886            decoder.debug_check_bounds::<Self>(offset);
1887            let prim = decoder.read_num::<u32>(offset);
1888
1889            *self = Self::from_primitive_allow_unknown(prim);
1890            Ok(())
1891        }
1892    }
1893
1894    impl fidl::encoding::ValueTypeMarker for PixelFormatAndModifier {
1895        type Borrowed<'a> = &'a Self;
1896        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1897            value
1898        }
1899    }
1900
1901    unsafe impl fidl::encoding::TypeMarker for PixelFormatAndModifier {
1902        type Owned = Self;
1903
1904        #[inline(always)]
1905        fn inline_align(_context: fidl::encoding::Context) -> usize {
1906            8
1907        }
1908
1909        #[inline(always)]
1910        fn inline_size(_context: fidl::encoding::Context) -> usize {
1911            16
1912        }
1913    }
1914
1915    unsafe impl<D: fidl::encoding::ResourceDialect>
1916        fidl::encoding::Encode<PixelFormatAndModifier, D> for &PixelFormatAndModifier
1917    {
1918        #[inline]
1919        unsafe fn encode(
1920            self,
1921            encoder: &mut fidl::encoding::Encoder<'_, D>,
1922            offset: usize,
1923            _depth: fidl::encoding::Depth,
1924        ) -> fidl::Result<()> {
1925            encoder.debug_check_bounds::<PixelFormatAndModifier>(offset);
1926            // Delegate to tuple encoding.
1927            fidl::encoding::Encode::<PixelFormatAndModifier, D>::encode(
1928                (
1929                    <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format),
1930                    <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format_modifier),
1931                ),
1932                encoder, offset, _depth
1933            )
1934        }
1935    }
1936    unsafe impl<
1937        D: fidl::encoding::ResourceDialect,
1938        T0: fidl::encoding::Encode<fidl_fuchsia_images2__common::PixelFormat, D>,
1939        T1: fidl::encoding::Encode<fidl_fuchsia_images2__common::PixelFormatModifier, D>,
1940    > fidl::encoding::Encode<PixelFormatAndModifier, D> for (T0, T1)
1941    {
1942        #[inline]
1943        unsafe fn encode(
1944            self,
1945            encoder: &mut fidl::encoding::Encoder<'_, D>,
1946            offset: usize,
1947            depth: fidl::encoding::Depth,
1948        ) -> fidl::Result<()> {
1949            encoder.debug_check_bounds::<PixelFormatAndModifier>(offset);
1950            // Zero out padding regions. There's no need to apply masks
1951            // because the unmasked parts will be overwritten by fields.
1952            unsafe {
1953                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1954                (ptr as *mut u64).write_unaligned(0);
1955            }
1956            // Write the fields.
1957            self.0.encode(encoder, offset + 0, depth)?;
1958            self.1.encode(encoder, offset + 8, depth)?;
1959            Ok(())
1960        }
1961    }
1962
1963    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1964        for PixelFormatAndModifier
1965    {
1966        #[inline(always)]
1967        fn new_empty() -> Self {
1968            Self {
1969                pixel_format: fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D),
1970                pixel_format_modifier: fidl::new_empty!(
1971                    fidl_fuchsia_images2__common::PixelFormatModifier,
1972                    D
1973                ),
1974            }
1975        }
1976
1977        #[inline]
1978        unsafe fn decode(
1979            &mut self,
1980            decoder: &mut fidl::encoding::Decoder<'_, D>,
1981            offset: usize,
1982            _depth: fidl::encoding::Depth,
1983        ) -> fidl::Result<()> {
1984            decoder.debug_check_bounds::<Self>(offset);
1985            // Verify that padding bytes are zero.
1986            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1987            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1988            let mask = 0xffffffff00000000u64;
1989            let maskedval = padval & mask;
1990            if maskedval != 0 {
1991                return Err(fidl::Error::NonZeroPadding {
1992                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1993                });
1994            }
1995            fidl::decode!(
1996                fidl_fuchsia_images2__common::PixelFormat,
1997                D,
1998                &mut self.pixel_format,
1999                decoder,
2000                offset + 0,
2001                _depth
2002            )?;
2003            fidl::decode!(
2004                fidl_fuchsia_images2__common::PixelFormatModifier,
2005                D,
2006                &mut self.pixel_format_modifier,
2007                decoder,
2008                offset + 8,
2009                _depth
2010            )?;
2011            Ok(())
2012        }
2013    }
2014
2015    impl AllocatorSetDebugClientInfoRequest {
2016        #[inline(always)]
2017        fn max_ordinal_present(&self) -> u64 {
2018            if let Some(_) = self.id {
2019                return 2;
2020            }
2021            if let Some(_) = self.name {
2022                return 1;
2023            }
2024            0
2025        }
2026    }
2027
2028    impl fidl::encoding::ValueTypeMarker for AllocatorSetDebugClientInfoRequest {
2029        type Borrowed<'a> = &'a Self;
2030        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2031            value
2032        }
2033    }
2034
2035    unsafe impl fidl::encoding::TypeMarker for AllocatorSetDebugClientInfoRequest {
2036        type Owned = Self;
2037
2038        #[inline(always)]
2039        fn inline_align(_context: fidl::encoding::Context) -> usize {
2040            8
2041        }
2042
2043        #[inline(always)]
2044        fn inline_size(_context: fidl::encoding::Context) -> usize {
2045            16
2046        }
2047    }
2048
2049    unsafe impl<D: fidl::encoding::ResourceDialect>
2050        fidl::encoding::Encode<AllocatorSetDebugClientInfoRequest, D>
2051        for &AllocatorSetDebugClientInfoRequest
2052    {
2053        unsafe fn encode(
2054            self,
2055            encoder: &mut fidl::encoding::Encoder<'_, D>,
2056            offset: usize,
2057            mut depth: fidl::encoding::Depth,
2058        ) -> fidl::Result<()> {
2059            encoder.debug_check_bounds::<AllocatorSetDebugClientInfoRequest>(offset);
2060            // Vector header
2061            let max_ordinal: u64 = self.max_ordinal_present();
2062            encoder.write_num(max_ordinal, offset);
2063            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2064            // Calling encoder.out_of_line_offset(0) is not allowed.
2065            if max_ordinal == 0 {
2066                return Ok(());
2067            }
2068            depth.increment()?;
2069            let envelope_size = 8;
2070            let bytes_len = max_ordinal as usize * envelope_size;
2071            #[allow(unused_variables)]
2072            let offset = encoder.out_of_line_offset(bytes_len);
2073            let mut _prev_end_offset: usize = 0;
2074            if 1 > max_ordinal {
2075                return Ok(());
2076            }
2077
2078            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2079            // are envelope_size bytes.
2080            let cur_offset: usize = (1 - 1) * envelope_size;
2081
2082            // Zero reserved fields.
2083            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2084
2085            // Safety:
2086            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2087            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2088            //   envelope_size bytes, there is always sufficient room.
2089            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
2090                self.name.as_ref().map(
2091                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
2092                ),
2093                encoder,
2094                offset + cur_offset,
2095                depth,
2096            )?;
2097
2098            _prev_end_offset = cur_offset + envelope_size;
2099            if 2 > max_ordinal {
2100                return Ok(());
2101            }
2102
2103            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2104            // are envelope_size bytes.
2105            let cur_offset: usize = (2 - 1) * envelope_size;
2106
2107            // Zero reserved fields.
2108            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2109
2110            // Safety:
2111            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2112            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2113            //   envelope_size bytes, there is always sufficient room.
2114            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2115                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2116                encoder,
2117                offset + cur_offset,
2118                depth,
2119            )?;
2120
2121            _prev_end_offset = cur_offset + envelope_size;
2122
2123            Ok(())
2124        }
2125    }
2126
2127    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2128        for AllocatorSetDebugClientInfoRequest
2129    {
2130        #[inline(always)]
2131        fn new_empty() -> Self {
2132            Self::default()
2133        }
2134
2135        unsafe fn decode(
2136            &mut self,
2137            decoder: &mut fidl::encoding::Decoder<'_, D>,
2138            offset: usize,
2139            mut depth: fidl::encoding::Depth,
2140        ) -> fidl::Result<()> {
2141            decoder.debug_check_bounds::<Self>(offset);
2142            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2143                None => return Err(fidl::Error::NotNullable),
2144                Some(len) => len,
2145            };
2146            // Calling decoder.out_of_line_offset(0) is not allowed.
2147            if len == 0 {
2148                return Ok(());
2149            };
2150            depth.increment()?;
2151            let envelope_size = 8;
2152            let bytes_len = len * envelope_size;
2153            let offset = decoder.out_of_line_offset(bytes_len)?;
2154            // Decode the envelope for each type.
2155            let mut _next_ordinal_to_read = 0;
2156            let mut next_offset = offset;
2157            let end_offset = offset + bytes_len;
2158            _next_ordinal_to_read += 1;
2159            if next_offset >= end_offset {
2160                return Ok(());
2161            }
2162
2163            // Decode unknown envelopes for gaps in ordinals.
2164            while _next_ordinal_to_read < 1 {
2165                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2166                _next_ordinal_to_read += 1;
2167                next_offset += envelope_size;
2168            }
2169
2170            let next_out_of_line = decoder.next_out_of_line();
2171            let handles_before = decoder.remaining_handles();
2172            if let Some((inlined, num_bytes, num_handles)) =
2173                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2174            {
2175                let member_inline_size =
2176                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
2177                        decoder.context,
2178                    );
2179                if inlined != (member_inline_size <= 4) {
2180                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2181                }
2182                let inner_offset;
2183                let mut inner_depth = depth.clone();
2184                if inlined {
2185                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2186                    inner_offset = next_offset;
2187                } else {
2188                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2189                    inner_depth.increment()?;
2190                }
2191                let val_ref = self
2192                    .name
2193                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
2194                fidl::decode!(
2195                    fidl::encoding::BoundedString<256>,
2196                    D,
2197                    val_ref,
2198                    decoder,
2199                    inner_offset,
2200                    inner_depth
2201                )?;
2202                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2203                {
2204                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2205                }
2206                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2207                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2208                }
2209            }
2210
2211            next_offset += envelope_size;
2212            _next_ordinal_to_read += 1;
2213            if next_offset >= end_offset {
2214                return Ok(());
2215            }
2216
2217            // Decode unknown envelopes for gaps in ordinals.
2218            while _next_ordinal_to_read < 2 {
2219                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2220                _next_ordinal_to_read += 1;
2221                next_offset += envelope_size;
2222            }
2223
2224            let next_out_of_line = decoder.next_out_of_line();
2225            let handles_before = decoder.remaining_handles();
2226            if let Some((inlined, num_bytes, num_handles)) =
2227                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2228            {
2229                let member_inline_size =
2230                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2231                if inlined != (member_inline_size <= 4) {
2232                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2233                }
2234                let inner_offset;
2235                let mut inner_depth = depth.clone();
2236                if inlined {
2237                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2238                    inner_offset = next_offset;
2239                } else {
2240                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2241                    inner_depth.increment()?;
2242                }
2243                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
2244                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2245                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2246                {
2247                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2248                }
2249                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2250                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2251                }
2252            }
2253
2254            next_offset += envelope_size;
2255
2256            // Decode the remaining unknown envelopes.
2257            while next_offset < end_offset {
2258                _next_ordinal_to_read += 1;
2259                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2260                next_offset += envelope_size;
2261            }
2262
2263            Ok(())
2264        }
2265    }
2266
2267    impl AllocatorValidateBufferCollectionTokenRequest {
2268        #[inline(always)]
2269        fn max_ordinal_present(&self) -> u64 {
2270            if let Some(_) = self.token_server_koid {
2271                return 1;
2272            }
2273            0
2274        }
2275    }
2276
2277    impl fidl::encoding::ValueTypeMarker for AllocatorValidateBufferCollectionTokenRequest {
2278        type Borrowed<'a> = &'a Self;
2279        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2280            value
2281        }
2282    }
2283
2284    unsafe impl fidl::encoding::TypeMarker for AllocatorValidateBufferCollectionTokenRequest {
2285        type Owned = Self;
2286
2287        #[inline(always)]
2288        fn inline_align(_context: fidl::encoding::Context) -> usize {
2289            8
2290        }
2291
2292        #[inline(always)]
2293        fn inline_size(_context: fidl::encoding::Context) -> usize {
2294            16
2295        }
2296    }
2297
2298    unsafe impl<D: fidl::encoding::ResourceDialect>
2299        fidl::encoding::Encode<AllocatorValidateBufferCollectionTokenRequest, D>
2300        for &AllocatorValidateBufferCollectionTokenRequest
2301    {
2302        unsafe fn encode(
2303            self,
2304            encoder: &mut fidl::encoding::Encoder<'_, D>,
2305            offset: usize,
2306            mut depth: fidl::encoding::Depth,
2307        ) -> fidl::Result<()> {
2308            encoder.debug_check_bounds::<AllocatorValidateBufferCollectionTokenRequest>(offset);
2309            // Vector header
2310            let max_ordinal: u64 = self.max_ordinal_present();
2311            encoder.write_num(max_ordinal, offset);
2312            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2313            // Calling encoder.out_of_line_offset(0) is not allowed.
2314            if max_ordinal == 0 {
2315                return Ok(());
2316            }
2317            depth.increment()?;
2318            let envelope_size = 8;
2319            let bytes_len = max_ordinal as usize * envelope_size;
2320            #[allow(unused_variables)]
2321            let offset = encoder.out_of_line_offset(bytes_len);
2322            let mut _prev_end_offset: usize = 0;
2323            if 1 > max_ordinal {
2324                return Ok(());
2325            }
2326
2327            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2328            // are envelope_size bytes.
2329            let cur_offset: usize = (1 - 1) * envelope_size;
2330
2331            // Zero reserved fields.
2332            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2333
2334            // Safety:
2335            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2336            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2337            //   envelope_size bytes, there is always sufficient room.
2338            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2339                self.token_server_koid
2340                    .as_ref()
2341                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2342                encoder,
2343                offset + cur_offset,
2344                depth,
2345            )?;
2346
2347            _prev_end_offset = cur_offset + envelope_size;
2348
2349            Ok(())
2350        }
2351    }
2352
2353    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2354        for AllocatorValidateBufferCollectionTokenRequest
2355    {
2356        #[inline(always)]
2357        fn new_empty() -> Self {
2358            Self::default()
2359        }
2360
2361        unsafe fn decode(
2362            &mut self,
2363            decoder: &mut fidl::encoding::Decoder<'_, D>,
2364            offset: usize,
2365            mut depth: fidl::encoding::Depth,
2366        ) -> fidl::Result<()> {
2367            decoder.debug_check_bounds::<Self>(offset);
2368            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2369                None => return Err(fidl::Error::NotNullable),
2370                Some(len) => len,
2371            };
2372            // Calling decoder.out_of_line_offset(0) is not allowed.
2373            if len == 0 {
2374                return Ok(());
2375            };
2376            depth.increment()?;
2377            let envelope_size = 8;
2378            let bytes_len = len * envelope_size;
2379            let offset = decoder.out_of_line_offset(bytes_len)?;
2380            // Decode the envelope for each type.
2381            let mut _next_ordinal_to_read = 0;
2382            let mut next_offset = offset;
2383            let end_offset = offset + bytes_len;
2384            _next_ordinal_to_read += 1;
2385            if next_offset >= end_offset {
2386                return Ok(());
2387            }
2388
2389            // Decode unknown envelopes for gaps in ordinals.
2390            while _next_ordinal_to_read < 1 {
2391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2392                _next_ordinal_to_read += 1;
2393                next_offset += envelope_size;
2394            }
2395
2396            let next_out_of_line = decoder.next_out_of_line();
2397            let handles_before = decoder.remaining_handles();
2398            if let Some((inlined, num_bytes, num_handles)) =
2399                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2400            {
2401                let member_inline_size =
2402                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2403                if inlined != (member_inline_size <= 4) {
2404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2405                }
2406                let inner_offset;
2407                let mut inner_depth = depth.clone();
2408                if inlined {
2409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2410                    inner_offset = next_offset;
2411                } else {
2412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2413                    inner_depth.increment()?;
2414                }
2415                let val_ref =
2416                    self.token_server_koid.get_or_insert_with(|| fidl::new_empty!(u64, D));
2417                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2418                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2419                {
2420                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2421                }
2422                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2423                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2424                }
2425            }
2426
2427            next_offset += envelope_size;
2428
2429            // Decode the remaining unknown envelopes.
2430            while next_offset < end_offset {
2431                _next_ordinal_to_read += 1;
2432                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2433                next_offset += envelope_size;
2434            }
2435
2436            Ok(())
2437        }
2438    }
2439
2440    impl AllocatorValidateBufferCollectionTokenResponse {
2441        #[inline(always)]
2442        fn max_ordinal_present(&self) -> u64 {
2443            if let Some(_) = self.is_known {
2444                return 1;
2445            }
2446            0
2447        }
2448    }
2449
2450    impl fidl::encoding::ValueTypeMarker for AllocatorValidateBufferCollectionTokenResponse {
2451        type Borrowed<'a> = &'a Self;
2452        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2453            value
2454        }
2455    }
2456
2457    unsafe impl fidl::encoding::TypeMarker for AllocatorValidateBufferCollectionTokenResponse {
2458        type Owned = Self;
2459
2460        #[inline(always)]
2461        fn inline_align(_context: fidl::encoding::Context) -> usize {
2462            8
2463        }
2464
2465        #[inline(always)]
2466        fn inline_size(_context: fidl::encoding::Context) -> usize {
2467            16
2468        }
2469    }
2470
2471    unsafe impl<D: fidl::encoding::ResourceDialect>
2472        fidl::encoding::Encode<AllocatorValidateBufferCollectionTokenResponse, D>
2473        for &AllocatorValidateBufferCollectionTokenResponse
2474    {
2475        unsafe fn encode(
2476            self,
2477            encoder: &mut fidl::encoding::Encoder<'_, D>,
2478            offset: usize,
2479            mut depth: fidl::encoding::Depth,
2480        ) -> fidl::Result<()> {
2481            encoder.debug_check_bounds::<AllocatorValidateBufferCollectionTokenResponse>(offset);
2482            // Vector header
2483            let max_ordinal: u64 = self.max_ordinal_present();
2484            encoder.write_num(max_ordinal, offset);
2485            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2486            // Calling encoder.out_of_line_offset(0) is not allowed.
2487            if max_ordinal == 0 {
2488                return Ok(());
2489            }
2490            depth.increment()?;
2491            let envelope_size = 8;
2492            let bytes_len = max_ordinal as usize * envelope_size;
2493            #[allow(unused_variables)]
2494            let offset = encoder.out_of_line_offset(bytes_len);
2495            let mut _prev_end_offset: usize = 0;
2496            if 1 > max_ordinal {
2497                return Ok(());
2498            }
2499
2500            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2501            // are envelope_size bytes.
2502            let cur_offset: usize = (1 - 1) * envelope_size;
2503
2504            // Zero reserved fields.
2505            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2506
2507            // Safety:
2508            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2509            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2510            //   envelope_size bytes, there is always sufficient room.
2511            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2512                self.is_known.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2513                encoder,
2514                offset + cur_offset,
2515                depth,
2516            )?;
2517
2518            _prev_end_offset = cur_offset + envelope_size;
2519
2520            Ok(())
2521        }
2522    }
2523
2524    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2525        for AllocatorValidateBufferCollectionTokenResponse
2526    {
2527        #[inline(always)]
2528        fn new_empty() -> Self {
2529            Self::default()
2530        }
2531
2532        unsafe fn decode(
2533            &mut self,
2534            decoder: &mut fidl::encoding::Decoder<'_, D>,
2535            offset: usize,
2536            mut depth: fidl::encoding::Depth,
2537        ) -> fidl::Result<()> {
2538            decoder.debug_check_bounds::<Self>(offset);
2539            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2540                None => return Err(fidl::Error::NotNullable),
2541                Some(len) => len,
2542            };
2543            // Calling decoder.out_of_line_offset(0) is not allowed.
2544            if len == 0 {
2545                return Ok(());
2546            };
2547            depth.increment()?;
2548            let envelope_size = 8;
2549            let bytes_len = len * envelope_size;
2550            let offset = decoder.out_of_line_offset(bytes_len)?;
2551            // Decode the envelope for each type.
2552            let mut _next_ordinal_to_read = 0;
2553            let mut next_offset = offset;
2554            let end_offset = offset + bytes_len;
2555            _next_ordinal_to_read += 1;
2556            if next_offset >= end_offset {
2557                return Ok(());
2558            }
2559
2560            // Decode unknown envelopes for gaps in ordinals.
2561            while _next_ordinal_to_read < 1 {
2562                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2563                _next_ordinal_to_read += 1;
2564                next_offset += envelope_size;
2565            }
2566
2567            let next_out_of_line = decoder.next_out_of_line();
2568            let handles_before = decoder.remaining_handles();
2569            if let Some((inlined, num_bytes, num_handles)) =
2570                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2571            {
2572                let member_inline_size =
2573                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2574                if inlined != (member_inline_size <= 4) {
2575                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2576                }
2577                let inner_offset;
2578                let mut inner_depth = depth.clone();
2579                if inlined {
2580                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2581                    inner_offset = next_offset;
2582                } else {
2583                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2584                    inner_depth.increment()?;
2585                }
2586                let val_ref = self.is_known.get_or_insert_with(|| fidl::new_empty!(bool, D));
2587                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2588                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2589                {
2590                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2591                }
2592                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2593                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2594                }
2595            }
2596
2597            next_offset += envelope_size;
2598
2599            // Decode the remaining unknown envelopes.
2600            while next_offset < end_offset {
2601                _next_ordinal_to_read += 1;
2602                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2603                next_offset += envelope_size;
2604            }
2605
2606            Ok(())
2607        }
2608    }
2609
2610    impl BufferCollectionConstraints {
2611        #[inline(always)]
2612        fn max_ordinal_present(&self) -> u64 {
2613            if let Some(_) = self.image_format_constraints {
2614                return 8;
2615            }
2616            if let Some(_) = self.buffer_memory_constraints {
2617                return 7;
2618            }
2619            if let Some(_) = self.max_buffer_count {
2620                return 6;
2621            }
2622            if let Some(_) = self.min_buffer_count {
2623                return 5;
2624            }
2625            if let Some(_) = self.min_buffer_count_for_shared_slack {
2626                return 4;
2627            }
2628            if let Some(_) = self.min_buffer_count_for_dedicated_slack {
2629                return 3;
2630            }
2631            if let Some(_) = self.min_buffer_count_for_camping {
2632                return 2;
2633            }
2634            if let Some(_) = self.usage {
2635                return 1;
2636            }
2637            0
2638        }
2639    }
2640
2641    impl fidl::encoding::ValueTypeMarker for BufferCollectionConstraints {
2642        type Borrowed<'a> = &'a Self;
2643        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2644            value
2645        }
2646    }
2647
2648    unsafe impl fidl::encoding::TypeMarker for BufferCollectionConstraints {
2649        type Owned = Self;
2650
2651        #[inline(always)]
2652        fn inline_align(_context: fidl::encoding::Context) -> usize {
2653            8
2654        }
2655
2656        #[inline(always)]
2657        fn inline_size(_context: fidl::encoding::Context) -> usize {
2658            16
2659        }
2660    }
2661
2662    unsafe impl<D: fidl::encoding::ResourceDialect>
2663        fidl::encoding::Encode<BufferCollectionConstraints, D> for &BufferCollectionConstraints
2664    {
2665        unsafe fn encode(
2666            self,
2667            encoder: &mut fidl::encoding::Encoder<'_, D>,
2668            offset: usize,
2669            mut depth: fidl::encoding::Depth,
2670        ) -> fidl::Result<()> {
2671            encoder.debug_check_bounds::<BufferCollectionConstraints>(offset);
2672            // Vector header
2673            let max_ordinal: u64 = self.max_ordinal_present();
2674            encoder.write_num(max_ordinal, offset);
2675            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2676            // Calling encoder.out_of_line_offset(0) is not allowed.
2677            if max_ordinal == 0 {
2678                return Ok(());
2679            }
2680            depth.increment()?;
2681            let envelope_size = 8;
2682            let bytes_len = max_ordinal as usize * envelope_size;
2683            #[allow(unused_variables)]
2684            let offset = encoder.out_of_line_offset(bytes_len);
2685            let mut _prev_end_offset: usize = 0;
2686            if 1 > max_ordinal {
2687                return Ok(());
2688            }
2689
2690            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2691            // are envelope_size bytes.
2692            let cur_offset: usize = (1 - 1) * envelope_size;
2693
2694            // Zero reserved fields.
2695            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2696
2697            // Safety:
2698            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2699            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2700            //   envelope_size bytes, there is always sufficient room.
2701            fidl::encoding::encode_in_envelope_optional::<BufferUsage, D>(
2702                self.usage.as_ref().map(<BufferUsage as fidl::encoding::ValueTypeMarker>::borrow),
2703                encoder,
2704                offset + cur_offset,
2705                depth,
2706            )?;
2707
2708            _prev_end_offset = cur_offset + envelope_size;
2709            if 2 > max_ordinal {
2710                return Ok(());
2711            }
2712
2713            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2714            // are envelope_size bytes.
2715            let cur_offset: usize = (2 - 1) * envelope_size;
2716
2717            // Zero reserved fields.
2718            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2719
2720            // Safety:
2721            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2722            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2723            //   envelope_size bytes, there is always sufficient room.
2724            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2725                self.min_buffer_count_for_camping
2726                    .as_ref()
2727                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2728                encoder,
2729                offset + cur_offset,
2730                depth,
2731            )?;
2732
2733            _prev_end_offset = cur_offset + envelope_size;
2734            if 3 > max_ordinal {
2735                return Ok(());
2736            }
2737
2738            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2739            // are envelope_size bytes.
2740            let cur_offset: usize = (3 - 1) * envelope_size;
2741
2742            // Zero reserved fields.
2743            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2744
2745            // Safety:
2746            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2747            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2748            //   envelope_size bytes, there is always sufficient room.
2749            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2750                self.min_buffer_count_for_dedicated_slack
2751                    .as_ref()
2752                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2753                encoder,
2754                offset + cur_offset,
2755                depth,
2756            )?;
2757
2758            _prev_end_offset = cur_offset + envelope_size;
2759            if 4 > max_ordinal {
2760                return Ok(());
2761            }
2762
2763            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2764            // are envelope_size bytes.
2765            let cur_offset: usize = (4 - 1) * envelope_size;
2766
2767            // Zero reserved fields.
2768            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2769
2770            // Safety:
2771            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2772            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2773            //   envelope_size bytes, there is always sufficient room.
2774            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2775                self.min_buffer_count_for_shared_slack
2776                    .as_ref()
2777                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2778                encoder,
2779                offset + cur_offset,
2780                depth,
2781            )?;
2782
2783            _prev_end_offset = cur_offset + envelope_size;
2784            if 5 > max_ordinal {
2785                return Ok(());
2786            }
2787
2788            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2789            // are envelope_size bytes.
2790            let cur_offset: usize = (5 - 1) * envelope_size;
2791
2792            // Zero reserved fields.
2793            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2794
2795            // Safety:
2796            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2797            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2798            //   envelope_size bytes, there is always sufficient room.
2799            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2800                self.min_buffer_count
2801                    .as_ref()
2802                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2803                encoder,
2804                offset + cur_offset,
2805                depth,
2806            )?;
2807
2808            _prev_end_offset = cur_offset + envelope_size;
2809            if 6 > max_ordinal {
2810                return Ok(());
2811            }
2812
2813            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2814            // are envelope_size bytes.
2815            let cur_offset: usize = (6 - 1) * envelope_size;
2816
2817            // Zero reserved fields.
2818            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2819
2820            // Safety:
2821            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2822            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2823            //   envelope_size bytes, there is always sufficient room.
2824            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2825                self.max_buffer_count
2826                    .as_ref()
2827                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2828                encoder,
2829                offset + cur_offset,
2830                depth,
2831            )?;
2832
2833            _prev_end_offset = cur_offset + envelope_size;
2834            if 7 > max_ordinal {
2835                return Ok(());
2836            }
2837
2838            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2839            // are envelope_size bytes.
2840            let cur_offset: usize = (7 - 1) * envelope_size;
2841
2842            // Zero reserved fields.
2843            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2844
2845            // Safety:
2846            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2847            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2848            //   envelope_size bytes, there is always sufficient room.
2849            fidl::encoding::encode_in_envelope_optional::<BufferMemoryConstraints, D>(
2850                self.buffer_memory_constraints
2851                    .as_ref()
2852                    .map(<BufferMemoryConstraints as fidl::encoding::ValueTypeMarker>::borrow),
2853                encoder,
2854                offset + cur_offset,
2855                depth,
2856            )?;
2857
2858            _prev_end_offset = cur_offset + envelope_size;
2859            if 8 > max_ordinal {
2860                return Ok(());
2861            }
2862
2863            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2864            // are envelope_size bytes.
2865            let cur_offset: usize = (8 - 1) * envelope_size;
2866
2867            // Zero reserved fields.
2868            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2869
2870            // Safety:
2871            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2872            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2873            //   envelope_size bytes, there is always sufficient room.
2874            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<ImageFormatConstraints, 64>, D>(
2875            self.image_format_constraints.as_ref().map(<fidl::encoding::Vector<ImageFormatConstraints, 64> as fidl::encoding::ValueTypeMarker>::borrow),
2876            encoder, offset + cur_offset, depth
2877        )?;
2878
2879            _prev_end_offset = cur_offset + envelope_size;
2880
2881            Ok(())
2882        }
2883    }
2884
2885    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2886        for BufferCollectionConstraints
2887    {
2888        #[inline(always)]
2889        fn new_empty() -> Self {
2890            Self::default()
2891        }
2892
2893        unsafe fn decode(
2894            &mut self,
2895            decoder: &mut fidl::encoding::Decoder<'_, D>,
2896            offset: usize,
2897            mut depth: fidl::encoding::Depth,
2898        ) -> fidl::Result<()> {
2899            decoder.debug_check_bounds::<Self>(offset);
2900            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2901                None => return Err(fidl::Error::NotNullable),
2902                Some(len) => len,
2903            };
2904            // Calling decoder.out_of_line_offset(0) is not allowed.
2905            if len == 0 {
2906                return Ok(());
2907            };
2908            depth.increment()?;
2909            let envelope_size = 8;
2910            let bytes_len = len * envelope_size;
2911            let offset = decoder.out_of_line_offset(bytes_len)?;
2912            // Decode the envelope for each type.
2913            let mut _next_ordinal_to_read = 0;
2914            let mut next_offset = offset;
2915            let end_offset = offset + bytes_len;
2916            _next_ordinal_to_read += 1;
2917            if next_offset >= end_offset {
2918                return Ok(());
2919            }
2920
2921            // Decode unknown envelopes for gaps in ordinals.
2922            while _next_ordinal_to_read < 1 {
2923                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2924                _next_ordinal_to_read += 1;
2925                next_offset += envelope_size;
2926            }
2927
2928            let next_out_of_line = decoder.next_out_of_line();
2929            let handles_before = decoder.remaining_handles();
2930            if let Some((inlined, num_bytes, num_handles)) =
2931                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2932            {
2933                let member_inline_size =
2934                    <BufferUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2935                if inlined != (member_inline_size <= 4) {
2936                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2937                }
2938                let inner_offset;
2939                let mut inner_depth = depth.clone();
2940                if inlined {
2941                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2942                    inner_offset = next_offset;
2943                } else {
2944                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2945                    inner_depth.increment()?;
2946                }
2947                let val_ref = self.usage.get_or_insert_with(|| fidl::new_empty!(BufferUsage, D));
2948                fidl::decode!(BufferUsage, D, val_ref, decoder, inner_offset, inner_depth)?;
2949                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2950                {
2951                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2952                }
2953                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2954                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2955                }
2956            }
2957
2958            next_offset += envelope_size;
2959            _next_ordinal_to_read += 1;
2960            if next_offset >= end_offset {
2961                return Ok(());
2962            }
2963
2964            // Decode unknown envelopes for gaps in ordinals.
2965            while _next_ordinal_to_read < 2 {
2966                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2967                _next_ordinal_to_read += 1;
2968                next_offset += envelope_size;
2969            }
2970
2971            let next_out_of_line = decoder.next_out_of_line();
2972            let handles_before = decoder.remaining_handles();
2973            if let Some((inlined, num_bytes, num_handles)) =
2974                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2975            {
2976                let member_inline_size =
2977                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2978                if inlined != (member_inline_size <= 4) {
2979                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2980                }
2981                let inner_offset;
2982                let mut inner_depth = depth.clone();
2983                if inlined {
2984                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2985                    inner_offset = next_offset;
2986                } else {
2987                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2988                    inner_depth.increment()?;
2989                }
2990                let val_ref = self
2991                    .min_buffer_count_for_camping
2992                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
2993                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2994                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2995                {
2996                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2997                }
2998                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2999                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3000                }
3001            }
3002
3003            next_offset += envelope_size;
3004            _next_ordinal_to_read += 1;
3005            if next_offset >= end_offset {
3006                return Ok(());
3007            }
3008
3009            // Decode unknown envelopes for gaps in ordinals.
3010            while _next_ordinal_to_read < 3 {
3011                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3012                _next_ordinal_to_read += 1;
3013                next_offset += envelope_size;
3014            }
3015
3016            let next_out_of_line = decoder.next_out_of_line();
3017            let handles_before = decoder.remaining_handles();
3018            if let Some((inlined, num_bytes, num_handles)) =
3019                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3020            {
3021                let member_inline_size =
3022                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3023                if inlined != (member_inline_size <= 4) {
3024                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3025                }
3026                let inner_offset;
3027                let mut inner_depth = depth.clone();
3028                if inlined {
3029                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3030                    inner_offset = next_offset;
3031                } else {
3032                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3033                    inner_depth.increment()?;
3034                }
3035                let val_ref = self
3036                    .min_buffer_count_for_dedicated_slack
3037                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3038                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3039                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3040                {
3041                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3042                }
3043                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3044                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3045                }
3046            }
3047
3048            next_offset += envelope_size;
3049            _next_ordinal_to_read += 1;
3050            if next_offset >= end_offset {
3051                return Ok(());
3052            }
3053
3054            // Decode unknown envelopes for gaps in ordinals.
3055            while _next_ordinal_to_read < 4 {
3056                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3057                _next_ordinal_to_read += 1;
3058                next_offset += envelope_size;
3059            }
3060
3061            let next_out_of_line = decoder.next_out_of_line();
3062            let handles_before = decoder.remaining_handles();
3063            if let Some((inlined, num_bytes, num_handles)) =
3064                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3065            {
3066                let member_inline_size =
3067                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3068                if inlined != (member_inline_size <= 4) {
3069                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3070                }
3071                let inner_offset;
3072                let mut inner_depth = depth.clone();
3073                if inlined {
3074                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3075                    inner_offset = next_offset;
3076                } else {
3077                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3078                    inner_depth.increment()?;
3079                }
3080                let val_ref = self
3081                    .min_buffer_count_for_shared_slack
3082                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3083                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3084                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3085                {
3086                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3087                }
3088                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3089                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3090                }
3091            }
3092
3093            next_offset += envelope_size;
3094            _next_ordinal_to_read += 1;
3095            if next_offset >= end_offset {
3096                return Ok(());
3097            }
3098
3099            // Decode unknown envelopes for gaps in ordinals.
3100            while _next_ordinal_to_read < 5 {
3101                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3102                _next_ordinal_to_read += 1;
3103                next_offset += envelope_size;
3104            }
3105
3106            let next_out_of_line = decoder.next_out_of_line();
3107            let handles_before = decoder.remaining_handles();
3108            if let Some((inlined, num_bytes, num_handles)) =
3109                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3110            {
3111                let member_inline_size =
3112                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3113                if inlined != (member_inline_size <= 4) {
3114                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3115                }
3116                let inner_offset;
3117                let mut inner_depth = depth.clone();
3118                if inlined {
3119                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3120                    inner_offset = next_offset;
3121                } else {
3122                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3123                    inner_depth.increment()?;
3124                }
3125                let val_ref = self.min_buffer_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
3126                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3127                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3128                {
3129                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3130                }
3131                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3132                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3133                }
3134            }
3135
3136            next_offset += envelope_size;
3137            _next_ordinal_to_read += 1;
3138            if next_offset >= end_offset {
3139                return Ok(());
3140            }
3141
3142            // Decode unknown envelopes for gaps in ordinals.
3143            while _next_ordinal_to_read < 6 {
3144                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3145                _next_ordinal_to_read += 1;
3146                next_offset += envelope_size;
3147            }
3148
3149            let next_out_of_line = decoder.next_out_of_line();
3150            let handles_before = decoder.remaining_handles();
3151            if let Some((inlined, num_bytes, num_handles)) =
3152                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3153            {
3154                let member_inline_size =
3155                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3156                if inlined != (member_inline_size <= 4) {
3157                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3158                }
3159                let inner_offset;
3160                let mut inner_depth = depth.clone();
3161                if inlined {
3162                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3163                    inner_offset = next_offset;
3164                } else {
3165                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3166                    inner_depth.increment()?;
3167                }
3168                let val_ref = self.max_buffer_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
3169                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3170                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3171                {
3172                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3173                }
3174                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3175                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3176                }
3177            }
3178
3179            next_offset += envelope_size;
3180            _next_ordinal_to_read += 1;
3181            if next_offset >= end_offset {
3182                return Ok(());
3183            }
3184
3185            // Decode unknown envelopes for gaps in ordinals.
3186            while _next_ordinal_to_read < 7 {
3187                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3188                _next_ordinal_to_read += 1;
3189                next_offset += envelope_size;
3190            }
3191
3192            let next_out_of_line = decoder.next_out_of_line();
3193            let handles_before = decoder.remaining_handles();
3194            if let Some((inlined, num_bytes, num_handles)) =
3195                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3196            {
3197                let member_inline_size =
3198                    <BufferMemoryConstraints as fidl::encoding::TypeMarker>::inline_size(
3199                        decoder.context,
3200                    );
3201                if inlined != (member_inline_size <= 4) {
3202                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3203                }
3204                let inner_offset;
3205                let mut inner_depth = depth.clone();
3206                if inlined {
3207                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3208                    inner_offset = next_offset;
3209                } else {
3210                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3211                    inner_depth.increment()?;
3212                }
3213                let val_ref = self
3214                    .buffer_memory_constraints
3215                    .get_or_insert_with(|| fidl::new_empty!(BufferMemoryConstraints, D));
3216                fidl::decode!(
3217                    BufferMemoryConstraints,
3218                    D,
3219                    val_ref,
3220                    decoder,
3221                    inner_offset,
3222                    inner_depth
3223                )?;
3224                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3225                {
3226                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3227                }
3228                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3229                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3230                }
3231            }
3232
3233            next_offset += envelope_size;
3234            _next_ordinal_to_read += 1;
3235            if next_offset >= end_offset {
3236                return Ok(());
3237            }
3238
3239            // Decode unknown envelopes for gaps in ordinals.
3240            while _next_ordinal_to_read < 8 {
3241                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3242                _next_ordinal_to_read += 1;
3243                next_offset += envelope_size;
3244            }
3245
3246            let next_out_of_line = decoder.next_out_of_line();
3247            let handles_before = decoder.remaining_handles();
3248            if let Some((inlined, num_bytes, num_handles)) =
3249                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3250            {
3251                let member_inline_size = <fidl::encoding::Vector<ImageFormatConstraints, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3252                if inlined != (member_inline_size <= 4) {
3253                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3254                }
3255                let inner_offset;
3256                let mut inner_depth = depth.clone();
3257                if inlined {
3258                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3259                    inner_offset = next_offset;
3260                } else {
3261                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3262                    inner_depth.increment()?;
3263                }
3264                let val_ref = self.image_format_constraints.get_or_insert_with(
3265                    || fidl::new_empty!(fidl::encoding::Vector<ImageFormatConstraints, 64>, D),
3266                );
3267                fidl::decode!(fidl::encoding::Vector<ImageFormatConstraints, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3268                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3269                {
3270                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3271                }
3272                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3273                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3274                }
3275            }
3276
3277            next_offset += envelope_size;
3278
3279            // Decode the remaining unknown envelopes.
3280            while next_offset < end_offset {
3281                _next_ordinal_to_read += 1;
3282                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3283                next_offset += envelope_size;
3284            }
3285
3286            Ok(())
3287        }
3288    }
3289
3290    impl BufferCollectionTokenDuplicateSyncRequest {
3291        #[inline(always)]
3292        fn max_ordinal_present(&self) -> u64 {
3293            if let Some(_) = self.rights_attenuation_masks {
3294                return 1;
3295            }
3296            0
3297        }
3298    }
3299
3300    impl fidl::encoding::ValueTypeMarker for BufferCollectionTokenDuplicateSyncRequest {
3301        type Borrowed<'a> = &'a Self;
3302        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3303            value
3304        }
3305    }
3306
3307    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncRequest {
3308        type Owned = Self;
3309
3310        #[inline(always)]
3311        fn inline_align(_context: fidl::encoding::Context) -> usize {
3312            8
3313        }
3314
3315        #[inline(always)]
3316        fn inline_size(_context: fidl::encoding::Context) -> usize {
3317            16
3318        }
3319    }
3320
3321    unsafe impl<D: fidl::encoding::ResourceDialect>
3322        fidl::encoding::Encode<BufferCollectionTokenDuplicateSyncRequest, D>
3323        for &BufferCollectionTokenDuplicateSyncRequest
3324    {
3325        unsafe fn encode(
3326            self,
3327            encoder: &mut fidl::encoding::Encoder<'_, D>,
3328            offset: usize,
3329            mut depth: fidl::encoding::Depth,
3330        ) -> fidl::Result<()> {
3331            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncRequest>(offset);
3332            // Vector header
3333            let max_ordinal: u64 = self.max_ordinal_present();
3334            encoder.write_num(max_ordinal, offset);
3335            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3336            // Calling encoder.out_of_line_offset(0) is not allowed.
3337            if max_ordinal == 0 {
3338                return Ok(());
3339            }
3340            depth.increment()?;
3341            let envelope_size = 8;
3342            let bytes_len = max_ordinal as usize * envelope_size;
3343            #[allow(unused_variables)]
3344            let offset = encoder.out_of_line_offset(bytes_len);
3345            let mut _prev_end_offset: usize = 0;
3346            if 1 > max_ordinal {
3347                return Ok(());
3348            }
3349
3350            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3351            // are envelope_size bytes.
3352            let cur_offset: usize = (1 - 1) * envelope_size;
3353
3354            // Zero reserved fields.
3355            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3356
3357            // Safety:
3358            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3359            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3360            //   envelope_size bytes, there is always sufficient room.
3361            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::Rights, 64>, D>(
3362            self.rights_attenuation_masks.as_ref().map(<fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3363            encoder, offset + cur_offset, depth
3364        )?;
3365
3366            _prev_end_offset = cur_offset + envelope_size;
3367
3368            Ok(())
3369        }
3370    }
3371
3372    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3373        for BufferCollectionTokenDuplicateSyncRequest
3374    {
3375        #[inline(always)]
3376        fn new_empty() -> Self {
3377            Self::default()
3378        }
3379
3380        unsafe fn decode(
3381            &mut self,
3382            decoder: &mut fidl::encoding::Decoder<'_, D>,
3383            offset: usize,
3384            mut depth: fidl::encoding::Depth,
3385        ) -> fidl::Result<()> {
3386            decoder.debug_check_bounds::<Self>(offset);
3387            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3388                None => return Err(fidl::Error::NotNullable),
3389                Some(len) => len,
3390            };
3391            // Calling decoder.out_of_line_offset(0) is not allowed.
3392            if len == 0 {
3393                return Ok(());
3394            };
3395            depth.increment()?;
3396            let envelope_size = 8;
3397            let bytes_len = len * envelope_size;
3398            let offset = decoder.out_of_line_offset(bytes_len)?;
3399            // Decode the envelope for each type.
3400            let mut _next_ordinal_to_read = 0;
3401            let mut next_offset = offset;
3402            let end_offset = offset + bytes_len;
3403            _next_ordinal_to_read += 1;
3404            if next_offset >= end_offset {
3405                return Ok(());
3406            }
3407
3408            // Decode unknown envelopes for gaps in ordinals.
3409            while _next_ordinal_to_read < 1 {
3410                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3411                _next_ordinal_to_read += 1;
3412                next_offset += envelope_size;
3413            }
3414
3415            let next_out_of_line = decoder.next_out_of_line();
3416            let handles_before = decoder.remaining_handles();
3417            if let Some((inlined, num_bytes, num_handles)) =
3418                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3419            {
3420                let member_inline_size = <fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3421                if inlined != (member_inline_size <= 4) {
3422                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3423                }
3424                let inner_offset;
3425                let mut inner_depth = depth.clone();
3426                if inlined {
3427                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3428                    inner_offset = next_offset;
3429                } else {
3430                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3431                    inner_depth.increment()?;
3432                }
3433                let val_ref = self.rights_attenuation_masks.get_or_insert_with(
3434                    || fidl::new_empty!(fidl::encoding::Vector<fidl::Rights, 64>, D),
3435                );
3436                fidl::decode!(fidl::encoding::Vector<fidl::Rights, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3437                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3438                {
3439                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3440                }
3441                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3442                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3443                }
3444            }
3445
3446            next_offset += envelope_size;
3447
3448            // Decode the remaining unknown envelopes.
3449            while next_offset < end_offset {
3450                _next_ordinal_to_read += 1;
3451                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3452                next_offset += envelope_size;
3453            }
3454
3455            Ok(())
3456        }
3457    }
3458
3459    impl BufferCollectionTokenGroupCreateChildrenSyncRequest {
3460        #[inline(always)]
3461        fn max_ordinal_present(&self) -> u64 {
3462            if let Some(_) = self.rights_attenuation_masks {
3463                return 1;
3464            }
3465            0
3466        }
3467    }
3468
3469    impl fidl::encoding::ValueTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncRequest {
3470        type Borrowed<'a> = &'a Self;
3471        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3472            value
3473        }
3474    }
3475
3476    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncRequest {
3477        type Owned = Self;
3478
3479        #[inline(always)]
3480        fn inline_align(_context: fidl::encoding::Context) -> usize {
3481            8
3482        }
3483
3484        #[inline(always)]
3485        fn inline_size(_context: fidl::encoding::Context) -> usize {
3486            16
3487        }
3488    }
3489
3490    unsafe impl<D: fidl::encoding::ResourceDialect>
3491        fidl::encoding::Encode<BufferCollectionTokenGroupCreateChildrenSyncRequest, D>
3492        for &BufferCollectionTokenGroupCreateChildrenSyncRequest
3493    {
3494        unsafe fn encode(
3495            self,
3496            encoder: &mut fidl::encoding::Encoder<'_, D>,
3497            offset: usize,
3498            mut depth: fidl::encoding::Depth,
3499        ) -> fidl::Result<()> {
3500            encoder
3501                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(offset);
3502            // Vector header
3503            let max_ordinal: u64 = self.max_ordinal_present();
3504            encoder.write_num(max_ordinal, offset);
3505            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3506            // Calling encoder.out_of_line_offset(0) is not allowed.
3507            if max_ordinal == 0 {
3508                return Ok(());
3509            }
3510            depth.increment()?;
3511            let envelope_size = 8;
3512            let bytes_len = max_ordinal as usize * envelope_size;
3513            #[allow(unused_variables)]
3514            let offset = encoder.out_of_line_offset(bytes_len);
3515            let mut _prev_end_offset: usize = 0;
3516            if 1 > max_ordinal {
3517                return Ok(());
3518            }
3519
3520            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3521            // are envelope_size bytes.
3522            let cur_offset: usize = (1 - 1) * envelope_size;
3523
3524            // Zero reserved fields.
3525            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3526
3527            // Safety:
3528            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3529            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3530            //   envelope_size bytes, there is always sufficient room.
3531            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::Rights, 64>, D>(
3532            self.rights_attenuation_masks.as_ref().map(<fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3533            encoder, offset + cur_offset, depth
3534        )?;
3535
3536            _prev_end_offset = cur_offset + envelope_size;
3537
3538            Ok(())
3539        }
3540    }
3541
3542    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3543        for BufferCollectionTokenGroupCreateChildrenSyncRequest
3544    {
3545        #[inline(always)]
3546        fn new_empty() -> Self {
3547            Self::default()
3548        }
3549
3550        unsafe fn decode(
3551            &mut self,
3552            decoder: &mut fidl::encoding::Decoder<'_, D>,
3553            offset: usize,
3554            mut depth: fidl::encoding::Depth,
3555        ) -> fidl::Result<()> {
3556            decoder.debug_check_bounds::<Self>(offset);
3557            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3558                None => return Err(fidl::Error::NotNullable),
3559                Some(len) => len,
3560            };
3561            // Calling decoder.out_of_line_offset(0) is not allowed.
3562            if len == 0 {
3563                return Ok(());
3564            };
3565            depth.increment()?;
3566            let envelope_size = 8;
3567            let bytes_len = len * envelope_size;
3568            let offset = decoder.out_of_line_offset(bytes_len)?;
3569            // Decode the envelope for each type.
3570            let mut _next_ordinal_to_read = 0;
3571            let mut next_offset = offset;
3572            let end_offset = offset + bytes_len;
3573            _next_ordinal_to_read += 1;
3574            if next_offset >= end_offset {
3575                return Ok(());
3576            }
3577
3578            // Decode unknown envelopes for gaps in ordinals.
3579            while _next_ordinal_to_read < 1 {
3580                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3581                _next_ordinal_to_read += 1;
3582                next_offset += envelope_size;
3583            }
3584
3585            let next_out_of_line = decoder.next_out_of_line();
3586            let handles_before = decoder.remaining_handles();
3587            if let Some((inlined, num_bytes, num_handles)) =
3588                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3589            {
3590                let member_inline_size = <fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3591                if inlined != (member_inline_size <= 4) {
3592                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3593                }
3594                let inner_offset;
3595                let mut inner_depth = depth.clone();
3596                if inlined {
3597                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3598                    inner_offset = next_offset;
3599                } else {
3600                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3601                    inner_depth.increment()?;
3602                }
3603                let val_ref = self.rights_attenuation_masks.get_or_insert_with(
3604                    || fidl::new_empty!(fidl::encoding::Vector<fidl::Rights, 64>, D),
3605                );
3606                fidl::decode!(fidl::encoding::Vector<fidl::Rights, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3607                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3608                {
3609                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3610                }
3611                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3612                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3613                }
3614            }
3615
3616            next_offset += envelope_size;
3617
3618            // Decode the remaining unknown envelopes.
3619            while next_offset < end_offset {
3620                _next_ordinal_to_read += 1;
3621                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3622                next_offset += envelope_size;
3623            }
3624
3625            Ok(())
3626        }
3627    }
3628
3629    impl BufferMemoryConstraints {
3630        #[inline(always)]
3631        fn max_ordinal_present(&self) -> u64 {
3632            if let Some(_) = self.permitted_heaps {
3633                return 8;
3634            }
3635            if let Some(_) = self.inaccessible_domain_supported {
3636                return 7;
3637            }
3638            if let Some(_) = self.ram_domain_supported {
3639                return 6;
3640            }
3641            if let Some(_) = self.cpu_domain_supported {
3642                return 5;
3643            }
3644            if let Some(_) = self.secure_required {
3645                return 4;
3646            }
3647            if let Some(_) = self.physically_contiguous_required {
3648                return 3;
3649            }
3650            if let Some(_) = self.max_size_bytes {
3651                return 2;
3652            }
3653            if let Some(_) = self.min_size_bytes {
3654                return 1;
3655            }
3656            0
3657        }
3658    }
3659
3660    impl fidl::encoding::ValueTypeMarker for BufferMemoryConstraints {
3661        type Borrowed<'a> = &'a Self;
3662        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3663            value
3664        }
3665    }
3666
3667    unsafe impl fidl::encoding::TypeMarker for BufferMemoryConstraints {
3668        type Owned = Self;
3669
3670        #[inline(always)]
3671        fn inline_align(_context: fidl::encoding::Context) -> usize {
3672            8
3673        }
3674
3675        #[inline(always)]
3676        fn inline_size(_context: fidl::encoding::Context) -> usize {
3677            16
3678        }
3679    }
3680
3681    unsafe impl<D: fidl::encoding::ResourceDialect>
3682        fidl::encoding::Encode<BufferMemoryConstraints, D> for &BufferMemoryConstraints
3683    {
3684        unsafe fn encode(
3685            self,
3686            encoder: &mut fidl::encoding::Encoder<'_, D>,
3687            offset: usize,
3688            mut depth: fidl::encoding::Depth,
3689        ) -> fidl::Result<()> {
3690            encoder.debug_check_bounds::<BufferMemoryConstraints>(offset);
3691            // Vector header
3692            let max_ordinal: u64 = self.max_ordinal_present();
3693            encoder.write_num(max_ordinal, offset);
3694            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3695            // Calling encoder.out_of_line_offset(0) is not allowed.
3696            if max_ordinal == 0 {
3697                return Ok(());
3698            }
3699            depth.increment()?;
3700            let envelope_size = 8;
3701            let bytes_len = max_ordinal as usize * envelope_size;
3702            #[allow(unused_variables)]
3703            let offset = encoder.out_of_line_offset(bytes_len);
3704            let mut _prev_end_offset: usize = 0;
3705            if 1 > max_ordinal {
3706                return Ok(());
3707            }
3708
3709            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3710            // are envelope_size bytes.
3711            let cur_offset: usize = (1 - 1) * envelope_size;
3712
3713            // Zero reserved fields.
3714            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3715
3716            // Safety:
3717            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3718            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3719            //   envelope_size bytes, there is always sufficient room.
3720            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3721                self.min_size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3722                encoder,
3723                offset + cur_offset,
3724                depth,
3725            )?;
3726
3727            _prev_end_offset = cur_offset + envelope_size;
3728            if 2 > max_ordinal {
3729                return Ok(());
3730            }
3731
3732            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3733            // are envelope_size bytes.
3734            let cur_offset: usize = (2 - 1) * envelope_size;
3735
3736            // Zero reserved fields.
3737            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3738
3739            // Safety:
3740            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3741            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3742            //   envelope_size bytes, there is always sufficient room.
3743            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3744                self.max_size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3745                encoder,
3746                offset + cur_offset,
3747                depth,
3748            )?;
3749
3750            _prev_end_offset = cur_offset + envelope_size;
3751            if 3 > max_ordinal {
3752                return Ok(());
3753            }
3754
3755            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3756            // are envelope_size bytes.
3757            let cur_offset: usize = (3 - 1) * envelope_size;
3758
3759            // Zero reserved fields.
3760            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3761
3762            // Safety:
3763            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3764            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3765            //   envelope_size bytes, there is always sufficient room.
3766            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3767                self.physically_contiguous_required
3768                    .as_ref()
3769                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3770                encoder,
3771                offset + cur_offset,
3772                depth,
3773            )?;
3774
3775            _prev_end_offset = cur_offset + envelope_size;
3776            if 4 > max_ordinal {
3777                return Ok(());
3778            }
3779
3780            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3781            // are envelope_size bytes.
3782            let cur_offset: usize = (4 - 1) * envelope_size;
3783
3784            // Zero reserved fields.
3785            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3786
3787            // Safety:
3788            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3789            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3790            //   envelope_size bytes, there is always sufficient room.
3791            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3792                self.secure_required
3793                    .as_ref()
3794                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3795                encoder,
3796                offset + cur_offset,
3797                depth,
3798            )?;
3799
3800            _prev_end_offset = cur_offset + envelope_size;
3801            if 5 > max_ordinal {
3802                return Ok(());
3803            }
3804
3805            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3806            // are envelope_size bytes.
3807            let cur_offset: usize = (5 - 1) * envelope_size;
3808
3809            // Zero reserved fields.
3810            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3811
3812            // Safety:
3813            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3814            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3815            //   envelope_size bytes, there is always sufficient room.
3816            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3817                self.cpu_domain_supported
3818                    .as_ref()
3819                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3820                encoder,
3821                offset + cur_offset,
3822                depth,
3823            )?;
3824
3825            _prev_end_offset = cur_offset + envelope_size;
3826            if 6 > max_ordinal {
3827                return Ok(());
3828            }
3829
3830            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3831            // are envelope_size bytes.
3832            let cur_offset: usize = (6 - 1) * envelope_size;
3833
3834            // Zero reserved fields.
3835            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3836
3837            // Safety:
3838            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3839            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3840            //   envelope_size bytes, there is always sufficient room.
3841            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3842                self.ram_domain_supported
3843                    .as_ref()
3844                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3845                encoder,
3846                offset + cur_offset,
3847                depth,
3848            )?;
3849
3850            _prev_end_offset = cur_offset + envelope_size;
3851            if 7 > max_ordinal {
3852                return Ok(());
3853            }
3854
3855            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3856            // are envelope_size bytes.
3857            let cur_offset: usize = (7 - 1) * envelope_size;
3858
3859            // Zero reserved fields.
3860            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3861
3862            // Safety:
3863            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3864            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3865            //   envelope_size bytes, there is always sufficient room.
3866            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3867                self.inaccessible_domain_supported
3868                    .as_ref()
3869                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3870                encoder,
3871                offset + cur_offset,
3872                depth,
3873            )?;
3874
3875            _prev_end_offset = cur_offset + envelope_size;
3876            if 8 > max_ordinal {
3877                return Ok(());
3878            }
3879
3880            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3881            // are envelope_size bytes.
3882            let cur_offset: usize = (8 - 1) * envelope_size;
3883
3884            // Zero reserved fields.
3885            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3886
3887            // Safety:
3888            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3889            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3890            //   envelope_size bytes, there is always sufficient room.
3891            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Heap, 64>, D>(
3892                self.permitted_heaps.as_ref().map(
3893                    <fidl::encoding::Vector<Heap, 64> as fidl::encoding::ValueTypeMarker>::borrow,
3894                ),
3895                encoder,
3896                offset + cur_offset,
3897                depth,
3898            )?;
3899
3900            _prev_end_offset = cur_offset + envelope_size;
3901
3902            Ok(())
3903        }
3904    }
3905
3906    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3907        for BufferMemoryConstraints
3908    {
3909        #[inline(always)]
3910        fn new_empty() -> Self {
3911            Self::default()
3912        }
3913
3914        unsafe fn decode(
3915            &mut self,
3916            decoder: &mut fidl::encoding::Decoder<'_, D>,
3917            offset: usize,
3918            mut depth: fidl::encoding::Depth,
3919        ) -> fidl::Result<()> {
3920            decoder.debug_check_bounds::<Self>(offset);
3921            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3922                None => return Err(fidl::Error::NotNullable),
3923                Some(len) => len,
3924            };
3925            // Calling decoder.out_of_line_offset(0) is not allowed.
3926            if len == 0 {
3927                return Ok(());
3928            };
3929            depth.increment()?;
3930            let envelope_size = 8;
3931            let bytes_len = len * envelope_size;
3932            let offset = decoder.out_of_line_offset(bytes_len)?;
3933            // Decode the envelope for each type.
3934            let mut _next_ordinal_to_read = 0;
3935            let mut next_offset = offset;
3936            let end_offset = offset + bytes_len;
3937            _next_ordinal_to_read += 1;
3938            if next_offset >= end_offset {
3939                return Ok(());
3940            }
3941
3942            // Decode unknown envelopes for gaps in ordinals.
3943            while _next_ordinal_to_read < 1 {
3944                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3945                _next_ordinal_to_read += 1;
3946                next_offset += envelope_size;
3947            }
3948
3949            let next_out_of_line = decoder.next_out_of_line();
3950            let handles_before = decoder.remaining_handles();
3951            if let Some((inlined, num_bytes, num_handles)) =
3952                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3953            {
3954                let member_inline_size =
3955                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3956                if inlined != (member_inline_size <= 4) {
3957                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3958                }
3959                let inner_offset;
3960                let mut inner_depth = depth.clone();
3961                if inlined {
3962                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3963                    inner_offset = next_offset;
3964                } else {
3965                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3966                    inner_depth.increment()?;
3967                }
3968                let val_ref = self.min_size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
3969                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
3970                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3971                {
3972                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3973                }
3974                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3975                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3976                }
3977            }
3978
3979            next_offset += envelope_size;
3980            _next_ordinal_to_read += 1;
3981            if next_offset >= end_offset {
3982                return Ok(());
3983            }
3984
3985            // Decode unknown envelopes for gaps in ordinals.
3986            while _next_ordinal_to_read < 2 {
3987                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3988                _next_ordinal_to_read += 1;
3989                next_offset += envelope_size;
3990            }
3991
3992            let next_out_of_line = decoder.next_out_of_line();
3993            let handles_before = decoder.remaining_handles();
3994            if let Some((inlined, num_bytes, num_handles)) =
3995                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3996            {
3997                let member_inline_size =
3998                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3999                if inlined != (member_inline_size <= 4) {
4000                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4001                }
4002                let inner_offset;
4003                let mut inner_depth = depth.clone();
4004                if inlined {
4005                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4006                    inner_offset = next_offset;
4007                } else {
4008                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4009                    inner_depth.increment()?;
4010                }
4011                let val_ref = self.max_size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4012                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4013                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4014                {
4015                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4016                }
4017                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4018                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4019                }
4020            }
4021
4022            next_offset += envelope_size;
4023            _next_ordinal_to_read += 1;
4024            if next_offset >= end_offset {
4025                return Ok(());
4026            }
4027
4028            // Decode unknown envelopes for gaps in ordinals.
4029            while _next_ordinal_to_read < 3 {
4030                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4031                _next_ordinal_to_read += 1;
4032                next_offset += envelope_size;
4033            }
4034
4035            let next_out_of_line = decoder.next_out_of_line();
4036            let handles_before = decoder.remaining_handles();
4037            if let Some((inlined, num_bytes, num_handles)) =
4038                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4039            {
4040                let member_inline_size =
4041                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4042                if inlined != (member_inline_size <= 4) {
4043                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4044                }
4045                let inner_offset;
4046                let mut inner_depth = depth.clone();
4047                if inlined {
4048                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4049                    inner_offset = next_offset;
4050                } else {
4051                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4052                    inner_depth.increment()?;
4053                }
4054                let val_ref = self
4055                    .physically_contiguous_required
4056                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
4057                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4058                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4059                {
4060                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4061                }
4062                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4063                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4064                }
4065            }
4066
4067            next_offset += envelope_size;
4068            _next_ordinal_to_read += 1;
4069            if next_offset >= end_offset {
4070                return Ok(());
4071            }
4072
4073            // Decode unknown envelopes for gaps in ordinals.
4074            while _next_ordinal_to_read < 4 {
4075                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4076                _next_ordinal_to_read += 1;
4077                next_offset += envelope_size;
4078            }
4079
4080            let next_out_of_line = decoder.next_out_of_line();
4081            let handles_before = decoder.remaining_handles();
4082            if let Some((inlined, num_bytes, num_handles)) =
4083                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4084            {
4085                let member_inline_size =
4086                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4087                if inlined != (member_inline_size <= 4) {
4088                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4089                }
4090                let inner_offset;
4091                let mut inner_depth = depth.clone();
4092                if inlined {
4093                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4094                    inner_offset = next_offset;
4095                } else {
4096                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4097                    inner_depth.increment()?;
4098                }
4099                let val_ref = self.secure_required.get_or_insert_with(|| fidl::new_empty!(bool, D));
4100                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4101                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4102                {
4103                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4104                }
4105                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4106                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4107                }
4108            }
4109
4110            next_offset += envelope_size;
4111            _next_ordinal_to_read += 1;
4112            if next_offset >= end_offset {
4113                return Ok(());
4114            }
4115
4116            // Decode unknown envelopes for gaps in ordinals.
4117            while _next_ordinal_to_read < 5 {
4118                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4119                _next_ordinal_to_read += 1;
4120                next_offset += envelope_size;
4121            }
4122
4123            let next_out_of_line = decoder.next_out_of_line();
4124            let handles_before = decoder.remaining_handles();
4125            if let Some((inlined, num_bytes, num_handles)) =
4126                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4127            {
4128                let member_inline_size =
4129                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4130                if inlined != (member_inline_size <= 4) {
4131                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4132                }
4133                let inner_offset;
4134                let mut inner_depth = depth.clone();
4135                if inlined {
4136                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4137                    inner_offset = next_offset;
4138                } else {
4139                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4140                    inner_depth.increment()?;
4141                }
4142                let val_ref =
4143                    self.cpu_domain_supported.get_or_insert_with(|| fidl::new_empty!(bool, D));
4144                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4145                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4146                {
4147                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4148                }
4149                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4150                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4151                }
4152            }
4153
4154            next_offset += envelope_size;
4155            _next_ordinal_to_read += 1;
4156            if next_offset >= end_offset {
4157                return Ok(());
4158            }
4159
4160            // Decode unknown envelopes for gaps in ordinals.
4161            while _next_ordinal_to_read < 6 {
4162                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4163                _next_ordinal_to_read += 1;
4164                next_offset += envelope_size;
4165            }
4166
4167            let next_out_of_line = decoder.next_out_of_line();
4168            let handles_before = decoder.remaining_handles();
4169            if let Some((inlined, num_bytes, num_handles)) =
4170                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4171            {
4172                let member_inline_size =
4173                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4174                if inlined != (member_inline_size <= 4) {
4175                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4176                }
4177                let inner_offset;
4178                let mut inner_depth = depth.clone();
4179                if inlined {
4180                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4181                    inner_offset = next_offset;
4182                } else {
4183                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4184                    inner_depth.increment()?;
4185                }
4186                let val_ref =
4187                    self.ram_domain_supported.get_or_insert_with(|| fidl::new_empty!(bool, D));
4188                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4189                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4190                {
4191                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4192                }
4193                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4194                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4195                }
4196            }
4197
4198            next_offset += envelope_size;
4199            _next_ordinal_to_read += 1;
4200            if next_offset >= end_offset {
4201                return Ok(());
4202            }
4203
4204            // Decode unknown envelopes for gaps in ordinals.
4205            while _next_ordinal_to_read < 7 {
4206                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4207                _next_ordinal_to_read += 1;
4208                next_offset += envelope_size;
4209            }
4210
4211            let next_out_of_line = decoder.next_out_of_line();
4212            let handles_before = decoder.remaining_handles();
4213            if let Some((inlined, num_bytes, num_handles)) =
4214                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4215            {
4216                let member_inline_size =
4217                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4218                if inlined != (member_inline_size <= 4) {
4219                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4220                }
4221                let inner_offset;
4222                let mut inner_depth = depth.clone();
4223                if inlined {
4224                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4225                    inner_offset = next_offset;
4226                } else {
4227                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4228                    inner_depth.increment()?;
4229                }
4230                let val_ref = self
4231                    .inaccessible_domain_supported
4232                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
4233                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4234                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4235                {
4236                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4237                }
4238                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4239                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4240                }
4241            }
4242
4243            next_offset += envelope_size;
4244            _next_ordinal_to_read += 1;
4245            if next_offset >= end_offset {
4246                return Ok(());
4247            }
4248
4249            // Decode unknown envelopes for gaps in ordinals.
4250            while _next_ordinal_to_read < 8 {
4251                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4252                _next_ordinal_to_read += 1;
4253                next_offset += envelope_size;
4254            }
4255
4256            let next_out_of_line = decoder.next_out_of_line();
4257            let handles_before = decoder.remaining_handles();
4258            if let Some((inlined, num_bytes, num_handles)) =
4259                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4260            {
4261                let member_inline_size =
4262                    <fidl::encoding::Vector<Heap, 64> as fidl::encoding::TypeMarker>::inline_size(
4263                        decoder.context,
4264                    );
4265                if inlined != (member_inline_size <= 4) {
4266                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4267                }
4268                let inner_offset;
4269                let mut inner_depth = depth.clone();
4270                if inlined {
4271                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4272                    inner_offset = next_offset;
4273                } else {
4274                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4275                    inner_depth.increment()?;
4276                }
4277                let val_ref = self
4278                    .permitted_heaps
4279                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Heap, 64>, D));
4280                fidl::decode!(fidl::encoding::Vector<Heap, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
4281                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4282                {
4283                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4284                }
4285                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4286                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4287                }
4288            }
4289
4290            next_offset += envelope_size;
4291
4292            // Decode the remaining unknown envelopes.
4293            while next_offset < end_offset {
4294                _next_ordinal_to_read += 1;
4295                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4296                next_offset += envelope_size;
4297            }
4298
4299            Ok(())
4300        }
4301    }
4302
4303    impl BufferMemorySettings {
4304        #[inline(always)]
4305        fn max_ordinal_present(&self) -> u64 {
4306            if let Some(_) = self.heap {
4307                return 5;
4308            }
4309            if let Some(_) = self.coherency_domain {
4310                return 4;
4311            }
4312            if let Some(_) = self.is_secure {
4313                return 3;
4314            }
4315            if let Some(_) = self.is_physically_contiguous {
4316                return 2;
4317            }
4318            if let Some(_) = self.size_bytes {
4319                return 1;
4320            }
4321            0
4322        }
4323    }
4324
4325    impl fidl::encoding::ValueTypeMarker for BufferMemorySettings {
4326        type Borrowed<'a> = &'a Self;
4327        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4328            value
4329        }
4330    }
4331
4332    unsafe impl fidl::encoding::TypeMarker for BufferMemorySettings {
4333        type Owned = Self;
4334
4335        #[inline(always)]
4336        fn inline_align(_context: fidl::encoding::Context) -> usize {
4337            8
4338        }
4339
4340        #[inline(always)]
4341        fn inline_size(_context: fidl::encoding::Context) -> usize {
4342            16
4343        }
4344    }
4345
4346    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BufferMemorySettings, D>
4347        for &BufferMemorySettings
4348    {
4349        unsafe fn encode(
4350            self,
4351            encoder: &mut fidl::encoding::Encoder<'_, D>,
4352            offset: usize,
4353            mut depth: fidl::encoding::Depth,
4354        ) -> fidl::Result<()> {
4355            encoder.debug_check_bounds::<BufferMemorySettings>(offset);
4356            // Vector header
4357            let max_ordinal: u64 = self.max_ordinal_present();
4358            encoder.write_num(max_ordinal, offset);
4359            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4360            // Calling encoder.out_of_line_offset(0) is not allowed.
4361            if max_ordinal == 0 {
4362                return Ok(());
4363            }
4364            depth.increment()?;
4365            let envelope_size = 8;
4366            let bytes_len = max_ordinal as usize * envelope_size;
4367            #[allow(unused_variables)]
4368            let offset = encoder.out_of_line_offset(bytes_len);
4369            let mut _prev_end_offset: usize = 0;
4370            if 1 > max_ordinal {
4371                return Ok(());
4372            }
4373
4374            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4375            // are envelope_size bytes.
4376            let cur_offset: usize = (1 - 1) * envelope_size;
4377
4378            // Zero reserved fields.
4379            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4380
4381            // Safety:
4382            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4383            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4384            //   envelope_size bytes, there is always sufficient room.
4385            fidl::encoding::encode_in_envelope_optional::<u64, D>(
4386                self.size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4387                encoder,
4388                offset + cur_offset,
4389                depth,
4390            )?;
4391
4392            _prev_end_offset = cur_offset + envelope_size;
4393            if 2 > max_ordinal {
4394                return Ok(());
4395            }
4396
4397            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4398            // are envelope_size bytes.
4399            let cur_offset: usize = (2 - 1) * envelope_size;
4400
4401            // Zero reserved fields.
4402            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4403
4404            // Safety:
4405            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4406            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4407            //   envelope_size bytes, there is always sufficient room.
4408            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4409                self.is_physically_contiguous
4410                    .as_ref()
4411                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4412                encoder,
4413                offset + cur_offset,
4414                depth,
4415            )?;
4416
4417            _prev_end_offset = cur_offset + envelope_size;
4418            if 3 > max_ordinal {
4419                return Ok(());
4420            }
4421
4422            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4423            // are envelope_size bytes.
4424            let cur_offset: usize = (3 - 1) * envelope_size;
4425
4426            // Zero reserved fields.
4427            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4428
4429            // Safety:
4430            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4431            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4432            //   envelope_size bytes, there is always sufficient room.
4433            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4434                self.is_secure.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4435                encoder,
4436                offset + cur_offset,
4437                depth,
4438            )?;
4439
4440            _prev_end_offset = cur_offset + envelope_size;
4441            if 4 > max_ordinal {
4442                return Ok(());
4443            }
4444
4445            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4446            // are envelope_size bytes.
4447            let cur_offset: usize = (4 - 1) * envelope_size;
4448
4449            // Zero reserved fields.
4450            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4451
4452            // Safety:
4453            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4454            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4455            //   envelope_size bytes, there is always sufficient room.
4456            fidl::encoding::encode_in_envelope_optional::<CoherencyDomain, D>(
4457                self.coherency_domain
4458                    .as_ref()
4459                    .map(<CoherencyDomain as fidl::encoding::ValueTypeMarker>::borrow),
4460                encoder,
4461                offset + cur_offset,
4462                depth,
4463            )?;
4464
4465            _prev_end_offset = cur_offset + envelope_size;
4466            if 5 > max_ordinal {
4467                return Ok(());
4468            }
4469
4470            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4471            // are envelope_size bytes.
4472            let cur_offset: usize = (5 - 1) * envelope_size;
4473
4474            // Zero reserved fields.
4475            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4476
4477            // Safety:
4478            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4479            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4480            //   envelope_size bytes, there is always sufficient room.
4481            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
4482                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
4483                encoder,
4484                offset + cur_offset,
4485                depth,
4486            )?;
4487
4488            _prev_end_offset = cur_offset + envelope_size;
4489
4490            Ok(())
4491        }
4492    }
4493
4494    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferMemorySettings {
4495        #[inline(always)]
4496        fn new_empty() -> Self {
4497            Self::default()
4498        }
4499
4500        unsafe fn decode(
4501            &mut self,
4502            decoder: &mut fidl::encoding::Decoder<'_, D>,
4503            offset: usize,
4504            mut depth: fidl::encoding::Depth,
4505        ) -> fidl::Result<()> {
4506            decoder.debug_check_bounds::<Self>(offset);
4507            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4508                None => return Err(fidl::Error::NotNullable),
4509                Some(len) => len,
4510            };
4511            // Calling decoder.out_of_line_offset(0) is not allowed.
4512            if len == 0 {
4513                return Ok(());
4514            };
4515            depth.increment()?;
4516            let envelope_size = 8;
4517            let bytes_len = len * envelope_size;
4518            let offset = decoder.out_of_line_offset(bytes_len)?;
4519            // Decode the envelope for each type.
4520            let mut _next_ordinal_to_read = 0;
4521            let mut next_offset = offset;
4522            let end_offset = offset + bytes_len;
4523            _next_ordinal_to_read += 1;
4524            if next_offset >= end_offset {
4525                return Ok(());
4526            }
4527
4528            // Decode unknown envelopes for gaps in ordinals.
4529            while _next_ordinal_to_read < 1 {
4530                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4531                _next_ordinal_to_read += 1;
4532                next_offset += envelope_size;
4533            }
4534
4535            let next_out_of_line = decoder.next_out_of_line();
4536            let handles_before = decoder.remaining_handles();
4537            if let Some((inlined, num_bytes, num_handles)) =
4538                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4539            {
4540                let member_inline_size =
4541                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4542                if inlined != (member_inline_size <= 4) {
4543                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4544                }
4545                let inner_offset;
4546                let mut inner_depth = depth.clone();
4547                if inlined {
4548                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4549                    inner_offset = next_offset;
4550                } else {
4551                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4552                    inner_depth.increment()?;
4553                }
4554                let val_ref = self.size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4555                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4556                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4557                {
4558                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4559                }
4560                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4561                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4562                }
4563            }
4564
4565            next_offset += envelope_size;
4566            _next_ordinal_to_read += 1;
4567            if next_offset >= end_offset {
4568                return Ok(());
4569            }
4570
4571            // Decode unknown envelopes for gaps in ordinals.
4572            while _next_ordinal_to_read < 2 {
4573                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4574                _next_ordinal_to_read += 1;
4575                next_offset += envelope_size;
4576            }
4577
4578            let next_out_of_line = decoder.next_out_of_line();
4579            let handles_before = decoder.remaining_handles();
4580            if let Some((inlined, num_bytes, num_handles)) =
4581                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4582            {
4583                let member_inline_size =
4584                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4585                if inlined != (member_inline_size <= 4) {
4586                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4587                }
4588                let inner_offset;
4589                let mut inner_depth = depth.clone();
4590                if inlined {
4591                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4592                    inner_offset = next_offset;
4593                } else {
4594                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4595                    inner_depth.increment()?;
4596                }
4597                let val_ref =
4598                    self.is_physically_contiguous.get_or_insert_with(|| fidl::new_empty!(bool, D));
4599                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4600                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4601                {
4602                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4603                }
4604                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4605                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4606                }
4607            }
4608
4609            next_offset += envelope_size;
4610            _next_ordinal_to_read += 1;
4611            if next_offset >= end_offset {
4612                return Ok(());
4613            }
4614
4615            // Decode unknown envelopes for gaps in ordinals.
4616            while _next_ordinal_to_read < 3 {
4617                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4618                _next_ordinal_to_read += 1;
4619                next_offset += envelope_size;
4620            }
4621
4622            let next_out_of_line = decoder.next_out_of_line();
4623            let handles_before = decoder.remaining_handles();
4624            if let Some((inlined, num_bytes, num_handles)) =
4625                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4626            {
4627                let member_inline_size =
4628                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4629                if inlined != (member_inline_size <= 4) {
4630                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4631                }
4632                let inner_offset;
4633                let mut inner_depth = depth.clone();
4634                if inlined {
4635                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4636                    inner_offset = next_offset;
4637                } else {
4638                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4639                    inner_depth.increment()?;
4640                }
4641                let val_ref = self.is_secure.get_or_insert_with(|| fidl::new_empty!(bool, D));
4642                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4643                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4644                {
4645                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4646                }
4647                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4648                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4649                }
4650            }
4651
4652            next_offset += envelope_size;
4653            _next_ordinal_to_read += 1;
4654            if next_offset >= end_offset {
4655                return Ok(());
4656            }
4657
4658            // Decode unknown envelopes for gaps in ordinals.
4659            while _next_ordinal_to_read < 4 {
4660                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4661                _next_ordinal_to_read += 1;
4662                next_offset += envelope_size;
4663            }
4664
4665            let next_out_of_line = decoder.next_out_of_line();
4666            let handles_before = decoder.remaining_handles();
4667            if let Some((inlined, num_bytes, num_handles)) =
4668                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4669            {
4670                let member_inline_size =
4671                    <CoherencyDomain as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4672                if inlined != (member_inline_size <= 4) {
4673                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4674                }
4675                let inner_offset;
4676                let mut inner_depth = depth.clone();
4677                if inlined {
4678                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4679                    inner_offset = next_offset;
4680                } else {
4681                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4682                    inner_depth.increment()?;
4683                }
4684                let val_ref = self
4685                    .coherency_domain
4686                    .get_or_insert_with(|| fidl::new_empty!(CoherencyDomain, D));
4687                fidl::decode!(CoherencyDomain, D, val_ref, decoder, inner_offset, inner_depth)?;
4688                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4689                {
4690                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4691                }
4692                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4693                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4694                }
4695            }
4696
4697            next_offset += envelope_size;
4698            _next_ordinal_to_read += 1;
4699            if next_offset >= end_offset {
4700                return Ok(());
4701            }
4702
4703            // Decode unknown envelopes for gaps in ordinals.
4704            while _next_ordinal_to_read < 5 {
4705                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4706                _next_ordinal_to_read += 1;
4707                next_offset += envelope_size;
4708            }
4709
4710            let next_out_of_line = decoder.next_out_of_line();
4711            let handles_before = decoder.remaining_handles();
4712            if let Some((inlined, num_bytes, num_handles)) =
4713                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4714            {
4715                let member_inline_size =
4716                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4717                if inlined != (member_inline_size <= 4) {
4718                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4719                }
4720                let inner_offset;
4721                let mut inner_depth = depth.clone();
4722                if inlined {
4723                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4724                    inner_offset = next_offset;
4725                } else {
4726                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4727                    inner_depth.increment()?;
4728                }
4729                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
4730                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
4731                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4732                {
4733                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4734                }
4735                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4736                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4737                }
4738            }
4739
4740            next_offset += envelope_size;
4741
4742            // Decode the remaining unknown envelopes.
4743            while next_offset < end_offset {
4744                _next_ordinal_to_read += 1;
4745                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4746                next_offset += envelope_size;
4747            }
4748
4749            Ok(())
4750        }
4751    }
4752
4753    impl BufferUsage {
4754        #[inline(always)]
4755        fn max_ordinal_present(&self) -> u64 {
4756            if let Some(_) = self.video {
4757                return 5;
4758            }
4759            if let Some(_) = self.display {
4760                return 4;
4761            }
4762            if let Some(_) = self.vulkan {
4763                return 3;
4764            }
4765            if let Some(_) = self.cpu {
4766                return 2;
4767            }
4768            if let Some(_) = self.none {
4769                return 1;
4770            }
4771            0
4772        }
4773    }
4774
4775    impl fidl::encoding::ValueTypeMarker for BufferUsage {
4776        type Borrowed<'a> = &'a Self;
4777        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4778            value
4779        }
4780    }
4781
4782    unsafe impl fidl::encoding::TypeMarker for BufferUsage {
4783        type Owned = Self;
4784
4785        #[inline(always)]
4786        fn inline_align(_context: fidl::encoding::Context) -> usize {
4787            8
4788        }
4789
4790        #[inline(always)]
4791        fn inline_size(_context: fidl::encoding::Context) -> usize {
4792            16
4793        }
4794    }
4795
4796    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BufferUsage, D>
4797        for &BufferUsage
4798    {
4799        unsafe fn encode(
4800            self,
4801            encoder: &mut fidl::encoding::Encoder<'_, D>,
4802            offset: usize,
4803            mut depth: fidl::encoding::Depth,
4804        ) -> fidl::Result<()> {
4805            encoder.debug_check_bounds::<BufferUsage>(offset);
4806            // Vector header
4807            let max_ordinal: u64 = self.max_ordinal_present();
4808            encoder.write_num(max_ordinal, offset);
4809            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4810            // Calling encoder.out_of_line_offset(0) is not allowed.
4811            if max_ordinal == 0 {
4812                return Ok(());
4813            }
4814            depth.increment()?;
4815            let envelope_size = 8;
4816            let bytes_len = max_ordinal as usize * envelope_size;
4817            #[allow(unused_variables)]
4818            let offset = encoder.out_of_line_offset(bytes_len);
4819            let mut _prev_end_offset: usize = 0;
4820            if 1 > max_ordinal {
4821                return Ok(());
4822            }
4823
4824            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4825            // are envelope_size bytes.
4826            let cur_offset: usize = (1 - 1) * envelope_size;
4827
4828            // Zero reserved fields.
4829            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4830
4831            // Safety:
4832            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4833            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4834            //   envelope_size bytes, there is always sufficient room.
4835            fidl::encoding::encode_in_envelope_optional::<u32, D>(
4836                self.none.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
4837                encoder,
4838                offset + cur_offset,
4839                depth,
4840            )?;
4841
4842            _prev_end_offset = cur_offset + envelope_size;
4843            if 2 > max_ordinal {
4844                return Ok(());
4845            }
4846
4847            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4848            // are envelope_size bytes.
4849            let cur_offset: usize = (2 - 1) * envelope_size;
4850
4851            // Zero reserved fields.
4852            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4853
4854            // Safety:
4855            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4856            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4857            //   envelope_size bytes, there is always sufficient room.
4858            fidl::encoding::encode_in_envelope_optional::<u32, D>(
4859                self.cpu.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
4860                encoder,
4861                offset + cur_offset,
4862                depth,
4863            )?;
4864
4865            _prev_end_offset = cur_offset + envelope_size;
4866            if 3 > max_ordinal {
4867                return Ok(());
4868            }
4869
4870            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4871            // are envelope_size bytes.
4872            let cur_offset: usize = (3 - 1) * envelope_size;
4873
4874            // Zero reserved fields.
4875            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4876
4877            // Safety:
4878            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4879            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4880            //   envelope_size bytes, there is always sufficient room.
4881            fidl::encoding::encode_in_envelope_optional::<u32, D>(
4882                self.vulkan.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
4883                encoder,
4884                offset + cur_offset,
4885                depth,
4886            )?;
4887
4888            _prev_end_offset = cur_offset + envelope_size;
4889            if 4 > max_ordinal {
4890                return Ok(());
4891            }
4892
4893            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4894            // are envelope_size bytes.
4895            let cur_offset: usize = (4 - 1) * envelope_size;
4896
4897            // Zero reserved fields.
4898            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4899
4900            // Safety:
4901            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4902            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4903            //   envelope_size bytes, there is always sufficient room.
4904            fidl::encoding::encode_in_envelope_optional::<u32, D>(
4905                self.display.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
4906                encoder,
4907                offset + cur_offset,
4908                depth,
4909            )?;
4910
4911            _prev_end_offset = cur_offset + envelope_size;
4912            if 5 > max_ordinal {
4913                return Ok(());
4914            }
4915
4916            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4917            // are envelope_size bytes.
4918            let cur_offset: usize = (5 - 1) * envelope_size;
4919
4920            // Zero reserved fields.
4921            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4922
4923            // Safety:
4924            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4925            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4926            //   envelope_size bytes, there is always sufficient room.
4927            fidl::encoding::encode_in_envelope_optional::<u32, D>(
4928                self.video.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
4929                encoder,
4930                offset + cur_offset,
4931                depth,
4932            )?;
4933
4934            _prev_end_offset = cur_offset + envelope_size;
4935
4936            Ok(())
4937        }
4938    }
4939
4940    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferUsage {
4941        #[inline(always)]
4942        fn new_empty() -> Self {
4943            Self::default()
4944        }
4945
4946        unsafe fn decode(
4947            &mut self,
4948            decoder: &mut fidl::encoding::Decoder<'_, D>,
4949            offset: usize,
4950            mut depth: fidl::encoding::Depth,
4951        ) -> fidl::Result<()> {
4952            decoder.debug_check_bounds::<Self>(offset);
4953            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4954                None => return Err(fidl::Error::NotNullable),
4955                Some(len) => len,
4956            };
4957            // Calling decoder.out_of_line_offset(0) is not allowed.
4958            if len == 0 {
4959                return Ok(());
4960            };
4961            depth.increment()?;
4962            let envelope_size = 8;
4963            let bytes_len = len * envelope_size;
4964            let offset = decoder.out_of_line_offset(bytes_len)?;
4965            // Decode the envelope for each type.
4966            let mut _next_ordinal_to_read = 0;
4967            let mut next_offset = offset;
4968            let end_offset = offset + bytes_len;
4969            _next_ordinal_to_read += 1;
4970            if next_offset >= end_offset {
4971                return Ok(());
4972            }
4973
4974            // Decode unknown envelopes for gaps in ordinals.
4975            while _next_ordinal_to_read < 1 {
4976                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4977                _next_ordinal_to_read += 1;
4978                next_offset += envelope_size;
4979            }
4980
4981            let next_out_of_line = decoder.next_out_of_line();
4982            let handles_before = decoder.remaining_handles();
4983            if let Some((inlined, num_bytes, num_handles)) =
4984                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4985            {
4986                let member_inline_size =
4987                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4988                if inlined != (member_inline_size <= 4) {
4989                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4990                }
4991                let inner_offset;
4992                let mut inner_depth = depth.clone();
4993                if inlined {
4994                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4995                    inner_offset = next_offset;
4996                } else {
4997                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4998                    inner_depth.increment()?;
4999                }
5000                let val_ref = self.none.get_or_insert_with(|| fidl::new_empty!(u32, D));
5001                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5002                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5003                {
5004                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5005                }
5006                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5007                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5008                }
5009            }
5010
5011            next_offset += envelope_size;
5012            _next_ordinal_to_read += 1;
5013            if next_offset >= end_offset {
5014                return Ok(());
5015            }
5016
5017            // Decode unknown envelopes for gaps in ordinals.
5018            while _next_ordinal_to_read < 2 {
5019                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5020                _next_ordinal_to_read += 1;
5021                next_offset += envelope_size;
5022            }
5023
5024            let next_out_of_line = decoder.next_out_of_line();
5025            let handles_before = decoder.remaining_handles();
5026            if let Some((inlined, num_bytes, num_handles)) =
5027                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5028            {
5029                let member_inline_size =
5030                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5031                if inlined != (member_inline_size <= 4) {
5032                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5033                }
5034                let inner_offset;
5035                let mut inner_depth = depth.clone();
5036                if inlined {
5037                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5038                    inner_offset = next_offset;
5039                } else {
5040                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5041                    inner_depth.increment()?;
5042                }
5043                let val_ref = self.cpu.get_or_insert_with(|| fidl::new_empty!(u32, D));
5044                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5045                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5046                {
5047                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5048                }
5049                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5050                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5051                }
5052            }
5053
5054            next_offset += envelope_size;
5055            _next_ordinal_to_read += 1;
5056            if next_offset >= end_offset {
5057                return Ok(());
5058            }
5059
5060            // Decode unknown envelopes for gaps in ordinals.
5061            while _next_ordinal_to_read < 3 {
5062                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5063                _next_ordinal_to_read += 1;
5064                next_offset += envelope_size;
5065            }
5066
5067            let next_out_of_line = decoder.next_out_of_line();
5068            let handles_before = decoder.remaining_handles();
5069            if let Some((inlined, num_bytes, num_handles)) =
5070                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5071            {
5072                let member_inline_size =
5073                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5074                if inlined != (member_inline_size <= 4) {
5075                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5076                }
5077                let inner_offset;
5078                let mut inner_depth = depth.clone();
5079                if inlined {
5080                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5081                    inner_offset = next_offset;
5082                } else {
5083                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5084                    inner_depth.increment()?;
5085                }
5086                let val_ref = self.vulkan.get_or_insert_with(|| fidl::new_empty!(u32, D));
5087                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5088                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5089                {
5090                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5091                }
5092                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5093                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5094                }
5095            }
5096
5097            next_offset += envelope_size;
5098            _next_ordinal_to_read += 1;
5099            if next_offset >= end_offset {
5100                return Ok(());
5101            }
5102
5103            // Decode unknown envelopes for gaps in ordinals.
5104            while _next_ordinal_to_read < 4 {
5105                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5106                _next_ordinal_to_read += 1;
5107                next_offset += envelope_size;
5108            }
5109
5110            let next_out_of_line = decoder.next_out_of_line();
5111            let handles_before = decoder.remaining_handles();
5112            if let Some((inlined, num_bytes, num_handles)) =
5113                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5114            {
5115                let member_inline_size =
5116                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5117                if inlined != (member_inline_size <= 4) {
5118                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5119                }
5120                let inner_offset;
5121                let mut inner_depth = depth.clone();
5122                if inlined {
5123                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5124                    inner_offset = next_offset;
5125                } else {
5126                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5127                    inner_depth.increment()?;
5128                }
5129                let val_ref = self.display.get_or_insert_with(|| fidl::new_empty!(u32, D));
5130                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5131                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5132                {
5133                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5134                }
5135                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5136                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5137                }
5138            }
5139
5140            next_offset += envelope_size;
5141            _next_ordinal_to_read += 1;
5142            if next_offset >= end_offset {
5143                return Ok(());
5144            }
5145
5146            // Decode unknown envelopes for gaps in ordinals.
5147            while _next_ordinal_to_read < 5 {
5148                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5149                _next_ordinal_to_read += 1;
5150                next_offset += envelope_size;
5151            }
5152
5153            let next_out_of_line = decoder.next_out_of_line();
5154            let handles_before = decoder.remaining_handles();
5155            if let Some((inlined, num_bytes, num_handles)) =
5156                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5157            {
5158                let member_inline_size =
5159                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5160                if inlined != (member_inline_size <= 4) {
5161                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5162                }
5163                let inner_offset;
5164                let mut inner_depth = depth.clone();
5165                if inlined {
5166                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5167                    inner_offset = next_offset;
5168                } else {
5169                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5170                    inner_depth.increment()?;
5171                }
5172                let val_ref = self.video.get_or_insert_with(|| fidl::new_empty!(u32, D));
5173                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5174                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5175                {
5176                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5177                }
5178                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5179                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5180                }
5181            }
5182
5183            next_offset += envelope_size;
5184
5185            // Decode the remaining unknown envelopes.
5186            while next_offset < end_offset {
5187                _next_ordinal_to_read += 1;
5188                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5189                next_offset += envelope_size;
5190            }
5191
5192            Ok(())
5193        }
5194    }
5195
5196    impl Config {
5197        #[inline(always)]
5198        fn max_ordinal_present(&self) -> u64 {
5199            if let Some(_) = self.format_costs {
5200                return 1;
5201            }
5202            0
5203        }
5204    }
5205
5206    impl fidl::encoding::ValueTypeMarker for Config {
5207        type Borrowed<'a> = &'a Self;
5208        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5209            value
5210        }
5211    }
5212
5213    unsafe impl fidl::encoding::TypeMarker for Config {
5214        type Owned = Self;
5215
5216        #[inline(always)]
5217        fn inline_align(_context: fidl::encoding::Context) -> usize {
5218            8
5219        }
5220
5221        #[inline(always)]
5222        fn inline_size(_context: fidl::encoding::Context) -> usize {
5223            16
5224        }
5225    }
5226
5227    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
5228        unsafe fn encode(
5229            self,
5230            encoder: &mut fidl::encoding::Encoder<'_, D>,
5231            offset: usize,
5232            mut depth: fidl::encoding::Depth,
5233        ) -> fidl::Result<()> {
5234            encoder.debug_check_bounds::<Config>(offset);
5235            // Vector header
5236            let max_ordinal: u64 = self.max_ordinal_present();
5237            encoder.write_num(max_ordinal, offset);
5238            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5239            // Calling encoder.out_of_line_offset(0) is not allowed.
5240            if max_ordinal == 0 {
5241                return Ok(());
5242            }
5243            depth.increment()?;
5244            let envelope_size = 8;
5245            let bytes_len = max_ordinal as usize * envelope_size;
5246            #[allow(unused_variables)]
5247            let offset = encoder.out_of_line_offset(bytes_len);
5248            let mut _prev_end_offset: usize = 0;
5249            if 1 > max_ordinal {
5250                return Ok(());
5251            }
5252
5253            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5254            // are envelope_size bytes.
5255            let cur_offset: usize = (1 - 1) * envelope_size;
5256
5257            // Zero reserved fields.
5258            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5259
5260            // Safety:
5261            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5262            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5263            //   envelope_size bytes, there is always sufficient room.
5264            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<FormatCostEntry>, D>(
5265            self.format_costs.as_ref().map(<fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::ValueTypeMarker>::borrow),
5266            encoder, offset + cur_offset, depth
5267        )?;
5268
5269            _prev_end_offset = cur_offset + envelope_size;
5270
5271            Ok(())
5272        }
5273    }
5274
5275    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
5276        #[inline(always)]
5277        fn new_empty() -> Self {
5278            Self::default()
5279        }
5280
5281        unsafe fn decode(
5282            &mut self,
5283            decoder: &mut fidl::encoding::Decoder<'_, D>,
5284            offset: usize,
5285            mut depth: fidl::encoding::Depth,
5286        ) -> fidl::Result<()> {
5287            decoder.debug_check_bounds::<Self>(offset);
5288            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5289                None => return Err(fidl::Error::NotNullable),
5290                Some(len) => len,
5291            };
5292            // Calling decoder.out_of_line_offset(0) is not allowed.
5293            if len == 0 {
5294                return Ok(());
5295            };
5296            depth.increment()?;
5297            let envelope_size = 8;
5298            let bytes_len = len * envelope_size;
5299            let offset = decoder.out_of_line_offset(bytes_len)?;
5300            // Decode the envelope for each type.
5301            let mut _next_ordinal_to_read = 0;
5302            let mut next_offset = offset;
5303            let end_offset = offset + bytes_len;
5304            _next_ordinal_to_read += 1;
5305            if next_offset >= end_offset {
5306                return Ok(());
5307            }
5308
5309            // Decode unknown envelopes for gaps in ordinals.
5310            while _next_ordinal_to_read < 1 {
5311                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5312                _next_ordinal_to_read += 1;
5313                next_offset += envelope_size;
5314            }
5315
5316            let next_out_of_line = decoder.next_out_of_line();
5317            let handles_before = decoder.remaining_handles();
5318            if let Some((inlined, num_bytes, num_handles)) =
5319                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5320            {
5321                let member_inline_size = <fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5322                if inlined != (member_inline_size <= 4) {
5323                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5324                }
5325                let inner_offset;
5326                let mut inner_depth = depth.clone();
5327                if inlined {
5328                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5329                    inner_offset = next_offset;
5330                } else {
5331                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5332                    inner_depth.increment()?;
5333                }
5334                let val_ref = self.format_costs.get_or_insert_with(|| {
5335                    fidl::new_empty!(fidl::encoding::UnboundedVector<FormatCostEntry>, D)
5336                });
5337                fidl::decode!(
5338                    fidl::encoding::UnboundedVector<FormatCostEntry>,
5339                    D,
5340                    val_ref,
5341                    decoder,
5342                    inner_offset,
5343                    inner_depth
5344                )?;
5345                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5346                {
5347                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5348                }
5349                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5350                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5351                }
5352            }
5353
5354            next_offset += envelope_size;
5355
5356            // Decode the remaining unknown envelopes.
5357            while next_offset < end_offset {
5358                _next_ordinal_to_read += 1;
5359                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5360                next_offset += envelope_size;
5361            }
5362
5363            Ok(())
5364        }
5365    }
5366
5367    impl DynamicSecureHeap {
5368        #[inline(always)]
5369        fn max_ordinal_present(&self) -> u64 {
5370            if let Some(_) = self.heap {
5371                return 1;
5372            }
5373            0
5374        }
5375    }
5376
5377    impl fidl::encoding::ValueTypeMarker for DynamicSecureHeap {
5378        type Borrowed<'a> = &'a Self;
5379        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5380            value
5381        }
5382    }
5383
5384    unsafe impl fidl::encoding::TypeMarker for DynamicSecureHeap {
5385        type Owned = Self;
5386
5387        #[inline(always)]
5388        fn inline_align(_context: fidl::encoding::Context) -> usize {
5389            8
5390        }
5391
5392        #[inline(always)]
5393        fn inline_size(_context: fidl::encoding::Context) -> usize {
5394            16
5395        }
5396    }
5397
5398    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DynamicSecureHeap, D>
5399        for &DynamicSecureHeap
5400    {
5401        unsafe fn encode(
5402            self,
5403            encoder: &mut fidl::encoding::Encoder<'_, D>,
5404            offset: usize,
5405            mut depth: fidl::encoding::Depth,
5406        ) -> fidl::Result<()> {
5407            encoder.debug_check_bounds::<DynamicSecureHeap>(offset);
5408            // Vector header
5409            let max_ordinal: u64 = self.max_ordinal_present();
5410            encoder.write_num(max_ordinal, offset);
5411            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5412            // Calling encoder.out_of_line_offset(0) is not allowed.
5413            if max_ordinal == 0 {
5414                return Ok(());
5415            }
5416            depth.increment()?;
5417            let envelope_size = 8;
5418            let bytes_len = max_ordinal as usize * envelope_size;
5419            #[allow(unused_variables)]
5420            let offset = encoder.out_of_line_offset(bytes_len);
5421            let mut _prev_end_offset: usize = 0;
5422            if 1 > max_ordinal {
5423                return Ok(());
5424            }
5425
5426            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5427            // are envelope_size bytes.
5428            let cur_offset: usize = (1 - 1) * envelope_size;
5429
5430            // Zero reserved fields.
5431            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5432
5433            // Safety:
5434            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5435            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5436            //   envelope_size bytes, there is always sufficient room.
5437            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
5438                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
5439                encoder,
5440                offset + cur_offset,
5441                depth,
5442            )?;
5443
5444            _prev_end_offset = cur_offset + envelope_size;
5445
5446            Ok(())
5447        }
5448    }
5449
5450    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DynamicSecureHeap {
5451        #[inline(always)]
5452        fn new_empty() -> Self {
5453            Self::default()
5454        }
5455
5456        unsafe fn decode(
5457            &mut self,
5458            decoder: &mut fidl::encoding::Decoder<'_, D>,
5459            offset: usize,
5460            mut depth: fidl::encoding::Depth,
5461        ) -> fidl::Result<()> {
5462            decoder.debug_check_bounds::<Self>(offset);
5463            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5464                None => return Err(fidl::Error::NotNullable),
5465                Some(len) => len,
5466            };
5467            // Calling decoder.out_of_line_offset(0) is not allowed.
5468            if len == 0 {
5469                return Ok(());
5470            };
5471            depth.increment()?;
5472            let envelope_size = 8;
5473            let bytes_len = len * envelope_size;
5474            let offset = decoder.out_of_line_offset(bytes_len)?;
5475            // Decode the envelope for each type.
5476            let mut _next_ordinal_to_read = 0;
5477            let mut next_offset = offset;
5478            let end_offset = offset + bytes_len;
5479            _next_ordinal_to_read += 1;
5480            if next_offset >= end_offset {
5481                return Ok(());
5482            }
5483
5484            // Decode unknown envelopes for gaps in ordinals.
5485            while _next_ordinal_to_read < 1 {
5486                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5487                _next_ordinal_to_read += 1;
5488                next_offset += envelope_size;
5489            }
5490
5491            let next_out_of_line = decoder.next_out_of_line();
5492            let handles_before = decoder.remaining_handles();
5493            if let Some((inlined, num_bytes, num_handles)) =
5494                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5495            {
5496                let member_inline_size =
5497                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5498                if inlined != (member_inline_size <= 4) {
5499                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5500                }
5501                let inner_offset;
5502                let mut inner_depth = depth.clone();
5503                if inlined {
5504                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5505                    inner_offset = next_offset;
5506                } else {
5507                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5508                    inner_depth.increment()?;
5509                }
5510                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
5511                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
5512                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5513                {
5514                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5515                }
5516                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5517                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5518                }
5519            }
5520
5521            next_offset += envelope_size;
5522
5523            // Decode the remaining unknown envelopes.
5524            while next_offset < end_offset {
5525                _next_ordinal_to_read += 1;
5526                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5527                next_offset += envelope_size;
5528            }
5529
5530            Ok(())
5531        }
5532    }
5533
5534    impl FormatCostEntry {
5535        #[inline(always)]
5536        fn max_ordinal_present(&self) -> u64 {
5537            if let Some(_) = self.cost {
5538                return 2;
5539            }
5540            if let Some(_) = self.key {
5541                return 1;
5542            }
5543            0
5544        }
5545    }
5546
5547    impl fidl::encoding::ValueTypeMarker for FormatCostEntry {
5548        type Borrowed<'a> = &'a Self;
5549        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5550            value
5551        }
5552    }
5553
5554    unsafe impl fidl::encoding::TypeMarker for FormatCostEntry {
5555        type Owned = Self;
5556
5557        #[inline(always)]
5558        fn inline_align(_context: fidl::encoding::Context) -> usize {
5559            8
5560        }
5561
5562        #[inline(always)]
5563        fn inline_size(_context: fidl::encoding::Context) -> usize {
5564            16
5565        }
5566    }
5567
5568    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCostEntry, D>
5569        for &FormatCostEntry
5570    {
5571        unsafe fn encode(
5572            self,
5573            encoder: &mut fidl::encoding::Encoder<'_, D>,
5574            offset: usize,
5575            mut depth: fidl::encoding::Depth,
5576        ) -> fidl::Result<()> {
5577            encoder.debug_check_bounds::<FormatCostEntry>(offset);
5578            // Vector header
5579            let max_ordinal: u64 = self.max_ordinal_present();
5580            encoder.write_num(max_ordinal, offset);
5581            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5582            // Calling encoder.out_of_line_offset(0) is not allowed.
5583            if max_ordinal == 0 {
5584                return Ok(());
5585            }
5586            depth.increment()?;
5587            let envelope_size = 8;
5588            let bytes_len = max_ordinal as usize * envelope_size;
5589            #[allow(unused_variables)]
5590            let offset = encoder.out_of_line_offset(bytes_len);
5591            let mut _prev_end_offset: usize = 0;
5592            if 1 > max_ordinal {
5593                return Ok(());
5594            }
5595
5596            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5597            // are envelope_size bytes.
5598            let cur_offset: usize = (1 - 1) * envelope_size;
5599
5600            // Zero reserved fields.
5601            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5602
5603            // Safety:
5604            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5605            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5606            //   envelope_size bytes, there is always sufficient room.
5607            fidl::encoding::encode_in_envelope_optional::<FormatCostKey, D>(
5608                self.key.as_ref().map(<FormatCostKey as fidl::encoding::ValueTypeMarker>::borrow),
5609                encoder,
5610                offset + cur_offset,
5611                depth,
5612            )?;
5613
5614            _prev_end_offset = cur_offset + envelope_size;
5615            if 2 > max_ordinal {
5616                return Ok(());
5617            }
5618
5619            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5620            // are envelope_size bytes.
5621            let cur_offset: usize = (2 - 1) * envelope_size;
5622
5623            // Zero reserved fields.
5624            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5625
5626            // Safety:
5627            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5628            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5629            //   envelope_size bytes, there is always sufficient room.
5630            fidl::encoding::encode_in_envelope_optional::<f32, D>(
5631                self.cost.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
5632                encoder,
5633                offset + cur_offset,
5634                depth,
5635            )?;
5636
5637            _prev_end_offset = cur_offset + envelope_size;
5638
5639            Ok(())
5640        }
5641    }
5642
5643    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCostEntry {
5644        #[inline(always)]
5645        fn new_empty() -> Self {
5646            Self::default()
5647        }
5648
5649        unsafe fn decode(
5650            &mut self,
5651            decoder: &mut fidl::encoding::Decoder<'_, D>,
5652            offset: usize,
5653            mut depth: fidl::encoding::Depth,
5654        ) -> fidl::Result<()> {
5655            decoder.debug_check_bounds::<Self>(offset);
5656            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5657                None => return Err(fidl::Error::NotNullable),
5658                Some(len) => len,
5659            };
5660            // Calling decoder.out_of_line_offset(0) is not allowed.
5661            if len == 0 {
5662                return Ok(());
5663            };
5664            depth.increment()?;
5665            let envelope_size = 8;
5666            let bytes_len = len * envelope_size;
5667            let offset = decoder.out_of_line_offset(bytes_len)?;
5668            // Decode the envelope for each type.
5669            let mut _next_ordinal_to_read = 0;
5670            let mut next_offset = offset;
5671            let end_offset = offset + bytes_len;
5672            _next_ordinal_to_read += 1;
5673            if next_offset >= end_offset {
5674                return Ok(());
5675            }
5676
5677            // Decode unknown envelopes for gaps in ordinals.
5678            while _next_ordinal_to_read < 1 {
5679                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5680                _next_ordinal_to_read += 1;
5681                next_offset += envelope_size;
5682            }
5683
5684            let next_out_of_line = decoder.next_out_of_line();
5685            let handles_before = decoder.remaining_handles();
5686            if let Some((inlined, num_bytes, num_handles)) =
5687                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5688            {
5689                let member_inline_size =
5690                    <FormatCostKey as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5691                if inlined != (member_inline_size <= 4) {
5692                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5693                }
5694                let inner_offset;
5695                let mut inner_depth = depth.clone();
5696                if inlined {
5697                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5698                    inner_offset = next_offset;
5699                } else {
5700                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5701                    inner_depth.increment()?;
5702                }
5703                let val_ref = self.key.get_or_insert_with(|| fidl::new_empty!(FormatCostKey, D));
5704                fidl::decode!(FormatCostKey, D, val_ref, decoder, inner_offset, inner_depth)?;
5705                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5706                {
5707                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5708                }
5709                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5710                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5711                }
5712            }
5713
5714            next_offset += envelope_size;
5715            _next_ordinal_to_read += 1;
5716            if next_offset >= end_offset {
5717                return Ok(());
5718            }
5719
5720            // Decode unknown envelopes for gaps in ordinals.
5721            while _next_ordinal_to_read < 2 {
5722                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5723                _next_ordinal_to_read += 1;
5724                next_offset += envelope_size;
5725            }
5726
5727            let next_out_of_line = decoder.next_out_of_line();
5728            let handles_before = decoder.remaining_handles();
5729            if let Some((inlined, num_bytes, num_handles)) =
5730                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5731            {
5732                let member_inline_size =
5733                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5734                if inlined != (member_inline_size <= 4) {
5735                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5736                }
5737                let inner_offset;
5738                let mut inner_depth = depth.clone();
5739                if inlined {
5740                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5741                    inner_offset = next_offset;
5742                } else {
5743                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5744                    inner_depth.increment()?;
5745                }
5746                let val_ref = self.cost.get_or_insert_with(|| fidl::new_empty!(f32, D));
5747                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
5748                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5749                {
5750                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5751                }
5752                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5753                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5754                }
5755            }
5756
5757            next_offset += envelope_size;
5758
5759            // Decode the remaining unknown envelopes.
5760            while next_offset < end_offset {
5761                _next_ordinal_to_read += 1;
5762                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5763                next_offset += envelope_size;
5764            }
5765
5766            Ok(())
5767        }
5768    }
5769
5770    impl FormatCostKey {
5771        #[inline(always)]
5772        fn max_ordinal_present(&self) -> u64 {
5773            if let Some(_) = self.buffer_usage_bits {
5774                return 3;
5775            }
5776            if let Some(_) = self.pixel_format_modifier {
5777                return 2;
5778            }
5779            if let Some(_) = self.pixel_format {
5780                return 1;
5781            }
5782            0
5783        }
5784    }
5785
5786    impl fidl::encoding::ValueTypeMarker for FormatCostKey {
5787        type Borrowed<'a> = &'a Self;
5788        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5789            value
5790        }
5791    }
5792
5793    unsafe impl fidl::encoding::TypeMarker for FormatCostKey {
5794        type Owned = Self;
5795
5796        #[inline(always)]
5797        fn inline_align(_context: fidl::encoding::Context) -> usize {
5798            8
5799        }
5800
5801        #[inline(always)]
5802        fn inline_size(_context: fidl::encoding::Context) -> usize {
5803            16
5804        }
5805    }
5806
5807    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCostKey, D>
5808        for &FormatCostKey
5809    {
5810        unsafe fn encode(
5811            self,
5812            encoder: &mut fidl::encoding::Encoder<'_, D>,
5813            offset: usize,
5814            mut depth: fidl::encoding::Depth,
5815        ) -> fidl::Result<()> {
5816            encoder.debug_check_bounds::<FormatCostKey>(offset);
5817            // Vector header
5818            let max_ordinal: u64 = self.max_ordinal_present();
5819            encoder.write_num(max_ordinal, offset);
5820            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5821            // Calling encoder.out_of_line_offset(0) is not allowed.
5822            if max_ordinal == 0 {
5823                return Ok(());
5824            }
5825            depth.increment()?;
5826            let envelope_size = 8;
5827            let bytes_len = max_ordinal as usize * envelope_size;
5828            #[allow(unused_variables)]
5829            let offset = encoder.out_of_line_offset(bytes_len);
5830            let mut _prev_end_offset: usize = 0;
5831            if 1 > max_ordinal {
5832                return Ok(());
5833            }
5834
5835            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5836            // are envelope_size bytes.
5837            let cur_offset: usize = (1 - 1) * envelope_size;
5838
5839            // Zero reserved fields.
5840            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5841
5842            // Safety:
5843            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5844            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5845            //   envelope_size bytes, there is always sufficient room.
5846            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormat, D>(
5847            self.pixel_format.as_ref().map(<fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow),
5848            encoder, offset + cur_offset, depth
5849        )?;
5850
5851            _prev_end_offset = cur_offset + envelope_size;
5852            if 2 > max_ordinal {
5853                return Ok(());
5854            }
5855
5856            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5857            // are envelope_size bytes.
5858            let cur_offset: usize = (2 - 1) * envelope_size;
5859
5860            // Zero reserved fields.
5861            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5862
5863            // Safety:
5864            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5865            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5866            //   envelope_size bytes, there is always sufficient room.
5867            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormatModifier, D>(
5868            self.pixel_format_modifier.as_ref().map(<fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow),
5869            encoder, offset + cur_offset, depth
5870        )?;
5871
5872            _prev_end_offset = cur_offset + envelope_size;
5873            if 3 > max_ordinal {
5874                return Ok(());
5875            }
5876
5877            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5878            // are envelope_size bytes.
5879            let cur_offset: usize = (3 - 1) * envelope_size;
5880
5881            // Zero reserved fields.
5882            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5883
5884            // Safety:
5885            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5886            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5887            //   envelope_size bytes, there is always sufficient room.
5888            fidl::encoding::encode_in_envelope_optional::<BufferUsage, D>(
5889                self.buffer_usage_bits
5890                    .as_ref()
5891                    .map(<BufferUsage as fidl::encoding::ValueTypeMarker>::borrow),
5892                encoder,
5893                offset + cur_offset,
5894                depth,
5895            )?;
5896
5897            _prev_end_offset = cur_offset + envelope_size;
5898
5899            Ok(())
5900        }
5901    }
5902
5903    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCostKey {
5904        #[inline(always)]
5905        fn new_empty() -> Self {
5906            Self::default()
5907        }
5908
5909        unsafe fn decode(
5910            &mut self,
5911            decoder: &mut fidl::encoding::Decoder<'_, D>,
5912            offset: usize,
5913            mut depth: fidl::encoding::Depth,
5914        ) -> fidl::Result<()> {
5915            decoder.debug_check_bounds::<Self>(offset);
5916            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5917                None => return Err(fidl::Error::NotNullable),
5918                Some(len) => len,
5919            };
5920            // Calling decoder.out_of_line_offset(0) is not allowed.
5921            if len == 0 {
5922                return Ok(());
5923            };
5924            depth.increment()?;
5925            let envelope_size = 8;
5926            let bytes_len = len * envelope_size;
5927            let offset = decoder.out_of_line_offset(bytes_len)?;
5928            // Decode the envelope for each type.
5929            let mut _next_ordinal_to_read = 0;
5930            let mut next_offset = offset;
5931            let end_offset = offset + bytes_len;
5932            _next_ordinal_to_read += 1;
5933            if next_offset >= end_offset {
5934                return Ok(());
5935            }
5936
5937            // Decode unknown envelopes for gaps in ordinals.
5938            while _next_ordinal_to_read < 1 {
5939                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5940                _next_ordinal_to_read += 1;
5941                next_offset += envelope_size;
5942            }
5943
5944            let next_out_of_line = decoder.next_out_of_line();
5945            let handles_before = decoder.remaining_handles();
5946            if let Some((inlined, num_bytes, num_handles)) =
5947                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5948            {
5949                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5950                if inlined != (member_inline_size <= 4) {
5951                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5952                }
5953                let inner_offset;
5954                let mut inner_depth = depth.clone();
5955                if inlined {
5956                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5957                    inner_offset = next_offset;
5958                } else {
5959                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5960                    inner_depth.increment()?;
5961                }
5962                let val_ref = self.pixel_format.get_or_insert_with(|| {
5963                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D)
5964                });
5965                fidl::decode!(
5966                    fidl_fuchsia_images2__common::PixelFormat,
5967                    D,
5968                    val_ref,
5969                    decoder,
5970                    inner_offset,
5971                    inner_depth
5972                )?;
5973                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5974                {
5975                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5976                }
5977                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5978                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5979                }
5980            }
5981
5982            next_offset += envelope_size;
5983            _next_ordinal_to_read += 1;
5984            if next_offset >= end_offset {
5985                return Ok(());
5986            }
5987
5988            // Decode unknown envelopes for gaps in ordinals.
5989            while _next_ordinal_to_read < 2 {
5990                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5991                _next_ordinal_to_read += 1;
5992                next_offset += envelope_size;
5993            }
5994
5995            let next_out_of_line = decoder.next_out_of_line();
5996            let handles_before = decoder.remaining_handles();
5997            if let Some((inlined, num_bytes, num_handles)) =
5998                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5999            {
6000                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6001                if inlined != (member_inline_size <= 4) {
6002                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6003                }
6004                let inner_offset;
6005                let mut inner_depth = depth.clone();
6006                if inlined {
6007                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6008                    inner_offset = next_offset;
6009                } else {
6010                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6011                    inner_depth.increment()?;
6012                }
6013                let val_ref = self.pixel_format_modifier.get_or_insert_with(|| {
6014                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormatModifier, D)
6015                });
6016                fidl::decode!(
6017                    fidl_fuchsia_images2__common::PixelFormatModifier,
6018                    D,
6019                    val_ref,
6020                    decoder,
6021                    inner_offset,
6022                    inner_depth
6023                )?;
6024                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6025                {
6026                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6027                }
6028                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6029                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6030                }
6031            }
6032
6033            next_offset += envelope_size;
6034            _next_ordinal_to_read += 1;
6035            if next_offset >= end_offset {
6036                return Ok(());
6037            }
6038
6039            // Decode unknown envelopes for gaps in ordinals.
6040            while _next_ordinal_to_read < 3 {
6041                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6042                _next_ordinal_to_read += 1;
6043                next_offset += envelope_size;
6044            }
6045
6046            let next_out_of_line = decoder.next_out_of_line();
6047            let handles_before = decoder.remaining_handles();
6048            if let Some((inlined, num_bytes, num_handles)) =
6049                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6050            {
6051                let member_inline_size =
6052                    <BufferUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6053                if inlined != (member_inline_size <= 4) {
6054                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6055                }
6056                let inner_offset;
6057                let mut inner_depth = depth.clone();
6058                if inlined {
6059                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6060                    inner_offset = next_offset;
6061                } else {
6062                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6063                    inner_depth.increment()?;
6064                }
6065                let val_ref =
6066                    self.buffer_usage_bits.get_or_insert_with(|| fidl::new_empty!(BufferUsage, D));
6067                fidl::decode!(BufferUsage, D, val_ref, decoder, inner_offset, inner_depth)?;
6068                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6069                {
6070                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6071                }
6072                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6073                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6074                }
6075            }
6076
6077            next_offset += envelope_size;
6078
6079            // Decode the remaining unknown envelopes.
6080            while next_offset < end_offset {
6081                _next_ordinal_to_read += 1;
6082                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6083                next_offset += envelope_size;
6084            }
6085
6086            Ok(())
6087        }
6088    }
6089
6090    impl FormatCosts {
6091        #[inline(always)]
6092        fn max_ordinal_present(&self) -> u64 {
6093            if let Some(_) = self.format_costs {
6094                return 1;
6095            }
6096            0
6097        }
6098    }
6099
6100    impl fidl::encoding::ValueTypeMarker for FormatCosts {
6101        type Borrowed<'a> = &'a Self;
6102        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6103            value
6104        }
6105    }
6106
6107    unsafe impl fidl::encoding::TypeMarker for FormatCosts {
6108        type Owned = Self;
6109
6110        #[inline(always)]
6111        fn inline_align(_context: fidl::encoding::Context) -> usize {
6112            8
6113        }
6114
6115        #[inline(always)]
6116        fn inline_size(_context: fidl::encoding::Context) -> usize {
6117            16
6118        }
6119    }
6120
6121    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCosts, D>
6122        for &FormatCosts
6123    {
6124        unsafe fn encode(
6125            self,
6126            encoder: &mut fidl::encoding::Encoder<'_, D>,
6127            offset: usize,
6128            mut depth: fidl::encoding::Depth,
6129        ) -> fidl::Result<()> {
6130            encoder.debug_check_bounds::<FormatCosts>(offset);
6131            // Vector header
6132            let max_ordinal: u64 = self.max_ordinal_present();
6133            encoder.write_num(max_ordinal, offset);
6134            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6135            // Calling encoder.out_of_line_offset(0) is not allowed.
6136            if max_ordinal == 0 {
6137                return Ok(());
6138            }
6139            depth.increment()?;
6140            let envelope_size = 8;
6141            let bytes_len = max_ordinal as usize * envelope_size;
6142            #[allow(unused_variables)]
6143            let offset = encoder.out_of_line_offset(bytes_len);
6144            let mut _prev_end_offset: usize = 0;
6145            if 1 > max_ordinal {
6146                return Ok(());
6147            }
6148
6149            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6150            // are envelope_size bytes.
6151            let cur_offset: usize = (1 - 1) * envelope_size;
6152
6153            // Zero reserved fields.
6154            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6155
6156            // Safety:
6157            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6158            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6159            //   envelope_size bytes, there is always sufficient room.
6160            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<FormatCostEntry>, D>(
6161            self.format_costs.as_ref().map(<fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::ValueTypeMarker>::borrow),
6162            encoder, offset + cur_offset, depth
6163        )?;
6164
6165            _prev_end_offset = cur_offset + envelope_size;
6166
6167            Ok(())
6168        }
6169    }
6170
6171    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCosts {
6172        #[inline(always)]
6173        fn new_empty() -> Self {
6174            Self::default()
6175        }
6176
6177        unsafe fn decode(
6178            &mut self,
6179            decoder: &mut fidl::encoding::Decoder<'_, D>,
6180            offset: usize,
6181            mut depth: fidl::encoding::Depth,
6182        ) -> fidl::Result<()> {
6183            decoder.debug_check_bounds::<Self>(offset);
6184            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6185                None => return Err(fidl::Error::NotNullable),
6186                Some(len) => len,
6187            };
6188            // Calling decoder.out_of_line_offset(0) is not allowed.
6189            if len == 0 {
6190                return Ok(());
6191            };
6192            depth.increment()?;
6193            let envelope_size = 8;
6194            let bytes_len = len * envelope_size;
6195            let offset = decoder.out_of_line_offset(bytes_len)?;
6196            // Decode the envelope for each type.
6197            let mut _next_ordinal_to_read = 0;
6198            let mut next_offset = offset;
6199            let end_offset = offset + bytes_len;
6200            _next_ordinal_to_read += 1;
6201            if next_offset >= end_offset {
6202                return Ok(());
6203            }
6204
6205            // Decode unknown envelopes for gaps in ordinals.
6206            while _next_ordinal_to_read < 1 {
6207                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6208                _next_ordinal_to_read += 1;
6209                next_offset += envelope_size;
6210            }
6211
6212            let next_out_of_line = decoder.next_out_of_line();
6213            let handles_before = decoder.remaining_handles();
6214            if let Some((inlined, num_bytes, num_handles)) =
6215                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6216            {
6217                let member_inline_size = <fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6218                if inlined != (member_inline_size <= 4) {
6219                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6220                }
6221                let inner_offset;
6222                let mut inner_depth = depth.clone();
6223                if inlined {
6224                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6225                    inner_offset = next_offset;
6226                } else {
6227                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6228                    inner_depth.increment()?;
6229                }
6230                let val_ref = self.format_costs.get_or_insert_with(|| {
6231                    fidl::new_empty!(fidl::encoding::UnboundedVector<FormatCostEntry>, D)
6232                });
6233                fidl::decode!(
6234                    fidl::encoding::UnboundedVector<FormatCostEntry>,
6235                    D,
6236                    val_ref,
6237                    decoder,
6238                    inner_offset,
6239                    inner_depth
6240                )?;
6241                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6242                {
6243                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6244                }
6245                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6246                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6247                }
6248            }
6249
6250            next_offset += envelope_size;
6251
6252            // Decode the remaining unknown envelopes.
6253            while next_offset < end_offset {
6254                _next_ordinal_to_read += 1;
6255                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6256                next_offset += envelope_size;
6257            }
6258
6259            Ok(())
6260        }
6261    }
6262
6263    impl Heap {
6264        #[inline(always)]
6265        fn max_ordinal_present(&self) -> u64 {
6266            if let Some(_) = self.id {
6267                return 2;
6268            }
6269            if let Some(_) = self.heap_type {
6270                return 1;
6271            }
6272            0
6273        }
6274    }
6275
6276    impl fidl::encoding::ValueTypeMarker for Heap {
6277        type Borrowed<'a> = &'a Self;
6278        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6279            value
6280        }
6281    }
6282
6283    unsafe impl fidl::encoding::TypeMarker for Heap {
6284        type Owned = Self;
6285
6286        #[inline(always)]
6287        fn inline_align(_context: fidl::encoding::Context) -> usize {
6288            8
6289        }
6290
6291        #[inline(always)]
6292        fn inline_size(_context: fidl::encoding::Context) -> usize {
6293            16
6294        }
6295    }
6296
6297    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Heap, D> for &Heap {
6298        unsafe fn encode(
6299            self,
6300            encoder: &mut fidl::encoding::Encoder<'_, D>,
6301            offset: usize,
6302            mut depth: fidl::encoding::Depth,
6303        ) -> fidl::Result<()> {
6304            encoder.debug_check_bounds::<Heap>(offset);
6305            // Vector header
6306            let max_ordinal: u64 = self.max_ordinal_present();
6307            encoder.write_num(max_ordinal, offset);
6308            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6309            // Calling encoder.out_of_line_offset(0) is not allowed.
6310            if max_ordinal == 0 {
6311                return Ok(());
6312            }
6313            depth.increment()?;
6314            let envelope_size = 8;
6315            let bytes_len = max_ordinal as usize * envelope_size;
6316            #[allow(unused_variables)]
6317            let offset = encoder.out_of_line_offset(bytes_len);
6318            let mut _prev_end_offset: usize = 0;
6319            if 1 > max_ordinal {
6320                return Ok(());
6321            }
6322
6323            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6324            // are envelope_size bytes.
6325            let cur_offset: usize = (1 - 1) * envelope_size;
6326
6327            // Zero reserved fields.
6328            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6329
6330            // Safety:
6331            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6332            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6333            //   envelope_size bytes, there is always sufficient room.
6334            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
6335                self.heap_type.as_ref().map(
6336                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
6337                ),
6338                encoder,
6339                offset + cur_offset,
6340                depth,
6341            )?;
6342
6343            _prev_end_offset = cur_offset + envelope_size;
6344            if 2 > max_ordinal {
6345                return Ok(());
6346            }
6347
6348            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6349            // are envelope_size bytes.
6350            let cur_offset: usize = (2 - 1) * envelope_size;
6351
6352            // Zero reserved fields.
6353            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6354
6355            // Safety:
6356            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6357            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6358            //   envelope_size bytes, there is always sufficient room.
6359            fidl::encoding::encode_in_envelope_optional::<u64, D>(
6360                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
6361                encoder,
6362                offset + cur_offset,
6363                depth,
6364            )?;
6365
6366            _prev_end_offset = cur_offset + envelope_size;
6367
6368            Ok(())
6369        }
6370    }
6371
6372    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Heap {
6373        #[inline(always)]
6374        fn new_empty() -> Self {
6375            Self::default()
6376        }
6377
6378        unsafe fn decode(
6379            &mut self,
6380            decoder: &mut fidl::encoding::Decoder<'_, D>,
6381            offset: usize,
6382            mut depth: fidl::encoding::Depth,
6383        ) -> fidl::Result<()> {
6384            decoder.debug_check_bounds::<Self>(offset);
6385            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6386                None => return Err(fidl::Error::NotNullable),
6387                Some(len) => len,
6388            };
6389            // Calling decoder.out_of_line_offset(0) is not allowed.
6390            if len == 0 {
6391                return Ok(());
6392            };
6393            depth.increment()?;
6394            let envelope_size = 8;
6395            let bytes_len = len * envelope_size;
6396            let offset = decoder.out_of_line_offset(bytes_len)?;
6397            // Decode the envelope for each type.
6398            let mut _next_ordinal_to_read = 0;
6399            let mut next_offset = offset;
6400            let end_offset = offset + bytes_len;
6401            _next_ordinal_to_read += 1;
6402            if next_offset >= end_offset {
6403                return Ok(());
6404            }
6405
6406            // Decode unknown envelopes for gaps in ordinals.
6407            while _next_ordinal_to_read < 1 {
6408                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6409                _next_ordinal_to_read += 1;
6410                next_offset += envelope_size;
6411            }
6412
6413            let next_out_of_line = decoder.next_out_of_line();
6414            let handles_before = decoder.remaining_handles();
6415            if let Some((inlined, num_bytes, num_handles)) =
6416                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6417            {
6418                let member_inline_size =
6419                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
6420                        decoder.context,
6421                    );
6422                if inlined != (member_inline_size <= 4) {
6423                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6424                }
6425                let inner_offset;
6426                let mut inner_depth = depth.clone();
6427                if inlined {
6428                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6429                    inner_offset = next_offset;
6430                } else {
6431                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6432                    inner_depth.increment()?;
6433                }
6434                let val_ref = self
6435                    .heap_type
6436                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
6437                fidl::decode!(
6438                    fidl::encoding::BoundedString<128>,
6439                    D,
6440                    val_ref,
6441                    decoder,
6442                    inner_offset,
6443                    inner_depth
6444                )?;
6445                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6446                {
6447                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6448                }
6449                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6450                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6451                }
6452            }
6453
6454            next_offset += envelope_size;
6455            _next_ordinal_to_read += 1;
6456            if next_offset >= end_offset {
6457                return Ok(());
6458            }
6459
6460            // Decode unknown envelopes for gaps in ordinals.
6461            while _next_ordinal_to_read < 2 {
6462                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6463                _next_ordinal_to_read += 1;
6464                next_offset += envelope_size;
6465            }
6466
6467            let next_out_of_line = decoder.next_out_of_line();
6468            let handles_before = decoder.remaining_handles();
6469            if let Some((inlined, num_bytes, num_handles)) =
6470                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6471            {
6472                let member_inline_size =
6473                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6474                if inlined != (member_inline_size <= 4) {
6475                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6476                }
6477                let inner_offset;
6478                let mut inner_depth = depth.clone();
6479                if inlined {
6480                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6481                    inner_offset = next_offset;
6482                } else {
6483                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6484                    inner_depth.increment()?;
6485                }
6486                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
6487                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
6488                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6489                {
6490                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6491                }
6492                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6493                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6494                }
6495            }
6496
6497            next_offset += envelope_size;
6498
6499            // Decode the remaining unknown envelopes.
6500            while next_offset < end_offset {
6501                _next_ordinal_to_read += 1;
6502                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6503                next_offset += envelope_size;
6504            }
6505
6506            Ok(())
6507        }
6508    }
6509
6510    impl ImageFormatConstraints {
6511        #[inline(always)]
6512        fn max_ordinal_present(&self) -> u64 {
6513            if let Some(_) = self.required_max_size_list {
6514                return 18;
6515            }
6516            if let Some(_) = self.is_alpha_present {
6517                return 17;
6518            }
6519            if let Some(_) = self.require_bytes_per_row_at_pixel_boundary {
6520                return 16;
6521            }
6522            if let Some(_) = self.pixel_format_and_modifiers {
6523                return 15;
6524            }
6525            if let Some(_) = self.start_offset_divisor {
6526                return 14;
6527            }
6528            if let Some(_) = self.bytes_per_row_divisor {
6529                return 13;
6530            }
6531            if let Some(_) = self.required_max_size {
6532                return 12;
6533            }
6534            if let Some(_) = self.required_min_size {
6535                return 11;
6536            }
6537            if let Some(_) = self.display_rect_alignment {
6538                return 10;
6539            }
6540            if let Some(_) = self.size_alignment {
6541                return 9;
6542            }
6543            if let Some(_) = self.max_width_times_height {
6544                return 8;
6545            }
6546            if let Some(_) = self.max_bytes_per_row {
6547                return 7;
6548            }
6549            if let Some(_) = self.min_bytes_per_row {
6550                return 6;
6551            }
6552            if let Some(_) = self.max_size {
6553                return 5;
6554            }
6555            if let Some(_) = self.min_size {
6556                return 4;
6557            }
6558            if let Some(_) = self.color_spaces {
6559                return 3;
6560            }
6561            if let Some(_) = self.pixel_format_modifier {
6562                return 2;
6563            }
6564            if let Some(_) = self.pixel_format {
6565                return 1;
6566            }
6567            0
6568        }
6569    }
6570
6571    impl fidl::encoding::ValueTypeMarker for ImageFormatConstraints {
6572        type Borrowed<'a> = &'a Self;
6573        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6574            value
6575        }
6576    }
6577
6578    unsafe impl fidl::encoding::TypeMarker for ImageFormatConstraints {
6579        type Owned = Self;
6580
6581        #[inline(always)]
6582        fn inline_align(_context: fidl::encoding::Context) -> usize {
6583            8
6584        }
6585
6586        #[inline(always)]
6587        fn inline_size(_context: fidl::encoding::Context) -> usize {
6588            16
6589        }
6590    }
6591
6592    unsafe impl<D: fidl::encoding::ResourceDialect>
6593        fidl::encoding::Encode<ImageFormatConstraints, D> for &ImageFormatConstraints
6594    {
6595        unsafe fn encode(
6596            self,
6597            encoder: &mut fidl::encoding::Encoder<'_, D>,
6598            offset: usize,
6599            mut depth: fidl::encoding::Depth,
6600        ) -> fidl::Result<()> {
6601            encoder.debug_check_bounds::<ImageFormatConstraints>(offset);
6602            // Vector header
6603            let max_ordinal: u64 = self.max_ordinal_present();
6604            encoder.write_num(max_ordinal, offset);
6605            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6606            // Calling encoder.out_of_line_offset(0) is not allowed.
6607            if max_ordinal == 0 {
6608                return Ok(());
6609            }
6610            depth.increment()?;
6611            let envelope_size = 8;
6612            let bytes_len = max_ordinal as usize * envelope_size;
6613            #[allow(unused_variables)]
6614            let offset = encoder.out_of_line_offset(bytes_len);
6615            let mut _prev_end_offset: usize = 0;
6616            if 1 > max_ordinal {
6617                return Ok(());
6618            }
6619
6620            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6621            // are envelope_size bytes.
6622            let cur_offset: usize = (1 - 1) * envelope_size;
6623
6624            // Zero reserved fields.
6625            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6626
6627            // Safety:
6628            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6629            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6630            //   envelope_size bytes, there is always sufficient room.
6631            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormat, D>(
6632            self.pixel_format.as_ref().map(<fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow),
6633            encoder, offset + cur_offset, depth
6634        )?;
6635
6636            _prev_end_offset = cur_offset + envelope_size;
6637            if 2 > max_ordinal {
6638                return Ok(());
6639            }
6640
6641            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6642            // are envelope_size bytes.
6643            let cur_offset: usize = (2 - 1) * envelope_size;
6644
6645            // Zero reserved fields.
6646            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6647
6648            // Safety:
6649            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6650            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6651            //   envelope_size bytes, there is always sufficient room.
6652            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormatModifier, D>(
6653            self.pixel_format_modifier.as_ref().map(<fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow),
6654            encoder, offset + cur_offset, depth
6655        )?;
6656
6657            _prev_end_offset = cur_offset + envelope_size;
6658            if 3 > max_ordinal {
6659                return Ok(());
6660            }
6661
6662            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6663            // are envelope_size bytes.
6664            let cur_offset: usize = (3 - 1) * envelope_size;
6665
6666            // Zero reserved fields.
6667            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6668
6669            // Safety:
6670            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6671            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6672            //   envelope_size bytes, there is always sufficient room.
6673            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D>(
6674            self.color_spaces.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32> as fidl::encoding::ValueTypeMarker>::borrow),
6675            encoder, offset + cur_offset, depth
6676        )?;
6677
6678            _prev_end_offset = cur_offset + envelope_size;
6679            if 4 > max_ordinal {
6680                return Ok(());
6681            }
6682
6683            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6684            // are envelope_size bytes.
6685            let cur_offset: usize = (4 - 1) * envelope_size;
6686
6687            // Zero reserved fields.
6688            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6689
6690            // Safety:
6691            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6692            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6693            //   envelope_size bytes, there is always sufficient room.
6694            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6695                self.min_size.as_ref().map(
6696                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6697                ),
6698                encoder,
6699                offset + cur_offset,
6700                depth,
6701            )?;
6702
6703            _prev_end_offset = cur_offset + envelope_size;
6704            if 5 > max_ordinal {
6705                return Ok(());
6706            }
6707
6708            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6709            // are envelope_size bytes.
6710            let cur_offset: usize = (5 - 1) * envelope_size;
6711
6712            // Zero reserved fields.
6713            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6714
6715            // Safety:
6716            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6717            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6718            //   envelope_size bytes, there is always sufficient room.
6719            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6720                self.max_size.as_ref().map(
6721                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6722                ),
6723                encoder,
6724                offset + cur_offset,
6725                depth,
6726            )?;
6727
6728            _prev_end_offset = cur_offset + envelope_size;
6729            if 6 > max_ordinal {
6730                return Ok(());
6731            }
6732
6733            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6734            // are envelope_size bytes.
6735            let cur_offset: usize = (6 - 1) * envelope_size;
6736
6737            // Zero reserved fields.
6738            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6739
6740            // Safety:
6741            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6742            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6743            //   envelope_size bytes, there is always sufficient room.
6744            fidl::encoding::encode_in_envelope_optional::<u32, D>(
6745                self.min_bytes_per_row
6746                    .as_ref()
6747                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
6748                encoder,
6749                offset + cur_offset,
6750                depth,
6751            )?;
6752
6753            _prev_end_offset = cur_offset + envelope_size;
6754            if 7 > max_ordinal {
6755                return Ok(());
6756            }
6757
6758            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6759            // are envelope_size bytes.
6760            let cur_offset: usize = (7 - 1) * envelope_size;
6761
6762            // Zero reserved fields.
6763            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6764
6765            // Safety:
6766            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6767            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6768            //   envelope_size bytes, there is always sufficient room.
6769            fidl::encoding::encode_in_envelope_optional::<u32, D>(
6770                self.max_bytes_per_row
6771                    .as_ref()
6772                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
6773                encoder,
6774                offset + cur_offset,
6775                depth,
6776            )?;
6777
6778            _prev_end_offset = cur_offset + envelope_size;
6779            if 8 > max_ordinal {
6780                return Ok(());
6781            }
6782
6783            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6784            // are envelope_size bytes.
6785            let cur_offset: usize = (8 - 1) * envelope_size;
6786
6787            // Zero reserved fields.
6788            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6789
6790            // Safety:
6791            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6792            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6793            //   envelope_size bytes, there is always sufficient room.
6794            fidl::encoding::encode_in_envelope_optional::<u64, D>(
6795                self.max_width_times_height
6796                    .as_ref()
6797                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
6798                encoder,
6799                offset + cur_offset,
6800                depth,
6801            )?;
6802
6803            _prev_end_offset = cur_offset + envelope_size;
6804            if 9 > max_ordinal {
6805                return Ok(());
6806            }
6807
6808            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6809            // are envelope_size bytes.
6810            let cur_offset: usize = (9 - 1) * envelope_size;
6811
6812            // Zero reserved fields.
6813            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6814
6815            // Safety:
6816            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6817            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6818            //   envelope_size bytes, there is always sufficient room.
6819            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6820                self.size_alignment.as_ref().map(
6821                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6822                ),
6823                encoder,
6824                offset + cur_offset,
6825                depth,
6826            )?;
6827
6828            _prev_end_offset = cur_offset + envelope_size;
6829            if 10 > max_ordinal {
6830                return Ok(());
6831            }
6832
6833            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6834            // are envelope_size bytes.
6835            let cur_offset: usize = (10 - 1) * envelope_size;
6836
6837            // Zero reserved fields.
6838            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6839
6840            // Safety:
6841            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6842            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6843            //   envelope_size bytes, there is always sufficient room.
6844            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6845                self.display_rect_alignment.as_ref().map(
6846                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6847                ),
6848                encoder,
6849                offset + cur_offset,
6850                depth,
6851            )?;
6852
6853            _prev_end_offset = cur_offset + envelope_size;
6854            if 11 > max_ordinal {
6855                return Ok(());
6856            }
6857
6858            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6859            // are envelope_size bytes.
6860            let cur_offset: usize = (11 - 1) * envelope_size;
6861
6862            // Zero reserved fields.
6863            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6864
6865            // Safety:
6866            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6867            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6868            //   envelope_size bytes, there is always sufficient room.
6869            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6870                self.required_min_size.as_ref().map(
6871                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6872                ),
6873                encoder,
6874                offset + cur_offset,
6875                depth,
6876            )?;
6877
6878            _prev_end_offset = cur_offset + envelope_size;
6879            if 12 > max_ordinal {
6880                return Ok(());
6881            }
6882
6883            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6884            // are envelope_size bytes.
6885            let cur_offset: usize = (12 - 1) * envelope_size;
6886
6887            // Zero reserved fields.
6888            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6889
6890            // Safety:
6891            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6892            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6893            //   envelope_size bytes, there is always sufficient room.
6894            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6895                self.required_max_size.as_ref().map(
6896                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6897                ),
6898                encoder,
6899                offset + cur_offset,
6900                depth,
6901            )?;
6902
6903            _prev_end_offset = cur_offset + envelope_size;
6904            if 13 > max_ordinal {
6905                return Ok(());
6906            }
6907
6908            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6909            // are envelope_size bytes.
6910            let cur_offset: usize = (13 - 1) * envelope_size;
6911
6912            // Zero reserved fields.
6913            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6914
6915            // Safety:
6916            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6917            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6918            //   envelope_size bytes, there is always sufficient room.
6919            fidl::encoding::encode_in_envelope_optional::<u32, D>(
6920                self.bytes_per_row_divisor
6921                    .as_ref()
6922                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
6923                encoder,
6924                offset + cur_offset,
6925                depth,
6926            )?;
6927
6928            _prev_end_offset = cur_offset + envelope_size;
6929            if 14 > max_ordinal {
6930                return Ok(());
6931            }
6932
6933            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6934            // are envelope_size bytes.
6935            let cur_offset: usize = (14 - 1) * envelope_size;
6936
6937            // Zero reserved fields.
6938            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6939
6940            // Safety:
6941            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6942            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6943            //   envelope_size bytes, there is always sufficient room.
6944            fidl::encoding::encode_in_envelope_optional::<u32, D>(
6945                self.start_offset_divisor
6946                    .as_ref()
6947                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
6948                encoder,
6949                offset + cur_offset,
6950                depth,
6951            )?;
6952
6953            _prev_end_offset = cur_offset + envelope_size;
6954            if 15 > max_ordinal {
6955                return Ok(());
6956            }
6957
6958            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6959            // are envelope_size bytes.
6960            let cur_offset: usize = (15 - 1) * envelope_size;
6961
6962            // Zero reserved fields.
6963            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6964
6965            // Safety:
6966            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6967            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6968            //   envelope_size bytes, there is always sufficient room.
6969            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<PixelFormatAndModifier, 64>, D>(
6970            self.pixel_format_and_modifiers.as_ref().map(<fidl::encoding::Vector<PixelFormatAndModifier, 64> as fidl::encoding::ValueTypeMarker>::borrow),
6971            encoder, offset + cur_offset, depth
6972        )?;
6973
6974            _prev_end_offset = cur_offset + envelope_size;
6975            if 16 > max_ordinal {
6976                return Ok(());
6977            }
6978
6979            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6980            // are envelope_size bytes.
6981            let cur_offset: usize = (16 - 1) * envelope_size;
6982
6983            // Zero reserved fields.
6984            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6985
6986            // Safety:
6987            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6988            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6989            //   envelope_size bytes, there is always sufficient room.
6990            fidl::encoding::encode_in_envelope_optional::<bool, D>(
6991                self.require_bytes_per_row_at_pixel_boundary
6992                    .as_ref()
6993                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
6994                encoder,
6995                offset + cur_offset,
6996                depth,
6997            )?;
6998
6999            _prev_end_offset = cur_offset + envelope_size;
7000            if 17 > max_ordinal {
7001                return Ok(());
7002            }
7003
7004            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7005            // are envelope_size bytes.
7006            let cur_offset: usize = (17 - 1) * envelope_size;
7007
7008            // Zero reserved fields.
7009            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7010
7011            // Safety:
7012            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7013            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7014            //   envelope_size bytes, there is always sufficient room.
7015            fidl::encoding::encode_in_envelope_optional::<bool, D>(
7016                self.is_alpha_present
7017                    .as_ref()
7018                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
7019                encoder,
7020                offset + cur_offset,
7021                depth,
7022            )?;
7023
7024            _prev_end_offset = cur_offset + envelope_size;
7025            if 18 > max_ordinal {
7026                return Ok(());
7027            }
7028
7029            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7030            // are envelope_size bytes.
7031            let cur_offset: usize = (18 - 1) * envelope_size;
7032
7033            // Zero reserved fields.
7034            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7035
7036            // Safety:
7037            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7038            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7039            //   envelope_size bytes, there is always sufficient room.
7040            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D>(
7041            self.required_max_size_list.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64> as fidl::encoding::ValueTypeMarker>::borrow),
7042            encoder, offset + cur_offset, depth
7043        )?;
7044
7045            _prev_end_offset = cur_offset + envelope_size;
7046
7047            Ok(())
7048        }
7049    }
7050
7051    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
7052        for ImageFormatConstraints
7053    {
7054        #[inline(always)]
7055        fn new_empty() -> Self {
7056            Self::default()
7057        }
7058
7059        unsafe fn decode(
7060            &mut self,
7061            decoder: &mut fidl::encoding::Decoder<'_, D>,
7062            offset: usize,
7063            mut depth: fidl::encoding::Depth,
7064        ) -> fidl::Result<()> {
7065            decoder.debug_check_bounds::<Self>(offset);
7066            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7067                None => return Err(fidl::Error::NotNullable),
7068                Some(len) => len,
7069            };
7070            // Calling decoder.out_of_line_offset(0) is not allowed.
7071            if len == 0 {
7072                return Ok(());
7073            };
7074            depth.increment()?;
7075            let envelope_size = 8;
7076            let bytes_len = len * envelope_size;
7077            let offset = decoder.out_of_line_offset(bytes_len)?;
7078            // Decode the envelope for each type.
7079            let mut _next_ordinal_to_read = 0;
7080            let mut next_offset = offset;
7081            let end_offset = offset + bytes_len;
7082            _next_ordinal_to_read += 1;
7083            if next_offset >= end_offset {
7084                return Ok(());
7085            }
7086
7087            // Decode unknown envelopes for gaps in ordinals.
7088            while _next_ordinal_to_read < 1 {
7089                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7090                _next_ordinal_to_read += 1;
7091                next_offset += envelope_size;
7092            }
7093
7094            let next_out_of_line = decoder.next_out_of_line();
7095            let handles_before = decoder.remaining_handles();
7096            if let Some((inlined, num_bytes, num_handles)) =
7097                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7098            {
7099                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7100                if inlined != (member_inline_size <= 4) {
7101                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7102                }
7103                let inner_offset;
7104                let mut inner_depth = depth.clone();
7105                if inlined {
7106                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7107                    inner_offset = next_offset;
7108                } else {
7109                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7110                    inner_depth.increment()?;
7111                }
7112                let val_ref = self.pixel_format.get_or_insert_with(|| {
7113                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D)
7114                });
7115                fidl::decode!(
7116                    fidl_fuchsia_images2__common::PixelFormat,
7117                    D,
7118                    val_ref,
7119                    decoder,
7120                    inner_offset,
7121                    inner_depth
7122                )?;
7123                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7124                {
7125                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7126                }
7127                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7128                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7129                }
7130            }
7131
7132            next_offset += envelope_size;
7133            _next_ordinal_to_read += 1;
7134            if next_offset >= end_offset {
7135                return Ok(());
7136            }
7137
7138            // Decode unknown envelopes for gaps in ordinals.
7139            while _next_ordinal_to_read < 2 {
7140                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7141                _next_ordinal_to_read += 1;
7142                next_offset += envelope_size;
7143            }
7144
7145            let next_out_of_line = decoder.next_out_of_line();
7146            let handles_before = decoder.remaining_handles();
7147            if let Some((inlined, num_bytes, num_handles)) =
7148                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7149            {
7150                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7151                if inlined != (member_inline_size <= 4) {
7152                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7153                }
7154                let inner_offset;
7155                let mut inner_depth = depth.clone();
7156                if inlined {
7157                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7158                    inner_offset = next_offset;
7159                } else {
7160                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7161                    inner_depth.increment()?;
7162                }
7163                let val_ref = self.pixel_format_modifier.get_or_insert_with(|| {
7164                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormatModifier, D)
7165                });
7166                fidl::decode!(
7167                    fidl_fuchsia_images2__common::PixelFormatModifier,
7168                    D,
7169                    val_ref,
7170                    decoder,
7171                    inner_offset,
7172                    inner_depth
7173                )?;
7174                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7175                {
7176                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7177                }
7178                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7179                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7180                }
7181            }
7182
7183            next_offset += envelope_size;
7184            _next_ordinal_to_read += 1;
7185            if next_offset >= end_offset {
7186                return Ok(());
7187            }
7188
7189            // Decode unknown envelopes for gaps in ordinals.
7190            while _next_ordinal_to_read < 3 {
7191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7192                _next_ordinal_to_read += 1;
7193                next_offset += envelope_size;
7194            }
7195
7196            let next_out_of_line = decoder.next_out_of_line();
7197            let handles_before = decoder.remaining_handles();
7198            if let Some((inlined, num_bytes, num_handles)) =
7199                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7200            {
7201                let member_inline_size = <fidl::encoding::Vector<
7202                    fidl_fuchsia_images2__common::ColorSpace,
7203                    32,
7204                > as fidl::encoding::TypeMarker>::inline_size(
7205                    decoder.context
7206                );
7207                if inlined != (member_inline_size <= 4) {
7208                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7209                }
7210                let inner_offset;
7211                let mut inner_depth = depth.clone();
7212                if inlined {
7213                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7214                    inner_offset = next_offset;
7215                } else {
7216                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7217                    inner_depth.increment()?;
7218                }
7219                let val_ref =
7220                self.color_spaces.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D));
7221                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
7222                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7223                {
7224                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7225                }
7226                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7227                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7228                }
7229            }
7230
7231            next_offset += envelope_size;
7232            _next_ordinal_to_read += 1;
7233            if next_offset >= end_offset {
7234                return Ok(());
7235            }
7236
7237            // Decode unknown envelopes for gaps in ordinals.
7238            while _next_ordinal_to_read < 4 {
7239                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7240                _next_ordinal_to_read += 1;
7241                next_offset += envelope_size;
7242            }
7243
7244            let next_out_of_line = decoder.next_out_of_line();
7245            let handles_before = decoder.remaining_handles();
7246            if let Some((inlined, num_bytes, num_handles)) =
7247                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7248            {
7249                let member_inline_size =
7250                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7251                        decoder.context,
7252                    );
7253                if inlined != (member_inline_size <= 4) {
7254                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7255                }
7256                let inner_offset;
7257                let mut inner_depth = depth.clone();
7258                if inlined {
7259                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7260                    inner_offset = next_offset;
7261                } else {
7262                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7263                    inner_depth.increment()?;
7264                }
7265                let val_ref = self
7266                    .min_size
7267                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7268                fidl::decode!(
7269                    fidl_fuchsia_math__common::SizeU,
7270                    D,
7271                    val_ref,
7272                    decoder,
7273                    inner_offset,
7274                    inner_depth
7275                )?;
7276                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7277                {
7278                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7279                }
7280                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7281                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7282                }
7283            }
7284
7285            next_offset += envelope_size;
7286            _next_ordinal_to_read += 1;
7287            if next_offset >= end_offset {
7288                return Ok(());
7289            }
7290
7291            // Decode unknown envelopes for gaps in ordinals.
7292            while _next_ordinal_to_read < 5 {
7293                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7294                _next_ordinal_to_read += 1;
7295                next_offset += envelope_size;
7296            }
7297
7298            let next_out_of_line = decoder.next_out_of_line();
7299            let handles_before = decoder.remaining_handles();
7300            if let Some((inlined, num_bytes, num_handles)) =
7301                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7302            {
7303                let member_inline_size =
7304                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7305                        decoder.context,
7306                    );
7307                if inlined != (member_inline_size <= 4) {
7308                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7309                }
7310                let inner_offset;
7311                let mut inner_depth = depth.clone();
7312                if inlined {
7313                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7314                    inner_offset = next_offset;
7315                } else {
7316                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7317                    inner_depth.increment()?;
7318                }
7319                let val_ref = self
7320                    .max_size
7321                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7322                fidl::decode!(
7323                    fidl_fuchsia_math__common::SizeU,
7324                    D,
7325                    val_ref,
7326                    decoder,
7327                    inner_offset,
7328                    inner_depth
7329                )?;
7330                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7331                {
7332                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7333                }
7334                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7335                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7336                }
7337            }
7338
7339            next_offset += envelope_size;
7340            _next_ordinal_to_read += 1;
7341            if next_offset >= end_offset {
7342                return Ok(());
7343            }
7344
7345            // Decode unknown envelopes for gaps in ordinals.
7346            while _next_ordinal_to_read < 6 {
7347                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7348                _next_ordinal_to_read += 1;
7349                next_offset += envelope_size;
7350            }
7351
7352            let next_out_of_line = decoder.next_out_of_line();
7353            let handles_before = decoder.remaining_handles();
7354            if let Some((inlined, num_bytes, num_handles)) =
7355                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7356            {
7357                let member_inline_size =
7358                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7359                if inlined != (member_inline_size <= 4) {
7360                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7361                }
7362                let inner_offset;
7363                let mut inner_depth = depth.clone();
7364                if inlined {
7365                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7366                    inner_offset = next_offset;
7367                } else {
7368                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7369                    inner_depth.increment()?;
7370                }
7371                let val_ref =
7372                    self.min_bytes_per_row.get_or_insert_with(|| fidl::new_empty!(u32, D));
7373                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7374                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7375                {
7376                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7377                }
7378                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7379                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7380                }
7381            }
7382
7383            next_offset += envelope_size;
7384            _next_ordinal_to_read += 1;
7385            if next_offset >= end_offset {
7386                return Ok(());
7387            }
7388
7389            // Decode unknown envelopes for gaps in ordinals.
7390            while _next_ordinal_to_read < 7 {
7391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7392                _next_ordinal_to_read += 1;
7393                next_offset += envelope_size;
7394            }
7395
7396            let next_out_of_line = decoder.next_out_of_line();
7397            let handles_before = decoder.remaining_handles();
7398            if let Some((inlined, num_bytes, num_handles)) =
7399                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7400            {
7401                let member_inline_size =
7402                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7403                if inlined != (member_inline_size <= 4) {
7404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7405                }
7406                let inner_offset;
7407                let mut inner_depth = depth.clone();
7408                if inlined {
7409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7410                    inner_offset = next_offset;
7411                } else {
7412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7413                    inner_depth.increment()?;
7414                }
7415                let val_ref =
7416                    self.max_bytes_per_row.get_or_insert_with(|| fidl::new_empty!(u32, D));
7417                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7418                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7419                {
7420                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7421                }
7422                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7423                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7424                }
7425            }
7426
7427            next_offset += envelope_size;
7428            _next_ordinal_to_read += 1;
7429            if next_offset >= end_offset {
7430                return Ok(());
7431            }
7432
7433            // Decode unknown envelopes for gaps in ordinals.
7434            while _next_ordinal_to_read < 8 {
7435                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7436                _next_ordinal_to_read += 1;
7437                next_offset += envelope_size;
7438            }
7439
7440            let next_out_of_line = decoder.next_out_of_line();
7441            let handles_before = decoder.remaining_handles();
7442            if let Some((inlined, num_bytes, num_handles)) =
7443                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7444            {
7445                let member_inline_size =
7446                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7447                if inlined != (member_inline_size <= 4) {
7448                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7449                }
7450                let inner_offset;
7451                let mut inner_depth = depth.clone();
7452                if inlined {
7453                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7454                    inner_offset = next_offset;
7455                } else {
7456                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7457                    inner_depth.increment()?;
7458                }
7459                let val_ref =
7460                    self.max_width_times_height.get_or_insert_with(|| fidl::new_empty!(u64, D));
7461                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
7462                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7463                {
7464                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7465                }
7466                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7467                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7468                }
7469            }
7470
7471            next_offset += envelope_size;
7472            _next_ordinal_to_read += 1;
7473            if next_offset >= end_offset {
7474                return Ok(());
7475            }
7476
7477            // Decode unknown envelopes for gaps in ordinals.
7478            while _next_ordinal_to_read < 9 {
7479                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7480                _next_ordinal_to_read += 1;
7481                next_offset += envelope_size;
7482            }
7483
7484            let next_out_of_line = decoder.next_out_of_line();
7485            let handles_before = decoder.remaining_handles();
7486            if let Some((inlined, num_bytes, num_handles)) =
7487                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7488            {
7489                let member_inline_size =
7490                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7491                        decoder.context,
7492                    );
7493                if inlined != (member_inline_size <= 4) {
7494                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7495                }
7496                let inner_offset;
7497                let mut inner_depth = depth.clone();
7498                if inlined {
7499                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7500                    inner_offset = next_offset;
7501                } else {
7502                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7503                    inner_depth.increment()?;
7504                }
7505                let val_ref = self
7506                    .size_alignment
7507                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7508                fidl::decode!(
7509                    fidl_fuchsia_math__common::SizeU,
7510                    D,
7511                    val_ref,
7512                    decoder,
7513                    inner_offset,
7514                    inner_depth
7515                )?;
7516                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7517                {
7518                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7519                }
7520                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7521                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7522                }
7523            }
7524
7525            next_offset += envelope_size;
7526            _next_ordinal_to_read += 1;
7527            if next_offset >= end_offset {
7528                return Ok(());
7529            }
7530
7531            // Decode unknown envelopes for gaps in ordinals.
7532            while _next_ordinal_to_read < 10 {
7533                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7534                _next_ordinal_to_read += 1;
7535                next_offset += envelope_size;
7536            }
7537
7538            let next_out_of_line = decoder.next_out_of_line();
7539            let handles_before = decoder.remaining_handles();
7540            if let Some((inlined, num_bytes, num_handles)) =
7541                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7542            {
7543                let member_inline_size =
7544                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7545                        decoder.context,
7546                    );
7547                if inlined != (member_inline_size <= 4) {
7548                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7549                }
7550                let inner_offset;
7551                let mut inner_depth = depth.clone();
7552                if inlined {
7553                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7554                    inner_offset = next_offset;
7555                } else {
7556                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7557                    inner_depth.increment()?;
7558                }
7559                let val_ref = self
7560                    .display_rect_alignment
7561                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7562                fidl::decode!(
7563                    fidl_fuchsia_math__common::SizeU,
7564                    D,
7565                    val_ref,
7566                    decoder,
7567                    inner_offset,
7568                    inner_depth
7569                )?;
7570                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7571                {
7572                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7573                }
7574                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7575                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7576                }
7577            }
7578
7579            next_offset += envelope_size;
7580            _next_ordinal_to_read += 1;
7581            if next_offset >= end_offset {
7582                return Ok(());
7583            }
7584
7585            // Decode unknown envelopes for gaps in ordinals.
7586            while _next_ordinal_to_read < 11 {
7587                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7588                _next_ordinal_to_read += 1;
7589                next_offset += envelope_size;
7590            }
7591
7592            let next_out_of_line = decoder.next_out_of_line();
7593            let handles_before = decoder.remaining_handles();
7594            if let Some((inlined, num_bytes, num_handles)) =
7595                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7596            {
7597                let member_inline_size =
7598                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7599                        decoder.context,
7600                    );
7601                if inlined != (member_inline_size <= 4) {
7602                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7603                }
7604                let inner_offset;
7605                let mut inner_depth = depth.clone();
7606                if inlined {
7607                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7608                    inner_offset = next_offset;
7609                } else {
7610                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7611                    inner_depth.increment()?;
7612                }
7613                let val_ref = self
7614                    .required_min_size
7615                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7616                fidl::decode!(
7617                    fidl_fuchsia_math__common::SizeU,
7618                    D,
7619                    val_ref,
7620                    decoder,
7621                    inner_offset,
7622                    inner_depth
7623                )?;
7624                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7625                {
7626                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7627                }
7628                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7629                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7630                }
7631            }
7632
7633            next_offset += envelope_size;
7634            _next_ordinal_to_read += 1;
7635            if next_offset >= end_offset {
7636                return Ok(());
7637            }
7638
7639            // Decode unknown envelopes for gaps in ordinals.
7640            while _next_ordinal_to_read < 12 {
7641                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7642                _next_ordinal_to_read += 1;
7643                next_offset += envelope_size;
7644            }
7645
7646            let next_out_of_line = decoder.next_out_of_line();
7647            let handles_before = decoder.remaining_handles();
7648            if let Some((inlined, num_bytes, num_handles)) =
7649                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7650            {
7651                let member_inline_size =
7652                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7653                        decoder.context,
7654                    );
7655                if inlined != (member_inline_size <= 4) {
7656                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7657                }
7658                let inner_offset;
7659                let mut inner_depth = depth.clone();
7660                if inlined {
7661                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7662                    inner_offset = next_offset;
7663                } else {
7664                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7665                    inner_depth.increment()?;
7666                }
7667                let val_ref = self
7668                    .required_max_size
7669                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7670                fidl::decode!(
7671                    fidl_fuchsia_math__common::SizeU,
7672                    D,
7673                    val_ref,
7674                    decoder,
7675                    inner_offset,
7676                    inner_depth
7677                )?;
7678                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7679                {
7680                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7681                }
7682                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7683                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7684                }
7685            }
7686
7687            next_offset += envelope_size;
7688            _next_ordinal_to_read += 1;
7689            if next_offset >= end_offset {
7690                return Ok(());
7691            }
7692
7693            // Decode unknown envelopes for gaps in ordinals.
7694            while _next_ordinal_to_read < 13 {
7695                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7696                _next_ordinal_to_read += 1;
7697                next_offset += envelope_size;
7698            }
7699
7700            let next_out_of_line = decoder.next_out_of_line();
7701            let handles_before = decoder.remaining_handles();
7702            if let Some((inlined, num_bytes, num_handles)) =
7703                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7704            {
7705                let member_inline_size =
7706                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7707                if inlined != (member_inline_size <= 4) {
7708                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7709                }
7710                let inner_offset;
7711                let mut inner_depth = depth.clone();
7712                if inlined {
7713                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7714                    inner_offset = next_offset;
7715                } else {
7716                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7717                    inner_depth.increment()?;
7718                }
7719                let val_ref =
7720                    self.bytes_per_row_divisor.get_or_insert_with(|| fidl::new_empty!(u32, D));
7721                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7722                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7723                {
7724                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7725                }
7726                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7727                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7728                }
7729            }
7730
7731            next_offset += envelope_size;
7732            _next_ordinal_to_read += 1;
7733            if next_offset >= end_offset {
7734                return Ok(());
7735            }
7736
7737            // Decode unknown envelopes for gaps in ordinals.
7738            while _next_ordinal_to_read < 14 {
7739                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7740                _next_ordinal_to_read += 1;
7741                next_offset += envelope_size;
7742            }
7743
7744            let next_out_of_line = decoder.next_out_of_line();
7745            let handles_before = decoder.remaining_handles();
7746            if let Some((inlined, num_bytes, num_handles)) =
7747                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7748            {
7749                let member_inline_size =
7750                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7751                if inlined != (member_inline_size <= 4) {
7752                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7753                }
7754                let inner_offset;
7755                let mut inner_depth = depth.clone();
7756                if inlined {
7757                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7758                    inner_offset = next_offset;
7759                } else {
7760                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7761                    inner_depth.increment()?;
7762                }
7763                let val_ref =
7764                    self.start_offset_divisor.get_or_insert_with(|| fidl::new_empty!(u32, D));
7765                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7766                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7767                {
7768                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7769                }
7770                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7771                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7772                }
7773            }
7774
7775            next_offset += envelope_size;
7776            _next_ordinal_to_read += 1;
7777            if next_offset >= end_offset {
7778                return Ok(());
7779            }
7780
7781            // Decode unknown envelopes for gaps in ordinals.
7782            while _next_ordinal_to_read < 15 {
7783                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7784                _next_ordinal_to_read += 1;
7785                next_offset += envelope_size;
7786            }
7787
7788            let next_out_of_line = decoder.next_out_of_line();
7789            let handles_before = decoder.remaining_handles();
7790            if let Some((inlined, num_bytes, num_handles)) =
7791                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7792            {
7793                let member_inline_size = <fidl::encoding::Vector<PixelFormatAndModifier, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7794                if inlined != (member_inline_size <= 4) {
7795                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7796                }
7797                let inner_offset;
7798                let mut inner_depth = depth.clone();
7799                if inlined {
7800                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7801                    inner_offset = next_offset;
7802                } else {
7803                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7804                    inner_depth.increment()?;
7805                }
7806                let val_ref = self.pixel_format_and_modifiers.get_or_insert_with(
7807                    || fidl::new_empty!(fidl::encoding::Vector<PixelFormatAndModifier, 64>, D),
7808                );
7809                fidl::decode!(fidl::encoding::Vector<PixelFormatAndModifier, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
7810                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7811                {
7812                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7813                }
7814                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7815                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7816                }
7817            }
7818
7819            next_offset += envelope_size;
7820            _next_ordinal_to_read += 1;
7821            if next_offset >= end_offset {
7822                return Ok(());
7823            }
7824
7825            // Decode unknown envelopes for gaps in ordinals.
7826            while _next_ordinal_to_read < 16 {
7827                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7828                _next_ordinal_to_read += 1;
7829                next_offset += envelope_size;
7830            }
7831
7832            let next_out_of_line = decoder.next_out_of_line();
7833            let handles_before = decoder.remaining_handles();
7834            if let Some((inlined, num_bytes, num_handles)) =
7835                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7836            {
7837                let member_inline_size =
7838                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7839                if inlined != (member_inline_size <= 4) {
7840                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7841                }
7842                let inner_offset;
7843                let mut inner_depth = depth.clone();
7844                if inlined {
7845                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7846                    inner_offset = next_offset;
7847                } else {
7848                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7849                    inner_depth.increment()?;
7850                }
7851                let val_ref = self
7852                    .require_bytes_per_row_at_pixel_boundary
7853                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
7854                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
7855                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7856                {
7857                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7858                }
7859                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7860                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7861                }
7862            }
7863
7864            next_offset += envelope_size;
7865            _next_ordinal_to_read += 1;
7866            if next_offset >= end_offset {
7867                return Ok(());
7868            }
7869
7870            // Decode unknown envelopes for gaps in ordinals.
7871            while _next_ordinal_to_read < 17 {
7872                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7873                _next_ordinal_to_read += 1;
7874                next_offset += envelope_size;
7875            }
7876
7877            let next_out_of_line = decoder.next_out_of_line();
7878            let handles_before = decoder.remaining_handles();
7879            if let Some((inlined, num_bytes, num_handles)) =
7880                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7881            {
7882                let member_inline_size =
7883                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7884                if inlined != (member_inline_size <= 4) {
7885                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7886                }
7887                let inner_offset;
7888                let mut inner_depth = depth.clone();
7889                if inlined {
7890                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7891                    inner_offset = next_offset;
7892                } else {
7893                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7894                    inner_depth.increment()?;
7895                }
7896                let val_ref =
7897                    self.is_alpha_present.get_or_insert_with(|| fidl::new_empty!(bool, D));
7898                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
7899                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7900                {
7901                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7902                }
7903                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7904                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7905                }
7906            }
7907
7908            next_offset += envelope_size;
7909            _next_ordinal_to_read += 1;
7910            if next_offset >= end_offset {
7911                return Ok(());
7912            }
7913
7914            // Decode unknown envelopes for gaps in ordinals.
7915            while _next_ordinal_to_read < 18 {
7916                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7917                _next_ordinal_to_read += 1;
7918                next_offset += envelope_size;
7919            }
7920
7921            let next_out_of_line = decoder.next_out_of_line();
7922            let handles_before = decoder.remaining_handles();
7923            if let Some((inlined, num_bytes, num_handles)) =
7924                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7925            {
7926                let member_inline_size = <fidl::encoding::Vector<
7927                    fidl_fuchsia_math__common::SizeU,
7928                    64,
7929                > as fidl::encoding::TypeMarker>::inline_size(
7930                    decoder.context
7931                );
7932                if inlined != (member_inline_size <= 4) {
7933                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7934                }
7935                let inner_offset;
7936                let mut inner_depth = depth.clone();
7937                if inlined {
7938                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7939                    inner_offset = next_offset;
7940                } else {
7941                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7942                    inner_depth.increment()?;
7943                }
7944                let val_ref =
7945                self.required_max_size_list.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D));
7946                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
7947                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7948                {
7949                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7950                }
7951                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7952                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7953                }
7954            }
7955
7956            next_offset += envelope_size;
7957
7958            // Decode the remaining unknown envelopes.
7959            while next_offset < end_offset {
7960                _next_ordinal_to_read += 1;
7961                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7962                next_offset += envelope_size;
7963            }
7964
7965            Ok(())
7966        }
7967    }
7968
7969    impl NodeSetDebugClientInfoRequest {
7970        #[inline(always)]
7971        fn max_ordinal_present(&self) -> u64 {
7972            if let Some(_) = self.id {
7973                return 2;
7974            }
7975            if let Some(_) = self.name {
7976                return 1;
7977            }
7978            0
7979        }
7980    }
7981
7982    impl fidl::encoding::ValueTypeMarker for NodeSetDebugClientInfoRequest {
7983        type Borrowed<'a> = &'a Self;
7984        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
7985            value
7986        }
7987    }
7988
7989    unsafe impl fidl::encoding::TypeMarker for NodeSetDebugClientInfoRequest {
7990        type Owned = Self;
7991
7992        #[inline(always)]
7993        fn inline_align(_context: fidl::encoding::Context) -> usize {
7994            8
7995        }
7996
7997        #[inline(always)]
7998        fn inline_size(_context: fidl::encoding::Context) -> usize {
7999            16
8000        }
8001    }
8002
8003    unsafe impl<D: fidl::encoding::ResourceDialect>
8004        fidl::encoding::Encode<NodeSetDebugClientInfoRequest, D>
8005        for &NodeSetDebugClientInfoRequest
8006    {
8007        unsafe fn encode(
8008            self,
8009            encoder: &mut fidl::encoding::Encoder<'_, D>,
8010            offset: usize,
8011            mut depth: fidl::encoding::Depth,
8012        ) -> fidl::Result<()> {
8013            encoder.debug_check_bounds::<NodeSetDebugClientInfoRequest>(offset);
8014            // Vector header
8015            let max_ordinal: u64 = self.max_ordinal_present();
8016            encoder.write_num(max_ordinal, offset);
8017            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8018            // Calling encoder.out_of_line_offset(0) is not allowed.
8019            if max_ordinal == 0 {
8020                return Ok(());
8021            }
8022            depth.increment()?;
8023            let envelope_size = 8;
8024            let bytes_len = max_ordinal as usize * envelope_size;
8025            #[allow(unused_variables)]
8026            let offset = encoder.out_of_line_offset(bytes_len);
8027            let mut _prev_end_offset: usize = 0;
8028            if 1 > max_ordinal {
8029                return Ok(());
8030            }
8031
8032            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8033            // are envelope_size bytes.
8034            let cur_offset: usize = (1 - 1) * envelope_size;
8035
8036            // Zero reserved fields.
8037            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8038
8039            // Safety:
8040            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8041            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8042            //   envelope_size bytes, there is always sufficient room.
8043            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
8044                self.name.as_ref().map(
8045                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
8046                ),
8047                encoder,
8048                offset + cur_offset,
8049                depth,
8050            )?;
8051
8052            _prev_end_offset = cur_offset + envelope_size;
8053            if 2 > max_ordinal {
8054                return Ok(());
8055            }
8056
8057            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8058            // are envelope_size bytes.
8059            let cur_offset: usize = (2 - 1) * envelope_size;
8060
8061            // Zero reserved fields.
8062            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8063
8064            // Safety:
8065            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8066            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8067            //   envelope_size bytes, there is always sufficient room.
8068            fidl::encoding::encode_in_envelope_optional::<u64, D>(
8069                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8070                encoder,
8071                offset + cur_offset,
8072                depth,
8073            )?;
8074
8075            _prev_end_offset = cur_offset + envelope_size;
8076
8077            Ok(())
8078        }
8079    }
8080
8081    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8082        for NodeSetDebugClientInfoRequest
8083    {
8084        #[inline(always)]
8085        fn new_empty() -> Self {
8086            Self::default()
8087        }
8088
8089        unsafe fn decode(
8090            &mut self,
8091            decoder: &mut fidl::encoding::Decoder<'_, D>,
8092            offset: usize,
8093            mut depth: fidl::encoding::Depth,
8094        ) -> fidl::Result<()> {
8095            decoder.debug_check_bounds::<Self>(offset);
8096            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8097                None => return Err(fidl::Error::NotNullable),
8098                Some(len) => len,
8099            };
8100            // Calling decoder.out_of_line_offset(0) is not allowed.
8101            if len == 0 {
8102                return Ok(());
8103            };
8104            depth.increment()?;
8105            let envelope_size = 8;
8106            let bytes_len = len * envelope_size;
8107            let offset = decoder.out_of_line_offset(bytes_len)?;
8108            // Decode the envelope for each type.
8109            let mut _next_ordinal_to_read = 0;
8110            let mut next_offset = offset;
8111            let end_offset = offset + bytes_len;
8112            _next_ordinal_to_read += 1;
8113            if next_offset >= end_offset {
8114                return Ok(());
8115            }
8116
8117            // Decode unknown envelopes for gaps in ordinals.
8118            while _next_ordinal_to_read < 1 {
8119                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8120                _next_ordinal_to_read += 1;
8121                next_offset += envelope_size;
8122            }
8123
8124            let next_out_of_line = decoder.next_out_of_line();
8125            let handles_before = decoder.remaining_handles();
8126            if let Some((inlined, num_bytes, num_handles)) =
8127                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8128            {
8129                let member_inline_size =
8130                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
8131                        decoder.context,
8132                    );
8133                if inlined != (member_inline_size <= 4) {
8134                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8135                }
8136                let inner_offset;
8137                let mut inner_depth = depth.clone();
8138                if inlined {
8139                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8140                    inner_offset = next_offset;
8141                } else {
8142                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8143                    inner_depth.increment()?;
8144                }
8145                let val_ref = self
8146                    .name
8147                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
8148                fidl::decode!(
8149                    fidl::encoding::BoundedString<256>,
8150                    D,
8151                    val_ref,
8152                    decoder,
8153                    inner_offset,
8154                    inner_depth
8155                )?;
8156                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8157                {
8158                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8159                }
8160                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8161                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8162                }
8163            }
8164
8165            next_offset += envelope_size;
8166            _next_ordinal_to_read += 1;
8167            if next_offset >= end_offset {
8168                return Ok(());
8169            }
8170
8171            // Decode unknown envelopes for gaps in ordinals.
8172            while _next_ordinal_to_read < 2 {
8173                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8174                _next_ordinal_to_read += 1;
8175                next_offset += envelope_size;
8176            }
8177
8178            let next_out_of_line = decoder.next_out_of_line();
8179            let handles_before = decoder.remaining_handles();
8180            if let Some((inlined, num_bytes, num_handles)) =
8181                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8182            {
8183                let member_inline_size =
8184                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8185                if inlined != (member_inline_size <= 4) {
8186                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8187                }
8188                let inner_offset;
8189                let mut inner_depth = depth.clone();
8190                if inlined {
8191                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8192                    inner_offset = next_offset;
8193                } else {
8194                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8195                    inner_depth.increment()?;
8196                }
8197                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
8198                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
8199                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8200                {
8201                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8202                }
8203                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8204                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8205                }
8206            }
8207
8208            next_offset += envelope_size;
8209
8210            // Decode the remaining unknown envelopes.
8211            while next_offset < end_offset {
8212                _next_ordinal_to_read += 1;
8213                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8214                next_offset += envelope_size;
8215            }
8216
8217            Ok(())
8218        }
8219    }
8220
8221    impl NodeSetDebugTimeoutLogDeadlineRequest {
8222        #[inline(always)]
8223        fn max_ordinal_present(&self) -> u64 {
8224            if let Some(_) = self.deadline {
8225                return 1;
8226            }
8227            0
8228        }
8229    }
8230
8231    impl fidl::encoding::ValueTypeMarker for NodeSetDebugTimeoutLogDeadlineRequest {
8232        type Borrowed<'a> = &'a Self;
8233        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8234            value
8235        }
8236    }
8237
8238    unsafe impl fidl::encoding::TypeMarker for NodeSetDebugTimeoutLogDeadlineRequest {
8239        type Owned = Self;
8240
8241        #[inline(always)]
8242        fn inline_align(_context: fidl::encoding::Context) -> usize {
8243            8
8244        }
8245
8246        #[inline(always)]
8247        fn inline_size(_context: fidl::encoding::Context) -> usize {
8248            16
8249        }
8250    }
8251
8252    unsafe impl<D: fidl::encoding::ResourceDialect>
8253        fidl::encoding::Encode<NodeSetDebugTimeoutLogDeadlineRequest, D>
8254        for &NodeSetDebugTimeoutLogDeadlineRequest
8255    {
8256        unsafe fn encode(
8257            self,
8258            encoder: &mut fidl::encoding::Encoder<'_, D>,
8259            offset: usize,
8260            mut depth: fidl::encoding::Depth,
8261        ) -> fidl::Result<()> {
8262            encoder.debug_check_bounds::<NodeSetDebugTimeoutLogDeadlineRequest>(offset);
8263            // Vector header
8264            let max_ordinal: u64 = self.max_ordinal_present();
8265            encoder.write_num(max_ordinal, offset);
8266            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8267            // Calling encoder.out_of_line_offset(0) is not allowed.
8268            if max_ordinal == 0 {
8269                return Ok(());
8270            }
8271            depth.increment()?;
8272            let envelope_size = 8;
8273            let bytes_len = max_ordinal as usize * envelope_size;
8274            #[allow(unused_variables)]
8275            let offset = encoder.out_of_line_offset(bytes_len);
8276            let mut _prev_end_offset: usize = 0;
8277            if 1 > max_ordinal {
8278                return Ok(());
8279            }
8280
8281            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8282            // are envelope_size bytes.
8283            let cur_offset: usize = (1 - 1) * envelope_size;
8284
8285            // Zero reserved fields.
8286            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8287
8288            // Safety:
8289            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8290            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8291            //   envelope_size bytes, there is always sufficient room.
8292            fidl::encoding::encode_in_envelope_optional::<i64, D>(
8293                self.deadline.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
8294                encoder,
8295                offset + cur_offset,
8296                depth,
8297            )?;
8298
8299            _prev_end_offset = cur_offset + envelope_size;
8300
8301            Ok(())
8302        }
8303    }
8304
8305    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8306        for NodeSetDebugTimeoutLogDeadlineRequest
8307    {
8308        #[inline(always)]
8309        fn new_empty() -> Self {
8310            Self::default()
8311        }
8312
8313        unsafe fn decode(
8314            &mut self,
8315            decoder: &mut fidl::encoding::Decoder<'_, D>,
8316            offset: usize,
8317            mut depth: fidl::encoding::Depth,
8318        ) -> fidl::Result<()> {
8319            decoder.debug_check_bounds::<Self>(offset);
8320            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8321                None => return Err(fidl::Error::NotNullable),
8322                Some(len) => len,
8323            };
8324            // Calling decoder.out_of_line_offset(0) is not allowed.
8325            if len == 0 {
8326                return Ok(());
8327            };
8328            depth.increment()?;
8329            let envelope_size = 8;
8330            let bytes_len = len * envelope_size;
8331            let offset = decoder.out_of_line_offset(bytes_len)?;
8332            // Decode the envelope for each type.
8333            let mut _next_ordinal_to_read = 0;
8334            let mut next_offset = offset;
8335            let end_offset = offset + bytes_len;
8336            _next_ordinal_to_read += 1;
8337            if next_offset >= end_offset {
8338                return Ok(());
8339            }
8340
8341            // Decode unknown envelopes for gaps in ordinals.
8342            while _next_ordinal_to_read < 1 {
8343                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8344                _next_ordinal_to_read += 1;
8345                next_offset += envelope_size;
8346            }
8347
8348            let next_out_of_line = decoder.next_out_of_line();
8349            let handles_before = decoder.remaining_handles();
8350            if let Some((inlined, num_bytes, num_handles)) =
8351                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8352            {
8353                let member_inline_size =
8354                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8355                if inlined != (member_inline_size <= 4) {
8356                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8357                }
8358                let inner_offset;
8359                let mut inner_depth = depth.clone();
8360                if inlined {
8361                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8362                    inner_offset = next_offset;
8363                } else {
8364                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8365                    inner_depth.increment()?;
8366                }
8367                let val_ref = self.deadline.get_or_insert_with(|| fidl::new_empty!(i64, D));
8368                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
8369                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8370                {
8371                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8372                }
8373                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8374                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8375                }
8376            }
8377
8378            next_offset += envelope_size;
8379
8380            // Decode the remaining unknown envelopes.
8381            while next_offset < end_offset {
8382                _next_ordinal_to_read += 1;
8383                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8384                next_offset += envelope_size;
8385            }
8386
8387            Ok(())
8388        }
8389    }
8390
8391    impl NodeSetNameRequest {
8392        #[inline(always)]
8393        fn max_ordinal_present(&self) -> u64 {
8394            if let Some(_) = self.name {
8395                return 2;
8396            }
8397            if let Some(_) = self.priority {
8398                return 1;
8399            }
8400            0
8401        }
8402    }
8403
8404    impl fidl::encoding::ValueTypeMarker for NodeSetNameRequest {
8405        type Borrowed<'a> = &'a Self;
8406        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8407            value
8408        }
8409    }
8410
8411    unsafe impl fidl::encoding::TypeMarker for NodeSetNameRequest {
8412        type Owned = Self;
8413
8414        #[inline(always)]
8415        fn inline_align(_context: fidl::encoding::Context) -> usize {
8416            8
8417        }
8418
8419        #[inline(always)]
8420        fn inline_size(_context: fidl::encoding::Context) -> usize {
8421            16
8422        }
8423    }
8424
8425    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NodeSetNameRequest, D>
8426        for &NodeSetNameRequest
8427    {
8428        unsafe fn encode(
8429            self,
8430            encoder: &mut fidl::encoding::Encoder<'_, D>,
8431            offset: usize,
8432            mut depth: fidl::encoding::Depth,
8433        ) -> fidl::Result<()> {
8434            encoder.debug_check_bounds::<NodeSetNameRequest>(offset);
8435            // Vector header
8436            let max_ordinal: u64 = self.max_ordinal_present();
8437            encoder.write_num(max_ordinal, offset);
8438            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8439            // Calling encoder.out_of_line_offset(0) is not allowed.
8440            if max_ordinal == 0 {
8441                return Ok(());
8442            }
8443            depth.increment()?;
8444            let envelope_size = 8;
8445            let bytes_len = max_ordinal as usize * envelope_size;
8446            #[allow(unused_variables)]
8447            let offset = encoder.out_of_line_offset(bytes_len);
8448            let mut _prev_end_offset: usize = 0;
8449            if 1 > max_ordinal {
8450                return Ok(());
8451            }
8452
8453            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8454            // are envelope_size bytes.
8455            let cur_offset: usize = (1 - 1) * envelope_size;
8456
8457            // Zero reserved fields.
8458            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8459
8460            // Safety:
8461            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8462            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8463            //   envelope_size bytes, there is always sufficient room.
8464            fidl::encoding::encode_in_envelope_optional::<u32, D>(
8465                self.priority.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
8466                encoder,
8467                offset + cur_offset,
8468                depth,
8469            )?;
8470
8471            _prev_end_offset = cur_offset + envelope_size;
8472            if 2 > max_ordinal {
8473                return Ok(());
8474            }
8475
8476            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8477            // are envelope_size bytes.
8478            let cur_offset: usize = (2 - 1) * envelope_size;
8479
8480            // Zero reserved fields.
8481            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8482
8483            // Safety:
8484            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8485            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8486            //   envelope_size bytes, there is always sufficient room.
8487            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<64>, D>(
8488                self.name.as_ref().map(
8489                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
8490                ),
8491                encoder,
8492                offset + cur_offset,
8493                depth,
8494            )?;
8495
8496            _prev_end_offset = cur_offset + envelope_size;
8497
8498            Ok(())
8499        }
8500    }
8501
8502    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NodeSetNameRequest {
8503        #[inline(always)]
8504        fn new_empty() -> Self {
8505            Self::default()
8506        }
8507
8508        unsafe fn decode(
8509            &mut self,
8510            decoder: &mut fidl::encoding::Decoder<'_, D>,
8511            offset: usize,
8512            mut depth: fidl::encoding::Depth,
8513        ) -> fidl::Result<()> {
8514            decoder.debug_check_bounds::<Self>(offset);
8515            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8516                None => return Err(fidl::Error::NotNullable),
8517                Some(len) => len,
8518            };
8519            // Calling decoder.out_of_line_offset(0) is not allowed.
8520            if len == 0 {
8521                return Ok(());
8522            };
8523            depth.increment()?;
8524            let envelope_size = 8;
8525            let bytes_len = len * envelope_size;
8526            let offset = decoder.out_of_line_offset(bytes_len)?;
8527            // Decode the envelope for each type.
8528            let mut _next_ordinal_to_read = 0;
8529            let mut next_offset = offset;
8530            let end_offset = offset + bytes_len;
8531            _next_ordinal_to_read += 1;
8532            if next_offset >= end_offset {
8533                return Ok(());
8534            }
8535
8536            // Decode unknown envelopes for gaps in ordinals.
8537            while _next_ordinal_to_read < 1 {
8538                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8539                _next_ordinal_to_read += 1;
8540                next_offset += envelope_size;
8541            }
8542
8543            let next_out_of_line = decoder.next_out_of_line();
8544            let handles_before = decoder.remaining_handles();
8545            if let Some((inlined, num_bytes, num_handles)) =
8546                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8547            {
8548                let member_inline_size =
8549                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8550                if inlined != (member_inline_size <= 4) {
8551                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8552                }
8553                let inner_offset;
8554                let mut inner_depth = depth.clone();
8555                if inlined {
8556                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8557                    inner_offset = next_offset;
8558                } else {
8559                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8560                    inner_depth.increment()?;
8561                }
8562                let val_ref = self.priority.get_or_insert_with(|| fidl::new_empty!(u32, D));
8563                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
8564                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8565                {
8566                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8567                }
8568                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8569                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8570                }
8571            }
8572
8573            next_offset += envelope_size;
8574            _next_ordinal_to_read += 1;
8575            if next_offset >= end_offset {
8576                return Ok(());
8577            }
8578
8579            // Decode unknown envelopes for gaps in ordinals.
8580            while _next_ordinal_to_read < 2 {
8581                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8582                _next_ordinal_to_read += 1;
8583                next_offset += envelope_size;
8584            }
8585
8586            let next_out_of_line = decoder.next_out_of_line();
8587            let handles_before = decoder.remaining_handles();
8588            if let Some((inlined, num_bytes, num_handles)) =
8589                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8590            {
8591                let member_inline_size =
8592                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
8593                        decoder.context,
8594                    );
8595                if inlined != (member_inline_size <= 4) {
8596                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8597                }
8598                let inner_offset;
8599                let mut inner_depth = depth.clone();
8600                if inlined {
8601                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8602                    inner_offset = next_offset;
8603                } else {
8604                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8605                    inner_depth.increment()?;
8606                }
8607                let val_ref = self
8608                    .name
8609                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<64>, D));
8610                fidl::decode!(
8611                    fidl::encoding::BoundedString<64>,
8612                    D,
8613                    val_ref,
8614                    decoder,
8615                    inner_offset,
8616                    inner_depth
8617                )?;
8618                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8619                {
8620                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8621                }
8622                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8623                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8624                }
8625            }
8626
8627            next_offset += envelope_size;
8628
8629            // Decode the remaining unknown envelopes.
8630            while next_offset < end_offset {
8631                _next_ordinal_to_read += 1;
8632                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8633                next_offset += envelope_size;
8634            }
8635
8636            Ok(())
8637        }
8638    }
8639
8640    impl NodeGetBufferCollectionIdResponse {
8641        #[inline(always)]
8642        fn max_ordinal_present(&self) -> u64 {
8643            if let Some(_) = self.buffer_collection_id {
8644                return 1;
8645            }
8646            0
8647        }
8648    }
8649
8650    impl fidl::encoding::ValueTypeMarker for NodeGetBufferCollectionIdResponse {
8651        type Borrowed<'a> = &'a Self;
8652        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8653            value
8654        }
8655    }
8656
8657    unsafe impl fidl::encoding::TypeMarker for NodeGetBufferCollectionIdResponse {
8658        type Owned = Self;
8659
8660        #[inline(always)]
8661        fn inline_align(_context: fidl::encoding::Context) -> usize {
8662            8
8663        }
8664
8665        #[inline(always)]
8666        fn inline_size(_context: fidl::encoding::Context) -> usize {
8667            16
8668        }
8669    }
8670
8671    unsafe impl<D: fidl::encoding::ResourceDialect>
8672        fidl::encoding::Encode<NodeGetBufferCollectionIdResponse, D>
8673        for &NodeGetBufferCollectionIdResponse
8674    {
8675        unsafe fn encode(
8676            self,
8677            encoder: &mut fidl::encoding::Encoder<'_, D>,
8678            offset: usize,
8679            mut depth: fidl::encoding::Depth,
8680        ) -> fidl::Result<()> {
8681            encoder.debug_check_bounds::<NodeGetBufferCollectionIdResponse>(offset);
8682            // Vector header
8683            let max_ordinal: u64 = self.max_ordinal_present();
8684            encoder.write_num(max_ordinal, offset);
8685            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8686            // Calling encoder.out_of_line_offset(0) is not allowed.
8687            if max_ordinal == 0 {
8688                return Ok(());
8689            }
8690            depth.increment()?;
8691            let envelope_size = 8;
8692            let bytes_len = max_ordinal as usize * envelope_size;
8693            #[allow(unused_variables)]
8694            let offset = encoder.out_of_line_offset(bytes_len);
8695            let mut _prev_end_offset: usize = 0;
8696            if 1 > max_ordinal {
8697                return Ok(());
8698            }
8699
8700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8701            // are envelope_size bytes.
8702            let cur_offset: usize = (1 - 1) * envelope_size;
8703
8704            // Zero reserved fields.
8705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8706
8707            // Safety:
8708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8710            //   envelope_size bytes, there is always sufficient room.
8711            fidl::encoding::encode_in_envelope_optional::<u64, D>(
8712                self.buffer_collection_id
8713                    .as_ref()
8714                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8715                encoder,
8716                offset + cur_offset,
8717                depth,
8718            )?;
8719
8720            _prev_end_offset = cur_offset + envelope_size;
8721
8722            Ok(())
8723        }
8724    }
8725
8726    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8727        for NodeGetBufferCollectionIdResponse
8728    {
8729        #[inline(always)]
8730        fn new_empty() -> Self {
8731            Self::default()
8732        }
8733
8734        unsafe fn decode(
8735            &mut self,
8736            decoder: &mut fidl::encoding::Decoder<'_, D>,
8737            offset: usize,
8738            mut depth: fidl::encoding::Depth,
8739        ) -> fidl::Result<()> {
8740            decoder.debug_check_bounds::<Self>(offset);
8741            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8742                None => return Err(fidl::Error::NotNullable),
8743                Some(len) => len,
8744            };
8745            // Calling decoder.out_of_line_offset(0) is not allowed.
8746            if len == 0 {
8747                return Ok(());
8748            };
8749            depth.increment()?;
8750            let envelope_size = 8;
8751            let bytes_len = len * envelope_size;
8752            let offset = decoder.out_of_line_offset(bytes_len)?;
8753            // Decode the envelope for each type.
8754            let mut _next_ordinal_to_read = 0;
8755            let mut next_offset = offset;
8756            let end_offset = offset + bytes_len;
8757            _next_ordinal_to_read += 1;
8758            if next_offset >= end_offset {
8759                return Ok(());
8760            }
8761
8762            // Decode unknown envelopes for gaps in ordinals.
8763            while _next_ordinal_to_read < 1 {
8764                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8765                _next_ordinal_to_read += 1;
8766                next_offset += envelope_size;
8767            }
8768
8769            let next_out_of_line = decoder.next_out_of_line();
8770            let handles_before = decoder.remaining_handles();
8771            if let Some((inlined, num_bytes, num_handles)) =
8772                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8773            {
8774                let member_inline_size =
8775                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8776                if inlined != (member_inline_size <= 4) {
8777                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8778                }
8779                let inner_offset;
8780                let mut inner_depth = depth.clone();
8781                if inlined {
8782                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8783                    inner_offset = next_offset;
8784                } else {
8785                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8786                    inner_depth.increment()?;
8787                }
8788                let val_ref =
8789                    self.buffer_collection_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
8790                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
8791                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8792                {
8793                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8794                }
8795                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8796                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8797                }
8798            }
8799
8800            next_offset += envelope_size;
8801
8802            // Decode the remaining unknown envelopes.
8803            while next_offset < end_offset {
8804                _next_ordinal_to_read += 1;
8805                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8806                next_offset += envelope_size;
8807            }
8808
8809            Ok(())
8810        }
8811    }
8812
8813    impl NodeIsAlternateForResponse {
8814        #[inline(always)]
8815        fn max_ordinal_present(&self) -> u64 {
8816            if let Some(_) = self.is_alternate {
8817                return 1;
8818            }
8819            0
8820        }
8821    }
8822
8823    impl fidl::encoding::ValueTypeMarker for NodeIsAlternateForResponse {
8824        type Borrowed<'a> = &'a Self;
8825        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8826            value
8827        }
8828    }
8829
8830    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForResponse {
8831        type Owned = Self;
8832
8833        #[inline(always)]
8834        fn inline_align(_context: fidl::encoding::Context) -> usize {
8835            8
8836        }
8837
8838        #[inline(always)]
8839        fn inline_size(_context: fidl::encoding::Context) -> usize {
8840            16
8841        }
8842    }
8843
8844    unsafe impl<D: fidl::encoding::ResourceDialect>
8845        fidl::encoding::Encode<NodeIsAlternateForResponse, D> for &NodeIsAlternateForResponse
8846    {
8847        unsafe fn encode(
8848            self,
8849            encoder: &mut fidl::encoding::Encoder<'_, D>,
8850            offset: usize,
8851            mut depth: fidl::encoding::Depth,
8852        ) -> fidl::Result<()> {
8853            encoder.debug_check_bounds::<NodeIsAlternateForResponse>(offset);
8854            // Vector header
8855            let max_ordinal: u64 = self.max_ordinal_present();
8856            encoder.write_num(max_ordinal, offset);
8857            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8858            // Calling encoder.out_of_line_offset(0) is not allowed.
8859            if max_ordinal == 0 {
8860                return Ok(());
8861            }
8862            depth.increment()?;
8863            let envelope_size = 8;
8864            let bytes_len = max_ordinal as usize * envelope_size;
8865            #[allow(unused_variables)]
8866            let offset = encoder.out_of_line_offset(bytes_len);
8867            let mut _prev_end_offset: usize = 0;
8868            if 1 > max_ordinal {
8869                return Ok(());
8870            }
8871
8872            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8873            // are envelope_size bytes.
8874            let cur_offset: usize = (1 - 1) * envelope_size;
8875
8876            // Zero reserved fields.
8877            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8878
8879            // Safety:
8880            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8881            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8882            //   envelope_size bytes, there is always sufficient room.
8883            fidl::encoding::encode_in_envelope_optional::<bool, D>(
8884                self.is_alternate.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
8885                encoder,
8886                offset + cur_offset,
8887                depth,
8888            )?;
8889
8890            _prev_end_offset = cur_offset + envelope_size;
8891
8892            Ok(())
8893        }
8894    }
8895
8896    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8897        for NodeIsAlternateForResponse
8898    {
8899        #[inline(always)]
8900        fn new_empty() -> Self {
8901            Self::default()
8902        }
8903
8904        unsafe fn decode(
8905            &mut self,
8906            decoder: &mut fidl::encoding::Decoder<'_, D>,
8907            offset: usize,
8908            mut depth: fidl::encoding::Depth,
8909        ) -> fidl::Result<()> {
8910            decoder.debug_check_bounds::<Self>(offset);
8911            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8912                None => return Err(fidl::Error::NotNullable),
8913                Some(len) => len,
8914            };
8915            // Calling decoder.out_of_line_offset(0) is not allowed.
8916            if len == 0 {
8917                return Ok(());
8918            };
8919            depth.increment()?;
8920            let envelope_size = 8;
8921            let bytes_len = len * envelope_size;
8922            let offset = decoder.out_of_line_offset(bytes_len)?;
8923            // Decode the envelope for each type.
8924            let mut _next_ordinal_to_read = 0;
8925            let mut next_offset = offset;
8926            let end_offset = offset + bytes_len;
8927            _next_ordinal_to_read += 1;
8928            if next_offset >= end_offset {
8929                return Ok(());
8930            }
8931
8932            // Decode unknown envelopes for gaps in ordinals.
8933            while _next_ordinal_to_read < 1 {
8934                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8935                _next_ordinal_to_read += 1;
8936                next_offset += envelope_size;
8937            }
8938
8939            let next_out_of_line = decoder.next_out_of_line();
8940            let handles_before = decoder.remaining_handles();
8941            if let Some((inlined, num_bytes, num_handles)) =
8942                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8943            {
8944                let member_inline_size =
8945                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8946                if inlined != (member_inline_size <= 4) {
8947                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8948                }
8949                let inner_offset;
8950                let mut inner_depth = depth.clone();
8951                if inlined {
8952                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8953                    inner_offset = next_offset;
8954                } else {
8955                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8956                    inner_depth.increment()?;
8957                }
8958                let val_ref = self.is_alternate.get_or_insert_with(|| fidl::new_empty!(bool, D));
8959                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
8960                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8961                {
8962                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8963                }
8964                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8965                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8966                }
8967            }
8968
8969            next_offset += envelope_size;
8970
8971            // Decode the remaining unknown envelopes.
8972            while next_offset < end_offset {
8973                _next_ordinal_to_read += 1;
8974                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8975                next_offset += envelope_size;
8976            }
8977
8978            Ok(())
8979        }
8980    }
8981
8982    impl SecureHeapAndRange {
8983        #[inline(always)]
8984        fn max_ordinal_present(&self) -> u64 {
8985            if let Some(_) = self.range {
8986                return 2;
8987            }
8988            if let Some(_) = self.heap {
8989                return 1;
8990            }
8991            0
8992        }
8993    }
8994
8995    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRange {
8996        type Borrowed<'a> = &'a Self;
8997        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8998            value
8999        }
9000    }
9001
9002    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRange {
9003        type Owned = Self;
9004
9005        #[inline(always)]
9006        fn inline_align(_context: fidl::encoding::Context) -> usize {
9007            8
9008        }
9009
9010        #[inline(always)]
9011        fn inline_size(_context: fidl::encoding::Context) -> usize {
9012            16
9013        }
9014    }
9015
9016    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapAndRange, D>
9017        for &SecureHeapAndRange
9018    {
9019        unsafe fn encode(
9020            self,
9021            encoder: &mut fidl::encoding::Encoder<'_, D>,
9022            offset: usize,
9023            mut depth: fidl::encoding::Depth,
9024        ) -> fidl::Result<()> {
9025            encoder.debug_check_bounds::<SecureHeapAndRange>(offset);
9026            // Vector header
9027            let max_ordinal: u64 = self.max_ordinal_present();
9028            encoder.write_num(max_ordinal, offset);
9029            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9030            // Calling encoder.out_of_line_offset(0) is not allowed.
9031            if max_ordinal == 0 {
9032                return Ok(());
9033            }
9034            depth.increment()?;
9035            let envelope_size = 8;
9036            let bytes_len = max_ordinal as usize * envelope_size;
9037            #[allow(unused_variables)]
9038            let offset = encoder.out_of_line_offset(bytes_len);
9039            let mut _prev_end_offset: usize = 0;
9040            if 1 > max_ordinal {
9041                return Ok(());
9042            }
9043
9044            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9045            // are envelope_size bytes.
9046            let cur_offset: usize = (1 - 1) * envelope_size;
9047
9048            // Zero reserved fields.
9049            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9050
9051            // Safety:
9052            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9053            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9054            //   envelope_size bytes, there is always sufficient room.
9055            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9056                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9057                encoder,
9058                offset + cur_offset,
9059                depth,
9060            )?;
9061
9062            _prev_end_offset = cur_offset + envelope_size;
9063            if 2 > max_ordinal {
9064                return Ok(());
9065            }
9066
9067            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9068            // are envelope_size bytes.
9069            let cur_offset: usize = (2 - 1) * envelope_size;
9070
9071            // Zero reserved fields.
9072            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9073
9074            // Safety:
9075            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9076            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9077            //   envelope_size bytes, there is always sufficient room.
9078            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9079                self.range
9080                    .as_ref()
9081                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9082                encoder,
9083                offset + cur_offset,
9084                depth,
9085            )?;
9086
9087            _prev_end_offset = cur_offset + envelope_size;
9088
9089            Ok(())
9090        }
9091    }
9092
9093    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapAndRange {
9094        #[inline(always)]
9095        fn new_empty() -> Self {
9096            Self::default()
9097        }
9098
9099        unsafe fn decode(
9100            &mut self,
9101            decoder: &mut fidl::encoding::Decoder<'_, D>,
9102            offset: usize,
9103            mut depth: fidl::encoding::Depth,
9104        ) -> fidl::Result<()> {
9105            decoder.debug_check_bounds::<Self>(offset);
9106            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9107                None => return Err(fidl::Error::NotNullable),
9108                Some(len) => len,
9109            };
9110            // Calling decoder.out_of_line_offset(0) is not allowed.
9111            if len == 0 {
9112                return Ok(());
9113            };
9114            depth.increment()?;
9115            let envelope_size = 8;
9116            let bytes_len = len * envelope_size;
9117            let offset = decoder.out_of_line_offset(bytes_len)?;
9118            // Decode the envelope for each type.
9119            let mut _next_ordinal_to_read = 0;
9120            let mut next_offset = offset;
9121            let end_offset = offset + bytes_len;
9122            _next_ordinal_to_read += 1;
9123            if next_offset >= end_offset {
9124                return Ok(());
9125            }
9126
9127            // Decode unknown envelopes for gaps in ordinals.
9128            while _next_ordinal_to_read < 1 {
9129                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9130                _next_ordinal_to_read += 1;
9131                next_offset += envelope_size;
9132            }
9133
9134            let next_out_of_line = decoder.next_out_of_line();
9135            let handles_before = decoder.remaining_handles();
9136            if let Some((inlined, num_bytes, num_handles)) =
9137                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9138            {
9139                let member_inline_size =
9140                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9141                if inlined != (member_inline_size <= 4) {
9142                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9143                }
9144                let inner_offset;
9145                let mut inner_depth = depth.clone();
9146                if inlined {
9147                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9148                    inner_offset = next_offset;
9149                } else {
9150                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9151                    inner_depth.increment()?;
9152                }
9153                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9154                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9155                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9156                {
9157                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9158                }
9159                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9160                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9161                }
9162            }
9163
9164            next_offset += envelope_size;
9165            _next_ordinal_to_read += 1;
9166            if next_offset >= end_offset {
9167                return Ok(());
9168            }
9169
9170            // Decode unknown envelopes for gaps in ordinals.
9171            while _next_ordinal_to_read < 2 {
9172                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9173                _next_ordinal_to_read += 1;
9174                next_offset += envelope_size;
9175            }
9176
9177            let next_out_of_line = decoder.next_out_of_line();
9178            let handles_before = decoder.remaining_handles();
9179            if let Some((inlined, num_bytes, num_handles)) =
9180                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9181            {
9182                let member_inline_size =
9183                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9184                if inlined != (member_inline_size <= 4) {
9185                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9186                }
9187                let inner_offset;
9188                let mut inner_depth = depth.clone();
9189                if inlined {
9190                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9191                    inner_offset = next_offset;
9192                } else {
9193                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9194                    inner_depth.increment()?;
9195                }
9196                let val_ref =
9197                    self.range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9198                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9199                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9200                {
9201                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9202                }
9203                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9204                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9205                }
9206            }
9207
9208            next_offset += envelope_size;
9209
9210            // Decode the remaining unknown envelopes.
9211            while next_offset < end_offset {
9212                _next_ordinal_to_read += 1;
9213                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9214                next_offset += envelope_size;
9215            }
9216
9217            Ok(())
9218        }
9219    }
9220
9221    impl SecureHeapAndRangeModification {
9222        #[inline(always)]
9223        fn max_ordinal_present(&self) -> u64 {
9224            if let Some(_) = self.new_range {
9225                return 3;
9226            }
9227            if let Some(_) = self.old_range {
9228                return 2;
9229            }
9230            if let Some(_) = self.heap {
9231                return 1;
9232            }
9233            0
9234        }
9235    }
9236
9237    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRangeModification {
9238        type Borrowed<'a> = &'a Self;
9239        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9240            value
9241        }
9242    }
9243
9244    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRangeModification {
9245        type Owned = Self;
9246
9247        #[inline(always)]
9248        fn inline_align(_context: fidl::encoding::Context) -> usize {
9249            8
9250        }
9251
9252        #[inline(always)]
9253        fn inline_size(_context: fidl::encoding::Context) -> usize {
9254            16
9255        }
9256    }
9257
9258    unsafe impl<D: fidl::encoding::ResourceDialect>
9259        fidl::encoding::Encode<SecureHeapAndRangeModification, D>
9260        for &SecureHeapAndRangeModification
9261    {
9262        unsafe fn encode(
9263            self,
9264            encoder: &mut fidl::encoding::Encoder<'_, D>,
9265            offset: usize,
9266            mut depth: fidl::encoding::Depth,
9267        ) -> fidl::Result<()> {
9268            encoder.debug_check_bounds::<SecureHeapAndRangeModification>(offset);
9269            // Vector header
9270            let max_ordinal: u64 = self.max_ordinal_present();
9271            encoder.write_num(max_ordinal, offset);
9272            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9273            // Calling encoder.out_of_line_offset(0) is not allowed.
9274            if max_ordinal == 0 {
9275                return Ok(());
9276            }
9277            depth.increment()?;
9278            let envelope_size = 8;
9279            let bytes_len = max_ordinal as usize * envelope_size;
9280            #[allow(unused_variables)]
9281            let offset = encoder.out_of_line_offset(bytes_len);
9282            let mut _prev_end_offset: usize = 0;
9283            if 1 > max_ordinal {
9284                return Ok(());
9285            }
9286
9287            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9288            // are envelope_size bytes.
9289            let cur_offset: usize = (1 - 1) * envelope_size;
9290
9291            // Zero reserved fields.
9292            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9293
9294            // Safety:
9295            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9296            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9297            //   envelope_size bytes, there is always sufficient room.
9298            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9299                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9300                encoder,
9301                offset + cur_offset,
9302                depth,
9303            )?;
9304
9305            _prev_end_offset = cur_offset + envelope_size;
9306            if 2 > max_ordinal {
9307                return Ok(());
9308            }
9309
9310            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9311            // are envelope_size bytes.
9312            let cur_offset: usize = (2 - 1) * envelope_size;
9313
9314            // Zero reserved fields.
9315            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9316
9317            // Safety:
9318            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9319            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9320            //   envelope_size bytes, there is always sufficient room.
9321            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9322                self.old_range
9323                    .as_ref()
9324                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9325                encoder,
9326                offset + cur_offset,
9327                depth,
9328            )?;
9329
9330            _prev_end_offset = cur_offset + envelope_size;
9331            if 3 > max_ordinal {
9332                return Ok(());
9333            }
9334
9335            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9336            // are envelope_size bytes.
9337            let cur_offset: usize = (3 - 1) * envelope_size;
9338
9339            // Zero reserved fields.
9340            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9341
9342            // Safety:
9343            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9344            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9345            //   envelope_size bytes, there is always sufficient room.
9346            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9347                self.new_range
9348                    .as_ref()
9349                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9350                encoder,
9351                offset + cur_offset,
9352                depth,
9353            )?;
9354
9355            _prev_end_offset = cur_offset + envelope_size;
9356
9357            Ok(())
9358        }
9359    }
9360
9361    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9362        for SecureHeapAndRangeModification
9363    {
9364        #[inline(always)]
9365        fn new_empty() -> Self {
9366            Self::default()
9367        }
9368
9369        unsafe fn decode(
9370            &mut self,
9371            decoder: &mut fidl::encoding::Decoder<'_, D>,
9372            offset: usize,
9373            mut depth: fidl::encoding::Depth,
9374        ) -> fidl::Result<()> {
9375            decoder.debug_check_bounds::<Self>(offset);
9376            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9377                None => return Err(fidl::Error::NotNullable),
9378                Some(len) => len,
9379            };
9380            // Calling decoder.out_of_line_offset(0) is not allowed.
9381            if len == 0 {
9382                return Ok(());
9383            };
9384            depth.increment()?;
9385            let envelope_size = 8;
9386            let bytes_len = len * envelope_size;
9387            let offset = decoder.out_of_line_offset(bytes_len)?;
9388            // Decode the envelope for each type.
9389            let mut _next_ordinal_to_read = 0;
9390            let mut next_offset = offset;
9391            let end_offset = offset + bytes_len;
9392            _next_ordinal_to_read += 1;
9393            if next_offset >= end_offset {
9394                return Ok(());
9395            }
9396
9397            // Decode unknown envelopes for gaps in ordinals.
9398            while _next_ordinal_to_read < 1 {
9399                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9400                _next_ordinal_to_read += 1;
9401                next_offset += envelope_size;
9402            }
9403
9404            let next_out_of_line = decoder.next_out_of_line();
9405            let handles_before = decoder.remaining_handles();
9406            if let Some((inlined, num_bytes, num_handles)) =
9407                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9408            {
9409                let member_inline_size =
9410                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9411                if inlined != (member_inline_size <= 4) {
9412                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9413                }
9414                let inner_offset;
9415                let mut inner_depth = depth.clone();
9416                if inlined {
9417                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9418                    inner_offset = next_offset;
9419                } else {
9420                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9421                    inner_depth.increment()?;
9422                }
9423                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9424                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9425                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9426                {
9427                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9428                }
9429                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9430                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9431                }
9432            }
9433
9434            next_offset += envelope_size;
9435            _next_ordinal_to_read += 1;
9436            if next_offset >= end_offset {
9437                return Ok(());
9438            }
9439
9440            // Decode unknown envelopes for gaps in ordinals.
9441            while _next_ordinal_to_read < 2 {
9442                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9443                _next_ordinal_to_read += 1;
9444                next_offset += envelope_size;
9445            }
9446
9447            let next_out_of_line = decoder.next_out_of_line();
9448            let handles_before = decoder.remaining_handles();
9449            if let Some((inlined, num_bytes, num_handles)) =
9450                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9451            {
9452                let member_inline_size =
9453                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9454                if inlined != (member_inline_size <= 4) {
9455                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9456                }
9457                let inner_offset;
9458                let mut inner_depth = depth.clone();
9459                if inlined {
9460                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9461                    inner_offset = next_offset;
9462                } else {
9463                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9464                    inner_depth.increment()?;
9465                }
9466                let val_ref =
9467                    self.old_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9468                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9469                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9470                {
9471                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9472                }
9473                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9474                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9475                }
9476            }
9477
9478            next_offset += envelope_size;
9479            _next_ordinal_to_read += 1;
9480            if next_offset >= end_offset {
9481                return Ok(());
9482            }
9483
9484            // Decode unknown envelopes for gaps in ordinals.
9485            while _next_ordinal_to_read < 3 {
9486                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9487                _next_ordinal_to_read += 1;
9488                next_offset += envelope_size;
9489            }
9490
9491            let next_out_of_line = decoder.next_out_of_line();
9492            let handles_before = decoder.remaining_handles();
9493            if let Some((inlined, num_bytes, num_handles)) =
9494                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9495            {
9496                let member_inline_size =
9497                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9498                if inlined != (member_inline_size <= 4) {
9499                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9500                }
9501                let inner_offset;
9502                let mut inner_depth = depth.clone();
9503                if inlined {
9504                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9505                    inner_offset = next_offset;
9506                } else {
9507                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9508                    inner_depth.increment()?;
9509                }
9510                let val_ref =
9511                    self.new_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9512                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9513                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9514                {
9515                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9516                }
9517                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9518                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9519                }
9520            }
9521
9522            next_offset += envelope_size;
9523
9524            // Decode the remaining unknown envelopes.
9525            while next_offset < end_offset {
9526                _next_ordinal_to_read += 1;
9527                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9528                next_offset += envelope_size;
9529            }
9530
9531            Ok(())
9532        }
9533    }
9534
9535    impl SecureHeapAndRanges {
9536        #[inline(always)]
9537        fn max_ordinal_present(&self) -> u64 {
9538            if let Some(_) = self.ranges {
9539                return 2;
9540            }
9541            if let Some(_) = self.heap {
9542                return 1;
9543            }
9544            0
9545        }
9546    }
9547
9548    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRanges {
9549        type Borrowed<'a> = &'a Self;
9550        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9551            value
9552        }
9553    }
9554
9555    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRanges {
9556        type Owned = Self;
9557
9558        #[inline(always)]
9559        fn inline_align(_context: fidl::encoding::Context) -> usize {
9560            8
9561        }
9562
9563        #[inline(always)]
9564        fn inline_size(_context: fidl::encoding::Context) -> usize {
9565            16
9566        }
9567    }
9568
9569    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapAndRanges, D>
9570        for &SecureHeapAndRanges
9571    {
9572        unsafe fn encode(
9573            self,
9574            encoder: &mut fidl::encoding::Encoder<'_, D>,
9575            offset: usize,
9576            mut depth: fidl::encoding::Depth,
9577        ) -> fidl::Result<()> {
9578            encoder.debug_check_bounds::<SecureHeapAndRanges>(offset);
9579            // Vector header
9580            let max_ordinal: u64 = self.max_ordinal_present();
9581            encoder.write_num(max_ordinal, offset);
9582            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9583            // Calling encoder.out_of_line_offset(0) is not allowed.
9584            if max_ordinal == 0 {
9585                return Ok(());
9586            }
9587            depth.increment()?;
9588            let envelope_size = 8;
9589            let bytes_len = max_ordinal as usize * envelope_size;
9590            #[allow(unused_variables)]
9591            let offset = encoder.out_of_line_offset(bytes_len);
9592            let mut _prev_end_offset: usize = 0;
9593            if 1 > max_ordinal {
9594                return Ok(());
9595            }
9596
9597            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9598            // are envelope_size bytes.
9599            let cur_offset: usize = (1 - 1) * envelope_size;
9600
9601            // Zero reserved fields.
9602            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9603
9604            // Safety:
9605            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9606            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9607            //   envelope_size bytes, there is always sufficient room.
9608            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9609                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9610                encoder,
9611                offset + cur_offset,
9612                depth,
9613            )?;
9614
9615            _prev_end_offset = cur_offset + envelope_size;
9616            if 2 > max_ordinal {
9617                return Ok(());
9618            }
9619
9620            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9621            // are envelope_size bytes.
9622            let cur_offset: usize = (2 - 1) * envelope_size;
9623
9624            // Zero reserved fields.
9625            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9626
9627            // Safety:
9628            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9629            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9630            //   envelope_size bytes, there is always sufficient room.
9631            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SecureHeapRange, 128>, D>(
9632            self.ranges.as_ref().map(<fidl::encoding::Vector<SecureHeapRange, 128> as fidl::encoding::ValueTypeMarker>::borrow),
9633            encoder, offset + cur_offset, depth
9634        )?;
9635
9636            _prev_end_offset = cur_offset + envelope_size;
9637
9638            Ok(())
9639        }
9640    }
9641
9642    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapAndRanges {
9643        #[inline(always)]
9644        fn new_empty() -> Self {
9645            Self::default()
9646        }
9647
9648        unsafe fn decode(
9649            &mut self,
9650            decoder: &mut fidl::encoding::Decoder<'_, D>,
9651            offset: usize,
9652            mut depth: fidl::encoding::Depth,
9653        ) -> fidl::Result<()> {
9654            decoder.debug_check_bounds::<Self>(offset);
9655            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9656                None => return Err(fidl::Error::NotNullable),
9657                Some(len) => len,
9658            };
9659            // Calling decoder.out_of_line_offset(0) is not allowed.
9660            if len == 0 {
9661                return Ok(());
9662            };
9663            depth.increment()?;
9664            let envelope_size = 8;
9665            let bytes_len = len * envelope_size;
9666            let offset = decoder.out_of_line_offset(bytes_len)?;
9667            // Decode the envelope for each type.
9668            let mut _next_ordinal_to_read = 0;
9669            let mut next_offset = offset;
9670            let end_offset = offset + bytes_len;
9671            _next_ordinal_to_read += 1;
9672            if next_offset >= end_offset {
9673                return Ok(());
9674            }
9675
9676            // Decode unknown envelopes for gaps in ordinals.
9677            while _next_ordinal_to_read < 1 {
9678                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9679                _next_ordinal_to_read += 1;
9680                next_offset += envelope_size;
9681            }
9682
9683            let next_out_of_line = decoder.next_out_of_line();
9684            let handles_before = decoder.remaining_handles();
9685            if let Some((inlined, num_bytes, num_handles)) =
9686                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9687            {
9688                let member_inline_size =
9689                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9690                if inlined != (member_inline_size <= 4) {
9691                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9692                }
9693                let inner_offset;
9694                let mut inner_depth = depth.clone();
9695                if inlined {
9696                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9697                    inner_offset = next_offset;
9698                } else {
9699                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9700                    inner_depth.increment()?;
9701                }
9702                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9703                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9704                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9705                {
9706                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9707                }
9708                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9709                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9710                }
9711            }
9712
9713            next_offset += envelope_size;
9714            _next_ordinal_to_read += 1;
9715            if next_offset >= end_offset {
9716                return Ok(());
9717            }
9718
9719            // Decode unknown envelopes for gaps in ordinals.
9720            while _next_ordinal_to_read < 2 {
9721                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9722                _next_ordinal_to_read += 1;
9723                next_offset += envelope_size;
9724            }
9725
9726            let next_out_of_line = decoder.next_out_of_line();
9727            let handles_before = decoder.remaining_handles();
9728            if let Some((inlined, num_bytes, num_handles)) =
9729                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9730            {
9731                let member_inline_size = <fidl::encoding::Vector<SecureHeapRange, 128> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9732                if inlined != (member_inline_size <= 4) {
9733                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9734                }
9735                let inner_offset;
9736                let mut inner_depth = depth.clone();
9737                if inlined {
9738                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9739                    inner_offset = next_offset;
9740                } else {
9741                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9742                    inner_depth.increment()?;
9743                }
9744                let val_ref = self.ranges.get_or_insert_with(
9745                    || fidl::new_empty!(fidl::encoding::Vector<SecureHeapRange, 128>, D),
9746                );
9747                fidl::decode!(fidl::encoding::Vector<SecureHeapRange, 128>, D, val_ref, decoder, inner_offset, inner_depth)?;
9748                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9749                {
9750                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9751                }
9752                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9753                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9754                }
9755            }
9756
9757            next_offset += envelope_size;
9758
9759            // Decode the remaining unknown envelopes.
9760            while next_offset < end_offset {
9761                _next_ordinal_to_read += 1;
9762                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9763                next_offset += envelope_size;
9764            }
9765
9766            Ok(())
9767        }
9768    }
9769
9770    impl SecureHeapProperties {
9771        #[inline(always)]
9772        fn max_ordinal_present(&self) -> u64 {
9773            if let Some(_) = self.is_mod_protected_range_available {
9774                return 5;
9775            }
9776            if let Some(_) = self.max_protected_range_count {
9777                return 4;
9778            }
9779            if let Some(_) = self.protected_range_granularity {
9780                return 3;
9781            }
9782            if let Some(_) = self.dynamic_protection_ranges {
9783                return 2;
9784            }
9785            if let Some(_) = self.heap {
9786                return 1;
9787            }
9788            0
9789        }
9790    }
9791
9792    impl fidl::encoding::ValueTypeMarker for SecureHeapProperties {
9793        type Borrowed<'a> = &'a Self;
9794        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9795            value
9796        }
9797    }
9798
9799    unsafe impl fidl::encoding::TypeMarker for SecureHeapProperties {
9800        type Owned = Self;
9801
9802        #[inline(always)]
9803        fn inline_align(_context: fidl::encoding::Context) -> usize {
9804            8
9805        }
9806
9807        #[inline(always)]
9808        fn inline_size(_context: fidl::encoding::Context) -> usize {
9809            16
9810        }
9811    }
9812
9813    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapProperties, D>
9814        for &SecureHeapProperties
9815    {
9816        unsafe fn encode(
9817            self,
9818            encoder: &mut fidl::encoding::Encoder<'_, D>,
9819            offset: usize,
9820            mut depth: fidl::encoding::Depth,
9821        ) -> fidl::Result<()> {
9822            encoder.debug_check_bounds::<SecureHeapProperties>(offset);
9823            // Vector header
9824            let max_ordinal: u64 = self.max_ordinal_present();
9825            encoder.write_num(max_ordinal, offset);
9826            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9827            // Calling encoder.out_of_line_offset(0) is not allowed.
9828            if max_ordinal == 0 {
9829                return Ok(());
9830            }
9831            depth.increment()?;
9832            let envelope_size = 8;
9833            let bytes_len = max_ordinal as usize * envelope_size;
9834            #[allow(unused_variables)]
9835            let offset = encoder.out_of_line_offset(bytes_len);
9836            let mut _prev_end_offset: usize = 0;
9837            if 1 > max_ordinal {
9838                return Ok(());
9839            }
9840
9841            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9842            // are envelope_size bytes.
9843            let cur_offset: usize = (1 - 1) * envelope_size;
9844
9845            // Zero reserved fields.
9846            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9847
9848            // Safety:
9849            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9850            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9851            //   envelope_size bytes, there is always sufficient room.
9852            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9853                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9854                encoder,
9855                offset + cur_offset,
9856                depth,
9857            )?;
9858
9859            _prev_end_offset = cur_offset + envelope_size;
9860            if 2 > max_ordinal {
9861                return Ok(());
9862            }
9863
9864            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9865            // are envelope_size bytes.
9866            let cur_offset: usize = (2 - 1) * envelope_size;
9867
9868            // Zero reserved fields.
9869            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9870
9871            // Safety:
9872            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9873            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9874            //   envelope_size bytes, there is always sufficient room.
9875            fidl::encoding::encode_in_envelope_optional::<bool, D>(
9876                self.dynamic_protection_ranges
9877                    .as_ref()
9878                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
9879                encoder,
9880                offset + cur_offset,
9881                depth,
9882            )?;
9883
9884            _prev_end_offset = cur_offset + envelope_size;
9885            if 3 > max_ordinal {
9886                return Ok(());
9887            }
9888
9889            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9890            // are envelope_size bytes.
9891            let cur_offset: usize = (3 - 1) * envelope_size;
9892
9893            // Zero reserved fields.
9894            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9895
9896            // Safety:
9897            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9898            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9899            //   envelope_size bytes, there is always sufficient room.
9900            fidl::encoding::encode_in_envelope_optional::<u32, D>(
9901                self.protected_range_granularity
9902                    .as_ref()
9903                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
9904                encoder,
9905                offset + cur_offset,
9906                depth,
9907            )?;
9908
9909            _prev_end_offset = cur_offset + envelope_size;
9910            if 4 > max_ordinal {
9911                return Ok(());
9912            }
9913
9914            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9915            // are envelope_size bytes.
9916            let cur_offset: usize = (4 - 1) * envelope_size;
9917
9918            // Zero reserved fields.
9919            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9920
9921            // Safety:
9922            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9923            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9924            //   envelope_size bytes, there is always sufficient room.
9925            fidl::encoding::encode_in_envelope_optional::<u64, D>(
9926                self.max_protected_range_count
9927                    .as_ref()
9928                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9929                encoder,
9930                offset + cur_offset,
9931                depth,
9932            )?;
9933
9934            _prev_end_offset = cur_offset + envelope_size;
9935            if 5 > max_ordinal {
9936                return Ok(());
9937            }
9938
9939            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9940            // are envelope_size bytes.
9941            let cur_offset: usize = (5 - 1) * envelope_size;
9942
9943            // Zero reserved fields.
9944            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9945
9946            // Safety:
9947            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9948            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9949            //   envelope_size bytes, there is always sufficient room.
9950            fidl::encoding::encode_in_envelope_optional::<bool, D>(
9951                self.is_mod_protected_range_available
9952                    .as_ref()
9953                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
9954                encoder,
9955                offset + cur_offset,
9956                depth,
9957            )?;
9958
9959            _prev_end_offset = cur_offset + envelope_size;
9960
9961            Ok(())
9962        }
9963    }
9964
9965    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapProperties {
9966        #[inline(always)]
9967        fn new_empty() -> Self {
9968            Self::default()
9969        }
9970
9971        unsafe fn decode(
9972            &mut self,
9973            decoder: &mut fidl::encoding::Decoder<'_, D>,
9974            offset: usize,
9975            mut depth: fidl::encoding::Depth,
9976        ) -> fidl::Result<()> {
9977            decoder.debug_check_bounds::<Self>(offset);
9978            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9979                None => return Err(fidl::Error::NotNullable),
9980                Some(len) => len,
9981            };
9982            // Calling decoder.out_of_line_offset(0) is not allowed.
9983            if len == 0 {
9984                return Ok(());
9985            };
9986            depth.increment()?;
9987            let envelope_size = 8;
9988            let bytes_len = len * envelope_size;
9989            let offset = decoder.out_of_line_offset(bytes_len)?;
9990            // Decode the envelope for each type.
9991            let mut _next_ordinal_to_read = 0;
9992            let mut next_offset = offset;
9993            let end_offset = offset + bytes_len;
9994            _next_ordinal_to_read += 1;
9995            if next_offset >= end_offset {
9996                return Ok(());
9997            }
9998
9999            // Decode unknown envelopes for gaps in ordinals.
10000            while _next_ordinal_to_read < 1 {
10001                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10002                _next_ordinal_to_read += 1;
10003                next_offset += envelope_size;
10004            }
10005
10006            let next_out_of_line = decoder.next_out_of_line();
10007            let handles_before = decoder.remaining_handles();
10008            if let Some((inlined, num_bytes, num_handles)) =
10009                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10010            {
10011                let member_inline_size =
10012                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10013                if inlined != (member_inline_size <= 4) {
10014                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10015                }
10016                let inner_offset;
10017                let mut inner_depth = depth.clone();
10018                if inlined {
10019                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10020                    inner_offset = next_offset;
10021                } else {
10022                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10023                    inner_depth.increment()?;
10024                }
10025                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
10026                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
10027                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10028                {
10029                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10030                }
10031                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10032                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10033                }
10034            }
10035
10036            next_offset += envelope_size;
10037            _next_ordinal_to_read += 1;
10038            if next_offset >= end_offset {
10039                return Ok(());
10040            }
10041
10042            // Decode unknown envelopes for gaps in ordinals.
10043            while _next_ordinal_to_read < 2 {
10044                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10045                _next_ordinal_to_read += 1;
10046                next_offset += envelope_size;
10047            }
10048
10049            let next_out_of_line = decoder.next_out_of_line();
10050            let handles_before = decoder.remaining_handles();
10051            if let Some((inlined, num_bytes, num_handles)) =
10052                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10053            {
10054                let member_inline_size =
10055                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10056                if inlined != (member_inline_size <= 4) {
10057                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10058                }
10059                let inner_offset;
10060                let mut inner_depth = depth.clone();
10061                if inlined {
10062                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10063                    inner_offset = next_offset;
10064                } else {
10065                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10066                    inner_depth.increment()?;
10067                }
10068                let val_ref =
10069                    self.dynamic_protection_ranges.get_or_insert_with(|| fidl::new_empty!(bool, D));
10070                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
10071                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10072                {
10073                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10074                }
10075                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10076                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10077                }
10078            }
10079
10080            next_offset += envelope_size;
10081            _next_ordinal_to_read += 1;
10082            if next_offset >= end_offset {
10083                return Ok(());
10084            }
10085
10086            // Decode unknown envelopes for gaps in ordinals.
10087            while _next_ordinal_to_read < 3 {
10088                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10089                _next_ordinal_to_read += 1;
10090                next_offset += envelope_size;
10091            }
10092
10093            let next_out_of_line = decoder.next_out_of_line();
10094            let handles_before = decoder.remaining_handles();
10095            if let Some((inlined, num_bytes, num_handles)) =
10096                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10097            {
10098                let member_inline_size =
10099                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10100                if inlined != (member_inline_size <= 4) {
10101                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10102                }
10103                let inner_offset;
10104                let mut inner_depth = depth.clone();
10105                if inlined {
10106                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10107                    inner_offset = next_offset;
10108                } else {
10109                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10110                    inner_depth.increment()?;
10111                }
10112                let val_ref = self
10113                    .protected_range_granularity
10114                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
10115                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
10116                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10117                {
10118                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10119                }
10120                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10121                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10122                }
10123            }
10124
10125            next_offset += envelope_size;
10126            _next_ordinal_to_read += 1;
10127            if next_offset >= end_offset {
10128                return Ok(());
10129            }
10130
10131            // Decode unknown envelopes for gaps in ordinals.
10132            while _next_ordinal_to_read < 4 {
10133                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10134                _next_ordinal_to_read += 1;
10135                next_offset += envelope_size;
10136            }
10137
10138            let next_out_of_line = decoder.next_out_of_line();
10139            let handles_before = decoder.remaining_handles();
10140            if let Some((inlined, num_bytes, num_handles)) =
10141                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10142            {
10143                let member_inline_size =
10144                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10145                if inlined != (member_inline_size <= 4) {
10146                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10147                }
10148                let inner_offset;
10149                let mut inner_depth = depth.clone();
10150                if inlined {
10151                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10152                    inner_offset = next_offset;
10153                } else {
10154                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10155                    inner_depth.increment()?;
10156                }
10157                let val_ref =
10158                    self.max_protected_range_count.get_or_insert_with(|| fidl::new_empty!(u64, D));
10159                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10160                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10161                {
10162                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10163                }
10164                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10165                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10166                }
10167            }
10168
10169            next_offset += envelope_size;
10170            _next_ordinal_to_read += 1;
10171            if next_offset >= end_offset {
10172                return Ok(());
10173            }
10174
10175            // Decode unknown envelopes for gaps in ordinals.
10176            while _next_ordinal_to_read < 5 {
10177                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10178                _next_ordinal_to_read += 1;
10179                next_offset += envelope_size;
10180            }
10181
10182            let next_out_of_line = decoder.next_out_of_line();
10183            let handles_before = decoder.remaining_handles();
10184            if let Some((inlined, num_bytes, num_handles)) =
10185                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10186            {
10187                let member_inline_size =
10188                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10189                if inlined != (member_inline_size <= 4) {
10190                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10191                }
10192                let inner_offset;
10193                let mut inner_depth = depth.clone();
10194                if inlined {
10195                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10196                    inner_offset = next_offset;
10197                } else {
10198                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10199                    inner_depth.increment()?;
10200                }
10201                let val_ref = self
10202                    .is_mod_protected_range_available
10203                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
10204                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
10205                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10206                {
10207                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10208                }
10209                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10210                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10211                }
10212            }
10213
10214            next_offset += envelope_size;
10215
10216            // Decode the remaining unknown envelopes.
10217            while next_offset < end_offset {
10218                _next_ordinal_to_read += 1;
10219                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10220                next_offset += envelope_size;
10221            }
10222
10223            Ok(())
10224        }
10225    }
10226
10227    impl SecureHeapRange {
10228        #[inline(always)]
10229        fn max_ordinal_present(&self) -> u64 {
10230            if let Some(_) = self.size_bytes {
10231                return 2;
10232            }
10233            if let Some(_) = self.physical_address {
10234                return 1;
10235            }
10236            0
10237        }
10238    }
10239
10240    impl fidl::encoding::ValueTypeMarker for SecureHeapRange {
10241        type Borrowed<'a> = &'a Self;
10242        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10243            value
10244        }
10245    }
10246
10247    unsafe impl fidl::encoding::TypeMarker for SecureHeapRange {
10248        type Owned = Self;
10249
10250        #[inline(always)]
10251        fn inline_align(_context: fidl::encoding::Context) -> usize {
10252            8
10253        }
10254
10255        #[inline(always)]
10256        fn inline_size(_context: fidl::encoding::Context) -> usize {
10257            16
10258        }
10259    }
10260
10261    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapRange, D>
10262        for &SecureHeapRange
10263    {
10264        unsafe fn encode(
10265            self,
10266            encoder: &mut fidl::encoding::Encoder<'_, D>,
10267            offset: usize,
10268            mut depth: fidl::encoding::Depth,
10269        ) -> fidl::Result<()> {
10270            encoder.debug_check_bounds::<SecureHeapRange>(offset);
10271            // Vector header
10272            let max_ordinal: u64 = self.max_ordinal_present();
10273            encoder.write_num(max_ordinal, offset);
10274            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10275            // Calling encoder.out_of_line_offset(0) is not allowed.
10276            if max_ordinal == 0 {
10277                return Ok(());
10278            }
10279            depth.increment()?;
10280            let envelope_size = 8;
10281            let bytes_len = max_ordinal as usize * envelope_size;
10282            #[allow(unused_variables)]
10283            let offset = encoder.out_of_line_offset(bytes_len);
10284            let mut _prev_end_offset: usize = 0;
10285            if 1 > max_ordinal {
10286                return Ok(());
10287            }
10288
10289            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10290            // are envelope_size bytes.
10291            let cur_offset: usize = (1 - 1) * envelope_size;
10292
10293            // Zero reserved fields.
10294            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10295
10296            // Safety:
10297            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10298            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10299            //   envelope_size bytes, there is always sufficient room.
10300            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10301                self.physical_address
10302                    .as_ref()
10303                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10304                encoder,
10305                offset + cur_offset,
10306                depth,
10307            )?;
10308
10309            _prev_end_offset = cur_offset + envelope_size;
10310            if 2 > max_ordinal {
10311                return Ok(());
10312            }
10313
10314            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10315            // are envelope_size bytes.
10316            let cur_offset: usize = (2 - 1) * envelope_size;
10317
10318            // Zero reserved fields.
10319            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10320
10321            // Safety:
10322            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10323            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10324            //   envelope_size bytes, there is always sufficient room.
10325            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10326                self.size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10327                encoder,
10328                offset + cur_offset,
10329                depth,
10330            )?;
10331
10332            _prev_end_offset = cur_offset + envelope_size;
10333
10334            Ok(())
10335        }
10336    }
10337
10338    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapRange {
10339        #[inline(always)]
10340        fn new_empty() -> Self {
10341            Self::default()
10342        }
10343
10344        unsafe fn decode(
10345            &mut self,
10346            decoder: &mut fidl::encoding::Decoder<'_, D>,
10347            offset: usize,
10348            mut depth: fidl::encoding::Depth,
10349        ) -> fidl::Result<()> {
10350            decoder.debug_check_bounds::<Self>(offset);
10351            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10352                None => return Err(fidl::Error::NotNullable),
10353                Some(len) => len,
10354            };
10355            // Calling decoder.out_of_line_offset(0) is not allowed.
10356            if len == 0 {
10357                return Ok(());
10358            };
10359            depth.increment()?;
10360            let envelope_size = 8;
10361            let bytes_len = len * envelope_size;
10362            let offset = decoder.out_of_line_offset(bytes_len)?;
10363            // Decode the envelope for each type.
10364            let mut _next_ordinal_to_read = 0;
10365            let mut next_offset = offset;
10366            let end_offset = offset + bytes_len;
10367            _next_ordinal_to_read += 1;
10368            if next_offset >= end_offset {
10369                return Ok(());
10370            }
10371
10372            // Decode unknown envelopes for gaps in ordinals.
10373            while _next_ordinal_to_read < 1 {
10374                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10375                _next_ordinal_to_read += 1;
10376                next_offset += envelope_size;
10377            }
10378
10379            let next_out_of_line = decoder.next_out_of_line();
10380            let handles_before = decoder.remaining_handles();
10381            if let Some((inlined, num_bytes, num_handles)) =
10382                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10383            {
10384                let member_inline_size =
10385                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10386                if inlined != (member_inline_size <= 4) {
10387                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10388                }
10389                let inner_offset;
10390                let mut inner_depth = depth.clone();
10391                if inlined {
10392                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10393                    inner_offset = next_offset;
10394                } else {
10395                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10396                    inner_depth.increment()?;
10397                }
10398                let val_ref = self.physical_address.get_or_insert_with(|| fidl::new_empty!(u64, D));
10399                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10400                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10401                {
10402                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10403                }
10404                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10405                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10406                }
10407            }
10408
10409            next_offset += envelope_size;
10410            _next_ordinal_to_read += 1;
10411            if next_offset >= end_offset {
10412                return Ok(());
10413            }
10414
10415            // Decode unknown envelopes for gaps in ordinals.
10416            while _next_ordinal_to_read < 2 {
10417                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10418                _next_ordinal_to_read += 1;
10419                next_offset += envelope_size;
10420            }
10421
10422            let next_out_of_line = decoder.next_out_of_line();
10423            let handles_before = decoder.remaining_handles();
10424            if let Some((inlined, num_bytes, num_handles)) =
10425                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10426            {
10427                let member_inline_size =
10428                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10429                if inlined != (member_inline_size <= 4) {
10430                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10431                }
10432                let inner_offset;
10433                let mut inner_depth = depth.clone();
10434                if inlined {
10435                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10436                    inner_offset = next_offset;
10437                } else {
10438                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10439                    inner_depth.increment()?;
10440                }
10441                let val_ref = self.size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
10442                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10443                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10444                {
10445                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10446                }
10447                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10448                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10449                }
10450            }
10451
10452            next_offset += envelope_size;
10453
10454            // Decode the remaining unknown envelopes.
10455            while next_offset < end_offset {
10456                _next_ordinal_to_read += 1;
10457                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10458                next_offset += envelope_size;
10459            }
10460
10461            Ok(())
10462        }
10463    }
10464
10465    impl SecureMemAddSecureHeapPhysicalRangeRequest {
10466        #[inline(always)]
10467        fn max_ordinal_present(&self) -> u64 {
10468            if let Some(_) = self.heap_range {
10469                return 1;
10470            }
10471            0
10472        }
10473    }
10474
10475    impl fidl::encoding::ValueTypeMarker for SecureMemAddSecureHeapPhysicalRangeRequest {
10476        type Borrowed<'a> = &'a Self;
10477        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10478            value
10479        }
10480    }
10481
10482    unsafe impl fidl::encoding::TypeMarker for SecureMemAddSecureHeapPhysicalRangeRequest {
10483        type Owned = Self;
10484
10485        #[inline(always)]
10486        fn inline_align(_context: fidl::encoding::Context) -> usize {
10487            8
10488        }
10489
10490        #[inline(always)]
10491        fn inline_size(_context: fidl::encoding::Context) -> usize {
10492            16
10493        }
10494    }
10495
10496    unsafe impl<D: fidl::encoding::ResourceDialect>
10497        fidl::encoding::Encode<SecureMemAddSecureHeapPhysicalRangeRequest, D>
10498        for &SecureMemAddSecureHeapPhysicalRangeRequest
10499    {
10500        unsafe fn encode(
10501            self,
10502            encoder: &mut fidl::encoding::Encoder<'_, D>,
10503            offset: usize,
10504            mut depth: fidl::encoding::Depth,
10505        ) -> fidl::Result<()> {
10506            encoder.debug_check_bounds::<SecureMemAddSecureHeapPhysicalRangeRequest>(offset);
10507            // Vector header
10508            let max_ordinal: u64 = self.max_ordinal_present();
10509            encoder.write_num(max_ordinal, offset);
10510            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10511            // Calling encoder.out_of_line_offset(0) is not allowed.
10512            if max_ordinal == 0 {
10513                return Ok(());
10514            }
10515            depth.increment()?;
10516            let envelope_size = 8;
10517            let bytes_len = max_ordinal as usize * envelope_size;
10518            #[allow(unused_variables)]
10519            let offset = encoder.out_of_line_offset(bytes_len);
10520            let mut _prev_end_offset: usize = 0;
10521            if 1 > max_ordinal {
10522                return Ok(());
10523            }
10524
10525            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10526            // are envelope_size bytes.
10527            let cur_offset: usize = (1 - 1) * envelope_size;
10528
10529            // Zero reserved fields.
10530            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10531
10532            // Safety:
10533            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10534            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10535            //   envelope_size bytes, there is always sufficient room.
10536            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
10537                self.heap_range
10538                    .as_ref()
10539                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
10540                encoder,
10541                offset + cur_offset,
10542                depth,
10543            )?;
10544
10545            _prev_end_offset = cur_offset + envelope_size;
10546
10547            Ok(())
10548        }
10549    }
10550
10551    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
10552        for SecureMemAddSecureHeapPhysicalRangeRequest
10553    {
10554        #[inline(always)]
10555        fn new_empty() -> Self {
10556            Self::default()
10557        }
10558
10559        unsafe fn decode(
10560            &mut self,
10561            decoder: &mut fidl::encoding::Decoder<'_, D>,
10562            offset: usize,
10563            mut depth: fidl::encoding::Depth,
10564        ) -> fidl::Result<()> {
10565            decoder.debug_check_bounds::<Self>(offset);
10566            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10567                None => return Err(fidl::Error::NotNullable),
10568                Some(len) => len,
10569            };
10570            // Calling decoder.out_of_line_offset(0) is not allowed.
10571            if len == 0 {
10572                return Ok(());
10573            };
10574            depth.increment()?;
10575            let envelope_size = 8;
10576            let bytes_len = len * envelope_size;
10577            let offset = decoder.out_of_line_offset(bytes_len)?;
10578            // Decode the envelope for each type.
10579            let mut _next_ordinal_to_read = 0;
10580            let mut next_offset = offset;
10581            let end_offset = offset + bytes_len;
10582            _next_ordinal_to_read += 1;
10583            if next_offset >= end_offset {
10584                return Ok(());
10585            }
10586
10587            // Decode unknown envelopes for gaps in ordinals.
10588            while _next_ordinal_to_read < 1 {
10589                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10590                _next_ordinal_to_read += 1;
10591                next_offset += envelope_size;
10592            }
10593
10594            let next_out_of_line = decoder.next_out_of_line();
10595            let handles_before = decoder.remaining_handles();
10596            if let Some((inlined, num_bytes, num_handles)) =
10597                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10598            {
10599                let member_inline_size =
10600                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
10601                        decoder.context,
10602                    );
10603                if inlined != (member_inline_size <= 4) {
10604                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10605                }
10606                let inner_offset;
10607                let mut inner_depth = depth.clone();
10608                if inlined {
10609                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10610                    inner_offset = next_offset;
10611                } else {
10612                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10613                    inner_depth.increment()?;
10614                }
10615                let val_ref =
10616                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
10617                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
10618                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10619                {
10620                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10621                }
10622                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10623                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10624                }
10625            }
10626
10627            next_offset += envelope_size;
10628
10629            // Decode the remaining unknown envelopes.
10630            while next_offset < end_offset {
10631                _next_ordinal_to_read += 1;
10632                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10633                next_offset += envelope_size;
10634            }
10635
10636            Ok(())
10637        }
10638    }
10639
10640    impl SecureMemDeleteSecureHeapPhysicalRangeRequest {
10641        #[inline(always)]
10642        fn max_ordinal_present(&self) -> u64 {
10643            if let Some(_) = self.heap_range {
10644                return 1;
10645            }
10646            0
10647        }
10648    }
10649
10650    impl fidl::encoding::ValueTypeMarker for SecureMemDeleteSecureHeapPhysicalRangeRequest {
10651        type Borrowed<'a> = &'a Self;
10652        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10653            value
10654        }
10655    }
10656
10657    unsafe impl fidl::encoding::TypeMarker for SecureMemDeleteSecureHeapPhysicalRangeRequest {
10658        type Owned = Self;
10659
10660        #[inline(always)]
10661        fn inline_align(_context: fidl::encoding::Context) -> usize {
10662            8
10663        }
10664
10665        #[inline(always)]
10666        fn inline_size(_context: fidl::encoding::Context) -> usize {
10667            16
10668        }
10669    }
10670
10671    unsafe impl<D: fidl::encoding::ResourceDialect>
10672        fidl::encoding::Encode<SecureMemDeleteSecureHeapPhysicalRangeRequest, D>
10673        for &SecureMemDeleteSecureHeapPhysicalRangeRequest
10674    {
10675        unsafe fn encode(
10676            self,
10677            encoder: &mut fidl::encoding::Encoder<'_, D>,
10678            offset: usize,
10679            mut depth: fidl::encoding::Depth,
10680        ) -> fidl::Result<()> {
10681            encoder.debug_check_bounds::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(offset);
10682            // Vector header
10683            let max_ordinal: u64 = self.max_ordinal_present();
10684            encoder.write_num(max_ordinal, offset);
10685            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10686            // Calling encoder.out_of_line_offset(0) is not allowed.
10687            if max_ordinal == 0 {
10688                return Ok(());
10689            }
10690            depth.increment()?;
10691            let envelope_size = 8;
10692            let bytes_len = max_ordinal as usize * envelope_size;
10693            #[allow(unused_variables)]
10694            let offset = encoder.out_of_line_offset(bytes_len);
10695            let mut _prev_end_offset: usize = 0;
10696            if 1 > max_ordinal {
10697                return Ok(());
10698            }
10699
10700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10701            // are envelope_size bytes.
10702            let cur_offset: usize = (1 - 1) * envelope_size;
10703
10704            // Zero reserved fields.
10705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10706
10707            // Safety:
10708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10710            //   envelope_size bytes, there is always sufficient room.
10711            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
10712                self.heap_range
10713                    .as_ref()
10714                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
10715                encoder,
10716                offset + cur_offset,
10717                depth,
10718            )?;
10719
10720            _prev_end_offset = cur_offset + envelope_size;
10721
10722            Ok(())
10723        }
10724    }
10725
10726    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
10727        for SecureMemDeleteSecureHeapPhysicalRangeRequest
10728    {
10729        #[inline(always)]
10730        fn new_empty() -> Self {
10731            Self::default()
10732        }
10733
10734        unsafe fn decode(
10735            &mut self,
10736            decoder: &mut fidl::encoding::Decoder<'_, D>,
10737            offset: usize,
10738            mut depth: fidl::encoding::Depth,
10739        ) -> fidl::Result<()> {
10740            decoder.debug_check_bounds::<Self>(offset);
10741            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10742                None => return Err(fidl::Error::NotNullable),
10743                Some(len) => len,
10744            };
10745            // Calling decoder.out_of_line_offset(0) is not allowed.
10746            if len == 0 {
10747                return Ok(());
10748            };
10749            depth.increment()?;
10750            let envelope_size = 8;
10751            let bytes_len = len * envelope_size;
10752            let offset = decoder.out_of_line_offset(bytes_len)?;
10753            // Decode the envelope for each type.
10754            let mut _next_ordinal_to_read = 0;
10755            let mut next_offset = offset;
10756            let end_offset = offset + bytes_len;
10757            _next_ordinal_to_read += 1;
10758            if next_offset >= end_offset {
10759                return Ok(());
10760            }
10761
10762            // Decode unknown envelopes for gaps in ordinals.
10763            while _next_ordinal_to_read < 1 {
10764                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10765                _next_ordinal_to_read += 1;
10766                next_offset += envelope_size;
10767            }
10768
10769            let next_out_of_line = decoder.next_out_of_line();
10770            let handles_before = decoder.remaining_handles();
10771            if let Some((inlined, num_bytes, num_handles)) =
10772                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10773            {
10774                let member_inline_size =
10775                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
10776                        decoder.context,
10777                    );
10778                if inlined != (member_inline_size <= 4) {
10779                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10780                }
10781                let inner_offset;
10782                let mut inner_depth = depth.clone();
10783                if inlined {
10784                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10785                    inner_offset = next_offset;
10786                } else {
10787                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10788                    inner_depth.increment()?;
10789                }
10790                let val_ref =
10791                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
10792                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
10793                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10794                {
10795                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10796                }
10797                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10798                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10799                }
10800            }
10801
10802            next_offset += envelope_size;
10803
10804            // Decode the remaining unknown envelopes.
10805            while next_offset < end_offset {
10806                _next_ordinal_to_read += 1;
10807                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10808                next_offset += envelope_size;
10809            }
10810
10811            Ok(())
10812        }
10813    }
10814
10815    impl SecureMemGetPhysicalSecureHeapPropertiesRequest {
10816        #[inline(always)]
10817        fn max_ordinal_present(&self) -> u64 {
10818            if let Some(_) = self.entire_heap {
10819                return 1;
10820            }
10821            0
10822        }
10823    }
10824
10825    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapPropertiesRequest {
10826        type Borrowed<'a> = &'a Self;
10827        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10828            value
10829        }
10830    }
10831
10832    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapPropertiesRequest {
10833        type Owned = Self;
10834
10835        #[inline(always)]
10836        fn inline_align(_context: fidl::encoding::Context) -> usize {
10837            8
10838        }
10839
10840        #[inline(always)]
10841        fn inline_size(_context: fidl::encoding::Context) -> usize {
10842            16
10843        }
10844    }
10845
10846    unsafe impl<D: fidl::encoding::ResourceDialect>
10847        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapPropertiesRequest, D>
10848        for &SecureMemGetPhysicalSecureHeapPropertiesRequest
10849    {
10850        unsafe fn encode(
10851            self,
10852            encoder: &mut fidl::encoding::Encoder<'_, D>,
10853            offset: usize,
10854            mut depth: fidl::encoding::Depth,
10855        ) -> fidl::Result<()> {
10856            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(offset);
10857            // Vector header
10858            let max_ordinal: u64 = self.max_ordinal_present();
10859            encoder.write_num(max_ordinal, offset);
10860            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10861            // Calling encoder.out_of_line_offset(0) is not allowed.
10862            if max_ordinal == 0 {
10863                return Ok(());
10864            }
10865            depth.increment()?;
10866            let envelope_size = 8;
10867            let bytes_len = max_ordinal as usize * envelope_size;
10868            #[allow(unused_variables)]
10869            let offset = encoder.out_of_line_offset(bytes_len);
10870            let mut _prev_end_offset: usize = 0;
10871            if 1 > max_ordinal {
10872                return Ok(());
10873            }
10874
10875            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10876            // are envelope_size bytes.
10877            let cur_offset: usize = (1 - 1) * envelope_size;
10878
10879            // Zero reserved fields.
10880            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10881
10882            // Safety:
10883            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10884            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10885            //   envelope_size bytes, there is always sufficient room.
10886            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
10887                self.entire_heap
10888                    .as_ref()
10889                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
10890                encoder,
10891                offset + cur_offset,
10892                depth,
10893            )?;
10894
10895            _prev_end_offset = cur_offset + envelope_size;
10896
10897            Ok(())
10898        }
10899    }
10900
10901    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
10902        for SecureMemGetPhysicalSecureHeapPropertiesRequest
10903    {
10904        #[inline(always)]
10905        fn new_empty() -> Self {
10906            Self::default()
10907        }
10908
10909        unsafe fn decode(
10910            &mut self,
10911            decoder: &mut fidl::encoding::Decoder<'_, D>,
10912            offset: usize,
10913            mut depth: fidl::encoding::Depth,
10914        ) -> fidl::Result<()> {
10915            decoder.debug_check_bounds::<Self>(offset);
10916            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10917                None => return Err(fidl::Error::NotNullable),
10918                Some(len) => len,
10919            };
10920            // Calling decoder.out_of_line_offset(0) is not allowed.
10921            if len == 0 {
10922                return Ok(());
10923            };
10924            depth.increment()?;
10925            let envelope_size = 8;
10926            let bytes_len = len * envelope_size;
10927            let offset = decoder.out_of_line_offset(bytes_len)?;
10928            // Decode the envelope for each type.
10929            let mut _next_ordinal_to_read = 0;
10930            let mut next_offset = offset;
10931            let end_offset = offset + bytes_len;
10932            _next_ordinal_to_read += 1;
10933            if next_offset >= end_offset {
10934                return Ok(());
10935            }
10936
10937            // Decode unknown envelopes for gaps in ordinals.
10938            while _next_ordinal_to_read < 1 {
10939                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10940                _next_ordinal_to_read += 1;
10941                next_offset += envelope_size;
10942            }
10943
10944            let next_out_of_line = decoder.next_out_of_line();
10945            let handles_before = decoder.remaining_handles();
10946            if let Some((inlined, num_bytes, num_handles)) =
10947                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10948            {
10949                let member_inline_size =
10950                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
10951                        decoder.context,
10952                    );
10953                if inlined != (member_inline_size <= 4) {
10954                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10955                }
10956                let inner_offset;
10957                let mut inner_depth = depth.clone();
10958                if inlined {
10959                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10960                    inner_offset = next_offset;
10961                } else {
10962                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10963                    inner_depth.increment()?;
10964                }
10965                let val_ref =
10966                    self.entire_heap.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
10967                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
10968                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10969                {
10970                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10971                }
10972                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10973                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10974                }
10975            }
10976
10977            next_offset += envelope_size;
10978
10979            // Decode the remaining unknown envelopes.
10980            while next_offset < end_offset {
10981                _next_ordinal_to_read += 1;
10982                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10983                next_offset += envelope_size;
10984            }
10985
10986            Ok(())
10987        }
10988    }
10989
10990    impl SecureMemModifySecureHeapPhysicalRangeRequest {
10991        #[inline(always)]
10992        fn max_ordinal_present(&self) -> u64 {
10993            if let Some(_) = self.range_modification {
10994                return 1;
10995            }
10996            0
10997        }
10998    }
10999
11000    impl fidl::encoding::ValueTypeMarker for SecureMemModifySecureHeapPhysicalRangeRequest {
11001        type Borrowed<'a> = &'a Self;
11002        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11003            value
11004        }
11005    }
11006
11007    unsafe impl fidl::encoding::TypeMarker for SecureMemModifySecureHeapPhysicalRangeRequest {
11008        type Owned = Self;
11009
11010        #[inline(always)]
11011        fn inline_align(_context: fidl::encoding::Context) -> usize {
11012            8
11013        }
11014
11015        #[inline(always)]
11016        fn inline_size(_context: fidl::encoding::Context) -> usize {
11017            16
11018        }
11019    }
11020
11021    unsafe impl<D: fidl::encoding::ResourceDialect>
11022        fidl::encoding::Encode<SecureMemModifySecureHeapPhysicalRangeRequest, D>
11023        for &SecureMemModifySecureHeapPhysicalRangeRequest
11024    {
11025        unsafe fn encode(
11026            self,
11027            encoder: &mut fidl::encoding::Encoder<'_, D>,
11028            offset: usize,
11029            mut depth: fidl::encoding::Depth,
11030        ) -> fidl::Result<()> {
11031            encoder.debug_check_bounds::<SecureMemModifySecureHeapPhysicalRangeRequest>(offset);
11032            // Vector header
11033            let max_ordinal: u64 = self.max_ordinal_present();
11034            encoder.write_num(max_ordinal, offset);
11035            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11036            // Calling encoder.out_of_line_offset(0) is not allowed.
11037            if max_ordinal == 0 {
11038                return Ok(());
11039            }
11040            depth.increment()?;
11041            let envelope_size = 8;
11042            let bytes_len = max_ordinal as usize * envelope_size;
11043            #[allow(unused_variables)]
11044            let offset = encoder.out_of_line_offset(bytes_len);
11045            let mut _prev_end_offset: usize = 0;
11046            if 1 > max_ordinal {
11047                return Ok(());
11048            }
11049
11050            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11051            // are envelope_size bytes.
11052            let cur_offset: usize = (1 - 1) * envelope_size;
11053
11054            // Zero reserved fields.
11055            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11056
11057            // Safety:
11058            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11059            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11060            //   envelope_size bytes, there is always sufficient room.
11061            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRangeModification, D>(
11062                self.range_modification.as_ref().map(
11063                    <SecureHeapAndRangeModification as fidl::encoding::ValueTypeMarker>::borrow,
11064                ),
11065                encoder,
11066                offset + cur_offset,
11067                depth,
11068            )?;
11069
11070            _prev_end_offset = cur_offset + envelope_size;
11071
11072            Ok(())
11073        }
11074    }
11075
11076    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11077        for SecureMemModifySecureHeapPhysicalRangeRequest
11078    {
11079        #[inline(always)]
11080        fn new_empty() -> Self {
11081            Self::default()
11082        }
11083
11084        unsafe fn decode(
11085            &mut self,
11086            decoder: &mut fidl::encoding::Decoder<'_, D>,
11087            offset: usize,
11088            mut depth: fidl::encoding::Depth,
11089        ) -> fidl::Result<()> {
11090            decoder.debug_check_bounds::<Self>(offset);
11091            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11092                None => return Err(fidl::Error::NotNullable),
11093                Some(len) => len,
11094            };
11095            // Calling decoder.out_of_line_offset(0) is not allowed.
11096            if len == 0 {
11097                return Ok(());
11098            };
11099            depth.increment()?;
11100            let envelope_size = 8;
11101            let bytes_len = len * envelope_size;
11102            let offset = decoder.out_of_line_offset(bytes_len)?;
11103            // Decode the envelope for each type.
11104            let mut _next_ordinal_to_read = 0;
11105            let mut next_offset = offset;
11106            let end_offset = offset + bytes_len;
11107            _next_ordinal_to_read += 1;
11108            if next_offset >= end_offset {
11109                return Ok(());
11110            }
11111
11112            // Decode unknown envelopes for gaps in ordinals.
11113            while _next_ordinal_to_read < 1 {
11114                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11115                _next_ordinal_to_read += 1;
11116                next_offset += envelope_size;
11117            }
11118
11119            let next_out_of_line = decoder.next_out_of_line();
11120            let handles_before = decoder.remaining_handles();
11121            if let Some((inlined, num_bytes, num_handles)) =
11122                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11123            {
11124                let member_inline_size =
11125                    <SecureHeapAndRangeModification as fidl::encoding::TypeMarker>::inline_size(
11126                        decoder.context,
11127                    );
11128                if inlined != (member_inline_size <= 4) {
11129                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11130                }
11131                let inner_offset;
11132                let mut inner_depth = depth.clone();
11133                if inlined {
11134                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11135                    inner_offset = next_offset;
11136                } else {
11137                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11138                    inner_depth.increment()?;
11139                }
11140                let val_ref = self
11141                    .range_modification
11142                    .get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRangeModification, D));
11143                fidl::decode!(
11144                    SecureHeapAndRangeModification,
11145                    D,
11146                    val_ref,
11147                    decoder,
11148                    inner_offset,
11149                    inner_depth
11150                )?;
11151                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11152                {
11153                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11154                }
11155                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11156                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11157                }
11158            }
11159
11160            next_offset += envelope_size;
11161
11162            // Decode the remaining unknown envelopes.
11163            while next_offset < end_offset {
11164                _next_ordinal_to_read += 1;
11165                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11166                next_offset += envelope_size;
11167            }
11168
11169            Ok(())
11170        }
11171    }
11172
11173    impl SecureMemZeroSubRangeRequest {
11174        #[inline(always)]
11175        fn max_ordinal_present(&self) -> u64 {
11176            if let Some(_) = self.heap_range {
11177                return 2;
11178            }
11179            if let Some(_) = self.is_covering_range_explicit {
11180                return 1;
11181            }
11182            0
11183        }
11184    }
11185
11186    impl fidl::encoding::ValueTypeMarker for SecureMemZeroSubRangeRequest {
11187        type Borrowed<'a> = &'a Self;
11188        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11189            value
11190        }
11191    }
11192
11193    unsafe impl fidl::encoding::TypeMarker for SecureMemZeroSubRangeRequest {
11194        type Owned = Self;
11195
11196        #[inline(always)]
11197        fn inline_align(_context: fidl::encoding::Context) -> usize {
11198            8
11199        }
11200
11201        #[inline(always)]
11202        fn inline_size(_context: fidl::encoding::Context) -> usize {
11203            16
11204        }
11205    }
11206
11207    unsafe impl<D: fidl::encoding::ResourceDialect>
11208        fidl::encoding::Encode<SecureMemZeroSubRangeRequest, D> for &SecureMemZeroSubRangeRequest
11209    {
11210        unsafe fn encode(
11211            self,
11212            encoder: &mut fidl::encoding::Encoder<'_, D>,
11213            offset: usize,
11214            mut depth: fidl::encoding::Depth,
11215        ) -> fidl::Result<()> {
11216            encoder.debug_check_bounds::<SecureMemZeroSubRangeRequest>(offset);
11217            // Vector header
11218            let max_ordinal: u64 = self.max_ordinal_present();
11219            encoder.write_num(max_ordinal, offset);
11220            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11221            // Calling encoder.out_of_line_offset(0) is not allowed.
11222            if max_ordinal == 0 {
11223                return Ok(());
11224            }
11225            depth.increment()?;
11226            let envelope_size = 8;
11227            let bytes_len = max_ordinal as usize * envelope_size;
11228            #[allow(unused_variables)]
11229            let offset = encoder.out_of_line_offset(bytes_len);
11230            let mut _prev_end_offset: usize = 0;
11231            if 1 > max_ordinal {
11232                return Ok(());
11233            }
11234
11235            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11236            // are envelope_size bytes.
11237            let cur_offset: usize = (1 - 1) * envelope_size;
11238
11239            // Zero reserved fields.
11240            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11241
11242            // Safety:
11243            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11244            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11245            //   envelope_size bytes, there is always sufficient room.
11246            fidl::encoding::encode_in_envelope_optional::<bool, D>(
11247                self.is_covering_range_explicit
11248                    .as_ref()
11249                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11250                encoder,
11251                offset + cur_offset,
11252                depth,
11253            )?;
11254
11255            _prev_end_offset = cur_offset + envelope_size;
11256            if 2 > max_ordinal {
11257                return Ok(());
11258            }
11259
11260            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11261            // are envelope_size bytes.
11262            let cur_offset: usize = (2 - 1) * envelope_size;
11263
11264            // Zero reserved fields.
11265            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11266
11267            // Safety:
11268            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11269            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11270            //   envelope_size bytes, there is always sufficient room.
11271            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11272                self.heap_range
11273                    .as_ref()
11274                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11275                encoder,
11276                offset + cur_offset,
11277                depth,
11278            )?;
11279
11280            _prev_end_offset = cur_offset + envelope_size;
11281
11282            Ok(())
11283        }
11284    }
11285
11286    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11287        for SecureMemZeroSubRangeRequest
11288    {
11289        #[inline(always)]
11290        fn new_empty() -> Self {
11291            Self::default()
11292        }
11293
11294        unsafe fn decode(
11295            &mut self,
11296            decoder: &mut fidl::encoding::Decoder<'_, D>,
11297            offset: usize,
11298            mut depth: fidl::encoding::Depth,
11299        ) -> fidl::Result<()> {
11300            decoder.debug_check_bounds::<Self>(offset);
11301            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11302                None => return Err(fidl::Error::NotNullable),
11303                Some(len) => len,
11304            };
11305            // Calling decoder.out_of_line_offset(0) is not allowed.
11306            if len == 0 {
11307                return Ok(());
11308            };
11309            depth.increment()?;
11310            let envelope_size = 8;
11311            let bytes_len = len * envelope_size;
11312            let offset = decoder.out_of_line_offset(bytes_len)?;
11313            // Decode the envelope for each type.
11314            let mut _next_ordinal_to_read = 0;
11315            let mut next_offset = offset;
11316            let end_offset = offset + bytes_len;
11317            _next_ordinal_to_read += 1;
11318            if next_offset >= end_offset {
11319                return Ok(());
11320            }
11321
11322            // Decode unknown envelopes for gaps in ordinals.
11323            while _next_ordinal_to_read < 1 {
11324                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11325                _next_ordinal_to_read += 1;
11326                next_offset += envelope_size;
11327            }
11328
11329            let next_out_of_line = decoder.next_out_of_line();
11330            let handles_before = decoder.remaining_handles();
11331            if let Some((inlined, num_bytes, num_handles)) =
11332                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11333            {
11334                let member_inline_size =
11335                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11336                if inlined != (member_inline_size <= 4) {
11337                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11338                }
11339                let inner_offset;
11340                let mut inner_depth = depth.clone();
11341                if inlined {
11342                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11343                    inner_offset = next_offset;
11344                } else {
11345                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11346                    inner_depth.increment()?;
11347                }
11348                let val_ref = self
11349                    .is_covering_range_explicit
11350                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
11351                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
11352                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11353                {
11354                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11355                }
11356                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11357                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11358                }
11359            }
11360
11361            next_offset += envelope_size;
11362            _next_ordinal_to_read += 1;
11363            if next_offset >= end_offset {
11364                return Ok(());
11365            }
11366
11367            // Decode unknown envelopes for gaps in ordinals.
11368            while _next_ordinal_to_read < 2 {
11369                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11370                _next_ordinal_to_read += 1;
11371                next_offset += envelope_size;
11372            }
11373
11374            let next_out_of_line = decoder.next_out_of_line();
11375            let handles_before = decoder.remaining_handles();
11376            if let Some((inlined, num_bytes, num_handles)) =
11377                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11378            {
11379                let member_inline_size =
11380                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11381                        decoder.context,
11382                    );
11383                if inlined != (member_inline_size <= 4) {
11384                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11385                }
11386                let inner_offset;
11387                let mut inner_depth = depth.clone();
11388                if inlined {
11389                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11390                    inner_offset = next_offset;
11391                } else {
11392                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11393                    inner_depth.increment()?;
11394                }
11395                let val_ref =
11396                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11397                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11398                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11399                {
11400                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11401                }
11402                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11403                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11404                }
11405            }
11406
11407            next_offset += envelope_size;
11408
11409            // Decode the remaining unknown envelopes.
11410            while next_offset < end_offset {
11411                _next_ordinal_to_read += 1;
11412                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11413                next_offset += envelope_size;
11414            }
11415
11416            Ok(())
11417        }
11418    }
11419
11420    impl SecureMemGetDynamicSecureHeapsResponse {
11421        #[inline(always)]
11422        fn max_ordinal_present(&self) -> u64 {
11423            if let Some(_) = self.heaps {
11424                return 1;
11425            }
11426            0
11427        }
11428    }
11429
11430    impl fidl::encoding::ValueTypeMarker for SecureMemGetDynamicSecureHeapsResponse {
11431        type Borrowed<'a> = &'a Self;
11432        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11433            value
11434        }
11435    }
11436
11437    unsafe impl fidl::encoding::TypeMarker for SecureMemGetDynamicSecureHeapsResponse {
11438        type Owned = Self;
11439
11440        #[inline(always)]
11441        fn inline_align(_context: fidl::encoding::Context) -> usize {
11442            8
11443        }
11444
11445        #[inline(always)]
11446        fn inline_size(_context: fidl::encoding::Context) -> usize {
11447            16
11448        }
11449    }
11450
11451    unsafe impl<D: fidl::encoding::ResourceDialect>
11452        fidl::encoding::Encode<SecureMemGetDynamicSecureHeapsResponse, D>
11453        for &SecureMemGetDynamicSecureHeapsResponse
11454    {
11455        unsafe fn encode(
11456            self,
11457            encoder: &mut fidl::encoding::Encoder<'_, D>,
11458            offset: usize,
11459            mut depth: fidl::encoding::Depth,
11460        ) -> fidl::Result<()> {
11461            encoder.debug_check_bounds::<SecureMemGetDynamicSecureHeapsResponse>(offset);
11462            // Vector header
11463            let max_ordinal: u64 = self.max_ordinal_present();
11464            encoder.write_num(max_ordinal, offset);
11465            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11466            // Calling encoder.out_of_line_offset(0) is not allowed.
11467            if max_ordinal == 0 {
11468                return Ok(());
11469            }
11470            depth.increment()?;
11471            let envelope_size = 8;
11472            let bytes_len = max_ordinal as usize * envelope_size;
11473            #[allow(unused_variables)]
11474            let offset = encoder.out_of_line_offset(bytes_len);
11475            let mut _prev_end_offset: usize = 0;
11476            if 1 > max_ordinal {
11477                return Ok(());
11478            }
11479
11480            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11481            // are envelope_size bytes.
11482            let cur_offset: usize = (1 - 1) * envelope_size;
11483
11484            // Zero reserved fields.
11485            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11486
11487            // Safety:
11488            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11489            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11490            //   envelope_size bytes, there is always sufficient room.
11491            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<DynamicSecureHeap, 32>, D>(
11492            self.heaps.as_ref().map(<fidl::encoding::Vector<DynamicSecureHeap, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11493            encoder, offset + cur_offset, depth
11494        )?;
11495
11496            _prev_end_offset = cur_offset + envelope_size;
11497
11498            Ok(())
11499        }
11500    }
11501
11502    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11503        for SecureMemGetDynamicSecureHeapsResponse
11504    {
11505        #[inline(always)]
11506        fn new_empty() -> Self {
11507            Self::default()
11508        }
11509
11510        unsafe fn decode(
11511            &mut self,
11512            decoder: &mut fidl::encoding::Decoder<'_, D>,
11513            offset: usize,
11514            mut depth: fidl::encoding::Depth,
11515        ) -> fidl::Result<()> {
11516            decoder.debug_check_bounds::<Self>(offset);
11517            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11518                None => return Err(fidl::Error::NotNullable),
11519                Some(len) => len,
11520            };
11521            // Calling decoder.out_of_line_offset(0) is not allowed.
11522            if len == 0 {
11523                return Ok(());
11524            };
11525            depth.increment()?;
11526            let envelope_size = 8;
11527            let bytes_len = len * envelope_size;
11528            let offset = decoder.out_of_line_offset(bytes_len)?;
11529            // Decode the envelope for each type.
11530            let mut _next_ordinal_to_read = 0;
11531            let mut next_offset = offset;
11532            let end_offset = offset + bytes_len;
11533            _next_ordinal_to_read += 1;
11534            if next_offset >= end_offset {
11535                return Ok(());
11536            }
11537
11538            // Decode unknown envelopes for gaps in ordinals.
11539            while _next_ordinal_to_read < 1 {
11540                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11541                _next_ordinal_to_read += 1;
11542                next_offset += envelope_size;
11543            }
11544
11545            let next_out_of_line = decoder.next_out_of_line();
11546            let handles_before = decoder.remaining_handles();
11547            if let Some((inlined, num_bytes, num_handles)) =
11548                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11549            {
11550                let member_inline_size = <fidl::encoding::Vector<DynamicSecureHeap, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11551                if inlined != (member_inline_size <= 4) {
11552                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11553                }
11554                let inner_offset;
11555                let mut inner_depth = depth.clone();
11556                if inlined {
11557                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11558                    inner_offset = next_offset;
11559                } else {
11560                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11561                    inner_depth.increment()?;
11562                }
11563                let val_ref = self.heaps.get_or_insert_with(
11564                    || fidl::new_empty!(fidl::encoding::Vector<DynamicSecureHeap, 32>, D),
11565                );
11566                fidl::decode!(fidl::encoding::Vector<DynamicSecureHeap, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
11567                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11568                {
11569                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11570                }
11571                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11572                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11573                }
11574            }
11575
11576            next_offset += envelope_size;
11577
11578            // Decode the remaining unknown envelopes.
11579            while next_offset < end_offset {
11580                _next_ordinal_to_read += 1;
11581                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11582                next_offset += envelope_size;
11583            }
11584
11585            Ok(())
11586        }
11587    }
11588
11589    impl SecureMemGetPhysicalSecureHeapPropertiesResponse {
11590        #[inline(always)]
11591        fn max_ordinal_present(&self) -> u64 {
11592            if let Some(_) = self.properties {
11593                return 1;
11594            }
11595            0
11596        }
11597    }
11598
11599    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapPropertiesResponse {
11600        type Borrowed<'a> = &'a Self;
11601        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11602            value
11603        }
11604    }
11605
11606    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapPropertiesResponse {
11607        type Owned = Self;
11608
11609        #[inline(always)]
11610        fn inline_align(_context: fidl::encoding::Context) -> usize {
11611            8
11612        }
11613
11614        #[inline(always)]
11615        fn inline_size(_context: fidl::encoding::Context) -> usize {
11616            16
11617        }
11618    }
11619
11620    unsafe impl<D: fidl::encoding::ResourceDialect>
11621        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapPropertiesResponse, D>
11622        for &SecureMemGetPhysicalSecureHeapPropertiesResponse
11623    {
11624        unsafe fn encode(
11625            self,
11626            encoder: &mut fidl::encoding::Encoder<'_, D>,
11627            offset: usize,
11628            mut depth: fidl::encoding::Depth,
11629        ) -> fidl::Result<()> {
11630            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapPropertiesResponse>(offset);
11631            // Vector header
11632            let max_ordinal: u64 = self.max_ordinal_present();
11633            encoder.write_num(max_ordinal, offset);
11634            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11635            // Calling encoder.out_of_line_offset(0) is not allowed.
11636            if max_ordinal == 0 {
11637                return Ok(());
11638            }
11639            depth.increment()?;
11640            let envelope_size = 8;
11641            let bytes_len = max_ordinal as usize * envelope_size;
11642            #[allow(unused_variables)]
11643            let offset = encoder.out_of_line_offset(bytes_len);
11644            let mut _prev_end_offset: usize = 0;
11645            if 1 > max_ordinal {
11646                return Ok(());
11647            }
11648
11649            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11650            // are envelope_size bytes.
11651            let cur_offset: usize = (1 - 1) * envelope_size;
11652
11653            // Zero reserved fields.
11654            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11655
11656            // Safety:
11657            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11658            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11659            //   envelope_size bytes, there is always sufficient room.
11660            fidl::encoding::encode_in_envelope_optional::<SecureHeapProperties, D>(
11661                self.properties
11662                    .as_ref()
11663                    .map(<SecureHeapProperties as fidl::encoding::ValueTypeMarker>::borrow),
11664                encoder,
11665                offset + cur_offset,
11666                depth,
11667            )?;
11668
11669            _prev_end_offset = cur_offset + envelope_size;
11670
11671            Ok(())
11672        }
11673    }
11674
11675    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11676        for SecureMemGetPhysicalSecureHeapPropertiesResponse
11677    {
11678        #[inline(always)]
11679        fn new_empty() -> Self {
11680            Self::default()
11681        }
11682
11683        unsafe fn decode(
11684            &mut self,
11685            decoder: &mut fidl::encoding::Decoder<'_, D>,
11686            offset: usize,
11687            mut depth: fidl::encoding::Depth,
11688        ) -> fidl::Result<()> {
11689            decoder.debug_check_bounds::<Self>(offset);
11690            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11691                None => return Err(fidl::Error::NotNullable),
11692                Some(len) => len,
11693            };
11694            // Calling decoder.out_of_line_offset(0) is not allowed.
11695            if len == 0 {
11696                return Ok(());
11697            };
11698            depth.increment()?;
11699            let envelope_size = 8;
11700            let bytes_len = len * envelope_size;
11701            let offset = decoder.out_of_line_offset(bytes_len)?;
11702            // Decode the envelope for each type.
11703            let mut _next_ordinal_to_read = 0;
11704            let mut next_offset = offset;
11705            let end_offset = offset + bytes_len;
11706            _next_ordinal_to_read += 1;
11707            if next_offset >= end_offset {
11708                return Ok(());
11709            }
11710
11711            // Decode unknown envelopes for gaps in ordinals.
11712            while _next_ordinal_to_read < 1 {
11713                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11714                _next_ordinal_to_read += 1;
11715                next_offset += envelope_size;
11716            }
11717
11718            let next_out_of_line = decoder.next_out_of_line();
11719            let handles_before = decoder.remaining_handles();
11720            if let Some((inlined, num_bytes, num_handles)) =
11721                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11722            {
11723                let member_inline_size =
11724                    <SecureHeapProperties as fidl::encoding::TypeMarker>::inline_size(
11725                        decoder.context,
11726                    );
11727                if inlined != (member_inline_size <= 4) {
11728                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11729                }
11730                let inner_offset;
11731                let mut inner_depth = depth.clone();
11732                if inlined {
11733                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11734                    inner_offset = next_offset;
11735                } else {
11736                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11737                    inner_depth.increment()?;
11738                }
11739                let val_ref = self
11740                    .properties
11741                    .get_or_insert_with(|| fidl::new_empty!(SecureHeapProperties, D));
11742                fidl::decode!(
11743                    SecureHeapProperties,
11744                    D,
11745                    val_ref,
11746                    decoder,
11747                    inner_offset,
11748                    inner_depth
11749                )?;
11750                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11751                {
11752                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11753                }
11754                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11755                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11756                }
11757            }
11758
11759            next_offset += envelope_size;
11760
11761            // Decode the remaining unknown envelopes.
11762            while next_offset < end_offset {
11763                _next_ordinal_to_read += 1;
11764                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11765                next_offset += envelope_size;
11766            }
11767
11768            Ok(())
11769        }
11770    }
11771
11772    impl SecureMemGetPhysicalSecureHeapsResponse {
11773        #[inline(always)]
11774        fn max_ordinal_present(&self) -> u64 {
11775            if let Some(_) = self.heaps {
11776                return 1;
11777            }
11778            0
11779        }
11780    }
11781
11782    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapsResponse {
11783        type Borrowed<'a> = &'a Self;
11784        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11785            value
11786        }
11787    }
11788
11789    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapsResponse {
11790        type Owned = Self;
11791
11792        #[inline(always)]
11793        fn inline_align(_context: fidl::encoding::Context) -> usize {
11794            8
11795        }
11796
11797        #[inline(always)]
11798        fn inline_size(_context: fidl::encoding::Context) -> usize {
11799            16
11800        }
11801    }
11802
11803    unsafe impl<D: fidl::encoding::ResourceDialect>
11804        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapsResponse, D>
11805        for &SecureMemGetPhysicalSecureHeapsResponse
11806    {
11807        unsafe fn encode(
11808            self,
11809            encoder: &mut fidl::encoding::Encoder<'_, D>,
11810            offset: usize,
11811            mut depth: fidl::encoding::Depth,
11812        ) -> fidl::Result<()> {
11813            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapsResponse>(offset);
11814            // Vector header
11815            let max_ordinal: u64 = self.max_ordinal_present();
11816            encoder.write_num(max_ordinal, offset);
11817            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11818            // Calling encoder.out_of_line_offset(0) is not allowed.
11819            if max_ordinal == 0 {
11820                return Ok(());
11821            }
11822            depth.increment()?;
11823            let envelope_size = 8;
11824            let bytes_len = max_ordinal as usize * envelope_size;
11825            #[allow(unused_variables)]
11826            let offset = encoder.out_of_line_offset(bytes_len);
11827            let mut _prev_end_offset: usize = 0;
11828            if 1 > max_ordinal {
11829                return Ok(());
11830            }
11831
11832            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11833            // are envelope_size bytes.
11834            let cur_offset: usize = (1 - 1) * envelope_size;
11835
11836            // Zero reserved fields.
11837            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11838
11839            // Safety:
11840            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11841            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11842            //   envelope_size bytes, there is always sufficient room.
11843            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SecureHeapAndRanges, 32>, D>(
11844            self.heaps.as_ref().map(<fidl::encoding::Vector<SecureHeapAndRanges, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11845            encoder, offset + cur_offset, depth
11846        )?;
11847
11848            _prev_end_offset = cur_offset + envelope_size;
11849
11850            Ok(())
11851        }
11852    }
11853
11854    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11855        for SecureMemGetPhysicalSecureHeapsResponse
11856    {
11857        #[inline(always)]
11858        fn new_empty() -> Self {
11859            Self::default()
11860        }
11861
11862        unsafe fn decode(
11863            &mut self,
11864            decoder: &mut fidl::encoding::Decoder<'_, D>,
11865            offset: usize,
11866            mut depth: fidl::encoding::Depth,
11867        ) -> fidl::Result<()> {
11868            decoder.debug_check_bounds::<Self>(offset);
11869            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11870                None => return Err(fidl::Error::NotNullable),
11871                Some(len) => len,
11872            };
11873            // Calling decoder.out_of_line_offset(0) is not allowed.
11874            if len == 0 {
11875                return Ok(());
11876            };
11877            depth.increment()?;
11878            let envelope_size = 8;
11879            let bytes_len = len * envelope_size;
11880            let offset = decoder.out_of_line_offset(bytes_len)?;
11881            // Decode the envelope for each type.
11882            let mut _next_ordinal_to_read = 0;
11883            let mut next_offset = offset;
11884            let end_offset = offset + bytes_len;
11885            _next_ordinal_to_read += 1;
11886            if next_offset >= end_offset {
11887                return Ok(());
11888            }
11889
11890            // Decode unknown envelopes for gaps in ordinals.
11891            while _next_ordinal_to_read < 1 {
11892                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11893                _next_ordinal_to_read += 1;
11894                next_offset += envelope_size;
11895            }
11896
11897            let next_out_of_line = decoder.next_out_of_line();
11898            let handles_before = decoder.remaining_handles();
11899            if let Some((inlined, num_bytes, num_handles)) =
11900                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11901            {
11902                let member_inline_size = <fidl::encoding::Vector<SecureHeapAndRanges, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11903                if inlined != (member_inline_size <= 4) {
11904                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11905                }
11906                let inner_offset;
11907                let mut inner_depth = depth.clone();
11908                if inlined {
11909                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11910                    inner_offset = next_offset;
11911                } else {
11912                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11913                    inner_depth.increment()?;
11914                }
11915                let val_ref = self.heaps.get_or_insert_with(
11916                    || fidl::new_empty!(fidl::encoding::Vector<SecureHeapAndRanges, 32>, D),
11917                );
11918                fidl::decode!(fidl::encoding::Vector<SecureHeapAndRanges, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
11919                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11920                {
11921                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11922                }
11923                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11924                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11925                }
11926            }
11927
11928            next_offset += envelope_size;
11929
11930            // Decode the remaining unknown envelopes.
11931            while next_offset < end_offset {
11932                _next_ordinal_to_read += 1;
11933                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11934                next_offset += envelope_size;
11935            }
11936
11937            Ok(())
11938        }
11939    }
11940
11941    impl SingleBufferSettings {
11942        #[inline(always)]
11943        fn max_ordinal_present(&self) -> u64 {
11944            if let Some(_) = self.image_format_constraints {
11945                return 2;
11946            }
11947            if let Some(_) = self.buffer_settings {
11948                return 1;
11949            }
11950            0
11951        }
11952    }
11953
11954    impl fidl::encoding::ValueTypeMarker for SingleBufferSettings {
11955        type Borrowed<'a> = &'a Self;
11956        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11957            value
11958        }
11959    }
11960
11961    unsafe impl fidl::encoding::TypeMarker for SingleBufferSettings {
11962        type Owned = Self;
11963
11964        #[inline(always)]
11965        fn inline_align(_context: fidl::encoding::Context) -> usize {
11966            8
11967        }
11968
11969        #[inline(always)]
11970        fn inline_size(_context: fidl::encoding::Context) -> usize {
11971            16
11972        }
11973    }
11974
11975    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SingleBufferSettings, D>
11976        for &SingleBufferSettings
11977    {
11978        unsafe fn encode(
11979            self,
11980            encoder: &mut fidl::encoding::Encoder<'_, D>,
11981            offset: usize,
11982            mut depth: fidl::encoding::Depth,
11983        ) -> fidl::Result<()> {
11984            encoder.debug_check_bounds::<SingleBufferSettings>(offset);
11985            // Vector header
11986            let max_ordinal: u64 = self.max_ordinal_present();
11987            encoder.write_num(max_ordinal, offset);
11988            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11989            // Calling encoder.out_of_line_offset(0) is not allowed.
11990            if max_ordinal == 0 {
11991                return Ok(());
11992            }
11993            depth.increment()?;
11994            let envelope_size = 8;
11995            let bytes_len = max_ordinal as usize * envelope_size;
11996            #[allow(unused_variables)]
11997            let offset = encoder.out_of_line_offset(bytes_len);
11998            let mut _prev_end_offset: usize = 0;
11999            if 1 > max_ordinal {
12000                return Ok(());
12001            }
12002
12003            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12004            // are envelope_size bytes.
12005            let cur_offset: usize = (1 - 1) * envelope_size;
12006
12007            // Zero reserved fields.
12008            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12009
12010            // Safety:
12011            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12012            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12013            //   envelope_size bytes, there is always sufficient room.
12014            fidl::encoding::encode_in_envelope_optional::<BufferMemorySettings, D>(
12015                self.buffer_settings
12016                    .as_ref()
12017                    .map(<BufferMemorySettings as fidl::encoding::ValueTypeMarker>::borrow),
12018                encoder,
12019                offset + cur_offset,
12020                depth,
12021            )?;
12022
12023            _prev_end_offset = cur_offset + envelope_size;
12024            if 2 > max_ordinal {
12025                return Ok(());
12026            }
12027
12028            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12029            // are envelope_size bytes.
12030            let cur_offset: usize = (2 - 1) * envelope_size;
12031
12032            // Zero reserved fields.
12033            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12034
12035            // Safety:
12036            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12037            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12038            //   envelope_size bytes, there is always sufficient room.
12039            fidl::encoding::encode_in_envelope_optional::<ImageFormatConstraints, D>(
12040                self.image_format_constraints
12041                    .as_ref()
12042                    .map(<ImageFormatConstraints as fidl::encoding::ValueTypeMarker>::borrow),
12043                encoder,
12044                offset + cur_offset,
12045                depth,
12046            )?;
12047
12048            _prev_end_offset = cur_offset + envelope_size;
12049
12050            Ok(())
12051        }
12052    }
12053
12054    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SingleBufferSettings {
12055        #[inline(always)]
12056        fn new_empty() -> Self {
12057            Self::default()
12058        }
12059
12060        unsafe fn decode(
12061            &mut self,
12062            decoder: &mut fidl::encoding::Decoder<'_, D>,
12063            offset: usize,
12064            mut depth: fidl::encoding::Depth,
12065        ) -> fidl::Result<()> {
12066            decoder.debug_check_bounds::<Self>(offset);
12067            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12068                None => return Err(fidl::Error::NotNullable),
12069                Some(len) => len,
12070            };
12071            // Calling decoder.out_of_line_offset(0) is not allowed.
12072            if len == 0 {
12073                return Ok(());
12074            };
12075            depth.increment()?;
12076            let envelope_size = 8;
12077            let bytes_len = len * envelope_size;
12078            let offset = decoder.out_of_line_offset(bytes_len)?;
12079            // Decode the envelope for each type.
12080            let mut _next_ordinal_to_read = 0;
12081            let mut next_offset = offset;
12082            let end_offset = offset + bytes_len;
12083            _next_ordinal_to_read += 1;
12084            if next_offset >= end_offset {
12085                return Ok(());
12086            }
12087
12088            // Decode unknown envelopes for gaps in ordinals.
12089            while _next_ordinal_to_read < 1 {
12090                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12091                _next_ordinal_to_read += 1;
12092                next_offset += envelope_size;
12093            }
12094
12095            let next_out_of_line = decoder.next_out_of_line();
12096            let handles_before = decoder.remaining_handles();
12097            if let Some((inlined, num_bytes, num_handles)) =
12098                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12099            {
12100                let member_inline_size =
12101                    <BufferMemorySettings as fidl::encoding::TypeMarker>::inline_size(
12102                        decoder.context,
12103                    );
12104                if inlined != (member_inline_size <= 4) {
12105                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12106                }
12107                let inner_offset;
12108                let mut inner_depth = depth.clone();
12109                if inlined {
12110                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12111                    inner_offset = next_offset;
12112                } else {
12113                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12114                    inner_depth.increment()?;
12115                }
12116                let val_ref = self
12117                    .buffer_settings
12118                    .get_or_insert_with(|| fidl::new_empty!(BufferMemorySettings, D));
12119                fidl::decode!(
12120                    BufferMemorySettings,
12121                    D,
12122                    val_ref,
12123                    decoder,
12124                    inner_offset,
12125                    inner_depth
12126                )?;
12127                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12128                {
12129                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12130                }
12131                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12132                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12133                }
12134            }
12135
12136            next_offset += envelope_size;
12137            _next_ordinal_to_read += 1;
12138            if next_offset >= end_offset {
12139                return Ok(());
12140            }
12141
12142            // Decode unknown envelopes for gaps in ordinals.
12143            while _next_ordinal_to_read < 2 {
12144                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12145                _next_ordinal_to_read += 1;
12146                next_offset += envelope_size;
12147            }
12148
12149            let next_out_of_line = decoder.next_out_of_line();
12150            let handles_before = decoder.remaining_handles();
12151            if let Some((inlined, num_bytes, num_handles)) =
12152                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12153            {
12154                let member_inline_size =
12155                    <ImageFormatConstraints as fidl::encoding::TypeMarker>::inline_size(
12156                        decoder.context,
12157                    );
12158                if inlined != (member_inline_size <= 4) {
12159                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12160                }
12161                let inner_offset;
12162                let mut inner_depth = depth.clone();
12163                if inlined {
12164                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12165                    inner_offset = next_offset;
12166                } else {
12167                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12168                    inner_depth.increment()?;
12169                }
12170                let val_ref = self
12171                    .image_format_constraints
12172                    .get_or_insert_with(|| fidl::new_empty!(ImageFormatConstraints, D));
12173                fidl::decode!(
12174                    ImageFormatConstraints,
12175                    D,
12176                    val_ref,
12177                    decoder,
12178                    inner_offset,
12179                    inner_depth
12180                )?;
12181                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12182                {
12183                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12184                }
12185                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12186                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12187                }
12188            }
12189
12190            next_offset += envelope_size;
12191
12192            // Decode the remaining unknown envelopes.
12193            while next_offset < end_offset {
12194                _next_ordinal_to_read += 1;
12195                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12196                next_offset += envelope_size;
12197            }
12198
12199            Ok(())
12200        }
12201    }
12202}