Skip to main content

fidl_fuchsia_ui_input_internal_common/
fidl_fuchsia_ui_input_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
11bitflags! {
12    /// Orthogonal ownership signal bits asserted on `ownership_event`.
13    ///
14    /// - User Signals 0..1 (`DISPLAY_UNOWNED`, `DISPLAY_PLATFORM_OWNED`) are controlled
15    ///   exclusively by Scenic's `DisplayManager` based on hardware Display
16    ///   Coordinator ownership.
17    /// - User Signal 2 (`ZX_USER_SIGNAL_2 = 0x04000000`) is reserved for future display use.
18    /// - User Signals 3..4 (`INPUT_CLIENT_OWNED`, `INPUT_PLATFORM_OWNED`) are controlled
19    ///   exclusively by Scenic's `ViewTree` evaluator based on single-view +
20    ///   full-screen criteria.
21    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
22    pub struct InputOwnershipSignal: u32 {
23        /// Scenic does NOT own the hardware display (Virtcon owns display and input).
24        /// Controlled by `DisplayManager`. Corresponds to ZX_USER_SIGNAL_0 (0x01000000).
25        const DISPLAY_UNOWNED = 16777216;
26        /// Platform (`Scenic`) owns the hardware display.
27        /// Controlled by `DisplayManager`. Corresponds to ZX_USER_SIGNAL_1 (0x02000000).
28        const DISPLAY_PLATFORM_OWNED = 33554432;
29        /// Target client view (`Starnix`) satisfies single-view + full-screen criteria.
30        /// Controlled by `ViewTree`. Corresponds to ZX_USER_SIGNAL_3 (0x08000000).
31        const INPUT_CLIENT_OWNED = 134217728;
32        /// Platform (`SceneManager` / `InputPipeline`) handles `ViewTree` input.
33        /// Controlled by `ViewTree`. Corresponds to ZX_USER_SIGNAL_4 (0x10000000).
34        const INPUT_PLATFORM_OWNED = 268435456;
35    }
36}
37
38impl InputOwnershipSignal {
39    #[inline(always)]
40    pub fn from_bits_allow_unknown(bits: u32) -> Self {
41        Self::from_bits_retain(bits)
42    }
43
44    #[inline(always)]
45    pub fn has_unknown_bits(&self) -> bool {
46        self.get_unknown_bits() != 0
47    }
48
49    #[inline(always)]
50    pub fn get_unknown_bits(&self) -> u32 {
51        self.bits() & !Self::all().bits()
52    }
53}
54
55/// Errors returned by `InputOwnership.GetEvent`.
56#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
57pub enum InputOwnershipError {
58    /// `target` was set to an unsupported variant or an unknown union variant.
59    InvalidTarget,
60    /// The `ViewRef` has `ZX_KOID_INVALID` or its `ViewRefControl` peer is closed
61    /// (indicating the view was destroyed before this call was handled). This error
62    /// is not returned merely because the view has not attached to the `ViewTree` yet.
63    UnknownView,
64    /// The caller is not permitted to observe ownership for `target`.
65    AccessDenied,
66    #[doc(hidden)]
67    __SourceBreaking { unknown_ordinal: u32 },
68}
69
70/// Pattern that matches an unknown `InputOwnershipError` member.
71#[macro_export]
72macro_rules! InputOwnershipErrorUnknown {
73    () => {
74        _
75    };
76}
77
78impl InputOwnershipError {
79    #[inline]
80    pub fn from_primitive(prim: u32) -> Option<Self> {
81        match prim {
82            1 => Some(Self::InvalidTarget),
83            2 => Some(Self::UnknownView),
84            3 => Some(Self::AccessDenied),
85            _ => None,
86        }
87    }
88
89    #[inline]
90    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
91        match prim {
92            1 => Self::InvalidTarget,
93            2 => Self::UnknownView,
94            3 => Self::AccessDenied,
95            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
96        }
97    }
98
99    #[inline]
100    pub fn unknown() -> Self {
101        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
102    }
103
104    #[inline]
105    pub const fn into_primitive(self) -> u32 {
106        match self {
107            Self::InvalidTarget => 1,
108            Self::UnknownView => 2,
109            Self::AccessDenied => 3,
110            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
111        }
112    }
113
114    #[inline]
115    pub fn is_unknown(&self) -> bool {
116        match self {
117            Self::__SourceBreaking { unknown_ordinal: _ } => true,
118            _ => false,
119        }
120    }
121}
122
123#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
124pub struct Platform;
125
126impl fidl::Persistable for Platform {}
127
128#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
129pub struct Virtcon;
130
131impl fidl::Persistable for Virtcon {}
132
133pub mod input_ownership_ordinals {
134    pub const GET_EVENT: u64 = 0x486e6eebf1f00657;
135}
136
137mod internal {
138    use super::*;
139    unsafe impl fidl::encoding::TypeMarker for InputOwnershipSignal {
140        type Owned = Self;
141
142        #[inline(always)]
143        fn inline_align(_context: fidl::encoding::Context) -> usize {
144            4
145        }
146
147        #[inline(always)]
148        fn inline_size(_context: fidl::encoding::Context) -> usize {
149            4
150        }
151    }
152
153    impl fidl::encoding::ValueTypeMarker for InputOwnershipSignal {
154        type Borrowed<'a> = Self;
155        #[inline(always)]
156        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
157            *value
158        }
159    }
160
161    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
162        for InputOwnershipSignal
163    {
164        #[inline]
165        unsafe fn encode(
166            self,
167            encoder: &mut fidl::encoding::Encoder<'_, D>,
168            offset: usize,
169            _depth: fidl::encoding::Depth,
170        ) -> fidl::Result<()> {
171            encoder.debug_check_bounds::<Self>(offset);
172            encoder.write_num(self.bits(), offset);
173            Ok(())
174        }
175    }
176
177    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InputOwnershipSignal {
178        #[inline(always)]
179        fn new_empty() -> Self {
180            Self::empty()
181        }
182
183        #[inline]
184        unsafe fn decode(
185            &mut self,
186            decoder: &mut fidl::encoding::Decoder<'_, D>,
187            offset: usize,
188            _depth: fidl::encoding::Depth,
189        ) -> fidl::Result<()> {
190            decoder.debug_check_bounds::<Self>(offset);
191            let prim = decoder.read_num::<u32>(offset);
192            *self = Self::from_bits_allow_unknown(prim);
193            Ok(())
194        }
195    }
196    unsafe impl fidl::encoding::TypeMarker for InputOwnershipError {
197        type Owned = Self;
198
199        #[inline(always)]
200        fn inline_align(_context: fidl::encoding::Context) -> usize {
201            std::mem::align_of::<u32>()
202        }
203
204        #[inline(always)]
205        fn inline_size(_context: fidl::encoding::Context) -> usize {
206            std::mem::size_of::<u32>()
207        }
208
209        #[inline(always)]
210        fn encode_is_copy() -> bool {
211            false
212        }
213
214        #[inline(always)]
215        fn decode_is_copy() -> bool {
216            false
217        }
218    }
219
220    impl fidl::encoding::ValueTypeMarker for InputOwnershipError {
221        type Borrowed<'a> = Self;
222        #[inline(always)]
223        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
224            *value
225        }
226    }
227
228    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
229        for InputOwnershipError
230    {
231        #[inline]
232        unsafe fn encode(
233            self,
234            encoder: &mut fidl::encoding::Encoder<'_, D>,
235            offset: usize,
236            _depth: fidl::encoding::Depth,
237        ) -> fidl::Result<()> {
238            encoder.debug_check_bounds::<Self>(offset);
239            encoder.write_num(self.into_primitive(), offset);
240            Ok(())
241        }
242    }
243
244    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InputOwnershipError {
245        #[inline(always)]
246        fn new_empty() -> Self {
247            Self::unknown()
248        }
249
250        #[inline]
251        unsafe fn decode(
252            &mut self,
253            decoder: &mut fidl::encoding::Decoder<'_, D>,
254            offset: usize,
255            _depth: fidl::encoding::Depth,
256        ) -> fidl::Result<()> {
257            decoder.debug_check_bounds::<Self>(offset);
258            let prim = decoder.read_num::<u32>(offset);
259
260            *self = Self::from_primitive_allow_unknown(prim);
261            Ok(())
262        }
263    }
264
265    impl fidl::encoding::ValueTypeMarker for Platform {
266        type Borrowed<'a> = &'a Self;
267        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
268            value
269        }
270    }
271
272    unsafe impl fidl::encoding::TypeMarker for Platform {
273        type Owned = Self;
274
275        #[inline(always)]
276        fn inline_align(_context: fidl::encoding::Context) -> usize {
277            1
278        }
279
280        #[inline(always)]
281        fn inline_size(_context: fidl::encoding::Context) -> usize {
282            1
283        }
284    }
285
286    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Platform, D> for &Platform {
287        #[inline]
288        unsafe fn encode(
289            self,
290            encoder: &mut fidl::encoding::Encoder<'_, D>,
291            offset: usize,
292            _depth: fidl::encoding::Depth,
293        ) -> fidl::Result<()> {
294            encoder.debug_check_bounds::<Platform>(offset);
295            encoder.write_num(0u8, offset);
296            Ok(())
297        }
298    }
299
300    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Platform {
301        #[inline(always)]
302        fn new_empty() -> Self {
303            Self
304        }
305
306        #[inline]
307        unsafe fn decode(
308            &mut self,
309            decoder: &mut fidl::encoding::Decoder<'_, D>,
310            offset: usize,
311            _depth: fidl::encoding::Depth,
312        ) -> fidl::Result<()> {
313            decoder.debug_check_bounds::<Self>(offset);
314            match decoder.read_num::<u8>(offset) {
315                0 => Ok(()),
316                _ => Err(fidl::Error::Invalid),
317            }
318        }
319    }
320
321    impl fidl::encoding::ValueTypeMarker for Virtcon {
322        type Borrowed<'a> = &'a Self;
323        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
324            value
325        }
326    }
327
328    unsafe impl fidl::encoding::TypeMarker for Virtcon {
329        type Owned = Self;
330
331        #[inline(always)]
332        fn inline_align(_context: fidl::encoding::Context) -> usize {
333            1
334        }
335
336        #[inline(always)]
337        fn inline_size(_context: fidl::encoding::Context) -> usize {
338            1
339        }
340    }
341
342    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Virtcon, D> for &Virtcon {
343        #[inline]
344        unsafe fn encode(
345            self,
346            encoder: &mut fidl::encoding::Encoder<'_, D>,
347            offset: usize,
348            _depth: fidl::encoding::Depth,
349        ) -> fidl::Result<()> {
350            encoder.debug_check_bounds::<Virtcon>(offset);
351            encoder.write_num(0u8, offset);
352            Ok(())
353        }
354    }
355
356    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Virtcon {
357        #[inline(always)]
358        fn new_empty() -> Self {
359            Self
360        }
361
362        #[inline]
363        unsafe fn decode(
364            &mut self,
365            decoder: &mut fidl::encoding::Decoder<'_, D>,
366            offset: usize,
367            _depth: fidl::encoding::Depth,
368        ) -> fidl::Result<()> {
369            decoder.debug_check_bounds::<Self>(offset);
370            match decoder.read_num::<u8>(offset) {
371                0 => Ok(()),
372                _ => Err(fidl::Error::Invalid),
373            }
374        }
375    }
376}