1#![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 type DisplayIdValue = u64;
13
14pub type ImageTilingTypeIdValue = u32;
26
27pub type ModeIdValue = u16;
29
30pub const IMAGE_TILING_TYPE_CAPTURE: u32 = 10;
39
40pub const IMAGE_TILING_TYPE_LINEAR: u32 = 0;
47
48pub const INVALID_DISP_ID: u64 = 0;
50
51pub const INVALID_MODE_ID: u16 = 0;
53
54bitflags! {
55 #[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 Disable = 0,
86 Premultiplied = 1,
88 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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
113#[repr(u32)]
114pub enum ConfigResult {
115 Ok = 0,
117 EmptyConfig = 1,
128 InvalidConfig = 2,
130 UnsupportedConfig = 3,
132 TooManyDisplays = 4,
134 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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
171#[repr(u8)]
172pub enum CoordinateTransformation {
173 Identity = 0,
178 ReflectX = 1,
190 ReflectY = 2,
202 RotateCcw180 = 3,
213 RotateCcw90 = 4,
228 RotateCcw90ReflectX = 5,
239 RotateCcw90ReflectY = 6,
250 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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
291pub enum PowerMode {
292 Off,
307 On,
317 Doze,
329 DozeSuspend,
346 #[doc(hidden)]
347 __SourceBreaking { unknown_ordinal: u32 },
348}
349
350#[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#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
408pub struct Color {
409 pub format: fidl_fuchsia_images2__common::PixelFormat,
414 pub bytes: [u8; 8],
422}
423
424impl fidl::Persistable for Color {}
425
426#[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#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
454#[repr(C)]
455pub struct ImageBufferUsage {
456 pub tiling_type: u32,
460}
461
462impl fidl::Persistable for ImageBufferUsage {}
463
464#[derive(Clone, Debug, PartialEq)]
469pub struct ImageMetadata {
470 pub dimensions: fidl_fuchsia_math__common::SizeU,
472 pub tiling_type: u32,
476}
477
478impl fidl::Persistable for ImageMetadata {}
479
480#[derive(Clone, Debug, PartialEq)]
487pub struct Mode {
488 pub active_area: fidl_fuchsia_math__common::SizeU,
497 pub refresh_rate_millihertz: u32,
505 pub flags: ModeFlags,
506}
507
508impl fidl::Persistable for Mode {}
509
510#[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 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 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 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 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
989 (buf_ptr as *mut DisplayId).write_unaligned((self as *const DisplayId).read());
990 }
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 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 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 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 }
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 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 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 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 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 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 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 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 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 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1379 (buf_ptr as *mut ModeId).write_unaligned((self as *const ModeId).read());
1380 }
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 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 unsafe {
1423 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
1424 }
1425 Ok(())
1426 }
1427 }
1428}