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