fidl_fuchsia_hardware_display_types__common/
fidl_fuchsia_hardware_display_types__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
11/// Type of the internal value in [`fuchsia.hardware.display.types/DisplayId`].
12pub type DisplayIdValue = u64;
13
14/// Specifies how individual pixels are arranged in an image buffer.
15///
16/// The tiling format influences other image parameters, such as dimensions
17/// and pixel format, that are supported by the display engines. Display engine
18/// drivers currently express this knowledge by setting buffer constraints in
19/// sysmem, and by rejecting invalid combinations.
20///
21/// Values other than [`IMAGE_TILING_TYPE_LINEAR`] and
22/// [`IMAGE_TILING_TYPE_CAPTURE`] are an escape hatch. The driver and image
23/// producer are responsible for agreeing on the meaning of the value, through
24/// some mechanism outside the scope of this API.
25pub type ImageTilingTypeIdValue = u32;
26
27/// Type of the internal value in [`fuchsia.hardware.display.types/ModeId`].
28pub type ModeIdValue = u16;
29
30/// The tiling used by the display engine's capture feature.
31///
32/// This value is used as a signal that the image buffer will used by the
33/// display engine to store displayed contents, and therefore is a slight abuse
34/// of the "tiling" semantics.
35///
36/// Like every other tiling value, this introduces constraints on image
37/// parameters such as dimensions and pixel format.
38pub const IMAGE_TILING_TYPE_CAPTURE: u32 = 10;
39
40/// Equivalent to Vulkan's linear tiling.
41///
42/// Pixels are arranged in the image buffer in row-major order. Each row may
43/// have some padding bytes.
44///
45/// Default for [`ImageTilingTypeIdValue`].
46pub const IMAGE_TILING_TYPE_LINEAR: u32 = 0;
47
48/// Invalid id for displays, images, and events.
49pub const INVALID_DISP_ID: u64 = 0;
50
51/// Invalid id for display modes.
52pub const INVALID_MODE_ID: u16 = 0;
53
54bitflags! {
55    /// Attributes for a [`Mode`].
56    ///
57    /// This type allows for the future expansion of `Mode` with binary attributes,
58    /// such as whether a display mode is interlaced.
59    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
60    pub struct ModeFlags: u32 {
61    }
62}
63
64impl ModeFlags {
65    #[inline(always)]
66    pub fn from_bits_allow_unknown(bits: u32) -> Self {
67        Self::from_bits_retain(bits)
68    }
69
70    #[inline(always)]
71    pub fn has_unknown_bits(&self) -> bool {
72        self.get_unknown_bits() != 0
73    }
74
75    #[inline(always)]
76    pub fn get_unknown_bits(&self) -> u32 {
77        self.bits() & !Self::all().bits()
78    }
79}
80
81#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
82#[repr(u8)]
83pub enum AlphaMode {
84    /// Alpha is disabled for the plane (default).
85    Disable = 0,
86    /// Plane alpha is premultiplied.
87    Premultiplied = 1,
88    /// Hardware should multiply the alpha and color channels when blending.
89    HwMultiply = 2,
90}
91
92impl AlphaMode {
93    #[inline]
94    pub fn from_primitive(prim: u8) -> Option<Self> {
95        match prim {
96            0 => Some(Self::Disable),
97            1 => Some(Self::Premultiplied),
98            2 => Some(Self::HwMultiply),
99            _ => None,
100        }
101    }
102
103    #[inline]
104    pub const fn into_primitive(self) -> u8 {
105        self as u8
106    }
107}
108
109/// The result of checking a draft display config.
110///
111/// Values are produced by [`fuchsia.hardware.display/Coordinator.CheckConfig`].
112#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
113#[repr(u32)]
114pub enum ConfigResult {
115    /// The config is compatible with the current hardware.
116    Ok = 0,
117    /// The config doesn't impact any connected display.
118    ///
119    /// Said differently, the config does not assign layers to any display that
120    /// is still connected to the system. A simple but unlikely case is that the
121    /// client did not assign any layers to any displays. A more complex and
122    /// likely case is that the client did assign layers to at least one
123    /// display, but that display is no longer connected to the system.
124    ///
125    /// Clients should process any display changes and retry the
126    /// [`Coordinator.CheckConfig`] call.
127    EmptyConfig = 1,
128    /// The config is not compatible with any hardware.
129    InvalidConfig = 2,
130    /// The config layer assignment is not supported by the current hardware.
131    UnsupportedConfig = 3,
132    /// The config uses more than the number of connected displays.
133    TooManyDisplays = 4,
134    /// The config display modes are not supported by the current hardware.
135    ///
136    /// The client should try a different set of displays or display modes.
137    UnsupportedDisplayModes = 5,
138}
139
140impl ConfigResult {
141    #[inline]
142    pub fn from_primitive(prim: u32) -> Option<Self> {
143        match prim {
144            0 => Some(Self::Ok),
145            1 => Some(Self::EmptyConfig),
146            2 => Some(Self::InvalidConfig),
147            3 => Some(Self::UnsupportedConfig),
148            4 => Some(Self::TooManyDisplays),
149            5 => Some(Self::UnsupportedDisplayModes),
150            _ => None,
151        }
152    }
153
154    #[inline]
155    pub const fn into_primitive(self) -> u32 {
156        self as u32
157    }
158}
159
160/// Transformations that can be applied by display hardware to input images.
161///
162/// The coordinate system transformations listed here can be implemented in
163/// hardware by display engines, because they have straightforward
164/// implementations for raster images.
165///
166/// Support for input image transformations (every member except for `IDENTITY`)
167/// varies across display engines. This is because each transformation requires
168/// non-trivial hardware modifications that have area (cost) and power
169/// implications.
170#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
171#[repr(u8)]
172pub enum CoordinateTransformation {
173    /// Image pixels are passed through without any change.
174    ///
175    /// This is the only value guaranteed to be supported by all display engine
176    /// drivers.
177    Identity = 0,
178    /// Image pixels are reflected across a line meeting the image's center, parallel to the X axis.
179    ///
180    /// This enum member's numeric value has a single bit set to 1. Any
181    /// transformation whose value has this bit set involves an X reflection.
182    ///
183    /// This transformation is also called an "X flip".
184    ///
185    /// Example:
186    /// |a b c d|      |i j k l|
187    /// |e f g h|  ->  |e f g h|
188    /// |i j k l|      |a b c d|
189    ReflectX = 1,
190    /// Image pixels are reflected across a line meeting the image's center, parallel to the Y axis.
191    ///
192    /// This enum member's numeric value has a single bit set to 1. Any
193    /// transformation whose value has this bit set involves an Y reflection.
194    ///
195    /// This transformation is also called an "Y flip".
196    ///
197    /// Example:
198    /// |a b c d|      |d c b a|
199    /// |e f g h|  ->  |h g f e|
200    /// |i j k l|      |l k j i|
201    ReflectY = 2,
202    /// Image pixels are rotated around the image's center counter-clockwise by 180 degrees.
203    ///
204    /// This is equivalent to applying the `REFLECT_X` and `REFLECT_Y`
205    /// transforms. `REFLECT_X` and `REFLECT_Y` are commutative, so their
206    /// ordering doesn't matter.
207    ///
208    /// Example:
209    /// |a b c d|      |l k j i|
210    /// |e f g h|  ->  |h g f e|
211    /// |i j k l|      |d c b a|
212    RotateCcw180 = 3,
213    /// Image pixels are rotated around the image's center counter-clockwise by 90 degrees.
214    ///
215    /// The image produced by this transformation has different dimensions from
216    /// the input image.
217    ///
218    /// This enum member's numeric value has a single bit set to 1. Any
219    /// transformation whose value has this bit set involves a 90-degree
220    /// counter-clockwise rotation.
221    ///
222    /// Example:
223    /// |a b c d|      |d h l|
224    /// |e f g h|  ->  |c g k|
225    /// |i j k l|      |b f j|
226    ///                |a e i|
227    RotateCcw90 = 4,
228    /// Image pixels are transformed using `ROTATE_CCW_90`, followed by `REFLECT_X`.
229    ///
230    /// The image produced by this transformation has different dimensions from
231    /// the input image.
232    ///
233    /// Example:
234    /// |a b c d|      |a e i|
235    /// |e f g h|  ->  |b f k|
236    /// |i j k l|      |c g k|
237    ///                |d h l|
238    RotateCcw90ReflectX = 5,
239    /// Image pixels are transformed using `ROTATE_CCW_90`, followed by `REFLECT_Y`.
240    ///
241    /// The image produced by this transformation has different dimensions from
242    /// the input image.
243    ///
244    /// Example:
245    /// |a b c d|      |l h d|
246    /// |e f g h|  ->  |k g c|
247    /// |i j k l|      |j f b|
248    ///                |i e a|
249    RotateCcw90ReflectY = 6,
250    /// Image pixels are rotated around the image's center counter-clockwise by 270 degrees.
251    ///
252    /// The image produced by this transformation has different dimensions from
253    /// the input image.
254    ///
255    /// This is equivalent to applying the `ROTATE_CCW_90` transform, followed
256    /// by `REFLECT_X` and `REFLECT_Y`. `REFLECT_X` and `REFLECT_Y` are
257    /// commutative, so their ordering doesn't matter.
258    ///
259    /// Example:
260    /// |a b c d|      |i e a|
261    /// |e f g h|  ->  |j f b|
262    /// |i j k l|      |k g c|
263    ///                |l h d|
264    RotateCcw270 = 7,
265}
266
267impl CoordinateTransformation {
268    #[inline]
269    pub fn from_primitive(prim: u8) -> Option<Self> {
270        match prim {
271            0 => Some(Self::Identity),
272            1 => Some(Self::ReflectX),
273            2 => Some(Self::ReflectY),
274            3 => Some(Self::RotateCcw180),
275            4 => Some(Self::RotateCcw90),
276            5 => Some(Self::RotateCcw90ReflectX),
277            6 => Some(Self::RotateCcw90ReflectY),
278            7 => Some(Self::RotateCcw270),
279            _ => None,
280        }
281    }
282
283    #[inline]
284    pub const fn into_primitive(self) -> u8 {
285        self as u8
286    }
287}
288
289/// The power mode of the display hardware.
290#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
291pub enum PowerMode {
292    /// Minimize power consumption while keeping the display blank.
293    ///
294    /// Conceptually, the user asked that the display be powered off.
295    ///
296    /// All supporting hardware is in the lowest supported power state, which is
297    /// ideally "off".
298    ///
299    /// While in this mode, the display will not generate VSync events.
300    ///
301    /// While in this mode, newly applied display configs will not be reflected
302    /// on the display. The latest applied config will be reflected on the
303    /// display once it enters a different power state.
304    ///
305    /// All display devices must support this power mode.
306    Off,
307    /// Maximize display fidelity, accepting higher power consumption.
308    ///
309    /// Conceptually, the user is fully engaged with the device.
310    ///
311    /// The display may still use power optimizations that do not reduce the
312    /// user perceived displayed image quality, such as DSC (Display Stream
313    /// Compression), dynamic refresh rates, or partial refresh.
314    ///
315    /// All display devices must support this power mode.
316    On,
317    /// Reduce power consumption at the cost of display fidelity.
318    ///
319    /// Conceptually, the user is not fully engaged with the device, but may
320    /// occasionally glance at the screen.
321    ///
322    /// The display hardware may reduce the displayed image quality in order to
323    /// save power. The image quality must remain suitable for presenting
324    /// ambient information to the user.
325    ///
326    /// A display device must support both `DOZE` and `DOZE_SUSPEND` power
327    /// modes, or neither.
328    Doze,
329    /// Reduce power consumption at the cost of display fidelity and freshness.
330    ///
331    /// Conceptually, the user is not fully engaged with the device, but may
332    /// occasionally glance at the screen. Additionally, the user prefers
333    /// saving power to seeing an updated display.
334    ///
335    /// In addition to the power savings allowed by the `DOZE` mode, the display
336    /// hardware is also free to save power by preserving the old display state,
337    /// instead of applying new display configs.
338    ///
339    /// The display still emits VSync events to acknowledge newly applied
340    /// display configs. The latest applied config will be reflected on the
341    /// display once it enters a different power state.
342    ///
343    /// A display device must support both `DOZE` and `DOZE_SUSPEND` power
344    /// modes, or neither.
345    DozeSuspend,
346    #[doc(hidden)]
347    __SourceBreaking { unknown_ordinal: u32 },
348}
349
350/// Pattern that matches an unknown `PowerMode` member.
351#[macro_export]
352macro_rules! PowerModeUnknown {
353    () => {
354        _
355    };
356}
357
358impl PowerMode {
359    #[inline]
360    pub fn from_primitive(prim: u32) -> Option<Self> {
361        match prim {
362            0 => Some(Self::Off),
363            1 => Some(Self::On),
364            2 => Some(Self::Doze),
365            3 => Some(Self::DozeSuspend),
366            _ => None,
367        }
368    }
369
370    #[inline]
371    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
372        match prim {
373            0 => Self::Off,
374            1 => Self::On,
375            2 => Self::Doze,
376            3 => Self::DozeSuspend,
377            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
378        }
379    }
380
381    #[inline]
382    pub fn unknown() -> Self {
383        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
384    }
385
386    #[inline]
387    pub const fn into_primitive(self) -> u32 {
388        match self {
389            Self::Off => 0,
390            Self::On => 1,
391            Self::Doze => 2,
392            Self::DozeSuspend => 3,
393            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
394        }
395    }
396
397    #[inline]
398    pub fn is_unknown(&self) -> bool {
399        match self {
400            Self::__SourceBreaking { unknown_ordinal: _ } => true,
401            _ => false,
402        }
403    }
404}
405
406/// A color constant.
407#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
408pub struct Color {
409    /// The format of pixel data stored in `bytes`.
410    ///
411    /// The format must use a single plane. The encoding of one pixel
412    /// must fit within the `bytes` array.
413    pub format: fidl_fuchsia_images2__common::PixelFormat,
414    /// The constant color, expressed as one pixel encoded using `format`.
415    ///
416    /// The pixel is encoded using little-endian byte ordering and zero padding.
417    /// In other words, the bytes obtained by encoding the pixel using `format`
418    /// are stored starting at the first byte in the array. If the pixel
419    /// requires fewer bytes per pixel than the array size, any unused bytes
420    /// (towards the end of the array) must be set to 0 (zero).
421    pub bytes: [u8; 8],
422}
423
424impl fidl::Persistable for Color {}
425
426/// Unique identifier for a display device attached to the system.
427///
428/// [`fuchsia.hardware.display.types/INVALID_DISP_ID`] represents an invalid
429/// value.
430///
431/// Values are unique within a [`fuchsia.hardware.display/Controller`]
432/// connection. An external display will be associated with different display ID
433/// values if it is disconnected and reconnected.
434///
435/// A display device may be identified by different values across boot cycles or
436/// across different Controller connections. Software that needs to identify
437/// displays (for example, to honor display-specific preferences) should use
438/// [`fuchsia.hardware.display/Info`] identifiers, not display IDs.
439///
440/// This type is not related to the VESA DisplayID standard.
441#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
442#[repr(C)]
443pub struct DisplayId {
444    pub value: u64,
445}
446
447impl fidl::Persistable for DisplayId {}
448
449/// The intended usage for a sysmem BufferCollection holding image buffers.
450///
451/// Each buffer in the collection will store a single image, which is intended
452/// to be used as described below.
453#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
454#[repr(C)]
455pub struct ImageBufferUsage {
456    /// Specifies how individual pixels are arranged in an image buffer.
457    ///
458    /// See [`fuchsia.hardware.display.types/ImageTilingTypeIdValue`].
459    pub tiling_type: u32,
460}
461
462impl fidl::Persistable for ImageBufferUsage {}
463
464/// Describes how an image is stored in a buffer of a sysmem BufferCollection.
465///
466/// The buffer is dedicated to storing a single image. The properties below are
467/// needed for decoding the image from the buffer.
468#[derive(Clone, Debug, PartialEq)]
469pub struct ImageMetadata {
470    /// The image size, in pixels.
471    pub dimensions: fidl_fuchsia_math__common::SizeU,
472    /// Specifies how individual pixels are arranged in an image buffer.
473    ///
474    /// See [`fuchsia.hardware.display.types/ImageTilingTypeIdValue`].
475    pub tiling_type: u32,
476}
477
478impl fidl::Persistable for ImageMetadata {}
479
480/// Describes an operational mode for a display device attached to the system.
481///
482/// The operational parameters that make up a mode description must be updated
483/// atomically, using a resource-intensive "mode setting" operation. Parameters
484/// that can be changed quickly, such as brightness and contrast, do not belong
485/// in a mode description.
486#[derive(Clone, Debug, PartialEq)]
487pub struct Mode {
488    /// The dimensions of the displayed image, in pixels.
489    ///
490    /// This describes the image data sent to the display, which is also called
491    /// the "active area" or "active pixels" in raster scan terminology. Despite
492    /// the name, some of the "active pixels" may not actually be shown to the
493    /// user, for example due to corners or notches.
494    ///
495    /// Valid modes have non-empty active areas.
496    pub active_area: fidl_fuchsia_math__common::SizeU,
497    /// Number of images transmitted to the display in 1,000 seconds.
498    ///
499    /// This quantity is also known as the display's frame rate, or the
500    /// display's vertical refresh rate. The rate is measured in millihertz
501    /// (mHz).
502    ///
503    /// Valid modes have positive refresh rates.
504    pub refresh_rate_millihertz: u32,
505    pub flags: ModeFlags,
506}
507
508impl fidl::Persistable for Mode {}
509
510/// Identifies a supported operational mode for a display.
511///
512/// Values are unique relatively to a [`DisplayId`] value, which is unique
513/// within a [`fuchsia.hardware.display.engine/Engine`] connection.
514///
515/// [`fuchsia.hardware.display.types/INVALID_MODE_ID`] represents an invalid
516/// value.
517#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
518#[repr(C)]
519pub struct ModeId {
520    pub value: u16,
521}
522
523impl fidl::Persistable for ModeId {}
524
525mod internal {
526    use super::*;
527    unsafe impl fidl::encoding::TypeMarker for ModeFlags {
528        type Owned = Self;
529
530        #[inline(always)]
531        fn inline_align(_context: fidl::encoding::Context) -> usize {
532            4
533        }
534
535        #[inline(always)]
536        fn inline_size(_context: fidl::encoding::Context) -> usize {
537            4
538        }
539    }
540
541    impl fidl::encoding::ValueTypeMarker for ModeFlags {
542        type Borrowed<'a> = Self;
543        #[inline(always)]
544        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
545            *value
546        }
547    }
548
549    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ModeFlags {
550        #[inline]
551        unsafe fn encode(
552            self,
553            encoder: &mut fidl::encoding::Encoder<'_, D>,
554            offset: usize,
555            _depth: fidl::encoding::Depth,
556        ) -> fidl::Result<()> {
557            encoder.debug_check_bounds::<Self>(offset);
558            encoder.write_num(self.bits(), offset);
559            Ok(())
560        }
561    }
562
563    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ModeFlags {
564        #[inline(always)]
565        fn new_empty() -> Self {
566            Self::empty()
567        }
568
569        #[inline]
570        unsafe fn decode(
571            &mut self,
572            decoder: &mut fidl::encoding::Decoder<'_, D>,
573            offset: usize,
574            _depth: fidl::encoding::Depth,
575        ) -> fidl::Result<()> {
576            decoder.debug_check_bounds::<Self>(offset);
577            let prim = decoder.read_num::<u32>(offset);
578            *self = Self::from_bits_allow_unknown(prim);
579            Ok(())
580        }
581    }
582    unsafe impl fidl::encoding::TypeMarker for AlphaMode {
583        type Owned = Self;
584
585        #[inline(always)]
586        fn inline_align(_context: fidl::encoding::Context) -> usize {
587            std::mem::align_of::<u8>()
588        }
589
590        #[inline(always)]
591        fn inline_size(_context: fidl::encoding::Context) -> usize {
592            std::mem::size_of::<u8>()
593        }
594
595        #[inline(always)]
596        fn encode_is_copy() -> bool {
597            true
598        }
599
600        #[inline(always)]
601        fn decode_is_copy() -> bool {
602            false
603        }
604    }
605
606    impl fidl::encoding::ValueTypeMarker for AlphaMode {
607        type Borrowed<'a> = Self;
608        #[inline(always)]
609        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
610            *value
611        }
612    }
613
614    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for AlphaMode {
615        #[inline]
616        unsafe fn encode(
617            self,
618            encoder: &mut fidl::encoding::Encoder<'_, D>,
619            offset: usize,
620            _depth: fidl::encoding::Depth,
621        ) -> fidl::Result<()> {
622            encoder.debug_check_bounds::<Self>(offset);
623            encoder.write_num(self.into_primitive(), offset);
624            Ok(())
625        }
626    }
627
628    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AlphaMode {
629        #[inline(always)]
630        fn new_empty() -> Self {
631            Self::Disable
632        }
633
634        #[inline]
635        unsafe fn decode(
636            &mut self,
637            decoder: &mut fidl::encoding::Decoder<'_, D>,
638            offset: usize,
639            _depth: fidl::encoding::Depth,
640        ) -> fidl::Result<()> {
641            decoder.debug_check_bounds::<Self>(offset);
642            let prim = decoder.read_num::<u8>(offset);
643
644            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
645            Ok(())
646        }
647    }
648    unsafe impl fidl::encoding::TypeMarker for ConfigResult {
649        type Owned = Self;
650
651        #[inline(always)]
652        fn inline_align(_context: fidl::encoding::Context) -> usize {
653            std::mem::align_of::<u32>()
654        }
655
656        #[inline(always)]
657        fn inline_size(_context: fidl::encoding::Context) -> usize {
658            std::mem::size_of::<u32>()
659        }
660
661        #[inline(always)]
662        fn encode_is_copy() -> bool {
663            true
664        }
665
666        #[inline(always)]
667        fn decode_is_copy() -> bool {
668            false
669        }
670    }
671
672    impl fidl::encoding::ValueTypeMarker for ConfigResult {
673        type Borrowed<'a> = Self;
674        #[inline(always)]
675        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
676            *value
677        }
678    }
679
680    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ConfigResult {
681        #[inline]
682        unsafe fn encode(
683            self,
684            encoder: &mut fidl::encoding::Encoder<'_, D>,
685            offset: usize,
686            _depth: fidl::encoding::Depth,
687        ) -> fidl::Result<()> {
688            encoder.debug_check_bounds::<Self>(offset);
689            encoder.write_num(self.into_primitive(), offset);
690            Ok(())
691        }
692    }
693
694    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConfigResult {
695        #[inline(always)]
696        fn new_empty() -> Self {
697            Self::Ok
698        }
699
700        #[inline]
701        unsafe fn decode(
702            &mut self,
703            decoder: &mut fidl::encoding::Decoder<'_, D>,
704            offset: usize,
705            _depth: fidl::encoding::Depth,
706        ) -> fidl::Result<()> {
707            decoder.debug_check_bounds::<Self>(offset);
708            let prim = decoder.read_num::<u32>(offset);
709
710            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
711            Ok(())
712        }
713    }
714    unsafe impl fidl::encoding::TypeMarker for CoordinateTransformation {
715        type Owned = Self;
716
717        #[inline(always)]
718        fn inline_align(_context: fidl::encoding::Context) -> usize {
719            std::mem::align_of::<u8>()
720        }
721
722        #[inline(always)]
723        fn inline_size(_context: fidl::encoding::Context) -> usize {
724            std::mem::size_of::<u8>()
725        }
726
727        #[inline(always)]
728        fn encode_is_copy() -> bool {
729            true
730        }
731
732        #[inline(always)]
733        fn decode_is_copy() -> bool {
734            false
735        }
736    }
737
738    impl fidl::encoding::ValueTypeMarker for CoordinateTransformation {
739        type Borrowed<'a> = Self;
740        #[inline(always)]
741        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
742            *value
743        }
744    }
745
746    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
747        for CoordinateTransformation
748    {
749        #[inline]
750        unsafe fn encode(
751            self,
752            encoder: &mut fidl::encoding::Encoder<'_, D>,
753            offset: usize,
754            _depth: fidl::encoding::Depth,
755        ) -> fidl::Result<()> {
756            encoder.debug_check_bounds::<Self>(offset);
757            encoder.write_num(self.into_primitive(), offset);
758            Ok(())
759        }
760    }
761
762    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
763        for CoordinateTransformation
764    {
765        #[inline(always)]
766        fn new_empty() -> Self {
767            Self::Identity
768        }
769
770        #[inline]
771        unsafe fn decode(
772            &mut self,
773            decoder: &mut fidl::encoding::Decoder<'_, D>,
774            offset: usize,
775            _depth: fidl::encoding::Depth,
776        ) -> fidl::Result<()> {
777            decoder.debug_check_bounds::<Self>(offset);
778            let prim = decoder.read_num::<u8>(offset);
779
780            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
781            Ok(())
782        }
783    }
784    unsafe impl fidl::encoding::TypeMarker for PowerMode {
785        type Owned = Self;
786
787        #[inline(always)]
788        fn inline_align(_context: fidl::encoding::Context) -> usize {
789            std::mem::align_of::<u32>()
790        }
791
792        #[inline(always)]
793        fn inline_size(_context: fidl::encoding::Context) -> usize {
794            std::mem::size_of::<u32>()
795        }
796
797        #[inline(always)]
798        fn encode_is_copy() -> bool {
799            false
800        }
801
802        #[inline(always)]
803        fn decode_is_copy() -> bool {
804            false
805        }
806    }
807
808    impl fidl::encoding::ValueTypeMarker for PowerMode {
809        type Borrowed<'a> = Self;
810        #[inline(always)]
811        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
812            *value
813        }
814    }
815
816    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PowerMode {
817        #[inline]
818        unsafe fn encode(
819            self,
820            encoder: &mut fidl::encoding::Encoder<'_, D>,
821            offset: usize,
822            _depth: fidl::encoding::Depth,
823        ) -> fidl::Result<()> {
824            encoder.debug_check_bounds::<Self>(offset);
825            encoder.write_num(self.into_primitive(), offset);
826            Ok(())
827        }
828    }
829
830    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PowerMode {
831        #[inline(always)]
832        fn new_empty() -> Self {
833            Self::unknown()
834        }
835
836        #[inline]
837        unsafe fn decode(
838            &mut self,
839            decoder: &mut fidl::encoding::Decoder<'_, D>,
840            offset: usize,
841            _depth: fidl::encoding::Depth,
842        ) -> fidl::Result<()> {
843            decoder.debug_check_bounds::<Self>(offset);
844            let prim = decoder.read_num::<u32>(offset);
845
846            *self = Self::from_primitive_allow_unknown(prim);
847            Ok(())
848        }
849    }
850
851    impl fidl::encoding::ValueTypeMarker for Color {
852        type Borrowed<'a> = &'a Self;
853        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
854            value
855        }
856    }
857
858    unsafe impl fidl::encoding::TypeMarker for Color {
859        type Owned = Self;
860
861        #[inline(always)]
862        fn inline_align(_context: fidl::encoding::Context) -> usize {
863            4
864        }
865
866        #[inline(always)]
867        fn inline_size(_context: fidl::encoding::Context) -> usize {
868            12
869        }
870    }
871
872    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Color, D> for &Color {
873        #[inline]
874        unsafe fn encode(
875            self,
876            encoder: &mut fidl::encoding::Encoder<'_, D>,
877            offset: usize,
878            _depth: fidl::encoding::Depth,
879        ) -> fidl::Result<()> {
880            encoder.debug_check_bounds::<Color>(offset);
881            // Delegate to tuple encoding.
882            fidl::encoding::Encode::<Color, D>::encode(
883                (
884                    <fidl_fuchsia_images2__common::PixelFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.format),
885                    <fidl::encoding::Array<u8, 8> as fidl::encoding::ValueTypeMarker>::borrow(&self.bytes),
886                ),
887                encoder, offset, _depth
888            )
889        }
890    }
891    unsafe impl<
892        D: fidl::encoding::ResourceDialect,
893        T0: fidl::encoding::Encode<fidl_fuchsia_images2__common::PixelFormat, D>,
894        T1: fidl::encoding::Encode<fidl::encoding::Array<u8, 8>, D>,
895    > fidl::encoding::Encode<Color, D> for (T0, T1)
896    {
897        #[inline]
898        unsafe fn encode(
899            self,
900            encoder: &mut fidl::encoding::Encoder<'_, D>,
901            offset: usize,
902            depth: fidl::encoding::Depth,
903        ) -> fidl::Result<()> {
904            encoder.debug_check_bounds::<Color>(offset);
905            // Zero out padding regions. There's no need to apply masks
906            // because the unmasked parts will be overwritten by fields.
907            // Write the fields.
908            self.0.encode(encoder, offset + 0, depth)?;
909            self.1.encode(encoder, offset + 4, depth)?;
910            Ok(())
911        }
912    }
913
914    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Color {
915        #[inline(always)]
916        fn new_empty() -> Self {
917            Self {
918                format: fidl::new_empty!(fidl_fuchsia_images2__common::PixelFormat, D),
919                bytes: fidl::new_empty!(fidl::encoding::Array<u8, 8>, D),
920            }
921        }
922
923        #[inline]
924        unsafe fn decode(
925            &mut self,
926            decoder: &mut fidl::encoding::Decoder<'_, D>,
927            offset: usize,
928            _depth: fidl::encoding::Depth,
929        ) -> fidl::Result<()> {
930            decoder.debug_check_bounds::<Self>(offset);
931            // Verify that padding bytes are zero.
932            fidl::decode!(
933                fidl_fuchsia_images2__common::PixelFormat,
934                D,
935                &mut self.format,
936                decoder,
937                offset + 0,
938                _depth
939            )?;
940            fidl::decode!(fidl::encoding::Array<u8, 8>, D, &mut self.bytes, decoder, offset + 4, _depth)?;
941            Ok(())
942        }
943    }
944
945    impl fidl::encoding::ValueTypeMarker for DisplayId {
946        type Borrowed<'a> = &'a Self;
947        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
948            value
949        }
950    }
951
952    unsafe impl fidl::encoding::TypeMarker for DisplayId {
953        type Owned = Self;
954
955        #[inline(always)]
956        fn inline_align(_context: fidl::encoding::Context) -> usize {
957            8
958        }
959
960        #[inline(always)]
961        fn inline_size(_context: fidl::encoding::Context) -> usize {
962            8
963        }
964        #[inline(always)]
965        fn encode_is_copy() -> bool {
966            true
967        }
968
969        #[inline(always)]
970        fn decode_is_copy() -> bool {
971            true
972        }
973    }
974
975    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DisplayId, D>
976        for &DisplayId
977    {
978        #[inline]
979        unsafe fn encode(
980            self,
981            encoder: &mut fidl::encoding::Encoder<'_, D>,
982            offset: usize,
983            _depth: fidl::encoding::Depth,
984        ) -> fidl::Result<()> {
985            encoder.debug_check_bounds::<DisplayId>(offset);
986            unsafe {
987                // Copy the object into the buffer.
988                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
989                (buf_ptr as *mut DisplayId).write_unaligned((self as *const DisplayId).read());
990                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
991                // done second because the memcpy will write garbage to these bytes.
992            }
993            Ok(())
994        }
995    }
996    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
997        fidl::encoding::Encode<DisplayId, D> for (T0,)
998    {
999        #[inline]
1000        unsafe fn encode(
1001            self,
1002            encoder: &mut fidl::encoding::Encoder<'_, D>,
1003            offset: usize,
1004            depth: fidl::encoding::Depth,
1005        ) -> fidl::Result<()> {
1006            encoder.debug_check_bounds::<DisplayId>(offset);
1007            // Zero out padding regions. There's no need to apply masks
1008            // because the unmasked parts will be overwritten by fields.
1009            // Write the fields.
1010            self.0.encode(encoder, offset + 0, depth)?;
1011            Ok(())
1012        }
1013    }
1014
1015    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DisplayId {
1016        #[inline(always)]
1017        fn new_empty() -> Self {
1018            Self { value: fidl::new_empty!(u64, D) }
1019        }
1020
1021        #[inline]
1022        unsafe fn decode(
1023            &mut self,
1024            decoder: &mut fidl::encoding::Decoder<'_, D>,
1025            offset: usize,
1026            _depth: fidl::encoding::Depth,
1027        ) -> fidl::Result<()> {
1028            decoder.debug_check_bounds::<Self>(offset);
1029            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1030            // Verify that padding bytes are zero.
1031            // Copy from the buffer into the object.
1032            unsafe {
1033                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1034            }
1035            Ok(())
1036        }
1037    }
1038
1039    impl fidl::encoding::ValueTypeMarker for ImageBufferUsage {
1040        type Borrowed<'a> = &'a Self;
1041        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1042            value
1043        }
1044    }
1045
1046    unsafe impl fidl::encoding::TypeMarker for ImageBufferUsage {
1047        type Owned = Self;
1048
1049        #[inline(always)]
1050        fn inline_align(_context: fidl::encoding::Context) -> usize {
1051            4
1052        }
1053
1054        #[inline(always)]
1055        fn inline_size(_context: fidl::encoding::Context) -> usize {
1056            4
1057        }
1058        #[inline(always)]
1059        fn encode_is_copy() -> bool {
1060            true
1061        }
1062
1063        #[inline(always)]
1064        fn decode_is_copy() -> bool {
1065            true
1066        }
1067    }
1068
1069    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ImageBufferUsage, D>
1070        for &ImageBufferUsage
1071    {
1072        #[inline]
1073        unsafe fn encode(
1074            self,
1075            encoder: &mut fidl::encoding::Encoder<'_, D>,
1076            offset: usize,
1077            _depth: fidl::encoding::Depth,
1078        ) -> fidl::Result<()> {
1079            encoder.debug_check_bounds::<ImageBufferUsage>(offset);
1080            unsafe {
1081                // Copy the object into the buffer.
1082                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1083                (buf_ptr as *mut ImageBufferUsage)
1084                    .write_unaligned((self as *const ImageBufferUsage).read());
1085                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1086                // done second because the memcpy will write garbage to these bytes.
1087            }
1088            Ok(())
1089        }
1090    }
1091    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1092        fidl::encoding::Encode<ImageBufferUsage, D> for (T0,)
1093    {
1094        #[inline]
1095        unsafe fn encode(
1096            self,
1097            encoder: &mut fidl::encoding::Encoder<'_, D>,
1098            offset: usize,
1099            depth: fidl::encoding::Depth,
1100        ) -> fidl::Result<()> {
1101            encoder.debug_check_bounds::<ImageBufferUsage>(offset);
1102            // Zero out padding regions. There's no need to apply masks
1103            // because the unmasked parts will be overwritten by fields.
1104            // Write the fields.
1105            self.0.encode(encoder, offset + 0, depth)?;
1106            Ok(())
1107        }
1108    }
1109
1110    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ImageBufferUsage {
1111        #[inline(always)]
1112        fn new_empty() -> Self {
1113            Self { tiling_type: fidl::new_empty!(u32, D) }
1114        }
1115
1116        #[inline]
1117        unsafe fn decode(
1118            &mut self,
1119            decoder: &mut fidl::encoding::Decoder<'_, D>,
1120            offset: usize,
1121            _depth: fidl::encoding::Depth,
1122        ) -> fidl::Result<()> {
1123            decoder.debug_check_bounds::<Self>(offset);
1124            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1125            // Verify that padding bytes are zero.
1126            // Copy from the buffer into the object.
1127            unsafe {
1128                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1129            }
1130            Ok(())
1131        }
1132    }
1133
1134    impl fidl::encoding::ValueTypeMarker for ImageMetadata {
1135        type Borrowed<'a> = &'a Self;
1136        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1137            value
1138        }
1139    }
1140
1141    unsafe impl fidl::encoding::TypeMarker for ImageMetadata {
1142        type Owned = Self;
1143
1144        #[inline(always)]
1145        fn inline_align(_context: fidl::encoding::Context) -> usize {
1146            4
1147        }
1148
1149        #[inline(always)]
1150        fn inline_size(_context: fidl::encoding::Context) -> usize {
1151            12
1152        }
1153    }
1154
1155    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ImageMetadata, D>
1156        for &ImageMetadata
1157    {
1158        #[inline]
1159        unsafe fn encode(
1160            self,
1161            encoder: &mut fidl::encoding::Encoder<'_, D>,
1162            offset: usize,
1163            _depth: fidl::encoding::Depth,
1164        ) -> fidl::Result<()> {
1165            encoder.debug_check_bounds::<ImageMetadata>(offset);
1166            // Delegate to tuple encoding.
1167            fidl::encoding::Encode::<ImageMetadata, D>::encode(
1168                (
1169                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow(
1170                        &self.dimensions,
1171                    ),
1172                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.tiling_type),
1173                ),
1174                encoder,
1175                offset,
1176                _depth,
1177            )
1178        }
1179    }
1180    unsafe impl<
1181        D: fidl::encoding::ResourceDialect,
1182        T0: fidl::encoding::Encode<fidl_fuchsia_math__common::SizeU, D>,
1183        T1: fidl::encoding::Encode<u32, D>,
1184    > fidl::encoding::Encode<ImageMetadata, D> for (T0, T1)
1185    {
1186        #[inline]
1187        unsafe fn encode(
1188            self,
1189            encoder: &mut fidl::encoding::Encoder<'_, D>,
1190            offset: usize,
1191            depth: fidl::encoding::Depth,
1192        ) -> fidl::Result<()> {
1193            encoder.debug_check_bounds::<ImageMetadata>(offset);
1194            // Zero out padding regions. There's no need to apply masks
1195            // because the unmasked parts will be overwritten by fields.
1196            // Write the fields.
1197            self.0.encode(encoder, offset + 0, depth)?;
1198            self.1.encode(encoder, offset + 8, depth)?;
1199            Ok(())
1200        }
1201    }
1202
1203    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ImageMetadata {
1204        #[inline(always)]
1205        fn new_empty() -> Self {
1206            Self {
1207                dimensions: fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D),
1208                tiling_type: fidl::new_empty!(u32, D),
1209            }
1210        }
1211
1212        #[inline]
1213        unsafe fn decode(
1214            &mut self,
1215            decoder: &mut fidl::encoding::Decoder<'_, D>,
1216            offset: usize,
1217            _depth: fidl::encoding::Depth,
1218        ) -> fidl::Result<()> {
1219            decoder.debug_check_bounds::<Self>(offset);
1220            // Verify that padding bytes are zero.
1221            fidl::decode!(
1222                fidl_fuchsia_math__common::SizeU,
1223                D,
1224                &mut self.dimensions,
1225                decoder,
1226                offset + 0,
1227                _depth
1228            )?;
1229            fidl::decode!(u32, D, &mut self.tiling_type, decoder, offset + 8, _depth)?;
1230            Ok(())
1231        }
1232    }
1233
1234    impl fidl::encoding::ValueTypeMarker for Mode {
1235        type Borrowed<'a> = &'a Self;
1236        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1237            value
1238        }
1239    }
1240
1241    unsafe impl fidl::encoding::TypeMarker for Mode {
1242        type Owned = Self;
1243
1244        #[inline(always)]
1245        fn inline_align(_context: fidl::encoding::Context) -> usize {
1246            4
1247        }
1248
1249        #[inline(always)]
1250        fn inline_size(_context: fidl::encoding::Context) -> usize {
1251            16
1252        }
1253    }
1254
1255    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Mode, D> for &Mode {
1256        #[inline]
1257        unsafe fn encode(
1258            self,
1259            encoder: &mut fidl::encoding::Encoder<'_, D>,
1260            offset: usize,
1261            _depth: fidl::encoding::Depth,
1262        ) -> fidl::Result<()> {
1263            encoder.debug_check_bounds::<Mode>(offset);
1264            // Delegate to tuple encoding.
1265            fidl::encoding::Encode::<Mode, D>::encode(
1266                (
1267                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow(
1268                        &self.active_area,
1269                    ),
1270                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.refresh_rate_millihertz),
1271                    <ModeFlags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1272                ),
1273                encoder,
1274                offset,
1275                _depth,
1276            )
1277        }
1278    }
1279    unsafe impl<
1280        D: fidl::encoding::ResourceDialect,
1281        T0: fidl::encoding::Encode<fidl_fuchsia_math__common::SizeU, D>,
1282        T1: fidl::encoding::Encode<u32, D>,
1283        T2: fidl::encoding::Encode<ModeFlags, D>,
1284    > fidl::encoding::Encode<Mode, D> for (T0, T1, T2)
1285    {
1286        #[inline]
1287        unsafe fn encode(
1288            self,
1289            encoder: &mut fidl::encoding::Encoder<'_, D>,
1290            offset: usize,
1291            depth: fidl::encoding::Depth,
1292        ) -> fidl::Result<()> {
1293            encoder.debug_check_bounds::<Mode>(offset);
1294            // Zero out padding regions. There's no need to apply masks
1295            // because the unmasked parts will be overwritten by fields.
1296            // Write the fields.
1297            self.0.encode(encoder, offset + 0, depth)?;
1298            self.1.encode(encoder, offset + 8, depth)?;
1299            self.2.encode(encoder, offset + 12, depth)?;
1300            Ok(())
1301        }
1302    }
1303
1304    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Mode {
1305        #[inline(always)]
1306        fn new_empty() -> Self {
1307            Self {
1308                active_area: fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D),
1309                refresh_rate_millihertz: fidl::new_empty!(u32, D),
1310                flags: fidl::new_empty!(ModeFlags, D),
1311            }
1312        }
1313
1314        #[inline]
1315        unsafe fn decode(
1316            &mut self,
1317            decoder: &mut fidl::encoding::Decoder<'_, D>,
1318            offset: usize,
1319            _depth: fidl::encoding::Depth,
1320        ) -> fidl::Result<()> {
1321            decoder.debug_check_bounds::<Self>(offset);
1322            // Verify that padding bytes are zero.
1323            fidl::decode!(
1324                fidl_fuchsia_math__common::SizeU,
1325                D,
1326                &mut self.active_area,
1327                decoder,
1328                offset + 0,
1329                _depth
1330            )?;
1331            fidl::decode!(u32, D, &mut self.refresh_rate_millihertz, decoder, offset + 8, _depth)?;
1332            fidl::decode!(ModeFlags, D, &mut self.flags, decoder, offset + 12, _depth)?;
1333            Ok(())
1334        }
1335    }
1336
1337    impl fidl::encoding::ValueTypeMarker for ModeId {
1338        type Borrowed<'a> = &'a Self;
1339        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1340            value
1341        }
1342    }
1343
1344    unsafe impl fidl::encoding::TypeMarker for ModeId {
1345        type Owned = Self;
1346
1347        #[inline(always)]
1348        fn inline_align(_context: fidl::encoding::Context) -> usize {
1349            2
1350        }
1351
1352        #[inline(always)]
1353        fn inline_size(_context: fidl::encoding::Context) -> usize {
1354            2
1355        }
1356        #[inline(always)]
1357        fn encode_is_copy() -> bool {
1358            true
1359        }
1360
1361        #[inline(always)]
1362        fn decode_is_copy() -> bool {
1363            true
1364        }
1365    }
1366
1367    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ModeId, D> for &ModeId {
1368        #[inline]
1369        unsafe fn encode(
1370            self,
1371            encoder: &mut fidl::encoding::Encoder<'_, D>,
1372            offset: usize,
1373            _depth: fidl::encoding::Depth,
1374        ) -> fidl::Result<()> {
1375            encoder.debug_check_bounds::<ModeId>(offset);
1376            unsafe {
1377                // Copy the object into the buffer.
1378                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1379                (buf_ptr as *mut ModeId).write_unaligned((self as *const ModeId).read());
1380                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1381                // done second because the memcpy will write garbage to these bytes.
1382            }
1383            Ok(())
1384        }
1385    }
1386    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u16, D>>
1387        fidl::encoding::Encode<ModeId, D> for (T0,)
1388    {
1389        #[inline]
1390        unsafe fn encode(
1391            self,
1392            encoder: &mut fidl::encoding::Encoder<'_, D>,
1393            offset: usize,
1394            depth: fidl::encoding::Depth,
1395        ) -> fidl::Result<()> {
1396            encoder.debug_check_bounds::<ModeId>(offset);
1397            // Zero out padding regions. There's no need to apply masks
1398            // because the unmasked parts will be overwritten by fields.
1399            // Write the fields.
1400            self.0.encode(encoder, offset + 0, depth)?;
1401            Ok(())
1402        }
1403    }
1404
1405    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ModeId {
1406        #[inline(always)]
1407        fn new_empty() -> Self {
1408            Self { value: fidl::new_empty!(u16, D) }
1409        }
1410
1411        #[inline]
1412        unsafe fn decode(
1413            &mut self,
1414            decoder: &mut fidl::encoding::Decoder<'_, D>,
1415            offset: usize,
1416            _depth: fidl::encoding::Depth,
1417        ) -> fidl::Result<()> {
1418            decoder.debug_check_bounds::<Self>(offset);
1419            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1420            // Verify that padding bytes are zero.
1421            // Copy from the buffer into the object.
1422            unsafe {
1423                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
1424            }
1425            Ok(())
1426        }
1427    }
1428}