fidl_fuchsia_ui_pointer_augment_common/
fidl_fuchsia_ui_pointer_augment_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/// A floating point two-dimensional point.
12/// - The values are placed in (x, y) order.
13pub type Point2 = [f32; 2];
14
15/// Abnormal conditions for augmentation protocols.
16#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
17#[repr(u32)]
18pub enum ErrorReason {
19    /// The augmentation attempt was denied.
20    Denied = 1,
21}
22
23impl ErrorReason {
24    #[inline]
25    pub fn from_primitive(prim: u32) -> Option<Self> {
26        match prim {
27            1 => Some(Self::Denied),
28            _ => None,
29        }
30    }
31
32    #[inline]
33    pub const fn into_primitive(self) -> u32 {
34        self as u32
35    }
36}
37
38/// An augmentation of [`fuchsia.ui.pointer.TouchEvent`] to provide local-hit
39/// data for a touch event.
40///
41/// For a given touch event `e`, consider the ordered list of intersections with
42/// graphical content: its "hits" from top to bottom. The "local hit" of `e` is
43/// the location of `e` in the coordinate system of the view in which `e` has
44/// the top-most intersection.
45#[derive(Clone, Debug, PartialEq)]
46pub struct TouchEventWithLocalHit {
47    /// Identical usage to [`fuchsia.ui.pointer.TouchEvent`].
48    pub touch_event: fidl_fuchsia_ui_pointer::TouchEvent,
49    /// Augmented data for `touch_event` that describes the top-most client
50    /// KOID that it hits.
51    pub local_viewref_koid: u64,
52    /// Augmented data for `touch_event` that describes its local coordinates in
53    /// the coordinate space for `local_viewref_koid`.
54    pub local_point: [f32; 2],
55}
56
57impl fidl::Persistable for TouchEventWithLocalHit {}
58
59#[derive(Clone, Debug, PartialEq)]
60pub struct TouchSourceWithLocalHitUpdateResponseRequest {
61    pub interaction: fidl_fuchsia_ui_pointer::TouchInteractionId,
62    pub response: fidl_fuchsia_ui_pointer::TouchResponse,
63}
64
65impl fidl::Persistable for TouchSourceWithLocalHitUpdateResponseRequest {}
66
67#[derive(Clone, Debug, PartialEq)]
68pub struct TouchSourceWithLocalHitWatchRequest {
69    pub responses: Vec<fidl_fuchsia_ui_pointer::TouchResponse>,
70}
71
72impl fidl::Persistable for TouchSourceWithLocalHitWatchRequest {}
73
74#[derive(Clone, Debug, PartialEq)]
75pub struct TouchSourceWithLocalHitWatchResponse {
76    pub events: Vec<TouchEventWithLocalHit>,
77}
78
79impl fidl::Persistable for TouchSourceWithLocalHitWatchResponse {}
80
81mod internal {
82    use super::*;
83    unsafe impl fidl::encoding::TypeMarker for ErrorReason {
84        type Owned = Self;
85
86        #[inline(always)]
87        fn inline_align(_context: fidl::encoding::Context) -> usize {
88            std::mem::align_of::<u32>()
89        }
90
91        #[inline(always)]
92        fn inline_size(_context: fidl::encoding::Context) -> usize {
93            std::mem::size_of::<u32>()
94        }
95
96        #[inline(always)]
97        fn encode_is_copy() -> bool {
98            true
99        }
100
101        #[inline(always)]
102        fn decode_is_copy() -> bool {
103            false
104        }
105    }
106
107    impl fidl::encoding::ValueTypeMarker for ErrorReason {
108        type Borrowed<'a> = Self;
109        #[inline(always)]
110        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
111            *value
112        }
113    }
114
115    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ErrorReason {
116        #[inline]
117        unsafe fn encode(
118            self,
119            encoder: &mut fidl::encoding::Encoder<'_, D>,
120            offset: usize,
121            _depth: fidl::encoding::Depth,
122        ) -> fidl::Result<()> {
123            encoder.debug_check_bounds::<Self>(offset);
124            encoder.write_num(self.into_primitive(), offset);
125            Ok(())
126        }
127    }
128
129    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ErrorReason {
130        #[inline(always)]
131        fn new_empty() -> Self {
132            Self::Denied
133        }
134
135        #[inline]
136        unsafe fn decode(
137            &mut self,
138            decoder: &mut fidl::encoding::Decoder<'_, D>,
139            offset: usize,
140            _depth: fidl::encoding::Depth,
141        ) -> fidl::Result<()> {
142            decoder.debug_check_bounds::<Self>(offset);
143            let prim = decoder.read_num::<u32>(offset);
144
145            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
146            Ok(())
147        }
148    }
149
150    impl fidl::encoding::ValueTypeMarker for TouchEventWithLocalHit {
151        type Borrowed<'a> = &'a Self;
152        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
153            value
154        }
155    }
156
157    unsafe impl fidl::encoding::TypeMarker for TouchEventWithLocalHit {
158        type Owned = Self;
159
160        #[inline(always)]
161        fn inline_align(_context: fidl::encoding::Context) -> usize {
162            8
163        }
164
165        #[inline(always)]
166        fn inline_size(_context: fidl::encoding::Context) -> usize {
167            32
168        }
169    }
170
171    unsafe impl<D: fidl::encoding::ResourceDialect>
172        fidl::encoding::Encode<TouchEventWithLocalHit, D> for &TouchEventWithLocalHit
173    {
174        #[inline]
175        unsafe fn encode(
176            self,
177            encoder: &mut fidl::encoding::Encoder<'_, D>,
178            offset: usize,
179            _depth: fidl::encoding::Depth,
180        ) -> fidl::Result<()> {
181            encoder.debug_check_bounds::<TouchEventWithLocalHit>(offset);
182            // Delegate to tuple encoding.
183            fidl::encoding::Encode::<TouchEventWithLocalHit, D>::encode(
184                (
185                    <fidl_fuchsia_ui_pointer::TouchEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.touch_event),
186                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.local_viewref_koid),
187                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow(&self.local_point),
188                ),
189                encoder, offset, _depth
190            )
191        }
192    }
193    unsafe impl<
194            D: fidl::encoding::ResourceDialect,
195            T0: fidl::encoding::Encode<fidl_fuchsia_ui_pointer::TouchEvent, D>,
196            T1: fidl::encoding::Encode<u64, D>,
197            T2: fidl::encoding::Encode<fidl::encoding::Array<f32, 2>, D>,
198        > fidl::encoding::Encode<TouchEventWithLocalHit, D> for (T0, T1, T2)
199    {
200        #[inline]
201        unsafe fn encode(
202            self,
203            encoder: &mut fidl::encoding::Encoder<'_, D>,
204            offset: usize,
205            depth: fidl::encoding::Depth,
206        ) -> fidl::Result<()> {
207            encoder.debug_check_bounds::<TouchEventWithLocalHit>(offset);
208            // Zero out padding regions. There's no need to apply masks
209            // because the unmasked parts will be overwritten by fields.
210            // Write the fields.
211            self.0.encode(encoder, offset + 0, depth)?;
212            self.1.encode(encoder, offset + 16, depth)?;
213            self.2.encode(encoder, offset + 24, depth)?;
214            Ok(())
215        }
216    }
217
218    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
219        for TouchEventWithLocalHit
220    {
221        #[inline(always)]
222        fn new_empty() -> Self {
223            Self {
224                touch_event: fidl::new_empty!(fidl_fuchsia_ui_pointer::TouchEvent, D),
225                local_viewref_koid: fidl::new_empty!(u64, D),
226                local_point: fidl::new_empty!(fidl::encoding::Array<f32, 2>, D),
227            }
228        }
229
230        #[inline]
231        unsafe fn decode(
232            &mut self,
233            decoder: &mut fidl::encoding::Decoder<'_, D>,
234            offset: usize,
235            _depth: fidl::encoding::Depth,
236        ) -> fidl::Result<()> {
237            decoder.debug_check_bounds::<Self>(offset);
238            // Verify that padding bytes are zero.
239            fidl::decode!(
240                fidl_fuchsia_ui_pointer::TouchEvent,
241                D,
242                &mut self.touch_event,
243                decoder,
244                offset + 0,
245                _depth
246            )?;
247            fidl::decode!(u64, D, &mut self.local_viewref_koid, decoder, offset + 16, _depth)?;
248            fidl::decode!(fidl::encoding::Array<f32, 2>, D, &mut self.local_point, decoder, offset + 24, _depth)?;
249            Ok(())
250        }
251    }
252
253    impl fidl::encoding::ValueTypeMarker for TouchSourceWithLocalHitUpdateResponseRequest {
254        type Borrowed<'a> = &'a Self;
255        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
256            value
257        }
258    }
259
260    unsafe impl fidl::encoding::TypeMarker for TouchSourceWithLocalHitUpdateResponseRequest {
261        type Owned = Self;
262
263        #[inline(always)]
264        fn inline_align(_context: fidl::encoding::Context) -> usize {
265            8
266        }
267
268        #[inline(always)]
269        fn inline_size(_context: fidl::encoding::Context) -> usize {
270            32
271        }
272    }
273
274    unsafe impl<D: fidl::encoding::ResourceDialect>
275        fidl::encoding::Encode<TouchSourceWithLocalHitUpdateResponseRequest, D>
276        for &TouchSourceWithLocalHitUpdateResponseRequest
277    {
278        #[inline]
279        unsafe fn encode(
280            self,
281            encoder: &mut fidl::encoding::Encoder<'_, D>,
282            offset: usize,
283            _depth: fidl::encoding::Depth,
284        ) -> fidl::Result<()> {
285            encoder.debug_check_bounds::<TouchSourceWithLocalHitUpdateResponseRequest>(offset);
286            // Delegate to tuple encoding.
287            fidl::encoding::Encode::<TouchSourceWithLocalHitUpdateResponseRequest, D>::encode(
288                (
289                    <fidl_fuchsia_ui_pointer::TouchInteractionId as fidl::encoding::ValueTypeMarker>::borrow(&self.interaction),
290                    <fidl_fuchsia_ui_pointer::TouchResponse as fidl::encoding::ValueTypeMarker>::borrow(&self.response),
291                ),
292                encoder, offset, _depth
293            )
294        }
295    }
296    unsafe impl<
297            D: fidl::encoding::ResourceDialect,
298            T0: fidl::encoding::Encode<fidl_fuchsia_ui_pointer::TouchInteractionId, D>,
299            T1: fidl::encoding::Encode<fidl_fuchsia_ui_pointer::TouchResponse, D>,
300        > fidl::encoding::Encode<TouchSourceWithLocalHitUpdateResponseRequest, D> for (T0, T1)
301    {
302        #[inline]
303        unsafe fn encode(
304            self,
305            encoder: &mut fidl::encoding::Encoder<'_, D>,
306            offset: usize,
307            depth: fidl::encoding::Depth,
308        ) -> fidl::Result<()> {
309            encoder.debug_check_bounds::<TouchSourceWithLocalHitUpdateResponseRequest>(offset);
310            // Zero out padding regions. There's no need to apply masks
311            // because the unmasked parts will be overwritten by fields.
312            unsafe {
313                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
314                (ptr as *mut u64).write_unaligned(0);
315            }
316            // Write the fields.
317            self.0.encode(encoder, offset + 0, depth)?;
318            self.1.encode(encoder, offset + 16, depth)?;
319            Ok(())
320        }
321    }
322
323    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
324        for TouchSourceWithLocalHitUpdateResponseRequest
325    {
326        #[inline(always)]
327        fn new_empty() -> Self {
328            Self {
329                interaction: fidl::new_empty!(fidl_fuchsia_ui_pointer::TouchInteractionId, D),
330                response: fidl::new_empty!(fidl_fuchsia_ui_pointer::TouchResponse, D),
331            }
332        }
333
334        #[inline]
335        unsafe fn decode(
336            &mut self,
337            decoder: &mut fidl::encoding::Decoder<'_, D>,
338            offset: usize,
339            _depth: fidl::encoding::Depth,
340        ) -> fidl::Result<()> {
341            decoder.debug_check_bounds::<Self>(offset);
342            // Verify that padding bytes are zero.
343            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
344            let padval = unsafe { (ptr as *const u64).read_unaligned() };
345            let mask = 0xffffffff00000000u64;
346            let maskedval = padval & mask;
347            if maskedval != 0 {
348                return Err(fidl::Error::NonZeroPadding {
349                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
350                });
351            }
352            fidl::decode!(
353                fidl_fuchsia_ui_pointer::TouchInteractionId,
354                D,
355                &mut self.interaction,
356                decoder,
357                offset + 0,
358                _depth
359            )?;
360            fidl::decode!(
361                fidl_fuchsia_ui_pointer::TouchResponse,
362                D,
363                &mut self.response,
364                decoder,
365                offset + 16,
366                _depth
367            )?;
368            Ok(())
369        }
370    }
371
372    impl fidl::encoding::ValueTypeMarker for TouchSourceWithLocalHitWatchRequest {
373        type Borrowed<'a> = &'a Self;
374        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
375            value
376        }
377    }
378
379    unsafe impl fidl::encoding::TypeMarker for TouchSourceWithLocalHitWatchRequest {
380        type Owned = Self;
381
382        #[inline(always)]
383        fn inline_align(_context: fidl::encoding::Context) -> usize {
384            8
385        }
386
387        #[inline(always)]
388        fn inline_size(_context: fidl::encoding::Context) -> usize {
389            16
390        }
391    }
392
393    unsafe impl<D: fidl::encoding::ResourceDialect>
394        fidl::encoding::Encode<TouchSourceWithLocalHitWatchRequest, D>
395        for &TouchSourceWithLocalHitWatchRequest
396    {
397        #[inline]
398        unsafe fn encode(
399            self,
400            encoder: &mut fidl::encoding::Encoder<'_, D>,
401            offset: usize,
402            _depth: fidl::encoding::Depth,
403        ) -> fidl::Result<()> {
404            encoder.debug_check_bounds::<TouchSourceWithLocalHitWatchRequest>(offset);
405            // Delegate to tuple encoding.
406            fidl::encoding::Encode::<TouchSourceWithLocalHitWatchRequest, D>::encode(
407                (
408                    <fidl::encoding::Vector<fidl_fuchsia_ui_pointer::TouchResponse, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.responses),
409                ),
410                encoder, offset, _depth
411            )
412        }
413    }
414    unsafe impl<
415            D: fidl::encoding::ResourceDialect,
416            T0: fidl::encoding::Encode<
417                fidl::encoding::Vector<fidl_fuchsia_ui_pointer::TouchResponse, 128>,
418                D,
419            >,
420        > fidl::encoding::Encode<TouchSourceWithLocalHitWatchRequest, D> for (T0,)
421    {
422        #[inline]
423        unsafe fn encode(
424            self,
425            encoder: &mut fidl::encoding::Encoder<'_, D>,
426            offset: usize,
427            depth: fidl::encoding::Depth,
428        ) -> fidl::Result<()> {
429            encoder.debug_check_bounds::<TouchSourceWithLocalHitWatchRequest>(offset);
430            // Zero out padding regions. There's no need to apply masks
431            // because the unmasked parts will be overwritten by fields.
432            // Write the fields.
433            self.0.encode(encoder, offset + 0, depth)?;
434            Ok(())
435        }
436    }
437
438    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
439        for TouchSourceWithLocalHitWatchRequest
440    {
441        #[inline(always)]
442        fn new_empty() -> Self {
443            Self {
444                responses: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_ui_pointer::TouchResponse, 128>, D),
445            }
446        }
447
448        #[inline]
449        unsafe fn decode(
450            &mut self,
451            decoder: &mut fidl::encoding::Decoder<'_, D>,
452            offset: usize,
453            _depth: fidl::encoding::Depth,
454        ) -> fidl::Result<()> {
455            decoder.debug_check_bounds::<Self>(offset);
456            // Verify that padding bytes are zero.
457            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_ui_pointer::TouchResponse, 128>, D, &mut self.responses, decoder, offset + 0, _depth)?;
458            Ok(())
459        }
460    }
461
462    impl fidl::encoding::ValueTypeMarker for TouchSourceWithLocalHitWatchResponse {
463        type Borrowed<'a> = &'a Self;
464        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
465            value
466        }
467    }
468
469    unsafe impl fidl::encoding::TypeMarker for TouchSourceWithLocalHitWatchResponse {
470        type Owned = Self;
471
472        #[inline(always)]
473        fn inline_align(_context: fidl::encoding::Context) -> usize {
474            8
475        }
476
477        #[inline(always)]
478        fn inline_size(_context: fidl::encoding::Context) -> usize {
479            16
480        }
481    }
482
483    unsafe impl<D: fidl::encoding::ResourceDialect>
484        fidl::encoding::Encode<TouchSourceWithLocalHitWatchResponse, D>
485        for &TouchSourceWithLocalHitWatchResponse
486    {
487        #[inline]
488        unsafe fn encode(
489            self,
490            encoder: &mut fidl::encoding::Encoder<'_, D>,
491            offset: usize,
492            _depth: fidl::encoding::Depth,
493        ) -> fidl::Result<()> {
494            encoder.debug_check_bounds::<TouchSourceWithLocalHitWatchResponse>(offset);
495            // Delegate to tuple encoding.
496            fidl::encoding::Encode::<TouchSourceWithLocalHitWatchResponse, D>::encode(
497                (
498                    <fidl::encoding::Vector<TouchEventWithLocalHit, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.events),
499                ),
500                encoder, offset, _depth
501            )
502        }
503    }
504    unsafe impl<
505            D: fidl::encoding::ResourceDialect,
506            T0: fidl::encoding::Encode<fidl::encoding::Vector<TouchEventWithLocalHit, 128>, D>,
507        > fidl::encoding::Encode<TouchSourceWithLocalHitWatchResponse, D> for (T0,)
508    {
509        #[inline]
510        unsafe fn encode(
511            self,
512            encoder: &mut fidl::encoding::Encoder<'_, D>,
513            offset: usize,
514            depth: fidl::encoding::Depth,
515        ) -> fidl::Result<()> {
516            encoder.debug_check_bounds::<TouchSourceWithLocalHitWatchResponse>(offset);
517            // Zero out padding regions. There's no need to apply masks
518            // because the unmasked parts will be overwritten by fields.
519            // Write the fields.
520            self.0.encode(encoder, offset + 0, depth)?;
521            Ok(())
522        }
523    }
524
525    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
526        for TouchSourceWithLocalHitWatchResponse
527    {
528        #[inline(always)]
529        fn new_empty() -> Self {
530            Self {
531                events: fidl::new_empty!(fidl::encoding::Vector<TouchEventWithLocalHit, 128>, D),
532            }
533        }
534
535        #[inline]
536        unsafe fn decode(
537            &mut self,
538            decoder: &mut fidl::encoding::Decoder<'_, D>,
539            offset: usize,
540            _depth: fidl::encoding::Depth,
541        ) -> fidl::Result<()> {
542            decoder.debug_check_bounds::<Self>(offset);
543            // Verify that padding bytes are zero.
544            fidl::decode!(fidl::encoding::Vector<TouchEventWithLocalHit, 128>, D, &mut self.events, decoder, offset + 0, _depth)?;
545            Ok(())
546        }
547    }
548}