fidl_fuchsia_sysmem2__common/
fidl_fuchsia_sysmem2__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub const CPU_USAGE_READ: u32 = 1;
12
13pub const CPU_USAGE_READ_OFTEN: u32 = 2;
14
15pub const CPU_USAGE_WRITE: u32 = 4;
16
17pub const CPU_USAGE_WRITE_OFTEN: u32 = 8;
18
19pub const DISPLAY_USAGE_CURSOR: u32 = 2;
20
21pub const DISPLAY_USAGE_LAYER: u32 = 1;
22
23/// The max length in bytes of the `name` request field in
24/// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] and
25/// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
26pub const MAX_CLIENT_NAME_LENGTH: i32 = 256;
27
28/// The maximum size of
29/// [`fuchsia.sysmem2/BufferCollectionConstraints.image_format_constraints`].
30pub const MAX_COUNT_BUFFER_COLLECTION_CONSTRAINTS_IMAGE_FORMAT_CONSTRAINTS: u32 = 64;
31
32/// The maximum entries that can be in the
33/// [`fuchsia.sysmem2/BufferCollectionInfo.buffers`] field.
34pub const MAX_COUNT_BUFFER_COLLECTION_INFO_BUFFERS: u32 = 128;
35
36/// The maximum size of
37/// [`fuchsia.sysmem2/BufferMemoryConstraints.permitted_heaps`].
38pub const MAX_COUNT_BUFFER_MEMORY_CONSTRAINTS_PERMITTED_HEAPS: u32 = 64;
39
40/// The maximum number of token children of an OR group that can be created per
41/// call to [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`].
42///
43/// Actually creating this many children isn't recommended in most typical
44/// scenarios, but isn't prevented, for testing reasons, and just in case an
45/// unusual scenario needs it. Mitigation of potentially high time complexity in
46/// sysmem will limit the actual number of group child combinations considered
47/// in aggregation attempts to a separate maximum that is not settable via
48/// sysmem protocols. The maximum number of total nodes in a sysmem token tree
49/// is limited to a separate maximum that is not settable via these protocols.
50pub const MAX_COUNT_CREATE_CHILDREN: i32 = 64;
51
52pub const MAX_COUNT_DUPLICATES: u32 = 64;
53
54/// The maximum size of [`fuchsia.sysmem2/ImageFormatConstraints.color_spaces`].
55pub const MAX_COUNT_IMAGE_FORMAT_CONSTRAINTS_COLOR_SPACES: u32 = 32;
56
57pub const MAX_COUNT_IMAGE_FORMAT_CONSTRAINTS_REQUIRED_MAX_SIZE_LIST: u32 = 64;
58
59/// The maximum size of
60/// [`fuchsia.sysmem2/ImageFormatConstraints.pixel_format_and_modifiers`].
61pub const MAX_COUNT_PIXEL_FORMAT_AND_MODIFIERS: u32 = 64;
62
63pub const MAX_HEAPS_COUNT: u32 = 32;
64
65pub const MAX_RANGES_COUNT: u32 = 128;
66
67pub const NONE_USAGE: u32 = 1;
68
69pub const NONE_USAGE_PERMIT_ALLOCATION: u32 = 2;
70
71pub const VIDEO_USAGE_CAPTURE: u32 = 8;
72
73pub const VIDEO_USAGE_DECRYPTOR_OUTPUT: u32 = 16;
74
75pub const VIDEO_USAGE_HW_DECODER: u32 = 1;
76
77pub const VIDEO_USAGE_HW_DECODER_INTERNAL: u32 = 32;
78
79pub const VIDEO_USAGE_HW_ENCODER: u32 = 2;
80
81pub const VULKAN_BUFFER_USAGE_INDEX_BUFFER: u32 = 4194304;
82
83pub const VULKAN_BUFFER_USAGE_INDIRECT_BUFFER: u32 = 16777216;
84
85pub const VULKAN_BUFFER_USAGE_STORAGE_BUFFER: u32 = 2097152;
86
87pub const VULKAN_BUFFER_USAGE_STORAGE_TEXEL_BUFFER: u32 = 524288;
88
89pub const VULKAN_BUFFER_USAGE_TRANSFER_DST: u32 = 131072;
90
91pub const VULKAN_BUFFER_USAGE_TRANSFER_SRC: u32 = 65536;
92
93pub const VULKAN_BUFFER_USAGE_UNIFORM_BUFFER: u32 = 1048576;
94
95pub const VULKAN_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER: u32 = 262144;
96
97pub const VULKAN_BUFFER_USAGE_VERTEX_BUFFER: u32 = 8388608;
98
99pub const VULKAN_IMAGE_USAGE_COLOR_ATTACHMENT: u32 = 16;
100
101pub const VULKAN_IMAGE_USAGE_INPUT_ATTACHMENT: u32 = 128;
102
103pub const VULKAN_IMAGE_USAGE_SAMPLED: u32 = 4;
104
105pub const VULKAN_IMAGE_USAGE_STENCIL_ATTACHMENT: u32 = 32;
106
107pub const VULKAN_IMAGE_USAGE_STORAGE: u32 = 8;
108
109pub const VULKAN_IMAGE_USAGE_TRANSFER_DST: u32 = 2;
110
111pub const VULKAN_IMAGE_USAGE_TRANSFER_SRC: u32 = 1;
112
113pub const VULKAN_IMAGE_USAGE_TRANSIENT_ATTACHMENT: u32 = 64;
114
115/// `INACCESSIBLE` is only for cases where there is no CPU access to the
116/// buffers.
117///
118/// Device-local memory that isn't reachable from the CPU is `CoherencyDomain`
119/// `INACCESSIBLE`, even if it's possible to cause a device (physical or
120/// virtual) to copy the data from the `INACCESSIBLE` buffers to buffers that
121/// are visible to the CPU. In other words, INACCESSIBLE does not imply secure,
122/// but secure implies INACCESSIBLE.
123///
124/// `CPU` means producers must ensure that a consumer can read the produced data
125/// with the CPU without the consumer needing to do additional cache ops not
126/// already performed (as needed) by the producer.
127///
128/// `RAM` means producers must ensure that the produced data is entirely present
129/// in RAM, without any dirty CPU cache lines, and a consumer must invalidate
130/// (or flush and invalidate, typically) the CPU cache before reading data with
131/// the CPU. The `RAM` domain can be faster than the `CPU` domain when all
132/// access is via HW DMA, since in that case no CPU cache ops are required,
133/// since no participant is actually reading/writing using the CPU.
134#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
135pub enum CoherencyDomain {
136    Cpu,
137    Ram,
138    Inaccessible,
139    #[doc(hidden)]
140    __SourceBreaking {
141        unknown_ordinal: u32,
142    },
143}
144
145/// Pattern that matches an unknown `CoherencyDomain` member.
146#[macro_export]
147macro_rules! CoherencyDomainUnknown {
148    () => {
149        _
150    };
151}
152
153impl CoherencyDomain {
154    #[inline]
155    pub fn from_primitive(prim: u32) -> Option<Self> {
156        match prim {
157            0 => Some(Self::Cpu),
158            1 => Some(Self::Ram),
159            2 => Some(Self::Inaccessible),
160            _ => None,
161        }
162    }
163
164    #[inline]
165    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
166        match prim {
167            0 => Self::Cpu,
168            1 => Self::Ram,
169            2 => Self::Inaccessible,
170            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
171        }
172    }
173
174    #[inline]
175    pub fn unknown() -> Self {
176        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
177    }
178
179    #[inline]
180    pub const fn into_primitive(self) -> u32 {
181        match self {
182            Self::Cpu => 0,
183            Self::Ram => 1,
184            Self::Inaccessible => 2,
185            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
186        }
187    }
188
189    #[inline]
190    pub fn is_unknown(&self) -> bool {
191        match self {
192            Self::__SourceBreaking { unknown_ordinal: _ } => true,
193            _ => false,
194        }
195    }
196}
197
198/// Regardless of which error code, any client retries should be very limited in
199/// number, if any.
200///
201/// A Error value should never be stored in a zx_status_t, since positive values
202/// in zx_status_t are deprecated.
203#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
204pub enum Error {
205    /// This is not a valid error value in this error enum. The server will
206    /// never send this value as a failure code. This value is not treated as
207    /// "success". In some languages, a locally default-initialized Error
208    /// instance will have this value until it is initialized with a valid
209    /// positive error code.
210    Invalid,
211    /// Unspecified error.
212    ///
213    /// This error code is used when no other error code applies, and the error
214    /// is probably not due to problematic messages sent to the server via the
215    /// channel delivering this error.
216    ///
217    /// This error should be handled by the client as a generic error.
218    ///
219    /// As one example, this error is used when a different client channel has
220    /// closed from the client end unexpectedly (without sending
221    /// [`fuchsia.sysmem2/Node.Release`] first), thereby causing failure of any
222    /// nodes in the same tree or sub-tree. In this usage, the main thing that's
223    /// relevant is it isn't the receiving client's "fault" - no reason to be
224    /// more specific since there's probably nothing the receiving client could
225    /// do about the error, at least not directly.
226    ///
227    /// As another example, this error can be used if a syscall that is normally
228    /// expected to succeed fails unexpectedly, and there's no identified reason
229    /// to "blame" the client.
230    ///
231    /// A client should never require / depend on a particular cause of error
232    /// continuing to result in UNSPECIFIED, as any particular error cause can
233    /// potentially start resulting in a more specific error code in future.
234    Unspecified,
235    /// A required field wasn't set or a specified value was invalid. See the
236    /// log for more info.
237    ///
238    /// This is also used when a message is received from the client in the
239    /// wrong order or in some way inconsistent with protocol rules.
240    ProtocolDeviation,
241    /// A client-specified object or ID was not found.
242    NotFound,
243    /// The object handle doesn't have sufficient rights to perform the request.
244    HandleAccessDenied,
245    /// The allocation could not be satisfied due to lack of available memory.
246    ///
247    /// The memory exhaustion can be specific to the heap that was selected
248    /// during constraints aggregation, so in some cases, this error can happen
249    /// despite normal system RAM not being near exhaustion, depending on
250    /// configured and selected heap(s).
251    NoMemory,
252    /// The request is valid but cannot be satisfied, perhaps due to hardware
253    /// limitations. This happens if participants involved in this allocation
254    /// have incompatible constraints (empty intersection, roughly speaking).
255    /// See the log for more info. In cases where a participant could
256    /// potentially be treated as optional, see [`BufferCollectionTokenGroup`].
257    ///
258    /// This can also happen if there aren't enough buffers in a pre-existing
259    /// collection to satisfy an additional token (including sub-tree of derived
260    /// tokens) created with [`fuchsia.sysmem2/BufferCollection.AttachToken`].
261    ///
262    /// This can also happen if a client's node is under a group and a different
263    /// group child is selected instead.
264    ConstraintsIntersectionEmpty,
265    /// Allocation hasn't been attempted yet. Calling
266    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] would
267    /// (likely) block.
268    Pending,
269    /// Too many `BufferCollectionTokenGroup` child token selection combinations
270    /// exist and were considered, causing sysmem to give up on allocating
271    /// rather than enumerate the rest.
272    TooManyGroupChildCombinations,
273    #[doc(hidden)]
274    __SourceBreaking { unknown_ordinal: u32 },
275}
276
277/// Pattern that matches an unknown `Error` member.
278#[macro_export]
279macro_rules! ErrorUnknown {
280    () => {
281        _
282    };
283}
284
285impl Error {
286    #[inline]
287    pub fn from_primitive(prim: u32) -> Option<Self> {
288        match prim {
289            0 => Some(Self::Invalid),
290            1 => Some(Self::Unspecified),
291            2 => Some(Self::ProtocolDeviation),
292            3 => Some(Self::NotFound),
293            4 => Some(Self::HandleAccessDenied),
294            5 => Some(Self::NoMemory),
295            6 => Some(Self::ConstraintsIntersectionEmpty),
296            7 => Some(Self::Pending),
297            8 => Some(Self::TooManyGroupChildCombinations),
298            _ => None,
299        }
300    }
301
302    #[inline]
303    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
304        match prim {
305            0 => Self::Invalid,
306            1 => Self::Unspecified,
307            2 => Self::ProtocolDeviation,
308            3 => Self::NotFound,
309            4 => Self::HandleAccessDenied,
310            5 => Self::NoMemory,
311            6 => Self::ConstraintsIntersectionEmpty,
312            7 => Self::Pending,
313            8 => Self::TooManyGroupChildCombinations,
314            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
315        }
316    }
317
318    #[inline]
319    pub fn unknown() -> Self {
320        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
321    }
322
323    #[inline]
324    pub const fn into_primitive(self) -> u32 {
325        match self {
326            Self::Invalid => 0,
327            Self::Unspecified => 1,
328            Self::ProtocolDeviation => 2,
329            Self::NotFound => 3,
330            Self::HandleAccessDenied => 4,
331            Self::NoMemory => 5,
332            Self::ConstraintsIntersectionEmpty => 6,
333            Self::Pending => 7,
334            Self::TooManyGroupChildCombinations => 8,
335            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
336        }
337    }
338
339    #[inline]
340    pub fn is_unknown(&self) -> bool {
341        match self {
342            Self::__SourceBreaking { unknown_ordinal: _ } => true,
343            _ => false,
344        }
345    }
346}
347
348#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
349pub struct PixelFormatAndModifier {
350    /// When specified by a participant in a message to sysmem, this can be any
351    /// `PixelFormat` value that's acceptable to the participant. Specifying
352    /// `kInvalid` is not permitted.
353    ///
354    /// The participant can specify [`fuchsia.images2/PixelFormat.DO_NOT_CARE`]
355    /// if the participant needs to specify `ImageFormatConstraints` without
356    /// constraining the `pixel_format`.
357    pub pixel_format: fidl_fuchsia_images2__common::PixelFormat,
358    /// The participant can specify
359    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] if the participant
360    /// needs to specify `ImageFormatConstraints` without constraining the
361    /// `pixel_format_modifier`.
362    pub pixel_format_modifier: fidl_fuchsia_images2__common::PixelFormatModifier,
363}
364
365impl fidl::Persistable for PixelFormatAndModifier {}
366
367#[derive(Clone, Debug, Default, PartialEq)]
368pub struct AllocatorSetDebugClientInfoRequest {
369    pub name: Option<String>,
370    pub id: Option<u64>,
371    #[doc(hidden)]
372    pub __source_breaking: fidl::marker::SourceBreaking,
373}
374
375impl fidl::Persistable for AllocatorSetDebugClientInfoRequest {}
376
377#[derive(Clone, Debug, Default, PartialEq)]
378pub struct AllocatorValidateBufferCollectionTokenRequest {
379    pub token_server_koid: Option<u64>,
380    #[doc(hidden)]
381    pub __source_breaking: fidl::marker::SourceBreaking,
382}
383
384impl fidl::Persistable for AllocatorValidateBufferCollectionTokenRequest {}
385
386#[derive(Clone, Debug, Default, PartialEq)]
387pub struct AllocatorValidateBufferCollectionTokenResponse {
388    pub is_known: Option<bool>,
389    #[doc(hidden)]
390    pub __source_breaking: fidl::marker::SourceBreaking,
391}
392
393impl fidl::Persistable for AllocatorValidateBufferCollectionTokenResponse {}
394
395/// Constraints on allocated buffers and, optionally, constraints on images
396/// stored in the buffers. These constraints can be specified per-participant.
397/// The sysmem service implements aggregation of constraints from multiple
398/// participants.
399#[derive(Clone, Debug, Default, PartialEq)]
400pub struct BufferCollectionConstraints {
401    /// The `usage` is a hint to sysmem to potentially help choose a more
402    /// optimal [`fuchsia.images2/PixelFormat`] and/or `pixel_format_modifier`
403    /// when multiple compatible options exist.
404    ///
405    /// When aggregating [`fuchsia.sysmem2/BufferCollectionConstraints`], these
406    /// values bitwise-OR.
407    ///
408    /// At least one `usage` bit must be specified (however, it's permitted for
409    /// a [`fuchsia.sysmem2/BufferCollection.SetConstraints`] request to have
410    /// the request `constraints` field not set, in which case `kNoneUsage` is
411    /// the default, along with no constraints from the participant).
412    ///
413    /// When `kNoneUsage` is specified it must be the only set bit, and no VMOs
414    /// will be sent in response to
415    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
416    pub usage: Option<BufferUsage>,
417    /// Per-participant number of buffers that the participant may concurrently
418    /// hold for its exclusive use for more than a transient duration (camp on).
419    /// In this context, a "transient" duration is the time it takes to finish
420    /// running a small amount of non-blocking code that finishes transfering
421    /// away ownership of the buffer. Things like reading from storage, waiting
422    /// on hardware that isn't already known to be done, or doing things like
423    /// frame encode or decode are not considered transient durations, even if
424    /// they might sometimes complete quickly.
425    ///
426    /// For example, a video decoder would specify (at least) the maximum number
427    /// of reference frames + 1 frame currently being decoded into. But not 1
428    /// more for the code that runs async and quickly to deliver a previously
429    /// decoded frame, even though that frame can potentially be owned for a
430    /// transient duration concurrent with decode of the next frame.
431    ///
432    /// A participant must not camp on more buffers than specified here (except
433    /// for a transient duration) else processing may get stuck.
434    ///
435    /// When aggregating BufferCollectionConstraints, these values add.
436    ///
437    /// In testing scenarios, camping on more buffers than this for any
438    /// significant duration (one screen refresh period is "significant" in this
439    /// context) may (ideally will) be flagged as a failure.  In testing
440    /// scenarios, the participant may not be provided with more buffers than
441    /// this concurrently.
442    pub min_buffer_count_for_camping: Option<u32>,
443    /// Per-participant minimum number of buffers that are needed for slack
444    /// reasons, for better overlap of processing / better performance.
445    ///
446    /// When aggregating `BufferCollectionConstraints`, these values add.
447    ///
448    /// A participant should typically specify 0 or 1 here - typically 0 is
449    /// appropriate if `min_buffer_count_for_camping` is already enough to keep
450    /// the participant busy 100% of the time when the participant is slightly
451    /// behind, while 1 can be appropriate if 1 more buffer than strictly needed
452    /// for min-camping reasons gives enough slack to stay busy 100% of the time
453    /// (when slightly behind, vs. lower % without the extra buffer).
454    ///
455    /// In testing scenarios, this field may be forced to 0, and all
456    /// participants are expected to continue to work without getting stuck. If
457    /// a buffer is needed for forward progress reasons, that buffer should be
458    /// accounted for in `min_buffer_count_for_camping`.
459    pub min_buffer_count_for_dedicated_slack: Option<u32>,
460    /// Similar to `min_buffer_count_for_dedicated_slack`, except when
461    /// aggregating these values max (instead of add). The value here is not
462    /// shared with any participant's `min_buffer_count_for_dedicated_slack`.
463    ///
464    /// A participant can specify > 0 here if a participant would like to ensure
465    /// there's some slack overall, but doesn't need that slack to be dedicated.
466    ///
467    /// The choice whether to use `min_buffer_count_for_dedicated_slack` or
468    /// `min_buffer_count_for_shared_slack` (or both) will typically be about
469    /// the degree to which the extra slack improves performance.
470    ///
471    /// In testing scenarios, this field may be forced to 0, and all
472    /// participants are expected to continue to work without getting stuck. If
473    /// a buffer is needed for forward progress reasons, that buffer should be
474    /// accounted for in `min_buffer_count_for_camping`.
475    pub min_buffer_count_for_shared_slack: Option<u32>,
476    /// A particularly-picky participant may unfortunately need to demand a
477    /// tight range of `buffer_count`, or even a specific `buffer_count`. This
478    /// field should remain 0 unless a participant really must set this field to
479    /// constrain the overall `BufferCollectionInfo.buffer_count`. Any such
480    /// participant should still fill out the min_buffer_count_for_* fields as
481    /// appropriate.
482    ///
483    /// If this field is un-set, the logical `min_buffer_count` is 0.
484    pub min_buffer_count: Option<u32>,
485    /// A particularly-picky participant may unfortunately need to demand a
486    /// tight range of `buffer_count`, or even a specific `buffer_count`. This
487    /// field should remain 0 unless a participant really must set this field to
488    /// constrain the overall `BufferCollectionInfo.buffer_count`. Any such
489    /// participant should still fill out the min_buffer_count_for_* fields.
490    ///
491    /// If this field is un-set, the logical `max_buffer_count` is 0xFFFFFFFF.
492    pub max_buffer_count: Option<u32>,
493    /// Optional constraints on `BufferCollectionSettings.buffer_settings`.
494    ///
495    /// A participant that intends to set `image_format_constraints` will
496    /// typically specify the minimum buffer size implicitly via
497    /// `image_format_constraints`, and possibly specify only the max buffer
498    /// size via `buffer_memory_constraints`.
499    ///
500    /// If un-set, the client is specifying "don't care" re. any buffer memory
501    /// constraints.
502    pub buffer_memory_constraints: Option<BufferMemoryConstraints>,
503    /// Optional constraints on the image format parameters of an image stored
504    /// in a buffer of the collection. This includes
505    /// [`fuchsia.images2/PixelFormat`] and `pixel_format_modifier` (for tiling
506    /// and the like). These constraints can be specified separately per
507    /// `pixel_format` `pixel_format_modifier` pair. Duplicated `pixel_format`
508    /// `pixel_format_modifier` pairs aren't permitted.
509    ///
510    /// When aggregating, only `pixel_format` `pixel_format_modifier` pairs that
511    /// are specified by all participants with non-zero
512    /// `image_format_constraints` size (and non-null)
513    /// BufferCollectionConstraints) are retained.
514    ///
515    /// A participant can specify `pixel_format`
516    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] and/or
517    /// `pixel_format_modifier`
518    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] to permit any value
519    /// to be selected, but at least one participant must specify a specific
520    /// format for overall allocation to succeed.
521    ///
522    /// In a SetConstraints message, un-set or zero length means no image format
523    /// constraints; a raw buffer can be allocated if no other participants
524    /// specify any `image_format_constraints` entries.
525    pub image_format_constraints: Option<Vec<ImageFormatConstraints>>,
526    #[doc(hidden)]
527    pub __source_breaking: fidl::marker::SourceBreaking,
528}
529
530impl fidl::Persistable for BufferCollectionConstraints {}
531
532#[derive(Clone, Debug, Default, PartialEq)]
533pub struct BufferCollectionTokenDuplicateSyncRequest {
534    pub rights_attenuation_masks: Option<Vec<fidl::Rights>>,
535    #[doc(hidden)]
536    pub __source_breaking: fidl::marker::SourceBreaking,
537}
538
539impl fidl::Persistable for BufferCollectionTokenDuplicateSyncRequest {}
540
541#[derive(Clone, Debug, Default, PartialEq)]
542pub struct BufferCollectionTokenGroupCreateChildrenSyncRequest {
543    pub rights_attenuation_masks: Option<Vec<fidl::Rights>>,
544    #[doc(hidden)]
545    pub __source_breaking: fidl::marker::SourceBreaking,
546}
547
548impl fidl::Persistable for BufferCollectionTokenGroupCreateChildrenSyncRequest {}
549
550#[derive(Clone, Debug, Default, PartialEq)]
551pub struct BufferMemoryConstraints {
552    /// un-set is treated as 1
553    pub min_size_bytes: Option<u64>,
554    /// un-set is treated as 0xFFFFFFFFFFFFFFFF.
555    pub max_size_bytes: Option<u64>,
556    /// When false, physical pages of a buffer VMO can be non-contiguous. When
557    /// true, physical pages of a buffer VMO must be sequentially contiguous. A
558    /// client that doesn't require physically contiguous VMOs must still accept
559    /// physically contiguous VMOs or "physical" VMOs.
560    pub physically_contiguous_required: Option<bool>,
561    /// If true, the participant requires secure memory.
562    ///
563    /// When aggregating `BufferCollectionConstraints`, these values boolean-OR.
564    pub secure_required: Option<bool>,
565    /// When true (or when `BufferMemoryConstraints` is not present), the
566    /// participant is ok with sysmem selecting the CPU domain.
567    ///
568    /// If the CPU domain is selected, participants must ensure the CPU can read
569    /// or write data to the buffer without cache operations outside of the
570    /// participant.
571    ///
572    /// In other words, if a producer participant DMAs data directly to RAM on a
573    /// non-cache-coherent architecture such as arm, the producer must ensure
574    /// the CPU cache is clean wrt. the buffer before the DMA write, and
575    /// invalidate the CPU cache after the DMA write and before indicating that
576    /// the buffer is ready to any other participant. If a consumer participant
577    /// DMAs data directly from RAM on a non-cache-coherent architecture such as
578    /// arm, the consumer must flush the CPU cache wrt the buffer before the DMA
579    /// read.
580    ///
581    /// CPU-only participants that don't do any DMA can just write and read the
582    /// buffers (when they should) without needing to do any CPU cache ops.
583    pub cpu_domain_supported: Option<bool>,
584    /// When true, the participant is ok with sysmem selecting the RAM domain.
585    ///
586    /// If the RAM domain is selected, producer data must be available in RAM
587    /// (with CPU cache state such that the RAM data won't get corrupted by a
588    /// dirty CPU cache line writing incorrect data to RAM), and a consumer
589    /// reading using the CPU must invalidate CPU cache before reading (the
590    /// producer doesn't guarantee zero stale "clean" cache lines).
591    ///
592    /// In other words, if a producer participant uses the CPU to write data on
593    /// a non-cache-coherent architecture such as arm, the producer must flush
594    /// the data to RAM before indicating to another participant that the buffer
595    /// is ready. If a consumer participant uses the CPU to read data on a
596    /// non-cache-coherent architecture such as arm, the participant must
597    /// invalidate (typically flush+invalidate with knowledge that no cache
598    /// lines are dirty) the CPU cache before reading the buffer.
599    ///
600    /// RAM-only participants that don't do any CPU accesses to a buffer can
601    /// just do DMA to/from the buffers (when they should) without needing to
602    /// do any CPU cache ops.
603    pub ram_domain_supported: Option<bool>,
604    /// When true, the participant is ok with sysmem selecting the INACCESSIBLE
605    /// domain.
606    ///
607    /// If the INACCESSIBLE domain is selected, CPU reads and writes of the data
608    /// are prevented. Attempts to read/write the data with the CPU may result
609    /// in UB and/or process termination.
610    ///
611    /// If the INACCESSIBLE domain is selected, participants must only operate
612    /// on the data using DMAs performed by HW, or platform-specific DMA-like
613    /// requests to a secure environment (which will do the needed CPU cache ops
614    /// similar to how a RAM domain participant would operate).
615    ///
616    /// Secure heaps only support INACCESSIBLE domain, and will fail allocation
617    /// if any participant with `BufferUsage` other than `NONE_USAGE` does not
618    /// set inaccessible_domain_supported to true.
619    ///
620    /// When the INACCESSIBLE domain is selected, participants (outside of
621    /// secure/DRM environments) should not attempt to map buffers, and should
622    /// not attempt to perform any CPU cache ops. In this respect, this domain
623    /// is similar to RAM domain with all participants only doing DMA and no
624    /// participant(s) doing CPU accesses.
625    pub inaccessible_domain_supported: Option<bool>,
626    /// Which heaps are acceptable to the participant. Participants that don't
627    /// care which heap memory is allocated on should leave this field un-set. A
628    /// secure heap is only selected if all participants explicitly indicate
629    /// that the secure heap is acceptable via `heap_permitted`, or specify
630    /// `NONE_USAGE`.
631    pub permitted_heaps: Option<Vec<Heap>>,
632    #[doc(hidden)]
633    pub __source_breaking: fidl::marker::SourceBreaking,
634}
635
636impl fidl::Persistable for BufferMemoryConstraints {}
637
638/// These are memory-related settings for all buffers of a buffer collection.
639#[derive(Clone, Debug, Default, PartialEq)]
640pub struct BufferMemorySettings {
641    /// This field will always be set by sysmem.
642    ///
643    /// Rule for producers: For `BufferCollectionInfo` with
644    /// `ImageFormatConstraints`, storing an image of a given `ImageFormat` in a
645    /// buffer of that `BufferCollection` is only allowed if the result of
646    /// calling `ImageFormatImageSize` or a strictly equivalent computation is
647    /// less than or equal to `size_bytes`.
648    ///
649    /// Producer participants _must_ stay within `size_bytes` when determining
650    /// whether an image will fit in a buffer, even if the VMO's size is larger
651    /// than this.
652    ///
653    /// Failure of a producer to use `size_bytes` as the constraint (not VMO
654    /// size) when determining whether a given `ImageFormat` will fit in a
655    /// buffer will, in general, cause problems for any participant that has set
656    /// ImageFormatConstraints.pad_for_block_size to larger than {1, 1}, or
657    /// pad_beyond_image_size_bytes to greater than 0. Those participants rely
658    /// on the ability to access bytes in the VMO beyond the image size. Putting
659    /// an image in the VMO that exceeds `size_bytes` can potentially lead to
660    /// those participants trying to access an offset beyond the last page of
661    /// the VMO.
662    ///
663    /// Similarly, any future padding-only constraint which is irrelevant to a
664    /// non-padding participant when locating each valid pixel's valid data will
665    /// also be accounted for by checking `ImageFormatImageSize()` against
666    /// `size_bytes` instead of the VMO size.
667    ///
668    /// Following this rule allows producers to not need to worry about
669    /// arbitrary padding requirements of participants, including future-added
670    /// padding-only constraints.
671    ///
672    /// The `bytes_per_row` and rounding up to a tile size boundary are included
673    /// in `ImageFormatImageSize` and accounted for in `size_bytes`, even though
674    /// these two aspects are partially about padding. These two aspects are
675    /// included in the `ImageFormatImageSize` calculation because these two
676    /// aspects are also relevant to all participants that need to locate pixel
677    /// data. The `fuchsia.images2.ImageFormat` intentionally doesn't contain
678    /// any padding-only fields.
679    ///
680    /// Participants with a padding constraint (in addition to `bytes_per_row`
681    /// or tile size boundary), such as pad_for_block_size or
682    /// pad_beyond_image_size_bytes, are allowed to access, but not treat as
683    /// meaningful, bytes which are at offset `size_bytes` up to the max offset
684    /// implied by their own padding constraint, which will never exceed the VMO
685    /// size minus 1, as long as the `ImageFormatImageSize` is less than or
686    /// equal to `BufferMemorySettings.size_bytes` and other constraints under
687    /// `BufferCollectionInfo` aren't violated by the producer.
688    ///
689    /// The same `size_bytes` value is sent to all participants.
690    ///
691    /// This field is not page aligned. This value rounded up to
692    /// zx_system_page_size() boundary is guaranteed to be less than or equal
693    /// the buffer VMO size. In other words, the VMO can have more pages than
694    /// implied by this value, due to padding-only constraints from
695    /// participant(s).
696    pub size_bytes: Option<u64>,
697    /// This field will always be set by sysmem.
698    pub is_physically_contiguous: Option<bool>,
699    /// This field will always be set by sysmem.
700    pub is_secure: Option<bool>,
701    /// This field will always be set by sysmem.
702    pub coherency_domain: Option<CoherencyDomain>,
703    /// The specific heap from which buffers are allocated.
704    ///
705    /// This field will always be set by sysmem.
706    pub heap: Option<Heap>,
707    /// This is guaranteed to be equal to the VMO size obtained via
708    /// `zx_vmo_get_size`. This field is here because `pad_*` constraints can
709    /// result in the VMO size being larger than implied by `size_bytes`, and
710    /// for participants using `pad_*` constraints, it can be convenient to have
711    /// this field available rather than having to query for the VMO size.
712    ///
713    /// When checking with `ImageFormatImageSize` to see if an image will fit in
714    /// a buffer, use `size_bytes` as the threshold, not `raw_vmo_size`.
715    ///
716    /// Producers using `pad_*` constraints must still only put images in the
717    /// buffer which have `ImageFormatImageSize() <= size_bytes`. Participants
718    /// using `pad_*` constraints are allowed to access bytes beyond
719    /// `size_bytes` consistent with what the participant set for the pad_*
720    /// constriant(s), which will always fit within `raw_vmo_size` assuming
721    /// correct operation of the participant and sysmem. This field can be
722    /// useful for double-checking that accesses will be within the VMO.
723    ///
724    /// When setting up VMO mappings and VMO pins, a participant using `pad_*`
725    /// constraint(s) should use `raw_vmo_size` for the size of the mapping. In
726    /// contrast, a participant not using any pad_* constraint can use
727    /// `size_bytes` rounded up to a page size boundary or said participant can
728    /// use raw_vmo_size, but for that participant, using `size_bytes` rounded
729    /// up to the page size can avoid mapping a few pages.
730    pub raw_vmo_size: Option<u64>,
731    #[doc(hidden)]
732    pub __source_breaking: fidl::marker::SourceBreaking,
733}
734
735impl fidl::Persistable for BufferMemorySettings {}
736
737/// Describes how a client will access the contents of a buffer.
738#[derive(Clone, Debug, Default, PartialEq)]
739pub struct BufferUsage {
740    /// If the client sets this field, the client should not set any other
741    /// fields in the same table instance. The only valid bit in this field is
742    /// `NONE_USAGE` which must be set if this field is set. The point of this
743    /// field and the one bit set in this field is to essentially prove that the
744    /// client really means they aren't going to use the buffers, so don't need
745    /// any VMOs (didn't just fail to fill out the table).
746    pub none: Option<u32>,
747    /// If set, holds CPU usage bits. See `CPU_USAGE_*` flags in usages.fidl.
748    pub cpu: Option<u32>,
749    /// If set, holds vulkan usage bits. See `VULKAN_IMAGE_*` and
750    /// `VULKAN_BUFFER_*` bits in usages.fidl. The `VULKAN_USAGE_*` bit
751    /// definitions/names are deprecated.
752    pub vulkan: Option<u32>,
753    /// If set, holds display usage bits. See `DISPLAY_USAGE_*` bits in
754    /// usages.fidl.
755    pub display: Option<u32>,
756    /// If set, holds video usage bits. See `VIDEO_USAGE_*` bits in usages.fidl.
757    pub video: Option<u32>,
758    #[doc(hidden)]
759    pub __source_breaking: fidl::marker::SourceBreaking,
760}
761
762impl fidl::Persistable for BufferUsage {}
763
764/// This type is fidl::Persist()'ed in the sysmem_config.persistent_fidl file
765/// within the sysmem domain config by the assembly tool, and read by the sysmem
766/// driver.
767///
768/// Normally json[5] would be preferable for config, but we generate this config
769/// in rust using FIDL types (to avoid repetition and to take advantage of FIDL
770/// rust codegen), and there's no json schema for FIDL types.
771///
772/// Currently there is no mechanism to change anything in this config at runtime
773/// or from boot to boot. This config is static per run of the assembly tool.
774///
775/// See src/lib/assembly/config_schema/src/platform_config/sysmem_config.rs for
776/// aspects of sysmem config which are specified directly inline in board info
777/// or assembly platform config. The two parts of sysmem config don't
778/// (currently) overlap. The config here is for aspects of sysmem config which
779/// would be too verbose for direct inclusion in board info or assembly platform
780/// config. In addition, some/most of the pixel format cost entries are
781/// programmatically generated (as of this comment).
782///
783/// Prior to aggregation by assembly tool, there are multiple .persistent_fidl
784/// files each storing its own Config instance. The board info and assembly
785/// platform config lists the input persistent_fidl files, with board info
786/// logically before assembly platform config. The overall list of files is
787/// processed, which allows later files to override/replace info in prior files.
788///
789/// Because this type is only intended for use with persistent fidl, where the
790/// length of a serialized instance isn't bounded, we don't bound the internal
791/// vector element counts.
792#[derive(Clone, Debug, Default, PartialEq)]
793pub struct Config {
794    /// This is the ordered list of FormatCost entries which will be considered
795    /// by sysmem when breaking ties among formats supported by all participants
796    /// of a buffer collection.
797    ///
798    /// During config aggregation, if a later entry has matching FormatCostKey,
799    /// the earlier entry is omitted/removed. This allows later files to
800    /// override entries in earlier files, and allows files specified in
801    /// assembly platform config to override entries in files specified in the
802    /// board info.
803    ///
804    /// This vector will normally not have any two entries with matching
805    /// pixel_format, pixel_format_modifier, and buffer_usage_bits in the Config
806    /// instance loaded from sysmem_config.persistent_fidl by sysmem. If somehow
807    /// two entries do match in those fields, sysmem can ignore all but one of
808    /// the entries chosen arbitrarily.
809    pub format_costs: Option<Vec<FormatCostEntry>>,
810    #[doc(hidden)]
811    pub __source_breaking: fidl::marker::SourceBreaking,
812}
813
814impl fidl::Persistable for Config {}
815
816#[derive(Clone, Debug, Default, PartialEq)]
817pub struct DynamicSecureHeap {
818    pub heap: Option<Heap>,
819    #[doc(hidden)]
820    pub __source_breaking: fidl::marker::SourceBreaking,
821}
822
823impl fidl::Persistable for DynamicSecureHeap {}
824
825/// A FormatCostEntry can be used to influence which PixelFormatAndModifier is
826/// chosen for a buffer collection, optionally taking BufferUsage into account.
827///
828/// The default cost is f32::MAX, so any specified cost with a non-MAX value
829/// will prefer the specified format over any formats that don't have any
830/// FormatCost entry.
831///
832/// Entries which have the same pixel_format, pixel_format_modifier, and
833/// required_usage_bits as a previous entry will override that previous entry.
834/// For matching purposes, an absent pixel_format_modifier matches LINEAR, and
835/// an absent required_buffer_usage_bits matches all-0 usage bits.
836///
837/// Board info sysmem_defaults entries are logically before platform sysmem
838/// entries.
839///
840/// Sysmem uses the resulting aggregated list of FormatCostEntry(s) when
841/// breaking ties among the set of formats which are supported by all
842/// participants of a buffer collection. For each mutually-supported format,
843/// entries with non-matching format are ignored, and entries with extra
844/// buffer_usage_bits set are ignored. Among the remaining entries, the entry
845/// with the most usage bits in common with the aggregated participant usages is
846/// selected to determine the cost (if a tie, the later entry wins). Then the
847/// format with the lowest cost is chosen. If it's still a tie (equal cost), the
848/// tie is broken arbitrarily but not randomly.
849///
850/// This is not intended as a mechanism to disallow selection of a format that
851/// is supported by all participants of a buffer collection. If a participant
852/// claims support for a format but fails to handle that format correctly, it
853/// should be fixed to handle that format correctly or changed to stop claiming
854/// support for that format.
855///
856/// This mechanism is intended to influence format selection toward more
857/// efficient formats with better performance, lower memory bandwidth usage,
858/// etc, for a given set of usage bits, taking into account quirks that may be
859/// unique to a given board or overall platform config.
860#[derive(Clone, Debug, Default, PartialEq)]
861pub struct FormatCostEntry {
862    /// Must be set. If two entries have logically equal key (after field
863    /// defaults are applied), the later entry will override the earlier entry.
864    pub key: Option<FormatCostKey>,
865    /// Must be set. Lower costs win, but see also FormatCostKey fields re.
866    /// filtering entries by format and usage bits first.
867    ///
868    /// When two entries (each with format supported by all the participants of
869    /// a buffer collection) have different costs, the lower cost entry (and its
870    /// format) is chosen.
871    ///
872    /// For non-test scenarios, only use cost values > 0.0 (typically at least
873    /// 1.0 as of this comment), with 0.0 and negative values reserved for
874    /// testing.
875    pub cost: Option<f32>,
876    #[doc(hidden)]
877    pub __source_breaking: fidl::marker::SourceBreaking,
878}
879
880impl fidl::Persistable for FormatCostEntry {}
881
882/// Entries which have the same pixel_format, pixel_format_modifier, and
883/// required_usage_bits as a previous entry will override that previous entry.
884/// For matching purposes, an absent pixel_format_modifier matches LINEAR, and
885/// an absent required_buffer_usage_bits matches all-0 usage bits.
886#[derive(Clone, Debug, Default, PartialEq)]
887pub struct FormatCostKey {
888    /// The pixel_format and pixel_format_modifier are the format to which this
889    /// FormatCost entry applies.
890    ///
891    /// Must be set.
892    pub pixel_format: Option<fidl_fuchsia_images2__common::PixelFormat>,
893    /// The pixel_format and pixel_format_modifier are the format to which this
894    /// FormatCost entry applies.
895    ///
896    /// Un-set is equivalent to LINEAR.
897    pub pixel_format_modifier: Option<fidl_fuchsia_images2__common::PixelFormatModifier>,
898    /// If set, this entry is only considered if the buffer collection has at
899    /// least these usage bits set.
900    ///
901    /// The buffer collection has an aggregated BufferUsage which is the union
902    /// of per-participant BufferUsage bits. FormatCost entries with additional
903    /// set bits are ignored. Among the rest, the one with matching format and
904    /// the most usage bits set determines the cost of that format for that
905    /// buffer collection.
906    ///
907    /// Then the lowest-cost format is chosen for that buffer collection among
908    /// the formats that are mutually suppored by all the participants of that
909    /// buffer collection.
910    ///
911    /// The main intent of this field is to allow "waving off" a format that
912    /// works, but doesn't perform well, for a particular combination of usages.
913    /// In that case the cost can be set high when the problematic combination
914    /// of usage bits is set. The format will still be chosen if this format is
915    /// the only mutually-supported format among the participants of the buffer
916    /// collection.
917    ///
918    /// Un-set is equivalent to zero usage bits set, meaning the entry applies
919    /// to the format unless another entry with more specific usage applies.
920    ///
921    /// It can be reasonable in some cases for all entries to omit this field,
922    /// when/if format selection based on format cost alone, ignoring usage, is
923    /// sufficient.
924    pub buffer_usage_bits: Option<BufferUsage>,
925    #[doc(hidden)]
926    pub __source_breaking: fidl::marker::SourceBreaking,
927}
928
929impl fidl::Persistable for FormatCostKey {}
930
931/// This is the root of the persistent fidl in a format costs file. The format
932/// costs files are read by the assembly tool and merged into the single
933/// sysmem_config.persistent_fidl file in the sysmem domain config (see Config
934/// above).
935///
936/// Normally json[5] would be preferable for config, but we generate this config
937/// in rust using FIDL types (to avoid repetition and to take advantage of FIDL
938/// rust codegen), and there's no json schema for FIDL types.
939///
940/// While the resulting sysmem_config.persistent_fidl is a single file that can
941/// contain multiple aspects of sysmem config, in contrast a format costs file
942/// contains only format costs. We don't mind having more separate files during
943/// the build, but it's nice to get sysmem's domain config down to a single file
944/// on-device.
945#[derive(Clone, Debug, Default, PartialEq)]
946pub struct FormatCosts {
947    /// This is a chunk of entries that'll end up in
948    /// ['fuchsia.sysmem2.Config.format_costs'] (see above) unless overriden by
949    /// later entries (either in this same vector or in later-processed files
950    /// during aggregation by the assembly tool).
951    pub format_costs: Option<Vec<FormatCostEntry>>,
952    #[doc(hidden)]
953    pub __source_breaking: fidl::marker::SourceBreaking,
954}
955
956impl fidl::Persistable for FormatCosts {}
957
958/// A reference to a heap instance.
959///
960/// A given heap instance can have more than one `Heap` which can be used to
961/// refer to the heap instance. Comparing `Heap` tables without knowledge of
962/// these `Heap` aliases is not a reliable way to determine if two `Heap` tables
963/// refer to the same heap (matching means yes, but not matching means maybe).
964/// Allowing heap aliases makes renaming `Heap.type`(s) easier.
965#[derive(Clone, Debug, Default, PartialEq)]
966pub struct Heap {
967    /// The type of the heap, specified using a bind string defined per the
968    /// schema and mechanism described in comments in the
969    /// fuchsia.sysmem.heap.bind file.
970    ///
971    /// Examples:
972    /// * "fuchsia.sysmem.heap.HEAP_TYPE.SYSTEM_RAM"
973    /// * "fuchsia.goldfish.platform.sysmem.heap.HEAP_TYPE.HOST_VISIBLE"
974    pub heap_type: Option<String>,
975    /// The uint64 id of the heap. This is only required to be unique per (type,
976    /// boot) tuple. In other words, a given heap id is only meaningful within
977    /// the current boot of the machine (not across boots), and only within the
978    /// `Heap.type`.
979    ///
980    /// For `Heap.type`(s) that refer to a singleton heap, a participant
981    /// specifying the singleton heap in
982    /// [`fuchsia.sysmem2.BufferMemoryConstraints.permitted_heaps`] can leave
983    /// this field un-set, or set it to zero. Sysmem will always fill out this
984    /// field for the heap indicated in
985    /// [`fuchsia.sysmem2.BufferMemorySettings.heap`] (for a singleton heap the
986    /// `id` field will be set to 0 by sysmem).
987    pub id: Option<u64>,
988    #[doc(hidden)]
989    pub __source_breaking: fidl::marker::SourceBreaking,
990}
991
992impl fidl::Persistable for Heap {}
993
994/// Describes constraints on layout of image data in buffers.
995#[derive(Clone, Debug, Default, PartialEq)]
996pub struct ImageFormatConstraints {
997    /// The [`fuchsia.images2/PixelFormat`] for which the following constraints
998    /// apply.
999    ///
1000    /// The `pixel_format` and `pixel_format_modifier` fields together are
1001    /// treated by the server as one additional `pixel_format_and_modifiers`
1002    /// entry.
1003    ///
1004    /// A participant may have more than one
1005    /// [`fuchsia.sysmem2/PixelFormatAndModifier`] that's supported.
1006    ///
1007    /// * If image constraints are the same for different
1008    ///   `PixelFormatAndModifier`s, the participant may list additional
1009    ///   `PixelFormatAndModifier`s for which the constraints apply in the
1010    ///   `pixel_format_and_modifiers` field. This reduces the overall number of
1011    ///   `ImageFormatConstraints` that need to be sent, without changing the
1012    ///   meaning (vs for example sending a bunch of separate
1013    ///   `ImageFormatConstraints` that only differ by the `pixel_format` and
1014    ///   `pixel_format_modifier` which overall specify the same list of
1015    ///   `PixelFormatAndModifier`s).
1016    /// * If image constraints differ for different `PixelFormatAndModifier`s,
1017    ///   the participant can convey this using a separate
1018    ///   `ImageFormatConstraints` entry in `image_format_constraints` for each
1019    ///   set of `PixelFormatAndModifier`s that have different image
1020    ///   constraints.
1021    /// * It's ok for a participant to have two `image_format_constraints`
1022    ///   entries that only differ in their pixel_format_and_modifiers, but this
1023    ///   is isn't the most compact way to represent that situation since the
1024    ///   two entries could be combined by specifying two
1025    ///   `PixelFormatAndModifier`s within a single `ImageFormatConstraints`.
1026    ///
1027    /// It's not uncommon for the other fields of `ImageFormatConstraints` to
1028    /// vary by `pixel_format` or by `pixel_format_modifier` - for example for a
1029    /// linear format to support smaller max size than a tiled format.
1030    ///
1031    /// See also
1032    /// [`fuchsia.sysmem2/ImageFormatConstraints.pixel_format_and_modifiers`].
1033    ///
1034    /// Thie field must be set to a value other than
1035    /// [`fuchsia.images2/PixelFormat.INVALID`] unless
1036    /// `pixel_format_and_modifiers` is non-empty. In other words, there must be
1037    /// at least one `PixelFormatAndModifier` per `ImageFormatConstraints`. If
1038    /// `pixel_format_modifier` is set, this field must also be set.
1039    ///
1040    /// The participant can specify [`fuchsia.images2/PixelFormat.DO_NOT_CARE`]
1041    /// if the participant needs to specify `ImageFormatConstraints` without
1042    /// constraining the `pixel_format`.
1043    pub pixel_format: Option<fidl_fuchsia_images2__common::PixelFormat>,
1044    /// The pixel format modifier for which the following constraints apply.
1045    ///
1046    /// The `pixel_format` and `pixel_format_modifier` fields together are
1047    /// treated by the server as one additional `pixel_format_and_modifiers`
1048    /// entry.
1049    ///
1050    /// This is a [`fuchsia.images2/PixelFormatModifier`] that's acceptable to
1051    /// the participant in combination with the `pixel_format`.
1052    ///
1053    /// See also `pixel_format_and_modifiers`.
1054    ///
1055    /// If `pixel_format` is set but `pixel_format_modifier` is un-set, the
1056    /// default depends on other fields:
1057    ///
1058    /// * If `pixel_format` is [`fuchsia.images2/PixelFormat.DO_NOT_CARE`], the
1059    ///   pixel format modifier is implicitly
1060    ///   [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`].
1061    /// * else if `BufferCollectionConstraints.usage` isn't `NONE`, the pixel
1062    ///   format modifier is implicitly
1063    ///   [`fuchsia.images2/PixelFormatModifier.LINEAR`].
1064    /// * else the pixel format modifier is implicitly
1065    ///   [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`].
1066    pub pixel_format_modifier: Option<fidl_fuchsia_images2__common::PixelFormatModifier>,
1067    /// Empty is an error. Duplicate entries are an error. Arbitrary ordering is
1068    /// not an error.
1069    ///
1070    /// The client can specify a single entry
1071    /// [`fuchsia.sysmem2/ColorSpace.DO_NOT_CARE`] if the client doesn't want to
1072    /// constrain which `ColorSpace` is chosen. At least one participant must
1073    /// specify at least one `ColorSpace` value other than
1074    /// `ColorSpace.DO_NOT_CARE`, or allocation will fail.
1075    pub color_spaces: Option<Vec<fidl_fuchsia_images2__common::ColorSpace>>,
1076    /// Minimum permitted size in pixels.
1077    ///
1078    /// For example a video decoder participant may set this field to the
1079    /// minimum size that might potentially be specified by a stream. In
1080    /// contrast, `required_min_size` would be set to the current size specified
1081    /// by the stream. While `min_size` aggregates by taking the max,
1082    /// `required_min_size` aggregates by taking the min.
1083    ///
1084    /// When sending to sysmem, this field can be un-set if the participant is
1085    /// prepared to deal with the smallest possible non-zero image layout
1086    /// limited only by the constraints implicitly imposed by the `pixel_format`
1087    /// and `pixel_format_modifier`. Or this field can be set to the actual
1088    /// minimum size the participant can handle.
1089    ///
1090    /// Producers should set `min_size` and set both width and height to the
1091    /// actual non-zero smallest width and height that the producer might
1092    /// generate. For example, a video decoder can set the size of a single
1093    /// macroblock here.
1094    ///
1095    /// When receiving from sysmem, this field will always be set, and neither
1096    /// width nor height will be 0, because at least one participant must
1097    /// specify a non-zero minimum size (where both width and height aren't
1098    /// zero).
1099    ///
1100    /// See also `required_min_size`.
1101    pub min_size: Option<fidl_fuchsia_math__common::SizeU>,
1102    /// Maximum size in pixels. For example Scenic may set this field (directly
1103    /// or via sub-participants) to the maximum size that can be composited.
1104    ///
1105    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF, 0xFFFFFFFF.
1106    ///
1107    /// Receiving from sysmem, this field will always be set. For width and
1108    /// height separately, if there is no enforced max, that sub-field will be
1109    /// 0xFFFFFFFF.
1110    ///
1111    /// See also `required_max_size`.
1112    pub max_size: Option<fidl_fuchsia_math__common::SizeU>,
1113    /// The minimum number of bytes per row, including any padding beyond the
1114    /// last image data in a row.
1115    ///
1116    /// This is sometimes called the "stride in bytes" or the "line to line
1117    /// offset". For single-plane formats, this is the number of bytes per row
1118    /// of pixels. For multi-plane formats, this is the number of bytes per row
1119    /// of samples in plane 0 (for example, the number of bytes per row of luma
1120    /// samples in the case of a multi-plane YUV format). For multi-plane
1121    /// formats, the bytes per row in planes other than plane 0 is format
1122    /// specific, but always a specific relationship to the plane 0 bytes per
1123    /// row.
1124    ///
1125    /// When sending `ImageFormatConstraints` to sysmem, setting this field is
1126    /// optional. Not setting this field is recommended unless the participant
1127    /// needs to force the `bytes_per_row` to be larger than the minimum value
1128    /// implied by `min_size.width`, the "stride bytes per width pixel" of the
1129    /// `pixel_format` plus `pixel_format_modifier` (see also
1130    /// `ImageFormatStrideBytesPerWidthPixel`), and `bytes_per_row_divisor`.
1131    ///
1132    /// When this structure is received from sysmem, this field will always be
1133    /// set (when the parent structure is present), and will always be at least
1134    /// the value implied by `min_size.width`, the "stride bytes per width
1135    /// pixel" of the `pixel_format` plus `pixel_format_modifier`, and
1136    /// `bytes_per_row_divisor`.
1137    ///
1138    /// Some producer participants may prefer to simply set
1139    /// `ImageFormat.bytes_per_row` to
1140    /// `ImageFormatConstraints.min_bytes_per_row` since sysmem is guaranteeing
1141    /// that `min_bytes_per_row` is compatible with an image of width
1142    /// `min_size.width`. However, producer participants that need to have
1143    /// `size.width` > `min_size.width` can get a corresponding
1144    /// `min_bytes_per_row` from `ImageFormatMinimumRowBytes` (in C++), or can
1145    /// just calculate the `bytes_per_row` directly.
1146    pub min_bytes_per_row: Option<u32>,
1147    /// The maximum number of bytes per row, including any padding beyond the
1148    /// last image data in a row.
1149    ///
1150    /// When sent to sysmem, must be >= the value implied by `max_size.width`,
1151    /// "stride bytes per width pixel", and `bytes_per_row_divisor`, or
1152    /// constraints aggregation will fail. Un-set means the participant doesn't
1153    /// need/want to set a strict max.
1154    ///
1155    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF.
1156    ///
1157    /// When received from sysmem, this field will always be set. If the max is
1158    /// effectively infinite, the value will be 0xFFFFFFFF (not zero).
1159    pub max_bytes_per_row: Option<u32>,
1160    /// The maximum number of pixels.
1161    ///
1162    /// The max image area in pixels is limited indirectly via
1163    /// [`fuchsia.sysmem/BufferMemoryConstraints.max_size_bytes`] and the
1164    /// resulting [`fuchsia.sysmem/BufferSettings.size_bytes`], and can also be
1165    /// enforced directly via this field.
1166    ///
1167    /// In contrast to the [`fuchsia.sysmem2/ImageFormatConstraints.max_size`]
1168    /// field which limits width and height separately, this field limits the
1169    /// total number of pixels.
1170    ///
1171    /// In contrast to
1172    /// [`fuchsia.sysmem/BufferMemoryConstraints.max_size_bytes`], this field
1173    /// doesn't limit the number of non-pixel padding bytes after each row of
1174    /// pixels, and doesn't limit the number of non-pixel bytes in the case of
1175    /// tiled `pixel_format_modifier`.
1176    ///
1177    /// Very narrow or very short image aspect ratios can have worse performance
1178    /// per pixel in comparison to more typical aspect ratios. Padding and/or
1179    /// memory bandwidth overheads tend to increase for extreme aspect ratios.
1180    /// Participants can indicate lack of support for very narrow or very short
1181    /// dimensions using ['fuchsia.sysmem/ImageFormatConstraints.min_size`].
1182    ///
1183    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF.
1184    ///
1185    /// Receiving from sysmem, this field will always be set, and can be set to
1186    /// 0xFFFFFFFF.
1187    pub max_width_times_height: Option<u64>,
1188    /// Alignment requirements on the image `size`.
1189    ///
1190    /// * `size.width % size_alignment.width` must be 0.
1191    /// * `size.height % size_alignment.height` must be 0.
1192    ///
1193    /// Both `size_alignment.width` and `size_alignment.height` must be non-zero
1194    /// and a power of 2.
1195    ///
1196    /// Un-set is treated as 1, 1.
1197    pub size_alignment: Option<fidl_fuchsia_math__common::SizeU>,
1198    /// Alignment requirements on `display_rect`.
1199    ///
1200    /// * `display_rect.x % display_rect_alignment.width` must be 0.
1201    /// * `display_rect.y % display_rect_alignment.height` must be 0.
1202    /// * `display_rect.width % display_rect_alignment.width` must be 0.
1203    /// * `display_rect.height % display_rect_alignment.height` must be 0.
1204    ///
1205    /// Un-set is treated as 1, 1.
1206    pub display_rect_alignment: Option<fidl_fuchsia_math__common::SizeU>,
1207    /// These fields can be used to ensure the aggregated constraints have
1208    /// `min_size` and `max_size` such that both `required_min_size` and
1209    /// `required_max_size` (and anything in between that satisfies alignment
1210    /// requirements) are permitted values of `ImageFormat.size`.
1211    ///
1212    /// For example, a producer video decoder doesn't want to constrain the
1213    /// allowed `ImageFormat.size`, as a compressed stream can change dimensions
1214    /// mid-stream, but the producer video decoder needs to ensure that the
1215    /// aggregated constraints allow for at least the current dimensions of
1216    /// uncompressed frames at the current position in the stream.
1217    ///
1218    /// As another example, an initiator that's intending to decode video may
1219    /// know what the maximum expected size of frames in the stream(s) can be,
1220    /// so by setting `required_max_size`, can ensure that the allocated buffers
1221    /// are large enough to support that max `size`. In addition on successful
1222    /// allocation the initiator also knows that the consumer participants are
1223    /// ok with receiving up to that max `size`.
1224    ///
1225    /// It's much more common for a producer or initiator to set these fields
1226    /// than for a consumer to set these fields.
1227    ///
1228    /// While `min_size` and `max_size` aggregate by effectively taking the
1229    /// intersection, the `required_min_size` and `required_max_size` aggregate
1230    /// by effectively taking the union.
1231    ///
1232    /// The `min_size` is the minimum size that a client is capable of handling.
1233    /// If any participant sets `required_min_size` smaller than this,
1234    /// allocation will fail.
1235    ///
1236    /// The `max_size` is the maximum size that a client is capable of handling.
1237    /// If any participant sets `required_max_size` larger than this, allocation
1238    /// will fail.
1239    ///
1240    /// This field aggregates by taking the min per component, and
1241    /// required_max_size aggregates by taking the max per component. In
1242    /// addition the aggregated required_max_size is included in the aggregated
1243    /// required_max_size_list.
1244    ///
1245    /// Un-set is treated as 0xFFFFFFFF, 0xFFFFFFFF.
1246    pub required_min_size: Option<fidl_fuchsia_math__common::SizeU>,
1247    /// This field is deprecated. The replacement is required_max_size_list.
1248    ///
1249    /// See also `required_min_size` and `required_max_size_list`. Un-set is
1250    /// treated as 0, 0.
1251    ///
1252    /// In the BufferCollectionInfo returned from sysmem, this field has the max
1253    /// across all participants' required_max_size fields, for width and height
1254    /// separately. In addition, the allocated buffer is large enough to store
1255    /// an image that is this max-of-all-widths by max-of-all-heights. This has
1256    /// the potential to allocate buffers that are larger than necessary, for
1257    /// example if the participant is trying to make sure the buffer can store
1258    /// both landscape and portrait images. In contrast, required_max_size_list
1259    /// allows listing those separately so they can be handled better by the
1260    /// server. See required_max_size_list and please switch to that field.
1261    ///
1262    /// When this field is set, the provided size is aggregated by taking max of
1263    /// across all participants' required_max_size fields, and that aggregated
1264    /// result is put in this field in the BufferCollectionInfo from the server,
1265    /// and is also treated as an additional item in the aggregated
1266    /// required_max_size_list (even if that field is not set by any client).
1267    /// See required_max_size_list. This behavior is for maintaining backward
1268    /// compatibility for clients using required_max_size before it was
1269    /// deprecated, and for overall compatibility with required_max_size_list,
1270    /// but this behavior is itself deprecated as well. Please switch to only
1271    /// using required_max_size_list.
1272    ///
1273    /// Please don't add additional usages of this field.
1274    pub required_max_size: Option<fidl_fuchsia_math__common::SizeU>,
1275    /// `fuchsia_images2.ImageFormat.bytes_per_row % bytes_per_row_divisor` must
1276    /// be 0. Un-set is treated as 1.
1277    ///
1278    /// Prefer to use `require_bytes_per_row_at_pixel_boundary` when the intent
1279    /// is to ensure that `bytes_per_row' will be a multiple of the pixel size
1280    /// in bytes.
1281    ///
1282    /// Prefer to use `size_alignment.width` when the intent is to ensure that
1283    /// the width in pixels is aligned. In contrast, this field can specify that
1284    /// the "stride in bytes" (byte offset from start of image to start of row n
1285    /// minus byte offset from start of image to start of row n-1, with result
1286    /// in bytes) needs to be aligned to the specified number of bytes. For
1287    /// example, when `PixelFormat.BGR24` (24 bit color; 3 bytes per pixel) is
1288    /// used, it's not uncommon for a participant to need each row of pixels to
1289    /// start at a 4 byte aligned offset from the start of the image, which can
1290    /// imply some padding bytes at the end of each row of pixels, before the
1291    /// start of the next row of pixels.
1292    ///
1293    /// While any value of `bytes_per_row_divisor` could instead be enforced by
1294    /// setting `size_alignment.width` to the least-common-multiple of the
1295    /// "stride bytes per width pixel" and the stride alignment requirement,
1296    /// enforcing the stride alignment requirement that way can lead to more
1297    /// padding than necessary (implying larger buffer than necessary), and can
1298    /// also result in a "fake" `size.width` values that other participants
1299    /// would need to care about; this field exists to avoid that situation.
1300    /// Instead, the stride alignment requirement in bytes is specified directly
1301    /// here.
1302    pub bytes_per_row_divisor: Option<u32>,
1303    /// `vmo_usable_start % start_offset_divisor` must be 0. Un-set is treated
1304    /// as 1.
1305    ///
1306    /// Producer participants are discouraged from setting non-zero image start
1307    /// offset (from the buffer base) unless actually required, as not all
1308    /// participants correctly handle non-zero image start offset.
1309    pub start_offset_divisor: Option<u32>,
1310    /// The (additional) [`fuchsia.sysmem2/PixelFormatAndModifier`]s for which
1311    /// the following constraints apply.
1312    ///
1313    /// As a non-limiting example, if a participant only wants to set a single
1314    /// `PixelFormatAndModifier` for this
1315    /// [`fuchsia.sysmem2/ImageFormatConstraints`], the participant can either
1316    /// (a) use `pixel_format` and `pixel_format_modifier` fields to specify the
1317    /// fields of the one `PixelFormatAndModifier` and leave
1318    /// `pixel_format_and_modifiers` un-set, or (b) leave `pixel_format` and
1319    /// `pixel_format_modifier` fields un-set and put the one
1320    /// `PixelFormatAndModifier` in `pixel_format_and_modifiers`.
1321    ///
1322    /// If `pixel_format` is set, the server will take pixel_format and
1323    /// pixel_format_modifier fields (un-setting them in the process), pack them
1324    /// into a `PixelFormatAndModifier`, and move it into this vector as one
1325    /// additional entry, with an overall size limit of
1326    /// `MAX_COUNT_PIXEL_FORMAT_AND_MODIFIERS + 1`.
1327    ///
1328    /// After the server moves `pixel_format`, `pixel_format_modifier` into one
1329    /// additional entry in this vector, this vector must not be empty. When the
1330    /// resulting list has more than 1 item, the entries in this vector are
1331    /// equivalent to (shorthand for) listing (size) separate
1332    /// `ImageFormatConstraints` entries, one per `pixel_format_and_modifiers`
1333    /// entry, each with one `PixelFormatAndModifier`, where all the separate
1334    /// `ImageFormatConstraints` entries have the same constraints (compared
1335    /// field by field, not including `pixel_format`, `pixel_format_modifier`,
1336    /// or `pixel_format_and_modifiers` fields).
1337    ///
1338    /// In `SetConstraints` message, each entry specifies a
1339    /// `PixelFormatAndModifier` which is acceptable to the participant
1340    /// (assuming the following constraints fields are also satisfied).
1341    ///
1342    /// In the response to `WaitForAllBuffersAllocated`, this field will be
1343    /// un-set and the one chosen `PixelFormatAndModifier` will be indicated
1344    /// using the `pixel_format` and `pixel_format_modifier` fields.
1345    ///
1346    /// All the `PixelFormatAndModifiers` in a `SetConstraints` message from a
1347    /// participant must be unique across all the entries under
1348    /// `image_format_constraints`. If
1349    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] is used in an entry, there
1350    /// must not be any other entry (considering all the entries under
1351    /// `image_format_constraints`) with matching `pixel_format_modifier`. If
1352    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] is used, there must
1353    /// not be any other entry (considering all the entries under
1354    /// `image_format_constraints`) with matching `pixel_format`.
1355    ///
1356    /// A `PixelFormatAndModifier` value with either
1357    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] or
1358    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] (but not both, for
1359    /// purposes of this example) can be combined with a
1360    /// `PixelFormatAndModifier` from a separate participant with the other
1361    /// field indicating "do not care", resulting in a complete
1362    /// `PixelFormatAndModifier` that can succeed allocation. However, at least
1363    /// for now, it's not permitted for a single participant to specify two
1364    /// separate `PixelFormatAndModifier` values which have "do not care" in
1365    /// different fields. This does not prohibit a single
1366    /// `PixelFormatAndModifier` with both `PixelFormat.DO_NOT_CARE` and
1367    /// `PixelFormatModifier.DO_NOT_CARE` (which is only a single
1368    /// `PixelFormatAndModifier` value). If a client really needs to specify
1369    /// some constraints relevant to `pixel_format`(s) with
1370    /// `pixel_format_modifier` `DO_NOT_CARE`, and other constraints relevant to
1371    /// `pixel_format_modifier`(s) with `pixel_format` `DO_NOT_CARE`, the client
1372    /// can do so by duplicating the token and using/driving two separate
1373    /// participants.
1374    ///
1375    /// See also `pixel_format` for more comments relevant to multiple
1376    /// `PixelFormatAndModifier`s in a single `ImageFormatConstraints`.
1377    pub pixel_format_and_modifiers: Option<Vec<PixelFormatAndModifier>>,
1378    /// Iff set and true, bytes_per_row_divisor in the resulting
1379    /// ImageFormatConstraints is guaranteed to be a value which requires
1380    /// bytes_per_row to be an integral number of pixels. This can result in
1381    /// more padding at the end of each row than when this field is not set to
1382    /// true, but ensures that the stride can be expressed as an integral number
1383    /// of pixels.
1384    ///
1385    /// For example, if the chosen `PixelFormat` is `B8G8R8`, if this field is
1386    /// set to true, the resulting bytes_per_row_divisor will be a multiple of
1387    /// 3. In this example, if another participant sets `bytes_per_row_divisor`
1388    /// to 4, the resulting `bytes_per_row_divisor` will be a multiple of 12.
1389    pub require_bytes_per_row_at_pixel_boundary: Option<bool>,
1390    /// If unset, any A channel of any format in this ImageFormatConstraints is
1391    /// is ignored or not ignored according to semantics conveyed out of band.
1392    ///
1393    /// If set to false, the A channel of any format in this
1394    /// ImageFormatConstraints is arbitrary values that don't mean anything.
1395    /// Producers don't need to ensure any particular values in the A channel
1396    /// and consumers should ignore the A channel. This is the same thing as
1397    /// calling the 'A' channel 'X' instead.
1398    ///
1399    /// If set to true, the A channel of any format in this
1400    /// ImageFormatConstraints is set to meaningful values. A producer should
1401    /// fill out the A values, and a consumer should pay attention to the A
1402    /// values as appropriate.
1403    ///
1404    /// If set values of this field don't match for the same pixel format and
1405    /// modifier, that format and modifier will be eliminated from
1406    /// consideration.
1407    ///
1408    /// A participant that knows that the semantics of the A channel are
1409    /// conveyed via out of band means can leave this field un-set, even if the
1410    /// out of band means is already known to specify alpha present or not
1411    /// present, but in this situation it's also ok to fill out this field for
1412    /// informational / debugging purposes.
1413    ///
1414    /// If no participant sets this field, the default is un-set.
1415    ///
1416    /// If the format chosen for allocation doesn't have an A channel, this
1417    /// field will be un-set in the allocation result.
1418    pub is_alpha_present: Option<bool>,
1419    /// If an entry in this list has width or height greater than max_size width
1420    /// or height respectively (evaluated both before and again after
1421    /// aggregation), allocation will fail.
1422    ///
1423    /// This field aggregates by appending the entries to an overall list, or in
1424    /// other words, this field does not aggregate; all entries from all
1425    /// participants must be satisfied by the allocated buffer(s) or the
1426    /// allocation will fail. This lack of aggregation is to avoid
1427    /// larger-than-necessary buffers if one participant specifies a large width
1428    /// and small height and another participant specifies a small width and
1429    /// large height, or more likely, if a single participant specifies those
1430    /// two entries (for example). In that case, the buffer's
1431    /// `BufferMemorySettings.size_bytes` needs to be large enough to store the
1432    /// larger (in bytes) of the specified sizes (given available ranges of
1433    /// other ImageFormatConstraints), but not the max width and max height
1434    /// across all specified sizes used as the width and height of a single
1435    /// image.
1436    ///
1437    /// Under the resulting `BufferCollectionInfo`, `max_size` is the max
1438    /// allowed value for each dimension separately, but this does not imply
1439    /// that an image of max_size can fit in the buffer (typically won't). In
1440    /// contrast, any image that's no bigger than an entry in the returned
1441    /// `required_max_size_list` will fit in the buffer. The returned list will
1442    /// have redundant entries removed, so a client's entry may not be present
1443    /// if another entry covers the client's entry; this also removes any
1444    /// duplicates. The correct way to check if an image will fit is to check
1445    /// that `ImageFormatImageSize()` is less than or equal to
1446    /// `BufferMemorySettings.size_bytes`.
1447    ///
1448    /// Until `required_max_size` is removed, the returned
1449    /// `required_max_size_list` will, if any participants specified
1450    /// `required_max_size`, ensure that the aggregated (using max width and max
1451    /// height) `required_max_size` will fit in the allocated buffer. This does
1452    /// not imply that there will necessarily be an entry that indicates this
1453    /// specific aggregated `required_max_size`, as that entry can be removed if
1454    /// it's covered by another entry.
1455    ///
1456    /// In contrast to `max_size`, an entry can be added to
1457    /// `required_max_size_list` to ensure the buffer actually has the capacity
1458    /// to store an image that has both width and height less than or equal to
1459    /// the entry's width and height respectively. See
1460    /// `BufferMemorySettings.size_bytes` for more on what "capacity" means
1461    /// here.
1462    ///
1463    /// A typical usage of more than one entry in this list would be specifying
1464    /// that each buffer needs to be able to store up to a given portrait size
1465    /// and also up to a given landscape size. In general, more than one entry
1466    /// makes sense if the participant needs to ensure that the buffer can be
1467    /// used to store images of a few different aspect ratios at up to the
1468    /// listed size per aspect ratio. In the response from the server, redundant
1469    /// entries are removed.
1470    pub required_max_size_list: Option<Vec<fidl_fuchsia_math__common::SizeU>>,
1471    /// `pad_for_block_size` ensures that a participant will be able to access
1472    /// pixel data in blocks of the specified size, even for the lower right
1473    /// pixel whose access block can extend beyond that pixel, sometimes
1474    /// requiring more page(s) in the VMO to avoid access fault or out-of-bounds
1475    /// DMA. The extra "pixel" data of blocks on the right and bottom will not
1476    /// overlap with any other pixel (or "pixel") data.
1477    ///
1478    /// At least for now this field is only accepted for linear single-plane
1479    /// formats. This corresponds to `PixelFormatModifier.Linear` and
1480    /// `ImageFormatPlaneByteOffset` returning false when plane is 1.
1481    ///
1482    /// This field being set is not accepted if the ImageFormatConstraints has
1483    /// PixelFormat.DO_NOT_CARE or PixelFormatModifier.DO_NOT_CARE.
1484    ///
1485    /// For linear single-plane formats, we don't need to force size_alignment
1486    /// to be the access block size, as (a) there's no intent by any participant
1487    /// to actually store more (valid) pixels in the buffer, and (b) no other
1488    /// non-block-accessing participant needs to know about block access by a
1489    /// different participant to correctly locate the data of any pixel. The
1490    /// accesses by the block-accessing participant just need to remain within
1491    /// the VMO, so that all accesses remain within the VMO's pages.
1492    ///
1493    /// This field ensures the VMO size is sufficient to store the lower right
1494    /// "pixel" of the lower right block, but by design, that "pixel" data is
1495    /// not necessarily within `BufferMemorySettings.size_bytes`. Participants
1496    /// specifying `pad_for_block_size` are allowed to access beyond
1497    /// `BufferMemorySettings.size_bytes`. Block access per `pad_for_block_size`
1498    /// will automatically be within the VMO sze (but participants may check as
1499    /// well of course).
1500    ///
1501    /// For a motivating example, see the top of pad_for_block_size_test.cc.
1502    ///
1503    /// If setting `pad_for_block_size.height` to a value greater than 1, the
1504    /// same participant must (enforced) set a `max_size.width` less than
1505    /// 0xFFFFFFFF (preferably no more than a small multiple of the expected
1506    /// actual max width). This helps in controlling the space overhead incurred
1507    /// by the participant's use of blocks. If not burdensome, any of the
1508    /// following can also help:
1509    ///   * `min_size.height` - any participant setting a value greater than 1
1510    ///   * `size_alignment.height` - any participant setting to a value greater
1511    ///     than 1
1512    pub pad_for_block_size: Option<fidl_fuchsia_math__common::SizeU>,
1513    /// pad_beyond_image_size_bytes ensures that there will be at least this
1514    /// many bytes in the VMO beyond the image size. Some SW video codecs need
1515    /// this for performance reasons.
1516    ///
1517    /// Some video decoders and encoders can require that a few more bytes be
1518    /// safe to access beyond the image's size as calculated by
1519    /// ImageFormatImageSize. This can sometimes require an additional page to
1520    /// be allocated. The padding specified by this field starts at byte 0 of
1521    /// the row beyond the last image row.
1522    ///
1523    /// This semantic is chosen because (a) it makes some video decoders used in
1524    /// ffmpeg happy (needs 16 bytes fully after the image as a run-out zone),
1525    /// and (b) it can serve as a not-particularly-wastful way to avoid adding
1526    /// pad_beyond_last_pixel_bytes as well, because this padding always starts
1527    /// at or beyond where that padding would without wasting more than
1528    /// bytes_per_row - pixel_stride_in_bytes * width which is very unlikely to
1529    /// result in wasting more than 1 page (and won't typically waste any
1530    /// pages).
1531    ///
1532    /// If the participant needs extra bytes beyond the image size to accomodate
1533    /// performance optimization(s), the number of extra bytes needed goes here.
1534    /// Do _not_ store valid pixels or metadata in these bytes; some or all of
1535    /// these bytes may be the same bytes requested via other participant's
1536    /// pad_* constraints.
1537    ///
1538    /// Do not write to these bytes outside time intervals during which
1539    /// writing to pixel data is permitted.
1540    pub pad_beyond_image_size_bytes: Option<u64>,
1541    #[doc(hidden)]
1542    pub __source_breaking: fidl::marker::SourceBreaking,
1543}
1544
1545impl fidl::Persistable for ImageFormatConstraints {}
1546
1547#[derive(Clone, Debug, Default, PartialEq)]
1548pub struct NodeSetDebugClientInfoRequest {
1549    pub name: Option<String>,
1550    pub id: Option<u64>,
1551    #[doc(hidden)]
1552    pub __source_breaking: fidl::marker::SourceBreaking,
1553}
1554
1555impl fidl::Persistable for NodeSetDebugClientInfoRequest {}
1556
1557#[derive(Clone, Debug, Default, PartialEq)]
1558pub struct NodeSetDebugTimeoutLogDeadlineRequest {
1559    pub deadline: Option<i64>,
1560    #[doc(hidden)]
1561    pub __source_breaking: fidl::marker::SourceBreaking,
1562}
1563
1564impl fidl::Persistable for NodeSetDebugTimeoutLogDeadlineRequest {}
1565
1566#[derive(Clone, Debug, Default, PartialEq)]
1567pub struct NodeSetNameRequest {
1568    pub priority: Option<u32>,
1569    pub name: Option<String>,
1570    #[doc(hidden)]
1571    pub __source_breaking: fidl::marker::SourceBreaking,
1572}
1573
1574impl fidl::Persistable for NodeSetNameRequest {}
1575
1576#[derive(Clone, Debug, Default, PartialEq)]
1577pub struct NodeGetBufferCollectionIdResponse {
1578    pub buffer_collection_id: Option<u64>,
1579    #[doc(hidden)]
1580    pub __source_breaking: fidl::marker::SourceBreaking,
1581}
1582
1583impl fidl::Persistable for NodeGetBufferCollectionIdResponse {}
1584
1585#[derive(Clone, Debug, Default, PartialEq)]
1586pub struct NodeIsAlternateForResponse {
1587    pub is_alternate: Option<bool>,
1588    #[doc(hidden)]
1589    pub __source_breaking: fidl::marker::SourceBreaking,
1590}
1591
1592impl fidl::Persistable for NodeIsAlternateForResponse {}
1593
1594#[derive(Clone, Debug, Default, PartialEq)]
1595pub struct SecureHeapAndRange {
1596    pub heap: Option<Heap>,
1597    pub range: Option<SecureHeapRange>,
1598    #[doc(hidden)]
1599    pub __source_breaking: fidl::marker::SourceBreaking,
1600}
1601
1602impl fidl::Persistable for SecureHeapAndRange {}
1603
1604#[derive(Clone, Debug, Default, PartialEq)]
1605pub struct SecureHeapAndRangeModification {
1606    pub heap: Option<Heap>,
1607    pub old_range: Option<SecureHeapRange>,
1608    pub new_range: Option<SecureHeapRange>,
1609    #[doc(hidden)]
1610    pub __source_breaking: fidl::marker::SourceBreaking,
1611}
1612
1613impl fidl::Persistable for SecureHeapAndRangeModification {}
1614
1615#[derive(Clone, Debug, Default, PartialEq)]
1616pub struct SecureHeapAndRanges {
1617    /// This is which secure/protected heap.
1618    pub heap: Option<Heap>,
1619    /// The list of physical ranges.  This list must be sorted by
1620    /// physical_address (lower first), and must not have any overlapping
1621    /// ranges.  Ranges that are directly adjacent are allowed (not
1622    /// overlapping).
1623    pub ranges: Option<Vec<SecureHeapRange>>,
1624    #[doc(hidden)]
1625    pub __source_breaking: fidl::marker::SourceBreaking,
1626}
1627
1628impl fidl::Persistable for SecureHeapAndRanges {}
1629
1630#[derive(Clone, Debug, Default, PartialEq)]
1631pub struct SecureHeapProperties {
1632    /// The Heap is repeated here for convenience.
1633    pub heap: Option<Heap>,
1634    /// If true, more than one call to SetPhysicalSecureHeap() for the same
1635    /// heap is allowed.  If false, only one SetPhyscialSecureHeap() call is
1636    /// allowed, and no calls to DeleteSecureHeapPhysicalRange() or
1637    /// ModifySecureHeapPhysicalRange() are allowed.  Even when this is false,
1638    /// the SecureMem server (driver) is still responsible for de-protecting
1639    /// just before warm reboot if protected ranges would not otherwise be
1640    /// cleaned up during a warm reboot.
1641    pub dynamic_protection_ranges: Option<bool>,
1642    /// The granularity of protection ranges.  If the granularity of start is
1643    /// different than granularity of end or length, then this is the max
1644    /// granularity value among those values.
1645    ///
1646    /// This must be a power of 2.  The client must not request ranges that
1647    /// specify smaller granularity.
1648    ///
1649    /// This must be at least zx_system_page_size() even if the HW can do
1650    /// smaller granularity.
1651    pub protected_range_granularity: Option<u32>,
1652    /// The SecureMem server should not count reserved ranges that the SecureMem
1653    /// server uses internally to get from range set A to range set B, if the
1654    /// SecureMem server needs to do any emulation of that sort.  Normally such
1655    /// emulation by the SecureMem server is unnecessary.  If any ranges are
1656    /// reserved by the SecureMem server, those reserved ranges are not
1657    /// available for use by the SecureMem client.
1658    ///
1659    /// If the number of ranges is limited only by available memory, it's ok for
1660    /// the SecureMem server to report 0xFFFFFFFFFFFFFFFF for this value.  The
1661    /// field must still be set.  As usual, the SecureMem server should ensure
1662    /// that SetPhysicalSecureHeapRanges() succeeds or fails atomically (either
1663    /// fully updates or rolls back before completing).
1664    pub max_protected_range_count: Option<u64>,
1665    /// Iff true, ModifySecureHeapPhysicalRange() is implemented.  Calling
1666    /// ModifySecureHeapPhysicalRange() when is_mod_protected_range_available
1667    /// is false is prohibited.  Don't attempt to detect availability of
1668    /// ModifySecureHeapPhysicalRange() by calling it to see if it fails; it
1669    /// may ZX_PANIC().
1670    pub is_mod_protected_range_available: Option<bool>,
1671    #[doc(hidden)]
1672    pub __source_breaking: fidl::marker::SourceBreaking,
1673}
1674
1675impl fidl::Persistable for SecureHeapProperties {}
1676
1677#[derive(Clone, Debug, Default, PartialEq)]
1678pub struct SecureHeapRange {
1679    /// Must be aligned to at least heap_range_granularity.
1680    pub physical_address: Option<u64>,
1681    /// Must be aligned to at least heap_range_granularity.
1682    pub size_bytes: Option<u64>,
1683    #[doc(hidden)]
1684    pub __source_breaking: fidl::marker::SourceBreaking,
1685}
1686
1687impl fidl::Persistable for SecureHeapRange {}
1688
1689#[derive(Clone, Debug, Default, PartialEq)]
1690pub struct SecureMemAddSecureHeapPhysicalRangeRequest {
1691    pub heap_range: Option<SecureHeapAndRange>,
1692    #[doc(hidden)]
1693    pub __source_breaking: fidl::marker::SourceBreaking,
1694}
1695
1696impl fidl::Persistable for SecureMemAddSecureHeapPhysicalRangeRequest {}
1697
1698#[derive(Clone, Debug, Default, PartialEq)]
1699pub struct SecureMemDeleteSecureHeapPhysicalRangeRequest {
1700    pub heap_range: Option<SecureHeapAndRange>,
1701    #[doc(hidden)]
1702    pub __source_breaking: fidl::marker::SourceBreaking,
1703}
1704
1705impl fidl::Persistable for SecureMemDeleteSecureHeapPhysicalRangeRequest {}
1706
1707#[derive(Clone, Debug, Default, PartialEq)]
1708pub struct SecureMemGetPhysicalSecureHeapPropertiesRequest {
1709    pub entire_heap: Option<SecureHeapAndRange>,
1710    #[doc(hidden)]
1711    pub __source_breaking: fidl::marker::SourceBreaking,
1712}
1713
1714impl fidl::Persistable for SecureMemGetPhysicalSecureHeapPropertiesRequest {}
1715
1716#[derive(Clone, Debug, Default, PartialEq)]
1717pub struct SecureMemModifySecureHeapPhysicalRangeRequest {
1718    pub range_modification: Option<SecureHeapAndRangeModification>,
1719    #[doc(hidden)]
1720    pub __source_breaking: fidl::marker::SourceBreaking,
1721}
1722
1723impl fidl::Persistable for SecureMemModifySecureHeapPhysicalRangeRequest {}
1724
1725#[derive(Clone, Debug, Default, PartialEq)]
1726pub struct SecureMemZeroSubRangeRequest {
1727    pub is_covering_range_explicit: Option<bool>,
1728    pub heap_range: Option<SecureHeapAndRange>,
1729    #[doc(hidden)]
1730    pub __source_breaking: fidl::marker::SourceBreaking,
1731}
1732
1733impl fidl::Persistable for SecureMemZeroSubRangeRequest {}
1734
1735#[derive(Clone, Debug, Default, PartialEq)]
1736pub struct SecureMemGetDynamicSecureHeapsResponse {
1737    pub heaps: Option<Vec<DynamicSecureHeap>>,
1738    #[doc(hidden)]
1739    pub __source_breaking: fidl::marker::SourceBreaking,
1740}
1741
1742impl fidl::Persistable for SecureMemGetDynamicSecureHeapsResponse {}
1743
1744#[derive(Clone, Debug, Default, PartialEq)]
1745pub struct SecureMemGetPhysicalSecureHeapPropertiesResponse {
1746    pub properties: Option<SecureHeapProperties>,
1747    #[doc(hidden)]
1748    pub __source_breaking: fidl::marker::SourceBreaking,
1749}
1750
1751impl fidl::Persistable for SecureMemGetPhysicalSecureHeapPropertiesResponse {}
1752
1753#[derive(Clone, Debug, Default, PartialEq)]
1754pub struct SecureMemGetPhysicalSecureHeapsResponse {
1755    pub heaps: Option<Vec<SecureHeapAndRanges>>,
1756    #[doc(hidden)]
1757    pub __source_breaking: fidl::marker::SourceBreaking,
1758}
1759
1760impl fidl::Persistable for SecureMemGetPhysicalSecureHeapsResponse {}
1761
1762/// These settings and constraints apply to all the buffers in the collection.
1763#[derive(Clone, Debug, Default, PartialEq)]
1764pub struct SingleBufferSettings {
1765    /// This field will always be set by sysmem.
1766    pub buffer_settings: Option<BufferMemorySettings>,
1767    /// Buffers holding data that is not uncompressed image data will not have
1768    /// this field set.  Buffers holding data that is uncompressed image data
1769    /// _may_ have this field set.
1770    ///
1771    /// At least for now, changing the PixelFormat requires re-allocating
1772    /// buffers.
1773    ///
1774    /// If un-set, there are no image format constraints.
1775    pub image_format_constraints: Option<ImageFormatConstraints>,
1776    #[doc(hidden)]
1777    pub __source_breaking: fidl::marker::SourceBreaking,
1778}
1779
1780impl fidl::Persistable for SingleBufferSettings {}
1781
1782pub mod allocator_ordinals {
1783    pub const ALLOCATE_NON_SHARED_COLLECTION: u64 = 0x5ca681f025a80e44;
1784    pub const ALLOCATE_SHARED_COLLECTION: u64 = 0x11a19ff51f0b49c1;
1785    pub const BIND_SHARED_COLLECTION: u64 = 0x550916b0dc1d5b4e;
1786    pub const VALIDATE_BUFFER_COLLECTION_TOKEN: u64 = 0x4c5ee91b02a7e68d;
1787    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x6f68f19a3f509c4d;
1788    pub const GET_VMO_INFO: u64 = 0x21a881120aa0ddf9;
1789}
1790
1791pub mod buffer_collection_ordinals {
1792    pub const SYNC: u64 = 0x11ac2555cf575b54;
1793    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1794    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1795    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1796    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1797    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1798    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1799    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1800    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1801    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1802    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1803    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1804    pub const SET_CONSTRAINTS: u64 = 0x1fde0f19d650197b;
1805    pub const WAIT_FOR_ALL_BUFFERS_ALLOCATED: u64 = 0x62300344b61404e;
1806    pub const CHECK_ALL_BUFFERS_ALLOCATED: u64 = 0x35a5fe77ce939c10;
1807    pub const ATTACH_TOKEN: u64 = 0x46ac7d0008492982;
1808    pub const ATTACH_LIFETIME_TRACKING: u64 = 0x3ecb510113116dcf;
1809}
1810
1811pub mod buffer_collection_token_ordinals {
1812    pub const SYNC: u64 = 0x11ac2555cf575b54;
1813    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1814    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1815    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1816    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1817    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1818    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1819    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1820    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1821    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1822    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1823    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1824    pub const DUPLICATE_SYNC: u64 = 0x1c1af9919d1ca45c;
1825    pub const DUPLICATE: u64 = 0x73e78f92ee7fb887;
1826    pub const SET_DISPENSABLE: u64 = 0x228acf979254df8b;
1827    pub const CREATE_BUFFER_COLLECTION_TOKEN_GROUP: u64 = 0x30f8d48e77bd36f2;
1828}
1829
1830pub mod buffer_collection_token_group_ordinals {
1831    pub const SYNC: u64 = 0x11ac2555cf575b54;
1832    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1833    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1834    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1835    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1836    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1837    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1838    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1839    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1840    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1841    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1842    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1843    pub const CREATE_CHILD: u64 = 0x41a0075d419f30c5;
1844    pub const CREATE_CHILDREN_SYNC: u64 = 0x15dea448c536070a;
1845    pub const ALL_CHILDREN_PRESENT: u64 = 0x5c327e4a23391312;
1846}
1847
1848pub mod node_ordinals {
1849    pub const SYNC: u64 = 0x11ac2555cf575b54;
1850    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1851    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1852    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1853    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1854    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1855    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1856    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1857    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1858    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1859    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1860    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1861}
1862
1863pub mod secure_mem_ordinals {
1864    pub const GET_PHYSICAL_SECURE_HEAPS: u64 = 0x38716300592073e3;
1865    pub const GET_DYNAMIC_SECURE_HEAPS: u64 = 0x1190847f99952834;
1866    pub const GET_PHYSICAL_SECURE_HEAP_PROPERTIES: u64 = 0xc6f06889009c7bc;
1867    pub const ADD_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0x35f695b9b6c7217a;
1868    pub const DELETE_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0xeaa58c650264c9e;
1869    pub const MODIFY_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0x60b7448aa1187734;
1870    pub const ZERO_SUB_RANGE: u64 = 0x5b25b7901a385ce5;
1871}
1872
1873mod internal {
1874    use super::*;
1875    unsafe impl fidl::encoding::TypeMarker for CoherencyDomain {
1876        type Owned = Self;
1877
1878        #[inline(always)]
1879        fn inline_align(_context: fidl::encoding::Context) -> usize {
1880            std::mem::align_of::<u32>()
1881        }
1882
1883        #[inline(always)]
1884        fn inline_size(_context: fidl::encoding::Context) -> usize {
1885            std::mem::size_of::<u32>()
1886        }
1887
1888        #[inline(always)]
1889        fn encode_is_copy() -> bool {
1890            false
1891        }
1892
1893        #[inline(always)]
1894        fn decode_is_copy() -> bool {
1895            false
1896        }
1897    }
1898
1899    impl fidl::encoding::ValueTypeMarker for CoherencyDomain {
1900        type Borrowed<'a> = Self;
1901        #[inline(always)]
1902        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1903            *value
1904        }
1905    }
1906
1907    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1908        for CoherencyDomain
1909    {
1910        #[inline]
1911        unsafe fn encode(
1912            self,
1913            encoder: &mut fidl::encoding::Encoder<'_, D>,
1914            offset: usize,
1915            _depth: fidl::encoding::Depth,
1916        ) -> fidl::Result<()> {
1917            encoder.debug_check_bounds::<Self>(offset);
1918            encoder.write_num(self.into_primitive(), offset);
1919            Ok(())
1920        }
1921    }
1922
1923    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CoherencyDomain {
1924        #[inline(always)]
1925        fn new_empty() -> Self {
1926            Self::unknown()
1927        }
1928
1929        #[inline]
1930        unsafe fn decode(
1931            &mut self,
1932            decoder: &mut fidl::encoding::Decoder<'_, D>,
1933            offset: usize,
1934            _depth: fidl::encoding::Depth,
1935        ) -> fidl::Result<()> {
1936            decoder.debug_check_bounds::<Self>(offset);
1937            let prim = decoder.read_num::<u32>(offset);
1938
1939            *self = Self::from_primitive_allow_unknown(prim);
1940            Ok(())
1941        }
1942    }
1943    unsafe impl fidl::encoding::TypeMarker for Error {
1944        type Owned = Self;
1945
1946        #[inline(always)]
1947        fn inline_align(_context: fidl::encoding::Context) -> usize {
1948            std::mem::align_of::<u32>()
1949        }
1950
1951        #[inline(always)]
1952        fn inline_size(_context: fidl::encoding::Context) -> usize {
1953            std::mem::size_of::<u32>()
1954        }
1955
1956        #[inline(always)]
1957        fn encode_is_copy() -> bool {
1958            false
1959        }
1960
1961        #[inline(always)]
1962        fn decode_is_copy() -> bool {
1963            false
1964        }
1965    }
1966
1967    impl fidl::encoding::ValueTypeMarker for Error {
1968        type Borrowed<'a> = Self;
1969        #[inline(always)]
1970        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1971            *value
1972        }
1973    }
1974
1975    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
1976        #[inline]
1977        unsafe fn encode(
1978            self,
1979            encoder: &mut fidl::encoding::Encoder<'_, D>,
1980            offset: usize,
1981            _depth: fidl::encoding::Depth,
1982        ) -> fidl::Result<()> {
1983            encoder.debug_check_bounds::<Self>(offset);
1984            encoder.write_num(self.into_primitive(), offset);
1985            Ok(())
1986        }
1987    }
1988
1989    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
1990        #[inline(always)]
1991        fn new_empty() -> Self {
1992            Self::unknown()
1993        }
1994
1995        #[inline]
1996        unsafe fn decode(
1997            &mut self,
1998            decoder: &mut fidl::encoding::Decoder<'_, D>,
1999            offset: usize,
2000            _depth: fidl::encoding::Depth,
2001        ) -> fidl::Result<()> {
2002            decoder.debug_check_bounds::<Self>(offset);
2003            let prim = decoder.read_num::<u32>(offset);
2004
2005            *self = Self::from_primitive_allow_unknown(prim);
2006            Ok(())
2007        }
2008    }
2009
2010    impl fidl::encoding::ValueTypeMarker for PixelFormatAndModifier {
2011        type Borrowed<'a> = &'a Self;
2012        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2013            value
2014        }
2015    }
2016
2017    unsafe impl fidl::encoding::TypeMarker for PixelFormatAndModifier {
2018        type Owned = Self;
2019
2020        #[inline(always)]
2021        fn inline_align(_context: fidl::encoding::Context) -> usize {
2022            8
2023        }
2024
2025        #[inline(always)]
2026        fn inline_size(_context: fidl::encoding::Context) -> usize {
2027            16
2028        }
2029    }
2030
2031    unsafe impl<D: fidl::encoding::ResourceDialect>
2032        fidl::encoding::Encode<PixelFormatAndModifier, D> for &PixelFormatAndModifier
2033    {
2034        #[inline]
2035        unsafe fn encode(
2036            self,
2037            encoder: &mut fidl::encoding::Encoder<'_, D>,
2038            offset: usize,
2039            _depth: fidl::encoding::Depth,
2040        ) -> fidl::Result<()> {
2041            encoder.debug_check_bounds::<PixelFormatAndModifier>(offset);
2042            // Delegate to tuple encoding.
2043            fidl::encoding::Encode::<PixelFormatAndModifier, D>::encode(
2044                (
2045                    <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format),
2046                    <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format_modifier),
2047                ),
2048                encoder, offset, _depth
2049            )
2050        }
2051    }
2052    unsafe impl<
2053        D: fidl::encoding::ResourceDialect,
2054        T0: fidl::encoding::Encode<fidl_fuchsia_images2__common::PixelFormat, D>,
2055        T1: fidl::encoding::Encode<fidl_fuchsia_images2__common::PixelFormatModifier, D>,
2056    > fidl::encoding::Encode<PixelFormatAndModifier, D> for (T0, T1)
2057    {
2058        #[inline]
2059        unsafe fn encode(
2060            self,
2061            encoder: &mut fidl::encoding::Encoder<'_, D>,
2062            offset: usize,
2063            depth: fidl::encoding::Depth,
2064        ) -> fidl::Result<()> {
2065            encoder.debug_check_bounds::<PixelFormatAndModifier>(offset);
2066            // Zero out padding regions. There's no need to apply masks
2067            // because the unmasked parts will be overwritten by fields.
2068            unsafe {
2069                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2070                (ptr as *mut u64).write_unaligned(0);
2071            }
2072            // Write the fields.
2073            self.0.encode(encoder, offset + 0, depth)?;
2074            self.1.encode(encoder, offset + 8, depth)?;
2075            Ok(())
2076        }
2077    }
2078
2079    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2080        for PixelFormatAndModifier
2081    {
2082        #[inline(always)]
2083        fn new_empty() -> Self {
2084            Self {
2085                pixel_format: fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D),
2086                pixel_format_modifier: fidl::new_empty!(
2087                    fidl_fuchsia_images2__common::PixelFormatModifier,
2088                    D
2089                ),
2090            }
2091        }
2092
2093        #[inline]
2094        unsafe fn decode(
2095            &mut self,
2096            decoder: &mut fidl::encoding::Decoder<'_, D>,
2097            offset: usize,
2098            _depth: fidl::encoding::Depth,
2099        ) -> fidl::Result<()> {
2100            decoder.debug_check_bounds::<Self>(offset);
2101            // Verify that padding bytes are zero.
2102            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2103            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2104            let mask = 0xffffffff00000000u64;
2105            let maskedval = padval & mask;
2106            if maskedval != 0 {
2107                return Err(fidl::Error::NonZeroPadding {
2108                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2109                });
2110            }
2111            fidl::decode!(
2112                fidl_fuchsia_images2__common::PixelFormat,
2113                D,
2114                &mut self.pixel_format,
2115                decoder,
2116                offset + 0,
2117                _depth
2118            )?;
2119            fidl::decode!(
2120                fidl_fuchsia_images2__common::PixelFormatModifier,
2121                D,
2122                &mut self.pixel_format_modifier,
2123                decoder,
2124                offset + 8,
2125                _depth
2126            )?;
2127            Ok(())
2128        }
2129    }
2130
2131    impl AllocatorSetDebugClientInfoRequest {
2132        #[inline(always)]
2133        fn max_ordinal_present(&self) -> u64 {
2134            if let Some(_) = self.id {
2135                return 2;
2136            }
2137            if let Some(_) = self.name {
2138                return 1;
2139            }
2140            0
2141        }
2142    }
2143
2144    impl fidl::encoding::ValueTypeMarker for AllocatorSetDebugClientInfoRequest {
2145        type Borrowed<'a> = &'a Self;
2146        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2147            value
2148        }
2149    }
2150
2151    unsafe impl fidl::encoding::TypeMarker for AllocatorSetDebugClientInfoRequest {
2152        type Owned = Self;
2153
2154        #[inline(always)]
2155        fn inline_align(_context: fidl::encoding::Context) -> usize {
2156            8
2157        }
2158
2159        #[inline(always)]
2160        fn inline_size(_context: fidl::encoding::Context) -> usize {
2161            16
2162        }
2163    }
2164
2165    unsafe impl<D: fidl::encoding::ResourceDialect>
2166        fidl::encoding::Encode<AllocatorSetDebugClientInfoRequest, D>
2167        for &AllocatorSetDebugClientInfoRequest
2168    {
2169        unsafe fn encode(
2170            self,
2171            encoder: &mut fidl::encoding::Encoder<'_, D>,
2172            offset: usize,
2173            mut depth: fidl::encoding::Depth,
2174        ) -> fidl::Result<()> {
2175            encoder.debug_check_bounds::<AllocatorSetDebugClientInfoRequest>(offset);
2176            // Vector header
2177            let max_ordinal: u64 = self.max_ordinal_present();
2178            encoder.write_num(max_ordinal, offset);
2179            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2180            // Calling encoder.out_of_line_offset(0) is not allowed.
2181            if max_ordinal == 0 {
2182                return Ok(());
2183            }
2184            depth.increment()?;
2185            let envelope_size = 8;
2186            let bytes_len = max_ordinal as usize * envelope_size;
2187            #[allow(unused_variables)]
2188            let offset = encoder.out_of_line_offset(bytes_len);
2189            let mut _prev_end_offset: usize = 0;
2190            if 1 > max_ordinal {
2191                return Ok(());
2192            }
2193
2194            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2195            // are envelope_size bytes.
2196            let cur_offset: usize = (1 - 1) * envelope_size;
2197
2198            // Zero reserved fields.
2199            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2200
2201            // Safety:
2202            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2203            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2204            //   envelope_size bytes, there is always sufficient room.
2205            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
2206                self.name.as_ref().map(
2207                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
2208                ),
2209                encoder,
2210                offset + cur_offset,
2211                depth,
2212            )?;
2213
2214            _prev_end_offset = cur_offset + envelope_size;
2215            if 2 > max_ordinal {
2216                return Ok(());
2217            }
2218
2219            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2220            // are envelope_size bytes.
2221            let cur_offset: usize = (2 - 1) * envelope_size;
2222
2223            // Zero reserved fields.
2224            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2225
2226            // Safety:
2227            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2228            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2229            //   envelope_size bytes, there is always sufficient room.
2230            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2231                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2232                encoder,
2233                offset + cur_offset,
2234                depth,
2235            )?;
2236
2237            _prev_end_offset = cur_offset + envelope_size;
2238
2239            Ok(())
2240        }
2241    }
2242
2243    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2244        for AllocatorSetDebugClientInfoRequest
2245    {
2246        #[inline(always)]
2247        fn new_empty() -> Self {
2248            Self::default()
2249        }
2250
2251        unsafe fn decode(
2252            &mut self,
2253            decoder: &mut fidl::encoding::Decoder<'_, D>,
2254            offset: usize,
2255            mut depth: fidl::encoding::Depth,
2256        ) -> fidl::Result<()> {
2257            decoder.debug_check_bounds::<Self>(offset);
2258            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2259                None => return Err(fidl::Error::NotNullable),
2260                Some(len) => len,
2261            };
2262            // Calling decoder.out_of_line_offset(0) is not allowed.
2263            if len == 0 {
2264                return Ok(());
2265            };
2266            depth.increment()?;
2267            let envelope_size = 8;
2268            let bytes_len = len * envelope_size;
2269            let offset = decoder.out_of_line_offset(bytes_len)?;
2270            // Decode the envelope for each type.
2271            let mut _next_ordinal_to_read = 0;
2272            let mut next_offset = offset;
2273            let end_offset = offset + bytes_len;
2274            _next_ordinal_to_read += 1;
2275            if next_offset >= end_offset {
2276                return Ok(());
2277            }
2278
2279            // Decode unknown envelopes for gaps in ordinals.
2280            while _next_ordinal_to_read < 1 {
2281                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2282                _next_ordinal_to_read += 1;
2283                next_offset += envelope_size;
2284            }
2285
2286            let next_out_of_line = decoder.next_out_of_line();
2287            let handles_before = decoder.remaining_handles();
2288            if let Some((inlined, num_bytes, num_handles)) =
2289                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2290            {
2291                let member_inline_size =
2292                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
2293                        decoder.context,
2294                    );
2295                if inlined != (member_inline_size <= 4) {
2296                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2297                }
2298                let inner_offset;
2299                let mut inner_depth = depth.clone();
2300                if inlined {
2301                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2302                    inner_offset = next_offset;
2303                } else {
2304                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2305                    inner_depth.increment()?;
2306                }
2307                let val_ref = self
2308                    .name
2309                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
2310                fidl::decode!(
2311                    fidl::encoding::BoundedString<256>,
2312                    D,
2313                    val_ref,
2314                    decoder,
2315                    inner_offset,
2316                    inner_depth
2317                )?;
2318                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2319                {
2320                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2321                }
2322                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2323                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2324                }
2325            }
2326
2327            next_offset += envelope_size;
2328            _next_ordinal_to_read += 1;
2329            if next_offset >= end_offset {
2330                return Ok(());
2331            }
2332
2333            // Decode unknown envelopes for gaps in ordinals.
2334            while _next_ordinal_to_read < 2 {
2335                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2336                _next_ordinal_to_read += 1;
2337                next_offset += envelope_size;
2338            }
2339
2340            let next_out_of_line = decoder.next_out_of_line();
2341            let handles_before = decoder.remaining_handles();
2342            if let Some((inlined, num_bytes, num_handles)) =
2343                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2344            {
2345                let member_inline_size =
2346                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2347                if inlined != (member_inline_size <= 4) {
2348                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2349                }
2350                let inner_offset;
2351                let mut inner_depth = depth.clone();
2352                if inlined {
2353                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2354                    inner_offset = next_offset;
2355                } else {
2356                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2357                    inner_depth.increment()?;
2358                }
2359                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
2360                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2361                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2362                {
2363                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2364                }
2365                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2366                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2367                }
2368            }
2369
2370            next_offset += envelope_size;
2371
2372            // Decode the remaining unknown envelopes.
2373            while next_offset < end_offset {
2374                _next_ordinal_to_read += 1;
2375                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2376                next_offset += envelope_size;
2377            }
2378
2379            Ok(())
2380        }
2381    }
2382
2383    impl AllocatorValidateBufferCollectionTokenRequest {
2384        #[inline(always)]
2385        fn max_ordinal_present(&self) -> u64 {
2386            if let Some(_) = self.token_server_koid {
2387                return 1;
2388            }
2389            0
2390        }
2391    }
2392
2393    impl fidl::encoding::ValueTypeMarker for AllocatorValidateBufferCollectionTokenRequest {
2394        type Borrowed<'a> = &'a Self;
2395        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2396            value
2397        }
2398    }
2399
2400    unsafe impl fidl::encoding::TypeMarker for AllocatorValidateBufferCollectionTokenRequest {
2401        type Owned = Self;
2402
2403        #[inline(always)]
2404        fn inline_align(_context: fidl::encoding::Context) -> usize {
2405            8
2406        }
2407
2408        #[inline(always)]
2409        fn inline_size(_context: fidl::encoding::Context) -> usize {
2410            16
2411        }
2412    }
2413
2414    unsafe impl<D: fidl::encoding::ResourceDialect>
2415        fidl::encoding::Encode<AllocatorValidateBufferCollectionTokenRequest, D>
2416        for &AllocatorValidateBufferCollectionTokenRequest
2417    {
2418        unsafe fn encode(
2419            self,
2420            encoder: &mut fidl::encoding::Encoder<'_, D>,
2421            offset: usize,
2422            mut depth: fidl::encoding::Depth,
2423        ) -> fidl::Result<()> {
2424            encoder.debug_check_bounds::<AllocatorValidateBufferCollectionTokenRequest>(offset);
2425            // Vector header
2426            let max_ordinal: u64 = self.max_ordinal_present();
2427            encoder.write_num(max_ordinal, offset);
2428            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2429            // Calling encoder.out_of_line_offset(0) is not allowed.
2430            if max_ordinal == 0 {
2431                return Ok(());
2432            }
2433            depth.increment()?;
2434            let envelope_size = 8;
2435            let bytes_len = max_ordinal as usize * envelope_size;
2436            #[allow(unused_variables)]
2437            let offset = encoder.out_of_line_offset(bytes_len);
2438            let mut _prev_end_offset: usize = 0;
2439            if 1 > max_ordinal {
2440                return Ok(());
2441            }
2442
2443            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2444            // are envelope_size bytes.
2445            let cur_offset: usize = (1 - 1) * envelope_size;
2446
2447            // Zero reserved fields.
2448            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2449
2450            // Safety:
2451            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2452            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2453            //   envelope_size bytes, there is always sufficient room.
2454            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2455                self.token_server_koid
2456                    .as_ref()
2457                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2458                encoder,
2459                offset + cur_offset,
2460                depth,
2461            )?;
2462
2463            _prev_end_offset = cur_offset + envelope_size;
2464
2465            Ok(())
2466        }
2467    }
2468
2469    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2470        for AllocatorValidateBufferCollectionTokenRequest
2471    {
2472        #[inline(always)]
2473        fn new_empty() -> Self {
2474            Self::default()
2475        }
2476
2477        unsafe fn decode(
2478            &mut self,
2479            decoder: &mut fidl::encoding::Decoder<'_, D>,
2480            offset: usize,
2481            mut depth: fidl::encoding::Depth,
2482        ) -> fidl::Result<()> {
2483            decoder.debug_check_bounds::<Self>(offset);
2484            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2485                None => return Err(fidl::Error::NotNullable),
2486                Some(len) => len,
2487            };
2488            // Calling decoder.out_of_line_offset(0) is not allowed.
2489            if len == 0 {
2490                return Ok(());
2491            };
2492            depth.increment()?;
2493            let envelope_size = 8;
2494            let bytes_len = len * envelope_size;
2495            let offset = decoder.out_of_line_offset(bytes_len)?;
2496            // Decode the envelope for each type.
2497            let mut _next_ordinal_to_read = 0;
2498            let mut next_offset = offset;
2499            let end_offset = offset + bytes_len;
2500            _next_ordinal_to_read += 1;
2501            if next_offset >= end_offset {
2502                return Ok(());
2503            }
2504
2505            // Decode unknown envelopes for gaps in ordinals.
2506            while _next_ordinal_to_read < 1 {
2507                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2508                _next_ordinal_to_read += 1;
2509                next_offset += envelope_size;
2510            }
2511
2512            let next_out_of_line = decoder.next_out_of_line();
2513            let handles_before = decoder.remaining_handles();
2514            if let Some((inlined, num_bytes, num_handles)) =
2515                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2516            {
2517                let member_inline_size =
2518                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2519                if inlined != (member_inline_size <= 4) {
2520                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2521                }
2522                let inner_offset;
2523                let mut inner_depth = depth.clone();
2524                if inlined {
2525                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2526                    inner_offset = next_offset;
2527                } else {
2528                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2529                    inner_depth.increment()?;
2530                }
2531                let val_ref =
2532                    self.token_server_koid.get_or_insert_with(|| fidl::new_empty!(u64, D));
2533                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2534                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2535                {
2536                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2537                }
2538                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2539                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2540                }
2541            }
2542
2543            next_offset += envelope_size;
2544
2545            // Decode the remaining unknown envelopes.
2546            while next_offset < end_offset {
2547                _next_ordinal_to_read += 1;
2548                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2549                next_offset += envelope_size;
2550            }
2551
2552            Ok(())
2553        }
2554    }
2555
2556    impl AllocatorValidateBufferCollectionTokenResponse {
2557        #[inline(always)]
2558        fn max_ordinal_present(&self) -> u64 {
2559            if let Some(_) = self.is_known {
2560                return 1;
2561            }
2562            0
2563        }
2564    }
2565
2566    impl fidl::encoding::ValueTypeMarker for AllocatorValidateBufferCollectionTokenResponse {
2567        type Borrowed<'a> = &'a Self;
2568        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2569            value
2570        }
2571    }
2572
2573    unsafe impl fidl::encoding::TypeMarker for AllocatorValidateBufferCollectionTokenResponse {
2574        type Owned = Self;
2575
2576        #[inline(always)]
2577        fn inline_align(_context: fidl::encoding::Context) -> usize {
2578            8
2579        }
2580
2581        #[inline(always)]
2582        fn inline_size(_context: fidl::encoding::Context) -> usize {
2583            16
2584        }
2585    }
2586
2587    unsafe impl<D: fidl::encoding::ResourceDialect>
2588        fidl::encoding::Encode<AllocatorValidateBufferCollectionTokenResponse, D>
2589        for &AllocatorValidateBufferCollectionTokenResponse
2590    {
2591        unsafe fn encode(
2592            self,
2593            encoder: &mut fidl::encoding::Encoder<'_, D>,
2594            offset: usize,
2595            mut depth: fidl::encoding::Depth,
2596        ) -> fidl::Result<()> {
2597            encoder.debug_check_bounds::<AllocatorValidateBufferCollectionTokenResponse>(offset);
2598            // Vector header
2599            let max_ordinal: u64 = self.max_ordinal_present();
2600            encoder.write_num(max_ordinal, offset);
2601            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2602            // Calling encoder.out_of_line_offset(0) is not allowed.
2603            if max_ordinal == 0 {
2604                return Ok(());
2605            }
2606            depth.increment()?;
2607            let envelope_size = 8;
2608            let bytes_len = max_ordinal as usize * envelope_size;
2609            #[allow(unused_variables)]
2610            let offset = encoder.out_of_line_offset(bytes_len);
2611            let mut _prev_end_offset: usize = 0;
2612            if 1 > max_ordinal {
2613                return Ok(());
2614            }
2615
2616            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2617            // are envelope_size bytes.
2618            let cur_offset: usize = (1 - 1) * envelope_size;
2619
2620            // Zero reserved fields.
2621            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2622
2623            // Safety:
2624            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2625            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2626            //   envelope_size bytes, there is always sufficient room.
2627            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2628                self.is_known.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2629                encoder,
2630                offset + cur_offset,
2631                depth,
2632            )?;
2633
2634            _prev_end_offset = cur_offset + envelope_size;
2635
2636            Ok(())
2637        }
2638    }
2639
2640    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2641        for AllocatorValidateBufferCollectionTokenResponse
2642    {
2643        #[inline(always)]
2644        fn new_empty() -> Self {
2645            Self::default()
2646        }
2647
2648        unsafe fn decode(
2649            &mut self,
2650            decoder: &mut fidl::encoding::Decoder<'_, D>,
2651            offset: usize,
2652            mut depth: fidl::encoding::Depth,
2653        ) -> fidl::Result<()> {
2654            decoder.debug_check_bounds::<Self>(offset);
2655            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2656                None => return Err(fidl::Error::NotNullable),
2657                Some(len) => len,
2658            };
2659            // Calling decoder.out_of_line_offset(0) is not allowed.
2660            if len == 0 {
2661                return Ok(());
2662            };
2663            depth.increment()?;
2664            let envelope_size = 8;
2665            let bytes_len = len * envelope_size;
2666            let offset = decoder.out_of_line_offset(bytes_len)?;
2667            // Decode the envelope for each type.
2668            let mut _next_ordinal_to_read = 0;
2669            let mut next_offset = offset;
2670            let end_offset = offset + bytes_len;
2671            _next_ordinal_to_read += 1;
2672            if next_offset >= end_offset {
2673                return Ok(());
2674            }
2675
2676            // Decode unknown envelopes for gaps in ordinals.
2677            while _next_ordinal_to_read < 1 {
2678                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2679                _next_ordinal_to_read += 1;
2680                next_offset += envelope_size;
2681            }
2682
2683            let next_out_of_line = decoder.next_out_of_line();
2684            let handles_before = decoder.remaining_handles();
2685            if let Some((inlined, num_bytes, num_handles)) =
2686                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2687            {
2688                let member_inline_size =
2689                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2690                if inlined != (member_inline_size <= 4) {
2691                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2692                }
2693                let inner_offset;
2694                let mut inner_depth = depth.clone();
2695                if inlined {
2696                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2697                    inner_offset = next_offset;
2698                } else {
2699                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2700                    inner_depth.increment()?;
2701                }
2702                let val_ref = self.is_known.get_or_insert_with(|| fidl::new_empty!(bool, D));
2703                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2704                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2705                {
2706                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2707                }
2708                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2709                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2710                }
2711            }
2712
2713            next_offset += envelope_size;
2714
2715            // Decode the remaining unknown envelopes.
2716            while next_offset < end_offset {
2717                _next_ordinal_to_read += 1;
2718                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2719                next_offset += envelope_size;
2720            }
2721
2722            Ok(())
2723        }
2724    }
2725
2726    impl BufferCollectionConstraints {
2727        #[inline(always)]
2728        fn max_ordinal_present(&self) -> u64 {
2729            if let Some(_) = self.image_format_constraints {
2730                return 8;
2731            }
2732            if let Some(_) = self.buffer_memory_constraints {
2733                return 7;
2734            }
2735            if let Some(_) = self.max_buffer_count {
2736                return 6;
2737            }
2738            if let Some(_) = self.min_buffer_count {
2739                return 5;
2740            }
2741            if let Some(_) = self.min_buffer_count_for_shared_slack {
2742                return 4;
2743            }
2744            if let Some(_) = self.min_buffer_count_for_dedicated_slack {
2745                return 3;
2746            }
2747            if let Some(_) = self.min_buffer_count_for_camping {
2748                return 2;
2749            }
2750            if let Some(_) = self.usage {
2751                return 1;
2752            }
2753            0
2754        }
2755    }
2756
2757    impl fidl::encoding::ValueTypeMarker for BufferCollectionConstraints {
2758        type Borrowed<'a> = &'a Self;
2759        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2760            value
2761        }
2762    }
2763
2764    unsafe impl fidl::encoding::TypeMarker for BufferCollectionConstraints {
2765        type Owned = Self;
2766
2767        #[inline(always)]
2768        fn inline_align(_context: fidl::encoding::Context) -> usize {
2769            8
2770        }
2771
2772        #[inline(always)]
2773        fn inline_size(_context: fidl::encoding::Context) -> usize {
2774            16
2775        }
2776    }
2777
2778    unsafe impl<D: fidl::encoding::ResourceDialect>
2779        fidl::encoding::Encode<BufferCollectionConstraints, D> for &BufferCollectionConstraints
2780    {
2781        unsafe fn encode(
2782            self,
2783            encoder: &mut fidl::encoding::Encoder<'_, D>,
2784            offset: usize,
2785            mut depth: fidl::encoding::Depth,
2786        ) -> fidl::Result<()> {
2787            encoder.debug_check_bounds::<BufferCollectionConstraints>(offset);
2788            // Vector header
2789            let max_ordinal: u64 = self.max_ordinal_present();
2790            encoder.write_num(max_ordinal, offset);
2791            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2792            // Calling encoder.out_of_line_offset(0) is not allowed.
2793            if max_ordinal == 0 {
2794                return Ok(());
2795            }
2796            depth.increment()?;
2797            let envelope_size = 8;
2798            let bytes_len = max_ordinal as usize * envelope_size;
2799            #[allow(unused_variables)]
2800            let offset = encoder.out_of_line_offset(bytes_len);
2801            let mut _prev_end_offset: usize = 0;
2802            if 1 > max_ordinal {
2803                return Ok(());
2804            }
2805
2806            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2807            // are envelope_size bytes.
2808            let cur_offset: usize = (1 - 1) * envelope_size;
2809
2810            // Zero reserved fields.
2811            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2812
2813            // Safety:
2814            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2815            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2816            //   envelope_size bytes, there is always sufficient room.
2817            fidl::encoding::encode_in_envelope_optional::<BufferUsage, D>(
2818                self.usage.as_ref().map(<BufferUsage as fidl::encoding::ValueTypeMarker>::borrow),
2819                encoder,
2820                offset + cur_offset,
2821                depth,
2822            )?;
2823
2824            _prev_end_offset = cur_offset + envelope_size;
2825            if 2 > max_ordinal {
2826                return Ok(());
2827            }
2828
2829            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2830            // are envelope_size bytes.
2831            let cur_offset: usize = (2 - 1) * envelope_size;
2832
2833            // Zero reserved fields.
2834            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2835
2836            // Safety:
2837            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2838            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2839            //   envelope_size bytes, there is always sufficient room.
2840            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2841                self.min_buffer_count_for_camping
2842                    .as_ref()
2843                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2844                encoder,
2845                offset + cur_offset,
2846                depth,
2847            )?;
2848
2849            _prev_end_offset = cur_offset + envelope_size;
2850            if 3 > max_ordinal {
2851                return Ok(());
2852            }
2853
2854            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2855            // are envelope_size bytes.
2856            let cur_offset: usize = (3 - 1) * envelope_size;
2857
2858            // Zero reserved fields.
2859            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2860
2861            // Safety:
2862            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2863            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2864            //   envelope_size bytes, there is always sufficient room.
2865            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2866                self.min_buffer_count_for_dedicated_slack
2867                    .as_ref()
2868                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2869                encoder,
2870                offset + cur_offset,
2871                depth,
2872            )?;
2873
2874            _prev_end_offset = cur_offset + envelope_size;
2875            if 4 > max_ordinal {
2876                return Ok(());
2877            }
2878
2879            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2880            // are envelope_size bytes.
2881            let cur_offset: usize = (4 - 1) * envelope_size;
2882
2883            // Zero reserved fields.
2884            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2885
2886            // Safety:
2887            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2888            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2889            //   envelope_size bytes, there is always sufficient room.
2890            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2891                self.min_buffer_count_for_shared_slack
2892                    .as_ref()
2893                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2894                encoder,
2895                offset + cur_offset,
2896                depth,
2897            )?;
2898
2899            _prev_end_offset = cur_offset + envelope_size;
2900            if 5 > max_ordinal {
2901                return Ok(());
2902            }
2903
2904            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2905            // are envelope_size bytes.
2906            let cur_offset: usize = (5 - 1) * envelope_size;
2907
2908            // Zero reserved fields.
2909            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2910
2911            // Safety:
2912            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2913            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2914            //   envelope_size bytes, there is always sufficient room.
2915            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2916                self.min_buffer_count
2917                    .as_ref()
2918                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2919                encoder,
2920                offset + cur_offset,
2921                depth,
2922            )?;
2923
2924            _prev_end_offset = cur_offset + envelope_size;
2925            if 6 > max_ordinal {
2926                return Ok(());
2927            }
2928
2929            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2930            // are envelope_size bytes.
2931            let cur_offset: usize = (6 - 1) * envelope_size;
2932
2933            // Zero reserved fields.
2934            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2935
2936            // Safety:
2937            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2938            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2939            //   envelope_size bytes, there is always sufficient room.
2940            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2941                self.max_buffer_count
2942                    .as_ref()
2943                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2944                encoder,
2945                offset + cur_offset,
2946                depth,
2947            )?;
2948
2949            _prev_end_offset = cur_offset + envelope_size;
2950            if 7 > max_ordinal {
2951                return Ok(());
2952            }
2953
2954            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2955            // are envelope_size bytes.
2956            let cur_offset: usize = (7 - 1) * envelope_size;
2957
2958            // Zero reserved fields.
2959            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2960
2961            // Safety:
2962            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2963            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2964            //   envelope_size bytes, there is always sufficient room.
2965            fidl::encoding::encode_in_envelope_optional::<BufferMemoryConstraints, D>(
2966                self.buffer_memory_constraints
2967                    .as_ref()
2968                    .map(<BufferMemoryConstraints as fidl::encoding::ValueTypeMarker>::borrow),
2969                encoder,
2970                offset + cur_offset,
2971                depth,
2972            )?;
2973
2974            _prev_end_offset = cur_offset + envelope_size;
2975            if 8 > max_ordinal {
2976                return Ok(());
2977            }
2978
2979            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2980            // are envelope_size bytes.
2981            let cur_offset: usize = (8 - 1) * envelope_size;
2982
2983            // Zero reserved fields.
2984            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2985
2986            // Safety:
2987            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2988            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2989            //   envelope_size bytes, there is always sufficient room.
2990            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<ImageFormatConstraints, 64>, D>(
2991            self.image_format_constraints.as_ref().map(<fidl::encoding::Vector<ImageFormatConstraints, 64> as fidl::encoding::ValueTypeMarker>::borrow),
2992            encoder, offset + cur_offset, depth
2993        )?;
2994
2995            _prev_end_offset = cur_offset + envelope_size;
2996
2997            Ok(())
2998        }
2999    }
3000
3001    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3002        for BufferCollectionConstraints
3003    {
3004        #[inline(always)]
3005        fn new_empty() -> Self {
3006            Self::default()
3007        }
3008
3009        unsafe fn decode(
3010            &mut self,
3011            decoder: &mut fidl::encoding::Decoder<'_, D>,
3012            offset: usize,
3013            mut depth: fidl::encoding::Depth,
3014        ) -> fidl::Result<()> {
3015            decoder.debug_check_bounds::<Self>(offset);
3016            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3017                None => return Err(fidl::Error::NotNullable),
3018                Some(len) => len,
3019            };
3020            // Calling decoder.out_of_line_offset(0) is not allowed.
3021            if len == 0 {
3022                return Ok(());
3023            };
3024            depth.increment()?;
3025            let envelope_size = 8;
3026            let bytes_len = len * envelope_size;
3027            let offset = decoder.out_of_line_offset(bytes_len)?;
3028            // Decode the envelope for each type.
3029            let mut _next_ordinal_to_read = 0;
3030            let mut next_offset = offset;
3031            let end_offset = offset + bytes_len;
3032            _next_ordinal_to_read += 1;
3033            if next_offset >= end_offset {
3034                return Ok(());
3035            }
3036
3037            // Decode unknown envelopes for gaps in ordinals.
3038            while _next_ordinal_to_read < 1 {
3039                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3040                _next_ordinal_to_read += 1;
3041                next_offset += envelope_size;
3042            }
3043
3044            let next_out_of_line = decoder.next_out_of_line();
3045            let handles_before = decoder.remaining_handles();
3046            if let Some((inlined, num_bytes, num_handles)) =
3047                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3048            {
3049                let member_inline_size =
3050                    <BufferUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3051                if inlined != (member_inline_size <= 4) {
3052                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3053                }
3054                let inner_offset;
3055                let mut inner_depth = depth.clone();
3056                if inlined {
3057                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3058                    inner_offset = next_offset;
3059                } else {
3060                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3061                    inner_depth.increment()?;
3062                }
3063                let val_ref = self.usage.get_or_insert_with(|| fidl::new_empty!(BufferUsage, D));
3064                fidl::decode!(BufferUsage, D, val_ref, decoder, inner_offset, inner_depth)?;
3065                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3066                {
3067                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3068                }
3069                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3070                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3071                }
3072            }
3073
3074            next_offset += envelope_size;
3075            _next_ordinal_to_read += 1;
3076            if next_offset >= end_offset {
3077                return Ok(());
3078            }
3079
3080            // Decode unknown envelopes for gaps in ordinals.
3081            while _next_ordinal_to_read < 2 {
3082                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3083                _next_ordinal_to_read += 1;
3084                next_offset += envelope_size;
3085            }
3086
3087            let next_out_of_line = decoder.next_out_of_line();
3088            let handles_before = decoder.remaining_handles();
3089            if let Some((inlined, num_bytes, num_handles)) =
3090                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3091            {
3092                let member_inline_size =
3093                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3094                if inlined != (member_inline_size <= 4) {
3095                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3096                }
3097                let inner_offset;
3098                let mut inner_depth = depth.clone();
3099                if inlined {
3100                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3101                    inner_offset = next_offset;
3102                } else {
3103                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3104                    inner_depth.increment()?;
3105                }
3106                let val_ref = self
3107                    .min_buffer_count_for_camping
3108                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3109                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3110                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3111                {
3112                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3113                }
3114                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3115                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3116                }
3117            }
3118
3119            next_offset += envelope_size;
3120            _next_ordinal_to_read += 1;
3121            if next_offset >= end_offset {
3122                return Ok(());
3123            }
3124
3125            // Decode unknown envelopes for gaps in ordinals.
3126            while _next_ordinal_to_read < 3 {
3127                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3128                _next_ordinal_to_read += 1;
3129                next_offset += envelope_size;
3130            }
3131
3132            let next_out_of_line = decoder.next_out_of_line();
3133            let handles_before = decoder.remaining_handles();
3134            if let Some((inlined, num_bytes, num_handles)) =
3135                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3136            {
3137                let member_inline_size =
3138                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3139                if inlined != (member_inline_size <= 4) {
3140                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3141                }
3142                let inner_offset;
3143                let mut inner_depth = depth.clone();
3144                if inlined {
3145                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3146                    inner_offset = next_offset;
3147                } else {
3148                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3149                    inner_depth.increment()?;
3150                }
3151                let val_ref = self
3152                    .min_buffer_count_for_dedicated_slack
3153                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3154                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3155                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3156                {
3157                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3158                }
3159                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3160                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3161                }
3162            }
3163
3164            next_offset += envelope_size;
3165            _next_ordinal_to_read += 1;
3166            if next_offset >= end_offset {
3167                return Ok(());
3168            }
3169
3170            // Decode unknown envelopes for gaps in ordinals.
3171            while _next_ordinal_to_read < 4 {
3172                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3173                _next_ordinal_to_read += 1;
3174                next_offset += envelope_size;
3175            }
3176
3177            let next_out_of_line = decoder.next_out_of_line();
3178            let handles_before = decoder.remaining_handles();
3179            if let Some((inlined, num_bytes, num_handles)) =
3180                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3181            {
3182                let member_inline_size =
3183                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3184                if inlined != (member_inline_size <= 4) {
3185                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3186                }
3187                let inner_offset;
3188                let mut inner_depth = depth.clone();
3189                if inlined {
3190                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3191                    inner_offset = next_offset;
3192                } else {
3193                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3194                    inner_depth.increment()?;
3195                }
3196                let val_ref = self
3197                    .min_buffer_count_for_shared_slack
3198                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3199                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3200                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3201                {
3202                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3203                }
3204                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3205                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3206                }
3207            }
3208
3209            next_offset += envelope_size;
3210            _next_ordinal_to_read += 1;
3211            if next_offset >= end_offset {
3212                return Ok(());
3213            }
3214
3215            // Decode unknown envelopes for gaps in ordinals.
3216            while _next_ordinal_to_read < 5 {
3217                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3218                _next_ordinal_to_read += 1;
3219                next_offset += envelope_size;
3220            }
3221
3222            let next_out_of_line = decoder.next_out_of_line();
3223            let handles_before = decoder.remaining_handles();
3224            if let Some((inlined, num_bytes, num_handles)) =
3225                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3226            {
3227                let member_inline_size =
3228                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3229                if inlined != (member_inline_size <= 4) {
3230                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3231                }
3232                let inner_offset;
3233                let mut inner_depth = depth.clone();
3234                if inlined {
3235                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3236                    inner_offset = next_offset;
3237                } else {
3238                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3239                    inner_depth.increment()?;
3240                }
3241                let val_ref = self.min_buffer_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
3242                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3243                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3244                {
3245                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3246                }
3247                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3248                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3249                }
3250            }
3251
3252            next_offset += envelope_size;
3253            _next_ordinal_to_read += 1;
3254            if next_offset >= end_offset {
3255                return Ok(());
3256            }
3257
3258            // Decode unknown envelopes for gaps in ordinals.
3259            while _next_ordinal_to_read < 6 {
3260                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3261                _next_ordinal_to_read += 1;
3262                next_offset += envelope_size;
3263            }
3264
3265            let next_out_of_line = decoder.next_out_of_line();
3266            let handles_before = decoder.remaining_handles();
3267            if let Some((inlined, num_bytes, num_handles)) =
3268                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3269            {
3270                let member_inline_size =
3271                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3272                if inlined != (member_inline_size <= 4) {
3273                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3274                }
3275                let inner_offset;
3276                let mut inner_depth = depth.clone();
3277                if inlined {
3278                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3279                    inner_offset = next_offset;
3280                } else {
3281                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3282                    inner_depth.increment()?;
3283                }
3284                let val_ref = self.max_buffer_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
3285                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3286                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3287                {
3288                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3289                }
3290                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3291                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3292                }
3293            }
3294
3295            next_offset += envelope_size;
3296            _next_ordinal_to_read += 1;
3297            if next_offset >= end_offset {
3298                return Ok(());
3299            }
3300
3301            // Decode unknown envelopes for gaps in ordinals.
3302            while _next_ordinal_to_read < 7 {
3303                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3304                _next_ordinal_to_read += 1;
3305                next_offset += envelope_size;
3306            }
3307
3308            let next_out_of_line = decoder.next_out_of_line();
3309            let handles_before = decoder.remaining_handles();
3310            if let Some((inlined, num_bytes, num_handles)) =
3311                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3312            {
3313                let member_inline_size =
3314                    <BufferMemoryConstraints as fidl::encoding::TypeMarker>::inline_size(
3315                        decoder.context,
3316                    );
3317                if inlined != (member_inline_size <= 4) {
3318                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3319                }
3320                let inner_offset;
3321                let mut inner_depth = depth.clone();
3322                if inlined {
3323                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3324                    inner_offset = next_offset;
3325                } else {
3326                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3327                    inner_depth.increment()?;
3328                }
3329                let val_ref = self
3330                    .buffer_memory_constraints
3331                    .get_or_insert_with(|| fidl::new_empty!(BufferMemoryConstraints, D));
3332                fidl::decode!(
3333                    BufferMemoryConstraints,
3334                    D,
3335                    val_ref,
3336                    decoder,
3337                    inner_offset,
3338                    inner_depth
3339                )?;
3340                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3341                {
3342                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3343                }
3344                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3345                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3346                }
3347            }
3348
3349            next_offset += envelope_size;
3350            _next_ordinal_to_read += 1;
3351            if next_offset >= end_offset {
3352                return Ok(());
3353            }
3354
3355            // Decode unknown envelopes for gaps in ordinals.
3356            while _next_ordinal_to_read < 8 {
3357                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3358                _next_ordinal_to_read += 1;
3359                next_offset += envelope_size;
3360            }
3361
3362            let next_out_of_line = decoder.next_out_of_line();
3363            let handles_before = decoder.remaining_handles();
3364            if let Some((inlined, num_bytes, num_handles)) =
3365                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3366            {
3367                let member_inline_size = <fidl::encoding::Vector<ImageFormatConstraints, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3368                if inlined != (member_inline_size <= 4) {
3369                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3370                }
3371                let inner_offset;
3372                let mut inner_depth = depth.clone();
3373                if inlined {
3374                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3375                    inner_offset = next_offset;
3376                } else {
3377                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3378                    inner_depth.increment()?;
3379                }
3380                let val_ref = self.image_format_constraints.get_or_insert_with(
3381                    || fidl::new_empty!(fidl::encoding::Vector<ImageFormatConstraints, 64>, D),
3382                );
3383                fidl::decode!(fidl::encoding::Vector<ImageFormatConstraints, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3384                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3385                {
3386                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3387                }
3388                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3389                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3390                }
3391            }
3392
3393            next_offset += envelope_size;
3394
3395            // Decode the remaining unknown envelopes.
3396            while next_offset < end_offset {
3397                _next_ordinal_to_read += 1;
3398                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3399                next_offset += envelope_size;
3400            }
3401
3402            Ok(())
3403        }
3404    }
3405
3406    impl BufferCollectionTokenDuplicateSyncRequest {
3407        #[inline(always)]
3408        fn max_ordinal_present(&self) -> u64 {
3409            if let Some(_) = self.rights_attenuation_masks {
3410                return 1;
3411            }
3412            0
3413        }
3414    }
3415
3416    impl fidl::encoding::ValueTypeMarker for BufferCollectionTokenDuplicateSyncRequest {
3417        type Borrowed<'a> = &'a Self;
3418        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3419            value
3420        }
3421    }
3422
3423    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncRequest {
3424        type Owned = Self;
3425
3426        #[inline(always)]
3427        fn inline_align(_context: fidl::encoding::Context) -> usize {
3428            8
3429        }
3430
3431        #[inline(always)]
3432        fn inline_size(_context: fidl::encoding::Context) -> usize {
3433            16
3434        }
3435    }
3436
3437    unsafe impl<D: fidl::encoding::ResourceDialect>
3438        fidl::encoding::Encode<BufferCollectionTokenDuplicateSyncRequest, D>
3439        for &BufferCollectionTokenDuplicateSyncRequest
3440    {
3441        unsafe fn encode(
3442            self,
3443            encoder: &mut fidl::encoding::Encoder<'_, D>,
3444            offset: usize,
3445            mut depth: fidl::encoding::Depth,
3446        ) -> fidl::Result<()> {
3447            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncRequest>(offset);
3448            // Vector header
3449            let max_ordinal: u64 = self.max_ordinal_present();
3450            encoder.write_num(max_ordinal, offset);
3451            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3452            // Calling encoder.out_of_line_offset(0) is not allowed.
3453            if max_ordinal == 0 {
3454                return Ok(());
3455            }
3456            depth.increment()?;
3457            let envelope_size = 8;
3458            let bytes_len = max_ordinal as usize * envelope_size;
3459            #[allow(unused_variables)]
3460            let offset = encoder.out_of_line_offset(bytes_len);
3461            let mut _prev_end_offset: usize = 0;
3462            if 1 > max_ordinal {
3463                return Ok(());
3464            }
3465
3466            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3467            // are envelope_size bytes.
3468            let cur_offset: usize = (1 - 1) * envelope_size;
3469
3470            // Zero reserved fields.
3471            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3472
3473            // Safety:
3474            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3475            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3476            //   envelope_size bytes, there is always sufficient room.
3477            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::Rights, 64>, D>(
3478            self.rights_attenuation_masks.as_ref().map(<fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3479            encoder, offset + cur_offset, depth
3480        )?;
3481
3482            _prev_end_offset = cur_offset + envelope_size;
3483
3484            Ok(())
3485        }
3486    }
3487
3488    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3489        for BufferCollectionTokenDuplicateSyncRequest
3490    {
3491        #[inline(always)]
3492        fn new_empty() -> Self {
3493            Self::default()
3494        }
3495
3496        unsafe fn decode(
3497            &mut self,
3498            decoder: &mut fidl::encoding::Decoder<'_, D>,
3499            offset: usize,
3500            mut depth: fidl::encoding::Depth,
3501        ) -> fidl::Result<()> {
3502            decoder.debug_check_bounds::<Self>(offset);
3503            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3504                None => return Err(fidl::Error::NotNullable),
3505                Some(len) => len,
3506            };
3507            // Calling decoder.out_of_line_offset(0) is not allowed.
3508            if len == 0 {
3509                return Ok(());
3510            };
3511            depth.increment()?;
3512            let envelope_size = 8;
3513            let bytes_len = len * envelope_size;
3514            let offset = decoder.out_of_line_offset(bytes_len)?;
3515            // Decode the envelope for each type.
3516            let mut _next_ordinal_to_read = 0;
3517            let mut next_offset = offset;
3518            let end_offset = offset + bytes_len;
3519            _next_ordinal_to_read += 1;
3520            if next_offset >= end_offset {
3521                return Ok(());
3522            }
3523
3524            // Decode unknown envelopes for gaps in ordinals.
3525            while _next_ordinal_to_read < 1 {
3526                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3527                _next_ordinal_to_read += 1;
3528                next_offset += envelope_size;
3529            }
3530
3531            let next_out_of_line = decoder.next_out_of_line();
3532            let handles_before = decoder.remaining_handles();
3533            if let Some((inlined, num_bytes, num_handles)) =
3534                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3535            {
3536                let member_inline_size = <fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3537                if inlined != (member_inline_size <= 4) {
3538                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3539                }
3540                let inner_offset;
3541                let mut inner_depth = depth.clone();
3542                if inlined {
3543                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3544                    inner_offset = next_offset;
3545                } else {
3546                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3547                    inner_depth.increment()?;
3548                }
3549                let val_ref = self.rights_attenuation_masks.get_or_insert_with(
3550                    || fidl::new_empty!(fidl::encoding::Vector<fidl::Rights, 64>, D),
3551                );
3552                fidl::decode!(fidl::encoding::Vector<fidl::Rights, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3553                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3554                {
3555                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3556                }
3557                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3558                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3559                }
3560            }
3561
3562            next_offset += envelope_size;
3563
3564            // Decode the remaining unknown envelopes.
3565            while next_offset < end_offset {
3566                _next_ordinal_to_read += 1;
3567                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3568                next_offset += envelope_size;
3569            }
3570
3571            Ok(())
3572        }
3573    }
3574
3575    impl BufferCollectionTokenGroupCreateChildrenSyncRequest {
3576        #[inline(always)]
3577        fn max_ordinal_present(&self) -> u64 {
3578            if let Some(_) = self.rights_attenuation_masks {
3579                return 1;
3580            }
3581            0
3582        }
3583    }
3584
3585    impl fidl::encoding::ValueTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncRequest {
3586        type Borrowed<'a> = &'a Self;
3587        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3588            value
3589        }
3590    }
3591
3592    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncRequest {
3593        type Owned = Self;
3594
3595        #[inline(always)]
3596        fn inline_align(_context: fidl::encoding::Context) -> usize {
3597            8
3598        }
3599
3600        #[inline(always)]
3601        fn inline_size(_context: fidl::encoding::Context) -> usize {
3602            16
3603        }
3604    }
3605
3606    unsafe impl<D: fidl::encoding::ResourceDialect>
3607        fidl::encoding::Encode<BufferCollectionTokenGroupCreateChildrenSyncRequest, D>
3608        for &BufferCollectionTokenGroupCreateChildrenSyncRequest
3609    {
3610        unsafe fn encode(
3611            self,
3612            encoder: &mut fidl::encoding::Encoder<'_, D>,
3613            offset: usize,
3614            mut depth: fidl::encoding::Depth,
3615        ) -> fidl::Result<()> {
3616            encoder
3617                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(offset);
3618            // Vector header
3619            let max_ordinal: u64 = self.max_ordinal_present();
3620            encoder.write_num(max_ordinal, offset);
3621            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3622            // Calling encoder.out_of_line_offset(0) is not allowed.
3623            if max_ordinal == 0 {
3624                return Ok(());
3625            }
3626            depth.increment()?;
3627            let envelope_size = 8;
3628            let bytes_len = max_ordinal as usize * envelope_size;
3629            #[allow(unused_variables)]
3630            let offset = encoder.out_of_line_offset(bytes_len);
3631            let mut _prev_end_offset: usize = 0;
3632            if 1 > max_ordinal {
3633                return Ok(());
3634            }
3635
3636            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3637            // are envelope_size bytes.
3638            let cur_offset: usize = (1 - 1) * envelope_size;
3639
3640            // Zero reserved fields.
3641            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3642
3643            // Safety:
3644            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3645            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3646            //   envelope_size bytes, there is always sufficient room.
3647            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::Rights, 64>, D>(
3648            self.rights_attenuation_masks.as_ref().map(<fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3649            encoder, offset + cur_offset, depth
3650        )?;
3651
3652            _prev_end_offset = cur_offset + envelope_size;
3653
3654            Ok(())
3655        }
3656    }
3657
3658    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3659        for BufferCollectionTokenGroupCreateChildrenSyncRequest
3660    {
3661        #[inline(always)]
3662        fn new_empty() -> Self {
3663            Self::default()
3664        }
3665
3666        unsafe fn decode(
3667            &mut self,
3668            decoder: &mut fidl::encoding::Decoder<'_, D>,
3669            offset: usize,
3670            mut depth: fidl::encoding::Depth,
3671        ) -> fidl::Result<()> {
3672            decoder.debug_check_bounds::<Self>(offset);
3673            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3674                None => return Err(fidl::Error::NotNullable),
3675                Some(len) => len,
3676            };
3677            // Calling decoder.out_of_line_offset(0) is not allowed.
3678            if len == 0 {
3679                return Ok(());
3680            };
3681            depth.increment()?;
3682            let envelope_size = 8;
3683            let bytes_len = len * envelope_size;
3684            let offset = decoder.out_of_line_offset(bytes_len)?;
3685            // Decode the envelope for each type.
3686            let mut _next_ordinal_to_read = 0;
3687            let mut next_offset = offset;
3688            let end_offset = offset + bytes_len;
3689            _next_ordinal_to_read += 1;
3690            if next_offset >= end_offset {
3691                return Ok(());
3692            }
3693
3694            // Decode unknown envelopes for gaps in ordinals.
3695            while _next_ordinal_to_read < 1 {
3696                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3697                _next_ordinal_to_read += 1;
3698                next_offset += envelope_size;
3699            }
3700
3701            let next_out_of_line = decoder.next_out_of_line();
3702            let handles_before = decoder.remaining_handles();
3703            if let Some((inlined, num_bytes, num_handles)) =
3704                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3705            {
3706                let member_inline_size = <fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3707                if inlined != (member_inline_size <= 4) {
3708                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3709                }
3710                let inner_offset;
3711                let mut inner_depth = depth.clone();
3712                if inlined {
3713                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3714                    inner_offset = next_offset;
3715                } else {
3716                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3717                    inner_depth.increment()?;
3718                }
3719                let val_ref = self.rights_attenuation_masks.get_or_insert_with(
3720                    || fidl::new_empty!(fidl::encoding::Vector<fidl::Rights, 64>, D),
3721                );
3722                fidl::decode!(fidl::encoding::Vector<fidl::Rights, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3723                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3724                {
3725                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3726                }
3727                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3728                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3729                }
3730            }
3731
3732            next_offset += envelope_size;
3733
3734            // Decode the remaining unknown envelopes.
3735            while next_offset < end_offset {
3736                _next_ordinal_to_read += 1;
3737                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3738                next_offset += envelope_size;
3739            }
3740
3741            Ok(())
3742        }
3743    }
3744
3745    impl BufferMemoryConstraints {
3746        #[inline(always)]
3747        fn max_ordinal_present(&self) -> u64 {
3748            if let Some(_) = self.permitted_heaps {
3749                return 8;
3750            }
3751            if let Some(_) = self.inaccessible_domain_supported {
3752                return 7;
3753            }
3754            if let Some(_) = self.ram_domain_supported {
3755                return 6;
3756            }
3757            if let Some(_) = self.cpu_domain_supported {
3758                return 5;
3759            }
3760            if let Some(_) = self.secure_required {
3761                return 4;
3762            }
3763            if let Some(_) = self.physically_contiguous_required {
3764                return 3;
3765            }
3766            if let Some(_) = self.max_size_bytes {
3767                return 2;
3768            }
3769            if let Some(_) = self.min_size_bytes {
3770                return 1;
3771            }
3772            0
3773        }
3774    }
3775
3776    impl fidl::encoding::ValueTypeMarker for BufferMemoryConstraints {
3777        type Borrowed<'a> = &'a Self;
3778        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3779            value
3780        }
3781    }
3782
3783    unsafe impl fidl::encoding::TypeMarker for BufferMemoryConstraints {
3784        type Owned = Self;
3785
3786        #[inline(always)]
3787        fn inline_align(_context: fidl::encoding::Context) -> usize {
3788            8
3789        }
3790
3791        #[inline(always)]
3792        fn inline_size(_context: fidl::encoding::Context) -> usize {
3793            16
3794        }
3795    }
3796
3797    unsafe impl<D: fidl::encoding::ResourceDialect>
3798        fidl::encoding::Encode<BufferMemoryConstraints, D> for &BufferMemoryConstraints
3799    {
3800        unsafe fn encode(
3801            self,
3802            encoder: &mut fidl::encoding::Encoder<'_, D>,
3803            offset: usize,
3804            mut depth: fidl::encoding::Depth,
3805        ) -> fidl::Result<()> {
3806            encoder.debug_check_bounds::<BufferMemoryConstraints>(offset);
3807            // Vector header
3808            let max_ordinal: u64 = self.max_ordinal_present();
3809            encoder.write_num(max_ordinal, offset);
3810            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3811            // Calling encoder.out_of_line_offset(0) is not allowed.
3812            if max_ordinal == 0 {
3813                return Ok(());
3814            }
3815            depth.increment()?;
3816            let envelope_size = 8;
3817            let bytes_len = max_ordinal as usize * envelope_size;
3818            #[allow(unused_variables)]
3819            let offset = encoder.out_of_line_offset(bytes_len);
3820            let mut _prev_end_offset: usize = 0;
3821            if 1 > max_ordinal {
3822                return Ok(());
3823            }
3824
3825            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3826            // are envelope_size bytes.
3827            let cur_offset: usize = (1 - 1) * envelope_size;
3828
3829            // Zero reserved fields.
3830            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3831
3832            // Safety:
3833            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3834            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3835            //   envelope_size bytes, there is always sufficient room.
3836            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3837                self.min_size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3838                encoder,
3839                offset + cur_offset,
3840                depth,
3841            )?;
3842
3843            _prev_end_offset = cur_offset + envelope_size;
3844            if 2 > max_ordinal {
3845                return Ok(());
3846            }
3847
3848            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3849            // are envelope_size bytes.
3850            let cur_offset: usize = (2 - 1) * envelope_size;
3851
3852            // Zero reserved fields.
3853            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3854
3855            // Safety:
3856            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3857            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3858            //   envelope_size bytes, there is always sufficient room.
3859            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3860                self.max_size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3861                encoder,
3862                offset + cur_offset,
3863                depth,
3864            )?;
3865
3866            _prev_end_offset = cur_offset + envelope_size;
3867            if 3 > max_ordinal {
3868                return Ok(());
3869            }
3870
3871            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3872            // are envelope_size bytes.
3873            let cur_offset: usize = (3 - 1) * envelope_size;
3874
3875            // Zero reserved fields.
3876            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3877
3878            // Safety:
3879            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3880            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3881            //   envelope_size bytes, there is always sufficient room.
3882            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3883                self.physically_contiguous_required
3884                    .as_ref()
3885                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3886                encoder,
3887                offset + cur_offset,
3888                depth,
3889            )?;
3890
3891            _prev_end_offset = cur_offset + envelope_size;
3892            if 4 > max_ordinal {
3893                return Ok(());
3894            }
3895
3896            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3897            // are envelope_size bytes.
3898            let cur_offset: usize = (4 - 1) * envelope_size;
3899
3900            // Zero reserved fields.
3901            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3902
3903            // Safety:
3904            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3905            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3906            //   envelope_size bytes, there is always sufficient room.
3907            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3908                self.secure_required
3909                    .as_ref()
3910                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3911                encoder,
3912                offset + cur_offset,
3913                depth,
3914            )?;
3915
3916            _prev_end_offset = cur_offset + envelope_size;
3917            if 5 > max_ordinal {
3918                return Ok(());
3919            }
3920
3921            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3922            // are envelope_size bytes.
3923            let cur_offset: usize = (5 - 1) * envelope_size;
3924
3925            // Zero reserved fields.
3926            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3927
3928            // Safety:
3929            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3930            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3931            //   envelope_size bytes, there is always sufficient room.
3932            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3933                self.cpu_domain_supported
3934                    .as_ref()
3935                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3936                encoder,
3937                offset + cur_offset,
3938                depth,
3939            )?;
3940
3941            _prev_end_offset = cur_offset + envelope_size;
3942            if 6 > max_ordinal {
3943                return Ok(());
3944            }
3945
3946            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3947            // are envelope_size bytes.
3948            let cur_offset: usize = (6 - 1) * envelope_size;
3949
3950            // Zero reserved fields.
3951            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3952
3953            // Safety:
3954            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3955            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3956            //   envelope_size bytes, there is always sufficient room.
3957            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3958                self.ram_domain_supported
3959                    .as_ref()
3960                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3961                encoder,
3962                offset + cur_offset,
3963                depth,
3964            )?;
3965
3966            _prev_end_offset = cur_offset + envelope_size;
3967            if 7 > max_ordinal {
3968                return Ok(());
3969            }
3970
3971            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3972            // are envelope_size bytes.
3973            let cur_offset: usize = (7 - 1) * envelope_size;
3974
3975            // Zero reserved fields.
3976            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3977
3978            // Safety:
3979            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3980            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3981            //   envelope_size bytes, there is always sufficient room.
3982            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3983                self.inaccessible_domain_supported
3984                    .as_ref()
3985                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3986                encoder,
3987                offset + cur_offset,
3988                depth,
3989            )?;
3990
3991            _prev_end_offset = cur_offset + envelope_size;
3992            if 8 > max_ordinal {
3993                return Ok(());
3994            }
3995
3996            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3997            // are envelope_size bytes.
3998            let cur_offset: usize = (8 - 1) * envelope_size;
3999
4000            // Zero reserved fields.
4001            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4002
4003            // Safety:
4004            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4005            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4006            //   envelope_size bytes, there is always sufficient room.
4007            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Heap, 64>, D>(
4008                self.permitted_heaps.as_ref().map(
4009                    <fidl::encoding::Vector<Heap, 64> as fidl::encoding::ValueTypeMarker>::borrow,
4010                ),
4011                encoder,
4012                offset + cur_offset,
4013                depth,
4014            )?;
4015
4016            _prev_end_offset = cur_offset + envelope_size;
4017
4018            Ok(())
4019        }
4020    }
4021
4022    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4023        for BufferMemoryConstraints
4024    {
4025        #[inline(always)]
4026        fn new_empty() -> Self {
4027            Self::default()
4028        }
4029
4030        unsafe fn decode(
4031            &mut self,
4032            decoder: &mut fidl::encoding::Decoder<'_, D>,
4033            offset: usize,
4034            mut depth: fidl::encoding::Depth,
4035        ) -> fidl::Result<()> {
4036            decoder.debug_check_bounds::<Self>(offset);
4037            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4038                None => return Err(fidl::Error::NotNullable),
4039                Some(len) => len,
4040            };
4041            // Calling decoder.out_of_line_offset(0) is not allowed.
4042            if len == 0 {
4043                return Ok(());
4044            };
4045            depth.increment()?;
4046            let envelope_size = 8;
4047            let bytes_len = len * envelope_size;
4048            let offset = decoder.out_of_line_offset(bytes_len)?;
4049            // Decode the envelope for each type.
4050            let mut _next_ordinal_to_read = 0;
4051            let mut next_offset = offset;
4052            let end_offset = offset + bytes_len;
4053            _next_ordinal_to_read += 1;
4054            if next_offset >= end_offset {
4055                return Ok(());
4056            }
4057
4058            // Decode unknown envelopes for gaps in ordinals.
4059            while _next_ordinal_to_read < 1 {
4060                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4061                _next_ordinal_to_read += 1;
4062                next_offset += envelope_size;
4063            }
4064
4065            let next_out_of_line = decoder.next_out_of_line();
4066            let handles_before = decoder.remaining_handles();
4067            if let Some((inlined, num_bytes, num_handles)) =
4068                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4069            {
4070                let member_inline_size =
4071                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4072                if inlined != (member_inline_size <= 4) {
4073                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4074                }
4075                let inner_offset;
4076                let mut inner_depth = depth.clone();
4077                if inlined {
4078                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4079                    inner_offset = next_offset;
4080                } else {
4081                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4082                    inner_depth.increment()?;
4083                }
4084                let val_ref = self.min_size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4085                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4086                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4087                {
4088                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4089                }
4090                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4091                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4092                }
4093            }
4094
4095            next_offset += envelope_size;
4096            _next_ordinal_to_read += 1;
4097            if next_offset >= end_offset {
4098                return Ok(());
4099            }
4100
4101            // Decode unknown envelopes for gaps in ordinals.
4102            while _next_ordinal_to_read < 2 {
4103                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4104                _next_ordinal_to_read += 1;
4105                next_offset += envelope_size;
4106            }
4107
4108            let next_out_of_line = decoder.next_out_of_line();
4109            let handles_before = decoder.remaining_handles();
4110            if let Some((inlined, num_bytes, num_handles)) =
4111                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4112            {
4113                let member_inline_size =
4114                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4115                if inlined != (member_inline_size <= 4) {
4116                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4117                }
4118                let inner_offset;
4119                let mut inner_depth = depth.clone();
4120                if inlined {
4121                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4122                    inner_offset = next_offset;
4123                } else {
4124                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4125                    inner_depth.increment()?;
4126                }
4127                let val_ref = self.max_size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4128                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4129                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4130                {
4131                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4132                }
4133                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4134                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4135                }
4136            }
4137
4138            next_offset += envelope_size;
4139            _next_ordinal_to_read += 1;
4140            if next_offset >= end_offset {
4141                return Ok(());
4142            }
4143
4144            // Decode unknown envelopes for gaps in ordinals.
4145            while _next_ordinal_to_read < 3 {
4146                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4147                _next_ordinal_to_read += 1;
4148                next_offset += envelope_size;
4149            }
4150
4151            let next_out_of_line = decoder.next_out_of_line();
4152            let handles_before = decoder.remaining_handles();
4153            if let Some((inlined, num_bytes, num_handles)) =
4154                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4155            {
4156                let member_inline_size =
4157                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4158                if inlined != (member_inline_size <= 4) {
4159                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4160                }
4161                let inner_offset;
4162                let mut inner_depth = depth.clone();
4163                if inlined {
4164                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4165                    inner_offset = next_offset;
4166                } else {
4167                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4168                    inner_depth.increment()?;
4169                }
4170                let val_ref = self
4171                    .physically_contiguous_required
4172                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
4173                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4174                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4175                {
4176                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4177                }
4178                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4179                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4180                }
4181            }
4182
4183            next_offset += envelope_size;
4184            _next_ordinal_to_read += 1;
4185            if next_offset >= end_offset {
4186                return Ok(());
4187            }
4188
4189            // Decode unknown envelopes for gaps in ordinals.
4190            while _next_ordinal_to_read < 4 {
4191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4192                _next_ordinal_to_read += 1;
4193                next_offset += envelope_size;
4194            }
4195
4196            let next_out_of_line = decoder.next_out_of_line();
4197            let handles_before = decoder.remaining_handles();
4198            if let Some((inlined, num_bytes, num_handles)) =
4199                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4200            {
4201                let member_inline_size =
4202                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4203                if inlined != (member_inline_size <= 4) {
4204                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4205                }
4206                let inner_offset;
4207                let mut inner_depth = depth.clone();
4208                if inlined {
4209                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4210                    inner_offset = next_offset;
4211                } else {
4212                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4213                    inner_depth.increment()?;
4214                }
4215                let val_ref = self.secure_required.get_or_insert_with(|| fidl::new_empty!(bool, D));
4216                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4217                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4218                {
4219                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4220                }
4221                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4222                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4223                }
4224            }
4225
4226            next_offset += envelope_size;
4227            _next_ordinal_to_read += 1;
4228            if next_offset >= end_offset {
4229                return Ok(());
4230            }
4231
4232            // Decode unknown envelopes for gaps in ordinals.
4233            while _next_ordinal_to_read < 5 {
4234                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4235                _next_ordinal_to_read += 1;
4236                next_offset += envelope_size;
4237            }
4238
4239            let next_out_of_line = decoder.next_out_of_line();
4240            let handles_before = decoder.remaining_handles();
4241            if let Some((inlined, num_bytes, num_handles)) =
4242                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4243            {
4244                let member_inline_size =
4245                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4246                if inlined != (member_inline_size <= 4) {
4247                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4248                }
4249                let inner_offset;
4250                let mut inner_depth = depth.clone();
4251                if inlined {
4252                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4253                    inner_offset = next_offset;
4254                } else {
4255                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4256                    inner_depth.increment()?;
4257                }
4258                let val_ref =
4259                    self.cpu_domain_supported.get_or_insert_with(|| fidl::new_empty!(bool, D));
4260                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4261                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4262                {
4263                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4264                }
4265                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4266                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4267                }
4268            }
4269
4270            next_offset += envelope_size;
4271            _next_ordinal_to_read += 1;
4272            if next_offset >= end_offset {
4273                return Ok(());
4274            }
4275
4276            // Decode unknown envelopes for gaps in ordinals.
4277            while _next_ordinal_to_read < 6 {
4278                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4279                _next_ordinal_to_read += 1;
4280                next_offset += envelope_size;
4281            }
4282
4283            let next_out_of_line = decoder.next_out_of_line();
4284            let handles_before = decoder.remaining_handles();
4285            if let Some((inlined, num_bytes, num_handles)) =
4286                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4287            {
4288                let member_inline_size =
4289                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4290                if inlined != (member_inline_size <= 4) {
4291                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4292                }
4293                let inner_offset;
4294                let mut inner_depth = depth.clone();
4295                if inlined {
4296                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4297                    inner_offset = next_offset;
4298                } else {
4299                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4300                    inner_depth.increment()?;
4301                }
4302                let val_ref =
4303                    self.ram_domain_supported.get_or_insert_with(|| fidl::new_empty!(bool, D));
4304                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4305                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4306                {
4307                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4308                }
4309                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4310                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4311                }
4312            }
4313
4314            next_offset += envelope_size;
4315            _next_ordinal_to_read += 1;
4316            if next_offset >= end_offset {
4317                return Ok(());
4318            }
4319
4320            // Decode unknown envelopes for gaps in ordinals.
4321            while _next_ordinal_to_read < 7 {
4322                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4323                _next_ordinal_to_read += 1;
4324                next_offset += envelope_size;
4325            }
4326
4327            let next_out_of_line = decoder.next_out_of_line();
4328            let handles_before = decoder.remaining_handles();
4329            if let Some((inlined, num_bytes, num_handles)) =
4330                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4331            {
4332                let member_inline_size =
4333                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4334                if inlined != (member_inline_size <= 4) {
4335                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4336                }
4337                let inner_offset;
4338                let mut inner_depth = depth.clone();
4339                if inlined {
4340                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4341                    inner_offset = next_offset;
4342                } else {
4343                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4344                    inner_depth.increment()?;
4345                }
4346                let val_ref = self
4347                    .inaccessible_domain_supported
4348                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
4349                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4350                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4351                {
4352                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4353                }
4354                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4355                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4356                }
4357            }
4358
4359            next_offset += envelope_size;
4360            _next_ordinal_to_read += 1;
4361            if next_offset >= end_offset {
4362                return Ok(());
4363            }
4364
4365            // Decode unknown envelopes for gaps in ordinals.
4366            while _next_ordinal_to_read < 8 {
4367                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4368                _next_ordinal_to_read += 1;
4369                next_offset += envelope_size;
4370            }
4371
4372            let next_out_of_line = decoder.next_out_of_line();
4373            let handles_before = decoder.remaining_handles();
4374            if let Some((inlined, num_bytes, num_handles)) =
4375                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4376            {
4377                let member_inline_size =
4378                    <fidl::encoding::Vector<Heap, 64> as fidl::encoding::TypeMarker>::inline_size(
4379                        decoder.context,
4380                    );
4381                if inlined != (member_inline_size <= 4) {
4382                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4383                }
4384                let inner_offset;
4385                let mut inner_depth = depth.clone();
4386                if inlined {
4387                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4388                    inner_offset = next_offset;
4389                } else {
4390                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4391                    inner_depth.increment()?;
4392                }
4393                let val_ref = self
4394                    .permitted_heaps
4395                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Heap, 64>, D));
4396                fidl::decode!(fidl::encoding::Vector<Heap, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
4397                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4398                {
4399                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4400                }
4401                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4402                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4403                }
4404            }
4405
4406            next_offset += envelope_size;
4407
4408            // Decode the remaining unknown envelopes.
4409            while next_offset < end_offset {
4410                _next_ordinal_to_read += 1;
4411                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4412                next_offset += envelope_size;
4413            }
4414
4415            Ok(())
4416        }
4417    }
4418
4419    impl BufferMemorySettings {
4420        #[inline(always)]
4421        fn max_ordinal_present(&self) -> u64 {
4422            if let Some(_) = self.raw_vmo_size {
4423                return 6;
4424            }
4425            if let Some(_) = self.heap {
4426                return 5;
4427            }
4428            if let Some(_) = self.coherency_domain {
4429                return 4;
4430            }
4431            if let Some(_) = self.is_secure {
4432                return 3;
4433            }
4434            if let Some(_) = self.is_physically_contiguous {
4435                return 2;
4436            }
4437            if let Some(_) = self.size_bytes {
4438                return 1;
4439            }
4440            0
4441        }
4442    }
4443
4444    impl fidl::encoding::ValueTypeMarker for BufferMemorySettings {
4445        type Borrowed<'a> = &'a Self;
4446        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4447            value
4448        }
4449    }
4450
4451    unsafe impl fidl::encoding::TypeMarker for BufferMemorySettings {
4452        type Owned = Self;
4453
4454        #[inline(always)]
4455        fn inline_align(_context: fidl::encoding::Context) -> usize {
4456            8
4457        }
4458
4459        #[inline(always)]
4460        fn inline_size(_context: fidl::encoding::Context) -> usize {
4461            16
4462        }
4463    }
4464
4465    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BufferMemorySettings, D>
4466        for &BufferMemorySettings
4467    {
4468        unsafe fn encode(
4469            self,
4470            encoder: &mut fidl::encoding::Encoder<'_, D>,
4471            offset: usize,
4472            mut depth: fidl::encoding::Depth,
4473        ) -> fidl::Result<()> {
4474            encoder.debug_check_bounds::<BufferMemorySettings>(offset);
4475            // Vector header
4476            let max_ordinal: u64 = self.max_ordinal_present();
4477            encoder.write_num(max_ordinal, offset);
4478            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4479            // Calling encoder.out_of_line_offset(0) is not allowed.
4480            if max_ordinal == 0 {
4481                return Ok(());
4482            }
4483            depth.increment()?;
4484            let envelope_size = 8;
4485            let bytes_len = max_ordinal as usize * envelope_size;
4486            #[allow(unused_variables)]
4487            let offset = encoder.out_of_line_offset(bytes_len);
4488            let mut _prev_end_offset: usize = 0;
4489            if 1 > max_ordinal {
4490                return Ok(());
4491            }
4492
4493            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4494            // are envelope_size bytes.
4495            let cur_offset: usize = (1 - 1) * envelope_size;
4496
4497            // Zero reserved fields.
4498            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4499
4500            // Safety:
4501            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4502            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4503            //   envelope_size bytes, there is always sufficient room.
4504            fidl::encoding::encode_in_envelope_optional::<u64, D>(
4505                self.size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4506                encoder,
4507                offset + cur_offset,
4508                depth,
4509            )?;
4510
4511            _prev_end_offset = cur_offset + envelope_size;
4512            if 2 > max_ordinal {
4513                return Ok(());
4514            }
4515
4516            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4517            // are envelope_size bytes.
4518            let cur_offset: usize = (2 - 1) * envelope_size;
4519
4520            // Zero reserved fields.
4521            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4522
4523            // Safety:
4524            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4525            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4526            //   envelope_size bytes, there is always sufficient room.
4527            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4528                self.is_physically_contiguous
4529                    .as_ref()
4530                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4531                encoder,
4532                offset + cur_offset,
4533                depth,
4534            )?;
4535
4536            _prev_end_offset = cur_offset + envelope_size;
4537            if 3 > max_ordinal {
4538                return Ok(());
4539            }
4540
4541            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4542            // are envelope_size bytes.
4543            let cur_offset: usize = (3 - 1) * envelope_size;
4544
4545            // Zero reserved fields.
4546            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4547
4548            // Safety:
4549            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4550            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4551            //   envelope_size bytes, there is always sufficient room.
4552            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4553                self.is_secure.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4554                encoder,
4555                offset + cur_offset,
4556                depth,
4557            )?;
4558
4559            _prev_end_offset = cur_offset + envelope_size;
4560            if 4 > max_ordinal {
4561                return Ok(());
4562            }
4563
4564            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4565            // are envelope_size bytes.
4566            let cur_offset: usize = (4 - 1) * envelope_size;
4567
4568            // Zero reserved fields.
4569            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4570
4571            // Safety:
4572            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4573            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4574            //   envelope_size bytes, there is always sufficient room.
4575            fidl::encoding::encode_in_envelope_optional::<CoherencyDomain, D>(
4576                self.coherency_domain
4577                    .as_ref()
4578                    .map(<CoherencyDomain as fidl::encoding::ValueTypeMarker>::borrow),
4579                encoder,
4580                offset + cur_offset,
4581                depth,
4582            )?;
4583
4584            _prev_end_offset = cur_offset + envelope_size;
4585            if 5 > max_ordinal {
4586                return Ok(());
4587            }
4588
4589            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4590            // are envelope_size bytes.
4591            let cur_offset: usize = (5 - 1) * envelope_size;
4592
4593            // Zero reserved fields.
4594            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4595
4596            // Safety:
4597            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4598            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4599            //   envelope_size bytes, there is always sufficient room.
4600            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
4601                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
4602                encoder,
4603                offset + cur_offset,
4604                depth,
4605            )?;
4606
4607            _prev_end_offset = cur_offset + envelope_size;
4608            if 6 > max_ordinal {
4609                return Ok(());
4610            }
4611
4612            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4613            // are envelope_size bytes.
4614            let cur_offset: usize = (6 - 1) * envelope_size;
4615
4616            // Zero reserved fields.
4617            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4618
4619            // Safety:
4620            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4621            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4622            //   envelope_size bytes, there is always sufficient room.
4623            fidl::encoding::encode_in_envelope_optional::<u64, D>(
4624                self.raw_vmo_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4625                encoder,
4626                offset + cur_offset,
4627                depth,
4628            )?;
4629
4630            _prev_end_offset = cur_offset + envelope_size;
4631
4632            Ok(())
4633        }
4634    }
4635
4636    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferMemorySettings {
4637        #[inline(always)]
4638        fn new_empty() -> Self {
4639            Self::default()
4640        }
4641
4642        unsafe fn decode(
4643            &mut self,
4644            decoder: &mut fidl::encoding::Decoder<'_, D>,
4645            offset: usize,
4646            mut depth: fidl::encoding::Depth,
4647        ) -> fidl::Result<()> {
4648            decoder.debug_check_bounds::<Self>(offset);
4649            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4650                None => return Err(fidl::Error::NotNullable),
4651                Some(len) => len,
4652            };
4653            // Calling decoder.out_of_line_offset(0) is not allowed.
4654            if len == 0 {
4655                return Ok(());
4656            };
4657            depth.increment()?;
4658            let envelope_size = 8;
4659            let bytes_len = len * envelope_size;
4660            let offset = decoder.out_of_line_offset(bytes_len)?;
4661            // Decode the envelope for each type.
4662            let mut _next_ordinal_to_read = 0;
4663            let mut next_offset = offset;
4664            let end_offset = offset + bytes_len;
4665            _next_ordinal_to_read += 1;
4666            if next_offset >= end_offset {
4667                return Ok(());
4668            }
4669
4670            // Decode unknown envelopes for gaps in ordinals.
4671            while _next_ordinal_to_read < 1 {
4672                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4673                _next_ordinal_to_read += 1;
4674                next_offset += envelope_size;
4675            }
4676
4677            let next_out_of_line = decoder.next_out_of_line();
4678            let handles_before = decoder.remaining_handles();
4679            if let Some((inlined, num_bytes, num_handles)) =
4680                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4681            {
4682                let member_inline_size =
4683                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4684                if inlined != (member_inline_size <= 4) {
4685                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4686                }
4687                let inner_offset;
4688                let mut inner_depth = depth.clone();
4689                if inlined {
4690                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4691                    inner_offset = next_offset;
4692                } else {
4693                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4694                    inner_depth.increment()?;
4695                }
4696                let val_ref = self.size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4697                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4698                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4699                {
4700                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4701                }
4702                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4703                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4704                }
4705            }
4706
4707            next_offset += envelope_size;
4708            _next_ordinal_to_read += 1;
4709            if next_offset >= end_offset {
4710                return Ok(());
4711            }
4712
4713            // Decode unknown envelopes for gaps in ordinals.
4714            while _next_ordinal_to_read < 2 {
4715                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4716                _next_ordinal_to_read += 1;
4717                next_offset += envelope_size;
4718            }
4719
4720            let next_out_of_line = decoder.next_out_of_line();
4721            let handles_before = decoder.remaining_handles();
4722            if let Some((inlined, num_bytes, num_handles)) =
4723                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4724            {
4725                let member_inline_size =
4726                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4727                if inlined != (member_inline_size <= 4) {
4728                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4729                }
4730                let inner_offset;
4731                let mut inner_depth = depth.clone();
4732                if inlined {
4733                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4734                    inner_offset = next_offset;
4735                } else {
4736                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4737                    inner_depth.increment()?;
4738                }
4739                let val_ref =
4740                    self.is_physically_contiguous.get_or_insert_with(|| fidl::new_empty!(bool, D));
4741                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4742                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4743                {
4744                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4745                }
4746                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4747                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4748                }
4749            }
4750
4751            next_offset += envelope_size;
4752            _next_ordinal_to_read += 1;
4753            if next_offset >= end_offset {
4754                return Ok(());
4755            }
4756
4757            // Decode unknown envelopes for gaps in ordinals.
4758            while _next_ordinal_to_read < 3 {
4759                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4760                _next_ordinal_to_read += 1;
4761                next_offset += envelope_size;
4762            }
4763
4764            let next_out_of_line = decoder.next_out_of_line();
4765            let handles_before = decoder.remaining_handles();
4766            if let Some((inlined, num_bytes, num_handles)) =
4767                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4768            {
4769                let member_inline_size =
4770                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4771                if inlined != (member_inline_size <= 4) {
4772                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4773                }
4774                let inner_offset;
4775                let mut inner_depth = depth.clone();
4776                if inlined {
4777                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4778                    inner_offset = next_offset;
4779                } else {
4780                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4781                    inner_depth.increment()?;
4782                }
4783                let val_ref = self.is_secure.get_or_insert_with(|| fidl::new_empty!(bool, D));
4784                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4785                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4786                {
4787                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4788                }
4789                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4790                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4791                }
4792            }
4793
4794            next_offset += envelope_size;
4795            _next_ordinal_to_read += 1;
4796            if next_offset >= end_offset {
4797                return Ok(());
4798            }
4799
4800            // Decode unknown envelopes for gaps in ordinals.
4801            while _next_ordinal_to_read < 4 {
4802                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4803                _next_ordinal_to_read += 1;
4804                next_offset += envelope_size;
4805            }
4806
4807            let next_out_of_line = decoder.next_out_of_line();
4808            let handles_before = decoder.remaining_handles();
4809            if let Some((inlined, num_bytes, num_handles)) =
4810                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4811            {
4812                let member_inline_size =
4813                    <CoherencyDomain as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4814                if inlined != (member_inline_size <= 4) {
4815                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4816                }
4817                let inner_offset;
4818                let mut inner_depth = depth.clone();
4819                if inlined {
4820                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4821                    inner_offset = next_offset;
4822                } else {
4823                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4824                    inner_depth.increment()?;
4825                }
4826                let val_ref = self
4827                    .coherency_domain
4828                    .get_or_insert_with(|| fidl::new_empty!(CoherencyDomain, D));
4829                fidl::decode!(CoherencyDomain, D, val_ref, decoder, inner_offset, inner_depth)?;
4830                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4831                {
4832                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4833                }
4834                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4835                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4836                }
4837            }
4838
4839            next_offset += envelope_size;
4840            _next_ordinal_to_read += 1;
4841            if next_offset >= end_offset {
4842                return Ok(());
4843            }
4844
4845            // Decode unknown envelopes for gaps in ordinals.
4846            while _next_ordinal_to_read < 5 {
4847                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4848                _next_ordinal_to_read += 1;
4849                next_offset += envelope_size;
4850            }
4851
4852            let next_out_of_line = decoder.next_out_of_line();
4853            let handles_before = decoder.remaining_handles();
4854            if let Some((inlined, num_bytes, num_handles)) =
4855                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4856            {
4857                let member_inline_size =
4858                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4859                if inlined != (member_inline_size <= 4) {
4860                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4861                }
4862                let inner_offset;
4863                let mut inner_depth = depth.clone();
4864                if inlined {
4865                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4866                    inner_offset = next_offset;
4867                } else {
4868                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4869                    inner_depth.increment()?;
4870                }
4871                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
4872                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
4873                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4874                {
4875                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4876                }
4877                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4878                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4879                }
4880            }
4881
4882            next_offset += envelope_size;
4883            _next_ordinal_to_read += 1;
4884            if next_offset >= end_offset {
4885                return Ok(());
4886            }
4887
4888            // Decode unknown envelopes for gaps in ordinals.
4889            while _next_ordinal_to_read < 6 {
4890                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4891                _next_ordinal_to_read += 1;
4892                next_offset += envelope_size;
4893            }
4894
4895            let next_out_of_line = decoder.next_out_of_line();
4896            let handles_before = decoder.remaining_handles();
4897            if let Some((inlined, num_bytes, num_handles)) =
4898                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4899            {
4900                let member_inline_size =
4901                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4902                if inlined != (member_inline_size <= 4) {
4903                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4904                }
4905                let inner_offset;
4906                let mut inner_depth = depth.clone();
4907                if inlined {
4908                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4909                    inner_offset = next_offset;
4910                } else {
4911                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4912                    inner_depth.increment()?;
4913                }
4914                let val_ref = self.raw_vmo_size.get_or_insert_with(|| fidl::new_empty!(u64, D));
4915                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4916                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4917                {
4918                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4919                }
4920                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4921                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4922                }
4923            }
4924
4925            next_offset += envelope_size;
4926
4927            // Decode the remaining unknown envelopes.
4928            while next_offset < end_offset {
4929                _next_ordinal_to_read += 1;
4930                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4931                next_offset += envelope_size;
4932            }
4933
4934            Ok(())
4935        }
4936    }
4937
4938    impl BufferUsage {
4939        #[inline(always)]
4940        fn max_ordinal_present(&self) -> u64 {
4941            if let Some(_) = self.video {
4942                return 5;
4943            }
4944            if let Some(_) = self.display {
4945                return 4;
4946            }
4947            if let Some(_) = self.vulkan {
4948                return 3;
4949            }
4950            if let Some(_) = self.cpu {
4951                return 2;
4952            }
4953            if let Some(_) = self.none {
4954                return 1;
4955            }
4956            0
4957        }
4958    }
4959
4960    impl fidl::encoding::ValueTypeMarker for BufferUsage {
4961        type Borrowed<'a> = &'a Self;
4962        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4963            value
4964        }
4965    }
4966
4967    unsafe impl fidl::encoding::TypeMarker for BufferUsage {
4968        type Owned = Self;
4969
4970        #[inline(always)]
4971        fn inline_align(_context: fidl::encoding::Context) -> usize {
4972            8
4973        }
4974
4975        #[inline(always)]
4976        fn inline_size(_context: fidl::encoding::Context) -> usize {
4977            16
4978        }
4979    }
4980
4981    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BufferUsage, D>
4982        for &BufferUsage
4983    {
4984        unsafe fn encode(
4985            self,
4986            encoder: &mut fidl::encoding::Encoder<'_, D>,
4987            offset: usize,
4988            mut depth: fidl::encoding::Depth,
4989        ) -> fidl::Result<()> {
4990            encoder.debug_check_bounds::<BufferUsage>(offset);
4991            // Vector header
4992            let max_ordinal: u64 = self.max_ordinal_present();
4993            encoder.write_num(max_ordinal, offset);
4994            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4995            // Calling encoder.out_of_line_offset(0) is not allowed.
4996            if max_ordinal == 0 {
4997                return Ok(());
4998            }
4999            depth.increment()?;
5000            let envelope_size = 8;
5001            let bytes_len = max_ordinal as usize * envelope_size;
5002            #[allow(unused_variables)]
5003            let offset = encoder.out_of_line_offset(bytes_len);
5004            let mut _prev_end_offset: usize = 0;
5005            if 1 > max_ordinal {
5006                return Ok(());
5007            }
5008
5009            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5010            // are envelope_size bytes.
5011            let cur_offset: usize = (1 - 1) * envelope_size;
5012
5013            // Zero reserved fields.
5014            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5015
5016            // Safety:
5017            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5018            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5019            //   envelope_size bytes, there is always sufficient room.
5020            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5021                self.none.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5022                encoder,
5023                offset + cur_offset,
5024                depth,
5025            )?;
5026
5027            _prev_end_offset = cur_offset + envelope_size;
5028            if 2 > max_ordinal {
5029                return Ok(());
5030            }
5031
5032            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5033            // are envelope_size bytes.
5034            let cur_offset: usize = (2 - 1) * envelope_size;
5035
5036            // Zero reserved fields.
5037            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5038
5039            // Safety:
5040            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5041            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5042            //   envelope_size bytes, there is always sufficient room.
5043            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5044                self.cpu.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5045                encoder,
5046                offset + cur_offset,
5047                depth,
5048            )?;
5049
5050            _prev_end_offset = cur_offset + envelope_size;
5051            if 3 > max_ordinal {
5052                return Ok(());
5053            }
5054
5055            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5056            // are envelope_size bytes.
5057            let cur_offset: usize = (3 - 1) * envelope_size;
5058
5059            // Zero reserved fields.
5060            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5061
5062            // Safety:
5063            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5064            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5065            //   envelope_size bytes, there is always sufficient room.
5066            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5067                self.vulkan.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5068                encoder,
5069                offset + cur_offset,
5070                depth,
5071            )?;
5072
5073            _prev_end_offset = cur_offset + envelope_size;
5074            if 4 > max_ordinal {
5075                return Ok(());
5076            }
5077
5078            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5079            // are envelope_size bytes.
5080            let cur_offset: usize = (4 - 1) * envelope_size;
5081
5082            // Zero reserved fields.
5083            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5084
5085            // Safety:
5086            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5087            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5088            //   envelope_size bytes, there is always sufficient room.
5089            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5090                self.display.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5091                encoder,
5092                offset + cur_offset,
5093                depth,
5094            )?;
5095
5096            _prev_end_offset = cur_offset + envelope_size;
5097            if 5 > max_ordinal {
5098                return Ok(());
5099            }
5100
5101            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5102            // are envelope_size bytes.
5103            let cur_offset: usize = (5 - 1) * envelope_size;
5104
5105            // Zero reserved fields.
5106            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5107
5108            // Safety:
5109            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5110            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5111            //   envelope_size bytes, there is always sufficient room.
5112            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5113                self.video.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5114                encoder,
5115                offset + cur_offset,
5116                depth,
5117            )?;
5118
5119            _prev_end_offset = cur_offset + envelope_size;
5120
5121            Ok(())
5122        }
5123    }
5124
5125    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferUsage {
5126        #[inline(always)]
5127        fn new_empty() -> Self {
5128            Self::default()
5129        }
5130
5131        unsafe fn decode(
5132            &mut self,
5133            decoder: &mut fidl::encoding::Decoder<'_, D>,
5134            offset: usize,
5135            mut depth: fidl::encoding::Depth,
5136        ) -> fidl::Result<()> {
5137            decoder.debug_check_bounds::<Self>(offset);
5138            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5139                None => return Err(fidl::Error::NotNullable),
5140                Some(len) => len,
5141            };
5142            // Calling decoder.out_of_line_offset(0) is not allowed.
5143            if len == 0 {
5144                return Ok(());
5145            };
5146            depth.increment()?;
5147            let envelope_size = 8;
5148            let bytes_len = len * envelope_size;
5149            let offset = decoder.out_of_line_offset(bytes_len)?;
5150            // Decode the envelope for each type.
5151            let mut _next_ordinal_to_read = 0;
5152            let mut next_offset = offset;
5153            let end_offset = offset + bytes_len;
5154            _next_ordinal_to_read += 1;
5155            if next_offset >= end_offset {
5156                return Ok(());
5157            }
5158
5159            // Decode unknown envelopes for gaps in ordinals.
5160            while _next_ordinal_to_read < 1 {
5161                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5162                _next_ordinal_to_read += 1;
5163                next_offset += envelope_size;
5164            }
5165
5166            let next_out_of_line = decoder.next_out_of_line();
5167            let handles_before = decoder.remaining_handles();
5168            if let Some((inlined, num_bytes, num_handles)) =
5169                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5170            {
5171                let member_inline_size =
5172                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5173                if inlined != (member_inline_size <= 4) {
5174                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5175                }
5176                let inner_offset;
5177                let mut inner_depth = depth.clone();
5178                if inlined {
5179                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5180                    inner_offset = next_offset;
5181                } else {
5182                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5183                    inner_depth.increment()?;
5184                }
5185                let val_ref = self.none.get_or_insert_with(|| fidl::new_empty!(u32, D));
5186                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5187                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5188                {
5189                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5190                }
5191                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5192                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5193                }
5194            }
5195
5196            next_offset += envelope_size;
5197            _next_ordinal_to_read += 1;
5198            if next_offset >= end_offset {
5199                return Ok(());
5200            }
5201
5202            // Decode unknown envelopes for gaps in ordinals.
5203            while _next_ordinal_to_read < 2 {
5204                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5205                _next_ordinal_to_read += 1;
5206                next_offset += envelope_size;
5207            }
5208
5209            let next_out_of_line = decoder.next_out_of_line();
5210            let handles_before = decoder.remaining_handles();
5211            if let Some((inlined, num_bytes, num_handles)) =
5212                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5213            {
5214                let member_inline_size =
5215                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5216                if inlined != (member_inline_size <= 4) {
5217                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5218                }
5219                let inner_offset;
5220                let mut inner_depth = depth.clone();
5221                if inlined {
5222                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5223                    inner_offset = next_offset;
5224                } else {
5225                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5226                    inner_depth.increment()?;
5227                }
5228                let val_ref = self.cpu.get_or_insert_with(|| fidl::new_empty!(u32, D));
5229                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5230                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5231                {
5232                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5233                }
5234                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5235                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5236                }
5237            }
5238
5239            next_offset += envelope_size;
5240            _next_ordinal_to_read += 1;
5241            if next_offset >= end_offset {
5242                return Ok(());
5243            }
5244
5245            // Decode unknown envelopes for gaps in ordinals.
5246            while _next_ordinal_to_read < 3 {
5247                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5248                _next_ordinal_to_read += 1;
5249                next_offset += envelope_size;
5250            }
5251
5252            let next_out_of_line = decoder.next_out_of_line();
5253            let handles_before = decoder.remaining_handles();
5254            if let Some((inlined, num_bytes, num_handles)) =
5255                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5256            {
5257                let member_inline_size =
5258                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5259                if inlined != (member_inline_size <= 4) {
5260                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5261                }
5262                let inner_offset;
5263                let mut inner_depth = depth.clone();
5264                if inlined {
5265                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5266                    inner_offset = next_offset;
5267                } else {
5268                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5269                    inner_depth.increment()?;
5270                }
5271                let val_ref = self.vulkan.get_or_insert_with(|| fidl::new_empty!(u32, D));
5272                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5273                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5274                {
5275                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5276                }
5277                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5278                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5279                }
5280            }
5281
5282            next_offset += envelope_size;
5283            _next_ordinal_to_read += 1;
5284            if next_offset >= end_offset {
5285                return Ok(());
5286            }
5287
5288            // Decode unknown envelopes for gaps in ordinals.
5289            while _next_ordinal_to_read < 4 {
5290                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5291                _next_ordinal_to_read += 1;
5292                next_offset += envelope_size;
5293            }
5294
5295            let next_out_of_line = decoder.next_out_of_line();
5296            let handles_before = decoder.remaining_handles();
5297            if let Some((inlined, num_bytes, num_handles)) =
5298                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5299            {
5300                let member_inline_size =
5301                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5302                if inlined != (member_inline_size <= 4) {
5303                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5304                }
5305                let inner_offset;
5306                let mut inner_depth = depth.clone();
5307                if inlined {
5308                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5309                    inner_offset = next_offset;
5310                } else {
5311                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5312                    inner_depth.increment()?;
5313                }
5314                let val_ref = self.display.get_or_insert_with(|| fidl::new_empty!(u32, D));
5315                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5316                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5317                {
5318                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5319                }
5320                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5321                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5322                }
5323            }
5324
5325            next_offset += envelope_size;
5326            _next_ordinal_to_read += 1;
5327            if next_offset >= end_offset {
5328                return Ok(());
5329            }
5330
5331            // Decode unknown envelopes for gaps in ordinals.
5332            while _next_ordinal_to_read < 5 {
5333                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5334                _next_ordinal_to_read += 1;
5335                next_offset += envelope_size;
5336            }
5337
5338            let next_out_of_line = decoder.next_out_of_line();
5339            let handles_before = decoder.remaining_handles();
5340            if let Some((inlined, num_bytes, num_handles)) =
5341                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5342            {
5343                let member_inline_size =
5344                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5345                if inlined != (member_inline_size <= 4) {
5346                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5347                }
5348                let inner_offset;
5349                let mut inner_depth = depth.clone();
5350                if inlined {
5351                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5352                    inner_offset = next_offset;
5353                } else {
5354                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5355                    inner_depth.increment()?;
5356                }
5357                let val_ref = self.video.get_or_insert_with(|| fidl::new_empty!(u32, D));
5358                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5359                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5360                {
5361                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5362                }
5363                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5364                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5365                }
5366            }
5367
5368            next_offset += envelope_size;
5369
5370            // Decode the remaining unknown envelopes.
5371            while next_offset < end_offset {
5372                _next_ordinal_to_read += 1;
5373                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5374                next_offset += envelope_size;
5375            }
5376
5377            Ok(())
5378        }
5379    }
5380
5381    impl Config {
5382        #[inline(always)]
5383        fn max_ordinal_present(&self) -> u64 {
5384            if let Some(_) = self.format_costs {
5385                return 1;
5386            }
5387            0
5388        }
5389    }
5390
5391    impl fidl::encoding::ValueTypeMarker for Config {
5392        type Borrowed<'a> = &'a Self;
5393        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5394            value
5395        }
5396    }
5397
5398    unsafe impl fidl::encoding::TypeMarker for Config {
5399        type Owned = Self;
5400
5401        #[inline(always)]
5402        fn inline_align(_context: fidl::encoding::Context) -> usize {
5403            8
5404        }
5405
5406        #[inline(always)]
5407        fn inline_size(_context: fidl::encoding::Context) -> usize {
5408            16
5409        }
5410    }
5411
5412    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
5413        unsafe fn encode(
5414            self,
5415            encoder: &mut fidl::encoding::Encoder<'_, D>,
5416            offset: usize,
5417            mut depth: fidl::encoding::Depth,
5418        ) -> fidl::Result<()> {
5419            encoder.debug_check_bounds::<Config>(offset);
5420            // Vector header
5421            let max_ordinal: u64 = self.max_ordinal_present();
5422            encoder.write_num(max_ordinal, offset);
5423            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5424            // Calling encoder.out_of_line_offset(0) is not allowed.
5425            if max_ordinal == 0 {
5426                return Ok(());
5427            }
5428            depth.increment()?;
5429            let envelope_size = 8;
5430            let bytes_len = max_ordinal as usize * envelope_size;
5431            #[allow(unused_variables)]
5432            let offset = encoder.out_of_line_offset(bytes_len);
5433            let mut _prev_end_offset: usize = 0;
5434            if 1 > max_ordinal {
5435                return Ok(());
5436            }
5437
5438            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5439            // are envelope_size bytes.
5440            let cur_offset: usize = (1 - 1) * envelope_size;
5441
5442            // Zero reserved fields.
5443            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5444
5445            // Safety:
5446            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5447            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5448            //   envelope_size bytes, there is always sufficient room.
5449            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<FormatCostEntry>, D>(
5450            self.format_costs.as_ref().map(<fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::ValueTypeMarker>::borrow),
5451            encoder, offset + cur_offset, depth
5452        )?;
5453
5454            _prev_end_offset = cur_offset + envelope_size;
5455
5456            Ok(())
5457        }
5458    }
5459
5460    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
5461        #[inline(always)]
5462        fn new_empty() -> Self {
5463            Self::default()
5464        }
5465
5466        unsafe fn decode(
5467            &mut self,
5468            decoder: &mut fidl::encoding::Decoder<'_, D>,
5469            offset: usize,
5470            mut depth: fidl::encoding::Depth,
5471        ) -> fidl::Result<()> {
5472            decoder.debug_check_bounds::<Self>(offset);
5473            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5474                None => return Err(fidl::Error::NotNullable),
5475                Some(len) => len,
5476            };
5477            // Calling decoder.out_of_line_offset(0) is not allowed.
5478            if len == 0 {
5479                return Ok(());
5480            };
5481            depth.increment()?;
5482            let envelope_size = 8;
5483            let bytes_len = len * envelope_size;
5484            let offset = decoder.out_of_line_offset(bytes_len)?;
5485            // Decode the envelope for each type.
5486            let mut _next_ordinal_to_read = 0;
5487            let mut next_offset = offset;
5488            let end_offset = offset + bytes_len;
5489            _next_ordinal_to_read += 1;
5490            if next_offset >= end_offset {
5491                return Ok(());
5492            }
5493
5494            // Decode unknown envelopes for gaps in ordinals.
5495            while _next_ordinal_to_read < 1 {
5496                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5497                _next_ordinal_to_read += 1;
5498                next_offset += envelope_size;
5499            }
5500
5501            let next_out_of_line = decoder.next_out_of_line();
5502            let handles_before = decoder.remaining_handles();
5503            if let Some((inlined, num_bytes, num_handles)) =
5504                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5505            {
5506                let member_inline_size = <fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5507                if inlined != (member_inline_size <= 4) {
5508                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5509                }
5510                let inner_offset;
5511                let mut inner_depth = depth.clone();
5512                if inlined {
5513                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5514                    inner_offset = next_offset;
5515                } else {
5516                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5517                    inner_depth.increment()?;
5518                }
5519                let val_ref = self.format_costs.get_or_insert_with(|| {
5520                    fidl::new_empty!(fidl::encoding::UnboundedVector<FormatCostEntry>, D)
5521                });
5522                fidl::decode!(
5523                    fidl::encoding::UnboundedVector<FormatCostEntry>,
5524                    D,
5525                    val_ref,
5526                    decoder,
5527                    inner_offset,
5528                    inner_depth
5529                )?;
5530                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5531                {
5532                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5533                }
5534                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5535                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5536                }
5537            }
5538
5539            next_offset += envelope_size;
5540
5541            // Decode the remaining unknown envelopes.
5542            while next_offset < end_offset {
5543                _next_ordinal_to_read += 1;
5544                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5545                next_offset += envelope_size;
5546            }
5547
5548            Ok(())
5549        }
5550    }
5551
5552    impl DynamicSecureHeap {
5553        #[inline(always)]
5554        fn max_ordinal_present(&self) -> u64 {
5555            if let Some(_) = self.heap {
5556                return 1;
5557            }
5558            0
5559        }
5560    }
5561
5562    impl fidl::encoding::ValueTypeMarker for DynamicSecureHeap {
5563        type Borrowed<'a> = &'a Self;
5564        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5565            value
5566        }
5567    }
5568
5569    unsafe impl fidl::encoding::TypeMarker for DynamicSecureHeap {
5570        type Owned = Self;
5571
5572        #[inline(always)]
5573        fn inline_align(_context: fidl::encoding::Context) -> usize {
5574            8
5575        }
5576
5577        #[inline(always)]
5578        fn inline_size(_context: fidl::encoding::Context) -> usize {
5579            16
5580        }
5581    }
5582
5583    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DynamicSecureHeap, D>
5584        for &DynamicSecureHeap
5585    {
5586        unsafe fn encode(
5587            self,
5588            encoder: &mut fidl::encoding::Encoder<'_, D>,
5589            offset: usize,
5590            mut depth: fidl::encoding::Depth,
5591        ) -> fidl::Result<()> {
5592            encoder.debug_check_bounds::<DynamicSecureHeap>(offset);
5593            // Vector header
5594            let max_ordinal: u64 = self.max_ordinal_present();
5595            encoder.write_num(max_ordinal, offset);
5596            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5597            // Calling encoder.out_of_line_offset(0) is not allowed.
5598            if max_ordinal == 0 {
5599                return Ok(());
5600            }
5601            depth.increment()?;
5602            let envelope_size = 8;
5603            let bytes_len = max_ordinal as usize * envelope_size;
5604            #[allow(unused_variables)]
5605            let offset = encoder.out_of_line_offset(bytes_len);
5606            let mut _prev_end_offset: usize = 0;
5607            if 1 > max_ordinal {
5608                return Ok(());
5609            }
5610
5611            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5612            // are envelope_size bytes.
5613            let cur_offset: usize = (1 - 1) * envelope_size;
5614
5615            // Zero reserved fields.
5616            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5617
5618            // Safety:
5619            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5620            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5621            //   envelope_size bytes, there is always sufficient room.
5622            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
5623                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
5624                encoder,
5625                offset + cur_offset,
5626                depth,
5627            )?;
5628
5629            _prev_end_offset = cur_offset + envelope_size;
5630
5631            Ok(())
5632        }
5633    }
5634
5635    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DynamicSecureHeap {
5636        #[inline(always)]
5637        fn new_empty() -> Self {
5638            Self::default()
5639        }
5640
5641        unsafe fn decode(
5642            &mut self,
5643            decoder: &mut fidl::encoding::Decoder<'_, D>,
5644            offset: usize,
5645            mut depth: fidl::encoding::Depth,
5646        ) -> fidl::Result<()> {
5647            decoder.debug_check_bounds::<Self>(offset);
5648            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5649                None => return Err(fidl::Error::NotNullable),
5650                Some(len) => len,
5651            };
5652            // Calling decoder.out_of_line_offset(0) is not allowed.
5653            if len == 0 {
5654                return Ok(());
5655            };
5656            depth.increment()?;
5657            let envelope_size = 8;
5658            let bytes_len = len * envelope_size;
5659            let offset = decoder.out_of_line_offset(bytes_len)?;
5660            // Decode the envelope for each type.
5661            let mut _next_ordinal_to_read = 0;
5662            let mut next_offset = offset;
5663            let end_offset = offset + bytes_len;
5664            _next_ordinal_to_read += 1;
5665            if next_offset >= end_offset {
5666                return Ok(());
5667            }
5668
5669            // Decode unknown envelopes for gaps in ordinals.
5670            while _next_ordinal_to_read < 1 {
5671                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5672                _next_ordinal_to_read += 1;
5673                next_offset += envelope_size;
5674            }
5675
5676            let next_out_of_line = decoder.next_out_of_line();
5677            let handles_before = decoder.remaining_handles();
5678            if let Some((inlined, num_bytes, num_handles)) =
5679                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5680            {
5681                let member_inline_size =
5682                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5683                if inlined != (member_inline_size <= 4) {
5684                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5685                }
5686                let inner_offset;
5687                let mut inner_depth = depth.clone();
5688                if inlined {
5689                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5690                    inner_offset = next_offset;
5691                } else {
5692                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5693                    inner_depth.increment()?;
5694                }
5695                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
5696                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
5697                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5698                {
5699                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5700                }
5701                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5702                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5703                }
5704            }
5705
5706            next_offset += envelope_size;
5707
5708            // Decode the remaining unknown envelopes.
5709            while next_offset < end_offset {
5710                _next_ordinal_to_read += 1;
5711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5712                next_offset += envelope_size;
5713            }
5714
5715            Ok(())
5716        }
5717    }
5718
5719    impl FormatCostEntry {
5720        #[inline(always)]
5721        fn max_ordinal_present(&self) -> u64 {
5722            if let Some(_) = self.cost {
5723                return 2;
5724            }
5725            if let Some(_) = self.key {
5726                return 1;
5727            }
5728            0
5729        }
5730    }
5731
5732    impl fidl::encoding::ValueTypeMarker for FormatCostEntry {
5733        type Borrowed<'a> = &'a Self;
5734        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5735            value
5736        }
5737    }
5738
5739    unsafe impl fidl::encoding::TypeMarker for FormatCostEntry {
5740        type Owned = Self;
5741
5742        #[inline(always)]
5743        fn inline_align(_context: fidl::encoding::Context) -> usize {
5744            8
5745        }
5746
5747        #[inline(always)]
5748        fn inline_size(_context: fidl::encoding::Context) -> usize {
5749            16
5750        }
5751    }
5752
5753    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCostEntry, D>
5754        for &FormatCostEntry
5755    {
5756        unsafe fn encode(
5757            self,
5758            encoder: &mut fidl::encoding::Encoder<'_, D>,
5759            offset: usize,
5760            mut depth: fidl::encoding::Depth,
5761        ) -> fidl::Result<()> {
5762            encoder.debug_check_bounds::<FormatCostEntry>(offset);
5763            // Vector header
5764            let max_ordinal: u64 = self.max_ordinal_present();
5765            encoder.write_num(max_ordinal, offset);
5766            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5767            // Calling encoder.out_of_line_offset(0) is not allowed.
5768            if max_ordinal == 0 {
5769                return Ok(());
5770            }
5771            depth.increment()?;
5772            let envelope_size = 8;
5773            let bytes_len = max_ordinal as usize * envelope_size;
5774            #[allow(unused_variables)]
5775            let offset = encoder.out_of_line_offset(bytes_len);
5776            let mut _prev_end_offset: usize = 0;
5777            if 1 > max_ordinal {
5778                return Ok(());
5779            }
5780
5781            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5782            // are envelope_size bytes.
5783            let cur_offset: usize = (1 - 1) * envelope_size;
5784
5785            // Zero reserved fields.
5786            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5787
5788            // Safety:
5789            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5790            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5791            //   envelope_size bytes, there is always sufficient room.
5792            fidl::encoding::encode_in_envelope_optional::<FormatCostKey, D>(
5793                self.key.as_ref().map(<FormatCostKey as fidl::encoding::ValueTypeMarker>::borrow),
5794                encoder,
5795                offset + cur_offset,
5796                depth,
5797            )?;
5798
5799            _prev_end_offset = cur_offset + envelope_size;
5800            if 2 > max_ordinal {
5801                return Ok(());
5802            }
5803
5804            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5805            // are envelope_size bytes.
5806            let cur_offset: usize = (2 - 1) * envelope_size;
5807
5808            // Zero reserved fields.
5809            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5810
5811            // Safety:
5812            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5813            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5814            //   envelope_size bytes, there is always sufficient room.
5815            fidl::encoding::encode_in_envelope_optional::<f32, D>(
5816                self.cost.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
5817                encoder,
5818                offset + cur_offset,
5819                depth,
5820            )?;
5821
5822            _prev_end_offset = cur_offset + envelope_size;
5823
5824            Ok(())
5825        }
5826    }
5827
5828    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCostEntry {
5829        #[inline(always)]
5830        fn new_empty() -> Self {
5831            Self::default()
5832        }
5833
5834        unsafe fn decode(
5835            &mut self,
5836            decoder: &mut fidl::encoding::Decoder<'_, D>,
5837            offset: usize,
5838            mut depth: fidl::encoding::Depth,
5839        ) -> fidl::Result<()> {
5840            decoder.debug_check_bounds::<Self>(offset);
5841            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5842                None => return Err(fidl::Error::NotNullable),
5843                Some(len) => len,
5844            };
5845            // Calling decoder.out_of_line_offset(0) is not allowed.
5846            if len == 0 {
5847                return Ok(());
5848            };
5849            depth.increment()?;
5850            let envelope_size = 8;
5851            let bytes_len = len * envelope_size;
5852            let offset = decoder.out_of_line_offset(bytes_len)?;
5853            // Decode the envelope for each type.
5854            let mut _next_ordinal_to_read = 0;
5855            let mut next_offset = offset;
5856            let end_offset = offset + bytes_len;
5857            _next_ordinal_to_read += 1;
5858            if next_offset >= end_offset {
5859                return Ok(());
5860            }
5861
5862            // Decode unknown envelopes for gaps in ordinals.
5863            while _next_ordinal_to_read < 1 {
5864                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5865                _next_ordinal_to_read += 1;
5866                next_offset += envelope_size;
5867            }
5868
5869            let next_out_of_line = decoder.next_out_of_line();
5870            let handles_before = decoder.remaining_handles();
5871            if let Some((inlined, num_bytes, num_handles)) =
5872                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5873            {
5874                let member_inline_size =
5875                    <FormatCostKey as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5876                if inlined != (member_inline_size <= 4) {
5877                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5878                }
5879                let inner_offset;
5880                let mut inner_depth = depth.clone();
5881                if inlined {
5882                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5883                    inner_offset = next_offset;
5884                } else {
5885                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5886                    inner_depth.increment()?;
5887                }
5888                let val_ref = self.key.get_or_insert_with(|| fidl::new_empty!(FormatCostKey, D));
5889                fidl::decode!(FormatCostKey, D, val_ref, decoder, inner_offset, inner_depth)?;
5890                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5891                {
5892                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5893                }
5894                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5895                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5896                }
5897            }
5898
5899            next_offset += envelope_size;
5900            _next_ordinal_to_read += 1;
5901            if next_offset >= end_offset {
5902                return Ok(());
5903            }
5904
5905            // Decode unknown envelopes for gaps in ordinals.
5906            while _next_ordinal_to_read < 2 {
5907                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5908                _next_ordinal_to_read += 1;
5909                next_offset += envelope_size;
5910            }
5911
5912            let next_out_of_line = decoder.next_out_of_line();
5913            let handles_before = decoder.remaining_handles();
5914            if let Some((inlined, num_bytes, num_handles)) =
5915                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5916            {
5917                let member_inline_size =
5918                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5919                if inlined != (member_inline_size <= 4) {
5920                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5921                }
5922                let inner_offset;
5923                let mut inner_depth = depth.clone();
5924                if inlined {
5925                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5926                    inner_offset = next_offset;
5927                } else {
5928                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5929                    inner_depth.increment()?;
5930                }
5931                let val_ref = self.cost.get_or_insert_with(|| fidl::new_empty!(f32, D));
5932                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
5933                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5934                {
5935                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5936                }
5937                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5938                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5939                }
5940            }
5941
5942            next_offset += envelope_size;
5943
5944            // Decode the remaining unknown envelopes.
5945            while next_offset < end_offset {
5946                _next_ordinal_to_read += 1;
5947                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5948                next_offset += envelope_size;
5949            }
5950
5951            Ok(())
5952        }
5953    }
5954
5955    impl FormatCostKey {
5956        #[inline(always)]
5957        fn max_ordinal_present(&self) -> u64 {
5958            if let Some(_) = self.buffer_usage_bits {
5959                return 3;
5960            }
5961            if let Some(_) = self.pixel_format_modifier {
5962                return 2;
5963            }
5964            if let Some(_) = self.pixel_format {
5965                return 1;
5966            }
5967            0
5968        }
5969    }
5970
5971    impl fidl::encoding::ValueTypeMarker for FormatCostKey {
5972        type Borrowed<'a> = &'a Self;
5973        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5974            value
5975        }
5976    }
5977
5978    unsafe impl fidl::encoding::TypeMarker for FormatCostKey {
5979        type Owned = Self;
5980
5981        #[inline(always)]
5982        fn inline_align(_context: fidl::encoding::Context) -> usize {
5983            8
5984        }
5985
5986        #[inline(always)]
5987        fn inline_size(_context: fidl::encoding::Context) -> usize {
5988            16
5989        }
5990    }
5991
5992    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCostKey, D>
5993        for &FormatCostKey
5994    {
5995        unsafe fn encode(
5996            self,
5997            encoder: &mut fidl::encoding::Encoder<'_, D>,
5998            offset: usize,
5999            mut depth: fidl::encoding::Depth,
6000        ) -> fidl::Result<()> {
6001            encoder.debug_check_bounds::<FormatCostKey>(offset);
6002            // Vector header
6003            let max_ordinal: u64 = self.max_ordinal_present();
6004            encoder.write_num(max_ordinal, offset);
6005            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6006            // Calling encoder.out_of_line_offset(0) is not allowed.
6007            if max_ordinal == 0 {
6008                return Ok(());
6009            }
6010            depth.increment()?;
6011            let envelope_size = 8;
6012            let bytes_len = max_ordinal as usize * envelope_size;
6013            #[allow(unused_variables)]
6014            let offset = encoder.out_of_line_offset(bytes_len);
6015            let mut _prev_end_offset: usize = 0;
6016            if 1 > max_ordinal {
6017                return Ok(());
6018            }
6019
6020            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6021            // are envelope_size bytes.
6022            let cur_offset: usize = (1 - 1) * envelope_size;
6023
6024            // Zero reserved fields.
6025            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6026
6027            // Safety:
6028            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6029            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6030            //   envelope_size bytes, there is always sufficient room.
6031            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormat, D>(
6032            self.pixel_format.as_ref().map(<fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow),
6033            encoder, offset + cur_offset, depth
6034        )?;
6035
6036            _prev_end_offset = cur_offset + envelope_size;
6037            if 2 > max_ordinal {
6038                return Ok(());
6039            }
6040
6041            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6042            // are envelope_size bytes.
6043            let cur_offset: usize = (2 - 1) * envelope_size;
6044
6045            // Zero reserved fields.
6046            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6047
6048            // Safety:
6049            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6050            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6051            //   envelope_size bytes, there is always sufficient room.
6052            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormatModifier, D>(
6053            self.pixel_format_modifier.as_ref().map(<fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow),
6054            encoder, offset + cur_offset, depth
6055        )?;
6056
6057            _prev_end_offset = cur_offset + envelope_size;
6058            if 3 > max_ordinal {
6059                return Ok(());
6060            }
6061
6062            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6063            // are envelope_size bytes.
6064            let cur_offset: usize = (3 - 1) * envelope_size;
6065
6066            // Zero reserved fields.
6067            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6068
6069            // Safety:
6070            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6071            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6072            //   envelope_size bytes, there is always sufficient room.
6073            fidl::encoding::encode_in_envelope_optional::<BufferUsage, D>(
6074                self.buffer_usage_bits
6075                    .as_ref()
6076                    .map(<BufferUsage as fidl::encoding::ValueTypeMarker>::borrow),
6077                encoder,
6078                offset + cur_offset,
6079                depth,
6080            )?;
6081
6082            _prev_end_offset = cur_offset + envelope_size;
6083
6084            Ok(())
6085        }
6086    }
6087
6088    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCostKey {
6089        #[inline(always)]
6090        fn new_empty() -> Self {
6091            Self::default()
6092        }
6093
6094        unsafe fn decode(
6095            &mut self,
6096            decoder: &mut fidl::encoding::Decoder<'_, D>,
6097            offset: usize,
6098            mut depth: fidl::encoding::Depth,
6099        ) -> fidl::Result<()> {
6100            decoder.debug_check_bounds::<Self>(offset);
6101            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6102                None => return Err(fidl::Error::NotNullable),
6103                Some(len) => len,
6104            };
6105            // Calling decoder.out_of_line_offset(0) is not allowed.
6106            if len == 0 {
6107                return Ok(());
6108            };
6109            depth.increment()?;
6110            let envelope_size = 8;
6111            let bytes_len = len * envelope_size;
6112            let offset = decoder.out_of_line_offset(bytes_len)?;
6113            // Decode the envelope for each type.
6114            let mut _next_ordinal_to_read = 0;
6115            let mut next_offset = offset;
6116            let end_offset = offset + bytes_len;
6117            _next_ordinal_to_read += 1;
6118            if next_offset >= end_offset {
6119                return Ok(());
6120            }
6121
6122            // Decode unknown envelopes for gaps in ordinals.
6123            while _next_ordinal_to_read < 1 {
6124                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6125                _next_ordinal_to_read += 1;
6126                next_offset += envelope_size;
6127            }
6128
6129            let next_out_of_line = decoder.next_out_of_line();
6130            let handles_before = decoder.remaining_handles();
6131            if let Some((inlined, num_bytes, num_handles)) =
6132                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6133            {
6134                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6135                if inlined != (member_inline_size <= 4) {
6136                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6137                }
6138                let inner_offset;
6139                let mut inner_depth = depth.clone();
6140                if inlined {
6141                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6142                    inner_offset = next_offset;
6143                } else {
6144                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6145                    inner_depth.increment()?;
6146                }
6147                let val_ref = self.pixel_format.get_or_insert_with(|| {
6148                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D)
6149                });
6150                fidl::decode!(
6151                    fidl_fuchsia_images2__common::PixelFormat,
6152                    D,
6153                    val_ref,
6154                    decoder,
6155                    inner_offset,
6156                    inner_depth
6157                )?;
6158                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6159                {
6160                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6161                }
6162                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6163                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6164                }
6165            }
6166
6167            next_offset += envelope_size;
6168            _next_ordinal_to_read += 1;
6169            if next_offset >= end_offset {
6170                return Ok(());
6171            }
6172
6173            // Decode unknown envelopes for gaps in ordinals.
6174            while _next_ordinal_to_read < 2 {
6175                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6176                _next_ordinal_to_read += 1;
6177                next_offset += envelope_size;
6178            }
6179
6180            let next_out_of_line = decoder.next_out_of_line();
6181            let handles_before = decoder.remaining_handles();
6182            if let Some((inlined, num_bytes, num_handles)) =
6183                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6184            {
6185                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6186                if inlined != (member_inline_size <= 4) {
6187                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6188                }
6189                let inner_offset;
6190                let mut inner_depth = depth.clone();
6191                if inlined {
6192                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6193                    inner_offset = next_offset;
6194                } else {
6195                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6196                    inner_depth.increment()?;
6197                }
6198                let val_ref = self.pixel_format_modifier.get_or_insert_with(|| {
6199                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormatModifier, D)
6200                });
6201                fidl::decode!(
6202                    fidl_fuchsia_images2__common::PixelFormatModifier,
6203                    D,
6204                    val_ref,
6205                    decoder,
6206                    inner_offset,
6207                    inner_depth
6208                )?;
6209                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6210                {
6211                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6212                }
6213                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6214                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6215                }
6216            }
6217
6218            next_offset += envelope_size;
6219            _next_ordinal_to_read += 1;
6220            if next_offset >= end_offset {
6221                return Ok(());
6222            }
6223
6224            // Decode unknown envelopes for gaps in ordinals.
6225            while _next_ordinal_to_read < 3 {
6226                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6227                _next_ordinal_to_read += 1;
6228                next_offset += envelope_size;
6229            }
6230
6231            let next_out_of_line = decoder.next_out_of_line();
6232            let handles_before = decoder.remaining_handles();
6233            if let Some((inlined, num_bytes, num_handles)) =
6234                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6235            {
6236                let member_inline_size =
6237                    <BufferUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6238                if inlined != (member_inline_size <= 4) {
6239                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6240                }
6241                let inner_offset;
6242                let mut inner_depth = depth.clone();
6243                if inlined {
6244                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6245                    inner_offset = next_offset;
6246                } else {
6247                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6248                    inner_depth.increment()?;
6249                }
6250                let val_ref =
6251                    self.buffer_usage_bits.get_or_insert_with(|| fidl::new_empty!(BufferUsage, D));
6252                fidl::decode!(BufferUsage, D, val_ref, decoder, inner_offset, inner_depth)?;
6253                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6254                {
6255                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6256                }
6257                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6258                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6259                }
6260            }
6261
6262            next_offset += envelope_size;
6263
6264            // Decode the remaining unknown envelopes.
6265            while next_offset < end_offset {
6266                _next_ordinal_to_read += 1;
6267                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6268                next_offset += envelope_size;
6269            }
6270
6271            Ok(())
6272        }
6273    }
6274
6275    impl FormatCosts {
6276        #[inline(always)]
6277        fn max_ordinal_present(&self) -> u64 {
6278            if let Some(_) = self.format_costs {
6279                return 1;
6280            }
6281            0
6282        }
6283    }
6284
6285    impl fidl::encoding::ValueTypeMarker for FormatCosts {
6286        type Borrowed<'a> = &'a Self;
6287        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6288            value
6289        }
6290    }
6291
6292    unsafe impl fidl::encoding::TypeMarker for FormatCosts {
6293        type Owned = Self;
6294
6295        #[inline(always)]
6296        fn inline_align(_context: fidl::encoding::Context) -> usize {
6297            8
6298        }
6299
6300        #[inline(always)]
6301        fn inline_size(_context: fidl::encoding::Context) -> usize {
6302            16
6303        }
6304    }
6305
6306    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCosts, D>
6307        for &FormatCosts
6308    {
6309        unsafe fn encode(
6310            self,
6311            encoder: &mut fidl::encoding::Encoder<'_, D>,
6312            offset: usize,
6313            mut depth: fidl::encoding::Depth,
6314        ) -> fidl::Result<()> {
6315            encoder.debug_check_bounds::<FormatCosts>(offset);
6316            // Vector header
6317            let max_ordinal: u64 = self.max_ordinal_present();
6318            encoder.write_num(max_ordinal, offset);
6319            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6320            // Calling encoder.out_of_line_offset(0) is not allowed.
6321            if max_ordinal == 0 {
6322                return Ok(());
6323            }
6324            depth.increment()?;
6325            let envelope_size = 8;
6326            let bytes_len = max_ordinal as usize * envelope_size;
6327            #[allow(unused_variables)]
6328            let offset = encoder.out_of_line_offset(bytes_len);
6329            let mut _prev_end_offset: usize = 0;
6330            if 1 > max_ordinal {
6331                return Ok(());
6332            }
6333
6334            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6335            // are envelope_size bytes.
6336            let cur_offset: usize = (1 - 1) * envelope_size;
6337
6338            // Zero reserved fields.
6339            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6340
6341            // Safety:
6342            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6343            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6344            //   envelope_size bytes, there is always sufficient room.
6345            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<FormatCostEntry>, D>(
6346            self.format_costs.as_ref().map(<fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::ValueTypeMarker>::borrow),
6347            encoder, offset + cur_offset, depth
6348        )?;
6349
6350            _prev_end_offset = cur_offset + envelope_size;
6351
6352            Ok(())
6353        }
6354    }
6355
6356    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCosts {
6357        #[inline(always)]
6358        fn new_empty() -> Self {
6359            Self::default()
6360        }
6361
6362        unsafe fn decode(
6363            &mut self,
6364            decoder: &mut fidl::encoding::Decoder<'_, D>,
6365            offset: usize,
6366            mut depth: fidl::encoding::Depth,
6367        ) -> fidl::Result<()> {
6368            decoder.debug_check_bounds::<Self>(offset);
6369            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6370                None => return Err(fidl::Error::NotNullable),
6371                Some(len) => len,
6372            };
6373            // Calling decoder.out_of_line_offset(0) is not allowed.
6374            if len == 0 {
6375                return Ok(());
6376            };
6377            depth.increment()?;
6378            let envelope_size = 8;
6379            let bytes_len = len * envelope_size;
6380            let offset = decoder.out_of_line_offset(bytes_len)?;
6381            // Decode the envelope for each type.
6382            let mut _next_ordinal_to_read = 0;
6383            let mut next_offset = offset;
6384            let end_offset = offset + bytes_len;
6385            _next_ordinal_to_read += 1;
6386            if next_offset >= end_offset {
6387                return Ok(());
6388            }
6389
6390            // Decode unknown envelopes for gaps in ordinals.
6391            while _next_ordinal_to_read < 1 {
6392                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6393                _next_ordinal_to_read += 1;
6394                next_offset += envelope_size;
6395            }
6396
6397            let next_out_of_line = decoder.next_out_of_line();
6398            let handles_before = decoder.remaining_handles();
6399            if let Some((inlined, num_bytes, num_handles)) =
6400                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6401            {
6402                let member_inline_size = <fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6403                if inlined != (member_inline_size <= 4) {
6404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6405                }
6406                let inner_offset;
6407                let mut inner_depth = depth.clone();
6408                if inlined {
6409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6410                    inner_offset = next_offset;
6411                } else {
6412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6413                    inner_depth.increment()?;
6414                }
6415                let val_ref = self.format_costs.get_or_insert_with(|| {
6416                    fidl::new_empty!(fidl::encoding::UnboundedVector<FormatCostEntry>, D)
6417                });
6418                fidl::decode!(
6419                    fidl::encoding::UnboundedVector<FormatCostEntry>,
6420                    D,
6421                    val_ref,
6422                    decoder,
6423                    inner_offset,
6424                    inner_depth
6425                )?;
6426                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6427                {
6428                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6429                }
6430                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6431                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6432                }
6433            }
6434
6435            next_offset += envelope_size;
6436
6437            // Decode the remaining unknown envelopes.
6438            while next_offset < end_offset {
6439                _next_ordinal_to_read += 1;
6440                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6441                next_offset += envelope_size;
6442            }
6443
6444            Ok(())
6445        }
6446    }
6447
6448    impl Heap {
6449        #[inline(always)]
6450        fn max_ordinal_present(&self) -> u64 {
6451            if let Some(_) = self.id {
6452                return 2;
6453            }
6454            if let Some(_) = self.heap_type {
6455                return 1;
6456            }
6457            0
6458        }
6459    }
6460
6461    impl fidl::encoding::ValueTypeMarker for Heap {
6462        type Borrowed<'a> = &'a Self;
6463        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6464            value
6465        }
6466    }
6467
6468    unsafe impl fidl::encoding::TypeMarker for Heap {
6469        type Owned = Self;
6470
6471        #[inline(always)]
6472        fn inline_align(_context: fidl::encoding::Context) -> usize {
6473            8
6474        }
6475
6476        #[inline(always)]
6477        fn inline_size(_context: fidl::encoding::Context) -> usize {
6478            16
6479        }
6480    }
6481
6482    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Heap, D> for &Heap {
6483        unsafe fn encode(
6484            self,
6485            encoder: &mut fidl::encoding::Encoder<'_, D>,
6486            offset: usize,
6487            mut depth: fidl::encoding::Depth,
6488        ) -> fidl::Result<()> {
6489            encoder.debug_check_bounds::<Heap>(offset);
6490            // Vector header
6491            let max_ordinal: u64 = self.max_ordinal_present();
6492            encoder.write_num(max_ordinal, offset);
6493            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6494            // Calling encoder.out_of_line_offset(0) is not allowed.
6495            if max_ordinal == 0 {
6496                return Ok(());
6497            }
6498            depth.increment()?;
6499            let envelope_size = 8;
6500            let bytes_len = max_ordinal as usize * envelope_size;
6501            #[allow(unused_variables)]
6502            let offset = encoder.out_of_line_offset(bytes_len);
6503            let mut _prev_end_offset: usize = 0;
6504            if 1 > max_ordinal {
6505                return Ok(());
6506            }
6507
6508            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6509            // are envelope_size bytes.
6510            let cur_offset: usize = (1 - 1) * envelope_size;
6511
6512            // Zero reserved fields.
6513            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6514
6515            // Safety:
6516            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6517            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6518            //   envelope_size bytes, there is always sufficient room.
6519            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
6520                self.heap_type.as_ref().map(
6521                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
6522                ),
6523                encoder,
6524                offset + cur_offset,
6525                depth,
6526            )?;
6527
6528            _prev_end_offset = cur_offset + envelope_size;
6529            if 2 > max_ordinal {
6530                return Ok(());
6531            }
6532
6533            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6534            // are envelope_size bytes.
6535            let cur_offset: usize = (2 - 1) * envelope_size;
6536
6537            // Zero reserved fields.
6538            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6539
6540            // Safety:
6541            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6542            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6543            //   envelope_size bytes, there is always sufficient room.
6544            fidl::encoding::encode_in_envelope_optional::<u64, D>(
6545                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
6546                encoder,
6547                offset + cur_offset,
6548                depth,
6549            )?;
6550
6551            _prev_end_offset = cur_offset + envelope_size;
6552
6553            Ok(())
6554        }
6555    }
6556
6557    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Heap {
6558        #[inline(always)]
6559        fn new_empty() -> Self {
6560            Self::default()
6561        }
6562
6563        unsafe fn decode(
6564            &mut self,
6565            decoder: &mut fidl::encoding::Decoder<'_, D>,
6566            offset: usize,
6567            mut depth: fidl::encoding::Depth,
6568        ) -> fidl::Result<()> {
6569            decoder.debug_check_bounds::<Self>(offset);
6570            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6571                None => return Err(fidl::Error::NotNullable),
6572                Some(len) => len,
6573            };
6574            // Calling decoder.out_of_line_offset(0) is not allowed.
6575            if len == 0 {
6576                return Ok(());
6577            };
6578            depth.increment()?;
6579            let envelope_size = 8;
6580            let bytes_len = len * envelope_size;
6581            let offset = decoder.out_of_line_offset(bytes_len)?;
6582            // Decode the envelope for each type.
6583            let mut _next_ordinal_to_read = 0;
6584            let mut next_offset = offset;
6585            let end_offset = offset + bytes_len;
6586            _next_ordinal_to_read += 1;
6587            if next_offset >= end_offset {
6588                return Ok(());
6589            }
6590
6591            // Decode unknown envelopes for gaps in ordinals.
6592            while _next_ordinal_to_read < 1 {
6593                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6594                _next_ordinal_to_read += 1;
6595                next_offset += envelope_size;
6596            }
6597
6598            let next_out_of_line = decoder.next_out_of_line();
6599            let handles_before = decoder.remaining_handles();
6600            if let Some((inlined, num_bytes, num_handles)) =
6601                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6602            {
6603                let member_inline_size =
6604                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
6605                        decoder.context,
6606                    );
6607                if inlined != (member_inline_size <= 4) {
6608                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6609                }
6610                let inner_offset;
6611                let mut inner_depth = depth.clone();
6612                if inlined {
6613                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6614                    inner_offset = next_offset;
6615                } else {
6616                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6617                    inner_depth.increment()?;
6618                }
6619                let val_ref = self
6620                    .heap_type
6621                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
6622                fidl::decode!(
6623                    fidl::encoding::BoundedString<128>,
6624                    D,
6625                    val_ref,
6626                    decoder,
6627                    inner_offset,
6628                    inner_depth
6629                )?;
6630                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6631                {
6632                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6633                }
6634                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6635                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6636                }
6637            }
6638
6639            next_offset += envelope_size;
6640            _next_ordinal_to_read += 1;
6641            if next_offset >= end_offset {
6642                return Ok(());
6643            }
6644
6645            // Decode unknown envelopes for gaps in ordinals.
6646            while _next_ordinal_to_read < 2 {
6647                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6648                _next_ordinal_to_read += 1;
6649                next_offset += envelope_size;
6650            }
6651
6652            let next_out_of_line = decoder.next_out_of_line();
6653            let handles_before = decoder.remaining_handles();
6654            if let Some((inlined, num_bytes, num_handles)) =
6655                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6656            {
6657                let member_inline_size =
6658                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6659                if inlined != (member_inline_size <= 4) {
6660                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6661                }
6662                let inner_offset;
6663                let mut inner_depth = depth.clone();
6664                if inlined {
6665                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6666                    inner_offset = next_offset;
6667                } else {
6668                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6669                    inner_depth.increment()?;
6670                }
6671                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
6672                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
6673                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6674                {
6675                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6676                }
6677                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6678                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6679                }
6680            }
6681
6682            next_offset += envelope_size;
6683
6684            // Decode the remaining unknown envelopes.
6685            while next_offset < end_offset {
6686                _next_ordinal_to_read += 1;
6687                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6688                next_offset += envelope_size;
6689            }
6690
6691            Ok(())
6692        }
6693    }
6694
6695    impl ImageFormatConstraints {
6696        #[inline(always)]
6697        fn max_ordinal_present(&self) -> u64 {
6698            if let Some(_) = self.pad_beyond_image_size_bytes {
6699                return 20;
6700            }
6701            if let Some(_) = self.pad_for_block_size {
6702                return 19;
6703            }
6704            if let Some(_) = self.required_max_size_list {
6705                return 18;
6706            }
6707            if let Some(_) = self.is_alpha_present {
6708                return 17;
6709            }
6710            if let Some(_) = self.require_bytes_per_row_at_pixel_boundary {
6711                return 16;
6712            }
6713            if let Some(_) = self.pixel_format_and_modifiers {
6714                return 15;
6715            }
6716            if let Some(_) = self.start_offset_divisor {
6717                return 14;
6718            }
6719            if let Some(_) = self.bytes_per_row_divisor {
6720                return 13;
6721            }
6722            if let Some(_) = self.required_max_size {
6723                return 12;
6724            }
6725            if let Some(_) = self.required_min_size {
6726                return 11;
6727            }
6728            if let Some(_) = self.display_rect_alignment {
6729                return 10;
6730            }
6731            if let Some(_) = self.size_alignment {
6732                return 9;
6733            }
6734            if let Some(_) = self.max_width_times_height {
6735                return 8;
6736            }
6737            if let Some(_) = self.max_bytes_per_row {
6738                return 7;
6739            }
6740            if let Some(_) = self.min_bytes_per_row {
6741                return 6;
6742            }
6743            if let Some(_) = self.max_size {
6744                return 5;
6745            }
6746            if let Some(_) = self.min_size {
6747                return 4;
6748            }
6749            if let Some(_) = self.color_spaces {
6750                return 3;
6751            }
6752            if let Some(_) = self.pixel_format_modifier {
6753                return 2;
6754            }
6755            if let Some(_) = self.pixel_format {
6756                return 1;
6757            }
6758            0
6759        }
6760    }
6761
6762    impl fidl::encoding::ValueTypeMarker for ImageFormatConstraints {
6763        type Borrowed<'a> = &'a Self;
6764        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6765            value
6766        }
6767    }
6768
6769    unsafe impl fidl::encoding::TypeMarker for ImageFormatConstraints {
6770        type Owned = Self;
6771
6772        #[inline(always)]
6773        fn inline_align(_context: fidl::encoding::Context) -> usize {
6774            8
6775        }
6776
6777        #[inline(always)]
6778        fn inline_size(_context: fidl::encoding::Context) -> usize {
6779            16
6780        }
6781    }
6782
6783    unsafe impl<D: fidl::encoding::ResourceDialect>
6784        fidl::encoding::Encode<ImageFormatConstraints, D> for &ImageFormatConstraints
6785    {
6786        unsafe fn encode(
6787            self,
6788            encoder: &mut fidl::encoding::Encoder<'_, D>,
6789            offset: usize,
6790            mut depth: fidl::encoding::Depth,
6791        ) -> fidl::Result<()> {
6792            encoder.debug_check_bounds::<ImageFormatConstraints>(offset);
6793            // Vector header
6794            let max_ordinal: u64 = self.max_ordinal_present();
6795            encoder.write_num(max_ordinal, offset);
6796            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6797            // Calling encoder.out_of_line_offset(0) is not allowed.
6798            if max_ordinal == 0 {
6799                return Ok(());
6800            }
6801            depth.increment()?;
6802            let envelope_size = 8;
6803            let bytes_len = max_ordinal as usize * envelope_size;
6804            #[allow(unused_variables)]
6805            let offset = encoder.out_of_line_offset(bytes_len);
6806            let mut _prev_end_offset: usize = 0;
6807            if 1 > max_ordinal {
6808                return Ok(());
6809            }
6810
6811            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6812            // are envelope_size bytes.
6813            let cur_offset: usize = (1 - 1) * envelope_size;
6814
6815            // Zero reserved fields.
6816            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6817
6818            // Safety:
6819            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6820            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6821            //   envelope_size bytes, there is always sufficient room.
6822            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormat, D>(
6823            self.pixel_format.as_ref().map(<fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow),
6824            encoder, offset + cur_offset, depth
6825        )?;
6826
6827            _prev_end_offset = cur_offset + envelope_size;
6828            if 2 > max_ordinal {
6829                return Ok(());
6830            }
6831
6832            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6833            // are envelope_size bytes.
6834            let cur_offset: usize = (2 - 1) * envelope_size;
6835
6836            // Zero reserved fields.
6837            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6838
6839            // Safety:
6840            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6841            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6842            //   envelope_size bytes, there is always sufficient room.
6843            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2__common::PixelFormatModifier, D>(
6844            self.pixel_format_modifier.as_ref().map(<fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow),
6845            encoder, offset + cur_offset, depth
6846        )?;
6847
6848            _prev_end_offset = cur_offset + envelope_size;
6849            if 3 > max_ordinal {
6850                return Ok(());
6851            }
6852
6853            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6854            // are envelope_size bytes.
6855            let cur_offset: usize = (3 - 1) * envelope_size;
6856
6857            // Zero reserved fields.
6858            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6859
6860            // Safety:
6861            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6862            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6863            //   envelope_size bytes, there is always sufficient room.
6864            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D>(
6865            self.color_spaces.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32> as fidl::encoding::ValueTypeMarker>::borrow),
6866            encoder, offset + cur_offset, depth
6867        )?;
6868
6869            _prev_end_offset = cur_offset + envelope_size;
6870            if 4 > max_ordinal {
6871                return Ok(());
6872            }
6873
6874            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6875            // are envelope_size bytes.
6876            let cur_offset: usize = (4 - 1) * envelope_size;
6877
6878            // Zero reserved fields.
6879            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6880
6881            // Safety:
6882            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6883            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6884            //   envelope_size bytes, there is always sufficient room.
6885            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6886                self.min_size.as_ref().map(
6887                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6888                ),
6889                encoder,
6890                offset + cur_offset,
6891                depth,
6892            )?;
6893
6894            _prev_end_offset = cur_offset + envelope_size;
6895            if 5 > max_ordinal {
6896                return Ok(());
6897            }
6898
6899            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6900            // are envelope_size bytes.
6901            let cur_offset: usize = (5 - 1) * envelope_size;
6902
6903            // Zero reserved fields.
6904            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6905
6906            // Safety:
6907            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6908            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6909            //   envelope_size bytes, there is always sufficient room.
6910            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
6911                self.max_size.as_ref().map(
6912                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6913                ),
6914                encoder,
6915                offset + cur_offset,
6916                depth,
6917            )?;
6918
6919            _prev_end_offset = cur_offset + envelope_size;
6920            if 6 > max_ordinal {
6921                return Ok(());
6922            }
6923
6924            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6925            // are envelope_size bytes.
6926            let cur_offset: usize = (6 - 1) * envelope_size;
6927
6928            // Zero reserved fields.
6929            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6930
6931            // Safety:
6932            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6933            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6934            //   envelope_size bytes, there is always sufficient room.
6935            fidl::encoding::encode_in_envelope_optional::<u32, D>(
6936                self.min_bytes_per_row
6937                    .as_ref()
6938                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
6939                encoder,
6940                offset + cur_offset,
6941                depth,
6942            )?;
6943
6944            _prev_end_offset = cur_offset + envelope_size;
6945            if 7 > max_ordinal {
6946                return Ok(());
6947            }
6948
6949            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6950            // are envelope_size bytes.
6951            let cur_offset: usize = (7 - 1) * envelope_size;
6952
6953            // Zero reserved fields.
6954            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6955
6956            // Safety:
6957            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6958            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6959            //   envelope_size bytes, there is always sufficient room.
6960            fidl::encoding::encode_in_envelope_optional::<u32, D>(
6961                self.max_bytes_per_row
6962                    .as_ref()
6963                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
6964                encoder,
6965                offset + cur_offset,
6966                depth,
6967            )?;
6968
6969            _prev_end_offset = cur_offset + envelope_size;
6970            if 8 > max_ordinal {
6971                return Ok(());
6972            }
6973
6974            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6975            // are envelope_size bytes.
6976            let cur_offset: usize = (8 - 1) * envelope_size;
6977
6978            // Zero reserved fields.
6979            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6980
6981            // Safety:
6982            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6983            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6984            //   envelope_size bytes, there is always sufficient room.
6985            fidl::encoding::encode_in_envelope_optional::<u64, D>(
6986                self.max_width_times_height
6987                    .as_ref()
6988                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
6989                encoder,
6990                offset + cur_offset,
6991                depth,
6992            )?;
6993
6994            _prev_end_offset = cur_offset + envelope_size;
6995            if 9 > max_ordinal {
6996                return Ok(());
6997            }
6998
6999            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7000            // are envelope_size bytes.
7001            let cur_offset: usize = (9 - 1) * envelope_size;
7002
7003            // Zero reserved fields.
7004            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7005
7006            // Safety:
7007            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7008            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7009            //   envelope_size bytes, there is always sufficient room.
7010            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7011                self.size_alignment.as_ref().map(
7012                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7013                ),
7014                encoder,
7015                offset + cur_offset,
7016                depth,
7017            )?;
7018
7019            _prev_end_offset = cur_offset + envelope_size;
7020            if 10 > max_ordinal {
7021                return Ok(());
7022            }
7023
7024            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7025            // are envelope_size bytes.
7026            let cur_offset: usize = (10 - 1) * envelope_size;
7027
7028            // Zero reserved fields.
7029            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7030
7031            // Safety:
7032            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7033            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7034            //   envelope_size bytes, there is always sufficient room.
7035            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7036                self.display_rect_alignment.as_ref().map(
7037                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7038                ),
7039                encoder,
7040                offset + cur_offset,
7041                depth,
7042            )?;
7043
7044            _prev_end_offset = cur_offset + envelope_size;
7045            if 11 > max_ordinal {
7046                return Ok(());
7047            }
7048
7049            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7050            // are envelope_size bytes.
7051            let cur_offset: usize = (11 - 1) * envelope_size;
7052
7053            // Zero reserved fields.
7054            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7055
7056            // Safety:
7057            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7058            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7059            //   envelope_size bytes, there is always sufficient room.
7060            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7061                self.required_min_size.as_ref().map(
7062                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7063                ),
7064                encoder,
7065                offset + cur_offset,
7066                depth,
7067            )?;
7068
7069            _prev_end_offset = cur_offset + envelope_size;
7070            if 12 > max_ordinal {
7071                return Ok(());
7072            }
7073
7074            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7075            // are envelope_size bytes.
7076            let cur_offset: usize = (12 - 1) * envelope_size;
7077
7078            // Zero reserved fields.
7079            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7080
7081            // Safety:
7082            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7083            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7084            //   envelope_size bytes, there is always sufficient room.
7085            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7086                self.required_max_size.as_ref().map(
7087                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7088                ),
7089                encoder,
7090                offset + cur_offset,
7091                depth,
7092            )?;
7093
7094            _prev_end_offset = cur_offset + envelope_size;
7095            if 13 > max_ordinal {
7096                return Ok(());
7097            }
7098
7099            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7100            // are envelope_size bytes.
7101            let cur_offset: usize = (13 - 1) * envelope_size;
7102
7103            // Zero reserved fields.
7104            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7105
7106            // Safety:
7107            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7108            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7109            //   envelope_size bytes, there is always sufficient room.
7110            fidl::encoding::encode_in_envelope_optional::<u32, D>(
7111                self.bytes_per_row_divisor
7112                    .as_ref()
7113                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7114                encoder,
7115                offset + cur_offset,
7116                depth,
7117            )?;
7118
7119            _prev_end_offset = cur_offset + envelope_size;
7120            if 14 > max_ordinal {
7121                return Ok(());
7122            }
7123
7124            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7125            // are envelope_size bytes.
7126            let cur_offset: usize = (14 - 1) * envelope_size;
7127
7128            // Zero reserved fields.
7129            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7130
7131            // Safety:
7132            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7133            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7134            //   envelope_size bytes, there is always sufficient room.
7135            fidl::encoding::encode_in_envelope_optional::<u32, D>(
7136                self.start_offset_divisor
7137                    .as_ref()
7138                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7139                encoder,
7140                offset + cur_offset,
7141                depth,
7142            )?;
7143
7144            _prev_end_offset = cur_offset + envelope_size;
7145            if 15 > max_ordinal {
7146                return Ok(());
7147            }
7148
7149            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7150            // are envelope_size bytes.
7151            let cur_offset: usize = (15 - 1) * envelope_size;
7152
7153            // Zero reserved fields.
7154            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7155
7156            // Safety:
7157            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7158            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7159            //   envelope_size bytes, there is always sufficient room.
7160            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<PixelFormatAndModifier, 64>, D>(
7161            self.pixel_format_and_modifiers.as_ref().map(<fidl::encoding::Vector<PixelFormatAndModifier, 64> as fidl::encoding::ValueTypeMarker>::borrow),
7162            encoder, offset + cur_offset, depth
7163        )?;
7164
7165            _prev_end_offset = cur_offset + envelope_size;
7166            if 16 > max_ordinal {
7167                return Ok(());
7168            }
7169
7170            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7171            // are envelope_size bytes.
7172            let cur_offset: usize = (16 - 1) * envelope_size;
7173
7174            // Zero reserved fields.
7175            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7176
7177            // Safety:
7178            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7179            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7180            //   envelope_size bytes, there is always sufficient room.
7181            fidl::encoding::encode_in_envelope_optional::<bool, D>(
7182                self.require_bytes_per_row_at_pixel_boundary
7183                    .as_ref()
7184                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
7185                encoder,
7186                offset + cur_offset,
7187                depth,
7188            )?;
7189
7190            _prev_end_offset = cur_offset + envelope_size;
7191            if 17 > max_ordinal {
7192                return Ok(());
7193            }
7194
7195            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7196            // are envelope_size bytes.
7197            let cur_offset: usize = (17 - 1) * envelope_size;
7198
7199            // Zero reserved fields.
7200            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7201
7202            // Safety:
7203            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7204            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7205            //   envelope_size bytes, there is always sufficient room.
7206            fidl::encoding::encode_in_envelope_optional::<bool, D>(
7207                self.is_alpha_present
7208                    .as_ref()
7209                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
7210                encoder,
7211                offset + cur_offset,
7212                depth,
7213            )?;
7214
7215            _prev_end_offset = cur_offset + envelope_size;
7216            if 18 > max_ordinal {
7217                return Ok(());
7218            }
7219
7220            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7221            // are envelope_size bytes.
7222            let cur_offset: usize = (18 - 1) * envelope_size;
7223
7224            // Zero reserved fields.
7225            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7226
7227            // Safety:
7228            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7229            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7230            //   envelope_size bytes, there is always sufficient room.
7231            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D>(
7232            self.required_max_size_list.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64> as fidl::encoding::ValueTypeMarker>::borrow),
7233            encoder, offset + cur_offset, depth
7234        )?;
7235
7236            _prev_end_offset = cur_offset + envelope_size;
7237            if 19 > max_ordinal {
7238                return Ok(());
7239            }
7240
7241            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7242            // are envelope_size bytes.
7243            let cur_offset: usize = (19 - 1) * envelope_size;
7244
7245            // Zero reserved fields.
7246            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7247
7248            // Safety:
7249            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7250            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7251            //   envelope_size bytes, there is always sufficient room.
7252            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
7253                self.pad_for_block_size.as_ref().map(
7254                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7255                ),
7256                encoder,
7257                offset + cur_offset,
7258                depth,
7259            )?;
7260
7261            _prev_end_offset = cur_offset + envelope_size;
7262            if 20 > max_ordinal {
7263                return Ok(());
7264            }
7265
7266            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7267            // are envelope_size bytes.
7268            let cur_offset: usize = (20 - 1) * envelope_size;
7269
7270            // Zero reserved fields.
7271            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7272
7273            // Safety:
7274            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7275            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7276            //   envelope_size bytes, there is always sufficient room.
7277            fidl::encoding::encode_in_envelope_optional::<u64, D>(
7278                self.pad_beyond_image_size_bytes
7279                    .as_ref()
7280                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7281                encoder,
7282                offset + cur_offset,
7283                depth,
7284            )?;
7285
7286            _prev_end_offset = cur_offset + envelope_size;
7287
7288            Ok(())
7289        }
7290    }
7291
7292    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
7293        for ImageFormatConstraints
7294    {
7295        #[inline(always)]
7296        fn new_empty() -> Self {
7297            Self::default()
7298        }
7299
7300        unsafe fn decode(
7301            &mut self,
7302            decoder: &mut fidl::encoding::Decoder<'_, D>,
7303            offset: usize,
7304            mut depth: fidl::encoding::Depth,
7305        ) -> fidl::Result<()> {
7306            decoder.debug_check_bounds::<Self>(offset);
7307            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7308                None => return Err(fidl::Error::NotNullable),
7309                Some(len) => len,
7310            };
7311            // Calling decoder.out_of_line_offset(0) is not allowed.
7312            if len == 0 {
7313                return Ok(());
7314            };
7315            depth.increment()?;
7316            let envelope_size = 8;
7317            let bytes_len = len * envelope_size;
7318            let offset = decoder.out_of_line_offset(bytes_len)?;
7319            // Decode the envelope for each type.
7320            let mut _next_ordinal_to_read = 0;
7321            let mut next_offset = offset;
7322            let end_offset = offset + bytes_len;
7323            _next_ordinal_to_read += 1;
7324            if next_offset >= end_offset {
7325                return Ok(());
7326            }
7327
7328            // Decode unknown envelopes for gaps in ordinals.
7329            while _next_ordinal_to_read < 1 {
7330                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7331                _next_ordinal_to_read += 1;
7332                next_offset += envelope_size;
7333            }
7334
7335            let next_out_of_line = decoder.next_out_of_line();
7336            let handles_before = decoder.remaining_handles();
7337            if let Some((inlined, num_bytes, num_handles)) =
7338                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7339            {
7340                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7341                if inlined != (member_inline_size <= 4) {
7342                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7343                }
7344                let inner_offset;
7345                let mut inner_depth = depth.clone();
7346                if inlined {
7347                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7348                    inner_offset = next_offset;
7349                } else {
7350                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7351                    inner_depth.increment()?;
7352                }
7353                let val_ref = self.pixel_format.get_or_insert_with(|| {
7354                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D)
7355                });
7356                fidl::decode!(
7357                    fidl_fuchsia_images2__common::PixelFormat,
7358                    D,
7359                    val_ref,
7360                    decoder,
7361                    inner_offset,
7362                    inner_depth
7363                )?;
7364                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7365                {
7366                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7367                }
7368                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7369                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7370                }
7371            }
7372
7373            next_offset += envelope_size;
7374            _next_ordinal_to_read += 1;
7375            if next_offset >= end_offset {
7376                return Ok(());
7377            }
7378
7379            // Decode unknown envelopes for gaps in ordinals.
7380            while _next_ordinal_to_read < 2 {
7381                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7382                _next_ordinal_to_read += 1;
7383                next_offset += envelope_size;
7384            }
7385
7386            let next_out_of_line = decoder.next_out_of_line();
7387            let handles_before = decoder.remaining_handles();
7388            if let Some((inlined, num_bytes, num_handles)) =
7389                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7390            {
7391                let member_inline_size = <fidl_fuchsia_images2__common::PixelFormatModifier as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7392                if inlined != (member_inline_size <= 4) {
7393                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7394                }
7395                let inner_offset;
7396                let mut inner_depth = depth.clone();
7397                if inlined {
7398                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7399                    inner_offset = next_offset;
7400                } else {
7401                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7402                    inner_depth.increment()?;
7403                }
7404                let val_ref = self.pixel_format_modifier.get_or_insert_with(|| {
7405                    fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormatModifier, D)
7406                });
7407                fidl::decode!(
7408                    fidl_fuchsia_images2__common::PixelFormatModifier,
7409                    D,
7410                    val_ref,
7411                    decoder,
7412                    inner_offset,
7413                    inner_depth
7414                )?;
7415                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7416                {
7417                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7418                }
7419                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7420                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7421                }
7422            }
7423
7424            next_offset += envelope_size;
7425            _next_ordinal_to_read += 1;
7426            if next_offset >= end_offset {
7427                return Ok(());
7428            }
7429
7430            // Decode unknown envelopes for gaps in ordinals.
7431            while _next_ordinal_to_read < 3 {
7432                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7433                _next_ordinal_to_read += 1;
7434                next_offset += envelope_size;
7435            }
7436
7437            let next_out_of_line = decoder.next_out_of_line();
7438            let handles_before = decoder.remaining_handles();
7439            if let Some((inlined, num_bytes, num_handles)) =
7440                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7441            {
7442                let member_inline_size = <fidl::encoding::Vector<
7443                    fidl_fuchsia_images2__common::ColorSpace,
7444                    32,
7445                > as fidl::encoding::TypeMarker>::inline_size(
7446                    decoder.context
7447                );
7448                if inlined != (member_inline_size <= 4) {
7449                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7450                }
7451                let inner_offset;
7452                let mut inner_depth = depth.clone();
7453                if inlined {
7454                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7455                    inner_offset = next_offset;
7456                } else {
7457                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7458                    inner_depth.increment()?;
7459                }
7460                let val_ref =
7461                self.color_spaces.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D));
7462                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_images2__common::ColorSpace, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
7463                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7464                {
7465                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7466                }
7467                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7468                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7469                }
7470            }
7471
7472            next_offset += envelope_size;
7473            _next_ordinal_to_read += 1;
7474            if next_offset >= end_offset {
7475                return Ok(());
7476            }
7477
7478            // Decode unknown envelopes for gaps in ordinals.
7479            while _next_ordinal_to_read < 4 {
7480                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7481                _next_ordinal_to_read += 1;
7482                next_offset += envelope_size;
7483            }
7484
7485            let next_out_of_line = decoder.next_out_of_line();
7486            let handles_before = decoder.remaining_handles();
7487            if let Some((inlined, num_bytes, num_handles)) =
7488                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7489            {
7490                let member_inline_size =
7491                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7492                        decoder.context,
7493                    );
7494                if inlined != (member_inline_size <= 4) {
7495                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7496                }
7497                let inner_offset;
7498                let mut inner_depth = depth.clone();
7499                if inlined {
7500                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7501                    inner_offset = next_offset;
7502                } else {
7503                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7504                    inner_depth.increment()?;
7505                }
7506                let val_ref = self
7507                    .min_size
7508                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7509                fidl::decode!(
7510                    fidl_fuchsia_math__common::SizeU,
7511                    D,
7512                    val_ref,
7513                    decoder,
7514                    inner_offset,
7515                    inner_depth
7516                )?;
7517                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7518                {
7519                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7520                }
7521                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7522                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7523                }
7524            }
7525
7526            next_offset += envelope_size;
7527            _next_ordinal_to_read += 1;
7528            if next_offset >= end_offset {
7529                return Ok(());
7530            }
7531
7532            // Decode unknown envelopes for gaps in ordinals.
7533            while _next_ordinal_to_read < 5 {
7534                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7535                _next_ordinal_to_read += 1;
7536                next_offset += envelope_size;
7537            }
7538
7539            let next_out_of_line = decoder.next_out_of_line();
7540            let handles_before = decoder.remaining_handles();
7541            if let Some((inlined, num_bytes, num_handles)) =
7542                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7543            {
7544                let member_inline_size =
7545                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7546                        decoder.context,
7547                    );
7548                if inlined != (member_inline_size <= 4) {
7549                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7550                }
7551                let inner_offset;
7552                let mut inner_depth = depth.clone();
7553                if inlined {
7554                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7555                    inner_offset = next_offset;
7556                } else {
7557                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7558                    inner_depth.increment()?;
7559                }
7560                let val_ref = self
7561                    .max_size
7562                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7563                fidl::decode!(
7564                    fidl_fuchsia_math__common::SizeU,
7565                    D,
7566                    val_ref,
7567                    decoder,
7568                    inner_offset,
7569                    inner_depth
7570                )?;
7571                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7572                {
7573                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7574                }
7575                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7576                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7577                }
7578            }
7579
7580            next_offset += envelope_size;
7581            _next_ordinal_to_read += 1;
7582            if next_offset >= end_offset {
7583                return Ok(());
7584            }
7585
7586            // Decode unknown envelopes for gaps in ordinals.
7587            while _next_ordinal_to_read < 6 {
7588                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7589                _next_ordinal_to_read += 1;
7590                next_offset += envelope_size;
7591            }
7592
7593            let next_out_of_line = decoder.next_out_of_line();
7594            let handles_before = decoder.remaining_handles();
7595            if let Some((inlined, num_bytes, num_handles)) =
7596                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7597            {
7598                let member_inline_size =
7599                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7600                if inlined != (member_inline_size <= 4) {
7601                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7602                }
7603                let inner_offset;
7604                let mut inner_depth = depth.clone();
7605                if inlined {
7606                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7607                    inner_offset = next_offset;
7608                } else {
7609                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7610                    inner_depth.increment()?;
7611                }
7612                let val_ref =
7613                    self.min_bytes_per_row.get_or_insert_with(|| fidl::new_empty!(u32, D));
7614                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7615                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7616                {
7617                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7618                }
7619                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7620                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7621                }
7622            }
7623
7624            next_offset += envelope_size;
7625            _next_ordinal_to_read += 1;
7626            if next_offset >= end_offset {
7627                return Ok(());
7628            }
7629
7630            // Decode unknown envelopes for gaps in ordinals.
7631            while _next_ordinal_to_read < 7 {
7632                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7633                _next_ordinal_to_read += 1;
7634                next_offset += envelope_size;
7635            }
7636
7637            let next_out_of_line = decoder.next_out_of_line();
7638            let handles_before = decoder.remaining_handles();
7639            if let Some((inlined, num_bytes, num_handles)) =
7640                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7641            {
7642                let member_inline_size =
7643                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7644                if inlined != (member_inline_size <= 4) {
7645                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7646                }
7647                let inner_offset;
7648                let mut inner_depth = depth.clone();
7649                if inlined {
7650                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7651                    inner_offset = next_offset;
7652                } else {
7653                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7654                    inner_depth.increment()?;
7655                }
7656                let val_ref =
7657                    self.max_bytes_per_row.get_or_insert_with(|| fidl::new_empty!(u32, D));
7658                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7659                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7660                {
7661                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7662                }
7663                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7664                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7665                }
7666            }
7667
7668            next_offset += envelope_size;
7669            _next_ordinal_to_read += 1;
7670            if next_offset >= end_offset {
7671                return Ok(());
7672            }
7673
7674            // Decode unknown envelopes for gaps in ordinals.
7675            while _next_ordinal_to_read < 8 {
7676                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7677                _next_ordinal_to_read += 1;
7678                next_offset += envelope_size;
7679            }
7680
7681            let next_out_of_line = decoder.next_out_of_line();
7682            let handles_before = decoder.remaining_handles();
7683            if let Some((inlined, num_bytes, num_handles)) =
7684                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7685            {
7686                let member_inline_size =
7687                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7688                if inlined != (member_inline_size <= 4) {
7689                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7690                }
7691                let inner_offset;
7692                let mut inner_depth = depth.clone();
7693                if inlined {
7694                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7695                    inner_offset = next_offset;
7696                } else {
7697                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7698                    inner_depth.increment()?;
7699                }
7700                let val_ref =
7701                    self.max_width_times_height.get_or_insert_with(|| fidl::new_empty!(u64, D));
7702                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
7703                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7704                {
7705                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7706                }
7707                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7708                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7709                }
7710            }
7711
7712            next_offset += envelope_size;
7713            _next_ordinal_to_read += 1;
7714            if next_offset >= end_offset {
7715                return Ok(());
7716            }
7717
7718            // Decode unknown envelopes for gaps in ordinals.
7719            while _next_ordinal_to_read < 9 {
7720                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7721                _next_ordinal_to_read += 1;
7722                next_offset += envelope_size;
7723            }
7724
7725            let next_out_of_line = decoder.next_out_of_line();
7726            let handles_before = decoder.remaining_handles();
7727            if let Some((inlined, num_bytes, num_handles)) =
7728                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7729            {
7730                let member_inline_size =
7731                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7732                        decoder.context,
7733                    );
7734                if inlined != (member_inline_size <= 4) {
7735                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7736                }
7737                let inner_offset;
7738                let mut inner_depth = depth.clone();
7739                if inlined {
7740                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7741                    inner_offset = next_offset;
7742                } else {
7743                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7744                    inner_depth.increment()?;
7745                }
7746                let val_ref = self
7747                    .size_alignment
7748                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7749                fidl::decode!(
7750                    fidl_fuchsia_math__common::SizeU,
7751                    D,
7752                    val_ref,
7753                    decoder,
7754                    inner_offset,
7755                    inner_depth
7756                )?;
7757                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7758                {
7759                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7760                }
7761                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7762                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7763                }
7764            }
7765
7766            next_offset += envelope_size;
7767            _next_ordinal_to_read += 1;
7768            if next_offset >= end_offset {
7769                return Ok(());
7770            }
7771
7772            // Decode unknown envelopes for gaps in ordinals.
7773            while _next_ordinal_to_read < 10 {
7774                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7775                _next_ordinal_to_read += 1;
7776                next_offset += envelope_size;
7777            }
7778
7779            let next_out_of_line = decoder.next_out_of_line();
7780            let handles_before = decoder.remaining_handles();
7781            if let Some((inlined, num_bytes, num_handles)) =
7782                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7783            {
7784                let member_inline_size =
7785                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7786                        decoder.context,
7787                    );
7788                if inlined != (member_inline_size <= 4) {
7789                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7790                }
7791                let inner_offset;
7792                let mut inner_depth = depth.clone();
7793                if inlined {
7794                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7795                    inner_offset = next_offset;
7796                } else {
7797                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7798                    inner_depth.increment()?;
7799                }
7800                let val_ref = self
7801                    .display_rect_alignment
7802                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7803                fidl::decode!(
7804                    fidl_fuchsia_math__common::SizeU,
7805                    D,
7806                    val_ref,
7807                    decoder,
7808                    inner_offset,
7809                    inner_depth
7810                )?;
7811                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7812                {
7813                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7814                }
7815                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7816                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7817                }
7818            }
7819
7820            next_offset += envelope_size;
7821            _next_ordinal_to_read += 1;
7822            if next_offset >= end_offset {
7823                return Ok(());
7824            }
7825
7826            // Decode unknown envelopes for gaps in ordinals.
7827            while _next_ordinal_to_read < 11 {
7828                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7829                _next_ordinal_to_read += 1;
7830                next_offset += envelope_size;
7831            }
7832
7833            let next_out_of_line = decoder.next_out_of_line();
7834            let handles_before = decoder.remaining_handles();
7835            if let Some((inlined, num_bytes, num_handles)) =
7836                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7837            {
7838                let member_inline_size =
7839                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7840                        decoder.context,
7841                    );
7842                if inlined != (member_inline_size <= 4) {
7843                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7844                }
7845                let inner_offset;
7846                let mut inner_depth = depth.clone();
7847                if inlined {
7848                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7849                    inner_offset = next_offset;
7850                } else {
7851                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7852                    inner_depth.increment()?;
7853                }
7854                let val_ref = self
7855                    .required_min_size
7856                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7857                fidl::decode!(
7858                    fidl_fuchsia_math__common::SizeU,
7859                    D,
7860                    val_ref,
7861                    decoder,
7862                    inner_offset,
7863                    inner_depth
7864                )?;
7865                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7866                {
7867                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7868                }
7869                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7870                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7871                }
7872            }
7873
7874            next_offset += envelope_size;
7875            _next_ordinal_to_read += 1;
7876            if next_offset >= end_offset {
7877                return Ok(());
7878            }
7879
7880            // Decode unknown envelopes for gaps in ordinals.
7881            while _next_ordinal_to_read < 12 {
7882                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7883                _next_ordinal_to_read += 1;
7884                next_offset += envelope_size;
7885            }
7886
7887            let next_out_of_line = decoder.next_out_of_line();
7888            let handles_before = decoder.remaining_handles();
7889            if let Some((inlined, num_bytes, num_handles)) =
7890                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7891            {
7892                let member_inline_size =
7893                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7894                        decoder.context,
7895                    );
7896                if inlined != (member_inline_size <= 4) {
7897                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7898                }
7899                let inner_offset;
7900                let mut inner_depth = depth.clone();
7901                if inlined {
7902                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7903                    inner_offset = next_offset;
7904                } else {
7905                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7906                    inner_depth.increment()?;
7907                }
7908                let val_ref = self
7909                    .required_max_size
7910                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
7911                fidl::decode!(
7912                    fidl_fuchsia_math__common::SizeU,
7913                    D,
7914                    val_ref,
7915                    decoder,
7916                    inner_offset,
7917                    inner_depth
7918                )?;
7919                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7920                {
7921                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7922                }
7923                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7924                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7925                }
7926            }
7927
7928            next_offset += envelope_size;
7929            _next_ordinal_to_read += 1;
7930            if next_offset >= end_offset {
7931                return Ok(());
7932            }
7933
7934            // Decode unknown envelopes for gaps in ordinals.
7935            while _next_ordinal_to_read < 13 {
7936                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7937                _next_ordinal_to_read += 1;
7938                next_offset += envelope_size;
7939            }
7940
7941            let next_out_of_line = decoder.next_out_of_line();
7942            let handles_before = decoder.remaining_handles();
7943            if let Some((inlined, num_bytes, num_handles)) =
7944                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7945            {
7946                let member_inline_size =
7947                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7948                if inlined != (member_inline_size <= 4) {
7949                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7950                }
7951                let inner_offset;
7952                let mut inner_depth = depth.clone();
7953                if inlined {
7954                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7955                    inner_offset = next_offset;
7956                } else {
7957                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7958                    inner_depth.increment()?;
7959                }
7960                let val_ref =
7961                    self.bytes_per_row_divisor.get_or_insert_with(|| fidl::new_empty!(u32, D));
7962                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7963                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7964                {
7965                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7966                }
7967                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7968                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7969                }
7970            }
7971
7972            next_offset += envelope_size;
7973            _next_ordinal_to_read += 1;
7974            if next_offset >= end_offset {
7975                return Ok(());
7976            }
7977
7978            // Decode unknown envelopes for gaps in ordinals.
7979            while _next_ordinal_to_read < 14 {
7980                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7981                _next_ordinal_to_read += 1;
7982                next_offset += envelope_size;
7983            }
7984
7985            let next_out_of_line = decoder.next_out_of_line();
7986            let handles_before = decoder.remaining_handles();
7987            if let Some((inlined, num_bytes, num_handles)) =
7988                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7989            {
7990                let member_inline_size =
7991                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7992                if inlined != (member_inline_size <= 4) {
7993                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7994                }
7995                let inner_offset;
7996                let mut inner_depth = depth.clone();
7997                if inlined {
7998                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7999                    inner_offset = next_offset;
8000                } else {
8001                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8002                    inner_depth.increment()?;
8003                }
8004                let val_ref =
8005                    self.start_offset_divisor.get_or_insert_with(|| fidl::new_empty!(u32, D));
8006                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
8007                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8008                {
8009                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8010                }
8011                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8012                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8013                }
8014            }
8015
8016            next_offset += envelope_size;
8017            _next_ordinal_to_read += 1;
8018            if next_offset >= end_offset {
8019                return Ok(());
8020            }
8021
8022            // Decode unknown envelopes for gaps in ordinals.
8023            while _next_ordinal_to_read < 15 {
8024                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8025                _next_ordinal_to_read += 1;
8026                next_offset += envelope_size;
8027            }
8028
8029            let next_out_of_line = decoder.next_out_of_line();
8030            let handles_before = decoder.remaining_handles();
8031            if let Some((inlined, num_bytes, num_handles)) =
8032                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8033            {
8034                let member_inline_size = <fidl::encoding::Vector<PixelFormatAndModifier, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8035                if inlined != (member_inline_size <= 4) {
8036                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8037                }
8038                let inner_offset;
8039                let mut inner_depth = depth.clone();
8040                if inlined {
8041                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8042                    inner_offset = next_offset;
8043                } else {
8044                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8045                    inner_depth.increment()?;
8046                }
8047                let val_ref = self.pixel_format_and_modifiers.get_or_insert_with(
8048                    || fidl::new_empty!(fidl::encoding::Vector<PixelFormatAndModifier, 64>, D),
8049                );
8050                fidl::decode!(fidl::encoding::Vector<PixelFormatAndModifier, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
8051                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8052                {
8053                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8054                }
8055                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8056                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8057                }
8058            }
8059
8060            next_offset += envelope_size;
8061            _next_ordinal_to_read += 1;
8062            if next_offset >= end_offset {
8063                return Ok(());
8064            }
8065
8066            // Decode unknown envelopes for gaps in ordinals.
8067            while _next_ordinal_to_read < 16 {
8068                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8069                _next_ordinal_to_read += 1;
8070                next_offset += envelope_size;
8071            }
8072
8073            let next_out_of_line = decoder.next_out_of_line();
8074            let handles_before = decoder.remaining_handles();
8075            if let Some((inlined, num_bytes, num_handles)) =
8076                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8077            {
8078                let member_inline_size =
8079                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8080                if inlined != (member_inline_size <= 4) {
8081                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8082                }
8083                let inner_offset;
8084                let mut inner_depth = depth.clone();
8085                if inlined {
8086                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8087                    inner_offset = next_offset;
8088                } else {
8089                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8090                    inner_depth.increment()?;
8091                }
8092                let val_ref = self
8093                    .require_bytes_per_row_at_pixel_boundary
8094                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
8095                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
8096                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8097                {
8098                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8099                }
8100                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8101                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8102                }
8103            }
8104
8105            next_offset += envelope_size;
8106            _next_ordinal_to_read += 1;
8107            if next_offset >= end_offset {
8108                return Ok(());
8109            }
8110
8111            // Decode unknown envelopes for gaps in ordinals.
8112            while _next_ordinal_to_read < 17 {
8113                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8114                _next_ordinal_to_read += 1;
8115                next_offset += envelope_size;
8116            }
8117
8118            let next_out_of_line = decoder.next_out_of_line();
8119            let handles_before = decoder.remaining_handles();
8120            if let Some((inlined, num_bytes, num_handles)) =
8121                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8122            {
8123                let member_inline_size =
8124                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8125                if inlined != (member_inline_size <= 4) {
8126                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8127                }
8128                let inner_offset;
8129                let mut inner_depth = depth.clone();
8130                if inlined {
8131                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8132                    inner_offset = next_offset;
8133                } else {
8134                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8135                    inner_depth.increment()?;
8136                }
8137                let val_ref =
8138                    self.is_alpha_present.get_or_insert_with(|| fidl::new_empty!(bool, D));
8139                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
8140                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8141                {
8142                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8143                }
8144                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8145                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8146                }
8147            }
8148
8149            next_offset += envelope_size;
8150            _next_ordinal_to_read += 1;
8151            if next_offset >= end_offset {
8152                return Ok(());
8153            }
8154
8155            // Decode unknown envelopes for gaps in ordinals.
8156            while _next_ordinal_to_read < 18 {
8157                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8158                _next_ordinal_to_read += 1;
8159                next_offset += envelope_size;
8160            }
8161
8162            let next_out_of_line = decoder.next_out_of_line();
8163            let handles_before = decoder.remaining_handles();
8164            if let Some((inlined, num_bytes, num_handles)) =
8165                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8166            {
8167                let member_inline_size = <fidl::encoding::Vector<
8168                    fidl_fuchsia_math__common::SizeU,
8169                    64,
8170                > as fidl::encoding::TypeMarker>::inline_size(
8171                    decoder.context
8172                );
8173                if inlined != (member_inline_size <= 4) {
8174                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8175                }
8176                let inner_offset;
8177                let mut inner_depth = depth.clone();
8178                if inlined {
8179                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8180                    inner_offset = next_offset;
8181                } else {
8182                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8183                    inner_depth.increment()?;
8184                }
8185                let val_ref =
8186                self.required_max_size_list.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D));
8187                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_math__common::SizeU, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
8188                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8189                {
8190                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8191                }
8192                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8193                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8194                }
8195            }
8196
8197            next_offset += envelope_size;
8198            _next_ordinal_to_read += 1;
8199            if next_offset >= end_offset {
8200                return Ok(());
8201            }
8202
8203            // Decode unknown envelopes for gaps in ordinals.
8204            while _next_ordinal_to_read < 19 {
8205                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8206                _next_ordinal_to_read += 1;
8207                next_offset += envelope_size;
8208            }
8209
8210            let next_out_of_line = decoder.next_out_of_line();
8211            let handles_before = decoder.remaining_handles();
8212            if let Some((inlined, num_bytes, num_handles)) =
8213                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8214            {
8215                let member_inline_size =
8216                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
8217                        decoder.context,
8218                    );
8219                if inlined != (member_inline_size <= 4) {
8220                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8221                }
8222                let inner_offset;
8223                let mut inner_depth = depth.clone();
8224                if inlined {
8225                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8226                    inner_offset = next_offset;
8227                } else {
8228                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8229                    inner_depth.increment()?;
8230                }
8231                let val_ref = self
8232                    .pad_for_block_size
8233                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
8234                fidl::decode!(
8235                    fidl_fuchsia_math__common::SizeU,
8236                    D,
8237                    val_ref,
8238                    decoder,
8239                    inner_offset,
8240                    inner_depth
8241                )?;
8242                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8243                {
8244                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8245                }
8246                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8247                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8248                }
8249            }
8250
8251            next_offset += envelope_size;
8252            _next_ordinal_to_read += 1;
8253            if next_offset >= end_offset {
8254                return Ok(());
8255            }
8256
8257            // Decode unknown envelopes for gaps in ordinals.
8258            while _next_ordinal_to_read < 20 {
8259                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8260                _next_ordinal_to_read += 1;
8261                next_offset += envelope_size;
8262            }
8263
8264            let next_out_of_line = decoder.next_out_of_line();
8265            let handles_before = decoder.remaining_handles();
8266            if let Some((inlined, num_bytes, num_handles)) =
8267                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8268            {
8269                let member_inline_size =
8270                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8271                if inlined != (member_inline_size <= 4) {
8272                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8273                }
8274                let inner_offset;
8275                let mut inner_depth = depth.clone();
8276                if inlined {
8277                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8278                    inner_offset = next_offset;
8279                } else {
8280                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8281                    inner_depth.increment()?;
8282                }
8283                let val_ref = self
8284                    .pad_beyond_image_size_bytes
8285                    .get_or_insert_with(|| fidl::new_empty!(u64, D));
8286                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
8287                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8288                {
8289                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8290                }
8291                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8292                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8293                }
8294            }
8295
8296            next_offset += envelope_size;
8297
8298            // Decode the remaining unknown envelopes.
8299            while next_offset < end_offset {
8300                _next_ordinal_to_read += 1;
8301                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8302                next_offset += envelope_size;
8303            }
8304
8305            Ok(())
8306        }
8307    }
8308
8309    impl NodeSetDebugClientInfoRequest {
8310        #[inline(always)]
8311        fn max_ordinal_present(&self) -> u64 {
8312            if let Some(_) = self.id {
8313                return 2;
8314            }
8315            if let Some(_) = self.name {
8316                return 1;
8317            }
8318            0
8319        }
8320    }
8321
8322    impl fidl::encoding::ValueTypeMarker for NodeSetDebugClientInfoRequest {
8323        type Borrowed<'a> = &'a Self;
8324        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8325            value
8326        }
8327    }
8328
8329    unsafe impl fidl::encoding::TypeMarker for NodeSetDebugClientInfoRequest {
8330        type Owned = Self;
8331
8332        #[inline(always)]
8333        fn inline_align(_context: fidl::encoding::Context) -> usize {
8334            8
8335        }
8336
8337        #[inline(always)]
8338        fn inline_size(_context: fidl::encoding::Context) -> usize {
8339            16
8340        }
8341    }
8342
8343    unsafe impl<D: fidl::encoding::ResourceDialect>
8344        fidl::encoding::Encode<NodeSetDebugClientInfoRequest, D>
8345        for &NodeSetDebugClientInfoRequest
8346    {
8347        unsafe fn encode(
8348            self,
8349            encoder: &mut fidl::encoding::Encoder<'_, D>,
8350            offset: usize,
8351            mut depth: fidl::encoding::Depth,
8352        ) -> fidl::Result<()> {
8353            encoder.debug_check_bounds::<NodeSetDebugClientInfoRequest>(offset);
8354            // Vector header
8355            let max_ordinal: u64 = self.max_ordinal_present();
8356            encoder.write_num(max_ordinal, offset);
8357            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8358            // Calling encoder.out_of_line_offset(0) is not allowed.
8359            if max_ordinal == 0 {
8360                return Ok(());
8361            }
8362            depth.increment()?;
8363            let envelope_size = 8;
8364            let bytes_len = max_ordinal as usize * envelope_size;
8365            #[allow(unused_variables)]
8366            let offset = encoder.out_of_line_offset(bytes_len);
8367            let mut _prev_end_offset: usize = 0;
8368            if 1 > max_ordinal {
8369                return Ok(());
8370            }
8371
8372            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8373            // are envelope_size bytes.
8374            let cur_offset: usize = (1 - 1) * envelope_size;
8375
8376            // Zero reserved fields.
8377            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8378
8379            // Safety:
8380            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8381            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8382            //   envelope_size bytes, there is always sufficient room.
8383            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
8384                self.name.as_ref().map(
8385                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
8386                ),
8387                encoder,
8388                offset + cur_offset,
8389                depth,
8390            )?;
8391
8392            _prev_end_offset = cur_offset + envelope_size;
8393            if 2 > max_ordinal {
8394                return Ok(());
8395            }
8396
8397            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8398            // are envelope_size bytes.
8399            let cur_offset: usize = (2 - 1) * envelope_size;
8400
8401            // Zero reserved fields.
8402            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8403
8404            // Safety:
8405            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8406            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8407            //   envelope_size bytes, there is always sufficient room.
8408            fidl::encoding::encode_in_envelope_optional::<u64, D>(
8409                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8410                encoder,
8411                offset + cur_offset,
8412                depth,
8413            )?;
8414
8415            _prev_end_offset = cur_offset + envelope_size;
8416
8417            Ok(())
8418        }
8419    }
8420
8421    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8422        for NodeSetDebugClientInfoRequest
8423    {
8424        #[inline(always)]
8425        fn new_empty() -> Self {
8426            Self::default()
8427        }
8428
8429        unsafe fn decode(
8430            &mut self,
8431            decoder: &mut fidl::encoding::Decoder<'_, D>,
8432            offset: usize,
8433            mut depth: fidl::encoding::Depth,
8434        ) -> fidl::Result<()> {
8435            decoder.debug_check_bounds::<Self>(offset);
8436            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8437                None => return Err(fidl::Error::NotNullable),
8438                Some(len) => len,
8439            };
8440            // Calling decoder.out_of_line_offset(0) is not allowed.
8441            if len == 0 {
8442                return Ok(());
8443            };
8444            depth.increment()?;
8445            let envelope_size = 8;
8446            let bytes_len = len * envelope_size;
8447            let offset = decoder.out_of_line_offset(bytes_len)?;
8448            // Decode the envelope for each type.
8449            let mut _next_ordinal_to_read = 0;
8450            let mut next_offset = offset;
8451            let end_offset = offset + bytes_len;
8452            _next_ordinal_to_read += 1;
8453            if next_offset >= end_offset {
8454                return Ok(());
8455            }
8456
8457            // Decode unknown envelopes for gaps in ordinals.
8458            while _next_ordinal_to_read < 1 {
8459                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8460                _next_ordinal_to_read += 1;
8461                next_offset += envelope_size;
8462            }
8463
8464            let next_out_of_line = decoder.next_out_of_line();
8465            let handles_before = decoder.remaining_handles();
8466            if let Some((inlined, num_bytes, num_handles)) =
8467                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8468            {
8469                let member_inline_size =
8470                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
8471                        decoder.context,
8472                    );
8473                if inlined != (member_inline_size <= 4) {
8474                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8475                }
8476                let inner_offset;
8477                let mut inner_depth = depth.clone();
8478                if inlined {
8479                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8480                    inner_offset = next_offset;
8481                } else {
8482                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8483                    inner_depth.increment()?;
8484                }
8485                let val_ref = self
8486                    .name
8487                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
8488                fidl::decode!(
8489                    fidl::encoding::BoundedString<256>,
8490                    D,
8491                    val_ref,
8492                    decoder,
8493                    inner_offset,
8494                    inner_depth
8495                )?;
8496                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8497                {
8498                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8499                }
8500                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8501                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8502                }
8503            }
8504
8505            next_offset += envelope_size;
8506            _next_ordinal_to_read += 1;
8507            if next_offset >= end_offset {
8508                return Ok(());
8509            }
8510
8511            // Decode unknown envelopes for gaps in ordinals.
8512            while _next_ordinal_to_read < 2 {
8513                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8514                _next_ordinal_to_read += 1;
8515                next_offset += envelope_size;
8516            }
8517
8518            let next_out_of_line = decoder.next_out_of_line();
8519            let handles_before = decoder.remaining_handles();
8520            if let Some((inlined, num_bytes, num_handles)) =
8521                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8522            {
8523                let member_inline_size =
8524                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8525                if inlined != (member_inline_size <= 4) {
8526                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8527                }
8528                let inner_offset;
8529                let mut inner_depth = depth.clone();
8530                if inlined {
8531                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8532                    inner_offset = next_offset;
8533                } else {
8534                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8535                    inner_depth.increment()?;
8536                }
8537                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
8538                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
8539                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8540                {
8541                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8542                }
8543                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8544                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8545                }
8546            }
8547
8548            next_offset += envelope_size;
8549
8550            // Decode the remaining unknown envelopes.
8551            while next_offset < end_offset {
8552                _next_ordinal_to_read += 1;
8553                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8554                next_offset += envelope_size;
8555            }
8556
8557            Ok(())
8558        }
8559    }
8560
8561    impl NodeSetDebugTimeoutLogDeadlineRequest {
8562        #[inline(always)]
8563        fn max_ordinal_present(&self) -> u64 {
8564            if let Some(_) = self.deadline {
8565                return 1;
8566            }
8567            0
8568        }
8569    }
8570
8571    impl fidl::encoding::ValueTypeMarker for NodeSetDebugTimeoutLogDeadlineRequest {
8572        type Borrowed<'a> = &'a Self;
8573        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8574            value
8575        }
8576    }
8577
8578    unsafe impl fidl::encoding::TypeMarker for NodeSetDebugTimeoutLogDeadlineRequest {
8579        type Owned = Self;
8580
8581        #[inline(always)]
8582        fn inline_align(_context: fidl::encoding::Context) -> usize {
8583            8
8584        }
8585
8586        #[inline(always)]
8587        fn inline_size(_context: fidl::encoding::Context) -> usize {
8588            16
8589        }
8590    }
8591
8592    unsafe impl<D: fidl::encoding::ResourceDialect>
8593        fidl::encoding::Encode<NodeSetDebugTimeoutLogDeadlineRequest, D>
8594        for &NodeSetDebugTimeoutLogDeadlineRequest
8595    {
8596        unsafe fn encode(
8597            self,
8598            encoder: &mut fidl::encoding::Encoder<'_, D>,
8599            offset: usize,
8600            mut depth: fidl::encoding::Depth,
8601        ) -> fidl::Result<()> {
8602            encoder.debug_check_bounds::<NodeSetDebugTimeoutLogDeadlineRequest>(offset);
8603            // Vector header
8604            let max_ordinal: u64 = self.max_ordinal_present();
8605            encoder.write_num(max_ordinal, offset);
8606            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8607            // Calling encoder.out_of_line_offset(0) is not allowed.
8608            if max_ordinal == 0 {
8609                return Ok(());
8610            }
8611            depth.increment()?;
8612            let envelope_size = 8;
8613            let bytes_len = max_ordinal as usize * envelope_size;
8614            #[allow(unused_variables)]
8615            let offset = encoder.out_of_line_offset(bytes_len);
8616            let mut _prev_end_offset: usize = 0;
8617            if 1 > max_ordinal {
8618                return Ok(());
8619            }
8620
8621            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8622            // are envelope_size bytes.
8623            let cur_offset: usize = (1 - 1) * envelope_size;
8624
8625            // Zero reserved fields.
8626            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8627
8628            // Safety:
8629            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8630            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8631            //   envelope_size bytes, there is always sufficient room.
8632            fidl::encoding::encode_in_envelope_optional::<i64, D>(
8633                self.deadline.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
8634                encoder,
8635                offset + cur_offset,
8636                depth,
8637            )?;
8638
8639            _prev_end_offset = cur_offset + envelope_size;
8640
8641            Ok(())
8642        }
8643    }
8644
8645    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8646        for NodeSetDebugTimeoutLogDeadlineRequest
8647    {
8648        #[inline(always)]
8649        fn new_empty() -> Self {
8650            Self::default()
8651        }
8652
8653        unsafe fn decode(
8654            &mut self,
8655            decoder: &mut fidl::encoding::Decoder<'_, D>,
8656            offset: usize,
8657            mut depth: fidl::encoding::Depth,
8658        ) -> fidl::Result<()> {
8659            decoder.debug_check_bounds::<Self>(offset);
8660            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8661                None => return Err(fidl::Error::NotNullable),
8662                Some(len) => len,
8663            };
8664            // Calling decoder.out_of_line_offset(0) is not allowed.
8665            if len == 0 {
8666                return Ok(());
8667            };
8668            depth.increment()?;
8669            let envelope_size = 8;
8670            let bytes_len = len * envelope_size;
8671            let offset = decoder.out_of_line_offset(bytes_len)?;
8672            // Decode the envelope for each type.
8673            let mut _next_ordinal_to_read = 0;
8674            let mut next_offset = offset;
8675            let end_offset = offset + bytes_len;
8676            _next_ordinal_to_read += 1;
8677            if next_offset >= end_offset {
8678                return Ok(());
8679            }
8680
8681            // Decode unknown envelopes for gaps in ordinals.
8682            while _next_ordinal_to_read < 1 {
8683                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8684                _next_ordinal_to_read += 1;
8685                next_offset += envelope_size;
8686            }
8687
8688            let next_out_of_line = decoder.next_out_of_line();
8689            let handles_before = decoder.remaining_handles();
8690            if let Some((inlined, num_bytes, num_handles)) =
8691                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8692            {
8693                let member_inline_size =
8694                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8695                if inlined != (member_inline_size <= 4) {
8696                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8697                }
8698                let inner_offset;
8699                let mut inner_depth = depth.clone();
8700                if inlined {
8701                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8702                    inner_offset = next_offset;
8703                } else {
8704                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8705                    inner_depth.increment()?;
8706                }
8707                let val_ref = self.deadline.get_or_insert_with(|| fidl::new_empty!(i64, D));
8708                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
8709                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8710                {
8711                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8712                }
8713                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8714                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8715                }
8716            }
8717
8718            next_offset += envelope_size;
8719
8720            // Decode the remaining unknown envelopes.
8721            while next_offset < end_offset {
8722                _next_ordinal_to_read += 1;
8723                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8724                next_offset += envelope_size;
8725            }
8726
8727            Ok(())
8728        }
8729    }
8730
8731    impl NodeSetNameRequest {
8732        #[inline(always)]
8733        fn max_ordinal_present(&self) -> u64 {
8734            if let Some(_) = self.name {
8735                return 2;
8736            }
8737            if let Some(_) = self.priority {
8738                return 1;
8739            }
8740            0
8741        }
8742    }
8743
8744    impl fidl::encoding::ValueTypeMarker for NodeSetNameRequest {
8745        type Borrowed<'a> = &'a Self;
8746        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8747            value
8748        }
8749    }
8750
8751    unsafe impl fidl::encoding::TypeMarker for NodeSetNameRequest {
8752        type Owned = Self;
8753
8754        #[inline(always)]
8755        fn inline_align(_context: fidl::encoding::Context) -> usize {
8756            8
8757        }
8758
8759        #[inline(always)]
8760        fn inline_size(_context: fidl::encoding::Context) -> usize {
8761            16
8762        }
8763    }
8764
8765    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NodeSetNameRequest, D>
8766        for &NodeSetNameRequest
8767    {
8768        unsafe fn encode(
8769            self,
8770            encoder: &mut fidl::encoding::Encoder<'_, D>,
8771            offset: usize,
8772            mut depth: fidl::encoding::Depth,
8773        ) -> fidl::Result<()> {
8774            encoder.debug_check_bounds::<NodeSetNameRequest>(offset);
8775            // Vector header
8776            let max_ordinal: u64 = self.max_ordinal_present();
8777            encoder.write_num(max_ordinal, offset);
8778            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8779            // Calling encoder.out_of_line_offset(0) is not allowed.
8780            if max_ordinal == 0 {
8781                return Ok(());
8782            }
8783            depth.increment()?;
8784            let envelope_size = 8;
8785            let bytes_len = max_ordinal as usize * envelope_size;
8786            #[allow(unused_variables)]
8787            let offset = encoder.out_of_line_offset(bytes_len);
8788            let mut _prev_end_offset: usize = 0;
8789            if 1 > max_ordinal {
8790                return Ok(());
8791            }
8792
8793            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8794            // are envelope_size bytes.
8795            let cur_offset: usize = (1 - 1) * envelope_size;
8796
8797            // Zero reserved fields.
8798            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8799
8800            // Safety:
8801            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8802            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8803            //   envelope_size bytes, there is always sufficient room.
8804            fidl::encoding::encode_in_envelope_optional::<u32, D>(
8805                self.priority.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
8806                encoder,
8807                offset + cur_offset,
8808                depth,
8809            )?;
8810
8811            _prev_end_offset = cur_offset + envelope_size;
8812            if 2 > max_ordinal {
8813                return Ok(());
8814            }
8815
8816            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8817            // are envelope_size bytes.
8818            let cur_offset: usize = (2 - 1) * envelope_size;
8819
8820            // Zero reserved fields.
8821            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8822
8823            // Safety:
8824            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8825            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8826            //   envelope_size bytes, there is always sufficient room.
8827            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<64>, D>(
8828                self.name.as_ref().map(
8829                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
8830                ),
8831                encoder,
8832                offset + cur_offset,
8833                depth,
8834            )?;
8835
8836            _prev_end_offset = cur_offset + envelope_size;
8837
8838            Ok(())
8839        }
8840    }
8841
8842    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NodeSetNameRequest {
8843        #[inline(always)]
8844        fn new_empty() -> Self {
8845            Self::default()
8846        }
8847
8848        unsafe fn decode(
8849            &mut self,
8850            decoder: &mut fidl::encoding::Decoder<'_, D>,
8851            offset: usize,
8852            mut depth: fidl::encoding::Depth,
8853        ) -> fidl::Result<()> {
8854            decoder.debug_check_bounds::<Self>(offset);
8855            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8856                None => return Err(fidl::Error::NotNullable),
8857                Some(len) => len,
8858            };
8859            // Calling decoder.out_of_line_offset(0) is not allowed.
8860            if len == 0 {
8861                return Ok(());
8862            };
8863            depth.increment()?;
8864            let envelope_size = 8;
8865            let bytes_len = len * envelope_size;
8866            let offset = decoder.out_of_line_offset(bytes_len)?;
8867            // Decode the envelope for each type.
8868            let mut _next_ordinal_to_read = 0;
8869            let mut next_offset = offset;
8870            let end_offset = offset + bytes_len;
8871            _next_ordinal_to_read += 1;
8872            if next_offset >= end_offset {
8873                return Ok(());
8874            }
8875
8876            // Decode unknown envelopes for gaps in ordinals.
8877            while _next_ordinal_to_read < 1 {
8878                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8879                _next_ordinal_to_read += 1;
8880                next_offset += envelope_size;
8881            }
8882
8883            let next_out_of_line = decoder.next_out_of_line();
8884            let handles_before = decoder.remaining_handles();
8885            if let Some((inlined, num_bytes, num_handles)) =
8886                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8887            {
8888                let member_inline_size =
8889                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8890                if inlined != (member_inline_size <= 4) {
8891                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8892                }
8893                let inner_offset;
8894                let mut inner_depth = depth.clone();
8895                if inlined {
8896                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8897                    inner_offset = next_offset;
8898                } else {
8899                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8900                    inner_depth.increment()?;
8901                }
8902                let val_ref = self.priority.get_or_insert_with(|| fidl::new_empty!(u32, D));
8903                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
8904                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8905                {
8906                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8907                }
8908                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8909                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8910                }
8911            }
8912
8913            next_offset += envelope_size;
8914            _next_ordinal_to_read += 1;
8915            if next_offset >= end_offset {
8916                return Ok(());
8917            }
8918
8919            // Decode unknown envelopes for gaps in ordinals.
8920            while _next_ordinal_to_read < 2 {
8921                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8922                _next_ordinal_to_read += 1;
8923                next_offset += envelope_size;
8924            }
8925
8926            let next_out_of_line = decoder.next_out_of_line();
8927            let handles_before = decoder.remaining_handles();
8928            if let Some((inlined, num_bytes, num_handles)) =
8929                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8930            {
8931                let member_inline_size =
8932                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
8933                        decoder.context,
8934                    );
8935                if inlined != (member_inline_size <= 4) {
8936                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8937                }
8938                let inner_offset;
8939                let mut inner_depth = depth.clone();
8940                if inlined {
8941                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8942                    inner_offset = next_offset;
8943                } else {
8944                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8945                    inner_depth.increment()?;
8946                }
8947                let val_ref = self
8948                    .name
8949                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<64>, D));
8950                fidl::decode!(
8951                    fidl::encoding::BoundedString<64>,
8952                    D,
8953                    val_ref,
8954                    decoder,
8955                    inner_offset,
8956                    inner_depth
8957                )?;
8958                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8959                {
8960                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8961                }
8962                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8963                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8964                }
8965            }
8966
8967            next_offset += envelope_size;
8968
8969            // Decode the remaining unknown envelopes.
8970            while next_offset < end_offset {
8971                _next_ordinal_to_read += 1;
8972                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8973                next_offset += envelope_size;
8974            }
8975
8976            Ok(())
8977        }
8978    }
8979
8980    impl NodeGetBufferCollectionIdResponse {
8981        #[inline(always)]
8982        fn max_ordinal_present(&self) -> u64 {
8983            if let Some(_) = self.buffer_collection_id {
8984                return 1;
8985            }
8986            0
8987        }
8988    }
8989
8990    impl fidl::encoding::ValueTypeMarker for NodeGetBufferCollectionIdResponse {
8991        type Borrowed<'a> = &'a Self;
8992        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8993            value
8994        }
8995    }
8996
8997    unsafe impl fidl::encoding::TypeMarker for NodeGetBufferCollectionIdResponse {
8998        type Owned = Self;
8999
9000        #[inline(always)]
9001        fn inline_align(_context: fidl::encoding::Context) -> usize {
9002            8
9003        }
9004
9005        #[inline(always)]
9006        fn inline_size(_context: fidl::encoding::Context) -> usize {
9007            16
9008        }
9009    }
9010
9011    unsafe impl<D: fidl::encoding::ResourceDialect>
9012        fidl::encoding::Encode<NodeGetBufferCollectionIdResponse, D>
9013        for &NodeGetBufferCollectionIdResponse
9014    {
9015        unsafe fn encode(
9016            self,
9017            encoder: &mut fidl::encoding::Encoder<'_, D>,
9018            offset: usize,
9019            mut depth: fidl::encoding::Depth,
9020        ) -> fidl::Result<()> {
9021            encoder.debug_check_bounds::<NodeGetBufferCollectionIdResponse>(offset);
9022            // Vector header
9023            let max_ordinal: u64 = self.max_ordinal_present();
9024            encoder.write_num(max_ordinal, offset);
9025            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9026            // Calling encoder.out_of_line_offset(0) is not allowed.
9027            if max_ordinal == 0 {
9028                return Ok(());
9029            }
9030            depth.increment()?;
9031            let envelope_size = 8;
9032            let bytes_len = max_ordinal as usize * envelope_size;
9033            #[allow(unused_variables)]
9034            let offset = encoder.out_of_line_offset(bytes_len);
9035            let mut _prev_end_offset: usize = 0;
9036            if 1 > max_ordinal {
9037                return Ok(());
9038            }
9039
9040            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9041            // are envelope_size bytes.
9042            let cur_offset: usize = (1 - 1) * envelope_size;
9043
9044            // Zero reserved fields.
9045            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9046
9047            // Safety:
9048            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9049            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9050            //   envelope_size bytes, there is always sufficient room.
9051            fidl::encoding::encode_in_envelope_optional::<u64, D>(
9052                self.buffer_collection_id
9053                    .as_ref()
9054                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9055                encoder,
9056                offset + cur_offset,
9057                depth,
9058            )?;
9059
9060            _prev_end_offset = cur_offset + envelope_size;
9061
9062            Ok(())
9063        }
9064    }
9065
9066    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9067        for NodeGetBufferCollectionIdResponse
9068    {
9069        #[inline(always)]
9070        fn new_empty() -> Self {
9071            Self::default()
9072        }
9073
9074        unsafe fn decode(
9075            &mut self,
9076            decoder: &mut fidl::encoding::Decoder<'_, D>,
9077            offset: usize,
9078            mut depth: fidl::encoding::Depth,
9079        ) -> fidl::Result<()> {
9080            decoder.debug_check_bounds::<Self>(offset);
9081            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9082                None => return Err(fidl::Error::NotNullable),
9083                Some(len) => len,
9084            };
9085            // Calling decoder.out_of_line_offset(0) is not allowed.
9086            if len == 0 {
9087                return Ok(());
9088            };
9089            depth.increment()?;
9090            let envelope_size = 8;
9091            let bytes_len = len * envelope_size;
9092            let offset = decoder.out_of_line_offset(bytes_len)?;
9093            // Decode the envelope for each type.
9094            let mut _next_ordinal_to_read = 0;
9095            let mut next_offset = offset;
9096            let end_offset = offset + bytes_len;
9097            _next_ordinal_to_read += 1;
9098            if next_offset >= end_offset {
9099                return Ok(());
9100            }
9101
9102            // Decode unknown envelopes for gaps in ordinals.
9103            while _next_ordinal_to_read < 1 {
9104                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9105                _next_ordinal_to_read += 1;
9106                next_offset += envelope_size;
9107            }
9108
9109            let next_out_of_line = decoder.next_out_of_line();
9110            let handles_before = decoder.remaining_handles();
9111            if let Some((inlined, num_bytes, num_handles)) =
9112                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9113            {
9114                let member_inline_size =
9115                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9116                if inlined != (member_inline_size <= 4) {
9117                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9118                }
9119                let inner_offset;
9120                let mut inner_depth = depth.clone();
9121                if inlined {
9122                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9123                    inner_offset = next_offset;
9124                } else {
9125                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9126                    inner_depth.increment()?;
9127                }
9128                let val_ref =
9129                    self.buffer_collection_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
9130                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
9131                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9132                {
9133                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9134                }
9135                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9136                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9137                }
9138            }
9139
9140            next_offset += envelope_size;
9141
9142            // Decode the remaining unknown envelopes.
9143            while next_offset < end_offset {
9144                _next_ordinal_to_read += 1;
9145                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9146                next_offset += envelope_size;
9147            }
9148
9149            Ok(())
9150        }
9151    }
9152
9153    impl NodeIsAlternateForResponse {
9154        #[inline(always)]
9155        fn max_ordinal_present(&self) -> u64 {
9156            if let Some(_) = self.is_alternate {
9157                return 1;
9158            }
9159            0
9160        }
9161    }
9162
9163    impl fidl::encoding::ValueTypeMarker for NodeIsAlternateForResponse {
9164        type Borrowed<'a> = &'a Self;
9165        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9166            value
9167        }
9168    }
9169
9170    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForResponse {
9171        type Owned = Self;
9172
9173        #[inline(always)]
9174        fn inline_align(_context: fidl::encoding::Context) -> usize {
9175            8
9176        }
9177
9178        #[inline(always)]
9179        fn inline_size(_context: fidl::encoding::Context) -> usize {
9180            16
9181        }
9182    }
9183
9184    unsafe impl<D: fidl::encoding::ResourceDialect>
9185        fidl::encoding::Encode<NodeIsAlternateForResponse, D> for &NodeIsAlternateForResponse
9186    {
9187        unsafe fn encode(
9188            self,
9189            encoder: &mut fidl::encoding::Encoder<'_, D>,
9190            offset: usize,
9191            mut depth: fidl::encoding::Depth,
9192        ) -> fidl::Result<()> {
9193            encoder.debug_check_bounds::<NodeIsAlternateForResponse>(offset);
9194            // Vector header
9195            let max_ordinal: u64 = self.max_ordinal_present();
9196            encoder.write_num(max_ordinal, offset);
9197            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9198            // Calling encoder.out_of_line_offset(0) is not allowed.
9199            if max_ordinal == 0 {
9200                return Ok(());
9201            }
9202            depth.increment()?;
9203            let envelope_size = 8;
9204            let bytes_len = max_ordinal as usize * envelope_size;
9205            #[allow(unused_variables)]
9206            let offset = encoder.out_of_line_offset(bytes_len);
9207            let mut _prev_end_offset: usize = 0;
9208            if 1 > max_ordinal {
9209                return Ok(());
9210            }
9211
9212            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9213            // are envelope_size bytes.
9214            let cur_offset: usize = (1 - 1) * envelope_size;
9215
9216            // Zero reserved fields.
9217            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9218
9219            // Safety:
9220            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9221            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9222            //   envelope_size bytes, there is always sufficient room.
9223            fidl::encoding::encode_in_envelope_optional::<bool, D>(
9224                self.is_alternate.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
9225                encoder,
9226                offset + cur_offset,
9227                depth,
9228            )?;
9229
9230            _prev_end_offset = cur_offset + envelope_size;
9231
9232            Ok(())
9233        }
9234    }
9235
9236    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9237        for NodeIsAlternateForResponse
9238    {
9239        #[inline(always)]
9240        fn new_empty() -> Self {
9241            Self::default()
9242        }
9243
9244        unsafe fn decode(
9245            &mut self,
9246            decoder: &mut fidl::encoding::Decoder<'_, D>,
9247            offset: usize,
9248            mut depth: fidl::encoding::Depth,
9249        ) -> fidl::Result<()> {
9250            decoder.debug_check_bounds::<Self>(offset);
9251            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9252                None => return Err(fidl::Error::NotNullable),
9253                Some(len) => len,
9254            };
9255            // Calling decoder.out_of_line_offset(0) is not allowed.
9256            if len == 0 {
9257                return Ok(());
9258            };
9259            depth.increment()?;
9260            let envelope_size = 8;
9261            let bytes_len = len * envelope_size;
9262            let offset = decoder.out_of_line_offset(bytes_len)?;
9263            // Decode the envelope for each type.
9264            let mut _next_ordinal_to_read = 0;
9265            let mut next_offset = offset;
9266            let end_offset = offset + bytes_len;
9267            _next_ordinal_to_read += 1;
9268            if next_offset >= end_offset {
9269                return Ok(());
9270            }
9271
9272            // Decode unknown envelopes for gaps in ordinals.
9273            while _next_ordinal_to_read < 1 {
9274                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9275                _next_ordinal_to_read += 1;
9276                next_offset += envelope_size;
9277            }
9278
9279            let next_out_of_line = decoder.next_out_of_line();
9280            let handles_before = decoder.remaining_handles();
9281            if let Some((inlined, num_bytes, num_handles)) =
9282                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9283            {
9284                let member_inline_size =
9285                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9286                if inlined != (member_inline_size <= 4) {
9287                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9288                }
9289                let inner_offset;
9290                let mut inner_depth = depth.clone();
9291                if inlined {
9292                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9293                    inner_offset = next_offset;
9294                } else {
9295                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9296                    inner_depth.increment()?;
9297                }
9298                let val_ref = self.is_alternate.get_or_insert_with(|| fidl::new_empty!(bool, D));
9299                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
9300                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9301                {
9302                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9303                }
9304                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9305                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9306                }
9307            }
9308
9309            next_offset += envelope_size;
9310
9311            // Decode the remaining unknown envelopes.
9312            while next_offset < end_offset {
9313                _next_ordinal_to_read += 1;
9314                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9315                next_offset += envelope_size;
9316            }
9317
9318            Ok(())
9319        }
9320    }
9321
9322    impl SecureHeapAndRange {
9323        #[inline(always)]
9324        fn max_ordinal_present(&self) -> u64 {
9325            if let Some(_) = self.range {
9326                return 2;
9327            }
9328            if let Some(_) = self.heap {
9329                return 1;
9330            }
9331            0
9332        }
9333    }
9334
9335    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRange {
9336        type Borrowed<'a> = &'a Self;
9337        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9338            value
9339        }
9340    }
9341
9342    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRange {
9343        type Owned = Self;
9344
9345        #[inline(always)]
9346        fn inline_align(_context: fidl::encoding::Context) -> usize {
9347            8
9348        }
9349
9350        #[inline(always)]
9351        fn inline_size(_context: fidl::encoding::Context) -> usize {
9352            16
9353        }
9354    }
9355
9356    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapAndRange, D>
9357        for &SecureHeapAndRange
9358    {
9359        unsafe fn encode(
9360            self,
9361            encoder: &mut fidl::encoding::Encoder<'_, D>,
9362            offset: usize,
9363            mut depth: fidl::encoding::Depth,
9364        ) -> fidl::Result<()> {
9365            encoder.debug_check_bounds::<SecureHeapAndRange>(offset);
9366            // Vector header
9367            let max_ordinal: u64 = self.max_ordinal_present();
9368            encoder.write_num(max_ordinal, offset);
9369            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9370            // Calling encoder.out_of_line_offset(0) is not allowed.
9371            if max_ordinal == 0 {
9372                return Ok(());
9373            }
9374            depth.increment()?;
9375            let envelope_size = 8;
9376            let bytes_len = max_ordinal as usize * envelope_size;
9377            #[allow(unused_variables)]
9378            let offset = encoder.out_of_line_offset(bytes_len);
9379            let mut _prev_end_offset: usize = 0;
9380            if 1 > max_ordinal {
9381                return Ok(());
9382            }
9383
9384            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9385            // are envelope_size bytes.
9386            let cur_offset: usize = (1 - 1) * envelope_size;
9387
9388            // Zero reserved fields.
9389            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9390
9391            // Safety:
9392            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9393            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9394            //   envelope_size bytes, there is always sufficient room.
9395            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9396                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9397                encoder,
9398                offset + cur_offset,
9399                depth,
9400            )?;
9401
9402            _prev_end_offset = cur_offset + envelope_size;
9403            if 2 > max_ordinal {
9404                return Ok(());
9405            }
9406
9407            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9408            // are envelope_size bytes.
9409            let cur_offset: usize = (2 - 1) * envelope_size;
9410
9411            // Zero reserved fields.
9412            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9413
9414            // Safety:
9415            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9416            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9417            //   envelope_size bytes, there is always sufficient room.
9418            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9419                self.range
9420                    .as_ref()
9421                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9422                encoder,
9423                offset + cur_offset,
9424                depth,
9425            )?;
9426
9427            _prev_end_offset = cur_offset + envelope_size;
9428
9429            Ok(())
9430        }
9431    }
9432
9433    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapAndRange {
9434        #[inline(always)]
9435        fn new_empty() -> Self {
9436            Self::default()
9437        }
9438
9439        unsafe fn decode(
9440            &mut self,
9441            decoder: &mut fidl::encoding::Decoder<'_, D>,
9442            offset: usize,
9443            mut depth: fidl::encoding::Depth,
9444        ) -> fidl::Result<()> {
9445            decoder.debug_check_bounds::<Self>(offset);
9446            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9447                None => return Err(fidl::Error::NotNullable),
9448                Some(len) => len,
9449            };
9450            // Calling decoder.out_of_line_offset(0) is not allowed.
9451            if len == 0 {
9452                return Ok(());
9453            };
9454            depth.increment()?;
9455            let envelope_size = 8;
9456            let bytes_len = len * envelope_size;
9457            let offset = decoder.out_of_line_offset(bytes_len)?;
9458            // Decode the envelope for each type.
9459            let mut _next_ordinal_to_read = 0;
9460            let mut next_offset = offset;
9461            let end_offset = offset + bytes_len;
9462            _next_ordinal_to_read += 1;
9463            if next_offset >= end_offset {
9464                return Ok(());
9465            }
9466
9467            // Decode unknown envelopes for gaps in ordinals.
9468            while _next_ordinal_to_read < 1 {
9469                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9470                _next_ordinal_to_read += 1;
9471                next_offset += envelope_size;
9472            }
9473
9474            let next_out_of_line = decoder.next_out_of_line();
9475            let handles_before = decoder.remaining_handles();
9476            if let Some((inlined, num_bytes, num_handles)) =
9477                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9478            {
9479                let member_inline_size =
9480                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9481                if inlined != (member_inline_size <= 4) {
9482                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9483                }
9484                let inner_offset;
9485                let mut inner_depth = depth.clone();
9486                if inlined {
9487                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9488                    inner_offset = next_offset;
9489                } else {
9490                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9491                    inner_depth.increment()?;
9492                }
9493                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9494                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9495                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9496                {
9497                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9498                }
9499                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9500                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9501                }
9502            }
9503
9504            next_offset += envelope_size;
9505            _next_ordinal_to_read += 1;
9506            if next_offset >= end_offset {
9507                return Ok(());
9508            }
9509
9510            // Decode unknown envelopes for gaps in ordinals.
9511            while _next_ordinal_to_read < 2 {
9512                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9513                _next_ordinal_to_read += 1;
9514                next_offset += envelope_size;
9515            }
9516
9517            let next_out_of_line = decoder.next_out_of_line();
9518            let handles_before = decoder.remaining_handles();
9519            if let Some((inlined, num_bytes, num_handles)) =
9520                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9521            {
9522                let member_inline_size =
9523                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9524                if inlined != (member_inline_size <= 4) {
9525                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9526                }
9527                let inner_offset;
9528                let mut inner_depth = depth.clone();
9529                if inlined {
9530                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9531                    inner_offset = next_offset;
9532                } else {
9533                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9534                    inner_depth.increment()?;
9535                }
9536                let val_ref =
9537                    self.range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9538                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9539                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9540                {
9541                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9542                }
9543                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9544                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9545                }
9546            }
9547
9548            next_offset += envelope_size;
9549
9550            // Decode the remaining unknown envelopes.
9551            while next_offset < end_offset {
9552                _next_ordinal_to_read += 1;
9553                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9554                next_offset += envelope_size;
9555            }
9556
9557            Ok(())
9558        }
9559    }
9560
9561    impl SecureHeapAndRangeModification {
9562        #[inline(always)]
9563        fn max_ordinal_present(&self) -> u64 {
9564            if let Some(_) = self.new_range {
9565                return 3;
9566            }
9567            if let Some(_) = self.old_range {
9568                return 2;
9569            }
9570            if let Some(_) = self.heap {
9571                return 1;
9572            }
9573            0
9574        }
9575    }
9576
9577    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRangeModification {
9578        type Borrowed<'a> = &'a Self;
9579        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9580            value
9581        }
9582    }
9583
9584    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRangeModification {
9585        type Owned = Self;
9586
9587        #[inline(always)]
9588        fn inline_align(_context: fidl::encoding::Context) -> usize {
9589            8
9590        }
9591
9592        #[inline(always)]
9593        fn inline_size(_context: fidl::encoding::Context) -> usize {
9594            16
9595        }
9596    }
9597
9598    unsafe impl<D: fidl::encoding::ResourceDialect>
9599        fidl::encoding::Encode<SecureHeapAndRangeModification, D>
9600        for &SecureHeapAndRangeModification
9601    {
9602        unsafe fn encode(
9603            self,
9604            encoder: &mut fidl::encoding::Encoder<'_, D>,
9605            offset: usize,
9606            mut depth: fidl::encoding::Depth,
9607        ) -> fidl::Result<()> {
9608            encoder.debug_check_bounds::<SecureHeapAndRangeModification>(offset);
9609            // Vector header
9610            let max_ordinal: u64 = self.max_ordinal_present();
9611            encoder.write_num(max_ordinal, offset);
9612            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9613            // Calling encoder.out_of_line_offset(0) is not allowed.
9614            if max_ordinal == 0 {
9615                return Ok(());
9616            }
9617            depth.increment()?;
9618            let envelope_size = 8;
9619            let bytes_len = max_ordinal as usize * envelope_size;
9620            #[allow(unused_variables)]
9621            let offset = encoder.out_of_line_offset(bytes_len);
9622            let mut _prev_end_offset: usize = 0;
9623            if 1 > max_ordinal {
9624                return Ok(());
9625            }
9626
9627            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9628            // are envelope_size bytes.
9629            let cur_offset: usize = (1 - 1) * envelope_size;
9630
9631            // Zero reserved fields.
9632            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9633
9634            // Safety:
9635            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9636            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9637            //   envelope_size bytes, there is always sufficient room.
9638            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9639                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9640                encoder,
9641                offset + cur_offset,
9642                depth,
9643            )?;
9644
9645            _prev_end_offset = cur_offset + envelope_size;
9646            if 2 > max_ordinal {
9647                return Ok(());
9648            }
9649
9650            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9651            // are envelope_size bytes.
9652            let cur_offset: usize = (2 - 1) * envelope_size;
9653
9654            // Zero reserved fields.
9655            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9656
9657            // Safety:
9658            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9659            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9660            //   envelope_size bytes, there is always sufficient room.
9661            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9662                self.old_range
9663                    .as_ref()
9664                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9665                encoder,
9666                offset + cur_offset,
9667                depth,
9668            )?;
9669
9670            _prev_end_offset = cur_offset + envelope_size;
9671            if 3 > max_ordinal {
9672                return Ok(());
9673            }
9674
9675            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9676            // are envelope_size bytes.
9677            let cur_offset: usize = (3 - 1) * envelope_size;
9678
9679            // Zero reserved fields.
9680            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9681
9682            // Safety:
9683            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9684            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9685            //   envelope_size bytes, there is always sufficient room.
9686            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9687                self.new_range
9688                    .as_ref()
9689                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9690                encoder,
9691                offset + cur_offset,
9692                depth,
9693            )?;
9694
9695            _prev_end_offset = cur_offset + envelope_size;
9696
9697            Ok(())
9698        }
9699    }
9700
9701    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9702        for SecureHeapAndRangeModification
9703    {
9704        #[inline(always)]
9705        fn new_empty() -> Self {
9706            Self::default()
9707        }
9708
9709        unsafe fn decode(
9710            &mut self,
9711            decoder: &mut fidl::encoding::Decoder<'_, D>,
9712            offset: usize,
9713            mut depth: fidl::encoding::Depth,
9714        ) -> fidl::Result<()> {
9715            decoder.debug_check_bounds::<Self>(offset);
9716            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9717                None => return Err(fidl::Error::NotNullable),
9718                Some(len) => len,
9719            };
9720            // Calling decoder.out_of_line_offset(0) is not allowed.
9721            if len == 0 {
9722                return Ok(());
9723            };
9724            depth.increment()?;
9725            let envelope_size = 8;
9726            let bytes_len = len * envelope_size;
9727            let offset = decoder.out_of_line_offset(bytes_len)?;
9728            // Decode the envelope for each type.
9729            let mut _next_ordinal_to_read = 0;
9730            let mut next_offset = offset;
9731            let end_offset = offset + bytes_len;
9732            _next_ordinal_to_read += 1;
9733            if next_offset >= end_offset {
9734                return Ok(());
9735            }
9736
9737            // Decode unknown envelopes for gaps in ordinals.
9738            while _next_ordinal_to_read < 1 {
9739                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9740                _next_ordinal_to_read += 1;
9741                next_offset += envelope_size;
9742            }
9743
9744            let next_out_of_line = decoder.next_out_of_line();
9745            let handles_before = decoder.remaining_handles();
9746            if let Some((inlined, num_bytes, num_handles)) =
9747                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9748            {
9749                let member_inline_size =
9750                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9751                if inlined != (member_inline_size <= 4) {
9752                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9753                }
9754                let inner_offset;
9755                let mut inner_depth = depth.clone();
9756                if inlined {
9757                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9758                    inner_offset = next_offset;
9759                } else {
9760                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9761                    inner_depth.increment()?;
9762                }
9763                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9764                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9765                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9766                {
9767                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9768                }
9769                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9770                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9771                }
9772            }
9773
9774            next_offset += envelope_size;
9775            _next_ordinal_to_read += 1;
9776            if next_offset >= end_offset {
9777                return Ok(());
9778            }
9779
9780            // Decode unknown envelopes for gaps in ordinals.
9781            while _next_ordinal_to_read < 2 {
9782                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9783                _next_ordinal_to_read += 1;
9784                next_offset += envelope_size;
9785            }
9786
9787            let next_out_of_line = decoder.next_out_of_line();
9788            let handles_before = decoder.remaining_handles();
9789            if let Some((inlined, num_bytes, num_handles)) =
9790                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9791            {
9792                let member_inline_size =
9793                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9794                if inlined != (member_inline_size <= 4) {
9795                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9796                }
9797                let inner_offset;
9798                let mut inner_depth = depth.clone();
9799                if inlined {
9800                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9801                    inner_offset = next_offset;
9802                } else {
9803                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9804                    inner_depth.increment()?;
9805                }
9806                let val_ref =
9807                    self.old_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9808                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9809                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9810                {
9811                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9812                }
9813                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9814                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9815                }
9816            }
9817
9818            next_offset += envelope_size;
9819            _next_ordinal_to_read += 1;
9820            if next_offset >= end_offset {
9821                return Ok(());
9822            }
9823
9824            // Decode unknown envelopes for gaps in ordinals.
9825            while _next_ordinal_to_read < 3 {
9826                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9827                _next_ordinal_to_read += 1;
9828                next_offset += envelope_size;
9829            }
9830
9831            let next_out_of_line = decoder.next_out_of_line();
9832            let handles_before = decoder.remaining_handles();
9833            if let Some((inlined, num_bytes, num_handles)) =
9834                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9835            {
9836                let member_inline_size =
9837                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9838                if inlined != (member_inline_size <= 4) {
9839                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9840                }
9841                let inner_offset;
9842                let mut inner_depth = depth.clone();
9843                if inlined {
9844                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9845                    inner_offset = next_offset;
9846                } else {
9847                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9848                    inner_depth.increment()?;
9849                }
9850                let val_ref =
9851                    self.new_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9852                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9853                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9854                {
9855                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9856                }
9857                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9858                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9859                }
9860            }
9861
9862            next_offset += envelope_size;
9863
9864            // Decode the remaining unknown envelopes.
9865            while next_offset < end_offset {
9866                _next_ordinal_to_read += 1;
9867                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9868                next_offset += envelope_size;
9869            }
9870
9871            Ok(())
9872        }
9873    }
9874
9875    impl SecureHeapAndRanges {
9876        #[inline(always)]
9877        fn max_ordinal_present(&self) -> u64 {
9878            if let Some(_) = self.ranges {
9879                return 2;
9880            }
9881            if let Some(_) = self.heap {
9882                return 1;
9883            }
9884            0
9885        }
9886    }
9887
9888    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRanges {
9889        type Borrowed<'a> = &'a Self;
9890        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9891            value
9892        }
9893    }
9894
9895    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRanges {
9896        type Owned = Self;
9897
9898        #[inline(always)]
9899        fn inline_align(_context: fidl::encoding::Context) -> usize {
9900            8
9901        }
9902
9903        #[inline(always)]
9904        fn inline_size(_context: fidl::encoding::Context) -> usize {
9905            16
9906        }
9907    }
9908
9909    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapAndRanges, D>
9910        for &SecureHeapAndRanges
9911    {
9912        unsafe fn encode(
9913            self,
9914            encoder: &mut fidl::encoding::Encoder<'_, D>,
9915            offset: usize,
9916            mut depth: fidl::encoding::Depth,
9917        ) -> fidl::Result<()> {
9918            encoder.debug_check_bounds::<SecureHeapAndRanges>(offset);
9919            // Vector header
9920            let max_ordinal: u64 = self.max_ordinal_present();
9921            encoder.write_num(max_ordinal, offset);
9922            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9923            // Calling encoder.out_of_line_offset(0) is not allowed.
9924            if max_ordinal == 0 {
9925                return Ok(());
9926            }
9927            depth.increment()?;
9928            let envelope_size = 8;
9929            let bytes_len = max_ordinal as usize * envelope_size;
9930            #[allow(unused_variables)]
9931            let offset = encoder.out_of_line_offset(bytes_len);
9932            let mut _prev_end_offset: usize = 0;
9933            if 1 > max_ordinal {
9934                return Ok(());
9935            }
9936
9937            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9938            // are envelope_size bytes.
9939            let cur_offset: usize = (1 - 1) * envelope_size;
9940
9941            // Zero reserved fields.
9942            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9943
9944            // Safety:
9945            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9946            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9947            //   envelope_size bytes, there is always sufficient room.
9948            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9949                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9950                encoder,
9951                offset + cur_offset,
9952                depth,
9953            )?;
9954
9955            _prev_end_offset = cur_offset + envelope_size;
9956            if 2 > max_ordinal {
9957                return Ok(());
9958            }
9959
9960            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9961            // are envelope_size bytes.
9962            let cur_offset: usize = (2 - 1) * envelope_size;
9963
9964            // Zero reserved fields.
9965            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9966
9967            // Safety:
9968            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9969            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9970            //   envelope_size bytes, there is always sufficient room.
9971            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SecureHeapRange, 128>, D>(
9972            self.ranges.as_ref().map(<fidl::encoding::Vector<SecureHeapRange, 128> as fidl::encoding::ValueTypeMarker>::borrow),
9973            encoder, offset + cur_offset, depth
9974        )?;
9975
9976            _prev_end_offset = cur_offset + envelope_size;
9977
9978            Ok(())
9979        }
9980    }
9981
9982    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapAndRanges {
9983        #[inline(always)]
9984        fn new_empty() -> Self {
9985            Self::default()
9986        }
9987
9988        unsafe fn decode(
9989            &mut self,
9990            decoder: &mut fidl::encoding::Decoder<'_, D>,
9991            offset: usize,
9992            mut depth: fidl::encoding::Depth,
9993        ) -> fidl::Result<()> {
9994            decoder.debug_check_bounds::<Self>(offset);
9995            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9996                None => return Err(fidl::Error::NotNullable),
9997                Some(len) => len,
9998            };
9999            // Calling decoder.out_of_line_offset(0) is not allowed.
10000            if len == 0 {
10001                return Ok(());
10002            };
10003            depth.increment()?;
10004            let envelope_size = 8;
10005            let bytes_len = len * envelope_size;
10006            let offset = decoder.out_of_line_offset(bytes_len)?;
10007            // Decode the envelope for each type.
10008            let mut _next_ordinal_to_read = 0;
10009            let mut next_offset = offset;
10010            let end_offset = offset + bytes_len;
10011            _next_ordinal_to_read += 1;
10012            if next_offset >= end_offset {
10013                return Ok(());
10014            }
10015
10016            // Decode unknown envelopes for gaps in ordinals.
10017            while _next_ordinal_to_read < 1 {
10018                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10019                _next_ordinal_to_read += 1;
10020                next_offset += envelope_size;
10021            }
10022
10023            let next_out_of_line = decoder.next_out_of_line();
10024            let handles_before = decoder.remaining_handles();
10025            if let Some((inlined, num_bytes, num_handles)) =
10026                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10027            {
10028                let member_inline_size =
10029                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10030                if inlined != (member_inline_size <= 4) {
10031                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10032                }
10033                let inner_offset;
10034                let mut inner_depth = depth.clone();
10035                if inlined {
10036                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10037                    inner_offset = next_offset;
10038                } else {
10039                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10040                    inner_depth.increment()?;
10041                }
10042                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
10043                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
10044                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10045                {
10046                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10047                }
10048                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10049                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10050                }
10051            }
10052
10053            next_offset += envelope_size;
10054            _next_ordinal_to_read += 1;
10055            if next_offset >= end_offset {
10056                return Ok(());
10057            }
10058
10059            // Decode unknown envelopes for gaps in ordinals.
10060            while _next_ordinal_to_read < 2 {
10061                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10062                _next_ordinal_to_read += 1;
10063                next_offset += envelope_size;
10064            }
10065
10066            let next_out_of_line = decoder.next_out_of_line();
10067            let handles_before = decoder.remaining_handles();
10068            if let Some((inlined, num_bytes, num_handles)) =
10069                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10070            {
10071                let member_inline_size = <fidl::encoding::Vector<SecureHeapRange, 128> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10072                if inlined != (member_inline_size <= 4) {
10073                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10074                }
10075                let inner_offset;
10076                let mut inner_depth = depth.clone();
10077                if inlined {
10078                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10079                    inner_offset = next_offset;
10080                } else {
10081                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10082                    inner_depth.increment()?;
10083                }
10084                let val_ref = self.ranges.get_or_insert_with(
10085                    || fidl::new_empty!(fidl::encoding::Vector<SecureHeapRange, 128>, D),
10086                );
10087                fidl::decode!(fidl::encoding::Vector<SecureHeapRange, 128>, D, val_ref, decoder, inner_offset, inner_depth)?;
10088                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10089                {
10090                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10091                }
10092                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10093                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10094                }
10095            }
10096
10097            next_offset += envelope_size;
10098
10099            // Decode the remaining unknown envelopes.
10100            while next_offset < end_offset {
10101                _next_ordinal_to_read += 1;
10102                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10103                next_offset += envelope_size;
10104            }
10105
10106            Ok(())
10107        }
10108    }
10109
10110    impl SecureHeapProperties {
10111        #[inline(always)]
10112        fn max_ordinal_present(&self) -> u64 {
10113            if let Some(_) = self.is_mod_protected_range_available {
10114                return 5;
10115            }
10116            if let Some(_) = self.max_protected_range_count {
10117                return 4;
10118            }
10119            if let Some(_) = self.protected_range_granularity {
10120                return 3;
10121            }
10122            if let Some(_) = self.dynamic_protection_ranges {
10123                return 2;
10124            }
10125            if let Some(_) = self.heap {
10126                return 1;
10127            }
10128            0
10129        }
10130    }
10131
10132    impl fidl::encoding::ValueTypeMarker for SecureHeapProperties {
10133        type Borrowed<'a> = &'a Self;
10134        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10135            value
10136        }
10137    }
10138
10139    unsafe impl fidl::encoding::TypeMarker for SecureHeapProperties {
10140        type Owned = Self;
10141
10142        #[inline(always)]
10143        fn inline_align(_context: fidl::encoding::Context) -> usize {
10144            8
10145        }
10146
10147        #[inline(always)]
10148        fn inline_size(_context: fidl::encoding::Context) -> usize {
10149            16
10150        }
10151    }
10152
10153    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapProperties, D>
10154        for &SecureHeapProperties
10155    {
10156        unsafe fn encode(
10157            self,
10158            encoder: &mut fidl::encoding::Encoder<'_, D>,
10159            offset: usize,
10160            mut depth: fidl::encoding::Depth,
10161        ) -> fidl::Result<()> {
10162            encoder.debug_check_bounds::<SecureHeapProperties>(offset);
10163            // Vector header
10164            let max_ordinal: u64 = self.max_ordinal_present();
10165            encoder.write_num(max_ordinal, offset);
10166            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10167            // Calling encoder.out_of_line_offset(0) is not allowed.
10168            if max_ordinal == 0 {
10169                return Ok(());
10170            }
10171            depth.increment()?;
10172            let envelope_size = 8;
10173            let bytes_len = max_ordinal as usize * envelope_size;
10174            #[allow(unused_variables)]
10175            let offset = encoder.out_of_line_offset(bytes_len);
10176            let mut _prev_end_offset: usize = 0;
10177            if 1 > max_ordinal {
10178                return Ok(());
10179            }
10180
10181            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10182            // are envelope_size bytes.
10183            let cur_offset: usize = (1 - 1) * envelope_size;
10184
10185            // Zero reserved fields.
10186            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10187
10188            // Safety:
10189            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10190            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10191            //   envelope_size bytes, there is always sufficient room.
10192            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
10193                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
10194                encoder,
10195                offset + cur_offset,
10196                depth,
10197            )?;
10198
10199            _prev_end_offset = cur_offset + envelope_size;
10200            if 2 > max_ordinal {
10201                return Ok(());
10202            }
10203
10204            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10205            // are envelope_size bytes.
10206            let cur_offset: usize = (2 - 1) * envelope_size;
10207
10208            // Zero reserved fields.
10209            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10210
10211            // Safety:
10212            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10213            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10214            //   envelope_size bytes, there is always sufficient room.
10215            fidl::encoding::encode_in_envelope_optional::<bool, D>(
10216                self.dynamic_protection_ranges
10217                    .as_ref()
10218                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
10219                encoder,
10220                offset + cur_offset,
10221                depth,
10222            )?;
10223
10224            _prev_end_offset = cur_offset + envelope_size;
10225            if 3 > max_ordinal {
10226                return Ok(());
10227            }
10228
10229            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10230            // are envelope_size bytes.
10231            let cur_offset: usize = (3 - 1) * envelope_size;
10232
10233            // Zero reserved fields.
10234            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10235
10236            // Safety:
10237            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10238            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10239            //   envelope_size bytes, there is always sufficient room.
10240            fidl::encoding::encode_in_envelope_optional::<u32, D>(
10241                self.protected_range_granularity
10242                    .as_ref()
10243                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
10244                encoder,
10245                offset + cur_offset,
10246                depth,
10247            )?;
10248
10249            _prev_end_offset = cur_offset + envelope_size;
10250            if 4 > max_ordinal {
10251                return Ok(());
10252            }
10253
10254            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10255            // are envelope_size bytes.
10256            let cur_offset: usize = (4 - 1) * envelope_size;
10257
10258            // Zero reserved fields.
10259            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10260
10261            // Safety:
10262            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10263            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10264            //   envelope_size bytes, there is always sufficient room.
10265            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10266                self.max_protected_range_count
10267                    .as_ref()
10268                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10269                encoder,
10270                offset + cur_offset,
10271                depth,
10272            )?;
10273
10274            _prev_end_offset = cur_offset + envelope_size;
10275            if 5 > max_ordinal {
10276                return Ok(());
10277            }
10278
10279            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10280            // are envelope_size bytes.
10281            let cur_offset: usize = (5 - 1) * envelope_size;
10282
10283            // Zero reserved fields.
10284            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10285
10286            // Safety:
10287            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10288            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10289            //   envelope_size bytes, there is always sufficient room.
10290            fidl::encoding::encode_in_envelope_optional::<bool, D>(
10291                self.is_mod_protected_range_available
10292                    .as_ref()
10293                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
10294                encoder,
10295                offset + cur_offset,
10296                depth,
10297            )?;
10298
10299            _prev_end_offset = cur_offset + envelope_size;
10300
10301            Ok(())
10302        }
10303    }
10304
10305    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapProperties {
10306        #[inline(always)]
10307        fn new_empty() -> Self {
10308            Self::default()
10309        }
10310
10311        unsafe fn decode(
10312            &mut self,
10313            decoder: &mut fidl::encoding::Decoder<'_, D>,
10314            offset: usize,
10315            mut depth: fidl::encoding::Depth,
10316        ) -> fidl::Result<()> {
10317            decoder.debug_check_bounds::<Self>(offset);
10318            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10319                None => return Err(fidl::Error::NotNullable),
10320                Some(len) => len,
10321            };
10322            // Calling decoder.out_of_line_offset(0) is not allowed.
10323            if len == 0 {
10324                return Ok(());
10325            };
10326            depth.increment()?;
10327            let envelope_size = 8;
10328            let bytes_len = len * envelope_size;
10329            let offset = decoder.out_of_line_offset(bytes_len)?;
10330            // Decode the envelope for each type.
10331            let mut _next_ordinal_to_read = 0;
10332            let mut next_offset = offset;
10333            let end_offset = offset + bytes_len;
10334            _next_ordinal_to_read += 1;
10335            if next_offset >= end_offset {
10336                return Ok(());
10337            }
10338
10339            // Decode unknown envelopes for gaps in ordinals.
10340            while _next_ordinal_to_read < 1 {
10341                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10342                _next_ordinal_to_read += 1;
10343                next_offset += envelope_size;
10344            }
10345
10346            let next_out_of_line = decoder.next_out_of_line();
10347            let handles_before = decoder.remaining_handles();
10348            if let Some((inlined, num_bytes, num_handles)) =
10349                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10350            {
10351                let member_inline_size =
10352                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10353                if inlined != (member_inline_size <= 4) {
10354                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10355                }
10356                let inner_offset;
10357                let mut inner_depth = depth.clone();
10358                if inlined {
10359                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10360                    inner_offset = next_offset;
10361                } else {
10362                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10363                    inner_depth.increment()?;
10364                }
10365                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
10366                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
10367                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10368                {
10369                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10370                }
10371                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10372                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10373                }
10374            }
10375
10376            next_offset += envelope_size;
10377            _next_ordinal_to_read += 1;
10378            if next_offset >= end_offset {
10379                return Ok(());
10380            }
10381
10382            // Decode unknown envelopes for gaps in ordinals.
10383            while _next_ordinal_to_read < 2 {
10384                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10385                _next_ordinal_to_read += 1;
10386                next_offset += envelope_size;
10387            }
10388
10389            let next_out_of_line = decoder.next_out_of_line();
10390            let handles_before = decoder.remaining_handles();
10391            if let Some((inlined, num_bytes, num_handles)) =
10392                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10393            {
10394                let member_inline_size =
10395                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10396                if inlined != (member_inline_size <= 4) {
10397                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10398                }
10399                let inner_offset;
10400                let mut inner_depth = depth.clone();
10401                if inlined {
10402                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10403                    inner_offset = next_offset;
10404                } else {
10405                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10406                    inner_depth.increment()?;
10407                }
10408                let val_ref =
10409                    self.dynamic_protection_ranges.get_or_insert_with(|| fidl::new_empty!(bool, D));
10410                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
10411                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10412                {
10413                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10414                }
10415                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10416                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10417                }
10418            }
10419
10420            next_offset += envelope_size;
10421            _next_ordinal_to_read += 1;
10422            if next_offset >= end_offset {
10423                return Ok(());
10424            }
10425
10426            // Decode unknown envelopes for gaps in ordinals.
10427            while _next_ordinal_to_read < 3 {
10428                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10429                _next_ordinal_to_read += 1;
10430                next_offset += envelope_size;
10431            }
10432
10433            let next_out_of_line = decoder.next_out_of_line();
10434            let handles_before = decoder.remaining_handles();
10435            if let Some((inlined, num_bytes, num_handles)) =
10436                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10437            {
10438                let member_inline_size =
10439                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10440                if inlined != (member_inline_size <= 4) {
10441                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10442                }
10443                let inner_offset;
10444                let mut inner_depth = depth.clone();
10445                if inlined {
10446                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10447                    inner_offset = next_offset;
10448                } else {
10449                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10450                    inner_depth.increment()?;
10451                }
10452                let val_ref = self
10453                    .protected_range_granularity
10454                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
10455                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
10456                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10457                {
10458                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10459                }
10460                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10461                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10462                }
10463            }
10464
10465            next_offset += envelope_size;
10466            _next_ordinal_to_read += 1;
10467            if next_offset >= end_offset {
10468                return Ok(());
10469            }
10470
10471            // Decode unknown envelopes for gaps in ordinals.
10472            while _next_ordinal_to_read < 4 {
10473                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10474                _next_ordinal_to_read += 1;
10475                next_offset += envelope_size;
10476            }
10477
10478            let next_out_of_line = decoder.next_out_of_line();
10479            let handles_before = decoder.remaining_handles();
10480            if let Some((inlined, num_bytes, num_handles)) =
10481                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10482            {
10483                let member_inline_size =
10484                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10485                if inlined != (member_inline_size <= 4) {
10486                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10487                }
10488                let inner_offset;
10489                let mut inner_depth = depth.clone();
10490                if inlined {
10491                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10492                    inner_offset = next_offset;
10493                } else {
10494                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10495                    inner_depth.increment()?;
10496                }
10497                let val_ref =
10498                    self.max_protected_range_count.get_or_insert_with(|| fidl::new_empty!(u64, D));
10499                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10500                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10501                {
10502                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10503                }
10504                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10505                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10506                }
10507            }
10508
10509            next_offset += envelope_size;
10510            _next_ordinal_to_read += 1;
10511            if next_offset >= end_offset {
10512                return Ok(());
10513            }
10514
10515            // Decode unknown envelopes for gaps in ordinals.
10516            while _next_ordinal_to_read < 5 {
10517                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10518                _next_ordinal_to_read += 1;
10519                next_offset += envelope_size;
10520            }
10521
10522            let next_out_of_line = decoder.next_out_of_line();
10523            let handles_before = decoder.remaining_handles();
10524            if let Some((inlined, num_bytes, num_handles)) =
10525                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10526            {
10527                let member_inline_size =
10528                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10529                if inlined != (member_inline_size <= 4) {
10530                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10531                }
10532                let inner_offset;
10533                let mut inner_depth = depth.clone();
10534                if inlined {
10535                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10536                    inner_offset = next_offset;
10537                } else {
10538                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10539                    inner_depth.increment()?;
10540                }
10541                let val_ref = self
10542                    .is_mod_protected_range_available
10543                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
10544                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
10545                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10546                {
10547                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10548                }
10549                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10550                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10551                }
10552            }
10553
10554            next_offset += envelope_size;
10555
10556            // Decode the remaining unknown envelopes.
10557            while next_offset < end_offset {
10558                _next_ordinal_to_read += 1;
10559                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10560                next_offset += envelope_size;
10561            }
10562
10563            Ok(())
10564        }
10565    }
10566
10567    impl SecureHeapRange {
10568        #[inline(always)]
10569        fn max_ordinal_present(&self) -> u64 {
10570            if let Some(_) = self.size_bytes {
10571                return 2;
10572            }
10573            if let Some(_) = self.physical_address {
10574                return 1;
10575            }
10576            0
10577        }
10578    }
10579
10580    impl fidl::encoding::ValueTypeMarker for SecureHeapRange {
10581        type Borrowed<'a> = &'a Self;
10582        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10583            value
10584        }
10585    }
10586
10587    unsafe impl fidl::encoding::TypeMarker for SecureHeapRange {
10588        type Owned = Self;
10589
10590        #[inline(always)]
10591        fn inline_align(_context: fidl::encoding::Context) -> usize {
10592            8
10593        }
10594
10595        #[inline(always)]
10596        fn inline_size(_context: fidl::encoding::Context) -> usize {
10597            16
10598        }
10599    }
10600
10601    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapRange, D>
10602        for &SecureHeapRange
10603    {
10604        unsafe fn encode(
10605            self,
10606            encoder: &mut fidl::encoding::Encoder<'_, D>,
10607            offset: usize,
10608            mut depth: fidl::encoding::Depth,
10609        ) -> fidl::Result<()> {
10610            encoder.debug_check_bounds::<SecureHeapRange>(offset);
10611            // Vector header
10612            let max_ordinal: u64 = self.max_ordinal_present();
10613            encoder.write_num(max_ordinal, offset);
10614            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10615            // Calling encoder.out_of_line_offset(0) is not allowed.
10616            if max_ordinal == 0 {
10617                return Ok(());
10618            }
10619            depth.increment()?;
10620            let envelope_size = 8;
10621            let bytes_len = max_ordinal as usize * envelope_size;
10622            #[allow(unused_variables)]
10623            let offset = encoder.out_of_line_offset(bytes_len);
10624            let mut _prev_end_offset: usize = 0;
10625            if 1 > max_ordinal {
10626                return Ok(());
10627            }
10628
10629            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10630            // are envelope_size bytes.
10631            let cur_offset: usize = (1 - 1) * envelope_size;
10632
10633            // Zero reserved fields.
10634            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10635
10636            // Safety:
10637            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10638            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10639            //   envelope_size bytes, there is always sufficient room.
10640            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10641                self.physical_address
10642                    .as_ref()
10643                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10644                encoder,
10645                offset + cur_offset,
10646                depth,
10647            )?;
10648
10649            _prev_end_offset = cur_offset + envelope_size;
10650            if 2 > max_ordinal {
10651                return Ok(());
10652            }
10653
10654            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10655            // are envelope_size bytes.
10656            let cur_offset: usize = (2 - 1) * envelope_size;
10657
10658            // Zero reserved fields.
10659            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10660
10661            // Safety:
10662            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10663            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10664            //   envelope_size bytes, there is always sufficient room.
10665            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10666                self.size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10667                encoder,
10668                offset + cur_offset,
10669                depth,
10670            )?;
10671
10672            _prev_end_offset = cur_offset + envelope_size;
10673
10674            Ok(())
10675        }
10676    }
10677
10678    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapRange {
10679        #[inline(always)]
10680        fn new_empty() -> Self {
10681            Self::default()
10682        }
10683
10684        unsafe fn decode(
10685            &mut self,
10686            decoder: &mut fidl::encoding::Decoder<'_, D>,
10687            offset: usize,
10688            mut depth: fidl::encoding::Depth,
10689        ) -> fidl::Result<()> {
10690            decoder.debug_check_bounds::<Self>(offset);
10691            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10692                None => return Err(fidl::Error::NotNullable),
10693                Some(len) => len,
10694            };
10695            // Calling decoder.out_of_line_offset(0) is not allowed.
10696            if len == 0 {
10697                return Ok(());
10698            };
10699            depth.increment()?;
10700            let envelope_size = 8;
10701            let bytes_len = len * envelope_size;
10702            let offset = decoder.out_of_line_offset(bytes_len)?;
10703            // Decode the envelope for each type.
10704            let mut _next_ordinal_to_read = 0;
10705            let mut next_offset = offset;
10706            let end_offset = offset + bytes_len;
10707            _next_ordinal_to_read += 1;
10708            if next_offset >= end_offset {
10709                return Ok(());
10710            }
10711
10712            // Decode unknown envelopes for gaps in ordinals.
10713            while _next_ordinal_to_read < 1 {
10714                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10715                _next_ordinal_to_read += 1;
10716                next_offset += envelope_size;
10717            }
10718
10719            let next_out_of_line = decoder.next_out_of_line();
10720            let handles_before = decoder.remaining_handles();
10721            if let Some((inlined, num_bytes, num_handles)) =
10722                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10723            {
10724                let member_inline_size =
10725                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10726                if inlined != (member_inline_size <= 4) {
10727                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10728                }
10729                let inner_offset;
10730                let mut inner_depth = depth.clone();
10731                if inlined {
10732                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10733                    inner_offset = next_offset;
10734                } else {
10735                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10736                    inner_depth.increment()?;
10737                }
10738                let val_ref = self.physical_address.get_or_insert_with(|| fidl::new_empty!(u64, D));
10739                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10740                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10741                {
10742                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10743                }
10744                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10745                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10746                }
10747            }
10748
10749            next_offset += envelope_size;
10750            _next_ordinal_to_read += 1;
10751            if next_offset >= end_offset {
10752                return Ok(());
10753            }
10754
10755            // Decode unknown envelopes for gaps in ordinals.
10756            while _next_ordinal_to_read < 2 {
10757                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10758                _next_ordinal_to_read += 1;
10759                next_offset += envelope_size;
10760            }
10761
10762            let next_out_of_line = decoder.next_out_of_line();
10763            let handles_before = decoder.remaining_handles();
10764            if let Some((inlined, num_bytes, num_handles)) =
10765                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10766            {
10767                let member_inline_size =
10768                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10769                if inlined != (member_inline_size <= 4) {
10770                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10771                }
10772                let inner_offset;
10773                let mut inner_depth = depth.clone();
10774                if inlined {
10775                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10776                    inner_offset = next_offset;
10777                } else {
10778                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10779                    inner_depth.increment()?;
10780                }
10781                let val_ref = self.size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
10782                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10783                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10784                {
10785                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10786                }
10787                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10788                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10789                }
10790            }
10791
10792            next_offset += envelope_size;
10793
10794            // Decode the remaining unknown envelopes.
10795            while next_offset < end_offset {
10796                _next_ordinal_to_read += 1;
10797                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10798                next_offset += envelope_size;
10799            }
10800
10801            Ok(())
10802        }
10803    }
10804
10805    impl SecureMemAddSecureHeapPhysicalRangeRequest {
10806        #[inline(always)]
10807        fn max_ordinal_present(&self) -> u64 {
10808            if let Some(_) = self.heap_range {
10809                return 1;
10810            }
10811            0
10812        }
10813    }
10814
10815    impl fidl::encoding::ValueTypeMarker for SecureMemAddSecureHeapPhysicalRangeRequest {
10816        type Borrowed<'a> = &'a Self;
10817        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10818            value
10819        }
10820    }
10821
10822    unsafe impl fidl::encoding::TypeMarker for SecureMemAddSecureHeapPhysicalRangeRequest {
10823        type Owned = Self;
10824
10825        #[inline(always)]
10826        fn inline_align(_context: fidl::encoding::Context) -> usize {
10827            8
10828        }
10829
10830        #[inline(always)]
10831        fn inline_size(_context: fidl::encoding::Context) -> usize {
10832            16
10833        }
10834    }
10835
10836    unsafe impl<D: fidl::encoding::ResourceDialect>
10837        fidl::encoding::Encode<SecureMemAddSecureHeapPhysicalRangeRequest, D>
10838        for &SecureMemAddSecureHeapPhysicalRangeRequest
10839    {
10840        unsafe fn encode(
10841            self,
10842            encoder: &mut fidl::encoding::Encoder<'_, D>,
10843            offset: usize,
10844            mut depth: fidl::encoding::Depth,
10845        ) -> fidl::Result<()> {
10846            encoder.debug_check_bounds::<SecureMemAddSecureHeapPhysicalRangeRequest>(offset);
10847            // Vector header
10848            let max_ordinal: u64 = self.max_ordinal_present();
10849            encoder.write_num(max_ordinal, offset);
10850            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10851            // Calling encoder.out_of_line_offset(0) is not allowed.
10852            if max_ordinal == 0 {
10853                return Ok(());
10854            }
10855            depth.increment()?;
10856            let envelope_size = 8;
10857            let bytes_len = max_ordinal as usize * envelope_size;
10858            #[allow(unused_variables)]
10859            let offset = encoder.out_of_line_offset(bytes_len);
10860            let mut _prev_end_offset: usize = 0;
10861            if 1 > max_ordinal {
10862                return Ok(());
10863            }
10864
10865            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10866            // are envelope_size bytes.
10867            let cur_offset: usize = (1 - 1) * envelope_size;
10868
10869            // Zero reserved fields.
10870            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10871
10872            // Safety:
10873            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10874            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10875            //   envelope_size bytes, there is always sufficient room.
10876            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
10877                self.heap_range
10878                    .as_ref()
10879                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
10880                encoder,
10881                offset + cur_offset,
10882                depth,
10883            )?;
10884
10885            _prev_end_offset = cur_offset + envelope_size;
10886
10887            Ok(())
10888        }
10889    }
10890
10891    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
10892        for SecureMemAddSecureHeapPhysicalRangeRequest
10893    {
10894        #[inline(always)]
10895        fn new_empty() -> Self {
10896            Self::default()
10897        }
10898
10899        unsafe fn decode(
10900            &mut self,
10901            decoder: &mut fidl::encoding::Decoder<'_, D>,
10902            offset: usize,
10903            mut depth: fidl::encoding::Depth,
10904        ) -> fidl::Result<()> {
10905            decoder.debug_check_bounds::<Self>(offset);
10906            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10907                None => return Err(fidl::Error::NotNullable),
10908                Some(len) => len,
10909            };
10910            // Calling decoder.out_of_line_offset(0) is not allowed.
10911            if len == 0 {
10912                return Ok(());
10913            };
10914            depth.increment()?;
10915            let envelope_size = 8;
10916            let bytes_len = len * envelope_size;
10917            let offset = decoder.out_of_line_offset(bytes_len)?;
10918            // Decode the envelope for each type.
10919            let mut _next_ordinal_to_read = 0;
10920            let mut next_offset = offset;
10921            let end_offset = offset + bytes_len;
10922            _next_ordinal_to_read += 1;
10923            if next_offset >= end_offset {
10924                return Ok(());
10925            }
10926
10927            // Decode unknown envelopes for gaps in ordinals.
10928            while _next_ordinal_to_read < 1 {
10929                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10930                _next_ordinal_to_read += 1;
10931                next_offset += envelope_size;
10932            }
10933
10934            let next_out_of_line = decoder.next_out_of_line();
10935            let handles_before = decoder.remaining_handles();
10936            if let Some((inlined, num_bytes, num_handles)) =
10937                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10938            {
10939                let member_inline_size =
10940                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
10941                        decoder.context,
10942                    );
10943                if inlined != (member_inline_size <= 4) {
10944                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10945                }
10946                let inner_offset;
10947                let mut inner_depth = depth.clone();
10948                if inlined {
10949                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10950                    inner_offset = next_offset;
10951                } else {
10952                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10953                    inner_depth.increment()?;
10954                }
10955                let val_ref =
10956                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
10957                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
10958                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10959                {
10960                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10961                }
10962                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10963                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10964                }
10965            }
10966
10967            next_offset += envelope_size;
10968
10969            // Decode the remaining unknown envelopes.
10970            while next_offset < end_offset {
10971                _next_ordinal_to_read += 1;
10972                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10973                next_offset += envelope_size;
10974            }
10975
10976            Ok(())
10977        }
10978    }
10979
10980    impl SecureMemDeleteSecureHeapPhysicalRangeRequest {
10981        #[inline(always)]
10982        fn max_ordinal_present(&self) -> u64 {
10983            if let Some(_) = self.heap_range {
10984                return 1;
10985            }
10986            0
10987        }
10988    }
10989
10990    impl fidl::encoding::ValueTypeMarker for SecureMemDeleteSecureHeapPhysicalRangeRequest {
10991        type Borrowed<'a> = &'a Self;
10992        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10993            value
10994        }
10995    }
10996
10997    unsafe impl fidl::encoding::TypeMarker for SecureMemDeleteSecureHeapPhysicalRangeRequest {
10998        type Owned = Self;
10999
11000        #[inline(always)]
11001        fn inline_align(_context: fidl::encoding::Context) -> usize {
11002            8
11003        }
11004
11005        #[inline(always)]
11006        fn inline_size(_context: fidl::encoding::Context) -> usize {
11007            16
11008        }
11009    }
11010
11011    unsafe impl<D: fidl::encoding::ResourceDialect>
11012        fidl::encoding::Encode<SecureMemDeleteSecureHeapPhysicalRangeRequest, D>
11013        for &SecureMemDeleteSecureHeapPhysicalRangeRequest
11014    {
11015        unsafe fn encode(
11016            self,
11017            encoder: &mut fidl::encoding::Encoder<'_, D>,
11018            offset: usize,
11019            mut depth: fidl::encoding::Depth,
11020        ) -> fidl::Result<()> {
11021            encoder.debug_check_bounds::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(offset);
11022            // Vector header
11023            let max_ordinal: u64 = self.max_ordinal_present();
11024            encoder.write_num(max_ordinal, offset);
11025            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11026            // Calling encoder.out_of_line_offset(0) is not allowed.
11027            if max_ordinal == 0 {
11028                return Ok(());
11029            }
11030            depth.increment()?;
11031            let envelope_size = 8;
11032            let bytes_len = max_ordinal as usize * envelope_size;
11033            #[allow(unused_variables)]
11034            let offset = encoder.out_of_line_offset(bytes_len);
11035            let mut _prev_end_offset: usize = 0;
11036            if 1 > max_ordinal {
11037                return Ok(());
11038            }
11039
11040            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11041            // are envelope_size bytes.
11042            let cur_offset: usize = (1 - 1) * envelope_size;
11043
11044            // Zero reserved fields.
11045            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11046
11047            // Safety:
11048            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11049            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11050            //   envelope_size bytes, there is always sufficient room.
11051            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11052                self.heap_range
11053                    .as_ref()
11054                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11055                encoder,
11056                offset + cur_offset,
11057                depth,
11058            )?;
11059
11060            _prev_end_offset = cur_offset + envelope_size;
11061
11062            Ok(())
11063        }
11064    }
11065
11066    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11067        for SecureMemDeleteSecureHeapPhysicalRangeRequest
11068    {
11069        #[inline(always)]
11070        fn new_empty() -> Self {
11071            Self::default()
11072        }
11073
11074        unsafe fn decode(
11075            &mut self,
11076            decoder: &mut fidl::encoding::Decoder<'_, D>,
11077            offset: usize,
11078            mut depth: fidl::encoding::Depth,
11079        ) -> fidl::Result<()> {
11080            decoder.debug_check_bounds::<Self>(offset);
11081            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11082                None => return Err(fidl::Error::NotNullable),
11083                Some(len) => len,
11084            };
11085            // Calling decoder.out_of_line_offset(0) is not allowed.
11086            if len == 0 {
11087                return Ok(());
11088            };
11089            depth.increment()?;
11090            let envelope_size = 8;
11091            let bytes_len = len * envelope_size;
11092            let offset = decoder.out_of_line_offset(bytes_len)?;
11093            // Decode the envelope for each type.
11094            let mut _next_ordinal_to_read = 0;
11095            let mut next_offset = offset;
11096            let end_offset = offset + bytes_len;
11097            _next_ordinal_to_read += 1;
11098            if next_offset >= end_offset {
11099                return Ok(());
11100            }
11101
11102            // Decode unknown envelopes for gaps in ordinals.
11103            while _next_ordinal_to_read < 1 {
11104                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11105                _next_ordinal_to_read += 1;
11106                next_offset += envelope_size;
11107            }
11108
11109            let next_out_of_line = decoder.next_out_of_line();
11110            let handles_before = decoder.remaining_handles();
11111            if let Some((inlined, num_bytes, num_handles)) =
11112                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11113            {
11114                let member_inline_size =
11115                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11116                        decoder.context,
11117                    );
11118                if inlined != (member_inline_size <= 4) {
11119                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11120                }
11121                let inner_offset;
11122                let mut inner_depth = depth.clone();
11123                if inlined {
11124                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11125                    inner_offset = next_offset;
11126                } else {
11127                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11128                    inner_depth.increment()?;
11129                }
11130                let val_ref =
11131                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11132                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11133                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11134                {
11135                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11136                }
11137                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11138                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11139                }
11140            }
11141
11142            next_offset += envelope_size;
11143
11144            // Decode the remaining unknown envelopes.
11145            while next_offset < end_offset {
11146                _next_ordinal_to_read += 1;
11147                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11148                next_offset += envelope_size;
11149            }
11150
11151            Ok(())
11152        }
11153    }
11154
11155    impl SecureMemGetPhysicalSecureHeapPropertiesRequest {
11156        #[inline(always)]
11157        fn max_ordinal_present(&self) -> u64 {
11158            if let Some(_) = self.entire_heap {
11159                return 1;
11160            }
11161            0
11162        }
11163    }
11164
11165    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapPropertiesRequest {
11166        type Borrowed<'a> = &'a Self;
11167        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11168            value
11169        }
11170    }
11171
11172    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapPropertiesRequest {
11173        type Owned = Self;
11174
11175        #[inline(always)]
11176        fn inline_align(_context: fidl::encoding::Context) -> usize {
11177            8
11178        }
11179
11180        #[inline(always)]
11181        fn inline_size(_context: fidl::encoding::Context) -> usize {
11182            16
11183        }
11184    }
11185
11186    unsafe impl<D: fidl::encoding::ResourceDialect>
11187        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapPropertiesRequest, D>
11188        for &SecureMemGetPhysicalSecureHeapPropertiesRequest
11189    {
11190        unsafe fn encode(
11191            self,
11192            encoder: &mut fidl::encoding::Encoder<'_, D>,
11193            offset: usize,
11194            mut depth: fidl::encoding::Depth,
11195        ) -> fidl::Result<()> {
11196            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(offset);
11197            // Vector header
11198            let max_ordinal: u64 = self.max_ordinal_present();
11199            encoder.write_num(max_ordinal, offset);
11200            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11201            // Calling encoder.out_of_line_offset(0) is not allowed.
11202            if max_ordinal == 0 {
11203                return Ok(());
11204            }
11205            depth.increment()?;
11206            let envelope_size = 8;
11207            let bytes_len = max_ordinal as usize * envelope_size;
11208            #[allow(unused_variables)]
11209            let offset = encoder.out_of_line_offset(bytes_len);
11210            let mut _prev_end_offset: usize = 0;
11211            if 1 > max_ordinal {
11212                return Ok(());
11213            }
11214
11215            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11216            // are envelope_size bytes.
11217            let cur_offset: usize = (1 - 1) * envelope_size;
11218
11219            // Zero reserved fields.
11220            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11221
11222            // Safety:
11223            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11224            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11225            //   envelope_size bytes, there is always sufficient room.
11226            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11227                self.entire_heap
11228                    .as_ref()
11229                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11230                encoder,
11231                offset + cur_offset,
11232                depth,
11233            )?;
11234
11235            _prev_end_offset = cur_offset + envelope_size;
11236
11237            Ok(())
11238        }
11239    }
11240
11241    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11242        for SecureMemGetPhysicalSecureHeapPropertiesRequest
11243    {
11244        #[inline(always)]
11245        fn new_empty() -> Self {
11246            Self::default()
11247        }
11248
11249        unsafe fn decode(
11250            &mut self,
11251            decoder: &mut fidl::encoding::Decoder<'_, D>,
11252            offset: usize,
11253            mut depth: fidl::encoding::Depth,
11254        ) -> fidl::Result<()> {
11255            decoder.debug_check_bounds::<Self>(offset);
11256            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11257                None => return Err(fidl::Error::NotNullable),
11258                Some(len) => len,
11259            };
11260            // Calling decoder.out_of_line_offset(0) is not allowed.
11261            if len == 0 {
11262                return Ok(());
11263            };
11264            depth.increment()?;
11265            let envelope_size = 8;
11266            let bytes_len = len * envelope_size;
11267            let offset = decoder.out_of_line_offset(bytes_len)?;
11268            // Decode the envelope for each type.
11269            let mut _next_ordinal_to_read = 0;
11270            let mut next_offset = offset;
11271            let end_offset = offset + bytes_len;
11272            _next_ordinal_to_read += 1;
11273            if next_offset >= end_offset {
11274                return Ok(());
11275            }
11276
11277            // Decode unknown envelopes for gaps in ordinals.
11278            while _next_ordinal_to_read < 1 {
11279                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11280                _next_ordinal_to_read += 1;
11281                next_offset += envelope_size;
11282            }
11283
11284            let next_out_of_line = decoder.next_out_of_line();
11285            let handles_before = decoder.remaining_handles();
11286            if let Some((inlined, num_bytes, num_handles)) =
11287                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11288            {
11289                let member_inline_size =
11290                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11291                        decoder.context,
11292                    );
11293                if inlined != (member_inline_size <= 4) {
11294                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11295                }
11296                let inner_offset;
11297                let mut inner_depth = depth.clone();
11298                if inlined {
11299                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11300                    inner_offset = next_offset;
11301                } else {
11302                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11303                    inner_depth.increment()?;
11304                }
11305                let val_ref =
11306                    self.entire_heap.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11307                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11308                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11309                {
11310                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11311                }
11312                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11313                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11314                }
11315            }
11316
11317            next_offset += envelope_size;
11318
11319            // Decode the remaining unknown envelopes.
11320            while next_offset < end_offset {
11321                _next_ordinal_to_read += 1;
11322                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11323                next_offset += envelope_size;
11324            }
11325
11326            Ok(())
11327        }
11328    }
11329
11330    impl SecureMemModifySecureHeapPhysicalRangeRequest {
11331        #[inline(always)]
11332        fn max_ordinal_present(&self) -> u64 {
11333            if let Some(_) = self.range_modification {
11334                return 1;
11335            }
11336            0
11337        }
11338    }
11339
11340    impl fidl::encoding::ValueTypeMarker for SecureMemModifySecureHeapPhysicalRangeRequest {
11341        type Borrowed<'a> = &'a Self;
11342        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11343            value
11344        }
11345    }
11346
11347    unsafe impl fidl::encoding::TypeMarker for SecureMemModifySecureHeapPhysicalRangeRequest {
11348        type Owned = Self;
11349
11350        #[inline(always)]
11351        fn inline_align(_context: fidl::encoding::Context) -> usize {
11352            8
11353        }
11354
11355        #[inline(always)]
11356        fn inline_size(_context: fidl::encoding::Context) -> usize {
11357            16
11358        }
11359    }
11360
11361    unsafe impl<D: fidl::encoding::ResourceDialect>
11362        fidl::encoding::Encode<SecureMemModifySecureHeapPhysicalRangeRequest, D>
11363        for &SecureMemModifySecureHeapPhysicalRangeRequest
11364    {
11365        unsafe fn encode(
11366            self,
11367            encoder: &mut fidl::encoding::Encoder<'_, D>,
11368            offset: usize,
11369            mut depth: fidl::encoding::Depth,
11370        ) -> fidl::Result<()> {
11371            encoder.debug_check_bounds::<SecureMemModifySecureHeapPhysicalRangeRequest>(offset);
11372            // Vector header
11373            let max_ordinal: u64 = self.max_ordinal_present();
11374            encoder.write_num(max_ordinal, offset);
11375            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11376            // Calling encoder.out_of_line_offset(0) is not allowed.
11377            if max_ordinal == 0 {
11378                return Ok(());
11379            }
11380            depth.increment()?;
11381            let envelope_size = 8;
11382            let bytes_len = max_ordinal as usize * envelope_size;
11383            #[allow(unused_variables)]
11384            let offset = encoder.out_of_line_offset(bytes_len);
11385            let mut _prev_end_offset: usize = 0;
11386            if 1 > max_ordinal {
11387                return Ok(());
11388            }
11389
11390            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11391            // are envelope_size bytes.
11392            let cur_offset: usize = (1 - 1) * envelope_size;
11393
11394            // Zero reserved fields.
11395            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11396
11397            // Safety:
11398            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11399            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11400            //   envelope_size bytes, there is always sufficient room.
11401            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRangeModification, D>(
11402                self.range_modification.as_ref().map(
11403                    <SecureHeapAndRangeModification as fidl::encoding::ValueTypeMarker>::borrow,
11404                ),
11405                encoder,
11406                offset + cur_offset,
11407                depth,
11408            )?;
11409
11410            _prev_end_offset = cur_offset + envelope_size;
11411
11412            Ok(())
11413        }
11414    }
11415
11416    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11417        for SecureMemModifySecureHeapPhysicalRangeRequest
11418    {
11419        #[inline(always)]
11420        fn new_empty() -> Self {
11421            Self::default()
11422        }
11423
11424        unsafe fn decode(
11425            &mut self,
11426            decoder: &mut fidl::encoding::Decoder<'_, D>,
11427            offset: usize,
11428            mut depth: fidl::encoding::Depth,
11429        ) -> fidl::Result<()> {
11430            decoder.debug_check_bounds::<Self>(offset);
11431            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11432                None => return Err(fidl::Error::NotNullable),
11433                Some(len) => len,
11434            };
11435            // Calling decoder.out_of_line_offset(0) is not allowed.
11436            if len == 0 {
11437                return Ok(());
11438            };
11439            depth.increment()?;
11440            let envelope_size = 8;
11441            let bytes_len = len * envelope_size;
11442            let offset = decoder.out_of_line_offset(bytes_len)?;
11443            // Decode the envelope for each type.
11444            let mut _next_ordinal_to_read = 0;
11445            let mut next_offset = offset;
11446            let end_offset = offset + bytes_len;
11447            _next_ordinal_to_read += 1;
11448            if next_offset >= end_offset {
11449                return Ok(());
11450            }
11451
11452            // Decode unknown envelopes for gaps in ordinals.
11453            while _next_ordinal_to_read < 1 {
11454                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11455                _next_ordinal_to_read += 1;
11456                next_offset += envelope_size;
11457            }
11458
11459            let next_out_of_line = decoder.next_out_of_line();
11460            let handles_before = decoder.remaining_handles();
11461            if let Some((inlined, num_bytes, num_handles)) =
11462                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11463            {
11464                let member_inline_size =
11465                    <SecureHeapAndRangeModification as fidl::encoding::TypeMarker>::inline_size(
11466                        decoder.context,
11467                    );
11468                if inlined != (member_inline_size <= 4) {
11469                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11470                }
11471                let inner_offset;
11472                let mut inner_depth = depth.clone();
11473                if inlined {
11474                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11475                    inner_offset = next_offset;
11476                } else {
11477                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11478                    inner_depth.increment()?;
11479                }
11480                let val_ref = self
11481                    .range_modification
11482                    .get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRangeModification, D));
11483                fidl::decode!(
11484                    SecureHeapAndRangeModification,
11485                    D,
11486                    val_ref,
11487                    decoder,
11488                    inner_offset,
11489                    inner_depth
11490                )?;
11491                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11492                {
11493                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11494                }
11495                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11496                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11497                }
11498            }
11499
11500            next_offset += envelope_size;
11501
11502            // Decode the remaining unknown envelopes.
11503            while next_offset < end_offset {
11504                _next_ordinal_to_read += 1;
11505                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11506                next_offset += envelope_size;
11507            }
11508
11509            Ok(())
11510        }
11511    }
11512
11513    impl SecureMemZeroSubRangeRequest {
11514        #[inline(always)]
11515        fn max_ordinal_present(&self) -> u64 {
11516            if let Some(_) = self.heap_range {
11517                return 2;
11518            }
11519            if let Some(_) = self.is_covering_range_explicit {
11520                return 1;
11521            }
11522            0
11523        }
11524    }
11525
11526    impl fidl::encoding::ValueTypeMarker for SecureMemZeroSubRangeRequest {
11527        type Borrowed<'a> = &'a Self;
11528        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11529            value
11530        }
11531    }
11532
11533    unsafe impl fidl::encoding::TypeMarker for SecureMemZeroSubRangeRequest {
11534        type Owned = Self;
11535
11536        #[inline(always)]
11537        fn inline_align(_context: fidl::encoding::Context) -> usize {
11538            8
11539        }
11540
11541        #[inline(always)]
11542        fn inline_size(_context: fidl::encoding::Context) -> usize {
11543            16
11544        }
11545    }
11546
11547    unsafe impl<D: fidl::encoding::ResourceDialect>
11548        fidl::encoding::Encode<SecureMemZeroSubRangeRequest, D> for &SecureMemZeroSubRangeRequest
11549    {
11550        unsafe fn encode(
11551            self,
11552            encoder: &mut fidl::encoding::Encoder<'_, D>,
11553            offset: usize,
11554            mut depth: fidl::encoding::Depth,
11555        ) -> fidl::Result<()> {
11556            encoder.debug_check_bounds::<SecureMemZeroSubRangeRequest>(offset);
11557            // Vector header
11558            let max_ordinal: u64 = self.max_ordinal_present();
11559            encoder.write_num(max_ordinal, offset);
11560            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11561            // Calling encoder.out_of_line_offset(0) is not allowed.
11562            if max_ordinal == 0 {
11563                return Ok(());
11564            }
11565            depth.increment()?;
11566            let envelope_size = 8;
11567            let bytes_len = max_ordinal as usize * envelope_size;
11568            #[allow(unused_variables)]
11569            let offset = encoder.out_of_line_offset(bytes_len);
11570            let mut _prev_end_offset: usize = 0;
11571            if 1 > max_ordinal {
11572                return Ok(());
11573            }
11574
11575            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11576            // are envelope_size bytes.
11577            let cur_offset: usize = (1 - 1) * envelope_size;
11578
11579            // Zero reserved fields.
11580            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11581
11582            // Safety:
11583            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11584            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11585            //   envelope_size bytes, there is always sufficient room.
11586            fidl::encoding::encode_in_envelope_optional::<bool, D>(
11587                self.is_covering_range_explicit
11588                    .as_ref()
11589                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11590                encoder,
11591                offset + cur_offset,
11592                depth,
11593            )?;
11594
11595            _prev_end_offset = cur_offset + envelope_size;
11596            if 2 > max_ordinal {
11597                return Ok(());
11598            }
11599
11600            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11601            // are envelope_size bytes.
11602            let cur_offset: usize = (2 - 1) * envelope_size;
11603
11604            // Zero reserved fields.
11605            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11606
11607            // Safety:
11608            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11609            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11610            //   envelope_size bytes, there is always sufficient room.
11611            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11612                self.heap_range
11613                    .as_ref()
11614                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11615                encoder,
11616                offset + cur_offset,
11617                depth,
11618            )?;
11619
11620            _prev_end_offset = cur_offset + envelope_size;
11621
11622            Ok(())
11623        }
11624    }
11625
11626    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11627        for SecureMemZeroSubRangeRequest
11628    {
11629        #[inline(always)]
11630        fn new_empty() -> Self {
11631            Self::default()
11632        }
11633
11634        unsafe fn decode(
11635            &mut self,
11636            decoder: &mut fidl::encoding::Decoder<'_, D>,
11637            offset: usize,
11638            mut depth: fidl::encoding::Depth,
11639        ) -> fidl::Result<()> {
11640            decoder.debug_check_bounds::<Self>(offset);
11641            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11642                None => return Err(fidl::Error::NotNullable),
11643                Some(len) => len,
11644            };
11645            // Calling decoder.out_of_line_offset(0) is not allowed.
11646            if len == 0 {
11647                return Ok(());
11648            };
11649            depth.increment()?;
11650            let envelope_size = 8;
11651            let bytes_len = len * envelope_size;
11652            let offset = decoder.out_of_line_offset(bytes_len)?;
11653            // Decode the envelope for each type.
11654            let mut _next_ordinal_to_read = 0;
11655            let mut next_offset = offset;
11656            let end_offset = offset + bytes_len;
11657            _next_ordinal_to_read += 1;
11658            if next_offset >= end_offset {
11659                return Ok(());
11660            }
11661
11662            // Decode unknown envelopes for gaps in ordinals.
11663            while _next_ordinal_to_read < 1 {
11664                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11665                _next_ordinal_to_read += 1;
11666                next_offset += envelope_size;
11667            }
11668
11669            let next_out_of_line = decoder.next_out_of_line();
11670            let handles_before = decoder.remaining_handles();
11671            if let Some((inlined, num_bytes, num_handles)) =
11672                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11673            {
11674                let member_inline_size =
11675                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11676                if inlined != (member_inline_size <= 4) {
11677                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11678                }
11679                let inner_offset;
11680                let mut inner_depth = depth.clone();
11681                if inlined {
11682                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11683                    inner_offset = next_offset;
11684                } else {
11685                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11686                    inner_depth.increment()?;
11687                }
11688                let val_ref = self
11689                    .is_covering_range_explicit
11690                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
11691                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
11692                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11693                {
11694                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11695                }
11696                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11697                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11698                }
11699            }
11700
11701            next_offset += envelope_size;
11702            _next_ordinal_to_read += 1;
11703            if next_offset >= end_offset {
11704                return Ok(());
11705            }
11706
11707            // Decode unknown envelopes for gaps in ordinals.
11708            while _next_ordinal_to_read < 2 {
11709                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11710                _next_ordinal_to_read += 1;
11711                next_offset += envelope_size;
11712            }
11713
11714            let next_out_of_line = decoder.next_out_of_line();
11715            let handles_before = decoder.remaining_handles();
11716            if let Some((inlined, num_bytes, num_handles)) =
11717                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11718            {
11719                let member_inline_size =
11720                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11721                        decoder.context,
11722                    );
11723                if inlined != (member_inline_size <= 4) {
11724                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11725                }
11726                let inner_offset;
11727                let mut inner_depth = depth.clone();
11728                if inlined {
11729                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11730                    inner_offset = next_offset;
11731                } else {
11732                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11733                    inner_depth.increment()?;
11734                }
11735                let val_ref =
11736                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11737                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11738                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11739                {
11740                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11741                }
11742                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11743                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11744                }
11745            }
11746
11747            next_offset += envelope_size;
11748
11749            // Decode the remaining unknown envelopes.
11750            while next_offset < end_offset {
11751                _next_ordinal_to_read += 1;
11752                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11753                next_offset += envelope_size;
11754            }
11755
11756            Ok(())
11757        }
11758    }
11759
11760    impl SecureMemGetDynamicSecureHeapsResponse {
11761        #[inline(always)]
11762        fn max_ordinal_present(&self) -> u64 {
11763            if let Some(_) = self.heaps {
11764                return 1;
11765            }
11766            0
11767        }
11768    }
11769
11770    impl fidl::encoding::ValueTypeMarker for SecureMemGetDynamicSecureHeapsResponse {
11771        type Borrowed<'a> = &'a Self;
11772        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11773            value
11774        }
11775    }
11776
11777    unsafe impl fidl::encoding::TypeMarker for SecureMemGetDynamicSecureHeapsResponse {
11778        type Owned = Self;
11779
11780        #[inline(always)]
11781        fn inline_align(_context: fidl::encoding::Context) -> usize {
11782            8
11783        }
11784
11785        #[inline(always)]
11786        fn inline_size(_context: fidl::encoding::Context) -> usize {
11787            16
11788        }
11789    }
11790
11791    unsafe impl<D: fidl::encoding::ResourceDialect>
11792        fidl::encoding::Encode<SecureMemGetDynamicSecureHeapsResponse, D>
11793        for &SecureMemGetDynamicSecureHeapsResponse
11794    {
11795        unsafe fn encode(
11796            self,
11797            encoder: &mut fidl::encoding::Encoder<'_, D>,
11798            offset: usize,
11799            mut depth: fidl::encoding::Depth,
11800        ) -> fidl::Result<()> {
11801            encoder.debug_check_bounds::<SecureMemGetDynamicSecureHeapsResponse>(offset);
11802            // Vector header
11803            let max_ordinal: u64 = self.max_ordinal_present();
11804            encoder.write_num(max_ordinal, offset);
11805            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11806            // Calling encoder.out_of_line_offset(0) is not allowed.
11807            if max_ordinal == 0 {
11808                return Ok(());
11809            }
11810            depth.increment()?;
11811            let envelope_size = 8;
11812            let bytes_len = max_ordinal as usize * envelope_size;
11813            #[allow(unused_variables)]
11814            let offset = encoder.out_of_line_offset(bytes_len);
11815            let mut _prev_end_offset: usize = 0;
11816            if 1 > max_ordinal {
11817                return Ok(());
11818            }
11819
11820            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11821            // are envelope_size bytes.
11822            let cur_offset: usize = (1 - 1) * envelope_size;
11823
11824            // Zero reserved fields.
11825            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11826
11827            // Safety:
11828            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11829            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11830            //   envelope_size bytes, there is always sufficient room.
11831            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<DynamicSecureHeap, 32>, D>(
11832            self.heaps.as_ref().map(<fidl::encoding::Vector<DynamicSecureHeap, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11833            encoder, offset + cur_offset, depth
11834        )?;
11835
11836            _prev_end_offset = cur_offset + envelope_size;
11837
11838            Ok(())
11839        }
11840    }
11841
11842    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11843        for SecureMemGetDynamicSecureHeapsResponse
11844    {
11845        #[inline(always)]
11846        fn new_empty() -> Self {
11847            Self::default()
11848        }
11849
11850        unsafe fn decode(
11851            &mut self,
11852            decoder: &mut fidl::encoding::Decoder<'_, D>,
11853            offset: usize,
11854            mut depth: fidl::encoding::Depth,
11855        ) -> fidl::Result<()> {
11856            decoder.debug_check_bounds::<Self>(offset);
11857            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11858                None => return Err(fidl::Error::NotNullable),
11859                Some(len) => len,
11860            };
11861            // Calling decoder.out_of_line_offset(0) is not allowed.
11862            if len == 0 {
11863                return Ok(());
11864            };
11865            depth.increment()?;
11866            let envelope_size = 8;
11867            let bytes_len = len * envelope_size;
11868            let offset = decoder.out_of_line_offset(bytes_len)?;
11869            // Decode the envelope for each type.
11870            let mut _next_ordinal_to_read = 0;
11871            let mut next_offset = offset;
11872            let end_offset = offset + bytes_len;
11873            _next_ordinal_to_read += 1;
11874            if next_offset >= end_offset {
11875                return Ok(());
11876            }
11877
11878            // Decode unknown envelopes for gaps in ordinals.
11879            while _next_ordinal_to_read < 1 {
11880                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11881                _next_ordinal_to_read += 1;
11882                next_offset += envelope_size;
11883            }
11884
11885            let next_out_of_line = decoder.next_out_of_line();
11886            let handles_before = decoder.remaining_handles();
11887            if let Some((inlined, num_bytes, num_handles)) =
11888                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11889            {
11890                let member_inline_size = <fidl::encoding::Vector<DynamicSecureHeap, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11891                if inlined != (member_inline_size <= 4) {
11892                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11893                }
11894                let inner_offset;
11895                let mut inner_depth = depth.clone();
11896                if inlined {
11897                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11898                    inner_offset = next_offset;
11899                } else {
11900                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11901                    inner_depth.increment()?;
11902                }
11903                let val_ref = self.heaps.get_or_insert_with(
11904                    || fidl::new_empty!(fidl::encoding::Vector<DynamicSecureHeap, 32>, D),
11905                );
11906                fidl::decode!(fidl::encoding::Vector<DynamicSecureHeap, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
11907                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11908                {
11909                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11910                }
11911                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11912                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11913                }
11914            }
11915
11916            next_offset += envelope_size;
11917
11918            // Decode the remaining unknown envelopes.
11919            while next_offset < end_offset {
11920                _next_ordinal_to_read += 1;
11921                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11922                next_offset += envelope_size;
11923            }
11924
11925            Ok(())
11926        }
11927    }
11928
11929    impl SecureMemGetPhysicalSecureHeapPropertiesResponse {
11930        #[inline(always)]
11931        fn max_ordinal_present(&self) -> u64 {
11932            if let Some(_) = self.properties {
11933                return 1;
11934            }
11935            0
11936        }
11937    }
11938
11939    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapPropertiesResponse {
11940        type Borrowed<'a> = &'a Self;
11941        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11942            value
11943        }
11944    }
11945
11946    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapPropertiesResponse {
11947        type Owned = Self;
11948
11949        #[inline(always)]
11950        fn inline_align(_context: fidl::encoding::Context) -> usize {
11951            8
11952        }
11953
11954        #[inline(always)]
11955        fn inline_size(_context: fidl::encoding::Context) -> usize {
11956            16
11957        }
11958    }
11959
11960    unsafe impl<D: fidl::encoding::ResourceDialect>
11961        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapPropertiesResponse, D>
11962        for &SecureMemGetPhysicalSecureHeapPropertiesResponse
11963    {
11964        unsafe fn encode(
11965            self,
11966            encoder: &mut fidl::encoding::Encoder<'_, D>,
11967            offset: usize,
11968            mut depth: fidl::encoding::Depth,
11969        ) -> fidl::Result<()> {
11970            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapPropertiesResponse>(offset);
11971            // Vector header
11972            let max_ordinal: u64 = self.max_ordinal_present();
11973            encoder.write_num(max_ordinal, offset);
11974            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11975            // Calling encoder.out_of_line_offset(0) is not allowed.
11976            if max_ordinal == 0 {
11977                return Ok(());
11978            }
11979            depth.increment()?;
11980            let envelope_size = 8;
11981            let bytes_len = max_ordinal as usize * envelope_size;
11982            #[allow(unused_variables)]
11983            let offset = encoder.out_of_line_offset(bytes_len);
11984            let mut _prev_end_offset: usize = 0;
11985            if 1 > max_ordinal {
11986                return Ok(());
11987            }
11988
11989            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11990            // are envelope_size bytes.
11991            let cur_offset: usize = (1 - 1) * envelope_size;
11992
11993            // Zero reserved fields.
11994            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11995
11996            // Safety:
11997            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11998            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11999            //   envelope_size bytes, there is always sufficient room.
12000            fidl::encoding::encode_in_envelope_optional::<SecureHeapProperties, D>(
12001                self.properties
12002                    .as_ref()
12003                    .map(<SecureHeapProperties as fidl::encoding::ValueTypeMarker>::borrow),
12004                encoder,
12005                offset + cur_offset,
12006                depth,
12007            )?;
12008
12009            _prev_end_offset = cur_offset + envelope_size;
12010
12011            Ok(())
12012        }
12013    }
12014
12015    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
12016        for SecureMemGetPhysicalSecureHeapPropertiesResponse
12017    {
12018        #[inline(always)]
12019        fn new_empty() -> Self {
12020            Self::default()
12021        }
12022
12023        unsafe fn decode(
12024            &mut self,
12025            decoder: &mut fidl::encoding::Decoder<'_, D>,
12026            offset: usize,
12027            mut depth: fidl::encoding::Depth,
12028        ) -> fidl::Result<()> {
12029            decoder.debug_check_bounds::<Self>(offset);
12030            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12031                None => return Err(fidl::Error::NotNullable),
12032                Some(len) => len,
12033            };
12034            // Calling decoder.out_of_line_offset(0) is not allowed.
12035            if len == 0 {
12036                return Ok(());
12037            };
12038            depth.increment()?;
12039            let envelope_size = 8;
12040            let bytes_len = len * envelope_size;
12041            let offset = decoder.out_of_line_offset(bytes_len)?;
12042            // Decode the envelope for each type.
12043            let mut _next_ordinal_to_read = 0;
12044            let mut next_offset = offset;
12045            let end_offset = offset + bytes_len;
12046            _next_ordinal_to_read += 1;
12047            if next_offset >= end_offset {
12048                return Ok(());
12049            }
12050
12051            // Decode unknown envelopes for gaps in ordinals.
12052            while _next_ordinal_to_read < 1 {
12053                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12054                _next_ordinal_to_read += 1;
12055                next_offset += envelope_size;
12056            }
12057
12058            let next_out_of_line = decoder.next_out_of_line();
12059            let handles_before = decoder.remaining_handles();
12060            if let Some((inlined, num_bytes, num_handles)) =
12061                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12062            {
12063                let member_inline_size =
12064                    <SecureHeapProperties as fidl::encoding::TypeMarker>::inline_size(
12065                        decoder.context,
12066                    );
12067                if inlined != (member_inline_size <= 4) {
12068                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12069                }
12070                let inner_offset;
12071                let mut inner_depth = depth.clone();
12072                if inlined {
12073                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12074                    inner_offset = next_offset;
12075                } else {
12076                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12077                    inner_depth.increment()?;
12078                }
12079                let val_ref = self
12080                    .properties
12081                    .get_or_insert_with(|| fidl::new_empty!(SecureHeapProperties, D));
12082                fidl::decode!(
12083                    SecureHeapProperties,
12084                    D,
12085                    val_ref,
12086                    decoder,
12087                    inner_offset,
12088                    inner_depth
12089                )?;
12090                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12091                {
12092                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12093                }
12094                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12095                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12096                }
12097            }
12098
12099            next_offset += envelope_size;
12100
12101            // Decode the remaining unknown envelopes.
12102            while next_offset < end_offset {
12103                _next_ordinal_to_read += 1;
12104                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12105                next_offset += envelope_size;
12106            }
12107
12108            Ok(())
12109        }
12110    }
12111
12112    impl SecureMemGetPhysicalSecureHeapsResponse {
12113        #[inline(always)]
12114        fn max_ordinal_present(&self) -> u64 {
12115            if let Some(_) = self.heaps {
12116                return 1;
12117            }
12118            0
12119        }
12120    }
12121
12122    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapsResponse {
12123        type Borrowed<'a> = &'a Self;
12124        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
12125            value
12126        }
12127    }
12128
12129    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapsResponse {
12130        type Owned = Self;
12131
12132        #[inline(always)]
12133        fn inline_align(_context: fidl::encoding::Context) -> usize {
12134            8
12135        }
12136
12137        #[inline(always)]
12138        fn inline_size(_context: fidl::encoding::Context) -> usize {
12139            16
12140        }
12141    }
12142
12143    unsafe impl<D: fidl::encoding::ResourceDialect>
12144        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapsResponse, D>
12145        for &SecureMemGetPhysicalSecureHeapsResponse
12146    {
12147        unsafe fn encode(
12148            self,
12149            encoder: &mut fidl::encoding::Encoder<'_, D>,
12150            offset: usize,
12151            mut depth: fidl::encoding::Depth,
12152        ) -> fidl::Result<()> {
12153            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapsResponse>(offset);
12154            // Vector header
12155            let max_ordinal: u64 = self.max_ordinal_present();
12156            encoder.write_num(max_ordinal, offset);
12157            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12158            // Calling encoder.out_of_line_offset(0) is not allowed.
12159            if max_ordinal == 0 {
12160                return Ok(());
12161            }
12162            depth.increment()?;
12163            let envelope_size = 8;
12164            let bytes_len = max_ordinal as usize * envelope_size;
12165            #[allow(unused_variables)]
12166            let offset = encoder.out_of_line_offset(bytes_len);
12167            let mut _prev_end_offset: usize = 0;
12168            if 1 > max_ordinal {
12169                return Ok(());
12170            }
12171
12172            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12173            // are envelope_size bytes.
12174            let cur_offset: usize = (1 - 1) * envelope_size;
12175
12176            // Zero reserved fields.
12177            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12178
12179            // Safety:
12180            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12181            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12182            //   envelope_size bytes, there is always sufficient room.
12183            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SecureHeapAndRanges, 32>, D>(
12184            self.heaps.as_ref().map(<fidl::encoding::Vector<SecureHeapAndRanges, 32> as fidl::encoding::ValueTypeMarker>::borrow),
12185            encoder, offset + cur_offset, depth
12186        )?;
12187
12188            _prev_end_offset = cur_offset + envelope_size;
12189
12190            Ok(())
12191        }
12192    }
12193
12194    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
12195        for SecureMemGetPhysicalSecureHeapsResponse
12196    {
12197        #[inline(always)]
12198        fn new_empty() -> Self {
12199            Self::default()
12200        }
12201
12202        unsafe fn decode(
12203            &mut self,
12204            decoder: &mut fidl::encoding::Decoder<'_, D>,
12205            offset: usize,
12206            mut depth: fidl::encoding::Depth,
12207        ) -> fidl::Result<()> {
12208            decoder.debug_check_bounds::<Self>(offset);
12209            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12210                None => return Err(fidl::Error::NotNullable),
12211                Some(len) => len,
12212            };
12213            // Calling decoder.out_of_line_offset(0) is not allowed.
12214            if len == 0 {
12215                return Ok(());
12216            };
12217            depth.increment()?;
12218            let envelope_size = 8;
12219            let bytes_len = len * envelope_size;
12220            let offset = decoder.out_of_line_offset(bytes_len)?;
12221            // Decode the envelope for each type.
12222            let mut _next_ordinal_to_read = 0;
12223            let mut next_offset = offset;
12224            let end_offset = offset + bytes_len;
12225            _next_ordinal_to_read += 1;
12226            if next_offset >= end_offset {
12227                return Ok(());
12228            }
12229
12230            // Decode unknown envelopes for gaps in ordinals.
12231            while _next_ordinal_to_read < 1 {
12232                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12233                _next_ordinal_to_read += 1;
12234                next_offset += envelope_size;
12235            }
12236
12237            let next_out_of_line = decoder.next_out_of_line();
12238            let handles_before = decoder.remaining_handles();
12239            if let Some((inlined, num_bytes, num_handles)) =
12240                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12241            {
12242                let member_inline_size = <fidl::encoding::Vector<SecureHeapAndRanges, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12243                if inlined != (member_inline_size <= 4) {
12244                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12245                }
12246                let inner_offset;
12247                let mut inner_depth = depth.clone();
12248                if inlined {
12249                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12250                    inner_offset = next_offset;
12251                } else {
12252                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12253                    inner_depth.increment()?;
12254                }
12255                let val_ref = self.heaps.get_or_insert_with(
12256                    || fidl::new_empty!(fidl::encoding::Vector<SecureHeapAndRanges, 32>, D),
12257                );
12258                fidl::decode!(fidl::encoding::Vector<SecureHeapAndRanges, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
12259                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12260                {
12261                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12262                }
12263                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12264                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12265                }
12266            }
12267
12268            next_offset += envelope_size;
12269
12270            // Decode the remaining unknown envelopes.
12271            while next_offset < end_offset {
12272                _next_ordinal_to_read += 1;
12273                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12274                next_offset += envelope_size;
12275            }
12276
12277            Ok(())
12278        }
12279    }
12280
12281    impl SingleBufferSettings {
12282        #[inline(always)]
12283        fn max_ordinal_present(&self) -> u64 {
12284            if let Some(_) = self.image_format_constraints {
12285                return 2;
12286            }
12287            if let Some(_) = self.buffer_settings {
12288                return 1;
12289            }
12290            0
12291        }
12292    }
12293
12294    impl fidl::encoding::ValueTypeMarker for SingleBufferSettings {
12295        type Borrowed<'a> = &'a Self;
12296        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
12297            value
12298        }
12299    }
12300
12301    unsafe impl fidl::encoding::TypeMarker for SingleBufferSettings {
12302        type Owned = Self;
12303
12304        #[inline(always)]
12305        fn inline_align(_context: fidl::encoding::Context) -> usize {
12306            8
12307        }
12308
12309        #[inline(always)]
12310        fn inline_size(_context: fidl::encoding::Context) -> usize {
12311            16
12312        }
12313    }
12314
12315    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SingleBufferSettings, D>
12316        for &SingleBufferSettings
12317    {
12318        unsafe fn encode(
12319            self,
12320            encoder: &mut fidl::encoding::Encoder<'_, D>,
12321            offset: usize,
12322            mut depth: fidl::encoding::Depth,
12323        ) -> fidl::Result<()> {
12324            encoder.debug_check_bounds::<SingleBufferSettings>(offset);
12325            // Vector header
12326            let max_ordinal: u64 = self.max_ordinal_present();
12327            encoder.write_num(max_ordinal, offset);
12328            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12329            // Calling encoder.out_of_line_offset(0) is not allowed.
12330            if max_ordinal == 0 {
12331                return Ok(());
12332            }
12333            depth.increment()?;
12334            let envelope_size = 8;
12335            let bytes_len = max_ordinal as usize * envelope_size;
12336            #[allow(unused_variables)]
12337            let offset = encoder.out_of_line_offset(bytes_len);
12338            let mut _prev_end_offset: usize = 0;
12339            if 1 > max_ordinal {
12340                return Ok(());
12341            }
12342
12343            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12344            // are envelope_size bytes.
12345            let cur_offset: usize = (1 - 1) * envelope_size;
12346
12347            // Zero reserved fields.
12348            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12349
12350            // Safety:
12351            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12352            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12353            //   envelope_size bytes, there is always sufficient room.
12354            fidl::encoding::encode_in_envelope_optional::<BufferMemorySettings, D>(
12355                self.buffer_settings
12356                    .as_ref()
12357                    .map(<BufferMemorySettings as fidl::encoding::ValueTypeMarker>::borrow),
12358                encoder,
12359                offset + cur_offset,
12360                depth,
12361            )?;
12362
12363            _prev_end_offset = cur_offset + envelope_size;
12364            if 2 > max_ordinal {
12365                return Ok(());
12366            }
12367
12368            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12369            // are envelope_size bytes.
12370            let cur_offset: usize = (2 - 1) * envelope_size;
12371
12372            // Zero reserved fields.
12373            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12374
12375            // Safety:
12376            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12377            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12378            //   envelope_size bytes, there is always sufficient room.
12379            fidl::encoding::encode_in_envelope_optional::<ImageFormatConstraints, D>(
12380                self.image_format_constraints
12381                    .as_ref()
12382                    .map(<ImageFormatConstraints as fidl::encoding::ValueTypeMarker>::borrow),
12383                encoder,
12384                offset + cur_offset,
12385                depth,
12386            )?;
12387
12388            _prev_end_offset = cur_offset + envelope_size;
12389
12390            Ok(())
12391        }
12392    }
12393
12394    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SingleBufferSettings {
12395        #[inline(always)]
12396        fn new_empty() -> Self {
12397            Self::default()
12398        }
12399
12400        unsafe fn decode(
12401            &mut self,
12402            decoder: &mut fidl::encoding::Decoder<'_, D>,
12403            offset: usize,
12404            mut depth: fidl::encoding::Depth,
12405        ) -> fidl::Result<()> {
12406            decoder.debug_check_bounds::<Self>(offset);
12407            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12408                None => return Err(fidl::Error::NotNullable),
12409                Some(len) => len,
12410            };
12411            // Calling decoder.out_of_line_offset(0) is not allowed.
12412            if len == 0 {
12413                return Ok(());
12414            };
12415            depth.increment()?;
12416            let envelope_size = 8;
12417            let bytes_len = len * envelope_size;
12418            let offset = decoder.out_of_line_offset(bytes_len)?;
12419            // Decode the envelope for each type.
12420            let mut _next_ordinal_to_read = 0;
12421            let mut next_offset = offset;
12422            let end_offset = offset + bytes_len;
12423            _next_ordinal_to_read += 1;
12424            if next_offset >= end_offset {
12425                return Ok(());
12426            }
12427
12428            // Decode unknown envelopes for gaps in ordinals.
12429            while _next_ordinal_to_read < 1 {
12430                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12431                _next_ordinal_to_read += 1;
12432                next_offset += envelope_size;
12433            }
12434
12435            let next_out_of_line = decoder.next_out_of_line();
12436            let handles_before = decoder.remaining_handles();
12437            if let Some((inlined, num_bytes, num_handles)) =
12438                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12439            {
12440                let member_inline_size =
12441                    <BufferMemorySettings as fidl::encoding::TypeMarker>::inline_size(
12442                        decoder.context,
12443                    );
12444                if inlined != (member_inline_size <= 4) {
12445                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12446                }
12447                let inner_offset;
12448                let mut inner_depth = depth.clone();
12449                if inlined {
12450                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12451                    inner_offset = next_offset;
12452                } else {
12453                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12454                    inner_depth.increment()?;
12455                }
12456                let val_ref = self
12457                    .buffer_settings
12458                    .get_or_insert_with(|| fidl::new_empty!(BufferMemorySettings, D));
12459                fidl::decode!(
12460                    BufferMemorySettings,
12461                    D,
12462                    val_ref,
12463                    decoder,
12464                    inner_offset,
12465                    inner_depth
12466                )?;
12467                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12468                {
12469                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12470                }
12471                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12472                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12473                }
12474            }
12475
12476            next_offset += envelope_size;
12477            _next_ordinal_to_read += 1;
12478            if next_offset >= end_offset {
12479                return Ok(());
12480            }
12481
12482            // Decode unknown envelopes for gaps in ordinals.
12483            while _next_ordinal_to_read < 2 {
12484                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12485                _next_ordinal_to_read += 1;
12486                next_offset += envelope_size;
12487            }
12488
12489            let next_out_of_line = decoder.next_out_of_line();
12490            let handles_before = decoder.remaining_handles();
12491            if let Some((inlined, num_bytes, num_handles)) =
12492                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12493            {
12494                let member_inline_size =
12495                    <ImageFormatConstraints as fidl::encoding::TypeMarker>::inline_size(
12496                        decoder.context,
12497                    );
12498                if inlined != (member_inline_size <= 4) {
12499                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12500                }
12501                let inner_offset;
12502                let mut inner_depth = depth.clone();
12503                if inlined {
12504                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12505                    inner_offset = next_offset;
12506                } else {
12507                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12508                    inner_depth.increment()?;
12509                }
12510                let val_ref = self
12511                    .image_format_constraints
12512                    .get_or_insert_with(|| fidl::new_empty!(ImageFormatConstraints, D));
12513                fidl::decode!(
12514                    ImageFormatConstraints,
12515                    D,
12516                    val_ref,
12517                    decoder,
12518                    inner_offset,
12519                    inner_depth
12520                )?;
12521                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12522                {
12523                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12524                }
12525                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12526                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12527                }
12528            }
12529
12530            next_offset += envelope_size;
12531
12532            // Decode the remaining unknown envelopes.
12533            while next_offset < end_offset {
12534                _next_ordinal_to_read += 1;
12535                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12536                next_offset += envelope_size;
12537            }
12538
12539            Ok(())
12540        }
12541    }
12542}