Skip to main content

fidl_fuchsia_sysmem2_common/
fidl_fuchsia_sysmem2_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub const CPU_USAGE_READ: u32 = 1;
12
13pub const CPU_USAGE_READ_OFTEN: u32 = 2;
14
15pub const CPU_USAGE_WRITE: u32 = 4;
16
17pub const CPU_USAGE_WRITE_OFTEN: u32 = 8;
18
19pub const DISPLAY_USAGE_CURSOR: u32 = 2;
20
21pub const DISPLAY_USAGE_LAYER: u32 = 1;
22
23/// The max length in bytes of the `name` request field in
24/// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] and
25/// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
26pub const MAX_CLIENT_NAME_LENGTH: i32 = 256;
27
28/// The maximum size of
29/// [`fuchsia.sysmem2/BufferCollectionConstraints.image_format_constraints`].
30pub const MAX_COUNT_BUFFER_COLLECTION_CONSTRAINTS_IMAGE_FORMAT_CONSTRAINTS: u32 = 64;
31
32/// The maximum entries that can be in the
33/// [`fuchsia.sysmem2/BufferCollectionInfo.buffers`] field.
34pub const MAX_COUNT_BUFFER_COLLECTION_INFO_BUFFERS: u32 = 128;
35
36/// The maximum size of
37/// [`fuchsia.sysmem2/BufferMemoryConstraints.permitted_heaps`].
38pub const MAX_COUNT_BUFFER_MEMORY_CONSTRAINTS_PERMITTED_HEAPS: u32 = 64;
39
40/// The maximum number of token children of an OR group that can be created per
41/// call to [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`].
42///
43/// Actually creating this many children isn't recommended in most typical
44/// scenarios, but isn't prevented, for testing reasons, and just in case an
45/// unusual scenario needs it. Mitigation of potentially high time complexity in
46/// sysmem will limit the actual number of group child combinations considered
47/// in aggregation attempts to a separate maximum that is not settable via
48/// sysmem protocols. The maximum number of total nodes in a sysmem token tree
49/// is limited to a separate maximum that is not settable via these protocols.
50pub const MAX_COUNT_CREATE_CHILDREN: i32 = 64;
51
52pub const MAX_COUNT_DUPLICATES: u32 = 64;
53
54/// The maximum size of [`fuchsia.sysmem2/ImageFormatConstraints.color_spaces`].
55pub const MAX_COUNT_IMAGE_FORMAT_CONSTRAINTS_COLOR_SPACES: u32 = 32;
56
57pub const MAX_COUNT_IMAGE_FORMAT_CONSTRAINTS_REQUIRED_MAX_SIZE_LIST: u32 = 64;
58
59/// The maximum size of
60/// [`fuchsia.sysmem2/ImageFormatConstraints.pixel_format_and_modifiers`].
61pub const MAX_COUNT_PIXEL_FORMAT_AND_MODIFIERS: u32 = 64;
62
63pub const MAX_HEAPS_COUNT: u32 = 32;
64
65pub const MAX_RANGES_COUNT: u32 = 128;
66
67pub const NONE_USAGE: u32 = 1;
68
69pub const NONE_USAGE_PERMIT_ALLOCATION: u32 = 2;
70
71pub const VIDEO_USAGE_CAPTURE: u32 = 8;
72
73pub const VIDEO_USAGE_DECRYPTOR_OUTPUT: u32 = 16;
74
75pub const VIDEO_USAGE_HW_DECODER: u32 = 1;
76
77pub const VIDEO_USAGE_HW_DECODER_INTERNAL: u32 = 32;
78
79pub const VIDEO_USAGE_HW_ENCODER: u32 = 2;
80
81pub const VULKAN_BUFFER_USAGE_INDEX_BUFFER: u32 = 4194304;
82
83pub const VULKAN_BUFFER_USAGE_INDIRECT_BUFFER: u32 = 16777216;
84
85pub const VULKAN_BUFFER_USAGE_STORAGE_BUFFER: u32 = 2097152;
86
87pub const VULKAN_BUFFER_USAGE_STORAGE_TEXEL_BUFFER: u32 = 524288;
88
89pub const VULKAN_BUFFER_USAGE_TRANSFER_DST: u32 = 131072;
90
91pub const VULKAN_BUFFER_USAGE_TRANSFER_SRC: u32 = 65536;
92
93pub const VULKAN_BUFFER_USAGE_UNIFORM_BUFFER: u32 = 1048576;
94
95pub const VULKAN_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER: u32 = 262144;
96
97pub const VULKAN_BUFFER_USAGE_VERTEX_BUFFER: u32 = 8388608;
98
99pub const VULKAN_IMAGE_USAGE_COLOR_ATTACHMENT: u32 = 16;
100
101pub const VULKAN_IMAGE_USAGE_INPUT_ATTACHMENT: u32 = 128;
102
103pub const VULKAN_IMAGE_USAGE_SAMPLED: u32 = 4;
104
105pub const VULKAN_IMAGE_USAGE_STENCIL_ATTACHMENT: u32 = 32;
106
107pub const VULKAN_IMAGE_USAGE_STORAGE: u32 = 8;
108
109pub const VULKAN_IMAGE_USAGE_TRANSFER_DST: u32 = 2;
110
111pub const VULKAN_IMAGE_USAGE_TRANSFER_SRC: u32 = 1;
112
113pub const VULKAN_IMAGE_USAGE_TRANSIENT_ATTACHMENT: u32 = 64;
114
115/// `INACCESSIBLE` is only for cases where there is no CPU access to the
116/// buffers.
117///
118/// Device-local memory that isn't reachable from the CPU is `CoherencyDomain`
119/// `INACCESSIBLE`, even if it's possible to cause a device (physical or
120/// virtual) to copy the data from the `INACCESSIBLE` buffers to buffers that
121/// are visible to the CPU. In other words, INACCESSIBLE does not imply secure,
122/// but secure implies INACCESSIBLE.
123///
124/// `CPU` means producers must ensure that a consumer can read the produced data
125/// with the CPU without the consumer needing to do additional cache ops not
126/// already performed (as needed) by the producer.
127///
128/// `RAM` means producers must ensure that the produced data is entirely present
129/// in RAM, without any dirty CPU cache lines, and a consumer must invalidate
130/// (or flush and invalidate, typically) the CPU cache before reading data with
131/// the CPU. The `RAM` domain can be faster than the `CPU` domain when all
132/// access is via HW DMA, since in that case no CPU cache ops are required,
133/// since no participant is actually reading/writing using the CPU.
134#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
135pub enum CoherencyDomain {
136    Cpu,
137    Ram,
138    Inaccessible,
139    #[doc(hidden)]
140    __SourceBreaking {
141        unknown_ordinal: u32,
142    },
143}
144
145/// Pattern that matches an unknown `CoherencyDomain` member.
146#[macro_export]
147macro_rules! CoherencyDomainUnknown {
148    () => {
149        _
150    };
151}
152
153impl CoherencyDomain {
154    #[inline]
155    pub fn from_primitive(prim: u32) -> Option<Self> {
156        match prim {
157            0 => Some(Self::Cpu),
158            1 => Some(Self::Ram),
159            2 => Some(Self::Inaccessible),
160            _ => None,
161        }
162    }
163
164    #[inline]
165    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
166        match prim {
167            0 => Self::Cpu,
168            1 => Self::Ram,
169            2 => Self::Inaccessible,
170            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
171        }
172    }
173
174    #[inline]
175    pub fn unknown() -> Self {
176        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
177    }
178
179    #[inline]
180    pub const fn into_primitive(self) -> u32 {
181        match self {
182            Self::Cpu => 0,
183            Self::Ram => 1,
184            Self::Inaccessible => 2,
185            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
186        }
187    }
188
189    #[inline]
190    pub fn is_unknown(&self) -> bool {
191        match self {
192            Self::__SourceBreaking { unknown_ordinal: _ } => true,
193            _ => false,
194        }
195    }
196}
197
198/// Regardless of which error code, any client retries should be very limited in
199/// number, if any.
200///
201/// A Error value should never be stored in a zx_status_t, since positive values
202/// in zx_status_t are deprecated.
203#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
204pub enum Error {
205    /// This is not a valid error value in this error enum. The server will
206    /// never send this value as a failure code. This value is not treated as
207    /// "success". In some languages, a locally default-initialized Error
208    /// instance will have this value until it is initialized with a valid
209    /// positive error code.
210    Invalid,
211    /// Unspecified error.
212    ///
213    /// This error code is used when no other error code applies, and the error
214    /// is probably not due to problematic messages sent to the server via the
215    /// channel delivering this error.
216    ///
217    /// This error should be handled by the client as a generic error.
218    ///
219    /// As one example, this error is used when a different client channel has
220    /// closed from the client end unexpectedly (without sending
221    /// [`fuchsia.sysmem2/Node.Release`] first), thereby causing failure of any
222    /// nodes in the same tree or sub-tree. In this usage, the main thing that's
223    /// relevant is it isn't the receiving client's "fault" - no reason to be
224    /// more specific since there's probably nothing the receiving client could
225    /// do about the error, at least not directly.
226    ///
227    /// As another example, this error can be used if a syscall that is normally
228    /// expected to succeed fails unexpectedly, and there's no identified reason
229    /// to "blame" the client.
230    ///
231    /// A client should never require / depend on a particular cause of error
232    /// continuing to result in UNSPECIFIED, as any particular error cause can
233    /// potentially start resulting in a more specific error code in future.
234    Unspecified,
235    /// A required field wasn't set or a specified value was invalid. See the
236    /// log for more info.
237    ///
238    /// This is also used when a message is received from the client in the
239    /// wrong order or in some way inconsistent with protocol rules.
240    ProtocolDeviation,
241    /// A client-specified object or ID was not found.
242    NotFound,
243    /// The object handle doesn't have sufficient rights to perform the request.
244    HandleAccessDenied,
245    /// The allocation could not be satisfied due to lack of available memory.
246    ///
247    /// The memory exhaustion can be specific to the heap that was selected
248    /// during constraints aggregation, so in some cases, this error can happen
249    /// despite normal system RAM not being near exhaustion, depending on
250    /// configured and selected heap(s).
251    NoMemory,
252    /// The request is valid but cannot be satisfied, perhaps due to hardware
253    /// limitations. This happens if participants involved in this allocation
254    /// have incompatible constraints (empty intersection, roughly speaking).
255    /// See the log for more info. In cases where a participant could
256    /// potentially be treated as optional, see [`BufferCollectionTokenGroup`].
257    ///
258    /// This can also happen if there aren't enough buffers in a pre-existing
259    /// collection to satisfy an additional token (including sub-tree of derived
260    /// tokens) created with [`fuchsia.sysmem2/BufferCollection.AttachToken`].
261    ///
262    /// This can also happen if a client's node is under a group and a different
263    /// group child is selected instead.
264    ConstraintsIntersectionEmpty,
265    /// Allocation hasn't been attempted yet. Calling
266    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] would
267    /// (likely) block.
268    Pending,
269    /// Too many `BufferCollectionTokenGroup` child token selection combinations
270    /// exist and were considered, causing sysmem to give up on allocating
271    /// rather than enumerate the rest.
272    TooManyGroupChildCombinations,
273    /// `GetVmoInfo` can fail with this error if `need_weak` is set to true and
274    /// no more strong vmo handles remain to the logical buffer.
275    NoMoreStrongVmoHandles,
276    #[doc(hidden)]
277    __SourceBreaking { unknown_ordinal: u32 },
278}
279
280/// Pattern that matches an unknown `Error` member.
281#[macro_export]
282macro_rules! ErrorUnknown {
283    () => {
284        _
285    };
286}
287
288impl Error {
289    #[inline]
290    pub fn from_primitive(prim: u32) -> Option<Self> {
291        match prim {
292            0 => Some(Self::Invalid),
293            1 => Some(Self::Unspecified),
294            2 => Some(Self::ProtocolDeviation),
295            3 => Some(Self::NotFound),
296            4 => Some(Self::HandleAccessDenied),
297            5 => Some(Self::NoMemory),
298            6 => Some(Self::ConstraintsIntersectionEmpty),
299            7 => Some(Self::Pending),
300            8 => Some(Self::TooManyGroupChildCombinations),
301            9 => Some(Self::NoMoreStrongVmoHandles),
302            _ => None,
303        }
304    }
305
306    #[inline]
307    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
308        match prim {
309            0 => Self::Invalid,
310            1 => Self::Unspecified,
311            2 => Self::ProtocolDeviation,
312            3 => Self::NotFound,
313            4 => Self::HandleAccessDenied,
314            5 => Self::NoMemory,
315            6 => Self::ConstraintsIntersectionEmpty,
316            7 => Self::Pending,
317            8 => Self::TooManyGroupChildCombinations,
318            9 => Self::NoMoreStrongVmoHandles,
319            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
320        }
321    }
322
323    #[inline]
324    pub fn unknown() -> Self {
325        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
326    }
327
328    #[inline]
329    pub const fn into_primitive(self) -> u32 {
330        match self {
331            Self::Invalid => 0,
332            Self::Unspecified => 1,
333            Self::ProtocolDeviation => 2,
334            Self::NotFound => 3,
335            Self::HandleAccessDenied => 4,
336            Self::NoMemory => 5,
337            Self::ConstraintsIntersectionEmpty => 6,
338            Self::Pending => 7,
339            Self::TooManyGroupChildCombinations => 8,
340            Self::NoMoreStrongVmoHandles => 9,
341            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
342        }
343    }
344
345    #[inline]
346    pub fn is_unknown(&self) -> bool {
347        match self {
348            Self::__SourceBreaking { unknown_ordinal: _ } => true,
349            _ => false,
350        }
351    }
352}
353
354#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
355pub struct PixelFormatAndModifier {
356    /// When specified by a participant in a message to sysmem, this can be any
357    /// `PixelFormat` value that's acceptable to the participant. Specifying
358    /// `kInvalid` is not permitted.
359    ///
360    /// The participant can specify [`fuchsia.images2/PixelFormat.DO_NOT_CARE`]
361    /// if the participant needs to specify `ImageFormatConstraints` without
362    /// constraining the `pixel_format`.
363    pub pixel_format: fidl_fuchsia_images2_common::PixelFormat,
364    /// The participant can specify
365    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] if the participant
366    /// needs to specify `ImageFormatConstraints` without constraining the
367    /// `pixel_format_modifier`.
368    pub pixel_format_modifier: fidl_fuchsia_images2_common::PixelFormatModifier,
369}
370
371impl fidl::Persistable for PixelFormatAndModifier {}
372
373#[derive(Clone, Debug, Default, PartialEq)]
374pub struct AllocatorSetDebugClientInfoRequest {
375    pub name: Option<String>,
376    pub id: Option<u64>,
377    #[doc(hidden)]
378    pub __source_breaking: fidl::marker::SourceBreaking,
379}
380
381impl fidl::Persistable for AllocatorSetDebugClientInfoRequest {}
382
383#[derive(Clone, Debug, Default, PartialEq)]
384pub struct AllocatorValidateBufferCollectionTokenRequest {
385    pub token_server_koid: Option<u64>,
386    #[doc(hidden)]
387    pub __source_breaking: fidl::marker::SourceBreaking,
388}
389
390impl fidl::Persistable for AllocatorValidateBufferCollectionTokenRequest {}
391
392#[derive(Clone, Debug, Default, PartialEq)]
393pub struct AllocatorValidateBufferCollectionTokenResponse {
394    pub is_known: Option<bool>,
395    #[doc(hidden)]
396    pub __source_breaking: fidl::marker::SourceBreaking,
397}
398
399impl fidl::Persistable for AllocatorValidateBufferCollectionTokenResponse {}
400
401/// Constraints on allocated buffers and, optionally, constraints on images
402/// stored in the buffers. These constraints can be specified per-participant.
403/// The sysmem service implements aggregation of constraints from multiple
404/// participants.
405#[derive(Clone, Debug, Default, PartialEq)]
406pub struct BufferCollectionConstraints {
407    /// The `usage` is a hint to sysmem to potentially help choose a more
408    /// optimal [`fuchsia.images2/PixelFormat`] and/or `pixel_format_modifier`
409    /// when multiple compatible options exist.
410    ///
411    /// When aggregating [`fuchsia.sysmem2/BufferCollectionConstraints`], these
412    /// values bitwise-OR.
413    ///
414    /// At least one `usage` bit must be specified (however, it's permitted for
415    /// a [`fuchsia.sysmem2/BufferCollection.SetConstraints`] request to have
416    /// the request `constraints` field not set, in which case `kNoneUsage` is
417    /// the default, along with no constraints from the participant).
418    ///
419    /// When `kNoneUsage` is specified it must be the only set bit, and no VMOs
420    /// will be sent in response to
421    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
422    pub usage: Option<BufferUsage>,
423    /// Per-participant number of buffers that the participant may concurrently
424    /// hold for its exclusive use for more than a transient duration (camp on).
425    /// In this context, a "transient" duration is the time it takes to finish
426    /// running a small amount of non-blocking code that finishes transfering
427    /// away ownership of the buffer. Things like reading from storage, waiting
428    /// on hardware that isn't already known to be done, or doing things like
429    /// frame encode or decode are not considered transient durations, even if
430    /// they might sometimes complete quickly.
431    ///
432    /// For example, a video decoder would specify (at least) the maximum number
433    /// of reference frames + 1 frame currently being decoded into. But not 1
434    /// more for the code that runs async and quickly to deliver a previously
435    /// decoded frame, even though that frame can potentially be owned for a
436    /// transient duration concurrent with decode of the next frame.
437    ///
438    /// A participant must not camp on more buffers than specified here (except
439    /// for a transient duration) else processing may get stuck.
440    ///
441    /// When aggregating BufferCollectionConstraints, these values add.
442    ///
443    /// In testing scenarios, camping on more buffers than this for any
444    /// significant duration (one screen refresh period is "significant" in this
445    /// context) may (ideally will) be flagged as a failure.  In testing
446    /// scenarios, the participant may not be provided with more buffers than
447    /// this concurrently.
448    pub min_buffer_count_for_camping: Option<u32>,
449    /// Per-participant minimum number of buffers that are needed for slack
450    /// reasons, for better overlap of processing / better performance.
451    ///
452    /// When aggregating `BufferCollectionConstraints`, these values add.
453    ///
454    /// A participant should typically specify 0 or 1 here - typically 0 is
455    /// appropriate if `min_buffer_count_for_camping` is already enough to keep
456    /// the participant busy 100% of the time when the participant is slightly
457    /// behind, while 1 can be appropriate if 1 more buffer than strictly needed
458    /// for min-camping reasons gives enough slack to stay busy 100% of the time
459    /// (when slightly behind, vs. lower % without the extra buffer).
460    ///
461    /// In testing scenarios, this field may be forced to 0, and all
462    /// participants are expected to continue to work without getting stuck. If
463    /// a buffer is needed for forward progress reasons, that buffer should be
464    /// accounted for in `min_buffer_count_for_camping`.
465    pub min_buffer_count_for_dedicated_slack: Option<u32>,
466    /// Similar to `min_buffer_count_for_dedicated_slack`, except when
467    /// aggregating these values max (instead of add). The value here is not
468    /// shared with any participant's `min_buffer_count_for_dedicated_slack`.
469    ///
470    /// A participant can specify > 0 here if a participant would like to ensure
471    /// there's some slack overall, but doesn't need that slack to be dedicated.
472    ///
473    /// The choice whether to use `min_buffer_count_for_dedicated_slack` or
474    /// `min_buffer_count_for_shared_slack` (or both) will typically be about
475    /// the degree to which the extra slack improves performance.
476    ///
477    /// In testing scenarios, this field may be forced to 0, and all
478    /// participants are expected to continue to work without getting stuck. If
479    /// a buffer is needed for forward progress reasons, that buffer should be
480    /// accounted for in `min_buffer_count_for_camping`.
481    pub min_buffer_count_for_shared_slack: Option<u32>,
482    /// A particularly-picky participant may unfortunately need to demand a
483    /// tight range of `buffer_count`, or even a specific `buffer_count`. This
484    /// field should remain 0 unless a participant really must set this field to
485    /// constrain the overall `BufferCollectionInfo.buffer_count`. Any such
486    /// participant should still fill out the min_buffer_count_for_* fields as
487    /// appropriate.
488    ///
489    /// If this field is un-set, the logical `min_buffer_count` is 0.
490    pub min_buffer_count: Option<u32>,
491    /// A particularly-picky participant may unfortunately need to demand a
492    /// tight range of `buffer_count`, or even a specific `buffer_count`. This
493    /// field should remain 0 unless a participant really must set this field to
494    /// constrain the overall `BufferCollectionInfo.buffer_count`. Any such
495    /// participant should still fill out the min_buffer_count_for_* fields.
496    ///
497    /// If this field is un-set, the logical `max_buffer_count` is 0xFFFFFFFF.
498    pub max_buffer_count: Option<u32>,
499    /// Optional constraints on `BufferCollectionSettings.buffer_settings`.
500    ///
501    /// A participant that intends to set `image_format_constraints` will
502    /// typically specify the minimum buffer size implicitly via
503    /// `image_format_constraints`, and possibly specify only the max buffer
504    /// size via `buffer_memory_constraints`.
505    ///
506    /// If un-set, the client is specifying "don't care" re. any buffer memory
507    /// constraints.
508    pub buffer_memory_constraints: Option<BufferMemoryConstraints>,
509    /// Optional constraints on the image format parameters of an image stored
510    /// in a buffer of the collection. This includes
511    /// [`fuchsia.images2/PixelFormat`] and `pixel_format_modifier` (for tiling
512    /// and the like). These constraints can be specified separately per
513    /// `pixel_format` `pixel_format_modifier` pair. Duplicated `pixel_format`
514    /// `pixel_format_modifier` pairs aren't permitted.
515    ///
516    /// When aggregating, only `pixel_format` `pixel_format_modifier` pairs that
517    /// are specified by all participants with non-zero
518    /// `image_format_constraints` size (and non-null)
519    /// BufferCollectionConstraints) are retained.
520    ///
521    /// A participant can specify `pixel_format`
522    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] and/or
523    /// `pixel_format_modifier`
524    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] to permit any value
525    /// to be selected, but at least one participant must specify a specific
526    /// format for overall allocation to succeed.
527    ///
528    /// In a SetConstraints message, un-set or zero length means no image format
529    /// constraints; a raw buffer can be allocated if no other participants
530    /// specify any `image_format_constraints` entries.
531    pub image_format_constraints: Option<Vec<ImageFormatConstraints>>,
532    #[doc(hidden)]
533    pub __source_breaking: fidl::marker::SourceBreaking,
534}
535
536impl fidl::Persistable for BufferCollectionConstraints {}
537
538#[derive(Clone, Debug, Default, PartialEq)]
539pub struct BufferCollectionTokenDuplicateSyncRequest {
540    pub rights_attenuation_masks: Option<Vec<fidl::Rights>>,
541    #[doc(hidden)]
542    pub __source_breaking: fidl::marker::SourceBreaking,
543}
544
545impl fidl::Persistable for BufferCollectionTokenDuplicateSyncRequest {}
546
547#[derive(Clone, Debug, Default, PartialEq)]
548pub struct BufferCollectionTokenGroupCreateChildrenSyncRequest {
549    pub rights_attenuation_masks: Option<Vec<fidl::Rights>>,
550    #[doc(hidden)]
551    pub __source_breaking: fidl::marker::SourceBreaking,
552}
553
554impl fidl::Persistable for BufferCollectionTokenGroupCreateChildrenSyncRequest {}
555
556#[derive(Clone, Debug, Default, PartialEq)]
557pub struct BufferMemoryConstraints {
558    /// un-set is treated as 1
559    pub min_size_bytes: Option<u64>,
560    /// un-set is treated as 0xFFFFFFFFFFFFFFFF.
561    pub max_size_bytes: Option<u64>,
562    /// When false, physical pages of a buffer VMO can be non-contiguous. When
563    /// true, physical pages of a buffer VMO must be sequentially contiguous. A
564    /// client that doesn't require physically contiguous VMOs must still accept
565    /// physically contiguous VMOs or "physical" VMOs.
566    pub physically_contiguous_required: Option<bool>,
567    /// If true, the participant requires secure memory.
568    ///
569    /// When aggregating `BufferCollectionConstraints`, these values boolean-OR.
570    pub secure_required: Option<bool>,
571    /// When true (or when `BufferMemoryConstraints` is not present), the
572    /// participant is ok with sysmem selecting the CPU domain.
573    ///
574    /// If the CPU domain is selected, participants must ensure the CPU can read
575    /// or write data to the buffer without cache operations outside of the
576    /// participant.
577    ///
578    /// In other words, if a producer participant DMAs data directly to RAM on a
579    /// non-cache-coherent architecture such as arm, the producer must ensure
580    /// the CPU cache is clean wrt. the buffer before the DMA write, and
581    /// invalidate the CPU cache after the DMA write and before indicating that
582    /// the buffer is ready to any other participant. If a consumer participant
583    /// DMAs data directly from RAM on a non-cache-coherent architecture such as
584    /// arm, the consumer must flush the CPU cache wrt the buffer before the DMA
585    /// read.
586    ///
587    /// CPU-only participants that don't do any DMA can just write and read the
588    /// buffers (when they should) without needing to do any CPU cache ops.
589    pub cpu_domain_supported: Option<bool>,
590    /// When true, the participant is ok with sysmem selecting the RAM domain.
591    ///
592    /// If the RAM domain is selected, producer data must be available in RAM
593    /// (with CPU cache state such that the RAM data won't get corrupted by a
594    /// dirty CPU cache line writing incorrect data to RAM), and a consumer
595    /// reading using the CPU must invalidate CPU cache before reading (the
596    /// producer doesn't guarantee zero stale "clean" cache lines).
597    ///
598    /// In other words, if a producer participant uses the CPU to write data on
599    /// a non-cache-coherent architecture such as arm, the producer must flush
600    /// the data to RAM before indicating to another participant that the buffer
601    /// is ready. If a consumer participant uses the CPU to read data on a
602    /// non-cache-coherent architecture such as arm, the participant must
603    /// invalidate (typically flush+invalidate with knowledge that no cache
604    /// lines are dirty) the CPU cache before reading the buffer.
605    ///
606    /// RAM-only participants that don't do any CPU accesses to a buffer can
607    /// just do DMA to/from the buffers (when they should) without needing to
608    /// do any CPU cache ops.
609    pub ram_domain_supported: Option<bool>,
610    /// When true, the participant is ok with sysmem selecting the INACCESSIBLE
611    /// domain.
612    ///
613    /// If the INACCESSIBLE domain is selected, CPU reads and writes of the data
614    /// are prevented. Attempts to read/write the data with the CPU may result
615    /// in UB and/or process termination.
616    ///
617    /// If the INACCESSIBLE domain is selected, participants must only operate
618    /// on the data using DMAs performed by HW, or platform-specific DMA-like
619    /// requests to a secure environment (which will do the needed CPU cache ops
620    /// similar to how a RAM domain participant would operate).
621    ///
622    /// Secure heaps only support INACCESSIBLE domain, and will fail allocation
623    /// if any participant with `BufferUsage` other than `NONE_USAGE` does not
624    /// set inaccessible_domain_supported to true.
625    ///
626    /// When the INACCESSIBLE domain is selected, participants (outside of
627    /// secure/DRM environments) should not attempt to map buffers, and should
628    /// not attempt to perform any CPU cache ops. In this respect, this domain
629    /// is similar to RAM domain with all participants only doing DMA and no
630    /// participant(s) doing CPU accesses.
631    pub inaccessible_domain_supported: Option<bool>,
632    /// Which heaps are acceptable to the participant. Participants that don't
633    /// care which heap memory is allocated on should leave this field un-set. A
634    /// secure heap is only selected if all participants explicitly indicate
635    /// that the secure heap is acceptable via `heap_permitted`, or specify
636    /// `NONE_USAGE`.
637    pub permitted_heaps: Option<Vec<Heap>>,
638    /// If physically_contiguous_required is false or un-set, this field must
639    /// also be un-set.
640    ///
641    /// When set, this field must be non-zero and must be a power of 2 (only 1
642    /// bit set to 1, rest all 0).
643    ///
644    /// When set, this is the minimum alignment of the base physical address of
645    /// each buffer.
646    pub min_physical_base_alignment: Option<u64>,
647    #[doc(hidden)]
648    pub __source_breaking: fidl::marker::SourceBreaking,
649}
650
651impl fidl::Persistable for BufferMemoryConstraints {}
652
653/// These are memory-related settings for all buffers of a buffer collection.
654#[derive(Clone, Debug, Default, PartialEq)]
655pub struct BufferMemorySettings {
656    /// This field will always be set by sysmem.
657    ///
658    /// Rule for producers: For `BufferCollectionInfo` with
659    /// `ImageFormatConstraints`, storing an image of a given `ImageFormat` in a
660    /// buffer of that `BufferCollection` is only allowed if the result of
661    /// calling `ImageFormatImageSize` or a strictly equivalent computation is
662    /// less than or equal to `size_bytes`.
663    ///
664    /// Producer participants _must_ stay within `size_bytes` when determining
665    /// whether an image will fit in a buffer, even if the VMO's size is larger
666    /// than this.
667    ///
668    /// Failure of a producer to use `size_bytes` as the constraint (not VMO
669    /// size) when determining whether a given `ImageFormat` will fit in a
670    /// buffer will, in general, cause problems for any participant that has set
671    /// ImageFormatConstraints.pad_for_block_size to larger than {1, 1}, or
672    /// pad_beyond_image_size_bytes to greater than 0. Those participants rely
673    /// on the ability to access bytes in the VMO beyond the image size. Putting
674    /// an image in the VMO that exceeds `size_bytes` can potentially lead to
675    /// those participants trying to access an offset beyond the last page of
676    /// the VMO.
677    ///
678    /// Similarly, any future padding-only constraint which is irrelevant to a
679    /// non-padding participant when locating each valid pixel's valid data will
680    /// also be accounted for by checking `ImageFormatImageSize()` against
681    /// `size_bytes` instead of the VMO size.
682    ///
683    /// Following this rule allows producers to not need to worry about
684    /// arbitrary padding requirements of participants, including future-added
685    /// padding-only constraints.
686    ///
687    /// The `bytes_per_row` and rounding up to a tile size boundary are included
688    /// in `ImageFormatImageSize` and accounted for in `size_bytes`, even though
689    /// these two aspects are partially about padding. These two aspects are
690    /// included in the `ImageFormatImageSize` calculation because these two
691    /// aspects are also relevant to all participants that need to locate pixel
692    /// data. The `fuchsia.images2.ImageFormat` intentionally doesn't contain
693    /// any padding-only fields.
694    ///
695    /// Participants with a padding constraint (in addition to `bytes_per_row`
696    /// or tile size boundary), such as pad_for_block_size or
697    /// pad_beyond_image_size_bytes, are allowed to access, but not treat as
698    /// meaningful, bytes which are at offset `size_bytes` up to the max offset
699    /// implied by their own padding constraint, which will never exceed the VMO
700    /// size minus 1, as long as the `ImageFormatImageSize` is less than or
701    /// equal to `BufferMemorySettings.size_bytes` and other constraints under
702    /// `BufferCollectionInfo` aren't violated by the producer.
703    ///
704    /// The same `size_bytes` value is sent to all participants.
705    ///
706    /// This field is not page aligned. This value rounded up to
707    /// zx_system_page_size() boundary is guaranteed to be less than or equal
708    /// the buffer VMO size. In other words, the VMO can have more pages than
709    /// implied by this value, due to padding-only constraints from
710    /// participant(s).
711    pub size_bytes: Option<u64>,
712    /// This field will always be set by sysmem.
713    pub is_physically_contiguous: Option<bool>,
714    /// This field will always be set by sysmem.
715    pub is_secure: Option<bool>,
716    /// This field will always be set by sysmem.
717    pub coherency_domain: Option<CoherencyDomain>,
718    /// The specific heap from which buffers are allocated.
719    ///
720    /// This field will always be set by sysmem.
721    pub heap: Option<Heap>,
722    /// This is guaranteed to be equal to the VMO size obtained via
723    /// `zx_vmo_get_size`. This field is here because `pad_*` constraints can
724    /// result in the VMO size being larger than implied by `size_bytes`, and
725    /// for participants using `pad_*` constraints, it can be convenient to have
726    /// this field available rather than having to query for the VMO size.
727    ///
728    /// When checking with `ImageFormatImageSize` to see if an image will fit in
729    /// a buffer, use `size_bytes` as the threshold, not `raw_vmo_size`.
730    ///
731    /// Producers using `pad_*` constraints must still only put images in the
732    /// buffer which have `ImageFormatImageSize() <= size_bytes`. Participants
733    /// using `pad_*` constraints are allowed to access bytes beyond
734    /// `size_bytes` consistent with what the participant set for the pad_*
735    /// constriant(s), which will always fit within `raw_vmo_size` assuming
736    /// correct operation of the participant and sysmem. This field can be
737    /// useful for double-checking that accesses will be within the VMO.
738    ///
739    /// When setting up VMO mappings and VMO pins, a participant using `pad_*`
740    /// constraint(s) should use `raw_vmo_size` for the size of the mapping. In
741    /// contrast, a participant not using any pad_* constraint can use
742    /// `size_bytes` rounded up to a page size boundary or said participant can
743    /// use raw_vmo_size, but for that participant, using `size_bytes` rounded
744    /// up to the page size can avoid mapping a few pages.
745    pub raw_vmo_size: Option<u64>,
746    #[doc(hidden)]
747    pub __source_breaking: fidl::marker::SourceBreaking,
748}
749
750impl fidl::Persistable for BufferMemorySettings {}
751
752/// Describes how a client will access the contents of a buffer.
753#[derive(Clone, Debug, Default, PartialEq)]
754pub struct BufferUsage {
755    /// If the client sets this field, the client should not set any other
756    /// fields in the same table instance. The only valid bit in this field is
757    /// `NONE_USAGE` which must be set if this field is set. The point of this
758    /// field and the one bit set in this field is to essentially prove that the
759    /// client really means they aren't going to use the buffers, so don't need
760    /// any VMOs (didn't just fail to fill out the table).
761    pub none: Option<u32>,
762    /// If set, holds CPU usage bits. See `CPU_USAGE_*` flags in usages.fidl.
763    pub cpu: Option<u32>,
764    /// If set, holds vulkan usage bits. See `VULKAN_IMAGE_*` and
765    /// `VULKAN_BUFFER_*` bits in usages.fidl. The `VULKAN_USAGE_*` bit
766    /// definitions/names are deprecated.
767    pub vulkan: Option<u32>,
768    /// If set, holds display usage bits. See `DISPLAY_USAGE_*` bits in
769    /// usages.fidl.
770    pub display: Option<u32>,
771    /// If set, holds video usage bits. See `VIDEO_USAGE_*` bits in usages.fidl.
772    pub video: Option<u32>,
773    #[doc(hidden)]
774    pub __source_breaking: fidl::marker::SourceBreaking,
775}
776
777impl fidl::Persistable for BufferUsage {}
778
779/// This type is fidl::Persist()'ed in the sysmem_config.persistent_fidl file
780/// within the sysmem domain config by the assembly tool, and read by the sysmem
781/// driver.
782///
783/// Normally json[5] would be preferable for config, but we generate this config
784/// in rust using FIDL types (to avoid repetition and to take advantage of FIDL
785/// rust codegen), and there's no json schema for FIDL types.
786///
787/// Currently there is no mechanism to change anything in this config at runtime
788/// or from boot to boot. This config is static per run of the assembly tool.
789///
790/// See src/lib/assembly/config_schema/src/platform_config/sysmem_config.rs for
791/// aspects of sysmem config which are specified directly inline in board info
792/// or assembly platform config. The two parts of sysmem config don't
793/// (currently) overlap. The config here is for aspects of sysmem config which
794/// would be too verbose for direct inclusion in board info or assembly platform
795/// config. In addition, some/most of the pixel format cost entries are
796/// programmatically generated (as of this comment).
797///
798/// Prior to aggregation by assembly tool, there are multiple .persistent_fidl
799/// files each storing its own Config instance. The board info and assembly
800/// platform config lists the input persistent_fidl files, with board info
801/// logically before assembly platform config. The overall list of files is
802/// processed, which allows later files to override/replace info in prior files.
803///
804/// Because this type is only intended for use with persistent fidl, where the
805/// length of a serialized instance isn't bounded, we don't bound the internal
806/// vector element counts.
807#[derive(Clone, Debug, Default, PartialEq)]
808pub struct Config {
809    /// This is the ordered list of FormatCost entries which will be considered
810    /// by sysmem when breaking ties among formats supported by all participants
811    /// of a buffer collection.
812    ///
813    /// During config aggregation, if a later entry has matching FormatCostKey,
814    /// the earlier entry is omitted/removed. This allows later files to
815    /// override entries in earlier files, and allows files specified in
816    /// assembly platform config to override entries in files specified in the
817    /// board info.
818    ///
819    /// This vector will normally not have any two entries with matching
820    /// pixel_format, pixel_format_modifier, and buffer_usage_bits in the Config
821    /// instance loaded from sysmem_config.persistent_fidl by sysmem. If somehow
822    /// two entries do match in those fields, sysmem can ignore all but one of
823    /// the entries chosen arbitrarily.
824    pub format_costs: Option<Vec<FormatCostEntry>>,
825    #[doc(hidden)]
826    pub __source_breaking: fidl::marker::SourceBreaking,
827}
828
829impl fidl::Persistable for Config {}
830
831#[derive(Clone, Debug, Default, PartialEq)]
832pub struct DynamicSecureHeap {
833    pub heap: Option<Heap>,
834    #[doc(hidden)]
835    pub __source_breaking: fidl::marker::SourceBreaking,
836}
837
838impl fidl::Persistable for DynamicSecureHeap {}
839
840/// A FormatCostEntry can be used to influence which PixelFormatAndModifier is
841/// chosen for a buffer collection, optionally taking BufferUsage into account.
842///
843/// The default cost is f32::MAX, so any specified cost with a non-MAX value
844/// will prefer the specified format over any formats that don't have any
845/// FormatCost entry.
846///
847/// Entries which have the same pixel_format, pixel_format_modifier, and
848/// required_usage_bits as a previous entry will override that previous entry.
849/// For matching purposes, an absent pixel_format_modifier matches LINEAR, and
850/// an absent required_buffer_usage_bits matches all-0 usage bits.
851///
852/// Board info sysmem_defaults entries are logically before platform sysmem
853/// entries.
854///
855/// Sysmem uses the resulting aggregated list of FormatCostEntry(s) when
856/// breaking ties among the set of formats which are supported by all
857/// participants of a buffer collection. For each mutually-supported format,
858/// entries with non-matching format are ignored, and entries with extra
859/// buffer_usage_bits set are ignored. Among the remaining entries, the entry
860/// with the most usage bits in common with the aggregated participant usages is
861/// selected to determine the cost (if a tie, the later entry wins). Then the
862/// format with the lowest cost is chosen. If it's still a tie (equal cost), the
863/// tie is broken arbitrarily but not randomly.
864///
865/// This is not intended as a mechanism to disallow selection of a format that
866/// is supported by all participants of a buffer collection. If a participant
867/// claims support for a format but fails to handle that format correctly, it
868/// should be fixed to handle that format correctly or changed to stop claiming
869/// support for that format.
870///
871/// This mechanism is intended to influence format selection toward more
872/// efficient formats with better performance, lower memory bandwidth usage,
873/// etc, for a given set of usage bits, taking into account quirks that may be
874/// unique to a given board or overall platform config.
875#[derive(Clone, Debug, Default, PartialEq)]
876pub struct FormatCostEntry {
877    /// Must be set. If two entries have logically equal key (after field
878    /// defaults are applied), the later entry will override the earlier entry.
879    pub key: Option<FormatCostKey>,
880    /// Must be set. Lower costs win, but see also FormatCostKey fields re.
881    /// filtering entries by format and usage bits first.
882    ///
883    /// When two entries (each with format supported by all the participants of
884    /// a buffer collection) have different costs, the lower cost entry (and its
885    /// format) is chosen.
886    ///
887    /// For non-test scenarios, only use cost values > 0.0 (typically at least
888    /// 1.0 as of this comment), with 0.0 and negative values reserved for
889    /// testing.
890    pub cost: Option<f32>,
891    #[doc(hidden)]
892    pub __source_breaking: fidl::marker::SourceBreaking,
893}
894
895impl fidl::Persistable for FormatCostEntry {}
896
897/// Entries which have the same pixel_format, pixel_format_modifier, and
898/// required_usage_bits as a previous entry will override that previous entry.
899/// For matching purposes, an absent pixel_format_modifier matches LINEAR, and
900/// an absent required_buffer_usage_bits matches all-0 usage bits.
901#[derive(Clone, Debug, Default, PartialEq)]
902pub struct FormatCostKey {
903    /// The pixel_format and pixel_format_modifier are the format to which this
904    /// FormatCost entry applies.
905    ///
906    /// Must be set.
907    pub pixel_format: Option<fidl_fuchsia_images2_common::PixelFormat>,
908    /// The pixel_format and pixel_format_modifier are the format to which this
909    /// FormatCost entry applies.
910    ///
911    /// Un-set is equivalent to LINEAR.
912    pub pixel_format_modifier: Option<fidl_fuchsia_images2_common::PixelFormatModifier>,
913    /// If set, this entry is only considered if the buffer collection has at
914    /// least these usage bits set.
915    ///
916    /// The buffer collection has an aggregated BufferUsage which is the union
917    /// of per-participant BufferUsage bits. FormatCost entries with additional
918    /// set bits are ignored. Among the rest, the one with matching format and
919    /// the most usage bits set determines the cost of that format for that
920    /// buffer collection.
921    ///
922    /// Then the lowest-cost format is chosen for that buffer collection among
923    /// the formats that are mutually suppored by all the participants of that
924    /// buffer collection.
925    ///
926    /// The main intent of this field is to allow "waving off" a format that
927    /// works, but doesn't perform well, for a particular combination of usages.
928    /// In that case the cost can be set high when the problematic combination
929    /// of usage bits is set. The format will still be chosen if this format is
930    /// the only mutually-supported format among the participants of the buffer
931    /// collection.
932    ///
933    /// Un-set is equivalent to zero usage bits set, meaning the entry applies
934    /// to the format unless another entry with more specific usage applies.
935    ///
936    /// It can be reasonable in some cases for all entries to omit this field,
937    /// when/if format selection based on format cost alone, ignoring usage, is
938    /// sufficient.
939    pub buffer_usage_bits: Option<BufferUsage>,
940    #[doc(hidden)]
941    pub __source_breaking: fidl::marker::SourceBreaking,
942}
943
944impl fidl::Persistable for FormatCostKey {}
945
946/// This is the root of the persistent fidl in a format costs file. The format
947/// costs files are read by the assembly tool and merged into the single
948/// sysmem_config.persistent_fidl file in the sysmem domain config (see Config
949/// above).
950///
951/// Normally json[5] would be preferable for config, but we generate this config
952/// in rust using FIDL types (to avoid repetition and to take advantage of FIDL
953/// rust codegen), and there's no json schema for FIDL types.
954///
955/// While the resulting sysmem_config.persistent_fidl is a single file that can
956/// contain multiple aspects of sysmem config, in contrast a format costs file
957/// contains only format costs. We don't mind having more separate files during
958/// the build, but it's nice to get sysmem's domain config down to a single file
959/// on-device.
960#[derive(Clone, Debug, Default, PartialEq)]
961pub struct FormatCosts {
962    /// This is a chunk of entries that'll end up in
963    /// ['fuchsia.sysmem2.Config.format_costs'] (see above) unless overriden by
964    /// later entries (either in this same vector or in later-processed files
965    /// during aggregation by the assembly tool).
966    pub format_costs: Option<Vec<FormatCostEntry>>,
967    #[doc(hidden)]
968    pub __source_breaking: fidl::marker::SourceBreaking,
969}
970
971impl fidl::Persistable for FormatCosts {}
972
973/// A reference to a heap instance.
974///
975/// A given heap instance can have more than one `Heap` which can be used to
976/// refer to the heap instance. Comparing `Heap` tables without knowledge of
977/// these `Heap` aliases is not a reliable way to determine if two `Heap` tables
978/// refer to the same heap (matching means yes, but not matching means maybe).
979/// Allowing heap aliases makes renaming `Heap.type`(s) easier.
980#[derive(Clone, Debug, Default, PartialEq)]
981pub struct Heap {
982    /// The type of the heap, specified using a bind string defined per the
983    /// schema and mechanism described in comments in the
984    /// fuchsia.sysmem.heap.bind file.
985    ///
986    /// Examples:
987    /// * "fuchsia.sysmem.heap.HEAP_TYPE.SYSTEM_RAM"
988    /// * "fuchsia.goldfish.platform.sysmem.heap.HEAP_TYPE.HOST_VISIBLE"
989    pub heap_type: Option<String>,
990    /// The uint64 id of the heap. This is only required to be unique per (type,
991    /// boot) tuple. In other words, a given heap id is only meaningful within
992    /// the current boot of the machine (not across boots), and only within the
993    /// `Heap.type`.
994    ///
995    /// For `Heap.type`(s) that refer to a singleton heap, a participant
996    /// specifying the singleton heap in
997    /// [`fuchsia.sysmem2.BufferMemoryConstraints.permitted_heaps`] can leave
998    /// this field un-set, or set it to zero. Sysmem will always fill out this
999    /// field for the heap indicated in
1000    /// [`fuchsia.sysmem2.BufferMemorySettings.heap`] (for a singleton heap the
1001    /// `id` field will be set to 0 by sysmem).
1002    pub id: Option<u64>,
1003    #[doc(hidden)]
1004    pub __source_breaking: fidl::marker::SourceBreaking,
1005}
1006
1007impl fidl::Persistable for Heap {}
1008
1009/// Describes constraints on layout of image data in buffers.
1010#[derive(Clone, Debug, Default, PartialEq)]
1011pub struct ImageFormatConstraints {
1012    /// The [`fuchsia.images2/PixelFormat`] for which the following constraints
1013    /// apply.
1014    ///
1015    /// The `pixel_format` and `pixel_format_modifier` fields together are
1016    /// treated by the server as one additional `pixel_format_and_modifiers`
1017    /// entry.
1018    ///
1019    /// A participant may have more than one
1020    /// [`fuchsia.sysmem2/PixelFormatAndModifier`] that's supported.
1021    ///
1022    /// * If image constraints are the same for different
1023    ///   `PixelFormatAndModifier`s, the participant may list additional
1024    ///   `PixelFormatAndModifier`s for which the constraints apply in the
1025    ///   `pixel_format_and_modifiers` field. This reduces the overall number of
1026    ///   `ImageFormatConstraints` that need to be sent, without changing the
1027    ///   meaning (vs for example sending a bunch of separate
1028    ///   `ImageFormatConstraints` that only differ by the `pixel_format` and
1029    ///   `pixel_format_modifier` which overall specify the same list of
1030    ///   `PixelFormatAndModifier`s).
1031    /// * If image constraints differ for different `PixelFormatAndModifier`s,
1032    ///   the participant can convey this using a separate
1033    ///   `ImageFormatConstraints` entry in `image_format_constraints` for each
1034    ///   set of `PixelFormatAndModifier`s that have different image
1035    ///   constraints.
1036    /// * It's ok for a participant to have two `image_format_constraints`
1037    ///   entries that only differ in their pixel_format_and_modifiers, but this
1038    ///   is isn't the most compact way to represent that situation since the
1039    ///   two entries could be combined by specifying two
1040    ///   `PixelFormatAndModifier`s within a single `ImageFormatConstraints`.
1041    ///
1042    /// It's not uncommon for the other fields of `ImageFormatConstraints` to
1043    /// vary by `pixel_format` or by `pixel_format_modifier` - for example for a
1044    /// linear format to support smaller max size than a tiled format.
1045    ///
1046    /// See also
1047    /// [`fuchsia.sysmem2/ImageFormatConstraints.pixel_format_and_modifiers`].
1048    ///
1049    /// Thie field must be set to a value other than
1050    /// [`fuchsia.images2/PixelFormat.INVALID`] unless
1051    /// `pixel_format_and_modifiers` is non-empty. In other words, there must be
1052    /// at least one `PixelFormatAndModifier` per `ImageFormatConstraints`. If
1053    /// `pixel_format_modifier` is set, this field must also be set.
1054    ///
1055    /// The participant can specify [`fuchsia.images2/PixelFormat.DO_NOT_CARE`]
1056    /// if the participant needs to specify `ImageFormatConstraints` without
1057    /// constraining the `pixel_format`.
1058    pub pixel_format: Option<fidl_fuchsia_images2_common::PixelFormat>,
1059    /// The pixel format modifier for which the following constraints apply.
1060    ///
1061    /// The `pixel_format` and `pixel_format_modifier` fields together are
1062    /// treated by the server as one additional `pixel_format_and_modifiers`
1063    /// entry.
1064    ///
1065    /// This is a [`fuchsia.images2/PixelFormatModifier`] that's acceptable to
1066    /// the participant in combination with the `pixel_format`.
1067    ///
1068    /// See also `pixel_format_and_modifiers`.
1069    ///
1070    /// If `pixel_format` is set but `pixel_format_modifier` is un-set, the
1071    /// default depends on other fields:
1072    ///
1073    /// * If `pixel_format` is [`fuchsia.images2/PixelFormat.DO_NOT_CARE`], the
1074    ///   pixel format modifier is implicitly
1075    ///   [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`].
1076    /// * else if `BufferCollectionConstraints.usage` isn't `NONE`, the pixel
1077    ///   format modifier is implicitly
1078    ///   [`fuchsia.images2/PixelFormatModifier.LINEAR`].
1079    /// * else the pixel format modifier is implicitly
1080    ///   [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`].
1081    pub pixel_format_modifier: Option<fidl_fuchsia_images2_common::PixelFormatModifier>,
1082    /// Empty is an error. Duplicate entries are an error. Arbitrary ordering is
1083    /// not an error.
1084    ///
1085    /// The client can specify a single entry
1086    /// [`fuchsia.sysmem2/ColorSpace.DO_NOT_CARE`] if the client doesn't want to
1087    /// constrain which `ColorSpace` is chosen. At least one participant must
1088    /// specify at least one `ColorSpace` value other than
1089    /// `ColorSpace.DO_NOT_CARE`, or allocation will fail.
1090    pub color_spaces: Option<Vec<fidl_fuchsia_images2_common::ColorSpace>>,
1091    /// Minimum permitted size in pixels.
1092    ///
1093    /// For example a video decoder participant may set this field to the
1094    /// minimum size that might potentially be specified by a stream. In
1095    /// contrast, `required_min_size` would be set to the current size specified
1096    /// by the stream. While `min_size` aggregates by taking the max,
1097    /// `required_min_size` aggregates by taking the min.
1098    ///
1099    /// When sending to sysmem, this field can be un-set if the participant is
1100    /// prepared to deal with the smallest possible non-zero image layout
1101    /// limited only by the constraints implicitly imposed by the `pixel_format`
1102    /// and `pixel_format_modifier`. Or this field can be set to the actual
1103    /// minimum size the participant can handle.
1104    ///
1105    /// Producers should set `min_size` and set both width and height to the
1106    /// actual non-zero smallest width and height that the producer might
1107    /// generate. For example, a video decoder can set the size of a single
1108    /// macroblock here.
1109    ///
1110    /// When receiving from sysmem, this field will always be set, and neither
1111    /// width nor height will be 0, because at least one participant must
1112    /// specify a non-zero minimum size (where both width and height aren't
1113    /// zero).
1114    ///
1115    /// See also `required_min_size`.
1116    pub min_size: Option<fidl_fuchsia_math_common::SizeU>,
1117    /// Maximum size in pixels. For example Scenic may set this field (directly
1118    /// or via sub-participants) to the maximum size that can be composited.
1119    ///
1120    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF, 0xFFFFFFFF.
1121    ///
1122    /// Receiving from sysmem, this field will always be set. For width and
1123    /// height separately, if there is no enforced max, that sub-field will be
1124    /// 0xFFFFFFFF.
1125    ///
1126    /// See also `required_max_size`.
1127    pub max_size: Option<fidl_fuchsia_math_common::SizeU>,
1128    /// The minimum number of bytes per row, including any padding beyond the
1129    /// last image data in a row.
1130    ///
1131    /// This is sometimes called the "stride in bytes" or the "line to line
1132    /// offset". For single-plane formats, this is the number of bytes per row
1133    /// of pixels. For multi-plane formats, this is the number of bytes per row
1134    /// of samples in plane 0 (for example, the number of bytes per row of luma
1135    /// samples in the case of a multi-plane YUV format). For multi-plane
1136    /// formats, the bytes per row in planes other than plane 0 is format
1137    /// specific, but always a specific relationship to the plane 0 bytes per
1138    /// row.
1139    ///
1140    /// When sending `ImageFormatConstraints` to sysmem, setting this field is
1141    /// optional. Not setting this field is recommended unless the participant
1142    /// needs to force the `bytes_per_row` to be larger than the minimum value
1143    /// implied by `min_size.width`, the "stride bytes per width pixel" of the
1144    /// `pixel_format` plus `pixel_format_modifier` (see also
1145    /// `ImageFormatStrideBytesPerWidthPixel`), and `bytes_per_row_divisor`.
1146    ///
1147    /// When this structure is received from sysmem, this field will always be
1148    /// set (when the parent structure is present), and will always be at least
1149    /// the value implied by `min_size.width`, the "stride bytes per width
1150    /// pixel" of the `pixel_format` plus `pixel_format_modifier`, and
1151    /// `bytes_per_row_divisor`.
1152    ///
1153    /// Some producer participants may prefer to simply set
1154    /// `ImageFormat.bytes_per_row` to
1155    /// `ImageFormatConstraints.min_bytes_per_row` since sysmem is guaranteeing
1156    /// that `min_bytes_per_row` is compatible with an image of width
1157    /// `min_size.width`. However, producer participants that need to have
1158    /// `size.width` > `min_size.width` can get a corresponding
1159    /// `min_bytes_per_row` from `ImageFormatMinimumRowBytes` (in C++), or can
1160    /// just calculate the `bytes_per_row` directly.
1161    pub min_bytes_per_row: Option<u32>,
1162    /// The maximum number of bytes per row, including any padding beyond the
1163    /// last image data in a row.
1164    ///
1165    /// When sent to sysmem, must be >= the value implied by `max_size.width`,
1166    /// "stride bytes per width pixel", and `bytes_per_row_divisor`, or
1167    /// constraints aggregation will fail. Un-set means the participant doesn't
1168    /// need/want to set a strict max.
1169    ///
1170    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF.
1171    ///
1172    /// When received from sysmem, this field will always be set. If the max is
1173    /// effectively infinite, the value will be 0xFFFFFFFF (not zero).
1174    pub max_bytes_per_row: Option<u32>,
1175    /// The maximum number of pixels.
1176    ///
1177    /// The max image area in pixels is limited indirectly via
1178    /// [`fuchsia.sysmem/BufferMemoryConstraints.max_size_bytes`] and the
1179    /// resulting [`fuchsia.sysmem/BufferSettings.size_bytes`], and can also be
1180    /// enforced directly via this field.
1181    ///
1182    /// In contrast to the [`fuchsia.sysmem2/ImageFormatConstraints.max_size`]
1183    /// field which limits width and height separately, this field limits the
1184    /// total number of pixels.
1185    ///
1186    /// In contrast to
1187    /// [`fuchsia.sysmem/BufferMemoryConstraints.max_size_bytes`], this field
1188    /// doesn't limit the number of non-pixel padding bytes after each row of
1189    /// pixels, and doesn't limit the number of non-pixel bytes in the case of
1190    /// tiled `pixel_format_modifier`.
1191    ///
1192    /// Very narrow or very short image aspect ratios can have worse performance
1193    /// per pixel in comparison to more typical aspect ratios. Padding and/or
1194    /// memory bandwidth overheads tend to increase for extreme aspect ratios.
1195    /// Participants can indicate lack of support for very narrow or very short
1196    /// dimensions using ['fuchsia.sysmem/ImageFormatConstraints.min_size`].
1197    ///
1198    /// Sending to sysmem, un-set is treated as 0xFFFFFFFF.
1199    ///
1200    /// Receiving from sysmem, this field will always be set, and can be set to
1201    /// 0xFFFFFFFF.
1202    pub max_width_times_height: Option<u64>,
1203    /// Alignment requirements on the image `size`.
1204    ///
1205    /// * `size.width % size_alignment.width` must be 0.
1206    /// * `size.height % size_alignment.height` must be 0.
1207    ///
1208    /// Both `size_alignment.width` and `size_alignment.height` must be non-zero
1209    /// and a power of 2.
1210    ///
1211    /// Un-set is treated as 1, 1.
1212    pub size_alignment: Option<fidl_fuchsia_math_common::SizeU>,
1213    /// Alignment requirements on `display_rect`.
1214    ///
1215    /// * `display_rect.x % display_rect_alignment.width` must be 0.
1216    /// * `display_rect.y % display_rect_alignment.height` must be 0.
1217    /// * `display_rect.width % display_rect_alignment.width` must be 0.
1218    /// * `display_rect.height % display_rect_alignment.height` must be 0.
1219    ///
1220    /// Un-set is treated as 1, 1.
1221    pub display_rect_alignment: Option<fidl_fuchsia_math_common::SizeU>,
1222    /// These fields can be used to ensure the aggregated constraints have
1223    /// `min_size` and `max_size` such that both `required_min_size` and
1224    /// `required_max_size` (and anything in between that satisfies alignment
1225    /// requirements) are permitted values of `ImageFormat.size`.
1226    ///
1227    /// For example, a producer video decoder doesn't want to constrain the
1228    /// allowed `ImageFormat.size`, as a compressed stream can change dimensions
1229    /// mid-stream, but the producer video decoder needs to ensure that the
1230    /// aggregated constraints allow for at least the current dimensions of
1231    /// uncompressed frames at the current position in the stream.
1232    ///
1233    /// As another example, an initiator that's intending to decode video may
1234    /// know what the maximum expected size of frames in the stream(s) can be,
1235    /// so by setting `required_max_size`, can ensure that the allocated buffers
1236    /// are large enough to support that max `size`. In addition on successful
1237    /// allocation the initiator also knows that the consumer participants are
1238    /// ok with receiving up to that max `size`.
1239    ///
1240    /// It's much more common for a producer or initiator to set these fields
1241    /// than for a consumer to set these fields.
1242    ///
1243    /// While `min_size` and `max_size` aggregate by effectively taking the
1244    /// intersection, the `required_min_size` and `required_max_size` aggregate
1245    /// by effectively taking the union.
1246    ///
1247    /// The `min_size` is the minimum size that a client is capable of handling.
1248    /// If any participant sets `required_min_size` smaller than this,
1249    /// allocation will fail.
1250    ///
1251    /// The `max_size` is the maximum size that a client is capable of handling.
1252    /// If any participant sets `required_max_size` larger than this, allocation
1253    /// will fail.
1254    ///
1255    /// This field aggregates by taking the min per component, and
1256    /// required_max_size aggregates by taking the max per component. In
1257    /// addition the aggregated required_max_size is included in the aggregated
1258    /// required_max_size_list.
1259    ///
1260    /// Un-set is treated as 0xFFFFFFFF, 0xFFFFFFFF.
1261    pub required_min_size: Option<fidl_fuchsia_math_common::SizeU>,
1262    /// This field is deprecated. The replacement is required_max_size_list.
1263    ///
1264    /// See also `required_min_size` and `required_max_size_list`. Un-set is
1265    /// treated as 0, 0.
1266    ///
1267    /// In the BufferCollectionInfo returned from sysmem, this field has the max
1268    /// across all participants' required_max_size fields, for width and height
1269    /// separately. In addition, the allocated buffer is large enough to store
1270    /// an image that is this max-of-all-widths by max-of-all-heights. This has
1271    /// the potential to allocate buffers that are larger than necessary, for
1272    /// example if the participant is trying to make sure the buffer can store
1273    /// both landscape and portrait images. In contrast, required_max_size_list
1274    /// allows listing those separately so they can be handled better by the
1275    /// server. See required_max_size_list and please switch to that field.
1276    ///
1277    /// When this field is set, the provided size is aggregated by taking max of
1278    /// across all participants' required_max_size fields, and that aggregated
1279    /// result is put in this field in the BufferCollectionInfo from the server,
1280    /// and is also treated as an additional item in the aggregated
1281    /// required_max_size_list (even if that field is not set by any client).
1282    /// See required_max_size_list. This behavior is for maintaining backward
1283    /// compatibility for clients using required_max_size before it was
1284    /// deprecated, and for overall compatibility with required_max_size_list,
1285    /// but this behavior is itself deprecated as well. Please switch to only
1286    /// using required_max_size_list.
1287    ///
1288    /// Please don't add additional usages of this field.
1289    pub required_max_size: Option<fidl_fuchsia_math_common::SizeU>,
1290    /// `fuchsia_images2.ImageFormat.bytes_per_row % bytes_per_row_divisor` must
1291    /// be 0. Un-set is treated as 1.
1292    ///
1293    /// Prefer to use `require_bytes_per_row_at_pixel_boundary` when the intent
1294    /// is to ensure that `bytes_per_row' will be a multiple of the pixel size
1295    /// in bytes.
1296    ///
1297    /// Prefer to use `size_alignment.width` when the intent is to ensure that
1298    /// the width in pixels is aligned. In contrast, this field can specify that
1299    /// the "stride in bytes" (byte offset from start of image to start of row n
1300    /// minus byte offset from start of image to start of row n-1, with result
1301    /// in bytes) needs to be aligned to the specified number of bytes. For
1302    /// example, when `PixelFormat.BGR24` (24 bit color; 3 bytes per pixel) is
1303    /// used, it's not uncommon for a participant to need each row of pixels to
1304    /// start at a 4 byte aligned offset from the start of the image, which can
1305    /// imply some padding bytes at the end of each row of pixels, before the
1306    /// start of the next row of pixels.
1307    ///
1308    /// While any value of `bytes_per_row_divisor` could instead be enforced by
1309    /// setting `size_alignment.width` to the least-common-multiple of the
1310    /// "stride bytes per width pixel" and the stride alignment requirement,
1311    /// enforcing the stride alignment requirement that way can lead to more
1312    /// padding than necessary (implying larger buffer than necessary), and can
1313    /// also result in a "fake" `size.width` values that other participants
1314    /// would need to care about; this field exists to avoid that situation.
1315    /// Instead, the stride alignment requirement in bytes is specified directly
1316    /// here.
1317    pub bytes_per_row_divisor: Option<u32>,
1318    /// `vmo_usable_start % start_offset_divisor` must be 0. Un-set is treated
1319    /// as 1.
1320    ///
1321    /// Producer participants are discouraged from setting non-zero image start
1322    /// offset (from the buffer base) unless actually required, as not all
1323    /// participants correctly handle non-zero image start offset.
1324    pub start_offset_divisor: Option<u32>,
1325    /// The (additional) [`fuchsia.sysmem2/PixelFormatAndModifier`]s for which
1326    /// the following constraints apply.
1327    ///
1328    /// As a non-limiting example, if a participant only wants to set a single
1329    /// `PixelFormatAndModifier` for this
1330    /// [`fuchsia.sysmem2/ImageFormatConstraints`], the participant can either
1331    /// (a) use `pixel_format` and `pixel_format_modifier` fields to specify the
1332    /// fields of the one `PixelFormatAndModifier` and leave
1333    /// `pixel_format_and_modifiers` un-set, or (b) leave `pixel_format` and
1334    /// `pixel_format_modifier` fields un-set and put the one
1335    /// `PixelFormatAndModifier` in `pixel_format_and_modifiers`.
1336    ///
1337    /// If `pixel_format` is set, the server will take pixel_format and
1338    /// pixel_format_modifier fields (un-setting them in the process), pack them
1339    /// into a `PixelFormatAndModifier`, and move it into this vector as one
1340    /// additional entry, with an overall size limit of
1341    /// `MAX_COUNT_PIXEL_FORMAT_AND_MODIFIERS + 1`.
1342    ///
1343    /// After the server moves `pixel_format`, `pixel_format_modifier` into one
1344    /// additional entry in this vector, this vector must not be empty. When the
1345    /// resulting list has more than 1 item, the entries in this vector are
1346    /// equivalent to (shorthand for) listing (size) separate
1347    /// `ImageFormatConstraints` entries, one per `pixel_format_and_modifiers`
1348    /// entry, each with one `PixelFormatAndModifier`, where all the separate
1349    /// `ImageFormatConstraints` entries have the same constraints (compared
1350    /// field by field, not including `pixel_format`, `pixel_format_modifier`,
1351    /// or `pixel_format_and_modifiers` fields).
1352    ///
1353    /// In `SetConstraints` message, each entry specifies a
1354    /// `PixelFormatAndModifier` which is acceptable to the participant
1355    /// (assuming the following constraints fields are also satisfied).
1356    ///
1357    /// In the response to `WaitForAllBuffersAllocated`, this field will be
1358    /// un-set and the one chosen `PixelFormatAndModifier` will be indicated
1359    /// using the `pixel_format` and `pixel_format_modifier` fields.
1360    ///
1361    /// All the `PixelFormatAndModifiers` in a `SetConstraints` message from a
1362    /// participant must be unique across all the entries under
1363    /// `image_format_constraints`. If
1364    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] is used in an entry, there
1365    /// must not be any other entry (considering all the entries under
1366    /// `image_format_constraints`) with matching `pixel_format_modifier`. If
1367    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] is used, there must
1368    /// not be any other entry (considering all the entries under
1369    /// `image_format_constraints`) with matching `pixel_format`.
1370    ///
1371    /// A `PixelFormatAndModifier` value with either
1372    /// [`fuchsia.images2/PixelFormat.DO_NOT_CARE`] or
1373    /// [`fuchsia.images2/PixelFormatModifier.DO_NOT_CARE`] (but not both, for
1374    /// purposes of this example) can be combined with a
1375    /// `PixelFormatAndModifier` from a separate participant with the other
1376    /// field indicating "do not care", resulting in a complete
1377    /// `PixelFormatAndModifier` that can succeed allocation. However, at least
1378    /// for now, it's not permitted for a single participant to specify two
1379    /// separate `PixelFormatAndModifier` values which have "do not care" in
1380    /// different fields. This does not prohibit a single
1381    /// `PixelFormatAndModifier` with both `PixelFormat.DO_NOT_CARE` and
1382    /// `PixelFormatModifier.DO_NOT_CARE` (which is only a single
1383    /// `PixelFormatAndModifier` value). If a client really needs to specify
1384    /// some constraints relevant to `pixel_format`(s) with
1385    /// `pixel_format_modifier` `DO_NOT_CARE`, and other constraints relevant to
1386    /// `pixel_format_modifier`(s) with `pixel_format` `DO_NOT_CARE`, the client
1387    /// can do so by duplicating the token and using/driving two separate
1388    /// participants.
1389    ///
1390    /// See also `pixel_format` for more comments relevant to multiple
1391    /// `PixelFormatAndModifier`s in a single `ImageFormatConstraints`.
1392    pub pixel_format_and_modifiers: Option<Vec<PixelFormatAndModifier>>,
1393    /// Iff set and true, bytes_per_row_divisor in the resulting
1394    /// ImageFormatConstraints is guaranteed to be a value which requires
1395    /// bytes_per_row to be an integral number of pixels. This can result in
1396    /// more padding at the end of each row than when this field is not set to
1397    /// true, but ensures that the stride can be expressed as an integral number
1398    /// of pixels.
1399    ///
1400    /// For example, if the chosen `PixelFormat` is `B8G8R8`, if this field is
1401    /// set to true, the resulting bytes_per_row_divisor will be a multiple of
1402    /// 3. In this example, if another participant sets `bytes_per_row_divisor`
1403    /// to 4, the resulting `bytes_per_row_divisor` will be a multiple of 12.
1404    pub require_bytes_per_row_at_pixel_boundary: Option<bool>,
1405    /// If unset, any A channel of any format in this ImageFormatConstraints is
1406    /// is ignored or not ignored according to semantics conveyed out of band.
1407    ///
1408    /// If set to false, the A channel of any format in this
1409    /// ImageFormatConstraints is arbitrary values that don't mean anything.
1410    /// Producers don't need to ensure any particular values in the A channel
1411    /// and consumers should ignore the A channel. This is the same thing as
1412    /// calling the 'A' channel 'X' instead.
1413    ///
1414    /// If set to true, the A channel of any format in this
1415    /// ImageFormatConstraints is set to meaningful values. A producer should
1416    /// fill out the A values, and a consumer should pay attention to the A
1417    /// values as appropriate.
1418    ///
1419    /// If set values of this field don't match for the same pixel format and
1420    /// modifier, that format and modifier will be eliminated from
1421    /// consideration.
1422    ///
1423    /// A participant that knows that the semantics of the A channel are
1424    /// conveyed via out of band means can leave this field un-set, even if the
1425    /// out of band means is already known to specify alpha present or not
1426    /// present, but in this situation it's also ok to fill out this field for
1427    /// informational / debugging purposes.
1428    ///
1429    /// If no participant sets this field, the default is un-set.
1430    ///
1431    /// If the format chosen for allocation doesn't have an A channel, this
1432    /// field will be un-set in the allocation result.
1433    pub is_alpha_present: Option<bool>,
1434    /// If an entry in this list has width or height greater than max_size width
1435    /// or height respectively (evaluated both before and again after
1436    /// aggregation), allocation will fail.
1437    ///
1438    /// This field aggregates by appending the entries to an overall list, or in
1439    /// other words, this field does not aggregate; all entries from all
1440    /// participants must be satisfied by the allocated buffer(s) or the
1441    /// allocation will fail. This lack of aggregation is to avoid
1442    /// larger-than-necessary buffers if one participant specifies a large width
1443    /// and small height and another participant specifies a small width and
1444    /// large height, or more likely, if a single participant specifies those
1445    /// two entries (for example). In that case, the buffer's
1446    /// `BufferMemorySettings.size_bytes` needs to be large enough to store the
1447    /// larger (in bytes) of the specified sizes (given available ranges of
1448    /// other ImageFormatConstraints), but not the max width and max height
1449    /// across all specified sizes used as the width and height of a single
1450    /// image.
1451    ///
1452    /// Under the resulting `BufferCollectionInfo`, `max_size` is the max
1453    /// allowed value for each dimension separately, but this does not imply
1454    /// that an image of max_size can fit in the buffer (typically won't). In
1455    /// contrast, any image that's no bigger than an entry in the returned
1456    /// `required_max_size_list` will fit in the buffer. The returned list will
1457    /// have redundant entries removed, so a client's entry may not be present
1458    /// if another entry covers the client's entry; this also removes any
1459    /// duplicates. The correct way to check if an image will fit is to check
1460    /// that `ImageFormatImageSize()` is less than or equal to
1461    /// `BufferMemorySettings.size_bytes`.
1462    ///
1463    /// Until `required_max_size` is removed, the returned
1464    /// `required_max_size_list` will, if any participants specified
1465    /// `required_max_size`, ensure that the aggregated (using max width and max
1466    /// height) `required_max_size` will fit in the allocated buffer. This does
1467    /// not imply that there will necessarily be an entry that indicates this
1468    /// specific aggregated `required_max_size`, as that entry can be removed if
1469    /// it's covered by another entry.
1470    ///
1471    /// In contrast to `max_size`, an entry can be added to
1472    /// `required_max_size_list` to ensure the buffer actually has the capacity
1473    /// to store an image that has both width and height less than or equal to
1474    /// the entry's width and height respectively. See
1475    /// `BufferMemorySettings.size_bytes` for more on what "capacity" means
1476    /// here.
1477    ///
1478    /// A typical usage of more than one entry in this list would be specifying
1479    /// that each buffer needs to be able to store up to a given portrait size
1480    /// and also up to a given landscape size. In general, more than one entry
1481    /// makes sense if the participant needs to ensure that the buffer can be
1482    /// used to store images of a few different aspect ratios at up to the
1483    /// listed size per aspect ratio. In the response from the server, redundant
1484    /// entries are removed.
1485    pub required_max_size_list: Option<Vec<fidl_fuchsia_math_common::SizeU>>,
1486    /// `pad_for_block_size` ensures that a participant will be able to access
1487    /// pixel data in blocks of the specified size, even for the lower right
1488    /// pixel whose access block can extend beyond that pixel, sometimes
1489    /// requiring more page(s) in the VMO to avoid access fault or out-of-bounds
1490    /// DMA. The extra "pixel" data of blocks on the right and bottom will not
1491    /// overlap with any other pixel (or "pixel") data.
1492    ///
1493    /// At least for now this field is only accepted for linear single-plane
1494    /// formats. This corresponds to `PixelFormatModifier.Linear` and
1495    /// `ImageFormatPlaneByteOffset` returning false when plane is 1.
1496    ///
1497    /// This field being set is not accepted if the ImageFormatConstraints has
1498    /// PixelFormat.DO_NOT_CARE or PixelFormatModifier.DO_NOT_CARE.
1499    ///
1500    /// For linear single-plane formats, we don't need to force size_alignment
1501    /// to be the access block size, as (a) there's no intent by any participant
1502    /// to actually store more (valid) pixels in the buffer, and (b) no other
1503    /// non-block-accessing participant needs to know about block access by a
1504    /// different participant to correctly locate the data of any pixel. The
1505    /// accesses by the block-accessing participant just need to remain within
1506    /// the VMO, so that all accesses remain within the VMO's pages.
1507    ///
1508    /// This field ensures the VMO size is sufficient to store the lower right
1509    /// "pixel" of the lower right block, but by design, that "pixel" data is
1510    /// not necessarily within `BufferMemorySettings.size_bytes`. Participants
1511    /// specifying `pad_for_block_size` are allowed to access beyond
1512    /// `BufferMemorySettings.size_bytes`. Block access per `pad_for_block_size`
1513    /// will automatically be within the VMO sze (but participants may check as
1514    /// well of course).
1515    ///
1516    /// For a motivating example, see the top of pad_for_block_size_test.cc.
1517    ///
1518    /// If setting `pad_for_block_size.height` to a value greater than 1, the
1519    /// same participant must (enforced) set a `max_size.width` less than
1520    /// 0xFFFFFFFF (preferably no more than a small multiple of the expected
1521    /// actual max width). This helps in controlling the space overhead incurred
1522    /// by the participant's use of blocks. If not burdensome, any of the
1523    /// following can also help:
1524    ///   * `min_size.height` - any participant setting a value greater than 1
1525    ///   * `size_alignment.height` - any participant setting to a value greater
1526    ///     than 1
1527    pub pad_for_block_size: Option<fidl_fuchsia_math_common::SizeU>,
1528    /// pad_beyond_image_size_bytes ensures that there will be at least this
1529    /// many bytes in the VMO beyond the image size. Some SW video codecs need
1530    /// this for performance reasons.
1531    ///
1532    /// Some video decoders and encoders can require that a few more bytes be
1533    /// safe to access beyond the image's size as calculated by
1534    /// ImageFormatImageSize. This can sometimes require an additional page to
1535    /// be allocated. The padding specified by this field starts at byte 0 of
1536    /// the row beyond the last image row.
1537    ///
1538    /// This semantic is chosen because (a) it makes some video decoders used in
1539    /// ffmpeg happy (needs 16 bytes fully after the image as a run-out zone),
1540    /// and (b) it can serve as a not-particularly-wastful way to avoid adding
1541    /// pad_beyond_last_pixel_bytes as well, because this padding always starts
1542    /// at or beyond where that padding would without wasting more than
1543    /// bytes_per_row - pixel_stride_in_bytes * width which is very unlikely to
1544    /// result in wasting more than 1 page (and won't typically waste any
1545    /// pages).
1546    ///
1547    /// If the participant needs extra bytes beyond the image size to accomodate
1548    /// performance optimization(s), the number of extra bytes needed goes here.
1549    /// Do _not_ store valid pixels or metadata in these bytes; some or all of
1550    /// these bytes may be the same bytes requested via other participant's
1551    /// pad_* constraints.
1552    ///
1553    /// Do not write to these bytes outside time intervals during which
1554    /// writing to pixel data is permitted.
1555    pub pad_beyond_image_size_bytes: Option<u64>,
1556    #[doc(hidden)]
1557    pub __source_breaking: fidl::marker::SourceBreaking,
1558}
1559
1560impl fidl::Persistable for ImageFormatConstraints {}
1561
1562#[derive(Clone, Debug, Default, PartialEq)]
1563pub struct NodeSetDebugClientInfoRequest {
1564    pub name: Option<String>,
1565    pub id: Option<u64>,
1566    #[doc(hidden)]
1567    pub __source_breaking: fidl::marker::SourceBreaking,
1568}
1569
1570impl fidl::Persistable for NodeSetDebugClientInfoRequest {}
1571
1572#[derive(Clone, Debug, Default, PartialEq)]
1573pub struct NodeSetDebugTimeoutLogDeadlineRequest {
1574    pub deadline: Option<i64>,
1575    #[doc(hidden)]
1576    pub __source_breaking: fidl::marker::SourceBreaking,
1577}
1578
1579impl fidl::Persistable for NodeSetDebugTimeoutLogDeadlineRequest {}
1580
1581#[derive(Clone, Debug, Default, PartialEq)]
1582pub struct NodeSetNameRequest {
1583    pub priority: Option<u32>,
1584    pub name: Option<String>,
1585    #[doc(hidden)]
1586    pub __source_breaking: fidl::marker::SourceBreaking,
1587}
1588
1589impl fidl::Persistable for NodeSetNameRequest {}
1590
1591#[derive(Clone, Debug, Default, PartialEq)]
1592pub struct NodeGetBufferCollectionIdResponse {
1593    pub buffer_collection_id: Option<u64>,
1594    #[doc(hidden)]
1595    pub __source_breaking: fidl::marker::SourceBreaking,
1596}
1597
1598impl fidl::Persistable for NodeGetBufferCollectionIdResponse {}
1599
1600#[derive(Clone, Debug, Default, PartialEq)]
1601pub struct NodeIsAlternateForResponse {
1602    pub is_alternate: Option<bool>,
1603    #[doc(hidden)]
1604    pub __source_breaking: fidl::marker::SourceBreaking,
1605}
1606
1607impl fidl::Persistable for NodeIsAlternateForResponse {}
1608
1609#[derive(Clone, Debug, Default, PartialEq)]
1610pub struct SecureHeapAndRange {
1611    pub heap: Option<Heap>,
1612    pub range: Option<SecureHeapRange>,
1613    #[doc(hidden)]
1614    pub __source_breaking: fidl::marker::SourceBreaking,
1615}
1616
1617impl fidl::Persistable for SecureHeapAndRange {}
1618
1619#[derive(Clone, Debug, Default, PartialEq)]
1620pub struct SecureHeapAndRangeModification {
1621    pub heap: Option<Heap>,
1622    pub old_range: Option<SecureHeapRange>,
1623    pub new_range: Option<SecureHeapRange>,
1624    #[doc(hidden)]
1625    pub __source_breaking: fidl::marker::SourceBreaking,
1626}
1627
1628impl fidl::Persistable for SecureHeapAndRangeModification {}
1629
1630#[derive(Clone, Debug, Default, PartialEq)]
1631pub struct SecureHeapAndRanges {
1632    /// This is which secure/protected heap.
1633    pub heap: Option<Heap>,
1634    /// The list of physical ranges.  This list must be sorted by
1635    /// physical_address (lower first), and must not have any overlapping
1636    /// ranges.  Ranges that are directly adjacent are allowed (not
1637    /// overlapping).
1638    pub ranges: Option<Vec<SecureHeapRange>>,
1639    #[doc(hidden)]
1640    pub __source_breaking: fidl::marker::SourceBreaking,
1641}
1642
1643impl fidl::Persistable for SecureHeapAndRanges {}
1644
1645#[derive(Clone, Debug, Default, PartialEq)]
1646pub struct SecureHeapProperties {
1647    /// The Heap is repeated here for convenience.
1648    pub heap: Option<Heap>,
1649    /// If true, more than one call to SetPhysicalSecureHeap() for the same
1650    /// heap is allowed.  If false, only one SetPhyscialSecureHeap() call is
1651    /// allowed, and no calls to DeleteSecureHeapPhysicalRange() or
1652    /// ModifySecureHeapPhysicalRange() are allowed.  Even when this is false,
1653    /// the SecureMem server (driver) is still responsible for de-protecting
1654    /// just before warm reboot if protected ranges would not otherwise be
1655    /// cleaned up during a warm reboot.
1656    pub dynamic_protection_ranges: Option<bool>,
1657    /// The granularity of protection ranges.  If the granularity of start is
1658    /// different than granularity of end or length, then this is the max
1659    /// granularity value among those values.
1660    ///
1661    /// This must be a power of 2.  The client must not request ranges that
1662    /// specify smaller granularity.
1663    ///
1664    /// This must be at least zx_system_page_size() even if the HW can do
1665    /// smaller granularity.
1666    pub protected_range_granularity: Option<u32>,
1667    /// The SecureMem server should not count reserved ranges that the SecureMem
1668    /// server uses internally to get from range set A to range set B, if the
1669    /// SecureMem server needs to do any emulation of that sort.  Normally such
1670    /// emulation by the SecureMem server is unnecessary.  If any ranges are
1671    /// reserved by the SecureMem server, those reserved ranges are not
1672    /// available for use by the SecureMem client.
1673    ///
1674    /// If the number of ranges is limited only by available memory, it's ok for
1675    /// the SecureMem server to report 0xFFFFFFFFFFFFFFFF for this value.  The
1676    /// field must still be set.  As usual, the SecureMem server should ensure
1677    /// that SetPhysicalSecureHeapRanges() succeeds or fails atomically (either
1678    /// fully updates or rolls back before completing).
1679    pub max_protected_range_count: Option<u64>,
1680    /// Iff true, ModifySecureHeapPhysicalRange() is implemented.  Calling
1681    /// ModifySecureHeapPhysicalRange() when is_mod_protected_range_available
1682    /// is false is prohibited.  Don't attempt to detect availability of
1683    /// ModifySecureHeapPhysicalRange() by calling it to see if it fails; it
1684    /// may ZX_PANIC().
1685    pub is_mod_protected_range_available: Option<bool>,
1686    #[doc(hidden)]
1687    pub __source_breaking: fidl::marker::SourceBreaking,
1688}
1689
1690impl fidl::Persistable for SecureHeapProperties {}
1691
1692#[derive(Clone, Debug, Default, PartialEq)]
1693pub struct SecureHeapRange {
1694    /// Must be aligned to at least heap_range_granularity.
1695    pub physical_address: Option<u64>,
1696    /// Must be aligned to at least heap_range_granularity.
1697    pub size_bytes: Option<u64>,
1698    #[doc(hidden)]
1699    pub __source_breaking: fidl::marker::SourceBreaking,
1700}
1701
1702impl fidl::Persistable for SecureHeapRange {}
1703
1704#[derive(Clone, Debug, Default, PartialEq)]
1705pub struct SecureMemAddSecureHeapPhysicalRangeRequest {
1706    pub heap_range: Option<SecureHeapAndRange>,
1707    #[doc(hidden)]
1708    pub __source_breaking: fidl::marker::SourceBreaking,
1709}
1710
1711impl fidl::Persistable for SecureMemAddSecureHeapPhysicalRangeRequest {}
1712
1713#[derive(Clone, Debug, Default, PartialEq)]
1714pub struct SecureMemDeleteSecureHeapPhysicalRangeRequest {
1715    pub heap_range: Option<SecureHeapAndRange>,
1716    #[doc(hidden)]
1717    pub __source_breaking: fidl::marker::SourceBreaking,
1718}
1719
1720impl fidl::Persistable for SecureMemDeleteSecureHeapPhysicalRangeRequest {}
1721
1722#[derive(Clone, Debug, Default, PartialEq)]
1723pub struct SecureMemGetPhysicalSecureHeapPropertiesRequest {
1724    pub entire_heap: Option<SecureHeapAndRange>,
1725    #[doc(hidden)]
1726    pub __source_breaking: fidl::marker::SourceBreaking,
1727}
1728
1729impl fidl::Persistable for SecureMemGetPhysicalSecureHeapPropertiesRequest {}
1730
1731#[derive(Clone, Debug, Default, PartialEq)]
1732pub struct SecureMemModifySecureHeapPhysicalRangeRequest {
1733    pub range_modification: Option<SecureHeapAndRangeModification>,
1734    #[doc(hidden)]
1735    pub __source_breaking: fidl::marker::SourceBreaking,
1736}
1737
1738impl fidl::Persistable for SecureMemModifySecureHeapPhysicalRangeRequest {}
1739
1740#[derive(Clone, Debug, Default, PartialEq)]
1741pub struct SecureMemZeroSubRangeRequest {
1742    pub is_covering_range_explicit: Option<bool>,
1743    pub heap_range: Option<SecureHeapAndRange>,
1744    #[doc(hidden)]
1745    pub __source_breaking: fidl::marker::SourceBreaking,
1746}
1747
1748impl fidl::Persistable for SecureMemZeroSubRangeRequest {}
1749
1750#[derive(Clone, Debug, Default, PartialEq)]
1751pub struct SecureMemGetDynamicSecureHeapsResponse {
1752    pub heaps: Option<Vec<DynamicSecureHeap>>,
1753    #[doc(hidden)]
1754    pub __source_breaking: fidl::marker::SourceBreaking,
1755}
1756
1757impl fidl::Persistable for SecureMemGetDynamicSecureHeapsResponse {}
1758
1759#[derive(Clone, Debug, Default, PartialEq)]
1760pub struct SecureMemGetPhysicalSecureHeapPropertiesResponse {
1761    pub properties: Option<SecureHeapProperties>,
1762    #[doc(hidden)]
1763    pub __source_breaking: fidl::marker::SourceBreaking,
1764}
1765
1766impl fidl::Persistable for SecureMemGetPhysicalSecureHeapPropertiesResponse {}
1767
1768#[derive(Clone, Debug, Default, PartialEq)]
1769pub struct SecureMemGetPhysicalSecureHeapsResponse {
1770    pub heaps: Option<Vec<SecureHeapAndRanges>>,
1771    #[doc(hidden)]
1772    pub __source_breaking: fidl::marker::SourceBreaking,
1773}
1774
1775impl fidl::Persistable for SecureMemGetPhysicalSecureHeapsResponse {}
1776
1777/// These settings and constraints apply to all the buffers in the collection.
1778#[derive(Clone, Debug, Default, PartialEq)]
1779pub struct SingleBufferSettings {
1780    /// This field will always be set by sysmem.
1781    pub buffer_settings: Option<BufferMemorySettings>,
1782    /// Buffers holding data that is not uncompressed image data will not have
1783    /// this field set.  Buffers holding data that is uncompressed image data
1784    /// _may_ have this field set.
1785    ///
1786    /// At least for now, changing the PixelFormat requires re-allocating
1787    /// buffers.
1788    ///
1789    /// If un-set, there are no image format constraints.
1790    pub image_format_constraints: Option<ImageFormatConstraints>,
1791    #[doc(hidden)]
1792    pub __source_breaking: fidl::marker::SourceBreaking,
1793}
1794
1795impl fidl::Persistable for SingleBufferSettings {}
1796
1797pub mod allocator_ordinals {
1798    pub const ALLOCATE_NON_SHARED_COLLECTION: u64 = 0x5ca681f025a80e44;
1799    pub const ALLOCATE_SHARED_COLLECTION: u64 = 0x11a19ff51f0b49c1;
1800    pub const BIND_SHARED_COLLECTION: u64 = 0x550916b0dc1d5b4e;
1801    pub const VALIDATE_BUFFER_COLLECTION_TOKEN: u64 = 0x4c5ee91b02a7e68d;
1802    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x6f68f19a3f509c4d;
1803    pub const GET_VMO_INFO: u64 = 0x21a881120aa0ddf9;
1804}
1805
1806pub mod buffer_collection_ordinals {
1807    pub const SYNC: u64 = 0x11ac2555cf575b54;
1808    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1809    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1810    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1811    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1812    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1813    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1814    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1815    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1816    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1817    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1818    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1819    pub const SET_CONSTRAINTS: u64 = 0x1fde0f19d650197b;
1820    pub const WAIT_FOR_ALL_BUFFERS_ALLOCATED: u64 = 0x62300344b61404e;
1821    pub const CHECK_ALL_BUFFERS_ALLOCATED: u64 = 0x35a5fe77ce939c10;
1822    pub const ATTACH_TOKEN: u64 = 0x46ac7d0008492982;
1823    pub const ATTACH_LIFETIME_TRACKING: u64 = 0x3ecb510113116dcf;
1824}
1825
1826pub mod buffer_collection_token_ordinals {
1827    pub const SYNC: u64 = 0x11ac2555cf575b54;
1828    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1829    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1830    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1831    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1832    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1833    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1834    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1835    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1836    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1837    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1838    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1839    pub const DUPLICATE_SYNC: u64 = 0x1c1af9919d1ca45c;
1840    pub const DUPLICATE: u64 = 0x73e78f92ee7fb887;
1841    pub const SET_DISPENSABLE: u64 = 0x228acf979254df8b;
1842    pub const CREATE_BUFFER_COLLECTION_TOKEN_GROUP: u64 = 0x30f8d48e77bd36f2;
1843}
1844
1845pub mod buffer_collection_token_group_ordinals {
1846    pub const SYNC: u64 = 0x11ac2555cf575b54;
1847    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1848    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1849    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1850    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1851    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1852    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1853    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1854    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1855    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1856    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1857    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1858    pub const CREATE_CHILD: u64 = 0x41a0075d419f30c5;
1859    pub const CREATE_CHILDREN_SYNC: u64 = 0x15dea448c536070a;
1860    pub const ALL_CHILDREN_PRESENT: u64 = 0x5c327e4a23391312;
1861}
1862
1863pub mod node_ordinals {
1864    pub const SYNC: u64 = 0x11ac2555cf575b54;
1865    pub const RELEASE: u64 = 0x6a5cae7d6d6e04c6;
1866    pub const SET_NAME: u64 = 0xb41f1624f48c1e9;
1867    pub const SET_DEBUG_CLIENT_INFO: u64 = 0x5cde8914608d99b1;
1868    pub const SET_DEBUG_TIMEOUT_LOG_DEADLINE: u64 = 0x716b0af13d5c0806;
1869    pub const SET_VERBOSE_LOGGING: u64 = 0x5209c77415b4dfad;
1870    pub const GET_NODE_REF: u64 = 0x5b3d0e51614df053;
1871    pub const IS_ALTERNATE_FOR: u64 = 0x3a58e00157e0825;
1872    pub const GET_BUFFER_COLLECTION_ID: u64 = 0x77d19a494b78ba8c;
1873    pub const SET_WEAK: u64 = 0x22dd3ea514eeffe1;
1874    pub const SET_WEAK_OK: u64 = 0x38a44fc4d7724be9;
1875    pub const ATTACH_NODE_TRACKING: u64 = 0x3f22f2a293d3cdac;
1876}
1877
1878pub mod secure_mem_ordinals {
1879    pub const GET_PHYSICAL_SECURE_HEAPS: u64 = 0x38716300592073e3;
1880    pub const GET_DYNAMIC_SECURE_HEAPS: u64 = 0x1190847f99952834;
1881    pub const GET_PHYSICAL_SECURE_HEAP_PROPERTIES: u64 = 0xc6f06889009c7bc;
1882    pub const ADD_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0x35f695b9b6c7217a;
1883    pub const DELETE_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0xeaa58c650264c9e;
1884    pub const MODIFY_SECURE_HEAP_PHYSICAL_RANGE: u64 = 0x60b7448aa1187734;
1885    pub const ZERO_SUB_RANGE: u64 = 0x5b25b7901a385ce5;
1886}
1887
1888mod internal {
1889    use super::*;
1890    unsafe impl fidl::encoding::TypeMarker for CoherencyDomain {
1891        type Owned = Self;
1892
1893        #[inline(always)]
1894        fn inline_align(_context: fidl::encoding::Context) -> usize {
1895            std::mem::align_of::<u32>()
1896        }
1897
1898        #[inline(always)]
1899        fn inline_size(_context: fidl::encoding::Context) -> usize {
1900            std::mem::size_of::<u32>()
1901        }
1902
1903        #[inline(always)]
1904        fn encode_is_copy() -> bool {
1905            false
1906        }
1907
1908        #[inline(always)]
1909        fn decode_is_copy() -> bool {
1910            false
1911        }
1912    }
1913
1914    impl fidl::encoding::ValueTypeMarker for CoherencyDomain {
1915        type Borrowed<'a> = Self;
1916        #[inline(always)]
1917        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1918            *value
1919        }
1920    }
1921
1922    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1923        for CoherencyDomain
1924    {
1925        #[inline]
1926        unsafe fn encode(
1927            self,
1928            encoder: &mut fidl::encoding::Encoder<'_, D>,
1929            offset: usize,
1930            _depth: fidl::encoding::Depth,
1931        ) -> fidl::Result<()> {
1932            encoder.debug_check_bounds::<Self>(offset);
1933            encoder.write_num(self.into_primitive(), offset);
1934            Ok(())
1935        }
1936    }
1937
1938    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CoherencyDomain {
1939        #[inline(always)]
1940        fn new_empty() -> Self {
1941            Self::unknown()
1942        }
1943
1944        #[inline]
1945        unsafe fn decode(
1946            &mut self,
1947            decoder: &mut fidl::encoding::Decoder<'_, D>,
1948            offset: usize,
1949            _depth: fidl::encoding::Depth,
1950        ) -> fidl::Result<()> {
1951            decoder.debug_check_bounds::<Self>(offset);
1952            let prim = decoder.read_num::<u32>(offset);
1953
1954            *self = Self::from_primitive_allow_unknown(prim);
1955            Ok(())
1956        }
1957    }
1958    unsafe impl fidl::encoding::TypeMarker for Error {
1959        type Owned = Self;
1960
1961        #[inline(always)]
1962        fn inline_align(_context: fidl::encoding::Context) -> usize {
1963            std::mem::align_of::<u32>()
1964        }
1965
1966        #[inline(always)]
1967        fn inline_size(_context: fidl::encoding::Context) -> usize {
1968            std::mem::size_of::<u32>()
1969        }
1970
1971        #[inline(always)]
1972        fn encode_is_copy() -> bool {
1973            false
1974        }
1975
1976        #[inline(always)]
1977        fn decode_is_copy() -> bool {
1978            false
1979        }
1980    }
1981
1982    impl fidl::encoding::ValueTypeMarker for Error {
1983        type Borrowed<'a> = Self;
1984        #[inline(always)]
1985        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1986            *value
1987        }
1988    }
1989
1990    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
1991        #[inline]
1992        unsafe fn encode(
1993            self,
1994            encoder: &mut fidl::encoding::Encoder<'_, D>,
1995            offset: usize,
1996            _depth: fidl::encoding::Depth,
1997        ) -> fidl::Result<()> {
1998            encoder.debug_check_bounds::<Self>(offset);
1999            encoder.write_num(self.into_primitive(), offset);
2000            Ok(())
2001        }
2002    }
2003
2004    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
2005        #[inline(always)]
2006        fn new_empty() -> Self {
2007            Self::unknown()
2008        }
2009
2010        #[inline]
2011        unsafe fn decode(
2012            &mut self,
2013            decoder: &mut fidl::encoding::Decoder<'_, D>,
2014            offset: usize,
2015            _depth: fidl::encoding::Depth,
2016        ) -> fidl::Result<()> {
2017            decoder.debug_check_bounds::<Self>(offset);
2018            let prim = decoder.read_num::<u32>(offset);
2019
2020            *self = Self::from_primitive_allow_unknown(prim);
2021            Ok(())
2022        }
2023    }
2024
2025    impl fidl::encoding::ValueTypeMarker for PixelFormatAndModifier {
2026        type Borrowed<'a> = &'a Self;
2027        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2028            value
2029        }
2030    }
2031
2032    unsafe impl fidl::encoding::TypeMarker for PixelFormatAndModifier {
2033        type Owned = Self;
2034
2035        #[inline(always)]
2036        fn inline_align(_context: fidl::encoding::Context) -> usize {
2037            8
2038        }
2039
2040        #[inline(always)]
2041        fn inline_size(_context: fidl::encoding::Context) -> usize {
2042            16
2043        }
2044    }
2045
2046    unsafe impl<D: fidl::encoding::ResourceDialect>
2047        fidl::encoding::Encode<PixelFormatAndModifier, D> for &PixelFormatAndModifier
2048    {
2049        #[inline]
2050        unsafe fn encode(
2051            self,
2052            encoder: &mut fidl::encoding::Encoder<'_, D>,
2053            offset: usize,
2054            _depth: fidl::encoding::Depth,
2055        ) -> fidl::Result<()> {
2056            encoder.debug_check_bounds::<PixelFormatAndModifier>(offset);
2057            // Delegate to tuple encoding.
2058            fidl::encoding::Encode::<PixelFormatAndModifier, D>::encode(
2059                (
2060                    <fidl_fuchsia_images2_common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format),
2061                    <fidl_fuchsia_images2_common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format_modifier),
2062                ),
2063                encoder, offset, _depth
2064            )
2065        }
2066    }
2067    unsafe impl<
2068        D: fidl::encoding::ResourceDialect,
2069        T0: fidl::encoding::Encode<fidl_fuchsia_images2_common::PixelFormat, D>,
2070        T1: fidl::encoding::Encode<fidl_fuchsia_images2_common::PixelFormatModifier, D>,
2071    > fidl::encoding::Encode<PixelFormatAndModifier, D> for (T0, T1)
2072    {
2073        #[inline]
2074        unsafe fn encode(
2075            self,
2076            encoder: &mut fidl::encoding::Encoder<'_, D>,
2077            offset: usize,
2078            depth: fidl::encoding::Depth,
2079        ) -> fidl::Result<()> {
2080            encoder.debug_check_bounds::<PixelFormatAndModifier>(offset);
2081            // Zero out padding regions. There's no need to apply masks
2082            // because the unmasked parts will be overwritten by fields.
2083            unsafe {
2084                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2085                (ptr as *mut u64).write_unaligned(0);
2086            }
2087            // Write the fields.
2088            self.0.encode(encoder, offset + 0, depth)?;
2089            self.1.encode(encoder, offset + 8, depth)?;
2090            Ok(())
2091        }
2092    }
2093
2094    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2095        for PixelFormatAndModifier
2096    {
2097        #[inline(always)]
2098        fn new_empty() -> Self {
2099            Self {
2100                pixel_format: fidl::new_empty!(fidl_fuchsia_images2_common::PixelFormat, D),
2101                pixel_format_modifier: fidl::new_empty!(
2102                    fidl_fuchsia_images2_common::PixelFormatModifier,
2103                    D
2104                ),
2105            }
2106        }
2107
2108        #[inline]
2109        unsafe fn decode(
2110            &mut self,
2111            decoder: &mut fidl::encoding::Decoder<'_, D>,
2112            offset: usize,
2113            _depth: fidl::encoding::Depth,
2114        ) -> fidl::Result<()> {
2115            decoder.debug_check_bounds::<Self>(offset);
2116            // Verify that padding bytes are zero.
2117            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2118            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2119            let mask = 0xffffffff00000000u64;
2120            let maskedval = padval & mask;
2121            if maskedval != 0 {
2122                return Err(fidl::Error::NonZeroPadding {
2123                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2124                });
2125            }
2126            fidl::decode!(
2127                fidl_fuchsia_images2_common::PixelFormat,
2128                D,
2129                &mut self.pixel_format,
2130                decoder,
2131                offset + 0,
2132                _depth
2133            )?;
2134            fidl::decode!(
2135                fidl_fuchsia_images2_common::PixelFormatModifier,
2136                D,
2137                &mut self.pixel_format_modifier,
2138                decoder,
2139                offset + 8,
2140                _depth
2141            )?;
2142            Ok(())
2143        }
2144    }
2145
2146    impl AllocatorSetDebugClientInfoRequest {
2147        #[inline(always)]
2148        fn max_ordinal_present(&self) -> u64 {
2149            if let Some(_) = self.id {
2150                return 2;
2151            }
2152            if let Some(_) = self.name {
2153                return 1;
2154            }
2155            0
2156        }
2157    }
2158
2159    impl fidl::encoding::ValueTypeMarker for AllocatorSetDebugClientInfoRequest {
2160        type Borrowed<'a> = &'a Self;
2161        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2162            value
2163        }
2164    }
2165
2166    unsafe impl fidl::encoding::TypeMarker for AllocatorSetDebugClientInfoRequest {
2167        type Owned = Self;
2168
2169        #[inline(always)]
2170        fn inline_align(_context: fidl::encoding::Context) -> usize {
2171            8
2172        }
2173
2174        #[inline(always)]
2175        fn inline_size(_context: fidl::encoding::Context) -> usize {
2176            16
2177        }
2178    }
2179
2180    unsafe impl<D: fidl::encoding::ResourceDialect>
2181        fidl::encoding::Encode<AllocatorSetDebugClientInfoRequest, D>
2182        for &AllocatorSetDebugClientInfoRequest
2183    {
2184        unsafe fn encode(
2185            self,
2186            encoder: &mut fidl::encoding::Encoder<'_, D>,
2187            offset: usize,
2188            mut depth: fidl::encoding::Depth,
2189        ) -> fidl::Result<()> {
2190            encoder.debug_check_bounds::<AllocatorSetDebugClientInfoRequest>(offset);
2191            // Vector header
2192            let max_ordinal: u64 = self.max_ordinal_present();
2193            encoder.write_num(max_ordinal, offset);
2194            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2195            // Calling encoder.out_of_line_offset(0) is not allowed.
2196            if max_ordinal == 0 {
2197                return Ok(());
2198            }
2199            depth.increment()?;
2200            let envelope_size = 8;
2201            let bytes_len = max_ordinal as usize * envelope_size;
2202            #[allow(unused_variables)]
2203            let offset = encoder.out_of_line_offset(bytes_len);
2204            let mut _prev_end_offset: usize = 0;
2205            if 1 > max_ordinal {
2206                return Ok(());
2207            }
2208
2209            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2210            // are envelope_size bytes.
2211            let cur_offset: usize = (1 - 1) * envelope_size;
2212
2213            // Zero reserved fields.
2214            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2215
2216            // Safety:
2217            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2218            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2219            //   envelope_size bytes, there is always sufficient room.
2220            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
2221                self.name.as_ref().map(
2222                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
2223                ),
2224                encoder,
2225                offset + cur_offset,
2226                depth,
2227            )?;
2228
2229            _prev_end_offset = cur_offset + envelope_size;
2230            if 2 > max_ordinal {
2231                return Ok(());
2232            }
2233
2234            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2235            // are envelope_size bytes.
2236            let cur_offset: usize = (2 - 1) * envelope_size;
2237
2238            // Zero reserved fields.
2239            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2240
2241            // Safety:
2242            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2243            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2244            //   envelope_size bytes, there is always sufficient room.
2245            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2246                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2247                encoder,
2248                offset + cur_offset,
2249                depth,
2250            )?;
2251
2252            _prev_end_offset = cur_offset + envelope_size;
2253
2254            Ok(())
2255        }
2256    }
2257
2258    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2259        for AllocatorSetDebugClientInfoRequest
2260    {
2261        #[inline(always)]
2262        fn new_empty() -> Self {
2263            Self::default()
2264        }
2265
2266        unsafe fn decode(
2267            &mut self,
2268            decoder: &mut fidl::encoding::Decoder<'_, D>,
2269            offset: usize,
2270            mut depth: fidl::encoding::Depth,
2271        ) -> fidl::Result<()> {
2272            decoder.debug_check_bounds::<Self>(offset);
2273            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2274                None => return Err(fidl::Error::NotNullable),
2275                Some(len) => len,
2276            };
2277            // Calling decoder.out_of_line_offset(0) is not allowed.
2278            if len == 0 {
2279                return Ok(());
2280            };
2281            depth.increment()?;
2282            let envelope_size = 8;
2283            let bytes_len = len * envelope_size;
2284            let offset = decoder.out_of_line_offset(bytes_len)?;
2285            // Decode the envelope for each type.
2286            let mut _next_ordinal_to_read = 0;
2287            let mut next_offset = offset;
2288            let end_offset = offset + bytes_len;
2289            _next_ordinal_to_read += 1;
2290            if next_offset >= end_offset {
2291                return Ok(());
2292            }
2293
2294            // Decode unknown envelopes for gaps in ordinals.
2295            while _next_ordinal_to_read < 1 {
2296                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2297                _next_ordinal_to_read += 1;
2298                next_offset += envelope_size;
2299            }
2300
2301            let next_out_of_line = decoder.next_out_of_line();
2302            let handles_before = decoder.remaining_handles();
2303            if let Some((inlined, num_bytes, num_handles)) =
2304                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2305            {
2306                let member_inline_size =
2307                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
2308                        decoder.context,
2309                    );
2310                if inlined != (member_inline_size <= 4) {
2311                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2312                }
2313                let inner_offset;
2314                let mut inner_depth = depth.clone();
2315                if inlined {
2316                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2317                    inner_offset = next_offset;
2318                } else {
2319                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2320                    inner_depth.increment()?;
2321                }
2322                let val_ref = self
2323                    .name
2324                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
2325                fidl::decode!(
2326                    fidl::encoding::BoundedString<256>,
2327                    D,
2328                    val_ref,
2329                    decoder,
2330                    inner_offset,
2331                    inner_depth
2332                )?;
2333                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2334                {
2335                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2336                }
2337                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2338                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2339                }
2340            }
2341
2342            next_offset += envelope_size;
2343            _next_ordinal_to_read += 1;
2344            if next_offset >= end_offset {
2345                return Ok(());
2346            }
2347
2348            // Decode unknown envelopes for gaps in ordinals.
2349            while _next_ordinal_to_read < 2 {
2350                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2351                _next_ordinal_to_read += 1;
2352                next_offset += envelope_size;
2353            }
2354
2355            let next_out_of_line = decoder.next_out_of_line();
2356            let handles_before = decoder.remaining_handles();
2357            if let Some((inlined, num_bytes, num_handles)) =
2358                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2359            {
2360                let member_inline_size =
2361                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2362                if inlined != (member_inline_size <= 4) {
2363                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2364                }
2365                let inner_offset;
2366                let mut inner_depth = depth.clone();
2367                if inlined {
2368                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2369                    inner_offset = next_offset;
2370                } else {
2371                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2372                    inner_depth.increment()?;
2373                }
2374                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
2375                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2376                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2377                {
2378                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2379                }
2380                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2381                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2382                }
2383            }
2384
2385            next_offset += envelope_size;
2386
2387            // Decode the remaining unknown envelopes.
2388            while next_offset < end_offset {
2389                _next_ordinal_to_read += 1;
2390                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2391                next_offset += envelope_size;
2392            }
2393
2394            Ok(())
2395        }
2396    }
2397
2398    impl AllocatorValidateBufferCollectionTokenRequest {
2399        #[inline(always)]
2400        fn max_ordinal_present(&self) -> u64 {
2401            if let Some(_) = self.token_server_koid {
2402                return 1;
2403            }
2404            0
2405        }
2406    }
2407
2408    impl fidl::encoding::ValueTypeMarker for AllocatorValidateBufferCollectionTokenRequest {
2409        type Borrowed<'a> = &'a Self;
2410        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2411            value
2412        }
2413    }
2414
2415    unsafe impl fidl::encoding::TypeMarker for AllocatorValidateBufferCollectionTokenRequest {
2416        type Owned = Self;
2417
2418        #[inline(always)]
2419        fn inline_align(_context: fidl::encoding::Context) -> usize {
2420            8
2421        }
2422
2423        #[inline(always)]
2424        fn inline_size(_context: fidl::encoding::Context) -> usize {
2425            16
2426        }
2427    }
2428
2429    unsafe impl<D: fidl::encoding::ResourceDialect>
2430        fidl::encoding::Encode<AllocatorValidateBufferCollectionTokenRequest, D>
2431        for &AllocatorValidateBufferCollectionTokenRequest
2432    {
2433        unsafe fn encode(
2434            self,
2435            encoder: &mut fidl::encoding::Encoder<'_, D>,
2436            offset: usize,
2437            mut depth: fidl::encoding::Depth,
2438        ) -> fidl::Result<()> {
2439            encoder.debug_check_bounds::<AllocatorValidateBufferCollectionTokenRequest>(offset);
2440            // Vector header
2441            let max_ordinal: u64 = self.max_ordinal_present();
2442            encoder.write_num(max_ordinal, offset);
2443            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2444            // Calling encoder.out_of_line_offset(0) is not allowed.
2445            if max_ordinal == 0 {
2446                return Ok(());
2447            }
2448            depth.increment()?;
2449            let envelope_size = 8;
2450            let bytes_len = max_ordinal as usize * envelope_size;
2451            #[allow(unused_variables)]
2452            let offset = encoder.out_of_line_offset(bytes_len);
2453            let mut _prev_end_offset: usize = 0;
2454            if 1 > max_ordinal {
2455                return Ok(());
2456            }
2457
2458            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2459            // are envelope_size bytes.
2460            let cur_offset: usize = (1 - 1) * envelope_size;
2461
2462            // Zero reserved fields.
2463            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2464
2465            // Safety:
2466            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2467            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2468            //   envelope_size bytes, there is always sufficient room.
2469            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2470                self.token_server_koid
2471                    .as_ref()
2472                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2473                encoder,
2474                offset + cur_offset,
2475                depth,
2476            )?;
2477
2478            _prev_end_offset = cur_offset + envelope_size;
2479
2480            Ok(())
2481        }
2482    }
2483
2484    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2485        for AllocatorValidateBufferCollectionTokenRequest
2486    {
2487        #[inline(always)]
2488        fn new_empty() -> Self {
2489            Self::default()
2490        }
2491
2492        unsafe fn decode(
2493            &mut self,
2494            decoder: &mut fidl::encoding::Decoder<'_, D>,
2495            offset: usize,
2496            mut depth: fidl::encoding::Depth,
2497        ) -> fidl::Result<()> {
2498            decoder.debug_check_bounds::<Self>(offset);
2499            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2500                None => return Err(fidl::Error::NotNullable),
2501                Some(len) => len,
2502            };
2503            // Calling decoder.out_of_line_offset(0) is not allowed.
2504            if len == 0 {
2505                return Ok(());
2506            };
2507            depth.increment()?;
2508            let envelope_size = 8;
2509            let bytes_len = len * envelope_size;
2510            let offset = decoder.out_of_line_offset(bytes_len)?;
2511            // Decode the envelope for each type.
2512            let mut _next_ordinal_to_read = 0;
2513            let mut next_offset = offset;
2514            let end_offset = offset + bytes_len;
2515            _next_ordinal_to_read += 1;
2516            if next_offset >= end_offset {
2517                return Ok(());
2518            }
2519
2520            // Decode unknown envelopes for gaps in ordinals.
2521            while _next_ordinal_to_read < 1 {
2522                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2523                _next_ordinal_to_read += 1;
2524                next_offset += envelope_size;
2525            }
2526
2527            let next_out_of_line = decoder.next_out_of_line();
2528            let handles_before = decoder.remaining_handles();
2529            if let Some((inlined, num_bytes, num_handles)) =
2530                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2531            {
2532                let member_inline_size =
2533                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2534                if inlined != (member_inline_size <= 4) {
2535                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2536                }
2537                let inner_offset;
2538                let mut inner_depth = depth.clone();
2539                if inlined {
2540                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2541                    inner_offset = next_offset;
2542                } else {
2543                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2544                    inner_depth.increment()?;
2545                }
2546                let val_ref =
2547                    self.token_server_koid.get_or_insert_with(|| fidl::new_empty!(u64, D));
2548                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2549                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2550                {
2551                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2552                }
2553                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2554                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2555                }
2556            }
2557
2558            next_offset += envelope_size;
2559
2560            // Decode the remaining unknown envelopes.
2561            while next_offset < end_offset {
2562                _next_ordinal_to_read += 1;
2563                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2564                next_offset += envelope_size;
2565            }
2566
2567            Ok(())
2568        }
2569    }
2570
2571    impl AllocatorValidateBufferCollectionTokenResponse {
2572        #[inline(always)]
2573        fn max_ordinal_present(&self) -> u64 {
2574            if let Some(_) = self.is_known {
2575                return 1;
2576            }
2577            0
2578        }
2579    }
2580
2581    impl fidl::encoding::ValueTypeMarker for AllocatorValidateBufferCollectionTokenResponse {
2582        type Borrowed<'a> = &'a Self;
2583        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2584            value
2585        }
2586    }
2587
2588    unsafe impl fidl::encoding::TypeMarker for AllocatorValidateBufferCollectionTokenResponse {
2589        type Owned = Self;
2590
2591        #[inline(always)]
2592        fn inline_align(_context: fidl::encoding::Context) -> usize {
2593            8
2594        }
2595
2596        #[inline(always)]
2597        fn inline_size(_context: fidl::encoding::Context) -> usize {
2598            16
2599        }
2600    }
2601
2602    unsafe impl<D: fidl::encoding::ResourceDialect>
2603        fidl::encoding::Encode<AllocatorValidateBufferCollectionTokenResponse, D>
2604        for &AllocatorValidateBufferCollectionTokenResponse
2605    {
2606        unsafe fn encode(
2607            self,
2608            encoder: &mut fidl::encoding::Encoder<'_, D>,
2609            offset: usize,
2610            mut depth: fidl::encoding::Depth,
2611        ) -> fidl::Result<()> {
2612            encoder.debug_check_bounds::<AllocatorValidateBufferCollectionTokenResponse>(offset);
2613            // Vector header
2614            let max_ordinal: u64 = self.max_ordinal_present();
2615            encoder.write_num(max_ordinal, offset);
2616            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2617            // Calling encoder.out_of_line_offset(0) is not allowed.
2618            if max_ordinal == 0 {
2619                return Ok(());
2620            }
2621            depth.increment()?;
2622            let envelope_size = 8;
2623            let bytes_len = max_ordinal as usize * envelope_size;
2624            #[allow(unused_variables)]
2625            let offset = encoder.out_of_line_offset(bytes_len);
2626            let mut _prev_end_offset: usize = 0;
2627            if 1 > max_ordinal {
2628                return Ok(());
2629            }
2630
2631            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2632            // are envelope_size bytes.
2633            let cur_offset: usize = (1 - 1) * envelope_size;
2634
2635            // Zero reserved fields.
2636            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2637
2638            // Safety:
2639            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2640            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2641            //   envelope_size bytes, there is always sufficient room.
2642            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2643                self.is_known.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2644                encoder,
2645                offset + cur_offset,
2646                depth,
2647            )?;
2648
2649            _prev_end_offset = cur_offset + envelope_size;
2650
2651            Ok(())
2652        }
2653    }
2654
2655    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2656        for AllocatorValidateBufferCollectionTokenResponse
2657    {
2658        #[inline(always)]
2659        fn new_empty() -> Self {
2660            Self::default()
2661        }
2662
2663        unsafe fn decode(
2664            &mut self,
2665            decoder: &mut fidl::encoding::Decoder<'_, D>,
2666            offset: usize,
2667            mut depth: fidl::encoding::Depth,
2668        ) -> fidl::Result<()> {
2669            decoder.debug_check_bounds::<Self>(offset);
2670            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2671                None => return Err(fidl::Error::NotNullable),
2672                Some(len) => len,
2673            };
2674            // Calling decoder.out_of_line_offset(0) is not allowed.
2675            if len == 0 {
2676                return Ok(());
2677            };
2678            depth.increment()?;
2679            let envelope_size = 8;
2680            let bytes_len = len * envelope_size;
2681            let offset = decoder.out_of_line_offset(bytes_len)?;
2682            // Decode the envelope for each type.
2683            let mut _next_ordinal_to_read = 0;
2684            let mut next_offset = offset;
2685            let end_offset = offset + bytes_len;
2686            _next_ordinal_to_read += 1;
2687            if next_offset >= end_offset {
2688                return Ok(());
2689            }
2690
2691            // Decode unknown envelopes for gaps in ordinals.
2692            while _next_ordinal_to_read < 1 {
2693                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2694                _next_ordinal_to_read += 1;
2695                next_offset += envelope_size;
2696            }
2697
2698            let next_out_of_line = decoder.next_out_of_line();
2699            let handles_before = decoder.remaining_handles();
2700            if let Some((inlined, num_bytes, num_handles)) =
2701                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2702            {
2703                let member_inline_size =
2704                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2705                if inlined != (member_inline_size <= 4) {
2706                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2707                }
2708                let inner_offset;
2709                let mut inner_depth = depth.clone();
2710                if inlined {
2711                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2712                    inner_offset = next_offset;
2713                } else {
2714                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2715                    inner_depth.increment()?;
2716                }
2717                let val_ref = self.is_known.get_or_insert_with(|| fidl::new_empty!(bool, D));
2718                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2719                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2720                {
2721                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2722                }
2723                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2724                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2725                }
2726            }
2727
2728            next_offset += envelope_size;
2729
2730            // Decode the remaining unknown envelopes.
2731            while next_offset < end_offset {
2732                _next_ordinal_to_read += 1;
2733                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2734                next_offset += envelope_size;
2735            }
2736
2737            Ok(())
2738        }
2739    }
2740
2741    impl BufferCollectionConstraints {
2742        #[inline(always)]
2743        fn max_ordinal_present(&self) -> u64 {
2744            if let Some(_) = self.image_format_constraints {
2745                return 8;
2746            }
2747            if let Some(_) = self.buffer_memory_constraints {
2748                return 7;
2749            }
2750            if let Some(_) = self.max_buffer_count {
2751                return 6;
2752            }
2753            if let Some(_) = self.min_buffer_count {
2754                return 5;
2755            }
2756            if let Some(_) = self.min_buffer_count_for_shared_slack {
2757                return 4;
2758            }
2759            if let Some(_) = self.min_buffer_count_for_dedicated_slack {
2760                return 3;
2761            }
2762            if let Some(_) = self.min_buffer_count_for_camping {
2763                return 2;
2764            }
2765            if let Some(_) = self.usage {
2766                return 1;
2767            }
2768            0
2769        }
2770    }
2771
2772    impl fidl::encoding::ValueTypeMarker for BufferCollectionConstraints {
2773        type Borrowed<'a> = &'a Self;
2774        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2775            value
2776        }
2777    }
2778
2779    unsafe impl fidl::encoding::TypeMarker for BufferCollectionConstraints {
2780        type Owned = Self;
2781
2782        #[inline(always)]
2783        fn inline_align(_context: fidl::encoding::Context) -> usize {
2784            8
2785        }
2786
2787        #[inline(always)]
2788        fn inline_size(_context: fidl::encoding::Context) -> usize {
2789            16
2790        }
2791    }
2792
2793    unsafe impl<D: fidl::encoding::ResourceDialect>
2794        fidl::encoding::Encode<BufferCollectionConstraints, D> for &BufferCollectionConstraints
2795    {
2796        unsafe fn encode(
2797            self,
2798            encoder: &mut fidl::encoding::Encoder<'_, D>,
2799            offset: usize,
2800            mut depth: fidl::encoding::Depth,
2801        ) -> fidl::Result<()> {
2802            encoder.debug_check_bounds::<BufferCollectionConstraints>(offset);
2803            // Vector header
2804            let max_ordinal: u64 = self.max_ordinal_present();
2805            encoder.write_num(max_ordinal, offset);
2806            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2807            // Calling encoder.out_of_line_offset(0) is not allowed.
2808            if max_ordinal == 0 {
2809                return Ok(());
2810            }
2811            depth.increment()?;
2812            let envelope_size = 8;
2813            let bytes_len = max_ordinal as usize * envelope_size;
2814            #[allow(unused_variables)]
2815            let offset = encoder.out_of_line_offset(bytes_len);
2816            let mut _prev_end_offset: usize = 0;
2817            if 1 > max_ordinal {
2818                return Ok(());
2819            }
2820
2821            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2822            // are envelope_size bytes.
2823            let cur_offset: usize = (1 - 1) * envelope_size;
2824
2825            // Zero reserved fields.
2826            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2827
2828            // Safety:
2829            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2830            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2831            //   envelope_size bytes, there is always sufficient room.
2832            fidl::encoding::encode_in_envelope_optional::<BufferUsage, D>(
2833                self.usage.as_ref().map(<BufferUsage as fidl::encoding::ValueTypeMarker>::borrow),
2834                encoder,
2835                offset + cur_offset,
2836                depth,
2837            )?;
2838
2839            _prev_end_offset = cur_offset + envelope_size;
2840            if 2 > max_ordinal {
2841                return Ok(());
2842            }
2843
2844            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2845            // are envelope_size bytes.
2846            let cur_offset: usize = (2 - 1) * envelope_size;
2847
2848            // Zero reserved fields.
2849            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2850
2851            // Safety:
2852            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2853            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2854            //   envelope_size bytes, there is always sufficient room.
2855            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2856                self.min_buffer_count_for_camping
2857                    .as_ref()
2858                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2859                encoder,
2860                offset + cur_offset,
2861                depth,
2862            )?;
2863
2864            _prev_end_offset = cur_offset + envelope_size;
2865            if 3 > max_ordinal {
2866                return Ok(());
2867            }
2868
2869            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2870            // are envelope_size bytes.
2871            let cur_offset: usize = (3 - 1) * envelope_size;
2872
2873            // Zero reserved fields.
2874            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2875
2876            // Safety:
2877            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2878            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2879            //   envelope_size bytes, there is always sufficient room.
2880            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2881                self.min_buffer_count_for_dedicated_slack
2882                    .as_ref()
2883                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2884                encoder,
2885                offset + cur_offset,
2886                depth,
2887            )?;
2888
2889            _prev_end_offset = cur_offset + envelope_size;
2890            if 4 > max_ordinal {
2891                return Ok(());
2892            }
2893
2894            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2895            // are envelope_size bytes.
2896            let cur_offset: usize = (4 - 1) * envelope_size;
2897
2898            // Zero reserved fields.
2899            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2900
2901            // Safety:
2902            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2903            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2904            //   envelope_size bytes, there is always sufficient room.
2905            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2906                self.min_buffer_count_for_shared_slack
2907                    .as_ref()
2908                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2909                encoder,
2910                offset + cur_offset,
2911                depth,
2912            )?;
2913
2914            _prev_end_offset = cur_offset + envelope_size;
2915            if 5 > max_ordinal {
2916                return Ok(());
2917            }
2918
2919            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2920            // are envelope_size bytes.
2921            let cur_offset: usize = (5 - 1) * envelope_size;
2922
2923            // Zero reserved fields.
2924            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2925
2926            // Safety:
2927            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2928            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2929            //   envelope_size bytes, there is always sufficient room.
2930            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2931                self.min_buffer_count
2932                    .as_ref()
2933                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2934                encoder,
2935                offset + cur_offset,
2936                depth,
2937            )?;
2938
2939            _prev_end_offset = cur_offset + envelope_size;
2940            if 6 > max_ordinal {
2941                return Ok(());
2942            }
2943
2944            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2945            // are envelope_size bytes.
2946            let cur_offset: usize = (6 - 1) * envelope_size;
2947
2948            // Zero reserved fields.
2949            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2950
2951            // Safety:
2952            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2953            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2954            //   envelope_size bytes, there is always sufficient room.
2955            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2956                self.max_buffer_count
2957                    .as_ref()
2958                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2959                encoder,
2960                offset + cur_offset,
2961                depth,
2962            )?;
2963
2964            _prev_end_offset = cur_offset + envelope_size;
2965            if 7 > max_ordinal {
2966                return Ok(());
2967            }
2968
2969            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2970            // are envelope_size bytes.
2971            let cur_offset: usize = (7 - 1) * envelope_size;
2972
2973            // Zero reserved fields.
2974            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2975
2976            // Safety:
2977            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2978            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2979            //   envelope_size bytes, there is always sufficient room.
2980            fidl::encoding::encode_in_envelope_optional::<BufferMemoryConstraints, D>(
2981                self.buffer_memory_constraints
2982                    .as_ref()
2983                    .map(<BufferMemoryConstraints as fidl::encoding::ValueTypeMarker>::borrow),
2984                encoder,
2985                offset + cur_offset,
2986                depth,
2987            )?;
2988
2989            _prev_end_offset = cur_offset + envelope_size;
2990            if 8 > max_ordinal {
2991                return Ok(());
2992            }
2993
2994            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2995            // are envelope_size bytes.
2996            let cur_offset: usize = (8 - 1) * envelope_size;
2997
2998            // Zero reserved fields.
2999            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3000
3001            // Safety:
3002            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3003            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3004            //   envelope_size bytes, there is always sufficient room.
3005            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<ImageFormatConstraints, 64>, D>(
3006            self.image_format_constraints.as_ref().map(<fidl::encoding::Vector<ImageFormatConstraints, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3007            encoder, offset + cur_offset, depth
3008        )?;
3009
3010            _prev_end_offset = cur_offset + envelope_size;
3011
3012            Ok(())
3013        }
3014    }
3015
3016    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3017        for BufferCollectionConstraints
3018    {
3019        #[inline(always)]
3020        fn new_empty() -> Self {
3021            Self::default()
3022        }
3023
3024        unsafe fn decode(
3025            &mut self,
3026            decoder: &mut fidl::encoding::Decoder<'_, D>,
3027            offset: usize,
3028            mut depth: fidl::encoding::Depth,
3029        ) -> fidl::Result<()> {
3030            decoder.debug_check_bounds::<Self>(offset);
3031            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3032                None => return Err(fidl::Error::NotNullable),
3033                Some(len) => len,
3034            };
3035            // Calling decoder.out_of_line_offset(0) is not allowed.
3036            if len == 0 {
3037                return Ok(());
3038            };
3039            depth.increment()?;
3040            let envelope_size = 8;
3041            let bytes_len = len * envelope_size;
3042            let offset = decoder.out_of_line_offset(bytes_len)?;
3043            // Decode the envelope for each type.
3044            let mut _next_ordinal_to_read = 0;
3045            let mut next_offset = offset;
3046            let end_offset = offset + bytes_len;
3047            _next_ordinal_to_read += 1;
3048            if next_offset >= end_offset {
3049                return Ok(());
3050            }
3051
3052            // Decode unknown envelopes for gaps in ordinals.
3053            while _next_ordinal_to_read < 1 {
3054                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3055                _next_ordinal_to_read += 1;
3056                next_offset += envelope_size;
3057            }
3058
3059            let next_out_of_line = decoder.next_out_of_line();
3060            let handles_before = decoder.remaining_handles();
3061            if let Some((inlined, num_bytes, num_handles)) =
3062                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3063            {
3064                let member_inline_size =
3065                    <BufferUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3066                if inlined != (member_inline_size <= 4) {
3067                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3068                }
3069                let inner_offset;
3070                let mut inner_depth = depth.clone();
3071                if inlined {
3072                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3073                    inner_offset = next_offset;
3074                } else {
3075                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3076                    inner_depth.increment()?;
3077                }
3078                let val_ref = self.usage.get_or_insert_with(|| fidl::new_empty!(BufferUsage, D));
3079                fidl::decode!(BufferUsage, D, val_ref, decoder, inner_offset, inner_depth)?;
3080                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3081                {
3082                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3083                }
3084                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3085                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3086                }
3087            }
3088
3089            next_offset += envelope_size;
3090            _next_ordinal_to_read += 1;
3091            if next_offset >= end_offset {
3092                return Ok(());
3093            }
3094
3095            // Decode unknown envelopes for gaps in ordinals.
3096            while _next_ordinal_to_read < 2 {
3097                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3098                _next_ordinal_to_read += 1;
3099                next_offset += envelope_size;
3100            }
3101
3102            let next_out_of_line = decoder.next_out_of_line();
3103            let handles_before = decoder.remaining_handles();
3104            if let Some((inlined, num_bytes, num_handles)) =
3105                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3106            {
3107                let member_inline_size =
3108                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3109                if inlined != (member_inline_size <= 4) {
3110                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3111                }
3112                let inner_offset;
3113                let mut inner_depth = depth.clone();
3114                if inlined {
3115                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3116                    inner_offset = next_offset;
3117                } else {
3118                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3119                    inner_depth.increment()?;
3120                }
3121                let val_ref = self
3122                    .min_buffer_count_for_camping
3123                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3124                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3125                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3126                {
3127                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3128                }
3129                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3130                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3131                }
3132            }
3133
3134            next_offset += envelope_size;
3135            _next_ordinal_to_read += 1;
3136            if next_offset >= end_offset {
3137                return Ok(());
3138            }
3139
3140            // Decode unknown envelopes for gaps in ordinals.
3141            while _next_ordinal_to_read < 3 {
3142                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3143                _next_ordinal_to_read += 1;
3144                next_offset += envelope_size;
3145            }
3146
3147            let next_out_of_line = decoder.next_out_of_line();
3148            let handles_before = decoder.remaining_handles();
3149            if let Some((inlined, num_bytes, num_handles)) =
3150                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3151            {
3152                let member_inline_size =
3153                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3154                if inlined != (member_inline_size <= 4) {
3155                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3156                }
3157                let inner_offset;
3158                let mut inner_depth = depth.clone();
3159                if inlined {
3160                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3161                    inner_offset = next_offset;
3162                } else {
3163                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3164                    inner_depth.increment()?;
3165                }
3166                let val_ref = self
3167                    .min_buffer_count_for_dedicated_slack
3168                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3169                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3170                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3171                {
3172                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3173                }
3174                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3175                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3176                }
3177            }
3178
3179            next_offset += envelope_size;
3180            _next_ordinal_to_read += 1;
3181            if next_offset >= end_offset {
3182                return Ok(());
3183            }
3184
3185            // Decode unknown envelopes for gaps in ordinals.
3186            while _next_ordinal_to_read < 4 {
3187                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3188                _next_ordinal_to_read += 1;
3189                next_offset += envelope_size;
3190            }
3191
3192            let next_out_of_line = decoder.next_out_of_line();
3193            let handles_before = decoder.remaining_handles();
3194            if let Some((inlined, num_bytes, num_handles)) =
3195                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3196            {
3197                let member_inline_size =
3198                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3199                if inlined != (member_inline_size <= 4) {
3200                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3201                }
3202                let inner_offset;
3203                let mut inner_depth = depth.clone();
3204                if inlined {
3205                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3206                    inner_offset = next_offset;
3207                } else {
3208                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3209                    inner_depth.increment()?;
3210                }
3211                let val_ref = self
3212                    .min_buffer_count_for_shared_slack
3213                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
3214                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3215                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3216                {
3217                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3218                }
3219                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3220                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3221                }
3222            }
3223
3224            next_offset += envelope_size;
3225            _next_ordinal_to_read += 1;
3226            if next_offset >= end_offset {
3227                return Ok(());
3228            }
3229
3230            // Decode unknown envelopes for gaps in ordinals.
3231            while _next_ordinal_to_read < 5 {
3232                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3233                _next_ordinal_to_read += 1;
3234                next_offset += envelope_size;
3235            }
3236
3237            let next_out_of_line = decoder.next_out_of_line();
3238            let handles_before = decoder.remaining_handles();
3239            if let Some((inlined, num_bytes, num_handles)) =
3240                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3241            {
3242                let member_inline_size =
3243                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3244                if inlined != (member_inline_size <= 4) {
3245                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3246                }
3247                let inner_offset;
3248                let mut inner_depth = depth.clone();
3249                if inlined {
3250                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3251                    inner_offset = next_offset;
3252                } else {
3253                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3254                    inner_depth.increment()?;
3255                }
3256                let val_ref = self.min_buffer_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
3257                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3258                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3259                {
3260                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3261                }
3262                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3263                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3264                }
3265            }
3266
3267            next_offset += envelope_size;
3268            _next_ordinal_to_read += 1;
3269            if next_offset >= end_offset {
3270                return Ok(());
3271            }
3272
3273            // Decode unknown envelopes for gaps in ordinals.
3274            while _next_ordinal_to_read < 6 {
3275                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3276                _next_ordinal_to_read += 1;
3277                next_offset += envelope_size;
3278            }
3279
3280            let next_out_of_line = decoder.next_out_of_line();
3281            let handles_before = decoder.remaining_handles();
3282            if let Some((inlined, num_bytes, num_handles)) =
3283                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3284            {
3285                let member_inline_size =
3286                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3287                if inlined != (member_inline_size <= 4) {
3288                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3289                }
3290                let inner_offset;
3291                let mut inner_depth = depth.clone();
3292                if inlined {
3293                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3294                    inner_offset = next_offset;
3295                } else {
3296                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3297                    inner_depth.increment()?;
3298                }
3299                let val_ref = self.max_buffer_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
3300                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3301                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3302                {
3303                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3304                }
3305                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3306                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3307                }
3308            }
3309
3310            next_offset += envelope_size;
3311            _next_ordinal_to_read += 1;
3312            if next_offset >= end_offset {
3313                return Ok(());
3314            }
3315
3316            // Decode unknown envelopes for gaps in ordinals.
3317            while _next_ordinal_to_read < 7 {
3318                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3319                _next_ordinal_to_read += 1;
3320                next_offset += envelope_size;
3321            }
3322
3323            let next_out_of_line = decoder.next_out_of_line();
3324            let handles_before = decoder.remaining_handles();
3325            if let Some((inlined, num_bytes, num_handles)) =
3326                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3327            {
3328                let member_inline_size =
3329                    <BufferMemoryConstraints as fidl::encoding::TypeMarker>::inline_size(
3330                        decoder.context,
3331                    );
3332                if inlined != (member_inline_size <= 4) {
3333                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3334                }
3335                let inner_offset;
3336                let mut inner_depth = depth.clone();
3337                if inlined {
3338                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3339                    inner_offset = next_offset;
3340                } else {
3341                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3342                    inner_depth.increment()?;
3343                }
3344                let val_ref = self
3345                    .buffer_memory_constraints
3346                    .get_or_insert_with(|| fidl::new_empty!(BufferMemoryConstraints, D));
3347                fidl::decode!(
3348                    BufferMemoryConstraints,
3349                    D,
3350                    val_ref,
3351                    decoder,
3352                    inner_offset,
3353                    inner_depth
3354                )?;
3355                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3356                {
3357                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3358                }
3359                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3360                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3361                }
3362            }
3363
3364            next_offset += envelope_size;
3365            _next_ordinal_to_read += 1;
3366            if next_offset >= end_offset {
3367                return Ok(());
3368            }
3369
3370            // Decode unknown envelopes for gaps in ordinals.
3371            while _next_ordinal_to_read < 8 {
3372                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3373                _next_ordinal_to_read += 1;
3374                next_offset += envelope_size;
3375            }
3376
3377            let next_out_of_line = decoder.next_out_of_line();
3378            let handles_before = decoder.remaining_handles();
3379            if let Some((inlined, num_bytes, num_handles)) =
3380                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3381            {
3382                let member_inline_size = <fidl::encoding::Vector<ImageFormatConstraints, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3383                if inlined != (member_inline_size <= 4) {
3384                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3385                }
3386                let inner_offset;
3387                let mut inner_depth = depth.clone();
3388                if inlined {
3389                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3390                    inner_offset = next_offset;
3391                } else {
3392                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3393                    inner_depth.increment()?;
3394                }
3395                let val_ref = self.image_format_constraints.get_or_insert_with(
3396                    || fidl::new_empty!(fidl::encoding::Vector<ImageFormatConstraints, 64>, D),
3397                );
3398                fidl::decode!(fidl::encoding::Vector<ImageFormatConstraints, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3399                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3400                {
3401                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3402                }
3403                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3404                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3405                }
3406            }
3407
3408            next_offset += envelope_size;
3409
3410            // Decode the remaining unknown envelopes.
3411            while next_offset < end_offset {
3412                _next_ordinal_to_read += 1;
3413                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3414                next_offset += envelope_size;
3415            }
3416
3417            Ok(())
3418        }
3419    }
3420
3421    impl BufferCollectionTokenDuplicateSyncRequest {
3422        #[inline(always)]
3423        fn max_ordinal_present(&self) -> u64 {
3424            if let Some(_) = self.rights_attenuation_masks {
3425                return 1;
3426            }
3427            0
3428        }
3429    }
3430
3431    impl fidl::encoding::ValueTypeMarker for BufferCollectionTokenDuplicateSyncRequest {
3432        type Borrowed<'a> = &'a Self;
3433        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3434            value
3435        }
3436    }
3437
3438    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncRequest {
3439        type Owned = Self;
3440
3441        #[inline(always)]
3442        fn inline_align(_context: fidl::encoding::Context) -> usize {
3443            8
3444        }
3445
3446        #[inline(always)]
3447        fn inline_size(_context: fidl::encoding::Context) -> usize {
3448            16
3449        }
3450    }
3451
3452    unsafe impl<D: fidl::encoding::ResourceDialect>
3453        fidl::encoding::Encode<BufferCollectionTokenDuplicateSyncRequest, D>
3454        for &BufferCollectionTokenDuplicateSyncRequest
3455    {
3456        unsafe fn encode(
3457            self,
3458            encoder: &mut fidl::encoding::Encoder<'_, D>,
3459            offset: usize,
3460            mut depth: fidl::encoding::Depth,
3461        ) -> fidl::Result<()> {
3462            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncRequest>(offset);
3463            // Vector header
3464            let max_ordinal: u64 = self.max_ordinal_present();
3465            encoder.write_num(max_ordinal, offset);
3466            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3467            // Calling encoder.out_of_line_offset(0) is not allowed.
3468            if max_ordinal == 0 {
3469                return Ok(());
3470            }
3471            depth.increment()?;
3472            let envelope_size = 8;
3473            let bytes_len = max_ordinal as usize * envelope_size;
3474            #[allow(unused_variables)]
3475            let offset = encoder.out_of_line_offset(bytes_len);
3476            let mut _prev_end_offset: usize = 0;
3477            if 1 > max_ordinal {
3478                return Ok(());
3479            }
3480
3481            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3482            // are envelope_size bytes.
3483            let cur_offset: usize = (1 - 1) * envelope_size;
3484
3485            // Zero reserved fields.
3486            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3487
3488            // Safety:
3489            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3490            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3491            //   envelope_size bytes, there is always sufficient room.
3492            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::Rights, 64>, D>(
3493            self.rights_attenuation_masks.as_ref().map(<fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3494            encoder, offset + cur_offset, depth
3495        )?;
3496
3497            _prev_end_offset = cur_offset + envelope_size;
3498
3499            Ok(())
3500        }
3501    }
3502
3503    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3504        for BufferCollectionTokenDuplicateSyncRequest
3505    {
3506        #[inline(always)]
3507        fn new_empty() -> Self {
3508            Self::default()
3509        }
3510
3511        unsafe fn decode(
3512            &mut self,
3513            decoder: &mut fidl::encoding::Decoder<'_, D>,
3514            offset: usize,
3515            mut depth: fidl::encoding::Depth,
3516        ) -> fidl::Result<()> {
3517            decoder.debug_check_bounds::<Self>(offset);
3518            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3519                None => return Err(fidl::Error::NotNullable),
3520                Some(len) => len,
3521            };
3522            // Calling decoder.out_of_line_offset(0) is not allowed.
3523            if len == 0 {
3524                return Ok(());
3525            };
3526            depth.increment()?;
3527            let envelope_size = 8;
3528            let bytes_len = len * envelope_size;
3529            let offset = decoder.out_of_line_offset(bytes_len)?;
3530            // Decode the envelope for each type.
3531            let mut _next_ordinal_to_read = 0;
3532            let mut next_offset = offset;
3533            let end_offset = offset + bytes_len;
3534            _next_ordinal_to_read += 1;
3535            if next_offset >= end_offset {
3536                return Ok(());
3537            }
3538
3539            // Decode unknown envelopes for gaps in ordinals.
3540            while _next_ordinal_to_read < 1 {
3541                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3542                _next_ordinal_to_read += 1;
3543                next_offset += envelope_size;
3544            }
3545
3546            let next_out_of_line = decoder.next_out_of_line();
3547            let handles_before = decoder.remaining_handles();
3548            if let Some((inlined, num_bytes, num_handles)) =
3549                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3550            {
3551                let member_inline_size = <fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3552                if inlined != (member_inline_size <= 4) {
3553                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3554                }
3555                let inner_offset;
3556                let mut inner_depth = depth.clone();
3557                if inlined {
3558                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3559                    inner_offset = next_offset;
3560                } else {
3561                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3562                    inner_depth.increment()?;
3563                }
3564                let val_ref = self.rights_attenuation_masks.get_or_insert_with(
3565                    || fidl::new_empty!(fidl::encoding::Vector<fidl::Rights, 64>, D),
3566                );
3567                fidl::decode!(fidl::encoding::Vector<fidl::Rights, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3568                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3569                {
3570                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3571                }
3572                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3573                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3574                }
3575            }
3576
3577            next_offset += envelope_size;
3578
3579            // Decode the remaining unknown envelopes.
3580            while next_offset < end_offset {
3581                _next_ordinal_to_read += 1;
3582                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3583                next_offset += envelope_size;
3584            }
3585
3586            Ok(())
3587        }
3588    }
3589
3590    impl BufferCollectionTokenGroupCreateChildrenSyncRequest {
3591        #[inline(always)]
3592        fn max_ordinal_present(&self) -> u64 {
3593            if let Some(_) = self.rights_attenuation_masks {
3594                return 1;
3595            }
3596            0
3597        }
3598    }
3599
3600    impl fidl::encoding::ValueTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncRequest {
3601        type Borrowed<'a> = &'a Self;
3602        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3603            value
3604        }
3605    }
3606
3607    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncRequest {
3608        type Owned = Self;
3609
3610        #[inline(always)]
3611        fn inline_align(_context: fidl::encoding::Context) -> usize {
3612            8
3613        }
3614
3615        #[inline(always)]
3616        fn inline_size(_context: fidl::encoding::Context) -> usize {
3617            16
3618        }
3619    }
3620
3621    unsafe impl<D: fidl::encoding::ResourceDialect>
3622        fidl::encoding::Encode<BufferCollectionTokenGroupCreateChildrenSyncRequest, D>
3623        for &BufferCollectionTokenGroupCreateChildrenSyncRequest
3624    {
3625        unsafe fn encode(
3626            self,
3627            encoder: &mut fidl::encoding::Encoder<'_, D>,
3628            offset: usize,
3629            mut depth: fidl::encoding::Depth,
3630        ) -> fidl::Result<()> {
3631            encoder
3632                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(offset);
3633            // Vector header
3634            let max_ordinal: u64 = self.max_ordinal_present();
3635            encoder.write_num(max_ordinal, offset);
3636            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3637            // Calling encoder.out_of_line_offset(0) is not allowed.
3638            if max_ordinal == 0 {
3639                return Ok(());
3640            }
3641            depth.increment()?;
3642            let envelope_size = 8;
3643            let bytes_len = max_ordinal as usize * envelope_size;
3644            #[allow(unused_variables)]
3645            let offset = encoder.out_of_line_offset(bytes_len);
3646            let mut _prev_end_offset: usize = 0;
3647            if 1 > max_ordinal {
3648                return Ok(());
3649            }
3650
3651            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3652            // are envelope_size bytes.
3653            let cur_offset: usize = (1 - 1) * envelope_size;
3654
3655            // Zero reserved fields.
3656            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3657
3658            // Safety:
3659            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3660            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3661            //   envelope_size bytes, there is always sufficient room.
3662            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::Rights, 64>, D>(
3663            self.rights_attenuation_masks.as_ref().map(<fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3664            encoder, offset + cur_offset, depth
3665        )?;
3666
3667            _prev_end_offset = cur_offset + envelope_size;
3668
3669            Ok(())
3670        }
3671    }
3672
3673    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3674        for BufferCollectionTokenGroupCreateChildrenSyncRequest
3675    {
3676        #[inline(always)]
3677        fn new_empty() -> Self {
3678            Self::default()
3679        }
3680
3681        unsafe fn decode(
3682            &mut self,
3683            decoder: &mut fidl::encoding::Decoder<'_, D>,
3684            offset: usize,
3685            mut depth: fidl::encoding::Depth,
3686        ) -> fidl::Result<()> {
3687            decoder.debug_check_bounds::<Self>(offset);
3688            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3689                None => return Err(fidl::Error::NotNullable),
3690                Some(len) => len,
3691            };
3692            // Calling decoder.out_of_line_offset(0) is not allowed.
3693            if len == 0 {
3694                return Ok(());
3695            };
3696            depth.increment()?;
3697            let envelope_size = 8;
3698            let bytes_len = len * envelope_size;
3699            let offset = decoder.out_of_line_offset(bytes_len)?;
3700            // Decode the envelope for each type.
3701            let mut _next_ordinal_to_read = 0;
3702            let mut next_offset = offset;
3703            let end_offset = offset + bytes_len;
3704            _next_ordinal_to_read += 1;
3705            if next_offset >= end_offset {
3706                return Ok(());
3707            }
3708
3709            // Decode unknown envelopes for gaps in ordinals.
3710            while _next_ordinal_to_read < 1 {
3711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3712                _next_ordinal_to_read += 1;
3713                next_offset += envelope_size;
3714            }
3715
3716            let next_out_of_line = decoder.next_out_of_line();
3717            let handles_before = decoder.remaining_handles();
3718            if let Some((inlined, num_bytes, num_handles)) =
3719                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3720            {
3721                let member_inline_size = <fidl::encoding::Vector<fidl::Rights, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3722                if inlined != (member_inline_size <= 4) {
3723                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3724                }
3725                let inner_offset;
3726                let mut inner_depth = depth.clone();
3727                if inlined {
3728                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3729                    inner_offset = next_offset;
3730                } else {
3731                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3732                    inner_depth.increment()?;
3733                }
3734                let val_ref = self.rights_attenuation_masks.get_or_insert_with(
3735                    || fidl::new_empty!(fidl::encoding::Vector<fidl::Rights, 64>, D),
3736                );
3737                fidl::decode!(fidl::encoding::Vector<fidl::Rights, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3738                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3739                {
3740                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3741                }
3742                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3743                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3744                }
3745            }
3746
3747            next_offset += envelope_size;
3748
3749            // Decode the remaining unknown envelopes.
3750            while next_offset < end_offset {
3751                _next_ordinal_to_read += 1;
3752                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3753                next_offset += envelope_size;
3754            }
3755
3756            Ok(())
3757        }
3758    }
3759
3760    impl BufferMemoryConstraints {
3761        #[inline(always)]
3762        fn max_ordinal_present(&self) -> u64 {
3763            if let Some(_) = self.min_physical_base_alignment {
3764                return 9;
3765            }
3766            if let Some(_) = self.permitted_heaps {
3767                return 8;
3768            }
3769            if let Some(_) = self.inaccessible_domain_supported {
3770                return 7;
3771            }
3772            if let Some(_) = self.ram_domain_supported {
3773                return 6;
3774            }
3775            if let Some(_) = self.cpu_domain_supported {
3776                return 5;
3777            }
3778            if let Some(_) = self.secure_required {
3779                return 4;
3780            }
3781            if let Some(_) = self.physically_contiguous_required {
3782                return 3;
3783            }
3784            if let Some(_) = self.max_size_bytes {
3785                return 2;
3786            }
3787            if let Some(_) = self.min_size_bytes {
3788                return 1;
3789            }
3790            0
3791        }
3792    }
3793
3794    impl fidl::encoding::ValueTypeMarker for BufferMemoryConstraints {
3795        type Borrowed<'a> = &'a Self;
3796        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3797            value
3798        }
3799    }
3800
3801    unsafe impl fidl::encoding::TypeMarker for BufferMemoryConstraints {
3802        type Owned = Self;
3803
3804        #[inline(always)]
3805        fn inline_align(_context: fidl::encoding::Context) -> usize {
3806            8
3807        }
3808
3809        #[inline(always)]
3810        fn inline_size(_context: fidl::encoding::Context) -> usize {
3811            16
3812        }
3813    }
3814
3815    unsafe impl<D: fidl::encoding::ResourceDialect>
3816        fidl::encoding::Encode<BufferMemoryConstraints, D> for &BufferMemoryConstraints
3817    {
3818        unsafe fn encode(
3819            self,
3820            encoder: &mut fidl::encoding::Encoder<'_, D>,
3821            offset: usize,
3822            mut depth: fidl::encoding::Depth,
3823        ) -> fidl::Result<()> {
3824            encoder.debug_check_bounds::<BufferMemoryConstraints>(offset);
3825            // Vector header
3826            let max_ordinal: u64 = self.max_ordinal_present();
3827            encoder.write_num(max_ordinal, offset);
3828            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3829            // Calling encoder.out_of_line_offset(0) is not allowed.
3830            if max_ordinal == 0 {
3831                return Ok(());
3832            }
3833            depth.increment()?;
3834            let envelope_size = 8;
3835            let bytes_len = max_ordinal as usize * envelope_size;
3836            #[allow(unused_variables)]
3837            let offset = encoder.out_of_line_offset(bytes_len);
3838            let mut _prev_end_offset: usize = 0;
3839            if 1 > max_ordinal {
3840                return Ok(());
3841            }
3842
3843            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3844            // are envelope_size bytes.
3845            let cur_offset: usize = (1 - 1) * envelope_size;
3846
3847            // Zero reserved fields.
3848            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3849
3850            // Safety:
3851            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3852            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3853            //   envelope_size bytes, there is always sufficient room.
3854            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3855                self.min_size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3856                encoder,
3857                offset + cur_offset,
3858                depth,
3859            )?;
3860
3861            _prev_end_offset = cur_offset + envelope_size;
3862            if 2 > max_ordinal {
3863                return Ok(());
3864            }
3865
3866            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3867            // are envelope_size bytes.
3868            let cur_offset: usize = (2 - 1) * envelope_size;
3869
3870            // Zero reserved fields.
3871            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3872
3873            // Safety:
3874            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3875            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3876            //   envelope_size bytes, there is always sufficient room.
3877            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3878                self.max_size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3879                encoder,
3880                offset + cur_offset,
3881                depth,
3882            )?;
3883
3884            _prev_end_offset = cur_offset + envelope_size;
3885            if 3 > max_ordinal {
3886                return Ok(());
3887            }
3888
3889            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3890            // are envelope_size bytes.
3891            let cur_offset: usize = (3 - 1) * envelope_size;
3892
3893            // Zero reserved fields.
3894            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3895
3896            // Safety:
3897            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3898            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3899            //   envelope_size bytes, there is always sufficient room.
3900            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3901                self.physically_contiguous_required
3902                    .as_ref()
3903                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3904                encoder,
3905                offset + cur_offset,
3906                depth,
3907            )?;
3908
3909            _prev_end_offset = cur_offset + envelope_size;
3910            if 4 > max_ordinal {
3911                return Ok(());
3912            }
3913
3914            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3915            // are envelope_size bytes.
3916            let cur_offset: usize = (4 - 1) * envelope_size;
3917
3918            // Zero reserved fields.
3919            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3920
3921            // Safety:
3922            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3923            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3924            //   envelope_size bytes, there is always sufficient room.
3925            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3926                self.secure_required
3927                    .as_ref()
3928                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3929                encoder,
3930                offset + cur_offset,
3931                depth,
3932            )?;
3933
3934            _prev_end_offset = cur_offset + envelope_size;
3935            if 5 > max_ordinal {
3936                return Ok(());
3937            }
3938
3939            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3940            // are envelope_size bytes.
3941            let cur_offset: usize = (5 - 1) * envelope_size;
3942
3943            // Zero reserved fields.
3944            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3945
3946            // Safety:
3947            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3948            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3949            //   envelope_size bytes, there is always sufficient room.
3950            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3951                self.cpu_domain_supported
3952                    .as_ref()
3953                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3954                encoder,
3955                offset + cur_offset,
3956                depth,
3957            )?;
3958
3959            _prev_end_offset = cur_offset + envelope_size;
3960            if 6 > max_ordinal {
3961                return Ok(());
3962            }
3963
3964            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3965            // are envelope_size bytes.
3966            let cur_offset: usize = (6 - 1) * envelope_size;
3967
3968            // Zero reserved fields.
3969            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3970
3971            // Safety:
3972            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3973            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3974            //   envelope_size bytes, there is always sufficient room.
3975            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3976                self.ram_domain_supported
3977                    .as_ref()
3978                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3979                encoder,
3980                offset + cur_offset,
3981                depth,
3982            )?;
3983
3984            _prev_end_offset = cur_offset + envelope_size;
3985            if 7 > max_ordinal {
3986                return Ok(());
3987            }
3988
3989            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3990            // are envelope_size bytes.
3991            let cur_offset: usize = (7 - 1) * envelope_size;
3992
3993            // Zero reserved fields.
3994            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3995
3996            // Safety:
3997            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3998            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3999            //   envelope_size bytes, there is always sufficient room.
4000            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4001                self.inaccessible_domain_supported
4002                    .as_ref()
4003                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4004                encoder,
4005                offset + cur_offset,
4006                depth,
4007            )?;
4008
4009            _prev_end_offset = cur_offset + envelope_size;
4010            if 8 > max_ordinal {
4011                return Ok(());
4012            }
4013
4014            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4015            // are envelope_size bytes.
4016            let cur_offset: usize = (8 - 1) * envelope_size;
4017
4018            // Zero reserved fields.
4019            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4020
4021            // Safety:
4022            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4023            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4024            //   envelope_size bytes, there is always sufficient room.
4025            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Heap, 64>, D>(
4026                self.permitted_heaps.as_ref().map(
4027                    <fidl::encoding::Vector<Heap, 64> as fidl::encoding::ValueTypeMarker>::borrow,
4028                ),
4029                encoder,
4030                offset + cur_offset,
4031                depth,
4032            )?;
4033
4034            _prev_end_offset = cur_offset + envelope_size;
4035            if 9 > max_ordinal {
4036                return Ok(());
4037            }
4038
4039            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4040            // are envelope_size bytes.
4041            let cur_offset: usize = (9 - 1) * envelope_size;
4042
4043            // Zero reserved fields.
4044            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4045
4046            // Safety:
4047            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4048            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4049            //   envelope_size bytes, there is always sufficient room.
4050            fidl::encoding::encode_in_envelope_optional::<u64, D>(
4051                self.min_physical_base_alignment
4052                    .as_ref()
4053                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4054                encoder,
4055                offset + cur_offset,
4056                depth,
4057            )?;
4058
4059            _prev_end_offset = cur_offset + envelope_size;
4060
4061            Ok(())
4062        }
4063    }
4064
4065    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4066        for BufferMemoryConstraints
4067    {
4068        #[inline(always)]
4069        fn new_empty() -> Self {
4070            Self::default()
4071        }
4072
4073        unsafe fn decode(
4074            &mut self,
4075            decoder: &mut fidl::encoding::Decoder<'_, D>,
4076            offset: usize,
4077            mut depth: fidl::encoding::Depth,
4078        ) -> fidl::Result<()> {
4079            decoder.debug_check_bounds::<Self>(offset);
4080            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4081                None => return Err(fidl::Error::NotNullable),
4082                Some(len) => len,
4083            };
4084            // Calling decoder.out_of_line_offset(0) is not allowed.
4085            if len == 0 {
4086                return Ok(());
4087            };
4088            depth.increment()?;
4089            let envelope_size = 8;
4090            let bytes_len = len * envelope_size;
4091            let offset = decoder.out_of_line_offset(bytes_len)?;
4092            // Decode the envelope for each type.
4093            let mut _next_ordinal_to_read = 0;
4094            let mut next_offset = offset;
4095            let end_offset = offset + bytes_len;
4096            _next_ordinal_to_read += 1;
4097            if next_offset >= end_offset {
4098                return Ok(());
4099            }
4100
4101            // Decode unknown envelopes for gaps in ordinals.
4102            while _next_ordinal_to_read < 1 {
4103                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4104                _next_ordinal_to_read += 1;
4105                next_offset += envelope_size;
4106            }
4107
4108            let next_out_of_line = decoder.next_out_of_line();
4109            let handles_before = decoder.remaining_handles();
4110            if let Some((inlined, num_bytes, num_handles)) =
4111                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4112            {
4113                let member_inline_size =
4114                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4115                if inlined != (member_inline_size <= 4) {
4116                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4117                }
4118                let inner_offset;
4119                let mut inner_depth = depth.clone();
4120                if inlined {
4121                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4122                    inner_offset = next_offset;
4123                } else {
4124                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4125                    inner_depth.increment()?;
4126                }
4127                let val_ref = self.min_size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4128                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4129                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4130                {
4131                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4132                }
4133                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4134                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4135                }
4136            }
4137
4138            next_offset += envelope_size;
4139            _next_ordinal_to_read += 1;
4140            if next_offset >= end_offset {
4141                return Ok(());
4142            }
4143
4144            // Decode unknown envelopes for gaps in ordinals.
4145            while _next_ordinal_to_read < 2 {
4146                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4147                _next_ordinal_to_read += 1;
4148                next_offset += envelope_size;
4149            }
4150
4151            let next_out_of_line = decoder.next_out_of_line();
4152            let handles_before = decoder.remaining_handles();
4153            if let Some((inlined, num_bytes, num_handles)) =
4154                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4155            {
4156                let member_inline_size =
4157                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4158                if inlined != (member_inline_size <= 4) {
4159                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4160                }
4161                let inner_offset;
4162                let mut inner_depth = depth.clone();
4163                if inlined {
4164                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4165                    inner_offset = next_offset;
4166                } else {
4167                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4168                    inner_depth.increment()?;
4169                }
4170                let val_ref = self.max_size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4171                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4172                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4173                {
4174                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4175                }
4176                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4177                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4178                }
4179            }
4180
4181            next_offset += envelope_size;
4182            _next_ordinal_to_read += 1;
4183            if next_offset >= end_offset {
4184                return Ok(());
4185            }
4186
4187            // Decode unknown envelopes for gaps in ordinals.
4188            while _next_ordinal_to_read < 3 {
4189                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4190                _next_ordinal_to_read += 1;
4191                next_offset += envelope_size;
4192            }
4193
4194            let next_out_of_line = decoder.next_out_of_line();
4195            let handles_before = decoder.remaining_handles();
4196            if let Some((inlined, num_bytes, num_handles)) =
4197                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4198            {
4199                let member_inline_size =
4200                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4201                if inlined != (member_inline_size <= 4) {
4202                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4203                }
4204                let inner_offset;
4205                let mut inner_depth = depth.clone();
4206                if inlined {
4207                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4208                    inner_offset = next_offset;
4209                } else {
4210                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4211                    inner_depth.increment()?;
4212                }
4213                let val_ref = self
4214                    .physically_contiguous_required
4215                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
4216                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4217                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4218                {
4219                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4220                }
4221                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4222                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4223                }
4224            }
4225
4226            next_offset += envelope_size;
4227            _next_ordinal_to_read += 1;
4228            if next_offset >= end_offset {
4229                return Ok(());
4230            }
4231
4232            // Decode unknown envelopes for gaps in ordinals.
4233            while _next_ordinal_to_read < 4 {
4234                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4235                _next_ordinal_to_read += 1;
4236                next_offset += envelope_size;
4237            }
4238
4239            let next_out_of_line = decoder.next_out_of_line();
4240            let handles_before = decoder.remaining_handles();
4241            if let Some((inlined, num_bytes, num_handles)) =
4242                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4243            {
4244                let member_inline_size =
4245                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4246                if inlined != (member_inline_size <= 4) {
4247                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4248                }
4249                let inner_offset;
4250                let mut inner_depth = depth.clone();
4251                if inlined {
4252                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4253                    inner_offset = next_offset;
4254                } else {
4255                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4256                    inner_depth.increment()?;
4257                }
4258                let val_ref = self.secure_required.get_or_insert_with(|| fidl::new_empty!(bool, D));
4259                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4260                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4261                {
4262                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4263                }
4264                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4265                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4266                }
4267            }
4268
4269            next_offset += envelope_size;
4270            _next_ordinal_to_read += 1;
4271            if next_offset >= end_offset {
4272                return Ok(());
4273            }
4274
4275            // Decode unknown envelopes for gaps in ordinals.
4276            while _next_ordinal_to_read < 5 {
4277                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4278                _next_ordinal_to_read += 1;
4279                next_offset += envelope_size;
4280            }
4281
4282            let next_out_of_line = decoder.next_out_of_line();
4283            let handles_before = decoder.remaining_handles();
4284            if let Some((inlined, num_bytes, num_handles)) =
4285                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4286            {
4287                let member_inline_size =
4288                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4289                if inlined != (member_inline_size <= 4) {
4290                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4291                }
4292                let inner_offset;
4293                let mut inner_depth = depth.clone();
4294                if inlined {
4295                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4296                    inner_offset = next_offset;
4297                } else {
4298                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4299                    inner_depth.increment()?;
4300                }
4301                let val_ref =
4302                    self.cpu_domain_supported.get_or_insert_with(|| fidl::new_empty!(bool, D));
4303                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4304                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4305                {
4306                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4307                }
4308                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4309                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4310                }
4311            }
4312
4313            next_offset += envelope_size;
4314            _next_ordinal_to_read += 1;
4315            if next_offset >= end_offset {
4316                return Ok(());
4317            }
4318
4319            // Decode unknown envelopes for gaps in ordinals.
4320            while _next_ordinal_to_read < 6 {
4321                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4322                _next_ordinal_to_read += 1;
4323                next_offset += envelope_size;
4324            }
4325
4326            let next_out_of_line = decoder.next_out_of_line();
4327            let handles_before = decoder.remaining_handles();
4328            if let Some((inlined, num_bytes, num_handles)) =
4329                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4330            {
4331                let member_inline_size =
4332                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4333                if inlined != (member_inline_size <= 4) {
4334                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4335                }
4336                let inner_offset;
4337                let mut inner_depth = depth.clone();
4338                if inlined {
4339                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4340                    inner_offset = next_offset;
4341                } else {
4342                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4343                    inner_depth.increment()?;
4344                }
4345                let val_ref =
4346                    self.ram_domain_supported.get_or_insert_with(|| fidl::new_empty!(bool, D));
4347                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4348                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4349                {
4350                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4351                }
4352                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4353                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4354                }
4355            }
4356
4357            next_offset += envelope_size;
4358            _next_ordinal_to_read += 1;
4359            if next_offset >= end_offset {
4360                return Ok(());
4361            }
4362
4363            // Decode unknown envelopes for gaps in ordinals.
4364            while _next_ordinal_to_read < 7 {
4365                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4366                _next_ordinal_to_read += 1;
4367                next_offset += envelope_size;
4368            }
4369
4370            let next_out_of_line = decoder.next_out_of_line();
4371            let handles_before = decoder.remaining_handles();
4372            if let Some((inlined, num_bytes, num_handles)) =
4373                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4374            {
4375                let member_inline_size =
4376                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4377                if inlined != (member_inline_size <= 4) {
4378                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4379                }
4380                let inner_offset;
4381                let mut inner_depth = depth.clone();
4382                if inlined {
4383                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4384                    inner_offset = next_offset;
4385                } else {
4386                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4387                    inner_depth.increment()?;
4388                }
4389                let val_ref = self
4390                    .inaccessible_domain_supported
4391                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
4392                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4393                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4394                {
4395                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4396                }
4397                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4398                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4399                }
4400            }
4401
4402            next_offset += envelope_size;
4403            _next_ordinal_to_read += 1;
4404            if next_offset >= end_offset {
4405                return Ok(());
4406            }
4407
4408            // Decode unknown envelopes for gaps in ordinals.
4409            while _next_ordinal_to_read < 8 {
4410                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4411                _next_ordinal_to_read += 1;
4412                next_offset += envelope_size;
4413            }
4414
4415            let next_out_of_line = decoder.next_out_of_line();
4416            let handles_before = decoder.remaining_handles();
4417            if let Some((inlined, num_bytes, num_handles)) =
4418                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4419            {
4420                let member_inline_size =
4421                    <fidl::encoding::Vector<Heap, 64> as fidl::encoding::TypeMarker>::inline_size(
4422                        decoder.context,
4423                    );
4424                if inlined != (member_inline_size <= 4) {
4425                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4426                }
4427                let inner_offset;
4428                let mut inner_depth = depth.clone();
4429                if inlined {
4430                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4431                    inner_offset = next_offset;
4432                } else {
4433                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4434                    inner_depth.increment()?;
4435                }
4436                let val_ref = self
4437                    .permitted_heaps
4438                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Heap, 64>, D));
4439                fidl::decode!(fidl::encoding::Vector<Heap, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
4440                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4441                {
4442                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4443                }
4444                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4445                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4446                }
4447            }
4448
4449            next_offset += envelope_size;
4450            _next_ordinal_to_read += 1;
4451            if next_offset >= end_offset {
4452                return Ok(());
4453            }
4454
4455            // Decode unknown envelopes for gaps in ordinals.
4456            while _next_ordinal_to_read < 9 {
4457                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4458                _next_ordinal_to_read += 1;
4459                next_offset += envelope_size;
4460            }
4461
4462            let next_out_of_line = decoder.next_out_of_line();
4463            let handles_before = decoder.remaining_handles();
4464            if let Some((inlined, num_bytes, num_handles)) =
4465                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4466            {
4467                let member_inline_size =
4468                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4469                if inlined != (member_inline_size <= 4) {
4470                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4471                }
4472                let inner_offset;
4473                let mut inner_depth = depth.clone();
4474                if inlined {
4475                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4476                    inner_offset = next_offset;
4477                } else {
4478                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4479                    inner_depth.increment()?;
4480                }
4481                let val_ref = self
4482                    .min_physical_base_alignment
4483                    .get_or_insert_with(|| fidl::new_empty!(u64, D));
4484                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4485                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4486                {
4487                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4488                }
4489                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4490                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4491                }
4492            }
4493
4494            next_offset += envelope_size;
4495
4496            // Decode the remaining unknown envelopes.
4497            while next_offset < end_offset {
4498                _next_ordinal_to_read += 1;
4499                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4500                next_offset += envelope_size;
4501            }
4502
4503            Ok(())
4504        }
4505    }
4506
4507    impl BufferMemorySettings {
4508        #[inline(always)]
4509        fn max_ordinal_present(&self) -> u64 {
4510            if let Some(_) = self.raw_vmo_size {
4511                return 6;
4512            }
4513            if let Some(_) = self.heap {
4514                return 5;
4515            }
4516            if let Some(_) = self.coherency_domain {
4517                return 4;
4518            }
4519            if let Some(_) = self.is_secure {
4520                return 3;
4521            }
4522            if let Some(_) = self.is_physically_contiguous {
4523                return 2;
4524            }
4525            if let Some(_) = self.size_bytes {
4526                return 1;
4527            }
4528            0
4529        }
4530    }
4531
4532    impl fidl::encoding::ValueTypeMarker for BufferMemorySettings {
4533        type Borrowed<'a> = &'a Self;
4534        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4535            value
4536        }
4537    }
4538
4539    unsafe impl fidl::encoding::TypeMarker for BufferMemorySettings {
4540        type Owned = Self;
4541
4542        #[inline(always)]
4543        fn inline_align(_context: fidl::encoding::Context) -> usize {
4544            8
4545        }
4546
4547        #[inline(always)]
4548        fn inline_size(_context: fidl::encoding::Context) -> usize {
4549            16
4550        }
4551    }
4552
4553    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BufferMemorySettings, D>
4554        for &BufferMemorySettings
4555    {
4556        unsafe fn encode(
4557            self,
4558            encoder: &mut fidl::encoding::Encoder<'_, D>,
4559            offset: usize,
4560            mut depth: fidl::encoding::Depth,
4561        ) -> fidl::Result<()> {
4562            encoder.debug_check_bounds::<BufferMemorySettings>(offset);
4563            // Vector header
4564            let max_ordinal: u64 = self.max_ordinal_present();
4565            encoder.write_num(max_ordinal, offset);
4566            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4567            // Calling encoder.out_of_line_offset(0) is not allowed.
4568            if max_ordinal == 0 {
4569                return Ok(());
4570            }
4571            depth.increment()?;
4572            let envelope_size = 8;
4573            let bytes_len = max_ordinal as usize * envelope_size;
4574            #[allow(unused_variables)]
4575            let offset = encoder.out_of_line_offset(bytes_len);
4576            let mut _prev_end_offset: usize = 0;
4577            if 1 > max_ordinal {
4578                return Ok(());
4579            }
4580
4581            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4582            // are envelope_size bytes.
4583            let cur_offset: usize = (1 - 1) * envelope_size;
4584
4585            // Zero reserved fields.
4586            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4587
4588            // Safety:
4589            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4590            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4591            //   envelope_size bytes, there is always sufficient room.
4592            fidl::encoding::encode_in_envelope_optional::<u64, D>(
4593                self.size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4594                encoder,
4595                offset + cur_offset,
4596                depth,
4597            )?;
4598
4599            _prev_end_offset = cur_offset + envelope_size;
4600            if 2 > max_ordinal {
4601                return Ok(());
4602            }
4603
4604            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4605            // are envelope_size bytes.
4606            let cur_offset: usize = (2 - 1) * envelope_size;
4607
4608            // Zero reserved fields.
4609            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4610
4611            // Safety:
4612            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4613            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4614            //   envelope_size bytes, there is always sufficient room.
4615            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4616                self.is_physically_contiguous
4617                    .as_ref()
4618                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4619                encoder,
4620                offset + cur_offset,
4621                depth,
4622            )?;
4623
4624            _prev_end_offset = cur_offset + envelope_size;
4625            if 3 > max_ordinal {
4626                return Ok(());
4627            }
4628
4629            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4630            // are envelope_size bytes.
4631            let cur_offset: usize = (3 - 1) * envelope_size;
4632
4633            // Zero reserved fields.
4634            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4635
4636            // Safety:
4637            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4638            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4639            //   envelope_size bytes, there is always sufficient room.
4640            fidl::encoding::encode_in_envelope_optional::<bool, D>(
4641                self.is_secure.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4642                encoder,
4643                offset + cur_offset,
4644                depth,
4645            )?;
4646
4647            _prev_end_offset = cur_offset + envelope_size;
4648            if 4 > max_ordinal {
4649                return Ok(());
4650            }
4651
4652            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4653            // are envelope_size bytes.
4654            let cur_offset: usize = (4 - 1) * envelope_size;
4655
4656            // Zero reserved fields.
4657            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4658
4659            // Safety:
4660            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4661            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4662            //   envelope_size bytes, there is always sufficient room.
4663            fidl::encoding::encode_in_envelope_optional::<CoherencyDomain, D>(
4664                self.coherency_domain
4665                    .as_ref()
4666                    .map(<CoherencyDomain as fidl::encoding::ValueTypeMarker>::borrow),
4667                encoder,
4668                offset + cur_offset,
4669                depth,
4670            )?;
4671
4672            _prev_end_offset = cur_offset + envelope_size;
4673            if 5 > max_ordinal {
4674                return Ok(());
4675            }
4676
4677            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4678            // are envelope_size bytes.
4679            let cur_offset: usize = (5 - 1) * envelope_size;
4680
4681            // Zero reserved fields.
4682            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4683
4684            // Safety:
4685            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4686            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4687            //   envelope_size bytes, there is always sufficient room.
4688            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
4689                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
4690                encoder,
4691                offset + cur_offset,
4692                depth,
4693            )?;
4694
4695            _prev_end_offset = cur_offset + envelope_size;
4696            if 6 > max_ordinal {
4697                return Ok(());
4698            }
4699
4700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4701            // are envelope_size bytes.
4702            let cur_offset: usize = (6 - 1) * envelope_size;
4703
4704            // Zero reserved fields.
4705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4706
4707            // Safety:
4708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4710            //   envelope_size bytes, there is always sufficient room.
4711            fidl::encoding::encode_in_envelope_optional::<u64, D>(
4712                self.raw_vmo_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4713                encoder,
4714                offset + cur_offset,
4715                depth,
4716            )?;
4717
4718            _prev_end_offset = cur_offset + envelope_size;
4719
4720            Ok(())
4721        }
4722    }
4723
4724    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferMemorySettings {
4725        #[inline(always)]
4726        fn new_empty() -> Self {
4727            Self::default()
4728        }
4729
4730        unsafe fn decode(
4731            &mut self,
4732            decoder: &mut fidl::encoding::Decoder<'_, D>,
4733            offset: usize,
4734            mut depth: fidl::encoding::Depth,
4735        ) -> fidl::Result<()> {
4736            decoder.debug_check_bounds::<Self>(offset);
4737            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4738                None => return Err(fidl::Error::NotNullable),
4739                Some(len) => len,
4740            };
4741            // Calling decoder.out_of_line_offset(0) is not allowed.
4742            if len == 0 {
4743                return Ok(());
4744            };
4745            depth.increment()?;
4746            let envelope_size = 8;
4747            let bytes_len = len * envelope_size;
4748            let offset = decoder.out_of_line_offset(bytes_len)?;
4749            // Decode the envelope for each type.
4750            let mut _next_ordinal_to_read = 0;
4751            let mut next_offset = offset;
4752            let end_offset = offset + bytes_len;
4753            _next_ordinal_to_read += 1;
4754            if next_offset >= end_offset {
4755                return Ok(());
4756            }
4757
4758            // Decode unknown envelopes for gaps in ordinals.
4759            while _next_ordinal_to_read < 1 {
4760                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4761                _next_ordinal_to_read += 1;
4762                next_offset += envelope_size;
4763            }
4764
4765            let next_out_of_line = decoder.next_out_of_line();
4766            let handles_before = decoder.remaining_handles();
4767            if let Some((inlined, num_bytes, num_handles)) =
4768                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4769            {
4770                let member_inline_size =
4771                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4772                if inlined != (member_inline_size <= 4) {
4773                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4774                }
4775                let inner_offset;
4776                let mut inner_depth = depth.clone();
4777                if inlined {
4778                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4779                    inner_offset = next_offset;
4780                } else {
4781                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4782                    inner_depth.increment()?;
4783                }
4784                let val_ref = self.size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
4785                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
4786                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4787                {
4788                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4789                }
4790                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4791                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4792                }
4793            }
4794
4795            next_offset += envelope_size;
4796            _next_ordinal_to_read += 1;
4797            if next_offset >= end_offset {
4798                return Ok(());
4799            }
4800
4801            // Decode unknown envelopes for gaps in ordinals.
4802            while _next_ordinal_to_read < 2 {
4803                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4804                _next_ordinal_to_read += 1;
4805                next_offset += envelope_size;
4806            }
4807
4808            let next_out_of_line = decoder.next_out_of_line();
4809            let handles_before = decoder.remaining_handles();
4810            if let Some((inlined, num_bytes, num_handles)) =
4811                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4812            {
4813                let member_inline_size =
4814                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4815                if inlined != (member_inline_size <= 4) {
4816                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4817                }
4818                let inner_offset;
4819                let mut inner_depth = depth.clone();
4820                if inlined {
4821                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4822                    inner_offset = next_offset;
4823                } else {
4824                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4825                    inner_depth.increment()?;
4826                }
4827                let val_ref =
4828                    self.is_physically_contiguous.get_or_insert_with(|| fidl::new_empty!(bool, D));
4829                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4830                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4831                {
4832                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4833                }
4834                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4835                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4836                }
4837            }
4838
4839            next_offset += envelope_size;
4840            _next_ordinal_to_read += 1;
4841            if next_offset >= end_offset {
4842                return Ok(());
4843            }
4844
4845            // Decode unknown envelopes for gaps in ordinals.
4846            while _next_ordinal_to_read < 3 {
4847                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4848                _next_ordinal_to_read += 1;
4849                next_offset += envelope_size;
4850            }
4851
4852            let next_out_of_line = decoder.next_out_of_line();
4853            let handles_before = decoder.remaining_handles();
4854            if let Some((inlined, num_bytes, num_handles)) =
4855                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4856            {
4857                let member_inline_size =
4858                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4859                if inlined != (member_inline_size <= 4) {
4860                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4861                }
4862                let inner_offset;
4863                let mut inner_depth = depth.clone();
4864                if inlined {
4865                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4866                    inner_offset = next_offset;
4867                } else {
4868                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4869                    inner_depth.increment()?;
4870                }
4871                let val_ref = self.is_secure.get_or_insert_with(|| fidl::new_empty!(bool, D));
4872                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
4873                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4874                {
4875                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4876                }
4877                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4878                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4879                }
4880            }
4881
4882            next_offset += envelope_size;
4883            _next_ordinal_to_read += 1;
4884            if next_offset >= end_offset {
4885                return Ok(());
4886            }
4887
4888            // Decode unknown envelopes for gaps in ordinals.
4889            while _next_ordinal_to_read < 4 {
4890                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4891                _next_ordinal_to_read += 1;
4892                next_offset += envelope_size;
4893            }
4894
4895            let next_out_of_line = decoder.next_out_of_line();
4896            let handles_before = decoder.remaining_handles();
4897            if let Some((inlined, num_bytes, num_handles)) =
4898                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4899            {
4900                let member_inline_size =
4901                    <CoherencyDomain as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4902                if inlined != (member_inline_size <= 4) {
4903                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4904                }
4905                let inner_offset;
4906                let mut inner_depth = depth.clone();
4907                if inlined {
4908                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4909                    inner_offset = next_offset;
4910                } else {
4911                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4912                    inner_depth.increment()?;
4913                }
4914                let val_ref = self
4915                    .coherency_domain
4916                    .get_or_insert_with(|| fidl::new_empty!(CoherencyDomain, D));
4917                fidl::decode!(CoherencyDomain, D, val_ref, decoder, inner_offset, inner_depth)?;
4918                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4919                {
4920                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4921                }
4922                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4923                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4924                }
4925            }
4926
4927            next_offset += envelope_size;
4928            _next_ordinal_to_read += 1;
4929            if next_offset >= end_offset {
4930                return Ok(());
4931            }
4932
4933            // Decode unknown envelopes for gaps in ordinals.
4934            while _next_ordinal_to_read < 5 {
4935                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4936                _next_ordinal_to_read += 1;
4937                next_offset += envelope_size;
4938            }
4939
4940            let next_out_of_line = decoder.next_out_of_line();
4941            let handles_before = decoder.remaining_handles();
4942            if let Some((inlined, num_bytes, num_handles)) =
4943                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4944            {
4945                let member_inline_size =
4946                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4947                if inlined != (member_inline_size <= 4) {
4948                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4949                }
4950                let inner_offset;
4951                let mut inner_depth = depth.clone();
4952                if inlined {
4953                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4954                    inner_offset = next_offset;
4955                } else {
4956                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4957                    inner_depth.increment()?;
4958                }
4959                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
4960                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
4961                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4962                {
4963                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4964                }
4965                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4966                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4967                }
4968            }
4969
4970            next_offset += envelope_size;
4971            _next_ordinal_to_read += 1;
4972            if next_offset >= end_offset {
4973                return Ok(());
4974            }
4975
4976            // Decode unknown envelopes for gaps in ordinals.
4977            while _next_ordinal_to_read < 6 {
4978                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4979                _next_ordinal_to_read += 1;
4980                next_offset += envelope_size;
4981            }
4982
4983            let next_out_of_line = decoder.next_out_of_line();
4984            let handles_before = decoder.remaining_handles();
4985            if let Some((inlined, num_bytes, num_handles)) =
4986                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4987            {
4988                let member_inline_size =
4989                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4990                if inlined != (member_inline_size <= 4) {
4991                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4992                }
4993                let inner_offset;
4994                let mut inner_depth = depth.clone();
4995                if inlined {
4996                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4997                    inner_offset = next_offset;
4998                } else {
4999                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5000                    inner_depth.increment()?;
5001                }
5002                let val_ref = self.raw_vmo_size.get_or_insert_with(|| fidl::new_empty!(u64, D));
5003                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
5004                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5005                {
5006                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5007                }
5008                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5009                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5010                }
5011            }
5012
5013            next_offset += envelope_size;
5014
5015            // Decode the remaining unknown envelopes.
5016            while next_offset < end_offset {
5017                _next_ordinal_to_read += 1;
5018                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5019                next_offset += envelope_size;
5020            }
5021
5022            Ok(())
5023        }
5024    }
5025
5026    impl BufferUsage {
5027        #[inline(always)]
5028        fn max_ordinal_present(&self) -> u64 {
5029            if let Some(_) = self.video {
5030                return 5;
5031            }
5032            if let Some(_) = self.display {
5033                return 4;
5034            }
5035            if let Some(_) = self.vulkan {
5036                return 3;
5037            }
5038            if let Some(_) = self.cpu {
5039                return 2;
5040            }
5041            if let Some(_) = self.none {
5042                return 1;
5043            }
5044            0
5045        }
5046    }
5047
5048    impl fidl::encoding::ValueTypeMarker for BufferUsage {
5049        type Borrowed<'a> = &'a Self;
5050        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5051            value
5052        }
5053    }
5054
5055    unsafe impl fidl::encoding::TypeMarker for BufferUsage {
5056        type Owned = Self;
5057
5058        #[inline(always)]
5059        fn inline_align(_context: fidl::encoding::Context) -> usize {
5060            8
5061        }
5062
5063        #[inline(always)]
5064        fn inline_size(_context: fidl::encoding::Context) -> usize {
5065            16
5066        }
5067    }
5068
5069    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BufferUsage, D>
5070        for &BufferUsage
5071    {
5072        unsafe fn encode(
5073            self,
5074            encoder: &mut fidl::encoding::Encoder<'_, D>,
5075            offset: usize,
5076            mut depth: fidl::encoding::Depth,
5077        ) -> fidl::Result<()> {
5078            encoder.debug_check_bounds::<BufferUsage>(offset);
5079            // Vector header
5080            let max_ordinal: u64 = self.max_ordinal_present();
5081            encoder.write_num(max_ordinal, offset);
5082            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5083            // Calling encoder.out_of_line_offset(0) is not allowed.
5084            if max_ordinal == 0 {
5085                return Ok(());
5086            }
5087            depth.increment()?;
5088            let envelope_size = 8;
5089            let bytes_len = max_ordinal as usize * envelope_size;
5090            #[allow(unused_variables)]
5091            let offset = encoder.out_of_line_offset(bytes_len);
5092            let mut _prev_end_offset: usize = 0;
5093            if 1 > max_ordinal {
5094                return Ok(());
5095            }
5096
5097            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5098            // are envelope_size bytes.
5099            let cur_offset: usize = (1 - 1) * envelope_size;
5100
5101            // Zero reserved fields.
5102            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5103
5104            // Safety:
5105            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5106            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5107            //   envelope_size bytes, there is always sufficient room.
5108            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5109                self.none.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5110                encoder,
5111                offset + cur_offset,
5112                depth,
5113            )?;
5114
5115            _prev_end_offset = cur_offset + envelope_size;
5116            if 2 > max_ordinal {
5117                return Ok(());
5118            }
5119
5120            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5121            // are envelope_size bytes.
5122            let cur_offset: usize = (2 - 1) * envelope_size;
5123
5124            // Zero reserved fields.
5125            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5126
5127            // Safety:
5128            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5129            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5130            //   envelope_size bytes, there is always sufficient room.
5131            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5132                self.cpu.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5133                encoder,
5134                offset + cur_offset,
5135                depth,
5136            )?;
5137
5138            _prev_end_offset = cur_offset + envelope_size;
5139            if 3 > max_ordinal {
5140                return Ok(());
5141            }
5142
5143            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5144            // are envelope_size bytes.
5145            let cur_offset: usize = (3 - 1) * envelope_size;
5146
5147            // Zero reserved fields.
5148            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5149
5150            // Safety:
5151            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5152            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5153            //   envelope_size bytes, there is always sufficient room.
5154            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5155                self.vulkan.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5156                encoder,
5157                offset + cur_offset,
5158                depth,
5159            )?;
5160
5161            _prev_end_offset = cur_offset + envelope_size;
5162            if 4 > max_ordinal {
5163                return Ok(());
5164            }
5165
5166            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5167            // are envelope_size bytes.
5168            let cur_offset: usize = (4 - 1) * envelope_size;
5169
5170            // Zero reserved fields.
5171            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5172
5173            // Safety:
5174            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5175            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5176            //   envelope_size bytes, there is always sufficient room.
5177            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5178                self.display.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5179                encoder,
5180                offset + cur_offset,
5181                depth,
5182            )?;
5183
5184            _prev_end_offset = cur_offset + envelope_size;
5185            if 5 > max_ordinal {
5186                return Ok(());
5187            }
5188
5189            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5190            // are envelope_size bytes.
5191            let cur_offset: usize = (5 - 1) * envelope_size;
5192
5193            // Zero reserved fields.
5194            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5195
5196            // Safety:
5197            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5198            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5199            //   envelope_size bytes, there is always sufficient room.
5200            fidl::encoding::encode_in_envelope_optional::<u32, D>(
5201                self.video.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
5202                encoder,
5203                offset + cur_offset,
5204                depth,
5205            )?;
5206
5207            _prev_end_offset = cur_offset + envelope_size;
5208
5209            Ok(())
5210        }
5211    }
5212
5213    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferUsage {
5214        #[inline(always)]
5215        fn new_empty() -> Self {
5216            Self::default()
5217        }
5218
5219        unsafe fn decode(
5220            &mut self,
5221            decoder: &mut fidl::encoding::Decoder<'_, D>,
5222            offset: usize,
5223            mut depth: fidl::encoding::Depth,
5224        ) -> fidl::Result<()> {
5225            decoder.debug_check_bounds::<Self>(offset);
5226            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5227                None => return Err(fidl::Error::NotNullable),
5228                Some(len) => len,
5229            };
5230            // Calling decoder.out_of_line_offset(0) is not allowed.
5231            if len == 0 {
5232                return Ok(());
5233            };
5234            depth.increment()?;
5235            let envelope_size = 8;
5236            let bytes_len = len * envelope_size;
5237            let offset = decoder.out_of_line_offset(bytes_len)?;
5238            // Decode the envelope for each type.
5239            let mut _next_ordinal_to_read = 0;
5240            let mut next_offset = offset;
5241            let end_offset = offset + bytes_len;
5242            _next_ordinal_to_read += 1;
5243            if next_offset >= end_offset {
5244                return Ok(());
5245            }
5246
5247            // Decode unknown envelopes for gaps in ordinals.
5248            while _next_ordinal_to_read < 1 {
5249                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5250                _next_ordinal_to_read += 1;
5251                next_offset += envelope_size;
5252            }
5253
5254            let next_out_of_line = decoder.next_out_of_line();
5255            let handles_before = decoder.remaining_handles();
5256            if let Some((inlined, num_bytes, num_handles)) =
5257                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5258            {
5259                let member_inline_size =
5260                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5261                if inlined != (member_inline_size <= 4) {
5262                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5263                }
5264                let inner_offset;
5265                let mut inner_depth = depth.clone();
5266                if inlined {
5267                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5268                    inner_offset = next_offset;
5269                } else {
5270                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5271                    inner_depth.increment()?;
5272                }
5273                let val_ref = self.none.get_or_insert_with(|| fidl::new_empty!(u32, D));
5274                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5275                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5276                {
5277                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5278                }
5279                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5280                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5281                }
5282            }
5283
5284            next_offset += envelope_size;
5285            _next_ordinal_to_read += 1;
5286            if next_offset >= end_offset {
5287                return Ok(());
5288            }
5289
5290            // Decode unknown envelopes for gaps in ordinals.
5291            while _next_ordinal_to_read < 2 {
5292                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5293                _next_ordinal_to_read += 1;
5294                next_offset += envelope_size;
5295            }
5296
5297            let next_out_of_line = decoder.next_out_of_line();
5298            let handles_before = decoder.remaining_handles();
5299            if let Some((inlined, num_bytes, num_handles)) =
5300                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5301            {
5302                let member_inline_size =
5303                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5304                if inlined != (member_inline_size <= 4) {
5305                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5306                }
5307                let inner_offset;
5308                let mut inner_depth = depth.clone();
5309                if inlined {
5310                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5311                    inner_offset = next_offset;
5312                } else {
5313                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5314                    inner_depth.increment()?;
5315                }
5316                let val_ref = self.cpu.get_or_insert_with(|| fidl::new_empty!(u32, D));
5317                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5318                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5319                {
5320                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5321                }
5322                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5323                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5324                }
5325            }
5326
5327            next_offset += envelope_size;
5328            _next_ordinal_to_read += 1;
5329            if next_offset >= end_offset {
5330                return Ok(());
5331            }
5332
5333            // Decode unknown envelopes for gaps in ordinals.
5334            while _next_ordinal_to_read < 3 {
5335                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5336                _next_ordinal_to_read += 1;
5337                next_offset += envelope_size;
5338            }
5339
5340            let next_out_of_line = decoder.next_out_of_line();
5341            let handles_before = decoder.remaining_handles();
5342            if let Some((inlined, num_bytes, num_handles)) =
5343                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5344            {
5345                let member_inline_size =
5346                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5347                if inlined != (member_inline_size <= 4) {
5348                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5349                }
5350                let inner_offset;
5351                let mut inner_depth = depth.clone();
5352                if inlined {
5353                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5354                    inner_offset = next_offset;
5355                } else {
5356                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5357                    inner_depth.increment()?;
5358                }
5359                let val_ref = self.vulkan.get_or_insert_with(|| fidl::new_empty!(u32, D));
5360                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5361                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5362                {
5363                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5364                }
5365                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5366                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5367                }
5368            }
5369
5370            next_offset += envelope_size;
5371            _next_ordinal_to_read += 1;
5372            if next_offset >= end_offset {
5373                return Ok(());
5374            }
5375
5376            // Decode unknown envelopes for gaps in ordinals.
5377            while _next_ordinal_to_read < 4 {
5378                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5379                _next_ordinal_to_read += 1;
5380                next_offset += envelope_size;
5381            }
5382
5383            let next_out_of_line = decoder.next_out_of_line();
5384            let handles_before = decoder.remaining_handles();
5385            if let Some((inlined, num_bytes, num_handles)) =
5386                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5387            {
5388                let member_inline_size =
5389                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5390                if inlined != (member_inline_size <= 4) {
5391                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5392                }
5393                let inner_offset;
5394                let mut inner_depth = depth.clone();
5395                if inlined {
5396                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5397                    inner_offset = next_offset;
5398                } else {
5399                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5400                    inner_depth.increment()?;
5401                }
5402                let val_ref = self.display.get_or_insert_with(|| fidl::new_empty!(u32, D));
5403                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5404                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5405                {
5406                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5407                }
5408                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5409                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5410                }
5411            }
5412
5413            next_offset += envelope_size;
5414            _next_ordinal_to_read += 1;
5415            if next_offset >= end_offset {
5416                return Ok(());
5417            }
5418
5419            // Decode unknown envelopes for gaps in ordinals.
5420            while _next_ordinal_to_read < 5 {
5421                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5422                _next_ordinal_to_read += 1;
5423                next_offset += envelope_size;
5424            }
5425
5426            let next_out_of_line = decoder.next_out_of_line();
5427            let handles_before = decoder.remaining_handles();
5428            if let Some((inlined, num_bytes, num_handles)) =
5429                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5430            {
5431                let member_inline_size =
5432                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5433                if inlined != (member_inline_size <= 4) {
5434                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5435                }
5436                let inner_offset;
5437                let mut inner_depth = depth.clone();
5438                if inlined {
5439                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5440                    inner_offset = next_offset;
5441                } else {
5442                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5443                    inner_depth.increment()?;
5444                }
5445                let val_ref = self.video.get_or_insert_with(|| fidl::new_empty!(u32, D));
5446                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
5447                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5448                {
5449                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5450                }
5451                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5452                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5453                }
5454            }
5455
5456            next_offset += envelope_size;
5457
5458            // Decode the remaining unknown envelopes.
5459            while next_offset < end_offset {
5460                _next_ordinal_to_read += 1;
5461                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5462                next_offset += envelope_size;
5463            }
5464
5465            Ok(())
5466        }
5467    }
5468
5469    impl Config {
5470        #[inline(always)]
5471        fn max_ordinal_present(&self) -> u64 {
5472            if let Some(_) = self.format_costs {
5473                return 1;
5474            }
5475            0
5476        }
5477    }
5478
5479    impl fidl::encoding::ValueTypeMarker for Config {
5480        type Borrowed<'a> = &'a Self;
5481        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5482            value
5483        }
5484    }
5485
5486    unsafe impl fidl::encoding::TypeMarker for Config {
5487        type Owned = Self;
5488
5489        #[inline(always)]
5490        fn inline_align(_context: fidl::encoding::Context) -> usize {
5491            8
5492        }
5493
5494        #[inline(always)]
5495        fn inline_size(_context: fidl::encoding::Context) -> usize {
5496            16
5497        }
5498    }
5499
5500    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
5501        unsafe fn encode(
5502            self,
5503            encoder: &mut fidl::encoding::Encoder<'_, D>,
5504            offset: usize,
5505            mut depth: fidl::encoding::Depth,
5506        ) -> fidl::Result<()> {
5507            encoder.debug_check_bounds::<Config>(offset);
5508            // Vector header
5509            let max_ordinal: u64 = self.max_ordinal_present();
5510            encoder.write_num(max_ordinal, offset);
5511            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5512            // Calling encoder.out_of_line_offset(0) is not allowed.
5513            if max_ordinal == 0 {
5514                return Ok(());
5515            }
5516            depth.increment()?;
5517            let envelope_size = 8;
5518            let bytes_len = max_ordinal as usize * envelope_size;
5519            #[allow(unused_variables)]
5520            let offset = encoder.out_of_line_offset(bytes_len);
5521            let mut _prev_end_offset: usize = 0;
5522            if 1 > max_ordinal {
5523                return Ok(());
5524            }
5525
5526            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5527            // are envelope_size bytes.
5528            let cur_offset: usize = (1 - 1) * envelope_size;
5529
5530            // Zero reserved fields.
5531            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5532
5533            // Safety:
5534            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5535            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5536            //   envelope_size bytes, there is always sufficient room.
5537            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<FormatCostEntry>, D>(
5538            self.format_costs.as_ref().map(<fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::ValueTypeMarker>::borrow),
5539            encoder, offset + cur_offset, depth
5540        )?;
5541
5542            _prev_end_offset = cur_offset + envelope_size;
5543
5544            Ok(())
5545        }
5546    }
5547
5548    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
5549        #[inline(always)]
5550        fn new_empty() -> Self {
5551            Self::default()
5552        }
5553
5554        unsafe fn decode(
5555            &mut self,
5556            decoder: &mut fidl::encoding::Decoder<'_, D>,
5557            offset: usize,
5558            mut depth: fidl::encoding::Depth,
5559        ) -> fidl::Result<()> {
5560            decoder.debug_check_bounds::<Self>(offset);
5561            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5562                None => return Err(fidl::Error::NotNullable),
5563                Some(len) => len,
5564            };
5565            // Calling decoder.out_of_line_offset(0) is not allowed.
5566            if len == 0 {
5567                return Ok(());
5568            };
5569            depth.increment()?;
5570            let envelope_size = 8;
5571            let bytes_len = len * envelope_size;
5572            let offset = decoder.out_of_line_offset(bytes_len)?;
5573            // Decode the envelope for each type.
5574            let mut _next_ordinal_to_read = 0;
5575            let mut next_offset = offset;
5576            let end_offset = offset + bytes_len;
5577            _next_ordinal_to_read += 1;
5578            if next_offset >= end_offset {
5579                return Ok(());
5580            }
5581
5582            // Decode unknown envelopes for gaps in ordinals.
5583            while _next_ordinal_to_read < 1 {
5584                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5585                _next_ordinal_to_read += 1;
5586                next_offset += envelope_size;
5587            }
5588
5589            let next_out_of_line = decoder.next_out_of_line();
5590            let handles_before = decoder.remaining_handles();
5591            if let Some((inlined, num_bytes, num_handles)) =
5592                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5593            {
5594                let member_inline_size = <fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5595                if inlined != (member_inline_size <= 4) {
5596                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5597                }
5598                let inner_offset;
5599                let mut inner_depth = depth.clone();
5600                if inlined {
5601                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5602                    inner_offset = next_offset;
5603                } else {
5604                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5605                    inner_depth.increment()?;
5606                }
5607                let val_ref = self.format_costs.get_or_insert_with(|| {
5608                    fidl::new_empty!(fidl::encoding::UnboundedVector<FormatCostEntry>, D)
5609                });
5610                fidl::decode!(
5611                    fidl::encoding::UnboundedVector<FormatCostEntry>,
5612                    D,
5613                    val_ref,
5614                    decoder,
5615                    inner_offset,
5616                    inner_depth
5617                )?;
5618                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5619                {
5620                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5621                }
5622                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5623                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5624                }
5625            }
5626
5627            next_offset += envelope_size;
5628
5629            // Decode the remaining unknown envelopes.
5630            while next_offset < end_offset {
5631                _next_ordinal_to_read += 1;
5632                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5633                next_offset += envelope_size;
5634            }
5635
5636            Ok(())
5637        }
5638    }
5639
5640    impl DynamicSecureHeap {
5641        #[inline(always)]
5642        fn max_ordinal_present(&self) -> u64 {
5643            if let Some(_) = self.heap {
5644                return 1;
5645            }
5646            0
5647        }
5648    }
5649
5650    impl fidl::encoding::ValueTypeMarker for DynamicSecureHeap {
5651        type Borrowed<'a> = &'a Self;
5652        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5653            value
5654        }
5655    }
5656
5657    unsafe impl fidl::encoding::TypeMarker for DynamicSecureHeap {
5658        type Owned = Self;
5659
5660        #[inline(always)]
5661        fn inline_align(_context: fidl::encoding::Context) -> usize {
5662            8
5663        }
5664
5665        #[inline(always)]
5666        fn inline_size(_context: fidl::encoding::Context) -> usize {
5667            16
5668        }
5669    }
5670
5671    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DynamicSecureHeap, D>
5672        for &DynamicSecureHeap
5673    {
5674        unsafe fn encode(
5675            self,
5676            encoder: &mut fidl::encoding::Encoder<'_, D>,
5677            offset: usize,
5678            mut depth: fidl::encoding::Depth,
5679        ) -> fidl::Result<()> {
5680            encoder.debug_check_bounds::<DynamicSecureHeap>(offset);
5681            // Vector header
5682            let max_ordinal: u64 = self.max_ordinal_present();
5683            encoder.write_num(max_ordinal, offset);
5684            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5685            // Calling encoder.out_of_line_offset(0) is not allowed.
5686            if max_ordinal == 0 {
5687                return Ok(());
5688            }
5689            depth.increment()?;
5690            let envelope_size = 8;
5691            let bytes_len = max_ordinal as usize * envelope_size;
5692            #[allow(unused_variables)]
5693            let offset = encoder.out_of_line_offset(bytes_len);
5694            let mut _prev_end_offset: usize = 0;
5695            if 1 > max_ordinal {
5696                return Ok(());
5697            }
5698
5699            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5700            // are envelope_size bytes.
5701            let cur_offset: usize = (1 - 1) * envelope_size;
5702
5703            // Zero reserved fields.
5704            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5705
5706            // Safety:
5707            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5708            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5709            //   envelope_size bytes, there is always sufficient room.
5710            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
5711                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
5712                encoder,
5713                offset + cur_offset,
5714                depth,
5715            )?;
5716
5717            _prev_end_offset = cur_offset + envelope_size;
5718
5719            Ok(())
5720        }
5721    }
5722
5723    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DynamicSecureHeap {
5724        #[inline(always)]
5725        fn new_empty() -> Self {
5726            Self::default()
5727        }
5728
5729        unsafe fn decode(
5730            &mut self,
5731            decoder: &mut fidl::encoding::Decoder<'_, D>,
5732            offset: usize,
5733            mut depth: fidl::encoding::Depth,
5734        ) -> fidl::Result<()> {
5735            decoder.debug_check_bounds::<Self>(offset);
5736            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5737                None => return Err(fidl::Error::NotNullable),
5738                Some(len) => len,
5739            };
5740            // Calling decoder.out_of_line_offset(0) is not allowed.
5741            if len == 0 {
5742                return Ok(());
5743            };
5744            depth.increment()?;
5745            let envelope_size = 8;
5746            let bytes_len = len * envelope_size;
5747            let offset = decoder.out_of_line_offset(bytes_len)?;
5748            // Decode the envelope for each type.
5749            let mut _next_ordinal_to_read = 0;
5750            let mut next_offset = offset;
5751            let end_offset = offset + bytes_len;
5752            _next_ordinal_to_read += 1;
5753            if next_offset >= end_offset {
5754                return Ok(());
5755            }
5756
5757            // Decode unknown envelopes for gaps in ordinals.
5758            while _next_ordinal_to_read < 1 {
5759                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5760                _next_ordinal_to_read += 1;
5761                next_offset += envelope_size;
5762            }
5763
5764            let next_out_of_line = decoder.next_out_of_line();
5765            let handles_before = decoder.remaining_handles();
5766            if let Some((inlined, num_bytes, num_handles)) =
5767                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5768            {
5769                let member_inline_size =
5770                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5771                if inlined != (member_inline_size <= 4) {
5772                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5773                }
5774                let inner_offset;
5775                let mut inner_depth = depth.clone();
5776                if inlined {
5777                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5778                    inner_offset = next_offset;
5779                } else {
5780                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5781                    inner_depth.increment()?;
5782                }
5783                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
5784                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
5785                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5786                {
5787                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5788                }
5789                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5790                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5791                }
5792            }
5793
5794            next_offset += envelope_size;
5795
5796            // Decode the remaining unknown envelopes.
5797            while next_offset < end_offset {
5798                _next_ordinal_to_read += 1;
5799                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5800                next_offset += envelope_size;
5801            }
5802
5803            Ok(())
5804        }
5805    }
5806
5807    impl FormatCostEntry {
5808        #[inline(always)]
5809        fn max_ordinal_present(&self) -> u64 {
5810            if let Some(_) = self.cost {
5811                return 2;
5812            }
5813            if let Some(_) = self.key {
5814                return 1;
5815            }
5816            0
5817        }
5818    }
5819
5820    impl fidl::encoding::ValueTypeMarker for FormatCostEntry {
5821        type Borrowed<'a> = &'a Self;
5822        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5823            value
5824        }
5825    }
5826
5827    unsafe impl fidl::encoding::TypeMarker for FormatCostEntry {
5828        type Owned = Self;
5829
5830        #[inline(always)]
5831        fn inline_align(_context: fidl::encoding::Context) -> usize {
5832            8
5833        }
5834
5835        #[inline(always)]
5836        fn inline_size(_context: fidl::encoding::Context) -> usize {
5837            16
5838        }
5839    }
5840
5841    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCostEntry, D>
5842        for &FormatCostEntry
5843    {
5844        unsafe fn encode(
5845            self,
5846            encoder: &mut fidl::encoding::Encoder<'_, D>,
5847            offset: usize,
5848            mut depth: fidl::encoding::Depth,
5849        ) -> fidl::Result<()> {
5850            encoder.debug_check_bounds::<FormatCostEntry>(offset);
5851            // Vector header
5852            let max_ordinal: u64 = self.max_ordinal_present();
5853            encoder.write_num(max_ordinal, offset);
5854            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5855            // Calling encoder.out_of_line_offset(0) is not allowed.
5856            if max_ordinal == 0 {
5857                return Ok(());
5858            }
5859            depth.increment()?;
5860            let envelope_size = 8;
5861            let bytes_len = max_ordinal as usize * envelope_size;
5862            #[allow(unused_variables)]
5863            let offset = encoder.out_of_line_offset(bytes_len);
5864            let mut _prev_end_offset: usize = 0;
5865            if 1 > max_ordinal {
5866                return Ok(());
5867            }
5868
5869            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5870            // are envelope_size bytes.
5871            let cur_offset: usize = (1 - 1) * envelope_size;
5872
5873            // Zero reserved fields.
5874            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5875
5876            // Safety:
5877            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5878            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5879            //   envelope_size bytes, there is always sufficient room.
5880            fidl::encoding::encode_in_envelope_optional::<FormatCostKey, D>(
5881                self.key.as_ref().map(<FormatCostKey as fidl::encoding::ValueTypeMarker>::borrow),
5882                encoder,
5883                offset + cur_offset,
5884                depth,
5885            )?;
5886
5887            _prev_end_offset = cur_offset + envelope_size;
5888            if 2 > max_ordinal {
5889                return Ok(());
5890            }
5891
5892            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5893            // are envelope_size bytes.
5894            let cur_offset: usize = (2 - 1) * envelope_size;
5895
5896            // Zero reserved fields.
5897            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5898
5899            // Safety:
5900            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5901            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5902            //   envelope_size bytes, there is always sufficient room.
5903            fidl::encoding::encode_in_envelope_optional::<f32, D>(
5904                self.cost.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
5905                encoder,
5906                offset + cur_offset,
5907                depth,
5908            )?;
5909
5910            _prev_end_offset = cur_offset + envelope_size;
5911
5912            Ok(())
5913        }
5914    }
5915
5916    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCostEntry {
5917        #[inline(always)]
5918        fn new_empty() -> Self {
5919            Self::default()
5920        }
5921
5922        unsafe fn decode(
5923            &mut self,
5924            decoder: &mut fidl::encoding::Decoder<'_, D>,
5925            offset: usize,
5926            mut depth: fidl::encoding::Depth,
5927        ) -> fidl::Result<()> {
5928            decoder.debug_check_bounds::<Self>(offset);
5929            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5930                None => return Err(fidl::Error::NotNullable),
5931                Some(len) => len,
5932            };
5933            // Calling decoder.out_of_line_offset(0) is not allowed.
5934            if len == 0 {
5935                return Ok(());
5936            };
5937            depth.increment()?;
5938            let envelope_size = 8;
5939            let bytes_len = len * envelope_size;
5940            let offset = decoder.out_of_line_offset(bytes_len)?;
5941            // Decode the envelope for each type.
5942            let mut _next_ordinal_to_read = 0;
5943            let mut next_offset = offset;
5944            let end_offset = offset + bytes_len;
5945            _next_ordinal_to_read += 1;
5946            if next_offset >= end_offset {
5947                return Ok(());
5948            }
5949
5950            // Decode unknown envelopes for gaps in ordinals.
5951            while _next_ordinal_to_read < 1 {
5952                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5953                _next_ordinal_to_read += 1;
5954                next_offset += envelope_size;
5955            }
5956
5957            let next_out_of_line = decoder.next_out_of_line();
5958            let handles_before = decoder.remaining_handles();
5959            if let Some((inlined, num_bytes, num_handles)) =
5960                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5961            {
5962                let member_inline_size =
5963                    <FormatCostKey as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5964                if inlined != (member_inline_size <= 4) {
5965                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5966                }
5967                let inner_offset;
5968                let mut inner_depth = depth.clone();
5969                if inlined {
5970                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5971                    inner_offset = next_offset;
5972                } else {
5973                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5974                    inner_depth.increment()?;
5975                }
5976                let val_ref = self.key.get_or_insert_with(|| fidl::new_empty!(FormatCostKey, D));
5977                fidl::decode!(FormatCostKey, D, val_ref, decoder, inner_offset, inner_depth)?;
5978                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5979                {
5980                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5981                }
5982                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5983                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5984                }
5985            }
5986
5987            next_offset += envelope_size;
5988            _next_ordinal_to_read += 1;
5989            if next_offset >= end_offset {
5990                return Ok(());
5991            }
5992
5993            // Decode unknown envelopes for gaps in ordinals.
5994            while _next_ordinal_to_read < 2 {
5995                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5996                _next_ordinal_to_read += 1;
5997                next_offset += envelope_size;
5998            }
5999
6000            let next_out_of_line = decoder.next_out_of_line();
6001            let handles_before = decoder.remaining_handles();
6002            if let Some((inlined, num_bytes, num_handles)) =
6003                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6004            {
6005                let member_inline_size =
6006                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6007                if inlined != (member_inline_size <= 4) {
6008                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6009                }
6010                let inner_offset;
6011                let mut inner_depth = depth.clone();
6012                if inlined {
6013                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6014                    inner_offset = next_offset;
6015                } else {
6016                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6017                    inner_depth.increment()?;
6018                }
6019                let val_ref = self.cost.get_or_insert_with(|| fidl::new_empty!(f32, D));
6020                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
6021                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6022                {
6023                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6024                }
6025                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6026                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6027                }
6028            }
6029
6030            next_offset += envelope_size;
6031
6032            // Decode the remaining unknown envelopes.
6033            while next_offset < end_offset {
6034                _next_ordinal_to_read += 1;
6035                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6036                next_offset += envelope_size;
6037            }
6038
6039            Ok(())
6040        }
6041    }
6042
6043    impl FormatCostKey {
6044        #[inline(always)]
6045        fn max_ordinal_present(&self) -> u64 {
6046            if let Some(_) = self.buffer_usage_bits {
6047                return 3;
6048            }
6049            if let Some(_) = self.pixel_format_modifier {
6050                return 2;
6051            }
6052            if let Some(_) = self.pixel_format {
6053                return 1;
6054            }
6055            0
6056        }
6057    }
6058
6059    impl fidl::encoding::ValueTypeMarker for FormatCostKey {
6060        type Borrowed<'a> = &'a Self;
6061        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6062            value
6063        }
6064    }
6065
6066    unsafe impl fidl::encoding::TypeMarker for FormatCostKey {
6067        type Owned = Self;
6068
6069        #[inline(always)]
6070        fn inline_align(_context: fidl::encoding::Context) -> usize {
6071            8
6072        }
6073
6074        #[inline(always)]
6075        fn inline_size(_context: fidl::encoding::Context) -> usize {
6076            16
6077        }
6078    }
6079
6080    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCostKey, D>
6081        for &FormatCostKey
6082    {
6083        unsafe fn encode(
6084            self,
6085            encoder: &mut fidl::encoding::Encoder<'_, D>,
6086            offset: usize,
6087            mut depth: fidl::encoding::Depth,
6088        ) -> fidl::Result<()> {
6089            encoder.debug_check_bounds::<FormatCostKey>(offset);
6090            // Vector header
6091            let max_ordinal: u64 = self.max_ordinal_present();
6092            encoder.write_num(max_ordinal, offset);
6093            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6094            // Calling encoder.out_of_line_offset(0) is not allowed.
6095            if max_ordinal == 0 {
6096                return Ok(());
6097            }
6098            depth.increment()?;
6099            let envelope_size = 8;
6100            let bytes_len = max_ordinal as usize * envelope_size;
6101            #[allow(unused_variables)]
6102            let offset = encoder.out_of_line_offset(bytes_len);
6103            let mut _prev_end_offset: usize = 0;
6104            if 1 > max_ordinal {
6105                return Ok(());
6106            }
6107
6108            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6109            // are envelope_size bytes.
6110            let cur_offset: usize = (1 - 1) * envelope_size;
6111
6112            // Zero reserved fields.
6113            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6114
6115            // Safety:
6116            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6117            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6118            //   envelope_size bytes, there is always sufficient room.
6119            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2_common::PixelFormat, D>(
6120            self.pixel_format.as_ref().map(<fidl_fuchsia_images2_common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow),
6121            encoder, offset + cur_offset, depth
6122        )?;
6123
6124            _prev_end_offset = cur_offset + envelope_size;
6125            if 2 > max_ordinal {
6126                return Ok(());
6127            }
6128
6129            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6130            // are envelope_size bytes.
6131            let cur_offset: usize = (2 - 1) * envelope_size;
6132
6133            // Zero reserved fields.
6134            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6135
6136            // Safety:
6137            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6138            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6139            //   envelope_size bytes, there is always sufficient room.
6140            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2_common::PixelFormatModifier, D>(
6141            self.pixel_format_modifier.as_ref().map(<fidl_fuchsia_images2_common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow),
6142            encoder, offset + cur_offset, depth
6143        )?;
6144
6145            _prev_end_offset = cur_offset + envelope_size;
6146            if 3 > max_ordinal {
6147                return Ok(());
6148            }
6149
6150            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6151            // are envelope_size bytes.
6152            let cur_offset: usize = (3 - 1) * envelope_size;
6153
6154            // Zero reserved fields.
6155            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6156
6157            // Safety:
6158            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6159            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6160            //   envelope_size bytes, there is always sufficient room.
6161            fidl::encoding::encode_in_envelope_optional::<BufferUsage, D>(
6162                self.buffer_usage_bits
6163                    .as_ref()
6164                    .map(<BufferUsage as fidl::encoding::ValueTypeMarker>::borrow),
6165                encoder,
6166                offset + cur_offset,
6167                depth,
6168            )?;
6169
6170            _prev_end_offset = cur_offset + envelope_size;
6171
6172            Ok(())
6173        }
6174    }
6175
6176    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCostKey {
6177        #[inline(always)]
6178        fn new_empty() -> Self {
6179            Self::default()
6180        }
6181
6182        unsafe fn decode(
6183            &mut self,
6184            decoder: &mut fidl::encoding::Decoder<'_, D>,
6185            offset: usize,
6186            mut depth: fidl::encoding::Depth,
6187        ) -> fidl::Result<()> {
6188            decoder.debug_check_bounds::<Self>(offset);
6189            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6190                None => return Err(fidl::Error::NotNullable),
6191                Some(len) => len,
6192            };
6193            // Calling decoder.out_of_line_offset(0) is not allowed.
6194            if len == 0 {
6195                return Ok(());
6196            };
6197            depth.increment()?;
6198            let envelope_size = 8;
6199            let bytes_len = len * envelope_size;
6200            let offset = decoder.out_of_line_offset(bytes_len)?;
6201            // Decode the envelope for each type.
6202            let mut _next_ordinal_to_read = 0;
6203            let mut next_offset = offset;
6204            let end_offset = offset + bytes_len;
6205            _next_ordinal_to_read += 1;
6206            if next_offset >= end_offset {
6207                return Ok(());
6208            }
6209
6210            // Decode unknown envelopes for gaps in ordinals.
6211            while _next_ordinal_to_read < 1 {
6212                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6213                _next_ordinal_to_read += 1;
6214                next_offset += envelope_size;
6215            }
6216
6217            let next_out_of_line = decoder.next_out_of_line();
6218            let handles_before = decoder.remaining_handles();
6219            if let Some((inlined, num_bytes, num_handles)) =
6220                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6221            {
6222                let member_inline_size = <fidl_fuchsia_images2_common::PixelFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6223                if inlined != (member_inline_size <= 4) {
6224                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6225                }
6226                let inner_offset;
6227                let mut inner_depth = depth.clone();
6228                if inlined {
6229                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6230                    inner_offset = next_offset;
6231                } else {
6232                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6233                    inner_depth.increment()?;
6234                }
6235                let val_ref = self.pixel_format.get_or_insert_with(|| {
6236                    fidl::new_empty!(fidl_fuchsia_images2_common::PixelFormat, D)
6237                });
6238                fidl::decode!(
6239                    fidl_fuchsia_images2_common::PixelFormat,
6240                    D,
6241                    val_ref,
6242                    decoder,
6243                    inner_offset,
6244                    inner_depth
6245                )?;
6246                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6247                {
6248                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6249                }
6250                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6251                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6252                }
6253            }
6254
6255            next_offset += envelope_size;
6256            _next_ordinal_to_read += 1;
6257            if next_offset >= end_offset {
6258                return Ok(());
6259            }
6260
6261            // Decode unknown envelopes for gaps in ordinals.
6262            while _next_ordinal_to_read < 2 {
6263                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6264                _next_ordinal_to_read += 1;
6265                next_offset += envelope_size;
6266            }
6267
6268            let next_out_of_line = decoder.next_out_of_line();
6269            let handles_before = decoder.remaining_handles();
6270            if let Some((inlined, num_bytes, num_handles)) =
6271                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6272            {
6273                let member_inline_size = <fidl_fuchsia_images2_common::PixelFormatModifier as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6274                if inlined != (member_inline_size <= 4) {
6275                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6276                }
6277                let inner_offset;
6278                let mut inner_depth = depth.clone();
6279                if inlined {
6280                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6281                    inner_offset = next_offset;
6282                } else {
6283                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6284                    inner_depth.increment()?;
6285                }
6286                let val_ref = self.pixel_format_modifier.get_or_insert_with(|| {
6287                    fidl::new_empty!(fidl_fuchsia_images2_common::PixelFormatModifier, D)
6288                });
6289                fidl::decode!(
6290                    fidl_fuchsia_images2_common::PixelFormatModifier,
6291                    D,
6292                    val_ref,
6293                    decoder,
6294                    inner_offset,
6295                    inner_depth
6296                )?;
6297                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6298                {
6299                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6300                }
6301                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6302                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6303                }
6304            }
6305
6306            next_offset += envelope_size;
6307            _next_ordinal_to_read += 1;
6308            if next_offset >= end_offset {
6309                return Ok(());
6310            }
6311
6312            // Decode unknown envelopes for gaps in ordinals.
6313            while _next_ordinal_to_read < 3 {
6314                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6315                _next_ordinal_to_read += 1;
6316                next_offset += envelope_size;
6317            }
6318
6319            let next_out_of_line = decoder.next_out_of_line();
6320            let handles_before = decoder.remaining_handles();
6321            if let Some((inlined, num_bytes, num_handles)) =
6322                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6323            {
6324                let member_inline_size =
6325                    <BufferUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6326                if inlined != (member_inline_size <= 4) {
6327                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6328                }
6329                let inner_offset;
6330                let mut inner_depth = depth.clone();
6331                if inlined {
6332                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6333                    inner_offset = next_offset;
6334                } else {
6335                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6336                    inner_depth.increment()?;
6337                }
6338                let val_ref =
6339                    self.buffer_usage_bits.get_or_insert_with(|| fidl::new_empty!(BufferUsage, D));
6340                fidl::decode!(BufferUsage, D, val_ref, decoder, inner_offset, inner_depth)?;
6341                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6342                {
6343                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6344                }
6345                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6346                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6347                }
6348            }
6349
6350            next_offset += envelope_size;
6351
6352            // Decode the remaining unknown envelopes.
6353            while next_offset < end_offset {
6354                _next_ordinal_to_read += 1;
6355                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6356                next_offset += envelope_size;
6357            }
6358
6359            Ok(())
6360        }
6361    }
6362
6363    impl FormatCosts {
6364        #[inline(always)]
6365        fn max_ordinal_present(&self) -> u64 {
6366            if let Some(_) = self.format_costs {
6367                return 1;
6368            }
6369            0
6370        }
6371    }
6372
6373    impl fidl::encoding::ValueTypeMarker for FormatCosts {
6374        type Borrowed<'a> = &'a Self;
6375        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6376            value
6377        }
6378    }
6379
6380    unsafe impl fidl::encoding::TypeMarker for FormatCosts {
6381        type Owned = Self;
6382
6383        #[inline(always)]
6384        fn inline_align(_context: fidl::encoding::Context) -> usize {
6385            8
6386        }
6387
6388        #[inline(always)]
6389        fn inline_size(_context: fidl::encoding::Context) -> usize {
6390            16
6391        }
6392    }
6393
6394    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FormatCosts, D>
6395        for &FormatCosts
6396    {
6397        unsafe fn encode(
6398            self,
6399            encoder: &mut fidl::encoding::Encoder<'_, D>,
6400            offset: usize,
6401            mut depth: fidl::encoding::Depth,
6402        ) -> fidl::Result<()> {
6403            encoder.debug_check_bounds::<FormatCosts>(offset);
6404            // Vector header
6405            let max_ordinal: u64 = self.max_ordinal_present();
6406            encoder.write_num(max_ordinal, offset);
6407            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6408            // Calling encoder.out_of_line_offset(0) is not allowed.
6409            if max_ordinal == 0 {
6410                return Ok(());
6411            }
6412            depth.increment()?;
6413            let envelope_size = 8;
6414            let bytes_len = max_ordinal as usize * envelope_size;
6415            #[allow(unused_variables)]
6416            let offset = encoder.out_of_line_offset(bytes_len);
6417            let mut _prev_end_offset: usize = 0;
6418            if 1 > max_ordinal {
6419                return Ok(());
6420            }
6421
6422            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6423            // are envelope_size bytes.
6424            let cur_offset: usize = (1 - 1) * envelope_size;
6425
6426            // Zero reserved fields.
6427            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6428
6429            // Safety:
6430            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6431            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6432            //   envelope_size bytes, there is always sufficient room.
6433            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<FormatCostEntry>, D>(
6434            self.format_costs.as_ref().map(<fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::ValueTypeMarker>::borrow),
6435            encoder, offset + cur_offset, depth
6436        )?;
6437
6438            _prev_end_offset = cur_offset + envelope_size;
6439
6440            Ok(())
6441        }
6442    }
6443
6444    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FormatCosts {
6445        #[inline(always)]
6446        fn new_empty() -> Self {
6447            Self::default()
6448        }
6449
6450        unsafe fn decode(
6451            &mut self,
6452            decoder: &mut fidl::encoding::Decoder<'_, D>,
6453            offset: usize,
6454            mut depth: fidl::encoding::Depth,
6455        ) -> fidl::Result<()> {
6456            decoder.debug_check_bounds::<Self>(offset);
6457            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6458                None => return Err(fidl::Error::NotNullable),
6459                Some(len) => len,
6460            };
6461            // Calling decoder.out_of_line_offset(0) is not allowed.
6462            if len == 0 {
6463                return Ok(());
6464            };
6465            depth.increment()?;
6466            let envelope_size = 8;
6467            let bytes_len = len * envelope_size;
6468            let offset = decoder.out_of_line_offset(bytes_len)?;
6469            // Decode the envelope for each type.
6470            let mut _next_ordinal_to_read = 0;
6471            let mut next_offset = offset;
6472            let end_offset = offset + bytes_len;
6473            _next_ordinal_to_read += 1;
6474            if next_offset >= end_offset {
6475                return Ok(());
6476            }
6477
6478            // Decode unknown envelopes for gaps in ordinals.
6479            while _next_ordinal_to_read < 1 {
6480                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6481                _next_ordinal_to_read += 1;
6482                next_offset += envelope_size;
6483            }
6484
6485            let next_out_of_line = decoder.next_out_of_line();
6486            let handles_before = decoder.remaining_handles();
6487            if let Some((inlined, num_bytes, num_handles)) =
6488                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6489            {
6490                let member_inline_size = <fidl::encoding::UnboundedVector<FormatCostEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6491                if inlined != (member_inline_size <= 4) {
6492                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6493                }
6494                let inner_offset;
6495                let mut inner_depth = depth.clone();
6496                if inlined {
6497                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6498                    inner_offset = next_offset;
6499                } else {
6500                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6501                    inner_depth.increment()?;
6502                }
6503                let val_ref = self.format_costs.get_or_insert_with(|| {
6504                    fidl::new_empty!(fidl::encoding::UnboundedVector<FormatCostEntry>, D)
6505                });
6506                fidl::decode!(
6507                    fidl::encoding::UnboundedVector<FormatCostEntry>,
6508                    D,
6509                    val_ref,
6510                    decoder,
6511                    inner_offset,
6512                    inner_depth
6513                )?;
6514                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6515                {
6516                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6517                }
6518                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6519                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6520                }
6521            }
6522
6523            next_offset += envelope_size;
6524
6525            // Decode the remaining unknown envelopes.
6526            while next_offset < end_offset {
6527                _next_ordinal_to_read += 1;
6528                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6529                next_offset += envelope_size;
6530            }
6531
6532            Ok(())
6533        }
6534    }
6535
6536    impl Heap {
6537        #[inline(always)]
6538        fn max_ordinal_present(&self) -> u64 {
6539            if let Some(_) = self.id {
6540                return 2;
6541            }
6542            if let Some(_) = self.heap_type {
6543                return 1;
6544            }
6545            0
6546        }
6547    }
6548
6549    impl fidl::encoding::ValueTypeMarker for Heap {
6550        type Borrowed<'a> = &'a Self;
6551        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6552            value
6553        }
6554    }
6555
6556    unsafe impl fidl::encoding::TypeMarker for Heap {
6557        type Owned = Self;
6558
6559        #[inline(always)]
6560        fn inline_align(_context: fidl::encoding::Context) -> usize {
6561            8
6562        }
6563
6564        #[inline(always)]
6565        fn inline_size(_context: fidl::encoding::Context) -> usize {
6566            16
6567        }
6568    }
6569
6570    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Heap, D> for &Heap {
6571        unsafe fn encode(
6572            self,
6573            encoder: &mut fidl::encoding::Encoder<'_, D>,
6574            offset: usize,
6575            mut depth: fidl::encoding::Depth,
6576        ) -> fidl::Result<()> {
6577            encoder.debug_check_bounds::<Heap>(offset);
6578            // Vector header
6579            let max_ordinal: u64 = self.max_ordinal_present();
6580            encoder.write_num(max_ordinal, offset);
6581            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6582            // Calling encoder.out_of_line_offset(0) is not allowed.
6583            if max_ordinal == 0 {
6584                return Ok(());
6585            }
6586            depth.increment()?;
6587            let envelope_size = 8;
6588            let bytes_len = max_ordinal as usize * envelope_size;
6589            #[allow(unused_variables)]
6590            let offset = encoder.out_of_line_offset(bytes_len);
6591            let mut _prev_end_offset: usize = 0;
6592            if 1 > max_ordinal {
6593                return Ok(());
6594            }
6595
6596            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6597            // are envelope_size bytes.
6598            let cur_offset: usize = (1 - 1) * envelope_size;
6599
6600            // Zero reserved fields.
6601            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6602
6603            // Safety:
6604            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6605            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6606            //   envelope_size bytes, there is always sufficient room.
6607            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
6608                self.heap_type.as_ref().map(
6609                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
6610                ),
6611                encoder,
6612                offset + cur_offset,
6613                depth,
6614            )?;
6615
6616            _prev_end_offset = cur_offset + envelope_size;
6617            if 2 > max_ordinal {
6618                return Ok(());
6619            }
6620
6621            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6622            // are envelope_size bytes.
6623            let cur_offset: usize = (2 - 1) * envelope_size;
6624
6625            // Zero reserved fields.
6626            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6627
6628            // Safety:
6629            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6630            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6631            //   envelope_size bytes, there is always sufficient room.
6632            fidl::encoding::encode_in_envelope_optional::<u64, D>(
6633                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
6634                encoder,
6635                offset + cur_offset,
6636                depth,
6637            )?;
6638
6639            _prev_end_offset = cur_offset + envelope_size;
6640
6641            Ok(())
6642        }
6643    }
6644
6645    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Heap {
6646        #[inline(always)]
6647        fn new_empty() -> Self {
6648            Self::default()
6649        }
6650
6651        unsafe fn decode(
6652            &mut self,
6653            decoder: &mut fidl::encoding::Decoder<'_, D>,
6654            offset: usize,
6655            mut depth: fidl::encoding::Depth,
6656        ) -> fidl::Result<()> {
6657            decoder.debug_check_bounds::<Self>(offset);
6658            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6659                None => return Err(fidl::Error::NotNullable),
6660                Some(len) => len,
6661            };
6662            // Calling decoder.out_of_line_offset(0) is not allowed.
6663            if len == 0 {
6664                return Ok(());
6665            };
6666            depth.increment()?;
6667            let envelope_size = 8;
6668            let bytes_len = len * envelope_size;
6669            let offset = decoder.out_of_line_offset(bytes_len)?;
6670            // Decode the envelope for each type.
6671            let mut _next_ordinal_to_read = 0;
6672            let mut next_offset = offset;
6673            let end_offset = offset + bytes_len;
6674            _next_ordinal_to_read += 1;
6675            if next_offset >= end_offset {
6676                return Ok(());
6677            }
6678
6679            // Decode unknown envelopes for gaps in ordinals.
6680            while _next_ordinal_to_read < 1 {
6681                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6682                _next_ordinal_to_read += 1;
6683                next_offset += envelope_size;
6684            }
6685
6686            let next_out_of_line = decoder.next_out_of_line();
6687            let handles_before = decoder.remaining_handles();
6688            if let Some((inlined, num_bytes, num_handles)) =
6689                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6690            {
6691                let member_inline_size =
6692                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
6693                        decoder.context,
6694                    );
6695                if inlined != (member_inline_size <= 4) {
6696                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6697                }
6698                let inner_offset;
6699                let mut inner_depth = depth.clone();
6700                if inlined {
6701                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6702                    inner_offset = next_offset;
6703                } else {
6704                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6705                    inner_depth.increment()?;
6706                }
6707                let val_ref = self
6708                    .heap_type
6709                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
6710                fidl::decode!(
6711                    fidl::encoding::BoundedString<128>,
6712                    D,
6713                    val_ref,
6714                    decoder,
6715                    inner_offset,
6716                    inner_depth
6717                )?;
6718                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6719                {
6720                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6721                }
6722                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6723                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6724                }
6725            }
6726
6727            next_offset += envelope_size;
6728            _next_ordinal_to_read += 1;
6729            if next_offset >= end_offset {
6730                return Ok(());
6731            }
6732
6733            // Decode unknown envelopes for gaps in ordinals.
6734            while _next_ordinal_to_read < 2 {
6735                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6736                _next_ordinal_to_read += 1;
6737                next_offset += envelope_size;
6738            }
6739
6740            let next_out_of_line = decoder.next_out_of_line();
6741            let handles_before = decoder.remaining_handles();
6742            if let Some((inlined, num_bytes, num_handles)) =
6743                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6744            {
6745                let member_inline_size =
6746                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6747                if inlined != (member_inline_size <= 4) {
6748                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6749                }
6750                let inner_offset;
6751                let mut inner_depth = depth.clone();
6752                if inlined {
6753                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6754                    inner_offset = next_offset;
6755                } else {
6756                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6757                    inner_depth.increment()?;
6758                }
6759                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
6760                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
6761                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6762                {
6763                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6764                }
6765                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6766                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6767                }
6768            }
6769
6770            next_offset += envelope_size;
6771
6772            // Decode the remaining unknown envelopes.
6773            while next_offset < end_offset {
6774                _next_ordinal_to_read += 1;
6775                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6776                next_offset += envelope_size;
6777            }
6778
6779            Ok(())
6780        }
6781    }
6782
6783    impl ImageFormatConstraints {
6784        #[inline(always)]
6785        fn max_ordinal_present(&self) -> u64 {
6786            if let Some(_) = self.pad_beyond_image_size_bytes {
6787                return 20;
6788            }
6789            if let Some(_) = self.pad_for_block_size {
6790                return 19;
6791            }
6792            if let Some(_) = self.required_max_size_list {
6793                return 18;
6794            }
6795            if let Some(_) = self.is_alpha_present {
6796                return 17;
6797            }
6798            if let Some(_) = self.require_bytes_per_row_at_pixel_boundary {
6799                return 16;
6800            }
6801            if let Some(_) = self.pixel_format_and_modifiers {
6802                return 15;
6803            }
6804            if let Some(_) = self.start_offset_divisor {
6805                return 14;
6806            }
6807            if let Some(_) = self.bytes_per_row_divisor {
6808                return 13;
6809            }
6810            if let Some(_) = self.required_max_size {
6811                return 12;
6812            }
6813            if let Some(_) = self.required_min_size {
6814                return 11;
6815            }
6816            if let Some(_) = self.display_rect_alignment {
6817                return 10;
6818            }
6819            if let Some(_) = self.size_alignment {
6820                return 9;
6821            }
6822            if let Some(_) = self.max_width_times_height {
6823                return 8;
6824            }
6825            if let Some(_) = self.max_bytes_per_row {
6826                return 7;
6827            }
6828            if let Some(_) = self.min_bytes_per_row {
6829                return 6;
6830            }
6831            if let Some(_) = self.max_size {
6832                return 5;
6833            }
6834            if let Some(_) = self.min_size {
6835                return 4;
6836            }
6837            if let Some(_) = self.color_spaces {
6838                return 3;
6839            }
6840            if let Some(_) = self.pixel_format_modifier {
6841                return 2;
6842            }
6843            if let Some(_) = self.pixel_format {
6844                return 1;
6845            }
6846            0
6847        }
6848    }
6849
6850    impl fidl::encoding::ValueTypeMarker for ImageFormatConstraints {
6851        type Borrowed<'a> = &'a Self;
6852        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6853            value
6854        }
6855    }
6856
6857    unsafe impl fidl::encoding::TypeMarker for ImageFormatConstraints {
6858        type Owned = Self;
6859
6860        #[inline(always)]
6861        fn inline_align(_context: fidl::encoding::Context) -> usize {
6862            8
6863        }
6864
6865        #[inline(always)]
6866        fn inline_size(_context: fidl::encoding::Context) -> usize {
6867            16
6868        }
6869    }
6870
6871    unsafe impl<D: fidl::encoding::ResourceDialect>
6872        fidl::encoding::Encode<ImageFormatConstraints, D> for &ImageFormatConstraints
6873    {
6874        unsafe fn encode(
6875            self,
6876            encoder: &mut fidl::encoding::Encoder<'_, D>,
6877            offset: usize,
6878            mut depth: fidl::encoding::Depth,
6879        ) -> fidl::Result<()> {
6880            encoder.debug_check_bounds::<ImageFormatConstraints>(offset);
6881            // Vector header
6882            let max_ordinal: u64 = self.max_ordinal_present();
6883            encoder.write_num(max_ordinal, offset);
6884            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6885            // Calling encoder.out_of_line_offset(0) is not allowed.
6886            if max_ordinal == 0 {
6887                return Ok(());
6888            }
6889            depth.increment()?;
6890            let envelope_size = 8;
6891            let bytes_len = max_ordinal as usize * envelope_size;
6892            #[allow(unused_variables)]
6893            let offset = encoder.out_of_line_offset(bytes_len);
6894            let mut _prev_end_offset: usize = 0;
6895            if 1 > max_ordinal {
6896                return Ok(());
6897            }
6898
6899            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6900            // are envelope_size bytes.
6901            let cur_offset: usize = (1 - 1) * envelope_size;
6902
6903            // Zero reserved fields.
6904            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6905
6906            // Safety:
6907            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6908            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6909            //   envelope_size bytes, there is always sufficient room.
6910            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2_common::PixelFormat, D>(
6911            self.pixel_format.as_ref().map(<fidl_fuchsia_images2_common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow),
6912            encoder, offset + cur_offset, depth
6913        )?;
6914
6915            _prev_end_offset = cur_offset + envelope_size;
6916            if 2 > max_ordinal {
6917                return Ok(());
6918            }
6919
6920            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6921            // are envelope_size bytes.
6922            let cur_offset: usize = (2 - 1) * envelope_size;
6923
6924            // Zero reserved fields.
6925            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6926
6927            // Safety:
6928            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6929            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6930            //   envelope_size bytes, there is always sufficient room.
6931            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_images2_common::PixelFormatModifier, D>(
6932            self.pixel_format_modifier.as_ref().map(<fidl_fuchsia_images2_common::PixelFormatModifier as fidl::encoding::ValueTypeMarker>::borrow),
6933            encoder, offset + cur_offset, depth
6934        )?;
6935
6936            _prev_end_offset = cur_offset + envelope_size;
6937            if 3 > max_ordinal {
6938                return Ok(());
6939            }
6940
6941            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6942            // are envelope_size bytes.
6943            let cur_offset: usize = (3 - 1) * envelope_size;
6944
6945            // Zero reserved fields.
6946            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6947
6948            // Safety:
6949            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6950            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6951            //   envelope_size bytes, there is always sufficient room.
6952            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_images2_common::ColorSpace, 32>, D>(
6953            self.color_spaces.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_images2_common::ColorSpace, 32> as fidl::encoding::ValueTypeMarker>::borrow),
6954            encoder, offset + cur_offset, depth
6955        )?;
6956
6957            _prev_end_offset = cur_offset + envelope_size;
6958            if 4 > max_ordinal {
6959                return Ok(());
6960            }
6961
6962            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6963            // are envelope_size bytes.
6964            let cur_offset: usize = (4 - 1) * envelope_size;
6965
6966            // Zero reserved fields.
6967            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6968
6969            // Safety:
6970            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6971            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6972            //   envelope_size bytes, there is always sufficient room.
6973            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math_common::SizeU, D>(
6974                self.min_size.as_ref().map(
6975                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
6976                ),
6977                encoder,
6978                offset + cur_offset,
6979                depth,
6980            )?;
6981
6982            _prev_end_offset = cur_offset + envelope_size;
6983            if 5 > max_ordinal {
6984                return Ok(());
6985            }
6986
6987            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6988            // are envelope_size bytes.
6989            let cur_offset: usize = (5 - 1) * envelope_size;
6990
6991            // Zero reserved fields.
6992            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6993
6994            // Safety:
6995            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6996            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6997            //   envelope_size bytes, there is always sufficient room.
6998            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math_common::SizeU, D>(
6999                self.max_size.as_ref().map(
7000                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7001                ),
7002                encoder,
7003                offset + cur_offset,
7004                depth,
7005            )?;
7006
7007            _prev_end_offset = cur_offset + envelope_size;
7008            if 6 > max_ordinal {
7009                return Ok(());
7010            }
7011
7012            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7013            // are envelope_size bytes.
7014            let cur_offset: usize = (6 - 1) * envelope_size;
7015
7016            // Zero reserved fields.
7017            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7018
7019            // Safety:
7020            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7021            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7022            //   envelope_size bytes, there is always sufficient room.
7023            fidl::encoding::encode_in_envelope_optional::<u32, D>(
7024                self.min_bytes_per_row
7025                    .as_ref()
7026                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7027                encoder,
7028                offset + cur_offset,
7029                depth,
7030            )?;
7031
7032            _prev_end_offset = cur_offset + envelope_size;
7033            if 7 > max_ordinal {
7034                return Ok(());
7035            }
7036
7037            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7038            // are envelope_size bytes.
7039            let cur_offset: usize = (7 - 1) * envelope_size;
7040
7041            // Zero reserved fields.
7042            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7043
7044            // Safety:
7045            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7046            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7047            //   envelope_size bytes, there is always sufficient room.
7048            fidl::encoding::encode_in_envelope_optional::<u32, D>(
7049                self.max_bytes_per_row
7050                    .as_ref()
7051                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7052                encoder,
7053                offset + cur_offset,
7054                depth,
7055            )?;
7056
7057            _prev_end_offset = cur_offset + envelope_size;
7058            if 8 > max_ordinal {
7059                return Ok(());
7060            }
7061
7062            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7063            // are envelope_size bytes.
7064            let cur_offset: usize = (8 - 1) * envelope_size;
7065
7066            // Zero reserved fields.
7067            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7068
7069            // Safety:
7070            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7071            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7072            //   envelope_size bytes, there is always sufficient room.
7073            fidl::encoding::encode_in_envelope_optional::<u64, D>(
7074                self.max_width_times_height
7075                    .as_ref()
7076                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7077                encoder,
7078                offset + cur_offset,
7079                depth,
7080            )?;
7081
7082            _prev_end_offset = cur_offset + envelope_size;
7083            if 9 > max_ordinal {
7084                return Ok(());
7085            }
7086
7087            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7088            // are envelope_size bytes.
7089            let cur_offset: usize = (9 - 1) * envelope_size;
7090
7091            // Zero reserved fields.
7092            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7093
7094            // Safety:
7095            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7096            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7097            //   envelope_size bytes, there is always sufficient room.
7098            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math_common::SizeU, D>(
7099                self.size_alignment.as_ref().map(
7100                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7101                ),
7102                encoder,
7103                offset + cur_offset,
7104                depth,
7105            )?;
7106
7107            _prev_end_offset = cur_offset + envelope_size;
7108            if 10 > max_ordinal {
7109                return Ok(());
7110            }
7111
7112            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7113            // are envelope_size bytes.
7114            let cur_offset: usize = (10 - 1) * envelope_size;
7115
7116            // Zero reserved fields.
7117            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7118
7119            // Safety:
7120            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7121            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7122            //   envelope_size bytes, there is always sufficient room.
7123            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math_common::SizeU, D>(
7124                self.display_rect_alignment.as_ref().map(
7125                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7126                ),
7127                encoder,
7128                offset + cur_offset,
7129                depth,
7130            )?;
7131
7132            _prev_end_offset = cur_offset + envelope_size;
7133            if 11 > max_ordinal {
7134                return Ok(());
7135            }
7136
7137            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7138            // are envelope_size bytes.
7139            let cur_offset: usize = (11 - 1) * envelope_size;
7140
7141            // Zero reserved fields.
7142            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7143
7144            // Safety:
7145            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7146            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7147            //   envelope_size bytes, there is always sufficient room.
7148            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math_common::SizeU, D>(
7149                self.required_min_size.as_ref().map(
7150                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7151                ),
7152                encoder,
7153                offset + cur_offset,
7154                depth,
7155            )?;
7156
7157            _prev_end_offset = cur_offset + envelope_size;
7158            if 12 > max_ordinal {
7159                return Ok(());
7160            }
7161
7162            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7163            // are envelope_size bytes.
7164            let cur_offset: usize = (12 - 1) * envelope_size;
7165
7166            // Zero reserved fields.
7167            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7168
7169            // Safety:
7170            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7171            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7172            //   envelope_size bytes, there is always sufficient room.
7173            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math_common::SizeU, D>(
7174                self.required_max_size.as_ref().map(
7175                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7176                ),
7177                encoder,
7178                offset + cur_offset,
7179                depth,
7180            )?;
7181
7182            _prev_end_offset = cur_offset + envelope_size;
7183            if 13 > max_ordinal {
7184                return Ok(());
7185            }
7186
7187            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7188            // are envelope_size bytes.
7189            let cur_offset: usize = (13 - 1) * envelope_size;
7190
7191            // Zero reserved fields.
7192            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7193
7194            // Safety:
7195            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7196            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7197            //   envelope_size bytes, there is always sufficient room.
7198            fidl::encoding::encode_in_envelope_optional::<u32, D>(
7199                self.bytes_per_row_divisor
7200                    .as_ref()
7201                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7202                encoder,
7203                offset + cur_offset,
7204                depth,
7205            )?;
7206
7207            _prev_end_offset = cur_offset + envelope_size;
7208            if 14 > max_ordinal {
7209                return Ok(());
7210            }
7211
7212            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7213            // are envelope_size bytes.
7214            let cur_offset: usize = (14 - 1) * envelope_size;
7215
7216            // Zero reserved fields.
7217            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7218
7219            // Safety:
7220            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7221            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7222            //   envelope_size bytes, there is always sufficient room.
7223            fidl::encoding::encode_in_envelope_optional::<u32, D>(
7224                self.start_offset_divisor
7225                    .as_ref()
7226                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7227                encoder,
7228                offset + cur_offset,
7229                depth,
7230            )?;
7231
7232            _prev_end_offset = cur_offset + envelope_size;
7233            if 15 > max_ordinal {
7234                return Ok(());
7235            }
7236
7237            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7238            // are envelope_size bytes.
7239            let cur_offset: usize = (15 - 1) * envelope_size;
7240
7241            // Zero reserved fields.
7242            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7243
7244            // Safety:
7245            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7246            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7247            //   envelope_size bytes, there is always sufficient room.
7248            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<PixelFormatAndModifier, 64>, D>(
7249            self.pixel_format_and_modifiers.as_ref().map(<fidl::encoding::Vector<PixelFormatAndModifier, 64> as fidl::encoding::ValueTypeMarker>::borrow),
7250            encoder, offset + cur_offset, depth
7251        )?;
7252
7253            _prev_end_offset = cur_offset + envelope_size;
7254            if 16 > max_ordinal {
7255                return Ok(());
7256            }
7257
7258            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7259            // are envelope_size bytes.
7260            let cur_offset: usize = (16 - 1) * envelope_size;
7261
7262            // Zero reserved fields.
7263            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7264
7265            // Safety:
7266            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7267            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7268            //   envelope_size bytes, there is always sufficient room.
7269            fidl::encoding::encode_in_envelope_optional::<bool, D>(
7270                self.require_bytes_per_row_at_pixel_boundary
7271                    .as_ref()
7272                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
7273                encoder,
7274                offset + cur_offset,
7275                depth,
7276            )?;
7277
7278            _prev_end_offset = cur_offset + envelope_size;
7279            if 17 > max_ordinal {
7280                return Ok(());
7281            }
7282
7283            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7284            // are envelope_size bytes.
7285            let cur_offset: usize = (17 - 1) * envelope_size;
7286
7287            // Zero reserved fields.
7288            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7289
7290            // Safety:
7291            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7292            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7293            //   envelope_size bytes, there is always sufficient room.
7294            fidl::encoding::encode_in_envelope_optional::<bool, D>(
7295                self.is_alpha_present
7296                    .as_ref()
7297                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
7298                encoder,
7299                offset + cur_offset,
7300                depth,
7301            )?;
7302
7303            _prev_end_offset = cur_offset + envelope_size;
7304            if 18 > max_ordinal {
7305                return Ok(());
7306            }
7307
7308            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7309            // are envelope_size bytes.
7310            let cur_offset: usize = (18 - 1) * envelope_size;
7311
7312            // Zero reserved fields.
7313            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7314
7315            // Safety:
7316            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7317            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7318            //   envelope_size bytes, there is always sufficient room.
7319            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_math_common::SizeU, 64>, D>(
7320            self.required_max_size_list.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_math_common::SizeU, 64> as fidl::encoding::ValueTypeMarker>::borrow),
7321            encoder, offset + cur_offset, depth
7322        )?;
7323
7324            _prev_end_offset = cur_offset + envelope_size;
7325            if 19 > max_ordinal {
7326                return Ok(());
7327            }
7328
7329            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7330            // are envelope_size bytes.
7331            let cur_offset: usize = (19 - 1) * envelope_size;
7332
7333            // Zero reserved fields.
7334            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7335
7336            // Safety:
7337            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7338            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7339            //   envelope_size bytes, there is always sufficient room.
7340            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math_common::SizeU, D>(
7341                self.pad_for_block_size.as_ref().map(
7342                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
7343                ),
7344                encoder,
7345                offset + cur_offset,
7346                depth,
7347            )?;
7348
7349            _prev_end_offset = cur_offset + envelope_size;
7350            if 20 > max_ordinal {
7351                return Ok(());
7352            }
7353
7354            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7355            // are envelope_size bytes.
7356            let cur_offset: usize = (20 - 1) * envelope_size;
7357
7358            // Zero reserved fields.
7359            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7360
7361            // Safety:
7362            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7363            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7364            //   envelope_size bytes, there is always sufficient room.
7365            fidl::encoding::encode_in_envelope_optional::<u64, D>(
7366                self.pad_beyond_image_size_bytes
7367                    .as_ref()
7368                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7369                encoder,
7370                offset + cur_offset,
7371                depth,
7372            )?;
7373
7374            _prev_end_offset = cur_offset + envelope_size;
7375
7376            Ok(())
7377        }
7378    }
7379
7380    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
7381        for ImageFormatConstraints
7382    {
7383        #[inline(always)]
7384        fn new_empty() -> Self {
7385            Self::default()
7386        }
7387
7388        unsafe fn decode(
7389            &mut self,
7390            decoder: &mut fidl::encoding::Decoder<'_, D>,
7391            offset: usize,
7392            mut depth: fidl::encoding::Depth,
7393        ) -> fidl::Result<()> {
7394            decoder.debug_check_bounds::<Self>(offset);
7395            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7396                None => return Err(fidl::Error::NotNullable),
7397                Some(len) => len,
7398            };
7399            // Calling decoder.out_of_line_offset(0) is not allowed.
7400            if len == 0 {
7401                return Ok(());
7402            };
7403            depth.increment()?;
7404            let envelope_size = 8;
7405            let bytes_len = len * envelope_size;
7406            let offset = decoder.out_of_line_offset(bytes_len)?;
7407            // Decode the envelope for each type.
7408            let mut _next_ordinal_to_read = 0;
7409            let mut next_offset = offset;
7410            let end_offset = offset + bytes_len;
7411            _next_ordinal_to_read += 1;
7412            if next_offset >= end_offset {
7413                return Ok(());
7414            }
7415
7416            // Decode unknown envelopes for gaps in ordinals.
7417            while _next_ordinal_to_read < 1 {
7418                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7419                _next_ordinal_to_read += 1;
7420                next_offset += envelope_size;
7421            }
7422
7423            let next_out_of_line = decoder.next_out_of_line();
7424            let handles_before = decoder.remaining_handles();
7425            if let Some((inlined, num_bytes, num_handles)) =
7426                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7427            {
7428                let member_inline_size = <fidl_fuchsia_images2_common::PixelFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7429                if inlined != (member_inline_size <= 4) {
7430                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7431                }
7432                let inner_offset;
7433                let mut inner_depth = depth.clone();
7434                if inlined {
7435                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7436                    inner_offset = next_offset;
7437                } else {
7438                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7439                    inner_depth.increment()?;
7440                }
7441                let val_ref = self.pixel_format.get_or_insert_with(|| {
7442                    fidl::new_empty!(fidl_fuchsia_images2_common::PixelFormat, D)
7443                });
7444                fidl::decode!(
7445                    fidl_fuchsia_images2_common::PixelFormat,
7446                    D,
7447                    val_ref,
7448                    decoder,
7449                    inner_offset,
7450                    inner_depth
7451                )?;
7452                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7453                {
7454                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7455                }
7456                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7457                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7458                }
7459            }
7460
7461            next_offset += envelope_size;
7462            _next_ordinal_to_read += 1;
7463            if next_offset >= end_offset {
7464                return Ok(());
7465            }
7466
7467            // Decode unknown envelopes for gaps in ordinals.
7468            while _next_ordinal_to_read < 2 {
7469                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7470                _next_ordinal_to_read += 1;
7471                next_offset += envelope_size;
7472            }
7473
7474            let next_out_of_line = decoder.next_out_of_line();
7475            let handles_before = decoder.remaining_handles();
7476            if let Some((inlined, num_bytes, num_handles)) =
7477                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7478            {
7479                let member_inline_size = <fidl_fuchsia_images2_common::PixelFormatModifier 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 = self.pixel_format_modifier.get_or_insert_with(|| {
7493                    fidl::new_empty!(fidl_fuchsia_images2_common::PixelFormatModifier, D)
7494                });
7495                fidl::decode!(
7496                    fidl_fuchsia_images2_common::PixelFormatModifier,
7497                    D,
7498                    val_ref,
7499                    decoder,
7500                    inner_offset,
7501                    inner_depth
7502                )?;
7503                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7504                {
7505                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7506                }
7507                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7508                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7509                }
7510            }
7511
7512            next_offset += envelope_size;
7513            _next_ordinal_to_read += 1;
7514            if next_offset >= end_offset {
7515                return Ok(());
7516            }
7517
7518            // Decode unknown envelopes for gaps in ordinals.
7519            while _next_ordinal_to_read < 3 {
7520                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7521                _next_ordinal_to_read += 1;
7522                next_offset += envelope_size;
7523            }
7524
7525            let next_out_of_line = decoder.next_out_of_line();
7526            let handles_before = decoder.remaining_handles();
7527            if let Some((inlined, num_bytes, num_handles)) =
7528                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7529            {
7530                let member_inline_size = <fidl::encoding::Vector<
7531                    fidl_fuchsia_images2_common::ColorSpace,
7532                    32,
7533                > as fidl::encoding::TypeMarker>::inline_size(
7534                    decoder.context
7535                );
7536                if inlined != (member_inline_size <= 4) {
7537                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7538                }
7539                let inner_offset;
7540                let mut inner_depth = depth.clone();
7541                if inlined {
7542                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7543                    inner_offset = next_offset;
7544                } else {
7545                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7546                    inner_depth.increment()?;
7547                }
7548                let val_ref =
7549                self.color_spaces.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_images2_common::ColorSpace, 32>, D));
7550                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_images2_common::ColorSpace, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
7551                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7552                {
7553                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7554                }
7555                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7556                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7557                }
7558            }
7559
7560            next_offset += envelope_size;
7561            _next_ordinal_to_read += 1;
7562            if next_offset >= end_offset {
7563                return Ok(());
7564            }
7565
7566            // Decode unknown envelopes for gaps in ordinals.
7567            while _next_ordinal_to_read < 4 {
7568                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7569                _next_ordinal_to_read += 1;
7570                next_offset += envelope_size;
7571            }
7572
7573            let next_out_of_line = decoder.next_out_of_line();
7574            let handles_before = decoder.remaining_handles();
7575            if let Some((inlined, num_bytes, num_handles)) =
7576                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7577            {
7578                let member_inline_size =
7579                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7580                        decoder.context,
7581                    );
7582                if inlined != (member_inline_size <= 4) {
7583                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7584                }
7585                let inner_offset;
7586                let mut inner_depth = depth.clone();
7587                if inlined {
7588                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7589                    inner_offset = next_offset;
7590                } else {
7591                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7592                    inner_depth.increment()?;
7593                }
7594                let val_ref = self
7595                    .min_size
7596                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math_common::SizeU, D));
7597                fidl::decode!(
7598                    fidl_fuchsia_math_common::SizeU,
7599                    D,
7600                    val_ref,
7601                    decoder,
7602                    inner_offset,
7603                    inner_depth
7604                )?;
7605                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7606                {
7607                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7608                }
7609                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7610                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7611                }
7612            }
7613
7614            next_offset += envelope_size;
7615            _next_ordinal_to_read += 1;
7616            if next_offset >= end_offset {
7617                return Ok(());
7618            }
7619
7620            // Decode unknown envelopes for gaps in ordinals.
7621            while _next_ordinal_to_read < 5 {
7622                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7623                _next_ordinal_to_read += 1;
7624                next_offset += envelope_size;
7625            }
7626
7627            let next_out_of_line = decoder.next_out_of_line();
7628            let handles_before = decoder.remaining_handles();
7629            if let Some((inlined, num_bytes, num_handles)) =
7630                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7631            {
7632                let member_inline_size =
7633                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7634                        decoder.context,
7635                    );
7636                if inlined != (member_inline_size <= 4) {
7637                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7638                }
7639                let inner_offset;
7640                let mut inner_depth = depth.clone();
7641                if inlined {
7642                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7643                    inner_offset = next_offset;
7644                } else {
7645                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7646                    inner_depth.increment()?;
7647                }
7648                let val_ref = self
7649                    .max_size
7650                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math_common::SizeU, D));
7651                fidl::decode!(
7652                    fidl_fuchsia_math_common::SizeU,
7653                    D,
7654                    val_ref,
7655                    decoder,
7656                    inner_offset,
7657                    inner_depth
7658                )?;
7659                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7660                {
7661                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7662                }
7663                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7664                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7665                }
7666            }
7667
7668            next_offset += envelope_size;
7669            _next_ordinal_to_read += 1;
7670            if next_offset >= end_offset {
7671                return Ok(());
7672            }
7673
7674            // Decode unknown envelopes for gaps in ordinals.
7675            while _next_ordinal_to_read < 6 {
7676                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7677                _next_ordinal_to_read += 1;
7678                next_offset += envelope_size;
7679            }
7680
7681            let next_out_of_line = decoder.next_out_of_line();
7682            let handles_before = decoder.remaining_handles();
7683            if let Some((inlined, num_bytes, num_handles)) =
7684                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7685            {
7686                let member_inline_size =
7687                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7688                if inlined != (member_inline_size <= 4) {
7689                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7690                }
7691                let inner_offset;
7692                let mut inner_depth = depth.clone();
7693                if inlined {
7694                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7695                    inner_offset = next_offset;
7696                } else {
7697                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7698                    inner_depth.increment()?;
7699                }
7700                let val_ref =
7701                    self.min_bytes_per_row.get_or_insert_with(|| fidl::new_empty!(u32, D));
7702                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7703                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7704                {
7705                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7706                }
7707                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7708                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7709                }
7710            }
7711
7712            next_offset += envelope_size;
7713            _next_ordinal_to_read += 1;
7714            if next_offset >= end_offset {
7715                return Ok(());
7716            }
7717
7718            // Decode unknown envelopes for gaps in ordinals.
7719            while _next_ordinal_to_read < 7 {
7720                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7721                _next_ordinal_to_read += 1;
7722                next_offset += envelope_size;
7723            }
7724
7725            let next_out_of_line = decoder.next_out_of_line();
7726            let handles_before = decoder.remaining_handles();
7727            if let Some((inlined, num_bytes, num_handles)) =
7728                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7729            {
7730                let member_inline_size =
7731                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7732                if inlined != (member_inline_size <= 4) {
7733                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7734                }
7735                let inner_offset;
7736                let mut inner_depth = depth.clone();
7737                if inlined {
7738                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7739                    inner_offset = next_offset;
7740                } else {
7741                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7742                    inner_depth.increment()?;
7743                }
7744                let val_ref =
7745                    self.max_bytes_per_row.get_or_insert_with(|| fidl::new_empty!(u32, D));
7746                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
7747                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7748                {
7749                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7750                }
7751                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7752                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7753                }
7754            }
7755
7756            next_offset += envelope_size;
7757            _next_ordinal_to_read += 1;
7758            if next_offset >= end_offset {
7759                return Ok(());
7760            }
7761
7762            // Decode unknown envelopes for gaps in ordinals.
7763            while _next_ordinal_to_read < 8 {
7764                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7765                _next_ordinal_to_read += 1;
7766                next_offset += envelope_size;
7767            }
7768
7769            let next_out_of_line = decoder.next_out_of_line();
7770            let handles_before = decoder.remaining_handles();
7771            if let Some((inlined, num_bytes, num_handles)) =
7772                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7773            {
7774                let member_inline_size =
7775                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7776                if inlined != (member_inline_size <= 4) {
7777                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7778                }
7779                let inner_offset;
7780                let mut inner_depth = depth.clone();
7781                if inlined {
7782                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7783                    inner_offset = next_offset;
7784                } else {
7785                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7786                    inner_depth.increment()?;
7787                }
7788                let val_ref =
7789                    self.max_width_times_height.get_or_insert_with(|| fidl::new_empty!(u64, D));
7790                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
7791                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7792                {
7793                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7794                }
7795                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7796                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7797                }
7798            }
7799
7800            next_offset += envelope_size;
7801            _next_ordinal_to_read += 1;
7802            if next_offset >= end_offset {
7803                return Ok(());
7804            }
7805
7806            // Decode unknown envelopes for gaps in ordinals.
7807            while _next_ordinal_to_read < 9 {
7808                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7809                _next_ordinal_to_read += 1;
7810                next_offset += envelope_size;
7811            }
7812
7813            let next_out_of_line = decoder.next_out_of_line();
7814            let handles_before = decoder.remaining_handles();
7815            if let Some((inlined, num_bytes, num_handles)) =
7816                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7817            {
7818                let member_inline_size =
7819                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7820                        decoder.context,
7821                    );
7822                if inlined != (member_inline_size <= 4) {
7823                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7824                }
7825                let inner_offset;
7826                let mut inner_depth = depth.clone();
7827                if inlined {
7828                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7829                    inner_offset = next_offset;
7830                } else {
7831                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7832                    inner_depth.increment()?;
7833                }
7834                let val_ref = self
7835                    .size_alignment
7836                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math_common::SizeU, D));
7837                fidl::decode!(
7838                    fidl_fuchsia_math_common::SizeU,
7839                    D,
7840                    val_ref,
7841                    decoder,
7842                    inner_offset,
7843                    inner_depth
7844                )?;
7845                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7846                {
7847                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7848                }
7849                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7850                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7851                }
7852            }
7853
7854            next_offset += envelope_size;
7855            _next_ordinal_to_read += 1;
7856            if next_offset >= end_offset {
7857                return Ok(());
7858            }
7859
7860            // Decode unknown envelopes for gaps in ordinals.
7861            while _next_ordinal_to_read < 10 {
7862                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7863                _next_ordinal_to_read += 1;
7864                next_offset += envelope_size;
7865            }
7866
7867            let next_out_of_line = decoder.next_out_of_line();
7868            let handles_before = decoder.remaining_handles();
7869            if let Some((inlined, num_bytes, num_handles)) =
7870                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7871            {
7872                let member_inline_size =
7873                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7874                        decoder.context,
7875                    );
7876                if inlined != (member_inline_size <= 4) {
7877                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7878                }
7879                let inner_offset;
7880                let mut inner_depth = depth.clone();
7881                if inlined {
7882                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7883                    inner_offset = next_offset;
7884                } else {
7885                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7886                    inner_depth.increment()?;
7887                }
7888                let val_ref = self
7889                    .display_rect_alignment
7890                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math_common::SizeU, D));
7891                fidl::decode!(
7892                    fidl_fuchsia_math_common::SizeU,
7893                    D,
7894                    val_ref,
7895                    decoder,
7896                    inner_offset,
7897                    inner_depth
7898                )?;
7899                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7900                {
7901                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7902                }
7903                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7904                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7905                }
7906            }
7907
7908            next_offset += envelope_size;
7909            _next_ordinal_to_read += 1;
7910            if next_offset >= end_offset {
7911                return Ok(());
7912            }
7913
7914            // Decode unknown envelopes for gaps in ordinals.
7915            while _next_ordinal_to_read < 11 {
7916                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7917                _next_ordinal_to_read += 1;
7918                next_offset += envelope_size;
7919            }
7920
7921            let next_out_of_line = decoder.next_out_of_line();
7922            let handles_before = decoder.remaining_handles();
7923            if let Some((inlined, num_bytes, num_handles)) =
7924                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7925            {
7926                let member_inline_size =
7927                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7928                        decoder.context,
7929                    );
7930                if inlined != (member_inline_size <= 4) {
7931                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7932                }
7933                let inner_offset;
7934                let mut inner_depth = depth.clone();
7935                if inlined {
7936                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7937                    inner_offset = next_offset;
7938                } else {
7939                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7940                    inner_depth.increment()?;
7941                }
7942                let val_ref = self
7943                    .required_min_size
7944                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math_common::SizeU, D));
7945                fidl::decode!(
7946                    fidl_fuchsia_math_common::SizeU,
7947                    D,
7948                    val_ref,
7949                    decoder,
7950                    inner_offset,
7951                    inner_depth
7952                )?;
7953                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7954                {
7955                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7956                }
7957                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7958                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7959                }
7960            }
7961
7962            next_offset += envelope_size;
7963            _next_ordinal_to_read += 1;
7964            if next_offset >= end_offset {
7965                return Ok(());
7966            }
7967
7968            // Decode unknown envelopes for gaps in ordinals.
7969            while _next_ordinal_to_read < 12 {
7970                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7971                _next_ordinal_to_read += 1;
7972                next_offset += envelope_size;
7973            }
7974
7975            let next_out_of_line = decoder.next_out_of_line();
7976            let handles_before = decoder.remaining_handles();
7977            if let Some((inlined, num_bytes, num_handles)) =
7978                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7979            {
7980                let member_inline_size =
7981                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::TypeMarker>::inline_size(
7982                        decoder.context,
7983                    );
7984                if inlined != (member_inline_size <= 4) {
7985                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7986                }
7987                let inner_offset;
7988                let mut inner_depth = depth.clone();
7989                if inlined {
7990                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7991                    inner_offset = next_offset;
7992                } else {
7993                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7994                    inner_depth.increment()?;
7995                }
7996                let val_ref = self
7997                    .required_max_size
7998                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math_common::SizeU, D));
7999                fidl::decode!(
8000                    fidl_fuchsia_math_common::SizeU,
8001                    D,
8002                    val_ref,
8003                    decoder,
8004                    inner_offset,
8005                    inner_depth
8006                )?;
8007                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8008                {
8009                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8010                }
8011                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8012                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8013                }
8014            }
8015
8016            next_offset += envelope_size;
8017            _next_ordinal_to_read += 1;
8018            if next_offset >= end_offset {
8019                return Ok(());
8020            }
8021
8022            // Decode unknown envelopes for gaps in ordinals.
8023            while _next_ordinal_to_read < 13 {
8024                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8025                _next_ordinal_to_read += 1;
8026                next_offset += envelope_size;
8027            }
8028
8029            let next_out_of_line = decoder.next_out_of_line();
8030            let handles_before = decoder.remaining_handles();
8031            if let Some((inlined, num_bytes, num_handles)) =
8032                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8033            {
8034                let member_inline_size =
8035                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8036                if inlined != (member_inline_size <= 4) {
8037                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8038                }
8039                let inner_offset;
8040                let mut inner_depth = depth.clone();
8041                if inlined {
8042                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8043                    inner_offset = next_offset;
8044                } else {
8045                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8046                    inner_depth.increment()?;
8047                }
8048                let val_ref =
8049                    self.bytes_per_row_divisor.get_or_insert_with(|| fidl::new_empty!(u32, D));
8050                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
8051                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8052                {
8053                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8054                }
8055                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8056                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8057                }
8058            }
8059
8060            next_offset += envelope_size;
8061            _next_ordinal_to_read += 1;
8062            if next_offset >= end_offset {
8063                return Ok(());
8064            }
8065
8066            // Decode unknown envelopes for gaps in ordinals.
8067            while _next_ordinal_to_read < 14 {
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                    <u32 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 =
8093                    self.start_offset_divisor.get_or_insert_with(|| fidl::new_empty!(u32, D));
8094                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
8095                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8096                {
8097                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8098                }
8099                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8100                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8101                }
8102            }
8103
8104            next_offset += envelope_size;
8105            _next_ordinal_to_read += 1;
8106            if next_offset >= end_offset {
8107                return Ok(());
8108            }
8109
8110            // Decode unknown envelopes for gaps in ordinals.
8111            while _next_ordinal_to_read < 15 {
8112                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8113                _next_ordinal_to_read += 1;
8114                next_offset += envelope_size;
8115            }
8116
8117            let next_out_of_line = decoder.next_out_of_line();
8118            let handles_before = decoder.remaining_handles();
8119            if let Some((inlined, num_bytes, num_handles)) =
8120                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8121            {
8122                let member_inline_size = <fidl::encoding::Vector<PixelFormatAndModifier, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8123                if inlined != (member_inline_size <= 4) {
8124                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8125                }
8126                let inner_offset;
8127                let mut inner_depth = depth.clone();
8128                if inlined {
8129                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8130                    inner_offset = next_offset;
8131                } else {
8132                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8133                    inner_depth.increment()?;
8134                }
8135                let val_ref = self.pixel_format_and_modifiers.get_or_insert_with(
8136                    || fidl::new_empty!(fidl::encoding::Vector<PixelFormatAndModifier, 64>, D),
8137                );
8138                fidl::decode!(fidl::encoding::Vector<PixelFormatAndModifier, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
8139                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8140                {
8141                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8142                }
8143                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8144                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8145                }
8146            }
8147
8148            next_offset += envelope_size;
8149            _next_ordinal_to_read += 1;
8150            if next_offset >= end_offset {
8151                return Ok(());
8152            }
8153
8154            // Decode unknown envelopes for gaps in ordinals.
8155            while _next_ordinal_to_read < 16 {
8156                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8157                _next_ordinal_to_read += 1;
8158                next_offset += envelope_size;
8159            }
8160
8161            let next_out_of_line = decoder.next_out_of_line();
8162            let handles_before = decoder.remaining_handles();
8163            if let Some((inlined, num_bytes, num_handles)) =
8164                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8165            {
8166                let member_inline_size =
8167                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8168                if inlined != (member_inline_size <= 4) {
8169                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8170                }
8171                let inner_offset;
8172                let mut inner_depth = depth.clone();
8173                if inlined {
8174                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8175                    inner_offset = next_offset;
8176                } else {
8177                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8178                    inner_depth.increment()?;
8179                }
8180                let val_ref = self
8181                    .require_bytes_per_row_at_pixel_boundary
8182                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
8183                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
8184                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8185                {
8186                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8187                }
8188                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8189                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8190                }
8191            }
8192
8193            next_offset += envelope_size;
8194            _next_ordinal_to_read += 1;
8195            if next_offset >= end_offset {
8196                return Ok(());
8197            }
8198
8199            // Decode unknown envelopes for gaps in ordinals.
8200            while _next_ordinal_to_read < 17 {
8201                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8202                _next_ordinal_to_read += 1;
8203                next_offset += envelope_size;
8204            }
8205
8206            let next_out_of_line = decoder.next_out_of_line();
8207            let handles_before = decoder.remaining_handles();
8208            if let Some((inlined, num_bytes, num_handles)) =
8209                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8210            {
8211                let member_inline_size =
8212                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8213                if inlined != (member_inline_size <= 4) {
8214                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8215                }
8216                let inner_offset;
8217                let mut inner_depth = depth.clone();
8218                if inlined {
8219                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8220                    inner_offset = next_offset;
8221                } else {
8222                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8223                    inner_depth.increment()?;
8224                }
8225                let val_ref =
8226                    self.is_alpha_present.get_or_insert_with(|| fidl::new_empty!(bool, D));
8227                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
8228                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8229                {
8230                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8231                }
8232                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8233                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8234                }
8235            }
8236
8237            next_offset += envelope_size;
8238            _next_ordinal_to_read += 1;
8239            if next_offset >= end_offset {
8240                return Ok(());
8241            }
8242
8243            // Decode unknown envelopes for gaps in ordinals.
8244            while _next_ordinal_to_read < 18 {
8245                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8246                _next_ordinal_to_read += 1;
8247                next_offset += envelope_size;
8248            }
8249
8250            let next_out_of_line = decoder.next_out_of_line();
8251            let handles_before = decoder.remaining_handles();
8252            if let Some((inlined, num_bytes, num_handles)) =
8253                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8254            {
8255                let member_inline_size = <fidl::encoding::Vector<
8256                    fidl_fuchsia_math_common::SizeU,
8257                    64,
8258                > as fidl::encoding::TypeMarker>::inline_size(
8259                    decoder.context
8260                );
8261                if inlined != (member_inline_size <= 4) {
8262                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8263                }
8264                let inner_offset;
8265                let mut inner_depth = depth.clone();
8266                if inlined {
8267                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8268                    inner_offset = next_offset;
8269                } else {
8270                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8271                    inner_depth.increment()?;
8272                }
8273                let val_ref =
8274                self.required_max_size_list.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_math_common::SizeU, 64>, D));
8275                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_math_common::SizeU, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
8276                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8277                {
8278                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8279                }
8280                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8281                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8282                }
8283            }
8284
8285            next_offset += envelope_size;
8286            _next_ordinal_to_read += 1;
8287            if next_offset >= end_offset {
8288                return Ok(());
8289            }
8290
8291            // Decode unknown envelopes for gaps in ordinals.
8292            while _next_ordinal_to_read < 19 {
8293                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8294                _next_ordinal_to_read += 1;
8295                next_offset += envelope_size;
8296            }
8297
8298            let next_out_of_line = decoder.next_out_of_line();
8299            let handles_before = decoder.remaining_handles();
8300            if let Some((inlined, num_bytes, num_handles)) =
8301                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8302            {
8303                let member_inline_size =
8304                    <fidl_fuchsia_math_common::SizeU as fidl::encoding::TypeMarker>::inline_size(
8305                        decoder.context,
8306                    );
8307                if inlined != (member_inline_size <= 4) {
8308                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8309                }
8310                let inner_offset;
8311                let mut inner_depth = depth.clone();
8312                if inlined {
8313                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8314                    inner_offset = next_offset;
8315                } else {
8316                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8317                    inner_depth.increment()?;
8318                }
8319                let val_ref = self
8320                    .pad_for_block_size
8321                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math_common::SizeU, D));
8322                fidl::decode!(
8323                    fidl_fuchsia_math_common::SizeU,
8324                    D,
8325                    val_ref,
8326                    decoder,
8327                    inner_offset,
8328                    inner_depth
8329                )?;
8330                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8331                {
8332                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8333                }
8334                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8335                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8336                }
8337            }
8338
8339            next_offset += envelope_size;
8340            _next_ordinal_to_read += 1;
8341            if next_offset >= end_offset {
8342                return Ok(());
8343            }
8344
8345            // Decode unknown envelopes for gaps in ordinals.
8346            while _next_ordinal_to_read < 20 {
8347                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8348                _next_ordinal_to_read += 1;
8349                next_offset += envelope_size;
8350            }
8351
8352            let next_out_of_line = decoder.next_out_of_line();
8353            let handles_before = decoder.remaining_handles();
8354            if let Some((inlined, num_bytes, num_handles)) =
8355                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8356            {
8357                let member_inline_size =
8358                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8359                if inlined != (member_inline_size <= 4) {
8360                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8361                }
8362                let inner_offset;
8363                let mut inner_depth = depth.clone();
8364                if inlined {
8365                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8366                    inner_offset = next_offset;
8367                } else {
8368                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8369                    inner_depth.increment()?;
8370                }
8371                let val_ref = self
8372                    .pad_beyond_image_size_bytes
8373                    .get_or_insert_with(|| fidl::new_empty!(u64, D));
8374                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
8375                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8376                {
8377                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8378                }
8379                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8380                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8381                }
8382            }
8383
8384            next_offset += envelope_size;
8385
8386            // Decode the remaining unknown envelopes.
8387            while next_offset < end_offset {
8388                _next_ordinal_to_read += 1;
8389                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8390                next_offset += envelope_size;
8391            }
8392
8393            Ok(())
8394        }
8395    }
8396
8397    impl NodeSetDebugClientInfoRequest {
8398        #[inline(always)]
8399        fn max_ordinal_present(&self) -> u64 {
8400            if let Some(_) = self.id {
8401                return 2;
8402            }
8403            if let Some(_) = self.name {
8404                return 1;
8405            }
8406            0
8407        }
8408    }
8409
8410    impl fidl::encoding::ValueTypeMarker for NodeSetDebugClientInfoRequest {
8411        type Borrowed<'a> = &'a Self;
8412        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8413            value
8414        }
8415    }
8416
8417    unsafe impl fidl::encoding::TypeMarker for NodeSetDebugClientInfoRequest {
8418        type Owned = Self;
8419
8420        #[inline(always)]
8421        fn inline_align(_context: fidl::encoding::Context) -> usize {
8422            8
8423        }
8424
8425        #[inline(always)]
8426        fn inline_size(_context: fidl::encoding::Context) -> usize {
8427            16
8428        }
8429    }
8430
8431    unsafe impl<D: fidl::encoding::ResourceDialect>
8432        fidl::encoding::Encode<NodeSetDebugClientInfoRequest, D>
8433        for &NodeSetDebugClientInfoRequest
8434    {
8435        unsafe fn encode(
8436            self,
8437            encoder: &mut fidl::encoding::Encoder<'_, D>,
8438            offset: usize,
8439            mut depth: fidl::encoding::Depth,
8440        ) -> fidl::Result<()> {
8441            encoder.debug_check_bounds::<NodeSetDebugClientInfoRequest>(offset);
8442            // Vector header
8443            let max_ordinal: u64 = self.max_ordinal_present();
8444            encoder.write_num(max_ordinal, offset);
8445            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8446            // Calling encoder.out_of_line_offset(0) is not allowed.
8447            if max_ordinal == 0 {
8448                return Ok(());
8449            }
8450            depth.increment()?;
8451            let envelope_size = 8;
8452            let bytes_len = max_ordinal as usize * envelope_size;
8453            #[allow(unused_variables)]
8454            let offset = encoder.out_of_line_offset(bytes_len);
8455            let mut _prev_end_offset: usize = 0;
8456            if 1 > max_ordinal {
8457                return Ok(());
8458            }
8459
8460            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8461            // are envelope_size bytes.
8462            let cur_offset: usize = (1 - 1) * envelope_size;
8463
8464            // Zero reserved fields.
8465            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8466
8467            // Safety:
8468            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8469            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8470            //   envelope_size bytes, there is always sufficient room.
8471            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
8472                self.name.as_ref().map(
8473                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
8474                ),
8475                encoder,
8476                offset + cur_offset,
8477                depth,
8478            )?;
8479
8480            _prev_end_offset = cur_offset + envelope_size;
8481            if 2 > max_ordinal {
8482                return Ok(());
8483            }
8484
8485            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8486            // are envelope_size bytes.
8487            let cur_offset: usize = (2 - 1) * envelope_size;
8488
8489            // Zero reserved fields.
8490            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8491
8492            // Safety:
8493            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8494            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8495            //   envelope_size bytes, there is always sufficient room.
8496            fidl::encoding::encode_in_envelope_optional::<u64, D>(
8497                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8498                encoder,
8499                offset + cur_offset,
8500                depth,
8501            )?;
8502
8503            _prev_end_offset = cur_offset + envelope_size;
8504
8505            Ok(())
8506        }
8507    }
8508
8509    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8510        for NodeSetDebugClientInfoRequest
8511    {
8512        #[inline(always)]
8513        fn new_empty() -> Self {
8514            Self::default()
8515        }
8516
8517        unsafe fn decode(
8518            &mut self,
8519            decoder: &mut fidl::encoding::Decoder<'_, D>,
8520            offset: usize,
8521            mut depth: fidl::encoding::Depth,
8522        ) -> fidl::Result<()> {
8523            decoder.debug_check_bounds::<Self>(offset);
8524            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8525                None => return Err(fidl::Error::NotNullable),
8526                Some(len) => len,
8527            };
8528            // Calling decoder.out_of_line_offset(0) is not allowed.
8529            if len == 0 {
8530                return Ok(());
8531            };
8532            depth.increment()?;
8533            let envelope_size = 8;
8534            let bytes_len = len * envelope_size;
8535            let offset = decoder.out_of_line_offset(bytes_len)?;
8536            // Decode the envelope for each type.
8537            let mut _next_ordinal_to_read = 0;
8538            let mut next_offset = offset;
8539            let end_offset = offset + bytes_len;
8540            _next_ordinal_to_read += 1;
8541            if next_offset >= end_offset {
8542                return Ok(());
8543            }
8544
8545            // Decode unknown envelopes for gaps in ordinals.
8546            while _next_ordinal_to_read < 1 {
8547                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8548                _next_ordinal_to_read += 1;
8549                next_offset += envelope_size;
8550            }
8551
8552            let next_out_of_line = decoder.next_out_of_line();
8553            let handles_before = decoder.remaining_handles();
8554            if let Some((inlined, num_bytes, num_handles)) =
8555                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8556            {
8557                let member_inline_size =
8558                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
8559                        decoder.context,
8560                    );
8561                if inlined != (member_inline_size <= 4) {
8562                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8563                }
8564                let inner_offset;
8565                let mut inner_depth = depth.clone();
8566                if inlined {
8567                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8568                    inner_offset = next_offset;
8569                } else {
8570                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8571                    inner_depth.increment()?;
8572                }
8573                let val_ref = self
8574                    .name
8575                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
8576                fidl::decode!(
8577                    fidl::encoding::BoundedString<256>,
8578                    D,
8579                    val_ref,
8580                    decoder,
8581                    inner_offset,
8582                    inner_depth
8583                )?;
8584                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8585                {
8586                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8587                }
8588                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8589                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8590                }
8591            }
8592
8593            next_offset += envelope_size;
8594            _next_ordinal_to_read += 1;
8595            if next_offset >= end_offset {
8596                return Ok(());
8597            }
8598
8599            // Decode unknown envelopes for gaps in ordinals.
8600            while _next_ordinal_to_read < 2 {
8601                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8602                _next_ordinal_to_read += 1;
8603                next_offset += envelope_size;
8604            }
8605
8606            let next_out_of_line = decoder.next_out_of_line();
8607            let handles_before = decoder.remaining_handles();
8608            if let Some((inlined, num_bytes, num_handles)) =
8609                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8610            {
8611                let member_inline_size =
8612                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8613                if inlined != (member_inline_size <= 4) {
8614                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8615                }
8616                let inner_offset;
8617                let mut inner_depth = depth.clone();
8618                if inlined {
8619                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8620                    inner_offset = next_offset;
8621                } else {
8622                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8623                    inner_depth.increment()?;
8624                }
8625                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
8626                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
8627                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8628                {
8629                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8630                }
8631                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8632                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8633                }
8634            }
8635
8636            next_offset += envelope_size;
8637
8638            // Decode the remaining unknown envelopes.
8639            while next_offset < end_offset {
8640                _next_ordinal_to_read += 1;
8641                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8642                next_offset += envelope_size;
8643            }
8644
8645            Ok(())
8646        }
8647    }
8648
8649    impl NodeSetDebugTimeoutLogDeadlineRequest {
8650        #[inline(always)]
8651        fn max_ordinal_present(&self) -> u64 {
8652            if let Some(_) = self.deadline {
8653                return 1;
8654            }
8655            0
8656        }
8657    }
8658
8659    impl fidl::encoding::ValueTypeMarker for NodeSetDebugTimeoutLogDeadlineRequest {
8660        type Borrowed<'a> = &'a Self;
8661        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8662            value
8663        }
8664    }
8665
8666    unsafe impl fidl::encoding::TypeMarker for NodeSetDebugTimeoutLogDeadlineRequest {
8667        type Owned = Self;
8668
8669        #[inline(always)]
8670        fn inline_align(_context: fidl::encoding::Context) -> usize {
8671            8
8672        }
8673
8674        #[inline(always)]
8675        fn inline_size(_context: fidl::encoding::Context) -> usize {
8676            16
8677        }
8678    }
8679
8680    unsafe impl<D: fidl::encoding::ResourceDialect>
8681        fidl::encoding::Encode<NodeSetDebugTimeoutLogDeadlineRequest, D>
8682        for &NodeSetDebugTimeoutLogDeadlineRequest
8683    {
8684        unsafe fn encode(
8685            self,
8686            encoder: &mut fidl::encoding::Encoder<'_, D>,
8687            offset: usize,
8688            mut depth: fidl::encoding::Depth,
8689        ) -> fidl::Result<()> {
8690            encoder.debug_check_bounds::<NodeSetDebugTimeoutLogDeadlineRequest>(offset);
8691            // Vector header
8692            let max_ordinal: u64 = self.max_ordinal_present();
8693            encoder.write_num(max_ordinal, offset);
8694            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8695            // Calling encoder.out_of_line_offset(0) is not allowed.
8696            if max_ordinal == 0 {
8697                return Ok(());
8698            }
8699            depth.increment()?;
8700            let envelope_size = 8;
8701            let bytes_len = max_ordinal as usize * envelope_size;
8702            #[allow(unused_variables)]
8703            let offset = encoder.out_of_line_offset(bytes_len);
8704            let mut _prev_end_offset: usize = 0;
8705            if 1 > max_ordinal {
8706                return Ok(());
8707            }
8708
8709            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8710            // are envelope_size bytes.
8711            let cur_offset: usize = (1 - 1) * envelope_size;
8712
8713            // Zero reserved fields.
8714            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8715
8716            // Safety:
8717            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8718            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8719            //   envelope_size bytes, there is always sufficient room.
8720            fidl::encoding::encode_in_envelope_optional::<i64, D>(
8721                self.deadline.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
8722                encoder,
8723                offset + cur_offset,
8724                depth,
8725            )?;
8726
8727            _prev_end_offset = cur_offset + envelope_size;
8728
8729            Ok(())
8730        }
8731    }
8732
8733    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
8734        for NodeSetDebugTimeoutLogDeadlineRequest
8735    {
8736        #[inline(always)]
8737        fn new_empty() -> Self {
8738            Self::default()
8739        }
8740
8741        unsafe fn decode(
8742            &mut self,
8743            decoder: &mut fidl::encoding::Decoder<'_, D>,
8744            offset: usize,
8745            mut depth: fidl::encoding::Depth,
8746        ) -> fidl::Result<()> {
8747            decoder.debug_check_bounds::<Self>(offset);
8748            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8749                None => return Err(fidl::Error::NotNullable),
8750                Some(len) => len,
8751            };
8752            // Calling decoder.out_of_line_offset(0) is not allowed.
8753            if len == 0 {
8754                return Ok(());
8755            };
8756            depth.increment()?;
8757            let envelope_size = 8;
8758            let bytes_len = len * envelope_size;
8759            let offset = decoder.out_of_line_offset(bytes_len)?;
8760            // Decode the envelope for each type.
8761            let mut _next_ordinal_to_read = 0;
8762            let mut next_offset = offset;
8763            let end_offset = offset + bytes_len;
8764            _next_ordinal_to_read += 1;
8765            if next_offset >= end_offset {
8766                return Ok(());
8767            }
8768
8769            // Decode unknown envelopes for gaps in ordinals.
8770            while _next_ordinal_to_read < 1 {
8771                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8772                _next_ordinal_to_read += 1;
8773                next_offset += envelope_size;
8774            }
8775
8776            let next_out_of_line = decoder.next_out_of_line();
8777            let handles_before = decoder.remaining_handles();
8778            if let Some((inlined, num_bytes, num_handles)) =
8779                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8780            {
8781                let member_inline_size =
8782                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8783                if inlined != (member_inline_size <= 4) {
8784                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8785                }
8786                let inner_offset;
8787                let mut inner_depth = depth.clone();
8788                if inlined {
8789                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8790                    inner_offset = next_offset;
8791                } else {
8792                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8793                    inner_depth.increment()?;
8794                }
8795                let val_ref = self.deadline.get_or_insert_with(|| fidl::new_empty!(i64, D));
8796                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
8797                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8798                {
8799                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8800                }
8801                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8802                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8803                }
8804            }
8805
8806            next_offset += envelope_size;
8807
8808            // Decode the remaining unknown envelopes.
8809            while next_offset < end_offset {
8810                _next_ordinal_to_read += 1;
8811                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8812                next_offset += envelope_size;
8813            }
8814
8815            Ok(())
8816        }
8817    }
8818
8819    impl NodeSetNameRequest {
8820        #[inline(always)]
8821        fn max_ordinal_present(&self) -> u64 {
8822            if let Some(_) = self.name {
8823                return 2;
8824            }
8825            if let Some(_) = self.priority {
8826                return 1;
8827            }
8828            0
8829        }
8830    }
8831
8832    impl fidl::encoding::ValueTypeMarker for NodeSetNameRequest {
8833        type Borrowed<'a> = &'a Self;
8834        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
8835            value
8836        }
8837    }
8838
8839    unsafe impl fidl::encoding::TypeMarker for NodeSetNameRequest {
8840        type Owned = Self;
8841
8842        #[inline(always)]
8843        fn inline_align(_context: fidl::encoding::Context) -> usize {
8844            8
8845        }
8846
8847        #[inline(always)]
8848        fn inline_size(_context: fidl::encoding::Context) -> usize {
8849            16
8850        }
8851    }
8852
8853    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NodeSetNameRequest, D>
8854        for &NodeSetNameRequest
8855    {
8856        unsafe fn encode(
8857            self,
8858            encoder: &mut fidl::encoding::Encoder<'_, D>,
8859            offset: usize,
8860            mut depth: fidl::encoding::Depth,
8861        ) -> fidl::Result<()> {
8862            encoder.debug_check_bounds::<NodeSetNameRequest>(offset);
8863            // Vector header
8864            let max_ordinal: u64 = self.max_ordinal_present();
8865            encoder.write_num(max_ordinal, offset);
8866            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8867            // Calling encoder.out_of_line_offset(0) is not allowed.
8868            if max_ordinal == 0 {
8869                return Ok(());
8870            }
8871            depth.increment()?;
8872            let envelope_size = 8;
8873            let bytes_len = max_ordinal as usize * envelope_size;
8874            #[allow(unused_variables)]
8875            let offset = encoder.out_of_line_offset(bytes_len);
8876            let mut _prev_end_offset: usize = 0;
8877            if 1 > max_ordinal {
8878                return Ok(());
8879            }
8880
8881            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8882            // are envelope_size bytes.
8883            let cur_offset: usize = (1 - 1) * envelope_size;
8884
8885            // Zero reserved fields.
8886            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8887
8888            // Safety:
8889            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8890            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8891            //   envelope_size bytes, there is always sufficient room.
8892            fidl::encoding::encode_in_envelope_optional::<u32, D>(
8893                self.priority.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
8894                encoder,
8895                offset + cur_offset,
8896                depth,
8897            )?;
8898
8899            _prev_end_offset = cur_offset + envelope_size;
8900            if 2 > max_ordinal {
8901                return Ok(());
8902            }
8903
8904            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8905            // are envelope_size bytes.
8906            let cur_offset: usize = (2 - 1) * envelope_size;
8907
8908            // Zero reserved fields.
8909            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8910
8911            // Safety:
8912            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8913            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8914            //   envelope_size bytes, there is always sufficient room.
8915            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<64>, D>(
8916                self.name.as_ref().map(
8917                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
8918                ),
8919                encoder,
8920                offset + cur_offset,
8921                depth,
8922            )?;
8923
8924            _prev_end_offset = cur_offset + envelope_size;
8925
8926            Ok(())
8927        }
8928    }
8929
8930    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NodeSetNameRequest {
8931        #[inline(always)]
8932        fn new_empty() -> Self {
8933            Self::default()
8934        }
8935
8936        unsafe fn decode(
8937            &mut self,
8938            decoder: &mut fidl::encoding::Decoder<'_, D>,
8939            offset: usize,
8940            mut depth: fidl::encoding::Depth,
8941        ) -> fidl::Result<()> {
8942            decoder.debug_check_bounds::<Self>(offset);
8943            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8944                None => return Err(fidl::Error::NotNullable),
8945                Some(len) => len,
8946            };
8947            // Calling decoder.out_of_line_offset(0) is not allowed.
8948            if len == 0 {
8949                return Ok(());
8950            };
8951            depth.increment()?;
8952            let envelope_size = 8;
8953            let bytes_len = len * envelope_size;
8954            let offset = decoder.out_of_line_offset(bytes_len)?;
8955            // Decode the envelope for each type.
8956            let mut _next_ordinal_to_read = 0;
8957            let mut next_offset = offset;
8958            let end_offset = offset + bytes_len;
8959            _next_ordinal_to_read += 1;
8960            if next_offset >= end_offset {
8961                return Ok(());
8962            }
8963
8964            // Decode unknown envelopes for gaps in ordinals.
8965            while _next_ordinal_to_read < 1 {
8966                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8967                _next_ordinal_to_read += 1;
8968                next_offset += envelope_size;
8969            }
8970
8971            let next_out_of_line = decoder.next_out_of_line();
8972            let handles_before = decoder.remaining_handles();
8973            if let Some((inlined, num_bytes, num_handles)) =
8974                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8975            {
8976                let member_inline_size =
8977                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8978                if inlined != (member_inline_size <= 4) {
8979                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8980                }
8981                let inner_offset;
8982                let mut inner_depth = depth.clone();
8983                if inlined {
8984                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8985                    inner_offset = next_offset;
8986                } else {
8987                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8988                    inner_depth.increment()?;
8989                }
8990                let val_ref = self.priority.get_or_insert_with(|| fidl::new_empty!(u32, D));
8991                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
8992                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8993                {
8994                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8995                }
8996                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8997                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8998                }
8999            }
9000
9001            next_offset += envelope_size;
9002            _next_ordinal_to_read += 1;
9003            if next_offset >= end_offset {
9004                return Ok(());
9005            }
9006
9007            // Decode unknown envelopes for gaps in ordinals.
9008            while _next_ordinal_to_read < 2 {
9009                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9010                _next_ordinal_to_read += 1;
9011                next_offset += envelope_size;
9012            }
9013
9014            let next_out_of_line = decoder.next_out_of_line();
9015            let handles_before = decoder.remaining_handles();
9016            if let Some((inlined, num_bytes, num_handles)) =
9017                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9018            {
9019                let member_inline_size =
9020                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
9021                        decoder.context,
9022                    );
9023                if inlined != (member_inline_size <= 4) {
9024                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9025                }
9026                let inner_offset;
9027                let mut inner_depth = depth.clone();
9028                if inlined {
9029                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9030                    inner_offset = next_offset;
9031                } else {
9032                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9033                    inner_depth.increment()?;
9034                }
9035                let val_ref = self
9036                    .name
9037                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<64>, D));
9038                fidl::decode!(
9039                    fidl::encoding::BoundedString<64>,
9040                    D,
9041                    val_ref,
9042                    decoder,
9043                    inner_offset,
9044                    inner_depth
9045                )?;
9046                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9047                {
9048                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9049                }
9050                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9051                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9052                }
9053            }
9054
9055            next_offset += envelope_size;
9056
9057            // Decode the remaining unknown envelopes.
9058            while next_offset < end_offset {
9059                _next_ordinal_to_read += 1;
9060                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9061                next_offset += envelope_size;
9062            }
9063
9064            Ok(())
9065        }
9066    }
9067
9068    impl NodeGetBufferCollectionIdResponse {
9069        #[inline(always)]
9070        fn max_ordinal_present(&self) -> u64 {
9071            if let Some(_) = self.buffer_collection_id {
9072                return 1;
9073            }
9074            0
9075        }
9076    }
9077
9078    impl fidl::encoding::ValueTypeMarker for NodeGetBufferCollectionIdResponse {
9079        type Borrowed<'a> = &'a Self;
9080        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9081            value
9082        }
9083    }
9084
9085    unsafe impl fidl::encoding::TypeMarker for NodeGetBufferCollectionIdResponse {
9086        type Owned = Self;
9087
9088        #[inline(always)]
9089        fn inline_align(_context: fidl::encoding::Context) -> usize {
9090            8
9091        }
9092
9093        #[inline(always)]
9094        fn inline_size(_context: fidl::encoding::Context) -> usize {
9095            16
9096        }
9097    }
9098
9099    unsafe impl<D: fidl::encoding::ResourceDialect>
9100        fidl::encoding::Encode<NodeGetBufferCollectionIdResponse, D>
9101        for &NodeGetBufferCollectionIdResponse
9102    {
9103        unsafe fn encode(
9104            self,
9105            encoder: &mut fidl::encoding::Encoder<'_, D>,
9106            offset: usize,
9107            mut depth: fidl::encoding::Depth,
9108        ) -> fidl::Result<()> {
9109            encoder.debug_check_bounds::<NodeGetBufferCollectionIdResponse>(offset);
9110            // Vector header
9111            let max_ordinal: u64 = self.max_ordinal_present();
9112            encoder.write_num(max_ordinal, offset);
9113            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9114            // Calling encoder.out_of_line_offset(0) is not allowed.
9115            if max_ordinal == 0 {
9116                return Ok(());
9117            }
9118            depth.increment()?;
9119            let envelope_size = 8;
9120            let bytes_len = max_ordinal as usize * envelope_size;
9121            #[allow(unused_variables)]
9122            let offset = encoder.out_of_line_offset(bytes_len);
9123            let mut _prev_end_offset: usize = 0;
9124            if 1 > max_ordinal {
9125                return Ok(());
9126            }
9127
9128            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9129            // are envelope_size bytes.
9130            let cur_offset: usize = (1 - 1) * envelope_size;
9131
9132            // Zero reserved fields.
9133            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9134
9135            // Safety:
9136            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9137            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9138            //   envelope_size bytes, there is always sufficient room.
9139            fidl::encoding::encode_in_envelope_optional::<u64, D>(
9140                self.buffer_collection_id
9141                    .as_ref()
9142                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9143                encoder,
9144                offset + cur_offset,
9145                depth,
9146            )?;
9147
9148            _prev_end_offset = cur_offset + envelope_size;
9149
9150            Ok(())
9151        }
9152    }
9153
9154    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9155        for NodeGetBufferCollectionIdResponse
9156    {
9157        #[inline(always)]
9158        fn new_empty() -> Self {
9159            Self::default()
9160        }
9161
9162        unsafe fn decode(
9163            &mut self,
9164            decoder: &mut fidl::encoding::Decoder<'_, D>,
9165            offset: usize,
9166            mut depth: fidl::encoding::Depth,
9167        ) -> fidl::Result<()> {
9168            decoder.debug_check_bounds::<Self>(offset);
9169            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9170                None => return Err(fidl::Error::NotNullable),
9171                Some(len) => len,
9172            };
9173            // Calling decoder.out_of_line_offset(0) is not allowed.
9174            if len == 0 {
9175                return Ok(());
9176            };
9177            depth.increment()?;
9178            let envelope_size = 8;
9179            let bytes_len = len * envelope_size;
9180            let offset = decoder.out_of_line_offset(bytes_len)?;
9181            // Decode the envelope for each type.
9182            let mut _next_ordinal_to_read = 0;
9183            let mut next_offset = offset;
9184            let end_offset = offset + bytes_len;
9185            _next_ordinal_to_read += 1;
9186            if next_offset >= end_offset {
9187                return Ok(());
9188            }
9189
9190            // Decode unknown envelopes for gaps in ordinals.
9191            while _next_ordinal_to_read < 1 {
9192                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9193                _next_ordinal_to_read += 1;
9194                next_offset += envelope_size;
9195            }
9196
9197            let next_out_of_line = decoder.next_out_of_line();
9198            let handles_before = decoder.remaining_handles();
9199            if let Some((inlined, num_bytes, num_handles)) =
9200                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9201            {
9202                let member_inline_size =
9203                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9204                if inlined != (member_inline_size <= 4) {
9205                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9206                }
9207                let inner_offset;
9208                let mut inner_depth = depth.clone();
9209                if inlined {
9210                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9211                    inner_offset = next_offset;
9212                } else {
9213                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9214                    inner_depth.increment()?;
9215                }
9216                let val_ref =
9217                    self.buffer_collection_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
9218                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
9219                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9220                {
9221                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9222                }
9223                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9224                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9225                }
9226            }
9227
9228            next_offset += envelope_size;
9229
9230            // Decode the remaining unknown envelopes.
9231            while next_offset < end_offset {
9232                _next_ordinal_to_read += 1;
9233                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9234                next_offset += envelope_size;
9235            }
9236
9237            Ok(())
9238        }
9239    }
9240
9241    impl NodeIsAlternateForResponse {
9242        #[inline(always)]
9243        fn max_ordinal_present(&self) -> u64 {
9244            if let Some(_) = self.is_alternate {
9245                return 1;
9246            }
9247            0
9248        }
9249    }
9250
9251    impl fidl::encoding::ValueTypeMarker for NodeIsAlternateForResponse {
9252        type Borrowed<'a> = &'a Self;
9253        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9254            value
9255        }
9256    }
9257
9258    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForResponse {
9259        type Owned = Self;
9260
9261        #[inline(always)]
9262        fn inline_align(_context: fidl::encoding::Context) -> usize {
9263            8
9264        }
9265
9266        #[inline(always)]
9267        fn inline_size(_context: fidl::encoding::Context) -> usize {
9268            16
9269        }
9270    }
9271
9272    unsafe impl<D: fidl::encoding::ResourceDialect>
9273        fidl::encoding::Encode<NodeIsAlternateForResponse, D> for &NodeIsAlternateForResponse
9274    {
9275        unsafe fn encode(
9276            self,
9277            encoder: &mut fidl::encoding::Encoder<'_, D>,
9278            offset: usize,
9279            mut depth: fidl::encoding::Depth,
9280        ) -> fidl::Result<()> {
9281            encoder.debug_check_bounds::<NodeIsAlternateForResponse>(offset);
9282            // Vector header
9283            let max_ordinal: u64 = self.max_ordinal_present();
9284            encoder.write_num(max_ordinal, offset);
9285            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9286            // Calling encoder.out_of_line_offset(0) is not allowed.
9287            if max_ordinal == 0 {
9288                return Ok(());
9289            }
9290            depth.increment()?;
9291            let envelope_size = 8;
9292            let bytes_len = max_ordinal as usize * envelope_size;
9293            #[allow(unused_variables)]
9294            let offset = encoder.out_of_line_offset(bytes_len);
9295            let mut _prev_end_offset: usize = 0;
9296            if 1 > max_ordinal {
9297                return Ok(());
9298            }
9299
9300            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9301            // are envelope_size bytes.
9302            let cur_offset: usize = (1 - 1) * envelope_size;
9303
9304            // Zero reserved fields.
9305            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9306
9307            // Safety:
9308            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9309            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9310            //   envelope_size bytes, there is always sufficient room.
9311            fidl::encoding::encode_in_envelope_optional::<bool, D>(
9312                self.is_alternate.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
9313                encoder,
9314                offset + cur_offset,
9315                depth,
9316            )?;
9317
9318            _prev_end_offset = cur_offset + envelope_size;
9319
9320            Ok(())
9321        }
9322    }
9323
9324    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9325        for NodeIsAlternateForResponse
9326    {
9327        #[inline(always)]
9328        fn new_empty() -> Self {
9329            Self::default()
9330        }
9331
9332        unsafe fn decode(
9333            &mut self,
9334            decoder: &mut fidl::encoding::Decoder<'_, D>,
9335            offset: usize,
9336            mut depth: fidl::encoding::Depth,
9337        ) -> fidl::Result<()> {
9338            decoder.debug_check_bounds::<Self>(offset);
9339            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9340                None => return Err(fidl::Error::NotNullable),
9341                Some(len) => len,
9342            };
9343            // Calling decoder.out_of_line_offset(0) is not allowed.
9344            if len == 0 {
9345                return Ok(());
9346            };
9347            depth.increment()?;
9348            let envelope_size = 8;
9349            let bytes_len = len * envelope_size;
9350            let offset = decoder.out_of_line_offset(bytes_len)?;
9351            // Decode the envelope for each type.
9352            let mut _next_ordinal_to_read = 0;
9353            let mut next_offset = offset;
9354            let end_offset = offset + bytes_len;
9355            _next_ordinal_to_read += 1;
9356            if next_offset >= end_offset {
9357                return Ok(());
9358            }
9359
9360            // Decode unknown envelopes for gaps in ordinals.
9361            while _next_ordinal_to_read < 1 {
9362                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9363                _next_ordinal_to_read += 1;
9364                next_offset += envelope_size;
9365            }
9366
9367            let next_out_of_line = decoder.next_out_of_line();
9368            let handles_before = decoder.remaining_handles();
9369            if let Some((inlined, num_bytes, num_handles)) =
9370                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9371            {
9372                let member_inline_size =
9373                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9374                if inlined != (member_inline_size <= 4) {
9375                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9376                }
9377                let inner_offset;
9378                let mut inner_depth = depth.clone();
9379                if inlined {
9380                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9381                    inner_offset = next_offset;
9382                } else {
9383                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9384                    inner_depth.increment()?;
9385                }
9386                let val_ref = self.is_alternate.get_or_insert_with(|| fidl::new_empty!(bool, D));
9387                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
9388                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9389                {
9390                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9391                }
9392                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9393                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9394                }
9395            }
9396
9397            next_offset += envelope_size;
9398
9399            // Decode the remaining unknown envelopes.
9400            while next_offset < end_offset {
9401                _next_ordinal_to_read += 1;
9402                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9403                next_offset += envelope_size;
9404            }
9405
9406            Ok(())
9407        }
9408    }
9409
9410    impl SecureHeapAndRange {
9411        #[inline(always)]
9412        fn max_ordinal_present(&self) -> u64 {
9413            if let Some(_) = self.range {
9414                return 2;
9415            }
9416            if let Some(_) = self.heap {
9417                return 1;
9418            }
9419            0
9420        }
9421    }
9422
9423    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRange {
9424        type Borrowed<'a> = &'a Self;
9425        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9426            value
9427        }
9428    }
9429
9430    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRange {
9431        type Owned = Self;
9432
9433        #[inline(always)]
9434        fn inline_align(_context: fidl::encoding::Context) -> usize {
9435            8
9436        }
9437
9438        #[inline(always)]
9439        fn inline_size(_context: fidl::encoding::Context) -> usize {
9440            16
9441        }
9442    }
9443
9444    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapAndRange, D>
9445        for &SecureHeapAndRange
9446    {
9447        unsafe fn encode(
9448            self,
9449            encoder: &mut fidl::encoding::Encoder<'_, D>,
9450            offset: usize,
9451            mut depth: fidl::encoding::Depth,
9452        ) -> fidl::Result<()> {
9453            encoder.debug_check_bounds::<SecureHeapAndRange>(offset);
9454            // Vector header
9455            let max_ordinal: u64 = self.max_ordinal_present();
9456            encoder.write_num(max_ordinal, offset);
9457            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9458            // Calling encoder.out_of_line_offset(0) is not allowed.
9459            if max_ordinal == 0 {
9460                return Ok(());
9461            }
9462            depth.increment()?;
9463            let envelope_size = 8;
9464            let bytes_len = max_ordinal as usize * envelope_size;
9465            #[allow(unused_variables)]
9466            let offset = encoder.out_of_line_offset(bytes_len);
9467            let mut _prev_end_offset: usize = 0;
9468            if 1 > max_ordinal {
9469                return Ok(());
9470            }
9471
9472            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9473            // are envelope_size bytes.
9474            let cur_offset: usize = (1 - 1) * envelope_size;
9475
9476            // Zero reserved fields.
9477            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9478
9479            // Safety:
9480            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9481            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9482            //   envelope_size bytes, there is always sufficient room.
9483            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9484                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9485                encoder,
9486                offset + cur_offset,
9487                depth,
9488            )?;
9489
9490            _prev_end_offset = cur_offset + envelope_size;
9491            if 2 > max_ordinal {
9492                return Ok(());
9493            }
9494
9495            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9496            // are envelope_size bytes.
9497            let cur_offset: usize = (2 - 1) * envelope_size;
9498
9499            // Zero reserved fields.
9500            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9501
9502            // Safety:
9503            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9504            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9505            //   envelope_size bytes, there is always sufficient room.
9506            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9507                self.range
9508                    .as_ref()
9509                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9510                encoder,
9511                offset + cur_offset,
9512                depth,
9513            )?;
9514
9515            _prev_end_offset = cur_offset + envelope_size;
9516
9517            Ok(())
9518        }
9519    }
9520
9521    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapAndRange {
9522        #[inline(always)]
9523        fn new_empty() -> Self {
9524            Self::default()
9525        }
9526
9527        unsafe fn decode(
9528            &mut self,
9529            decoder: &mut fidl::encoding::Decoder<'_, D>,
9530            offset: usize,
9531            mut depth: fidl::encoding::Depth,
9532        ) -> fidl::Result<()> {
9533            decoder.debug_check_bounds::<Self>(offset);
9534            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9535                None => return Err(fidl::Error::NotNullable),
9536                Some(len) => len,
9537            };
9538            // Calling decoder.out_of_line_offset(0) is not allowed.
9539            if len == 0 {
9540                return Ok(());
9541            };
9542            depth.increment()?;
9543            let envelope_size = 8;
9544            let bytes_len = len * envelope_size;
9545            let offset = decoder.out_of_line_offset(bytes_len)?;
9546            // Decode the envelope for each type.
9547            let mut _next_ordinal_to_read = 0;
9548            let mut next_offset = offset;
9549            let end_offset = offset + bytes_len;
9550            _next_ordinal_to_read += 1;
9551            if next_offset >= end_offset {
9552                return Ok(());
9553            }
9554
9555            // Decode unknown envelopes for gaps in ordinals.
9556            while _next_ordinal_to_read < 1 {
9557                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9558                _next_ordinal_to_read += 1;
9559                next_offset += envelope_size;
9560            }
9561
9562            let next_out_of_line = decoder.next_out_of_line();
9563            let handles_before = decoder.remaining_handles();
9564            if let Some((inlined, num_bytes, num_handles)) =
9565                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9566            {
9567                let member_inline_size =
9568                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9569                if inlined != (member_inline_size <= 4) {
9570                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9571                }
9572                let inner_offset;
9573                let mut inner_depth = depth.clone();
9574                if inlined {
9575                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9576                    inner_offset = next_offset;
9577                } else {
9578                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9579                    inner_depth.increment()?;
9580                }
9581                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9582                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9583                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9584                {
9585                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9586                }
9587                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9588                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9589                }
9590            }
9591
9592            next_offset += envelope_size;
9593            _next_ordinal_to_read += 1;
9594            if next_offset >= end_offset {
9595                return Ok(());
9596            }
9597
9598            // Decode unknown envelopes for gaps in ordinals.
9599            while _next_ordinal_to_read < 2 {
9600                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9601                _next_ordinal_to_read += 1;
9602                next_offset += envelope_size;
9603            }
9604
9605            let next_out_of_line = decoder.next_out_of_line();
9606            let handles_before = decoder.remaining_handles();
9607            if let Some((inlined, num_bytes, num_handles)) =
9608                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9609            {
9610                let member_inline_size =
9611                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9612                if inlined != (member_inline_size <= 4) {
9613                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9614                }
9615                let inner_offset;
9616                let mut inner_depth = depth.clone();
9617                if inlined {
9618                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9619                    inner_offset = next_offset;
9620                } else {
9621                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9622                    inner_depth.increment()?;
9623                }
9624                let val_ref =
9625                    self.range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9626                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9627                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9628                {
9629                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9630                }
9631                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9632                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9633                }
9634            }
9635
9636            next_offset += envelope_size;
9637
9638            // Decode the remaining unknown envelopes.
9639            while next_offset < end_offset {
9640                _next_ordinal_to_read += 1;
9641                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9642                next_offset += envelope_size;
9643            }
9644
9645            Ok(())
9646        }
9647    }
9648
9649    impl SecureHeapAndRangeModification {
9650        #[inline(always)]
9651        fn max_ordinal_present(&self) -> u64 {
9652            if let Some(_) = self.new_range {
9653                return 3;
9654            }
9655            if let Some(_) = self.old_range {
9656                return 2;
9657            }
9658            if let Some(_) = self.heap {
9659                return 1;
9660            }
9661            0
9662        }
9663    }
9664
9665    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRangeModification {
9666        type Borrowed<'a> = &'a Self;
9667        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9668            value
9669        }
9670    }
9671
9672    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRangeModification {
9673        type Owned = Self;
9674
9675        #[inline(always)]
9676        fn inline_align(_context: fidl::encoding::Context) -> usize {
9677            8
9678        }
9679
9680        #[inline(always)]
9681        fn inline_size(_context: fidl::encoding::Context) -> usize {
9682            16
9683        }
9684    }
9685
9686    unsafe impl<D: fidl::encoding::ResourceDialect>
9687        fidl::encoding::Encode<SecureHeapAndRangeModification, D>
9688        for &SecureHeapAndRangeModification
9689    {
9690        unsafe fn encode(
9691            self,
9692            encoder: &mut fidl::encoding::Encoder<'_, D>,
9693            offset: usize,
9694            mut depth: fidl::encoding::Depth,
9695        ) -> fidl::Result<()> {
9696            encoder.debug_check_bounds::<SecureHeapAndRangeModification>(offset);
9697            // Vector header
9698            let max_ordinal: u64 = self.max_ordinal_present();
9699            encoder.write_num(max_ordinal, offset);
9700            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9701            // Calling encoder.out_of_line_offset(0) is not allowed.
9702            if max_ordinal == 0 {
9703                return Ok(());
9704            }
9705            depth.increment()?;
9706            let envelope_size = 8;
9707            let bytes_len = max_ordinal as usize * envelope_size;
9708            #[allow(unused_variables)]
9709            let offset = encoder.out_of_line_offset(bytes_len);
9710            let mut _prev_end_offset: usize = 0;
9711            if 1 > max_ordinal {
9712                return Ok(());
9713            }
9714
9715            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9716            // are envelope_size bytes.
9717            let cur_offset: usize = (1 - 1) * envelope_size;
9718
9719            // Zero reserved fields.
9720            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9721
9722            // Safety:
9723            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9724            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9725            //   envelope_size bytes, there is always sufficient room.
9726            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
9727                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
9728                encoder,
9729                offset + cur_offset,
9730                depth,
9731            )?;
9732
9733            _prev_end_offset = cur_offset + envelope_size;
9734            if 2 > max_ordinal {
9735                return Ok(());
9736            }
9737
9738            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9739            // are envelope_size bytes.
9740            let cur_offset: usize = (2 - 1) * envelope_size;
9741
9742            // Zero reserved fields.
9743            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9744
9745            // Safety:
9746            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9747            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9748            //   envelope_size bytes, there is always sufficient room.
9749            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9750                self.old_range
9751                    .as_ref()
9752                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9753                encoder,
9754                offset + cur_offset,
9755                depth,
9756            )?;
9757
9758            _prev_end_offset = cur_offset + envelope_size;
9759            if 3 > max_ordinal {
9760                return Ok(());
9761            }
9762
9763            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9764            // are envelope_size bytes.
9765            let cur_offset: usize = (3 - 1) * envelope_size;
9766
9767            // Zero reserved fields.
9768            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9769
9770            // Safety:
9771            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9772            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9773            //   envelope_size bytes, there is always sufficient room.
9774            fidl::encoding::encode_in_envelope_optional::<SecureHeapRange, D>(
9775                self.new_range
9776                    .as_ref()
9777                    .map(<SecureHeapRange as fidl::encoding::ValueTypeMarker>::borrow),
9778                encoder,
9779                offset + cur_offset,
9780                depth,
9781            )?;
9782
9783            _prev_end_offset = cur_offset + envelope_size;
9784
9785            Ok(())
9786        }
9787    }
9788
9789    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
9790        for SecureHeapAndRangeModification
9791    {
9792        #[inline(always)]
9793        fn new_empty() -> Self {
9794            Self::default()
9795        }
9796
9797        unsafe fn decode(
9798            &mut self,
9799            decoder: &mut fidl::encoding::Decoder<'_, D>,
9800            offset: usize,
9801            mut depth: fidl::encoding::Depth,
9802        ) -> fidl::Result<()> {
9803            decoder.debug_check_bounds::<Self>(offset);
9804            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9805                None => return Err(fidl::Error::NotNullable),
9806                Some(len) => len,
9807            };
9808            // Calling decoder.out_of_line_offset(0) is not allowed.
9809            if len == 0 {
9810                return Ok(());
9811            };
9812            depth.increment()?;
9813            let envelope_size = 8;
9814            let bytes_len = len * envelope_size;
9815            let offset = decoder.out_of_line_offset(bytes_len)?;
9816            // Decode the envelope for each type.
9817            let mut _next_ordinal_to_read = 0;
9818            let mut next_offset = offset;
9819            let end_offset = offset + bytes_len;
9820            _next_ordinal_to_read += 1;
9821            if next_offset >= end_offset {
9822                return Ok(());
9823            }
9824
9825            // Decode unknown envelopes for gaps in ordinals.
9826            while _next_ordinal_to_read < 1 {
9827                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9828                _next_ordinal_to_read += 1;
9829                next_offset += envelope_size;
9830            }
9831
9832            let next_out_of_line = decoder.next_out_of_line();
9833            let handles_before = decoder.remaining_handles();
9834            if let Some((inlined, num_bytes, num_handles)) =
9835                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9836            {
9837                let member_inline_size =
9838                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9839                if inlined != (member_inline_size <= 4) {
9840                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9841                }
9842                let inner_offset;
9843                let mut inner_depth = depth.clone();
9844                if inlined {
9845                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9846                    inner_offset = next_offset;
9847                } else {
9848                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9849                    inner_depth.increment()?;
9850                }
9851                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
9852                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
9853                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9854                {
9855                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9856                }
9857                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9858                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9859                }
9860            }
9861
9862            next_offset += envelope_size;
9863            _next_ordinal_to_read += 1;
9864            if next_offset >= end_offset {
9865                return Ok(());
9866            }
9867
9868            // Decode unknown envelopes for gaps in ordinals.
9869            while _next_ordinal_to_read < 2 {
9870                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9871                _next_ordinal_to_read += 1;
9872                next_offset += envelope_size;
9873            }
9874
9875            let next_out_of_line = decoder.next_out_of_line();
9876            let handles_before = decoder.remaining_handles();
9877            if let Some((inlined, num_bytes, num_handles)) =
9878                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9879            {
9880                let member_inline_size =
9881                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9882                if inlined != (member_inline_size <= 4) {
9883                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9884                }
9885                let inner_offset;
9886                let mut inner_depth = depth.clone();
9887                if inlined {
9888                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9889                    inner_offset = next_offset;
9890                } else {
9891                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9892                    inner_depth.increment()?;
9893                }
9894                let val_ref =
9895                    self.old_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9896                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9897                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9898                {
9899                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9900                }
9901                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9902                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9903                }
9904            }
9905
9906            next_offset += envelope_size;
9907            _next_ordinal_to_read += 1;
9908            if next_offset >= end_offset {
9909                return Ok(());
9910            }
9911
9912            // Decode unknown envelopes for gaps in ordinals.
9913            while _next_ordinal_to_read < 3 {
9914                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9915                _next_ordinal_to_read += 1;
9916                next_offset += envelope_size;
9917            }
9918
9919            let next_out_of_line = decoder.next_out_of_line();
9920            let handles_before = decoder.remaining_handles();
9921            if let Some((inlined, num_bytes, num_handles)) =
9922                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9923            {
9924                let member_inline_size =
9925                    <SecureHeapRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9926                if inlined != (member_inline_size <= 4) {
9927                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9928                }
9929                let inner_offset;
9930                let mut inner_depth = depth.clone();
9931                if inlined {
9932                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9933                    inner_offset = next_offset;
9934                } else {
9935                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9936                    inner_depth.increment()?;
9937                }
9938                let val_ref =
9939                    self.new_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapRange, D));
9940                fidl::decode!(SecureHeapRange, D, val_ref, decoder, inner_offset, inner_depth)?;
9941                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9942                {
9943                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9944                }
9945                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9946                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9947                }
9948            }
9949
9950            next_offset += envelope_size;
9951
9952            // Decode the remaining unknown envelopes.
9953            while next_offset < end_offset {
9954                _next_ordinal_to_read += 1;
9955                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9956                next_offset += envelope_size;
9957            }
9958
9959            Ok(())
9960        }
9961    }
9962
9963    impl SecureHeapAndRanges {
9964        #[inline(always)]
9965        fn max_ordinal_present(&self) -> u64 {
9966            if let Some(_) = self.ranges {
9967                return 2;
9968            }
9969            if let Some(_) = self.heap {
9970                return 1;
9971            }
9972            0
9973        }
9974    }
9975
9976    impl fidl::encoding::ValueTypeMarker for SecureHeapAndRanges {
9977        type Borrowed<'a> = &'a Self;
9978        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
9979            value
9980        }
9981    }
9982
9983    unsafe impl fidl::encoding::TypeMarker for SecureHeapAndRanges {
9984        type Owned = Self;
9985
9986        #[inline(always)]
9987        fn inline_align(_context: fidl::encoding::Context) -> usize {
9988            8
9989        }
9990
9991        #[inline(always)]
9992        fn inline_size(_context: fidl::encoding::Context) -> usize {
9993            16
9994        }
9995    }
9996
9997    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapAndRanges, D>
9998        for &SecureHeapAndRanges
9999    {
10000        unsafe fn encode(
10001            self,
10002            encoder: &mut fidl::encoding::Encoder<'_, D>,
10003            offset: usize,
10004            mut depth: fidl::encoding::Depth,
10005        ) -> fidl::Result<()> {
10006            encoder.debug_check_bounds::<SecureHeapAndRanges>(offset);
10007            // Vector header
10008            let max_ordinal: u64 = self.max_ordinal_present();
10009            encoder.write_num(max_ordinal, offset);
10010            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10011            // Calling encoder.out_of_line_offset(0) is not allowed.
10012            if max_ordinal == 0 {
10013                return Ok(());
10014            }
10015            depth.increment()?;
10016            let envelope_size = 8;
10017            let bytes_len = max_ordinal as usize * envelope_size;
10018            #[allow(unused_variables)]
10019            let offset = encoder.out_of_line_offset(bytes_len);
10020            let mut _prev_end_offset: usize = 0;
10021            if 1 > max_ordinal {
10022                return Ok(());
10023            }
10024
10025            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10026            // are envelope_size bytes.
10027            let cur_offset: usize = (1 - 1) * envelope_size;
10028
10029            // Zero reserved fields.
10030            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10031
10032            // Safety:
10033            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10034            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10035            //   envelope_size bytes, there is always sufficient room.
10036            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
10037                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
10038                encoder,
10039                offset + cur_offset,
10040                depth,
10041            )?;
10042
10043            _prev_end_offset = cur_offset + envelope_size;
10044            if 2 > max_ordinal {
10045                return Ok(());
10046            }
10047
10048            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10049            // are envelope_size bytes.
10050            let cur_offset: usize = (2 - 1) * envelope_size;
10051
10052            // Zero reserved fields.
10053            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10054
10055            // Safety:
10056            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10057            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10058            //   envelope_size bytes, there is always sufficient room.
10059            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SecureHeapRange, 128>, D>(
10060            self.ranges.as_ref().map(<fidl::encoding::Vector<SecureHeapRange, 128> as fidl::encoding::ValueTypeMarker>::borrow),
10061            encoder, offset + cur_offset, depth
10062        )?;
10063
10064            _prev_end_offset = cur_offset + envelope_size;
10065
10066            Ok(())
10067        }
10068    }
10069
10070    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapAndRanges {
10071        #[inline(always)]
10072        fn new_empty() -> Self {
10073            Self::default()
10074        }
10075
10076        unsafe fn decode(
10077            &mut self,
10078            decoder: &mut fidl::encoding::Decoder<'_, D>,
10079            offset: usize,
10080            mut depth: fidl::encoding::Depth,
10081        ) -> fidl::Result<()> {
10082            decoder.debug_check_bounds::<Self>(offset);
10083            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10084                None => return Err(fidl::Error::NotNullable),
10085                Some(len) => len,
10086            };
10087            // Calling decoder.out_of_line_offset(0) is not allowed.
10088            if len == 0 {
10089                return Ok(());
10090            };
10091            depth.increment()?;
10092            let envelope_size = 8;
10093            let bytes_len = len * envelope_size;
10094            let offset = decoder.out_of_line_offset(bytes_len)?;
10095            // Decode the envelope for each type.
10096            let mut _next_ordinal_to_read = 0;
10097            let mut next_offset = offset;
10098            let end_offset = offset + bytes_len;
10099            _next_ordinal_to_read += 1;
10100            if next_offset >= end_offset {
10101                return Ok(());
10102            }
10103
10104            // Decode unknown envelopes for gaps in ordinals.
10105            while _next_ordinal_to_read < 1 {
10106                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10107                _next_ordinal_to_read += 1;
10108                next_offset += envelope_size;
10109            }
10110
10111            let next_out_of_line = decoder.next_out_of_line();
10112            let handles_before = decoder.remaining_handles();
10113            if let Some((inlined, num_bytes, num_handles)) =
10114                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10115            {
10116                let member_inline_size =
10117                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10118                if inlined != (member_inline_size <= 4) {
10119                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10120                }
10121                let inner_offset;
10122                let mut inner_depth = depth.clone();
10123                if inlined {
10124                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10125                    inner_offset = next_offset;
10126                } else {
10127                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10128                    inner_depth.increment()?;
10129                }
10130                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
10131                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
10132                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10133                {
10134                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10135                }
10136                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10137                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10138                }
10139            }
10140
10141            next_offset += envelope_size;
10142            _next_ordinal_to_read += 1;
10143            if next_offset >= end_offset {
10144                return Ok(());
10145            }
10146
10147            // Decode unknown envelopes for gaps in ordinals.
10148            while _next_ordinal_to_read < 2 {
10149                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10150                _next_ordinal_to_read += 1;
10151                next_offset += envelope_size;
10152            }
10153
10154            let next_out_of_line = decoder.next_out_of_line();
10155            let handles_before = decoder.remaining_handles();
10156            if let Some((inlined, num_bytes, num_handles)) =
10157                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10158            {
10159                let member_inline_size = <fidl::encoding::Vector<SecureHeapRange, 128> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10160                if inlined != (member_inline_size <= 4) {
10161                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10162                }
10163                let inner_offset;
10164                let mut inner_depth = depth.clone();
10165                if inlined {
10166                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10167                    inner_offset = next_offset;
10168                } else {
10169                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10170                    inner_depth.increment()?;
10171                }
10172                let val_ref = self.ranges.get_or_insert_with(
10173                    || fidl::new_empty!(fidl::encoding::Vector<SecureHeapRange, 128>, D),
10174                );
10175                fidl::decode!(fidl::encoding::Vector<SecureHeapRange, 128>, D, val_ref, decoder, inner_offset, inner_depth)?;
10176                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10177                {
10178                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10179                }
10180                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10181                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10182                }
10183            }
10184
10185            next_offset += envelope_size;
10186
10187            // Decode the remaining unknown envelopes.
10188            while next_offset < end_offset {
10189                _next_ordinal_to_read += 1;
10190                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10191                next_offset += envelope_size;
10192            }
10193
10194            Ok(())
10195        }
10196    }
10197
10198    impl SecureHeapProperties {
10199        #[inline(always)]
10200        fn max_ordinal_present(&self) -> u64 {
10201            if let Some(_) = self.is_mod_protected_range_available {
10202                return 5;
10203            }
10204            if let Some(_) = self.max_protected_range_count {
10205                return 4;
10206            }
10207            if let Some(_) = self.protected_range_granularity {
10208                return 3;
10209            }
10210            if let Some(_) = self.dynamic_protection_ranges {
10211                return 2;
10212            }
10213            if let Some(_) = self.heap {
10214                return 1;
10215            }
10216            0
10217        }
10218    }
10219
10220    impl fidl::encoding::ValueTypeMarker for SecureHeapProperties {
10221        type Borrowed<'a> = &'a Self;
10222        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10223            value
10224        }
10225    }
10226
10227    unsafe impl fidl::encoding::TypeMarker for SecureHeapProperties {
10228        type Owned = Self;
10229
10230        #[inline(always)]
10231        fn inline_align(_context: fidl::encoding::Context) -> usize {
10232            8
10233        }
10234
10235        #[inline(always)]
10236        fn inline_size(_context: fidl::encoding::Context) -> usize {
10237            16
10238        }
10239    }
10240
10241    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapProperties, D>
10242        for &SecureHeapProperties
10243    {
10244        unsafe fn encode(
10245            self,
10246            encoder: &mut fidl::encoding::Encoder<'_, D>,
10247            offset: usize,
10248            mut depth: fidl::encoding::Depth,
10249        ) -> fidl::Result<()> {
10250            encoder.debug_check_bounds::<SecureHeapProperties>(offset);
10251            // Vector header
10252            let max_ordinal: u64 = self.max_ordinal_present();
10253            encoder.write_num(max_ordinal, offset);
10254            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10255            // Calling encoder.out_of_line_offset(0) is not allowed.
10256            if max_ordinal == 0 {
10257                return Ok(());
10258            }
10259            depth.increment()?;
10260            let envelope_size = 8;
10261            let bytes_len = max_ordinal as usize * envelope_size;
10262            #[allow(unused_variables)]
10263            let offset = encoder.out_of_line_offset(bytes_len);
10264            let mut _prev_end_offset: usize = 0;
10265            if 1 > max_ordinal {
10266                return Ok(());
10267            }
10268
10269            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10270            // are envelope_size bytes.
10271            let cur_offset: usize = (1 - 1) * envelope_size;
10272
10273            // Zero reserved fields.
10274            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10275
10276            // Safety:
10277            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10278            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10279            //   envelope_size bytes, there is always sufficient room.
10280            fidl::encoding::encode_in_envelope_optional::<Heap, D>(
10281                self.heap.as_ref().map(<Heap as fidl::encoding::ValueTypeMarker>::borrow),
10282                encoder,
10283                offset + cur_offset,
10284                depth,
10285            )?;
10286
10287            _prev_end_offset = cur_offset + envelope_size;
10288            if 2 > max_ordinal {
10289                return Ok(());
10290            }
10291
10292            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10293            // are envelope_size bytes.
10294            let cur_offset: usize = (2 - 1) * envelope_size;
10295
10296            // Zero reserved fields.
10297            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10298
10299            // Safety:
10300            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10301            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10302            //   envelope_size bytes, there is always sufficient room.
10303            fidl::encoding::encode_in_envelope_optional::<bool, D>(
10304                self.dynamic_protection_ranges
10305                    .as_ref()
10306                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
10307                encoder,
10308                offset + cur_offset,
10309                depth,
10310            )?;
10311
10312            _prev_end_offset = cur_offset + envelope_size;
10313            if 3 > max_ordinal {
10314                return Ok(());
10315            }
10316
10317            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10318            // are envelope_size bytes.
10319            let cur_offset: usize = (3 - 1) * envelope_size;
10320
10321            // Zero reserved fields.
10322            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10323
10324            // Safety:
10325            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10326            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10327            //   envelope_size bytes, there is always sufficient room.
10328            fidl::encoding::encode_in_envelope_optional::<u32, D>(
10329                self.protected_range_granularity
10330                    .as_ref()
10331                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
10332                encoder,
10333                offset + cur_offset,
10334                depth,
10335            )?;
10336
10337            _prev_end_offset = cur_offset + envelope_size;
10338            if 4 > max_ordinal {
10339                return Ok(());
10340            }
10341
10342            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10343            // are envelope_size bytes.
10344            let cur_offset: usize = (4 - 1) * envelope_size;
10345
10346            // Zero reserved fields.
10347            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10348
10349            // Safety:
10350            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10351            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10352            //   envelope_size bytes, there is always sufficient room.
10353            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10354                self.max_protected_range_count
10355                    .as_ref()
10356                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10357                encoder,
10358                offset + cur_offset,
10359                depth,
10360            )?;
10361
10362            _prev_end_offset = cur_offset + envelope_size;
10363            if 5 > max_ordinal {
10364                return Ok(());
10365            }
10366
10367            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10368            // are envelope_size bytes.
10369            let cur_offset: usize = (5 - 1) * envelope_size;
10370
10371            // Zero reserved fields.
10372            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10373
10374            // Safety:
10375            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10376            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10377            //   envelope_size bytes, there is always sufficient room.
10378            fidl::encoding::encode_in_envelope_optional::<bool, D>(
10379                self.is_mod_protected_range_available
10380                    .as_ref()
10381                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
10382                encoder,
10383                offset + cur_offset,
10384                depth,
10385            )?;
10386
10387            _prev_end_offset = cur_offset + envelope_size;
10388
10389            Ok(())
10390        }
10391    }
10392
10393    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapProperties {
10394        #[inline(always)]
10395        fn new_empty() -> Self {
10396            Self::default()
10397        }
10398
10399        unsafe fn decode(
10400            &mut self,
10401            decoder: &mut fidl::encoding::Decoder<'_, D>,
10402            offset: usize,
10403            mut depth: fidl::encoding::Depth,
10404        ) -> fidl::Result<()> {
10405            decoder.debug_check_bounds::<Self>(offset);
10406            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10407                None => return Err(fidl::Error::NotNullable),
10408                Some(len) => len,
10409            };
10410            // Calling decoder.out_of_line_offset(0) is not allowed.
10411            if len == 0 {
10412                return Ok(());
10413            };
10414            depth.increment()?;
10415            let envelope_size = 8;
10416            let bytes_len = len * envelope_size;
10417            let offset = decoder.out_of_line_offset(bytes_len)?;
10418            // Decode the envelope for each type.
10419            let mut _next_ordinal_to_read = 0;
10420            let mut next_offset = offset;
10421            let end_offset = offset + bytes_len;
10422            _next_ordinal_to_read += 1;
10423            if next_offset >= end_offset {
10424                return Ok(());
10425            }
10426
10427            // Decode unknown envelopes for gaps in ordinals.
10428            while _next_ordinal_to_read < 1 {
10429                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10430                _next_ordinal_to_read += 1;
10431                next_offset += envelope_size;
10432            }
10433
10434            let next_out_of_line = decoder.next_out_of_line();
10435            let handles_before = decoder.remaining_handles();
10436            if let Some((inlined, num_bytes, num_handles)) =
10437                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10438            {
10439                let member_inline_size =
10440                    <Heap as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10441                if inlined != (member_inline_size <= 4) {
10442                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10443                }
10444                let inner_offset;
10445                let mut inner_depth = depth.clone();
10446                if inlined {
10447                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10448                    inner_offset = next_offset;
10449                } else {
10450                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10451                    inner_depth.increment()?;
10452                }
10453                let val_ref = self.heap.get_or_insert_with(|| fidl::new_empty!(Heap, D));
10454                fidl::decode!(Heap, D, val_ref, decoder, inner_offset, inner_depth)?;
10455                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10456                {
10457                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10458                }
10459                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10460                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10461                }
10462            }
10463
10464            next_offset += envelope_size;
10465            _next_ordinal_to_read += 1;
10466            if next_offset >= end_offset {
10467                return Ok(());
10468            }
10469
10470            // Decode unknown envelopes for gaps in ordinals.
10471            while _next_ordinal_to_read < 2 {
10472                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10473                _next_ordinal_to_read += 1;
10474                next_offset += envelope_size;
10475            }
10476
10477            let next_out_of_line = decoder.next_out_of_line();
10478            let handles_before = decoder.remaining_handles();
10479            if let Some((inlined, num_bytes, num_handles)) =
10480                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10481            {
10482                let member_inline_size =
10483                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10484                if inlined != (member_inline_size <= 4) {
10485                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10486                }
10487                let inner_offset;
10488                let mut inner_depth = depth.clone();
10489                if inlined {
10490                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10491                    inner_offset = next_offset;
10492                } else {
10493                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10494                    inner_depth.increment()?;
10495                }
10496                let val_ref =
10497                    self.dynamic_protection_ranges.get_or_insert_with(|| fidl::new_empty!(bool, D));
10498                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
10499                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10500                {
10501                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10502                }
10503                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10504                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10505                }
10506            }
10507
10508            next_offset += envelope_size;
10509            _next_ordinal_to_read += 1;
10510            if next_offset >= end_offset {
10511                return Ok(());
10512            }
10513
10514            // Decode unknown envelopes for gaps in ordinals.
10515            while _next_ordinal_to_read < 3 {
10516                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10517                _next_ordinal_to_read += 1;
10518                next_offset += envelope_size;
10519            }
10520
10521            let next_out_of_line = decoder.next_out_of_line();
10522            let handles_before = decoder.remaining_handles();
10523            if let Some((inlined, num_bytes, num_handles)) =
10524                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10525            {
10526                let member_inline_size =
10527                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10528                if inlined != (member_inline_size <= 4) {
10529                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10530                }
10531                let inner_offset;
10532                let mut inner_depth = depth.clone();
10533                if inlined {
10534                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10535                    inner_offset = next_offset;
10536                } else {
10537                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10538                    inner_depth.increment()?;
10539                }
10540                let val_ref = self
10541                    .protected_range_granularity
10542                    .get_or_insert_with(|| fidl::new_empty!(u32, D));
10543                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
10544                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10545                {
10546                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10547                }
10548                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10549                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10550                }
10551            }
10552
10553            next_offset += envelope_size;
10554            _next_ordinal_to_read += 1;
10555            if next_offset >= end_offset {
10556                return Ok(());
10557            }
10558
10559            // Decode unknown envelopes for gaps in ordinals.
10560            while _next_ordinal_to_read < 4 {
10561                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10562                _next_ordinal_to_read += 1;
10563                next_offset += envelope_size;
10564            }
10565
10566            let next_out_of_line = decoder.next_out_of_line();
10567            let handles_before = decoder.remaining_handles();
10568            if let Some((inlined, num_bytes, num_handles)) =
10569                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10570            {
10571                let member_inline_size =
10572                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10573                if inlined != (member_inline_size <= 4) {
10574                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10575                }
10576                let inner_offset;
10577                let mut inner_depth = depth.clone();
10578                if inlined {
10579                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10580                    inner_offset = next_offset;
10581                } else {
10582                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10583                    inner_depth.increment()?;
10584                }
10585                let val_ref =
10586                    self.max_protected_range_count.get_or_insert_with(|| fidl::new_empty!(u64, D));
10587                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10588                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10589                {
10590                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10591                }
10592                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10593                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10594                }
10595            }
10596
10597            next_offset += envelope_size;
10598            _next_ordinal_to_read += 1;
10599            if next_offset >= end_offset {
10600                return Ok(());
10601            }
10602
10603            // Decode unknown envelopes for gaps in ordinals.
10604            while _next_ordinal_to_read < 5 {
10605                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10606                _next_ordinal_to_read += 1;
10607                next_offset += envelope_size;
10608            }
10609
10610            let next_out_of_line = decoder.next_out_of_line();
10611            let handles_before = decoder.remaining_handles();
10612            if let Some((inlined, num_bytes, num_handles)) =
10613                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10614            {
10615                let member_inline_size =
10616                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10617                if inlined != (member_inline_size <= 4) {
10618                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10619                }
10620                let inner_offset;
10621                let mut inner_depth = depth.clone();
10622                if inlined {
10623                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10624                    inner_offset = next_offset;
10625                } else {
10626                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10627                    inner_depth.increment()?;
10628                }
10629                let val_ref = self
10630                    .is_mod_protected_range_available
10631                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
10632                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
10633                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10634                {
10635                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10636                }
10637                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10638                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10639                }
10640            }
10641
10642            next_offset += envelope_size;
10643
10644            // Decode the remaining unknown envelopes.
10645            while next_offset < end_offset {
10646                _next_ordinal_to_read += 1;
10647                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10648                next_offset += envelope_size;
10649            }
10650
10651            Ok(())
10652        }
10653    }
10654
10655    impl SecureHeapRange {
10656        #[inline(always)]
10657        fn max_ordinal_present(&self) -> u64 {
10658            if let Some(_) = self.size_bytes {
10659                return 2;
10660            }
10661            if let Some(_) = self.physical_address {
10662                return 1;
10663            }
10664            0
10665        }
10666    }
10667
10668    impl fidl::encoding::ValueTypeMarker for SecureHeapRange {
10669        type Borrowed<'a> = &'a Self;
10670        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10671            value
10672        }
10673    }
10674
10675    unsafe impl fidl::encoding::TypeMarker for SecureHeapRange {
10676        type Owned = Self;
10677
10678        #[inline(always)]
10679        fn inline_align(_context: fidl::encoding::Context) -> usize {
10680            8
10681        }
10682
10683        #[inline(always)]
10684        fn inline_size(_context: fidl::encoding::Context) -> usize {
10685            16
10686        }
10687    }
10688
10689    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SecureHeapRange, D>
10690        for &SecureHeapRange
10691    {
10692        unsafe fn encode(
10693            self,
10694            encoder: &mut fidl::encoding::Encoder<'_, D>,
10695            offset: usize,
10696            mut depth: fidl::encoding::Depth,
10697        ) -> fidl::Result<()> {
10698            encoder.debug_check_bounds::<SecureHeapRange>(offset);
10699            // Vector header
10700            let max_ordinal: u64 = self.max_ordinal_present();
10701            encoder.write_num(max_ordinal, offset);
10702            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10703            // Calling encoder.out_of_line_offset(0) is not allowed.
10704            if max_ordinal == 0 {
10705                return Ok(());
10706            }
10707            depth.increment()?;
10708            let envelope_size = 8;
10709            let bytes_len = max_ordinal as usize * envelope_size;
10710            #[allow(unused_variables)]
10711            let offset = encoder.out_of_line_offset(bytes_len);
10712            let mut _prev_end_offset: usize = 0;
10713            if 1 > max_ordinal {
10714                return Ok(());
10715            }
10716
10717            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10718            // are envelope_size bytes.
10719            let cur_offset: usize = (1 - 1) * envelope_size;
10720
10721            // Zero reserved fields.
10722            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10723
10724            // Safety:
10725            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10726            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10727            //   envelope_size bytes, there is always sufficient room.
10728            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10729                self.physical_address
10730                    .as_ref()
10731                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10732                encoder,
10733                offset + cur_offset,
10734                depth,
10735            )?;
10736
10737            _prev_end_offset = cur_offset + envelope_size;
10738            if 2 > max_ordinal {
10739                return Ok(());
10740            }
10741
10742            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10743            // are envelope_size bytes.
10744            let cur_offset: usize = (2 - 1) * envelope_size;
10745
10746            // Zero reserved fields.
10747            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10748
10749            // Safety:
10750            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10751            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10752            //   envelope_size bytes, there is always sufficient room.
10753            fidl::encoding::encode_in_envelope_optional::<u64, D>(
10754                self.size_bytes.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10755                encoder,
10756                offset + cur_offset,
10757                depth,
10758            )?;
10759
10760            _prev_end_offset = cur_offset + envelope_size;
10761
10762            Ok(())
10763        }
10764    }
10765
10766    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureHeapRange {
10767        #[inline(always)]
10768        fn new_empty() -> Self {
10769            Self::default()
10770        }
10771
10772        unsafe fn decode(
10773            &mut self,
10774            decoder: &mut fidl::encoding::Decoder<'_, D>,
10775            offset: usize,
10776            mut depth: fidl::encoding::Depth,
10777        ) -> fidl::Result<()> {
10778            decoder.debug_check_bounds::<Self>(offset);
10779            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10780                None => return Err(fidl::Error::NotNullable),
10781                Some(len) => len,
10782            };
10783            // Calling decoder.out_of_line_offset(0) is not allowed.
10784            if len == 0 {
10785                return Ok(());
10786            };
10787            depth.increment()?;
10788            let envelope_size = 8;
10789            let bytes_len = len * envelope_size;
10790            let offset = decoder.out_of_line_offset(bytes_len)?;
10791            // Decode the envelope for each type.
10792            let mut _next_ordinal_to_read = 0;
10793            let mut next_offset = offset;
10794            let end_offset = offset + bytes_len;
10795            _next_ordinal_to_read += 1;
10796            if next_offset >= end_offset {
10797                return Ok(());
10798            }
10799
10800            // Decode unknown envelopes for gaps in ordinals.
10801            while _next_ordinal_to_read < 1 {
10802                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10803                _next_ordinal_to_read += 1;
10804                next_offset += envelope_size;
10805            }
10806
10807            let next_out_of_line = decoder.next_out_of_line();
10808            let handles_before = decoder.remaining_handles();
10809            if let Some((inlined, num_bytes, num_handles)) =
10810                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10811            {
10812                let member_inline_size =
10813                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10814                if inlined != (member_inline_size <= 4) {
10815                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10816                }
10817                let inner_offset;
10818                let mut inner_depth = depth.clone();
10819                if inlined {
10820                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10821                    inner_offset = next_offset;
10822                } else {
10823                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10824                    inner_depth.increment()?;
10825                }
10826                let val_ref = self.physical_address.get_or_insert_with(|| fidl::new_empty!(u64, D));
10827                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10828                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10829                {
10830                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10831                }
10832                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10833                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10834                }
10835            }
10836
10837            next_offset += envelope_size;
10838            _next_ordinal_to_read += 1;
10839            if next_offset >= end_offset {
10840                return Ok(());
10841            }
10842
10843            // Decode unknown envelopes for gaps in ordinals.
10844            while _next_ordinal_to_read < 2 {
10845                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10846                _next_ordinal_to_read += 1;
10847                next_offset += envelope_size;
10848            }
10849
10850            let next_out_of_line = decoder.next_out_of_line();
10851            let handles_before = decoder.remaining_handles();
10852            if let Some((inlined, num_bytes, num_handles)) =
10853                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10854            {
10855                let member_inline_size =
10856                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10857                if inlined != (member_inline_size <= 4) {
10858                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10859                }
10860                let inner_offset;
10861                let mut inner_depth = depth.clone();
10862                if inlined {
10863                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10864                    inner_offset = next_offset;
10865                } else {
10866                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10867                    inner_depth.increment()?;
10868                }
10869                let val_ref = self.size_bytes.get_or_insert_with(|| fidl::new_empty!(u64, D));
10870                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
10871                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10872                {
10873                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10874                }
10875                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10876                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10877                }
10878            }
10879
10880            next_offset += envelope_size;
10881
10882            // Decode the remaining unknown envelopes.
10883            while next_offset < end_offset {
10884                _next_ordinal_to_read += 1;
10885                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10886                next_offset += envelope_size;
10887            }
10888
10889            Ok(())
10890        }
10891    }
10892
10893    impl SecureMemAddSecureHeapPhysicalRangeRequest {
10894        #[inline(always)]
10895        fn max_ordinal_present(&self) -> u64 {
10896            if let Some(_) = self.heap_range {
10897                return 1;
10898            }
10899            0
10900        }
10901    }
10902
10903    impl fidl::encoding::ValueTypeMarker for SecureMemAddSecureHeapPhysicalRangeRequest {
10904        type Borrowed<'a> = &'a Self;
10905        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
10906            value
10907        }
10908    }
10909
10910    unsafe impl fidl::encoding::TypeMarker for SecureMemAddSecureHeapPhysicalRangeRequest {
10911        type Owned = Self;
10912
10913        #[inline(always)]
10914        fn inline_align(_context: fidl::encoding::Context) -> usize {
10915            8
10916        }
10917
10918        #[inline(always)]
10919        fn inline_size(_context: fidl::encoding::Context) -> usize {
10920            16
10921        }
10922    }
10923
10924    unsafe impl<D: fidl::encoding::ResourceDialect>
10925        fidl::encoding::Encode<SecureMemAddSecureHeapPhysicalRangeRequest, D>
10926        for &SecureMemAddSecureHeapPhysicalRangeRequest
10927    {
10928        unsafe fn encode(
10929            self,
10930            encoder: &mut fidl::encoding::Encoder<'_, D>,
10931            offset: usize,
10932            mut depth: fidl::encoding::Depth,
10933        ) -> fidl::Result<()> {
10934            encoder.debug_check_bounds::<SecureMemAddSecureHeapPhysicalRangeRequest>(offset);
10935            // Vector header
10936            let max_ordinal: u64 = self.max_ordinal_present();
10937            encoder.write_num(max_ordinal, offset);
10938            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10939            // Calling encoder.out_of_line_offset(0) is not allowed.
10940            if max_ordinal == 0 {
10941                return Ok(());
10942            }
10943            depth.increment()?;
10944            let envelope_size = 8;
10945            let bytes_len = max_ordinal as usize * envelope_size;
10946            #[allow(unused_variables)]
10947            let offset = encoder.out_of_line_offset(bytes_len);
10948            let mut _prev_end_offset: usize = 0;
10949            if 1 > max_ordinal {
10950                return Ok(());
10951            }
10952
10953            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10954            // are envelope_size bytes.
10955            let cur_offset: usize = (1 - 1) * envelope_size;
10956
10957            // Zero reserved fields.
10958            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10959
10960            // Safety:
10961            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10962            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10963            //   envelope_size bytes, there is always sufficient room.
10964            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
10965                self.heap_range
10966                    .as_ref()
10967                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
10968                encoder,
10969                offset + cur_offset,
10970                depth,
10971            )?;
10972
10973            _prev_end_offset = cur_offset + envelope_size;
10974
10975            Ok(())
10976        }
10977    }
10978
10979    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
10980        for SecureMemAddSecureHeapPhysicalRangeRequest
10981    {
10982        #[inline(always)]
10983        fn new_empty() -> Self {
10984            Self::default()
10985        }
10986
10987        unsafe fn decode(
10988            &mut self,
10989            decoder: &mut fidl::encoding::Decoder<'_, D>,
10990            offset: usize,
10991            mut depth: fidl::encoding::Depth,
10992        ) -> fidl::Result<()> {
10993            decoder.debug_check_bounds::<Self>(offset);
10994            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10995                None => return Err(fidl::Error::NotNullable),
10996                Some(len) => len,
10997            };
10998            // Calling decoder.out_of_line_offset(0) is not allowed.
10999            if len == 0 {
11000                return Ok(());
11001            };
11002            depth.increment()?;
11003            let envelope_size = 8;
11004            let bytes_len = len * envelope_size;
11005            let offset = decoder.out_of_line_offset(bytes_len)?;
11006            // Decode the envelope for each type.
11007            let mut _next_ordinal_to_read = 0;
11008            let mut next_offset = offset;
11009            let end_offset = offset + bytes_len;
11010            _next_ordinal_to_read += 1;
11011            if next_offset >= end_offset {
11012                return Ok(());
11013            }
11014
11015            // Decode unknown envelopes for gaps in ordinals.
11016            while _next_ordinal_to_read < 1 {
11017                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11018                _next_ordinal_to_read += 1;
11019                next_offset += envelope_size;
11020            }
11021
11022            let next_out_of_line = decoder.next_out_of_line();
11023            let handles_before = decoder.remaining_handles();
11024            if let Some((inlined, num_bytes, num_handles)) =
11025                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11026            {
11027                let member_inline_size =
11028                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11029                        decoder.context,
11030                    );
11031                if inlined != (member_inline_size <= 4) {
11032                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11033                }
11034                let inner_offset;
11035                let mut inner_depth = depth.clone();
11036                if inlined {
11037                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11038                    inner_offset = next_offset;
11039                } else {
11040                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11041                    inner_depth.increment()?;
11042                }
11043                let val_ref =
11044                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11045                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11046                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11047                {
11048                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11049                }
11050                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11051                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11052                }
11053            }
11054
11055            next_offset += envelope_size;
11056
11057            // Decode the remaining unknown envelopes.
11058            while next_offset < end_offset {
11059                _next_ordinal_to_read += 1;
11060                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11061                next_offset += envelope_size;
11062            }
11063
11064            Ok(())
11065        }
11066    }
11067
11068    impl SecureMemDeleteSecureHeapPhysicalRangeRequest {
11069        #[inline(always)]
11070        fn max_ordinal_present(&self) -> u64 {
11071            if let Some(_) = self.heap_range {
11072                return 1;
11073            }
11074            0
11075        }
11076    }
11077
11078    impl fidl::encoding::ValueTypeMarker for SecureMemDeleteSecureHeapPhysicalRangeRequest {
11079        type Borrowed<'a> = &'a Self;
11080        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11081            value
11082        }
11083    }
11084
11085    unsafe impl fidl::encoding::TypeMarker for SecureMemDeleteSecureHeapPhysicalRangeRequest {
11086        type Owned = Self;
11087
11088        #[inline(always)]
11089        fn inline_align(_context: fidl::encoding::Context) -> usize {
11090            8
11091        }
11092
11093        #[inline(always)]
11094        fn inline_size(_context: fidl::encoding::Context) -> usize {
11095            16
11096        }
11097    }
11098
11099    unsafe impl<D: fidl::encoding::ResourceDialect>
11100        fidl::encoding::Encode<SecureMemDeleteSecureHeapPhysicalRangeRequest, D>
11101        for &SecureMemDeleteSecureHeapPhysicalRangeRequest
11102    {
11103        unsafe fn encode(
11104            self,
11105            encoder: &mut fidl::encoding::Encoder<'_, D>,
11106            offset: usize,
11107            mut depth: fidl::encoding::Depth,
11108        ) -> fidl::Result<()> {
11109            encoder.debug_check_bounds::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(offset);
11110            // Vector header
11111            let max_ordinal: u64 = self.max_ordinal_present();
11112            encoder.write_num(max_ordinal, offset);
11113            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11114            // Calling encoder.out_of_line_offset(0) is not allowed.
11115            if max_ordinal == 0 {
11116                return Ok(());
11117            }
11118            depth.increment()?;
11119            let envelope_size = 8;
11120            let bytes_len = max_ordinal as usize * envelope_size;
11121            #[allow(unused_variables)]
11122            let offset = encoder.out_of_line_offset(bytes_len);
11123            let mut _prev_end_offset: usize = 0;
11124            if 1 > max_ordinal {
11125                return Ok(());
11126            }
11127
11128            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11129            // are envelope_size bytes.
11130            let cur_offset: usize = (1 - 1) * envelope_size;
11131
11132            // Zero reserved fields.
11133            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11134
11135            // Safety:
11136            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11137            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11138            //   envelope_size bytes, there is always sufficient room.
11139            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11140                self.heap_range
11141                    .as_ref()
11142                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11143                encoder,
11144                offset + cur_offset,
11145                depth,
11146            )?;
11147
11148            _prev_end_offset = cur_offset + envelope_size;
11149
11150            Ok(())
11151        }
11152    }
11153
11154    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11155        for SecureMemDeleteSecureHeapPhysicalRangeRequest
11156    {
11157        #[inline(always)]
11158        fn new_empty() -> Self {
11159            Self::default()
11160        }
11161
11162        unsafe fn decode(
11163            &mut self,
11164            decoder: &mut fidl::encoding::Decoder<'_, D>,
11165            offset: usize,
11166            mut depth: fidl::encoding::Depth,
11167        ) -> fidl::Result<()> {
11168            decoder.debug_check_bounds::<Self>(offset);
11169            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11170                None => return Err(fidl::Error::NotNullable),
11171                Some(len) => len,
11172            };
11173            // Calling decoder.out_of_line_offset(0) is not allowed.
11174            if len == 0 {
11175                return Ok(());
11176            };
11177            depth.increment()?;
11178            let envelope_size = 8;
11179            let bytes_len = len * envelope_size;
11180            let offset = decoder.out_of_line_offset(bytes_len)?;
11181            // Decode the envelope for each type.
11182            let mut _next_ordinal_to_read = 0;
11183            let mut next_offset = offset;
11184            let end_offset = offset + bytes_len;
11185            _next_ordinal_to_read += 1;
11186            if next_offset >= end_offset {
11187                return Ok(());
11188            }
11189
11190            // Decode unknown envelopes for gaps in ordinals.
11191            while _next_ordinal_to_read < 1 {
11192                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11193                _next_ordinal_to_read += 1;
11194                next_offset += envelope_size;
11195            }
11196
11197            let next_out_of_line = decoder.next_out_of_line();
11198            let handles_before = decoder.remaining_handles();
11199            if let Some((inlined, num_bytes, num_handles)) =
11200                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11201            {
11202                let member_inline_size =
11203                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11204                        decoder.context,
11205                    );
11206                if inlined != (member_inline_size <= 4) {
11207                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11208                }
11209                let inner_offset;
11210                let mut inner_depth = depth.clone();
11211                if inlined {
11212                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11213                    inner_offset = next_offset;
11214                } else {
11215                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11216                    inner_depth.increment()?;
11217                }
11218                let val_ref =
11219                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11220                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11221                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11222                {
11223                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11224                }
11225                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11226                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11227                }
11228            }
11229
11230            next_offset += envelope_size;
11231
11232            // Decode the remaining unknown envelopes.
11233            while next_offset < end_offset {
11234                _next_ordinal_to_read += 1;
11235                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11236                next_offset += envelope_size;
11237            }
11238
11239            Ok(())
11240        }
11241    }
11242
11243    impl SecureMemGetPhysicalSecureHeapPropertiesRequest {
11244        #[inline(always)]
11245        fn max_ordinal_present(&self) -> u64 {
11246            if let Some(_) = self.entire_heap {
11247                return 1;
11248            }
11249            0
11250        }
11251    }
11252
11253    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapPropertiesRequest {
11254        type Borrowed<'a> = &'a Self;
11255        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11256            value
11257        }
11258    }
11259
11260    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapPropertiesRequest {
11261        type Owned = Self;
11262
11263        #[inline(always)]
11264        fn inline_align(_context: fidl::encoding::Context) -> usize {
11265            8
11266        }
11267
11268        #[inline(always)]
11269        fn inline_size(_context: fidl::encoding::Context) -> usize {
11270            16
11271        }
11272    }
11273
11274    unsafe impl<D: fidl::encoding::ResourceDialect>
11275        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapPropertiesRequest, D>
11276        for &SecureMemGetPhysicalSecureHeapPropertiesRequest
11277    {
11278        unsafe fn encode(
11279            self,
11280            encoder: &mut fidl::encoding::Encoder<'_, D>,
11281            offset: usize,
11282            mut depth: fidl::encoding::Depth,
11283        ) -> fidl::Result<()> {
11284            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(offset);
11285            // Vector header
11286            let max_ordinal: u64 = self.max_ordinal_present();
11287            encoder.write_num(max_ordinal, offset);
11288            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11289            // Calling encoder.out_of_line_offset(0) is not allowed.
11290            if max_ordinal == 0 {
11291                return Ok(());
11292            }
11293            depth.increment()?;
11294            let envelope_size = 8;
11295            let bytes_len = max_ordinal as usize * envelope_size;
11296            #[allow(unused_variables)]
11297            let offset = encoder.out_of_line_offset(bytes_len);
11298            let mut _prev_end_offset: usize = 0;
11299            if 1 > max_ordinal {
11300                return Ok(());
11301            }
11302
11303            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11304            // are envelope_size bytes.
11305            let cur_offset: usize = (1 - 1) * envelope_size;
11306
11307            // Zero reserved fields.
11308            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11309
11310            // Safety:
11311            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11312            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11313            //   envelope_size bytes, there is always sufficient room.
11314            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11315                self.entire_heap
11316                    .as_ref()
11317                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11318                encoder,
11319                offset + cur_offset,
11320                depth,
11321            )?;
11322
11323            _prev_end_offset = cur_offset + envelope_size;
11324
11325            Ok(())
11326        }
11327    }
11328
11329    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11330        for SecureMemGetPhysicalSecureHeapPropertiesRequest
11331    {
11332        #[inline(always)]
11333        fn new_empty() -> Self {
11334            Self::default()
11335        }
11336
11337        unsafe fn decode(
11338            &mut self,
11339            decoder: &mut fidl::encoding::Decoder<'_, D>,
11340            offset: usize,
11341            mut depth: fidl::encoding::Depth,
11342        ) -> fidl::Result<()> {
11343            decoder.debug_check_bounds::<Self>(offset);
11344            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11345                None => return Err(fidl::Error::NotNullable),
11346                Some(len) => len,
11347            };
11348            // Calling decoder.out_of_line_offset(0) is not allowed.
11349            if len == 0 {
11350                return Ok(());
11351            };
11352            depth.increment()?;
11353            let envelope_size = 8;
11354            let bytes_len = len * envelope_size;
11355            let offset = decoder.out_of_line_offset(bytes_len)?;
11356            // Decode the envelope for each type.
11357            let mut _next_ordinal_to_read = 0;
11358            let mut next_offset = offset;
11359            let end_offset = offset + bytes_len;
11360            _next_ordinal_to_read += 1;
11361            if next_offset >= end_offset {
11362                return Ok(());
11363            }
11364
11365            // Decode unknown envelopes for gaps in ordinals.
11366            while _next_ordinal_to_read < 1 {
11367                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11368                _next_ordinal_to_read += 1;
11369                next_offset += envelope_size;
11370            }
11371
11372            let next_out_of_line = decoder.next_out_of_line();
11373            let handles_before = decoder.remaining_handles();
11374            if let Some((inlined, num_bytes, num_handles)) =
11375                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11376            {
11377                let member_inline_size =
11378                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11379                        decoder.context,
11380                    );
11381                if inlined != (member_inline_size <= 4) {
11382                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11383                }
11384                let inner_offset;
11385                let mut inner_depth = depth.clone();
11386                if inlined {
11387                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11388                    inner_offset = next_offset;
11389                } else {
11390                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11391                    inner_depth.increment()?;
11392                }
11393                let val_ref =
11394                    self.entire_heap.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11395                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11396                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11397                {
11398                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11399                }
11400                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11401                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11402                }
11403            }
11404
11405            next_offset += envelope_size;
11406
11407            // Decode the remaining unknown envelopes.
11408            while next_offset < end_offset {
11409                _next_ordinal_to_read += 1;
11410                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11411                next_offset += envelope_size;
11412            }
11413
11414            Ok(())
11415        }
11416    }
11417
11418    impl SecureMemModifySecureHeapPhysicalRangeRequest {
11419        #[inline(always)]
11420        fn max_ordinal_present(&self) -> u64 {
11421            if let Some(_) = self.range_modification {
11422                return 1;
11423            }
11424            0
11425        }
11426    }
11427
11428    impl fidl::encoding::ValueTypeMarker for SecureMemModifySecureHeapPhysicalRangeRequest {
11429        type Borrowed<'a> = &'a Self;
11430        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11431            value
11432        }
11433    }
11434
11435    unsafe impl fidl::encoding::TypeMarker for SecureMemModifySecureHeapPhysicalRangeRequest {
11436        type Owned = Self;
11437
11438        #[inline(always)]
11439        fn inline_align(_context: fidl::encoding::Context) -> usize {
11440            8
11441        }
11442
11443        #[inline(always)]
11444        fn inline_size(_context: fidl::encoding::Context) -> usize {
11445            16
11446        }
11447    }
11448
11449    unsafe impl<D: fidl::encoding::ResourceDialect>
11450        fidl::encoding::Encode<SecureMemModifySecureHeapPhysicalRangeRequest, D>
11451        for &SecureMemModifySecureHeapPhysicalRangeRequest
11452    {
11453        unsafe fn encode(
11454            self,
11455            encoder: &mut fidl::encoding::Encoder<'_, D>,
11456            offset: usize,
11457            mut depth: fidl::encoding::Depth,
11458        ) -> fidl::Result<()> {
11459            encoder.debug_check_bounds::<SecureMemModifySecureHeapPhysicalRangeRequest>(offset);
11460            // Vector header
11461            let max_ordinal: u64 = self.max_ordinal_present();
11462            encoder.write_num(max_ordinal, offset);
11463            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11464            // Calling encoder.out_of_line_offset(0) is not allowed.
11465            if max_ordinal == 0 {
11466                return Ok(());
11467            }
11468            depth.increment()?;
11469            let envelope_size = 8;
11470            let bytes_len = max_ordinal as usize * envelope_size;
11471            #[allow(unused_variables)]
11472            let offset = encoder.out_of_line_offset(bytes_len);
11473            let mut _prev_end_offset: usize = 0;
11474            if 1 > max_ordinal {
11475                return Ok(());
11476            }
11477
11478            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11479            // are envelope_size bytes.
11480            let cur_offset: usize = (1 - 1) * envelope_size;
11481
11482            // Zero reserved fields.
11483            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11484
11485            // Safety:
11486            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11487            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11488            //   envelope_size bytes, there is always sufficient room.
11489            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRangeModification, D>(
11490                self.range_modification.as_ref().map(
11491                    <SecureHeapAndRangeModification as fidl::encoding::ValueTypeMarker>::borrow,
11492                ),
11493                encoder,
11494                offset + cur_offset,
11495                depth,
11496            )?;
11497
11498            _prev_end_offset = cur_offset + envelope_size;
11499
11500            Ok(())
11501        }
11502    }
11503
11504    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11505        for SecureMemModifySecureHeapPhysicalRangeRequest
11506    {
11507        #[inline(always)]
11508        fn new_empty() -> Self {
11509            Self::default()
11510        }
11511
11512        unsafe fn decode(
11513            &mut self,
11514            decoder: &mut fidl::encoding::Decoder<'_, D>,
11515            offset: usize,
11516            mut depth: fidl::encoding::Depth,
11517        ) -> fidl::Result<()> {
11518            decoder.debug_check_bounds::<Self>(offset);
11519            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11520                None => return Err(fidl::Error::NotNullable),
11521                Some(len) => len,
11522            };
11523            // Calling decoder.out_of_line_offset(0) is not allowed.
11524            if len == 0 {
11525                return Ok(());
11526            };
11527            depth.increment()?;
11528            let envelope_size = 8;
11529            let bytes_len = len * envelope_size;
11530            let offset = decoder.out_of_line_offset(bytes_len)?;
11531            // Decode the envelope for each type.
11532            let mut _next_ordinal_to_read = 0;
11533            let mut next_offset = offset;
11534            let end_offset = offset + bytes_len;
11535            _next_ordinal_to_read += 1;
11536            if next_offset >= end_offset {
11537                return Ok(());
11538            }
11539
11540            // Decode unknown envelopes for gaps in ordinals.
11541            while _next_ordinal_to_read < 1 {
11542                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11543                _next_ordinal_to_read += 1;
11544                next_offset += envelope_size;
11545            }
11546
11547            let next_out_of_line = decoder.next_out_of_line();
11548            let handles_before = decoder.remaining_handles();
11549            if let Some((inlined, num_bytes, num_handles)) =
11550                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11551            {
11552                let member_inline_size =
11553                    <SecureHeapAndRangeModification as fidl::encoding::TypeMarker>::inline_size(
11554                        decoder.context,
11555                    );
11556                if inlined != (member_inline_size <= 4) {
11557                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11558                }
11559                let inner_offset;
11560                let mut inner_depth = depth.clone();
11561                if inlined {
11562                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11563                    inner_offset = next_offset;
11564                } else {
11565                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11566                    inner_depth.increment()?;
11567                }
11568                let val_ref = self
11569                    .range_modification
11570                    .get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRangeModification, D));
11571                fidl::decode!(
11572                    SecureHeapAndRangeModification,
11573                    D,
11574                    val_ref,
11575                    decoder,
11576                    inner_offset,
11577                    inner_depth
11578                )?;
11579                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11580                {
11581                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11582                }
11583                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11584                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11585                }
11586            }
11587
11588            next_offset += envelope_size;
11589
11590            // Decode the remaining unknown envelopes.
11591            while next_offset < end_offset {
11592                _next_ordinal_to_read += 1;
11593                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11594                next_offset += envelope_size;
11595            }
11596
11597            Ok(())
11598        }
11599    }
11600
11601    impl SecureMemZeroSubRangeRequest {
11602        #[inline(always)]
11603        fn max_ordinal_present(&self) -> u64 {
11604            if let Some(_) = self.heap_range {
11605                return 2;
11606            }
11607            if let Some(_) = self.is_covering_range_explicit {
11608                return 1;
11609            }
11610            0
11611        }
11612    }
11613
11614    impl fidl::encoding::ValueTypeMarker for SecureMemZeroSubRangeRequest {
11615        type Borrowed<'a> = &'a Self;
11616        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11617            value
11618        }
11619    }
11620
11621    unsafe impl fidl::encoding::TypeMarker for SecureMemZeroSubRangeRequest {
11622        type Owned = Self;
11623
11624        #[inline(always)]
11625        fn inline_align(_context: fidl::encoding::Context) -> usize {
11626            8
11627        }
11628
11629        #[inline(always)]
11630        fn inline_size(_context: fidl::encoding::Context) -> usize {
11631            16
11632        }
11633    }
11634
11635    unsafe impl<D: fidl::encoding::ResourceDialect>
11636        fidl::encoding::Encode<SecureMemZeroSubRangeRequest, D> for &SecureMemZeroSubRangeRequest
11637    {
11638        unsafe fn encode(
11639            self,
11640            encoder: &mut fidl::encoding::Encoder<'_, D>,
11641            offset: usize,
11642            mut depth: fidl::encoding::Depth,
11643        ) -> fidl::Result<()> {
11644            encoder.debug_check_bounds::<SecureMemZeroSubRangeRequest>(offset);
11645            // Vector header
11646            let max_ordinal: u64 = self.max_ordinal_present();
11647            encoder.write_num(max_ordinal, offset);
11648            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11649            // Calling encoder.out_of_line_offset(0) is not allowed.
11650            if max_ordinal == 0 {
11651                return Ok(());
11652            }
11653            depth.increment()?;
11654            let envelope_size = 8;
11655            let bytes_len = max_ordinal as usize * envelope_size;
11656            #[allow(unused_variables)]
11657            let offset = encoder.out_of_line_offset(bytes_len);
11658            let mut _prev_end_offset: usize = 0;
11659            if 1 > max_ordinal {
11660                return Ok(());
11661            }
11662
11663            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11664            // are envelope_size bytes.
11665            let cur_offset: usize = (1 - 1) * envelope_size;
11666
11667            // Zero reserved fields.
11668            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11669
11670            // Safety:
11671            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11672            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11673            //   envelope_size bytes, there is always sufficient room.
11674            fidl::encoding::encode_in_envelope_optional::<bool, D>(
11675                self.is_covering_range_explicit
11676                    .as_ref()
11677                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11678                encoder,
11679                offset + cur_offset,
11680                depth,
11681            )?;
11682
11683            _prev_end_offset = cur_offset + envelope_size;
11684            if 2 > max_ordinal {
11685                return Ok(());
11686            }
11687
11688            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11689            // are envelope_size bytes.
11690            let cur_offset: usize = (2 - 1) * envelope_size;
11691
11692            // Zero reserved fields.
11693            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11694
11695            // Safety:
11696            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11697            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11698            //   envelope_size bytes, there is always sufficient room.
11699            fidl::encoding::encode_in_envelope_optional::<SecureHeapAndRange, D>(
11700                self.heap_range
11701                    .as_ref()
11702                    .map(<SecureHeapAndRange as fidl::encoding::ValueTypeMarker>::borrow),
11703                encoder,
11704                offset + cur_offset,
11705                depth,
11706            )?;
11707
11708            _prev_end_offset = cur_offset + envelope_size;
11709
11710            Ok(())
11711        }
11712    }
11713
11714    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11715        for SecureMemZeroSubRangeRequest
11716    {
11717        #[inline(always)]
11718        fn new_empty() -> Self {
11719            Self::default()
11720        }
11721
11722        unsafe fn decode(
11723            &mut self,
11724            decoder: &mut fidl::encoding::Decoder<'_, D>,
11725            offset: usize,
11726            mut depth: fidl::encoding::Depth,
11727        ) -> fidl::Result<()> {
11728            decoder.debug_check_bounds::<Self>(offset);
11729            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11730                None => return Err(fidl::Error::NotNullable),
11731                Some(len) => len,
11732            };
11733            // Calling decoder.out_of_line_offset(0) is not allowed.
11734            if len == 0 {
11735                return Ok(());
11736            };
11737            depth.increment()?;
11738            let envelope_size = 8;
11739            let bytes_len = len * envelope_size;
11740            let offset = decoder.out_of_line_offset(bytes_len)?;
11741            // Decode the envelope for each type.
11742            let mut _next_ordinal_to_read = 0;
11743            let mut next_offset = offset;
11744            let end_offset = offset + bytes_len;
11745            _next_ordinal_to_read += 1;
11746            if next_offset >= end_offset {
11747                return Ok(());
11748            }
11749
11750            // Decode unknown envelopes for gaps in ordinals.
11751            while _next_ordinal_to_read < 1 {
11752                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11753                _next_ordinal_to_read += 1;
11754                next_offset += envelope_size;
11755            }
11756
11757            let next_out_of_line = decoder.next_out_of_line();
11758            let handles_before = decoder.remaining_handles();
11759            if let Some((inlined, num_bytes, num_handles)) =
11760                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11761            {
11762                let member_inline_size =
11763                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11764                if inlined != (member_inline_size <= 4) {
11765                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11766                }
11767                let inner_offset;
11768                let mut inner_depth = depth.clone();
11769                if inlined {
11770                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11771                    inner_offset = next_offset;
11772                } else {
11773                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11774                    inner_depth.increment()?;
11775                }
11776                let val_ref = self
11777                    .is_covering_range_explicit
11778                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
11779                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
11780                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11781                {
11782                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11783                }
11784                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11785                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11786                }
11787            }
11788
11789            next_offset += envelope_size;
11790            _next_ordinal_to_read += 1;
11791            if next_offset >= end_offset {
11792                return Ok(());
11793            }
11794
11795            // Decode unknown envelopes for gaps in ordinals.
11796            while _next_ordinal_to_read < 2 {
11797                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11798                _next_ordinal_to_read += 1;
11799                next_offset += envelope_size;
11800            }
11801
11802            let next_out_of_line = decoder.next_out_of_line();
11803            let handles_before = decoder.remaining_handles();
11804            if let Some((inlined, num_bytes, num_handles)) =
11805                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11806            {
11807                let member_inline_size =
11808                    <SecureHeapAndRange as fidl::encoding::TypeMarker>::inline_size(
11809                        decoder.context,
11810                    );
11811                if inlined != (member_inline_size <= 4) {
11812                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11813                }
11814                let inner_offset;
11815                let mut inner_depth = depth.clone();
11816                if inlined {
11817                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11818                    inner_offset = next_offset;
11819                } else {
11820                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11821                    inner_depth.increment()?;
11822                }
11823                let val_ref =
11824                    self.heap_range.get_or_insert_with(|| fidl::new_empty!(SecureHeapAndRange, D));
11825                fidl::decode!(SecureHeapAndRange, D, val_ref, decoder, inner_offset, inner_depth)?;
11826                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11827                {
11828                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11829                }
11830                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11831                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11832                }
11833            }
11834
11835            next_offset += envelope_size;
11836
11837            // Decode the remaining unknown envelopes.
11838            while next_offset < end_offset {
11839                _next_ordinal_to_read += 1;
11840                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11841                next_offset += envelope_size;
11842            }
11843
11844            Ok(())
11845        }
11846    }
11847
11848    impl SecureMemGetDynamicSecureHeapsResponse {
11849        #[inline(always)]
11850        fn max_ordinal_present(&self) -> u64 {
11851            if let Some(_) = self.heaps {
11852                return 1;
11853            }
11854            0
11855        }
11856    }
11857
11858    impl fidl::encoding::ValueTypeMarker for SecureMemGetDynamicSecureHeapsResponse {
11859        type Borrowed<'a> = &'a Self;
11860        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
11861            value
11862        }
11863    }
11864
11865    unsafe impl fidl::encoding::TypeMarker for SecureMemGetDynamicSecureHeapsResponse {
11866        type Owned = Self;
11867
11868        #[inline(always)]
11869        fn inline_align(_context: fidl::encoding::Context) -> usize {
11870            8
11871        }
11872
11873        #[inline(always)]
11874        fn inline_size(_context: fidl::encoding::Context) -> usize {
11875            16
11876        }
11877    }
11878
11879    unsafe impl<D: fidl::encoding::ResourceDialect>
11880        fidl::encoding::Encode<SecureMemGetDynamicSecureHeapsResponse, D>
11881        for &SecureMemGetDynamicSecureHeapsResponse
11882    {
11883        unsafe fn encode(
11884            self,
11885            encoder: &mut fidl::encoding::Encoder<'_, D>,
11886            offset: usize,
11887            mut depth: fidl::encoding::Depth,
11888        ) -> fidl::Result<()> {
11889            encoder.debug_check_bounds::<SecureMemGetDynamicSecureHeapsResponse>(offset);
11890            // Vector header
11891            let max_ordinal: u64 = self.max_ordinal_present();
11892            encoder.write_num(max_ordinal, offset);
11893            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11894            // Calling encoder.out_of_line_offset(0) is not allowed.
11895            if max_ordinal == 0 {
11896                return Ok(());
11897            }
11898            depth.increment()?;
11899            let envelope_size = 8;
11900            let bytes_len = max_ordinal as usize * envelope_size;
11901            #[allow(unused_variables)]
11902            let offset = encoder.out_of_line_offset(bytes_len);
11903            let mut _prev_end_offset: usize = 0;
11904            if 1 > max_ordinal {
11905                return Ok(());
11906            }
11907
11908            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11909            // are envelope_size bytes.
11910            let cur_offset: usize = (1 - 1) * envelope_size;
11911
11912            // Zero reserved fields.
11913            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11914
11915            // Safety:
11916            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11917            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11918            //   envelope_size bytes, there is always sufficient room.
11919            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<DynamicSecureHeap, 32>, D>(
11920            self.heaps.as_ref().map(<fidl::encoding::Vector<DynamicSecureHeap, 32> as fidl::encoding::ValueTypeMarker>::borrow),
11921            encoder, offset + cur_offset, depth
11922        )?;
11923
11924            _prev_end_offset = cur_offset + envelope_size;
11925
11926            Ok(())
11927        }
11928    }
11929
11930    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
11931        for SecureMemGetDynamicSecureHeapsResponse
11932    {
11933        #[inline(always)]
11934        fn new_empty() -> Self {
11935            Self::default()
11936        }
11937
11938        unsafe fn decode(
11939            &mut self,
11940            decoder: &mut fidl::encoding::Decoder<'_, D>,
11941            offset: usize,
11942            mut depth: fidl::encoding::Depth,
11943        ) -> fidl::Result<()> {
11944            decoder.debug_check_bounds::<Self>(offset);
11945            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11946                None => return Err(fidl::Error::NotNullable),
11947                Some(len) => len,
11948            };
11949            // Calling decoder.out_of_line_offset(0) is not allowed.
11950            if len == 0 {
11951                return Ok(());
11952            };
11953            depth.increment()?;
11954            let envelope_size = 8;
11955            let bytes_len = len * envelope_size;
11956            let offset = decoder.out_of_line_offset(bytes_len)?;
11957            // Decode the envelope for each type.
11958            let mut _next_ordinal_to_read = 0;
11959            let mut next_offset = offset;
11960            let end_offset = offset + bytes_len;
11961            _next_ordinal_to_read += 1;
11962            if next_offset >= end_offset {
11963                return Ok(());
11964            }
11965
11966            // Decode unknown envelopes for gaps in ordinals.
11967            while _next_ordinal_to_read < 1 {
11968                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11969                _next_ordinal_to_read += 1;
11970                next_offset += envelope_size;
11971            }
11972
11973            let next_out_of_line = decoder.next_out_of_line();
11974            let handles_before = decoder.remaining_handles();
11975            if let Some((inlined, num_bytes, num_handles)) =
11976                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11977            {
11978                let member_inline_size = <fidl::encoding::Vector<DynamicSecureHeap, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11979                if inlined != (member_inline_size <= 4) {
11980                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11981                }
11982                let inner_offset;
11983                let mut inner_depth = depth.clone();
11984                if inlined {
11985                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11986                    inner_offset = next_offset;
11987                } else {
11988                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11989                    inner_depth.increment()?;
11990                }
11991                let val_ref = self.heaps.get_or_insert_with(
11992                    || fidl::new_empty!(fidl::encoding::Vector<DynamicSecureHeap, 32>, D),
11993                );
11994                fidl::decode!(fidl::encoding::Vector<DynamicSecureHeap, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
11995                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11996                {
11997                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11998                }
11999                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12000                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12001                }
12002            }
12003
12004            next_offset += envelope_size;
12005
12006            // Decode the remaining unknown envelopes.
12007            while next_offset < end_offset {
12008                _next_ordinal_to_read += 1;
12009                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12010                next_offset += envelope_size;
12011            }
12012
12013            Ok(())
12014        }
12015    }
12016
12017    impl SecureMemGetPhysicalSecureHeapPropertiesResponse {
12018        #[inline(always)]
12019        fn max_ordinal_present(&self) -> u64 {
12020            if let Some(_) = self.properties {
12021                return 1;
12022            }
12023            0
12024        }
12025    }
12026
12027    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapPropertiesResponse {
12028        type Borrowed<'a> = &'a Self;
12029        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
12030            value
12031        }
12032    }
12033
12034    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapPropertiesResponse {
12035        type Owned = Self;
12036
12037        #[inline(always)]
12038        fn inline_align(_context: fidl::encoding::Context) -> usize {
12039            8
12040        }
12041
12042        #[inline(always)]
12043        fn inline_size(_context: fidl::encoding::Context) -> usize {
12044            16
12045        }
12046    }
12047
12048    unsafe impl<D: fidl::encoding::ResourceDialect>
12049        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapPropertiesResponse, D>
12050        for &SecureMemGetPhysicalSecureHeapPropertiesResponse
12051    {
12052        unsafe fn encode(
12053            self,
12054            encoder: &mut fidl::encoding::Encoder<'_, D>,
12055            offset: usize,
12056            mut depth: fidl::encoding::Depth,
12057        ) -> fidl::Result<()> {
12058            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapPropertiesResponse>(offset);
12059            // Vector header
12060            let max_ordinal: u64 = self.max_ordinal_present();
12061            encoder.write_num(max_ordinal, offset);
12062            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12063            // Calling encoder.out_of_line_offset(0) is not allowed.
12064            if max_ordinal == 0 {
12065                return Ok(());
12066            }
12067            depth.increment()?;
12068            let envelope_size = 8;
12069            let bytes_len = max_ordinal as usize * envelope_size;
12070            #[allow(unused_variables)]
12071            let offset = encoder.out_of_line_offset(bytes_len);
12072            let mut _prev_end_offset: usize = 0;
12073            if 1 > max_ordinal {
12074                return Ok(());
12075            }
12076
12077            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12078            // are envelope_size bytes.
12079            let cur_offset: usize = (1 - 1) * envelope_size;
12080
12081            // Zero reserved fields.
12082            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12083
12084            // Safety:
12085            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12086            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12087            //   envelope_size bytes, there is always sufficient room.
12088            fidl::encoding::encode_in_envelope_optional::<SecureHeapProperties, D>(
12089                self.properties
12090                    .as_ref()
12091                    .map(<SecureHeapProperties as fidl::encoding::ValueTypeMarker>::borrow),
12092                encoder,
12093                offset + cur_offset,
12094                depth,
12095            )?;
12096
12097            _prev_end_offset = cur_offset + envelope_size;
12098
12099            Ok(())
12100        }
12101    }
12102
12103    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
12104        for SecureMemGetPhysicalSecureHeapPropertiesResponse
12105    {
12106        #[inline(always)]
12107        fn new_empty() -> Self {
12108            Self::default()
12109        }
12110
12111        unsafe fn decode(
12112            &mut self,
12113            decoder: &mut fidl::encoding::Decoder<'_, D>,
12114            offset: usize,
12115            mut depth: fidl::encoding::Depth,
12116        ) -> fidl::Result<()> {
12117            decoder.debug_check_bounds::<Self>(offset);
12118            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12119                None => return Err(fidl::Error::NotNullable),
12120                Some(len) => len,
12121            };
12122            // Calling decoder.out_of_line_offset(0) is not allowed.
12123            if len == 0 {
12124                return Ok(());
12125            };
12126            depth.increment()?;
12127            let envelope_size = 8;
12128            let bytes_len = len * envelope_size;
12129            let offset = decoder.out_of_line_offset(bytes_len)?;
12130            // Decode the envelope for each type.
12131            let mut _next_ordinal_to_read = 0;
12132            let mut next_offset = offset;
12133            let end_offset = offset + bytes_len;
12134            _next_ordinal_to_read += 1;
12135            if next_offset >= end_offset {
12136                return Ok(());
12137            }
12138
12139            // Decode unknown envelopes for gaps in ordinals.
12140            while _next_ordinal_to_read < 1 {
12141                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12142                _next_ordinal_to_read += 1;
12143                next_offset += envelope_size;
12144            }
12145
12146            let next_out_of_line = decoder.next_out_of_line();
12147            let handles_before = decoder.remaining_handles();
12148            if let Some((inlined, num_bytes, num_handles)) =
12149                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12150            {
12151                let member_inline_size =
12152                    <SecureHeapProperties as fidl::encoding::TypeMarker>::inline_size(
12153                        decoder.context,
12154                    );
12155                if inlined != (member_inline_size <= 4) {
12156                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12157                }
12158                let inner_offset;
12159                let mut inner_depth = depth.clone();
12160                if inlined {
12161                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12162                    inner_offset = next_offset;
12163                } else {
12164                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12165                    inner_depth.increment()?;
12166                }
12167                let val_ref = self
12168                    .properties
12169                    .get_or_insert_with(|| fidl::new_empty!(SecureHeapProperties, D));
12170                fidl::decode!(
12171                    SecureHeapProperties,
12172                    D,
12173                    val_ref,
12174                    decoder,
12175                    inner_offset,
12176                    inner_depth
12177                )?;
12178                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12179                {
12180                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12181                }
12182                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12183                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12184                }
12185            }
12186
12187            next_offset += envelope_size;
12188
12189            // Decode the remaining unknown envelopes.
12190            while next_offset < end_offset {
12191                _next_ordinal_to_read += 1;
12192                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12193                next_offset += envelope_size;
12194            }
12195
12196            Ok(())
12197        }
12198    }
12199
12200    impl SecureMemGetPhysicalSecureHeapsResponse {
12201        #[inline(always)]
12202        fn max_ordinal_present(&self) -> u64 {
12203            if let Some(_) = self.heaps {
12204                return 1;
12205            }
12206            0
12207        }
12208    }
12209
12210    impl fidl::encoding::ValueTypeMarker for SecureMemGetPhysicalSecureHeapsResponse {
12211        type Borrowed<'a> = &'a Self;
12212        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
12213            value
12214        }
12215    }
12216
12217    unsafe impl fidl::encoding::TypeMarker for SecureMemGetPhysicalSecureHeapsResponse {
12218        type Owned = Self;
12219
12220        #[inline(always)]
12221        fn inline_align(_context: fidl::encoding::Context) -> usize {
12222            8
12223        }
12224
12225        #[inline(always)]
12226        fn inline_size(_context: fidl::encoding::Context) -> usize {
12227            16
12228        }
12229    }
12230
12231    unsafe impl<D: fidl::encoding::ResourceDialect>
12232        fidl::encoding::Encode<SecureMemGetPhysicalSecureHeapsResponse, D>
12233        for &SecureMemGetPhysicalSecureHeapsResponse
12234    {
12235        unsafe fn encode(
12236            self,
12237            encoder: &mut fidl::encoding::Encoder<'_, D>,
12238            offset: usize,
12239            mut depth: fidl::encoding::Depth,
12240        ) -> fidl::Result<()> {
12241            encoder.debug_check_bounds::<SecureMemGetPhysicalSecureHeapsResponse>(offset);
12242            // Vector header
12243            let max_ordinal: u64 = self.max_ordinal_present();
12244            encoder.write_num(max_ordinal, offset);
12245            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12246            // Calling encoder.out_of_line_offset(0) is not allowed.
12247            if max_ordinal == 0 {
12248                return Ok(());
12249            }
12250            depth.increment()?;
12251            let envelope_size = 8;
12252            let bytes_len = max_ordinal as usize * envelope_size;
12253            #[allow(unused_variables)]
12254            let offset = encoder.out_of_line_offset(bytes_len);
12255            let mut _prev_end_offset: usize = 0;
12256            if 1 > max_ordinal {
12257                return Ok(());
12258            }
12259
12260            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12261            // are envelope_size bytes.
12262            let cur_offset: usize = (1 - 1) * envelope_size;
12263
12264            // Zero reserved fields.
12265            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12266
12267            // Safety:
12268            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12269            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12270            //   envelope_size bytes, there is always sufficient room.
12271            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SecureHeapAndRanges, 32>, D>(
12272            self.heaps.as_ref().map(<fidl::encoding::Vector<SecureHeapAndRanges, 32> as fidl::encoding::ValueTypeMarker>::borrow),
12273            encoder, offset + cur_offset, depth
12274        )?;
12275
12276            _prev_end_offset = cur_offset + envelope_size;
12277
12278            Ok(())
12279        }
12280    }
12281
12282    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
12283        for SecureMemGetPhysicalSecureHeapsResponse
12284    {
12285        #[inline(always)]
12286        fn new_empty() -> Self {
12287            Self::default()
12288        }
12289
12290        unsafe fn decode(
12291            &mut self,
12292            decoder: &mut fidl::encoding::Decoder<'_, D>,
12293            offset: usize,
12294            mut depth: fidl::encoding::Depth,
12295        ) -> fidl::Result<()> {
12296            decoder.debug_check_bounds::<Self>(offset);
12297            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12298                None => return Err(fidl::Error::NotNullable),
12299                Some(len) => len,
12300            };
12301            // Calling decoder.out_of_line_offset(0) is not allowed.
12302            if len == 0 {
12303                return Ok(());
12304            };
12305            depth.increment()?;
12306            let envelope_size = 8;
12307            let bytes_len = len * envelope_size;
12308            let offset = decoder.out_of_line_offset(bytes_len)?;
12309            // Decode the envelope for each type.
12310            let mut _next_ordinal_to_read = 0;
12311            let mut next_offset = offset;
12312            let end_offset = offset + bytes_len;
12313            _next_ordinal_to_read += 1;
12314            if next_offset >= end_offset {
12315                return Ok(());
12316            }
12317
12318            // Decode unknown envelopes for gaps in ordinals.
12319            while _next_ordinal_to_read < 1 {
12320                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12321                _next_ordinal_to_read += 1;
12322                next_offset += envelope_size;
12323            }
12324
12325            let next_out_of_line = decoder.next_out_of_line();
12326            let handles_before = decoder.remaining_handles();
12327            if let Some((inlined, num_bytes, num_handles)) =
12328                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12329            {
12330                let member_inline_size = <fidl::encoding::Vector<SecureHeapAndRanges, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12331                if inlined != (member_inline_size <= 4) {
12332                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12333                }
12334                let inner_offset;
12335                let mut inner_depth = depth.clone();
12336                if inlined {
12337                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12338                    inner_offset = next_offset;
12339                } else {
12340                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12341                    inner_depth.increment()?;
12342                }
12343                let val_ref = self.heaps.get_or_insert_with(
12344                    || fidl::new_empty!(fidl::encoding::Vector<SecureHeapAndRanges, 32>, D),
12345                );
12346                fidl::decode!(fidl::encoding::Vector<SecureHeapAndRanges, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
12347                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12348                {
12349                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12350                }
12351                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12352                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12353                }
12354            }
12355
12356            next_offset += envelope_size;
12357
12358            // Decode the remaining unknown envelopes.
12359            while next_offset < end_offset {
12360                _next_ordinal_to_read += 1;
12361                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12362                next_offset += envelope_size;
12363            }
12364
12365            Ok(())
12366        }
12367    }
12368
12369    impl SingleBufferSettings {
12370        #[inline(always)]
12371        fn max_ordinal_present(&self) -> u64 {
12372            if let Some(_) = self.image_format_constraints {
12373                return 2;
12374            }
12375            if let Some(_) = self.buffer_settings {
12376                return 1;
12377            }
12378            0
12379        }
12380    }
12381
12382    impl fidl::encoding::ValueTypeMarker for SingleBufferSettings {
12383        type Borrowed<'a> = &'a Self;
12384        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
12385            value
12386        }
12387    }
12388
12389    unsafe impl fidl::encoding::TypeMarker for SingleBufferSettings {
12390        type Owned = Self;
12391
12392        #[inline(always)]
12393        fn inline_align(_context: fidl::encoding::Context) -> usize {
12394            8
12395        }
12396
12397        #[inline(always)]
12398        fn inline_size(_context: fidl::encoding::Context) -> usize {
12399            16
12400        }
12401    }
12402
12403    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SingleBufferSettings, D>
12404        for &SingleBufferSettings
12405    {
12406        unsafe fn encode(
12407            self,
12408            encoder: &mut fidl::encoding::Encoder<'_, D>,
12409            offset: usize,
12410            mut depth: fidl::encoding::Depth,
12411        ) -> fidl::Result<()> {
12412            encoder.debug_check_bounds::<SingleBufferSettings>(offset);
12413            // Vector header
12414            let max_ordinal: u64 = self.max_ordinal_present();
12415            encoder.write_num(max_ordinal, offset);
12416            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12417            // Calling encoder.out_of_line_offset(0) is not allowed.
12418            if max_ordinal == 0 {
12419                return Ok(());
12420            }
12421            depth.increment()?;
12422            let envelope_size = 8;
12423            let bytes_len = max_ordinal as usize * envelope_size;
12424            #[allow(unused_variables)]
12425            let offset = encoder.out_of_line_offset(bytes_len);
12426            let mut _prev_end_offset: usize = 0;
12427            if 1 > max_ordinal {
12428                return Ok(());
12429            }
12430
12431            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12432            // are envelope_size bytes.
12433            let cur_offset: usize = (1 - 1) * envelope_size;
12434
12435            // Zero reserved fields.
12436            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12437
12438            // Safety:
12439            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12440            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12441            //   envelope_size bytes, there is always sufficient room.
12442            fidl::encoding::encode_in_envelope_optional::<BufferMemorySettings, D>(
12443                self.buffer_settings
12444                    .as_ref()
12445                    .map(<BufferMemorySettings as fidl::encoding::ValueTypeMarker>::borrow),
12446                encoder,
12447                offset + cur_offset,
12448                depth,
12449            )?;
12450
12451            _prev_end_offset = cur_offset + envelope_size;
12452            if 2 > max_ordinal {
12453                return Ok(());
12454            }
12455
12456            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12457            // are envelope_size bytes.
12458            let cur_offset: usize = (2 - 1) * envelope_size;
12459
12460            // Zero reserved fields.
12461            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12462
12463            // Safety:
12464            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12465            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12466            //   envelope_size bytes, there is always sufficient room.
12467            fidl::encoding::encode_in_envelope_optional::<ImageFormatConstraints, D>(
12468                self.image_format_constraints
12469                    .as_ref()
12470                    .map(<ImageFormatConstraints as fidl::encoding::ValueTypeMarker>::borrow),
12471                encoder,
12472                offset + cur_offset,
12473                depth,
12474            )?;
12475
12476            _prev_end_offset = cur_offset + envelope_size;
12477
12478            Ok(())
12479        }
12480    }
12481
12482    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SingleBufferSettings {
12483        #[inline(always)]
12484        fn new_empty() -> Self {
12485            Self::default()
12486        }
12487
12488        unsafe fn decode(
12489            &mut self,
12490            decoder: &mut fidl::encoding::Decoder<'_, D>,
12491            offset: usize,
12492            mut depth: fidl::encoding::Depth,
12493        ) -> fidl::Result<()> {
12494            decoder.debug_check_bounds::<Self>(offset);
12495            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12496                None => return Err(fidl::Error::NotNullable),
12497                Some(len) => len,
12498            };
12499            // Calling decoder.out_of_line_offset(0) is not allowed.
12500            if len == 0 {
12501                return Ok(());
12502            };
12503            depth.increment()?;
12504            let envelope_size = 8;
12505            let bytes_len = len * envelope_size;
12506            let offset = decoder.out_of_line_offset(bytes_len)?;
12507            // Decode the envelope for each type.
12508            let mut _next_ordinal_to_read = 0;
12509            let mut next_offset = offset;
12510            let end_offset = offset + bytes_len;
12511            _next_ordinal_to_read += 1;
12512            if next_offset >= end_offset {
12513                return Ok(());
12514            }
12515
12516            // Decode unknown envelopes for gaps in ordinals.
12517            while _next_ordinal_to_read < 1 {
12518                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12519                _next_ordinal_to_read += 1;
12520                next_offset += envelope_size;
12521            }
12522
12523            let next_out_of_line = decoder.next_out_of_line();
12524            let handles_before = decoder.remaining_handles();
12525            if let Some((inlined, num_bytes, num_handles)) =
12526                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12527            {
12528                let member_inline_size =
12529                    <BufferMemorySettings as fidl::encoding::TypeMarker>::inline_size(
12530                        decoder.context,
12531                    );
12532                if inlined != (member_inline_size <= 4) {
12533                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12534                }
12535                let inner_offset;
12536                let mut inner_depth = depth.clone();
12537                if inlined {
12538                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12539                    inner_offset = next_offset;
12540                } else {
12541                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12542                    inner_depth.increment()?;
12543                }
12544                let val_ref = self
12545                    .buffer_settings
12546                    .get_or_insert_with(|| fidl::new_empty!(BufferMemorySettings, D));
12547                fidl::decode!(
12548                    BufferMemorySettings,
12549                    D,
12550                    val_ref,
12551                    decoder,
12552                    inner_offset,
12553                    inner_depth
12554                )?;
12555                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12556                {
12557                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12558                }
12559                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12560                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12561                }
12562            }
12563
12564            next_offset += envelope_size;
12565            _next_ordinal_to_read += 1;
12566            if next_offset >= end_offset {
12567                return Ok(());
12568            }
12569
12570            // Decode unknown envelopes for gaps in ordinals.
12571            while _next_ordinal_to_read < 2 {
12572                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12573                _next_ordinal_to_read += 1;
12574                next_offset += envelope_size;
12575            }
12576
12577            let next_out_of_line = decoder.next_out_of_line();
12578            let handles_before = decoder.remaining_handles();
12579            if let Some((inlined, num_bytes, num_handles)) =
12580                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12581            {
12582                let member_inline_size =
12583                    <ImageFormatConstraints as fidl::encoding::TypeMarker>::inline_size(
12584                        decoder.context,
12585                    );
12586                if inlined != (member_inline_size <= 4) {
12587                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12588                }
12589                let inner_offset;
12590                let mut inner_depth = depth.clone();
12591                if inlined {
12592                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12593                    inner_offset = next_offset;
12594                } else {
12595                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12596                    inner_depth.increment()?;
12597                }
12598                let val_ref = self
12599                    .image_format_constraints
12600                    .get_or_insert_with(|| fidl::new_empty!(ImageFormatConstraints, D));
12601                fidl::decode!(
12602                    ImageFormatConstraints,
12603                    D,
12604                    val_ref,
12605                    decoder,
12606                    inner_offset,
12607                    inner_depth
12608                )?;
12609                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12610                {
12611                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12612                }
12613                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12614                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12615                }
12616            }
12617
12618            next_offset += envelope_size;
12619
12620            // Decode the remaining unknown envelopes.
12621            while next_offset < end_offset {
12622                _next_ordinal_to_read += 1;
12623                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12624                next_offset += envelope_size;
12625            }
12626
12627            Ok(())
12628        }
12629    }
12630}