fidl_fuchsia_ui_composition_internal_common/
fidl_fuchsia_ui_composition_internal_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 SIGNAL_DISPLAY_NOT_OWNED: u32 = 16777216;
12
13pub const SIGNAL_DISPLAY_OWNED: u32 = 33554432;
14
15/// Possible errors of the ScreenCapture protocol.
16#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
17pub enum ScreenCaptureError {
18    /// One or more of the arguments was missing.
19    MissingArgs,
20    /// One or more of the arguments was not valid.
21    InvalidArgs,
22    /// Indicates that the client has sent an overwritten hanging get.
23    BadHangingGet,
24    #[doc(hidden)]
25    __SourceBreaking { unknown_ordinal: u32 },
26}
27
28/// Pattern that matches an unknown `ScreenCaptureError` member.
29#[macro_export]
30macro_rules! ScreenCaptureErrorUnknown {
31    () => {
32        _
33    };
34}
35
36impl ScreenCaptureError {
37    #[inline]
38    pub fn from_primitive(prim: u32) -> Option<Self> {
39        match prim {
40            1 => Some(Self::MissingArgs),
41            2 => Some(Self::InvalidArgs),
42            3 => Some(Self::BadHangingGet),
43            _ => None,
44        }
45    }
46
47    #[inline]
48    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
49        match prim {
50            1 => Self::MissingArgs,
51            2 => Self::InvalidArgs,
52            3 => Self::BadHangingGet,
53            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
54        }
55    }
56
57    #[inline]
58    pub fn unknown() -> Self {
59        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
60    }
61
62    #[inline]
63    pub const fn into_primitive(self) -> u32 {
64        match self {
65            Self::MissingArgs => 1,
66            Self::InvalidArgs => 2,
67            Self::BadHangingGet => 3,
68            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
69        }
70    }
71
72    #[inline]
73    pub fn is_unknown(&self) -> bool {
74        match self {
75            Self::__SourceBreaking { unknown_ordinal: _ } => true,
76            _ => false,
77        }
78    }
79}
80
81/// Rotation applied to the image.
82/// For example, if the display is rotated 90 degrees according to its
83/// `display_info` config file, the image can be captured as if the display
84/// is not rotated (0 degrees) by applying CW_270_DEGREES.
85#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
86#[repr(u32)]
87pub enum ScreenCaptureRotation {
88    Cw0Degrees = 0,
89    Cw90Degrees = 1,
90    Cw180Degrees = 2,
91    Cw270Degrees = 3,
92}
93
94impl ScreenCaptureRotation {
95    #[inline]
96    pub fn from_primitive(prim: u32) -> Option<Self> {
97        match prim {
98            0 => Some(Self::Cw0Degrees),
99            1 => Some(Self::Cw90Degrees),
100            2 => Some(Self::Cw180Degrees),
101            3 => Some(Self::Cw270Degrees),
102            _ => None,
103        }
104    }
105
106    #[inline]
107    pub const fn into_primitive(self) -> u32 {
108        self as u32
109    }
110
111    #[deprecated = "Strict enums should not use `is_unknown`"]
112    #[inline]
113    pub fn is_unknown(&self) -> bool {
114        false
115    }
116}
117
118mod internal {
119    use super::*;
120    unsafe impl fidl::encoding::TypeMarker for ScreenCaptureError {
121        type Owned = Self;
122
123        #[inline(always)]
124        fn inline_align(_context: fidl::encoding::Context) -> usize {
125            std::mem::align_of::<u32>()
126        }
127
128        #[inline(always)]
129        fn inline_size(_context: fidl::encoding::Context) -> usize {
130            std::mem::size_of::<u32>()
131        }
132
133        #[inline(always)]
134        fn encode_is_copy() -> bool {
135            false
136        }
137
138        #[inline(always)]
139        fn decode_is_copy() -> bool {
140            false
141        }
142    }
143
144    impl fidl::encoding::ValueTypeMarker for ScreenCaptureError {
145        type Borrowed<'a> = Self;
146        #[inline(always)]
147        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
148            *value
149        }
150    }
151
152    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
153        for ScreenCaptureError
154    {
155        #[inline]
156        unsafe fn encode(
157            self,
158            encoder: &mut fidl::encoding::Encoder<'_, D>,
159            offset: usize,
160            _depth: fidl::encoding::Depth,
161        ) -> fidl::Result<()> {
162            encoder.debug_check_bounds::<Self>(offset);
163            encoder.write_num(self.into_primitive(), offset);
164            Ok(())
165        }
166    }
167
168    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ScreenCaptureError {
169        #[inline(always)]
170        fn new_empty() -> Self {
171            Self::unknown()
172        }
173
174        #[inline]
175        unsafe fn decode(
176            &mut self,
177            decoder: &mut fidl::encoding::Decoder<'_, D>,
178            offset: usize,
179            _depth: fidl::encoding::Depth,
180        ) -> fidl::Result<()> {
181            decoder.debug_check_bounds::<Self>(offset);
182            let prim = decoder.read_num::<u32>(offset);
183
184            *self = Self::from_primitive_allow_unknown(prim);
185            Ok(())
186        }
187    }
188    unsafe impl fidl::encoding::TypeMarker for ScreenCaptureRotation {
189        type Owned = Self;
190
191        #[inline(always)]
192        fn inline_align(_context: fidl::encoding::Context) -> usize {
193            std::mem::align_of::<u32>()
194        }
195
196        #[inline(always)]
197        fn inline_size(_context: fidl::encoding::Context) -> usize {
198            std::mem::size_of::<u32>()
199        }
200
201        #[inline(always)]
202        fn encode_is_copy() -> bool {
203            true
204        }
205
206        #[inline(always)]
207        fn decode_is_copy() -> bool {
208            false
209        }
210    }
211
212    impl fidl::encoding::ValueTypeMarker for ScreenCaptureRotation {
213        type Borrowed<'a> = Self;
214        #[inline(always)]
215        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
216            *value
217        }
218    }
219
220    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
221        for ScreenCaptureRotation
222    {
223        #[inline]
224        unsafe fn encode(
225            self,
226            encoder: &mut fidl::encoding::Encoder<'_, D>,
227            offset: usize,
228            _depth: fidl::encoding::Depth,
229        ) -> fidl::Result<()> {
230            encoder.debug_check_bounds::<Self>(offset);
231            encoder.write_num(self.into_primitive(), offset);
232            Ok(())
233        }
234    }
235
236    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ScreenCaptureRotation {
237        #[inline(always)]
238        fn new_empty() -> Self {
239            Self::Cw0Degrees
240        }
241
242        #[inline]
243        unsafe fn decode(
244            &mut self,
245            decoder: &mut fidl::encoding::Decoder<'_, D>,
246            offset: usize,
247            _depth: fidl::encoding::Depth,
248        ) -> fidl::Result<()> {
249            decoder.debug_check_bounds::<Self>(offset);
250            let prim = decoder.read_num::<u32>(offset);
251
252            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
253            Ok(())
254        }
255    }
256}