Skip to main content

fidl_fuchsia_ui_gfx_common/
fidl_fuchsia_ui_gfx_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/// Represents an axis-aligned bounding box.
12///
13/// If any of the dimensions has a negative extent (e.g. max.x < min.x) then the
14/// bounding box is treated as empty. It is valid for a client to define an
15/// empty bounding box.
16///
17/// An "empty bounding box" is one that does not admit a point inhabitant.
18/// Note that a zero-volume, zero-area bounding box (e.g., a point like
19/// (0,0,0)-(0,0,0), or a line like (0,0,0)-(1,0,0)) is thus not empty.
20#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
21pub struct BoundingBox {
22    pub min: Vec3,
23    pub max: Vec3,
24}
25
26impl fidl::Persistable for BoundingBox {}
27
28/// A value that is specified explicitly by `value` if `variable_id` is zero,
29/// or is the value produced by the resource identified by `variable_id`, e.g.
30/// an animation or expression.  In the latter case, the value produced by the
31/// resource must be a vec4, and `value` is ignored.
32#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
33pub struct Matrix4Value {
34    pub value: Mat4,
35    pub variable_id: u32,
36}
37
38impl fidl::Persistable for Matrix4Value {}
39
40#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
41pub struct Mat4 {
42    /// Column major order.
43    pub matrix: [f32; 16],
44}
45
46impl fidl::Persistable for Mat4 {}
47
48#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
49pub struct Vec2 {
50    pub x: f32,
51    pub y: f32,
52}
53
54impl fidl::Persistable for Vec2 {}
55
56#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
57pub struct Vec3 {
58    pub x: f32,
59    pub y: f32,
60    pub z: f32,
61}
62
63impl fidl::Persistable for Vec3 {}
64
65mod internal {
66    use super::*;
67
68    impl fidl::encoding::ValueTypeMarker for BoundingBox {
69        type Borrowed<'a> = &'a Self;
70        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
71            value
72        }
73    }
74
75    unsafe impl fidl::encoding::TypeMarker for BoundingBox {
76        type Owned = Self;
77
78        #[inline(always)]
79        fn inline_align(_context: fidl::encoding::Context) -> usize {
80            4
81        }
82
83        #[inline(always)]
84        fn inline_size(_context: fidl::encoding::Context) -> usize {
85            24
86        }
87    }
88
89    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BoundingBox, D>
90        for &BoundingBox
91    {
92        #[inline]
93        unsafe fn encode(
94            self,
95            encoder: &mut fidl::encoding::Encoder<'_, D>,
96            offset: usize,
97            _depth: fidl::encoding::Depth,
98        ) -> fidl::Result<()> {
99            encoder.debug_check_bounds::<BoundingBox>(offset);
100            // Delegate to tuple encoding.
101            fidl::encoding::Encode::<BoundingBox, D>::encode(
102                (
103                    <Vec3 as fidl::encoding::ValueTypeMarker>::borrow(&self.min),
104                    <Vec3 as fidl::encoding::ValueTypeMarker>::borrow(&self.max),
105                ),
106                encoder,
107                offset,
108                _depth,
109            )
110        }
111    }
112    unsafe impl<
113        D: fidl::encoding::ResourceDialect,
114        T0: fidl::encoding::Encode<Vec3, D>,
115        T1: fidl::encoding::Encode<Vec3, D>,
116    > fidl::encoding::Encode<BoundingBox, D> for (T0, T1)
117    {
118        #[inline]
119        unsafe fn encode(
120            self,
121            encoder: &mut fidl::encoding::Encoder<'_, D>,
122            offset: usize,
123            depth: fidl::encoding::Depth,
124        ) -> fidl::Result<()> {
125            encoder.debug_check_bounds::<BoundingBox>(offset);
126            // Zero out padding regions. There's no need to apply masks
127            // because the unmasked parts will be overwritten by fields.
128            // Write the fields.
129            self.0.encode(encoder, offset + 0, depth)?;
130            self.1.encode(encoder, offset + 12, depth)?;
131            Ok(())
132        }
133    }
134
135    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BoundingBox {
136        #[inline(always)]
137        fn new_empty() -> Self {
138            Self { min: fidl::new_empty!(Vec3, D), max: fidl::new_empty!(Vec3, D) }
139        }
140
141        #[inline]
142        unsafe fn decode(
143            &mut self,
144            decoder: &mut fidl::encoding::Decoder<'_, D>,
145            offset: usize,
146            _depth: fidl::encoding::Depth,
147        ) -> fidl::Result<()> {
148            decoder.debug_check_bounds::<Self>(offset);
149            // Verify that padding bytes are zero.
150            fidl::decode!(Vec3, D, &mut self.min, decoder, offset + 0, _depth)?;
151            fidl::decode!(Vec3, D, &mut self.max, decoder, offset + 12, _depth)?;
152            Ok(())
153        }
154    }
155
156    impl fidl::encoding::ValueTypeMarker for Matrix4Value {
157        type Borrowed<'a> = &'a Self;
158        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
159            value
160        }
161    }
162
163    unsafe impl fidl::encoding::TypeMarker for Matrix4Value {
164        type Owned = Self;
165
166        #[inline(always)]
167        fn inline_align(_context: fidl::encoding::Context) -> usize {
168            4
169        }
170
171        #[inline(always)]
172        fn inline_size(_context: fidl::encoding::Context) -> usize {
173            68
174        }
175    }
176
177    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Matrix4Value, D>
178        for &Matrix4Value
179    {
180        #[inline]
181        unsafe fn encode(
182            self,
183            encoder: &mut fidl::encoding::Encoder<'_, D>,
184            offset: usize,
185            _depth: fidl::encoding::Depth,
186        ) -> fidl::Result<()> {
187            encoder.debug_check_bounds::<Matrix4Value>(offset);
188            // Delegate to tuple encoding.
189            fidl::encoding::Encode::<Matrix4Value, D>::encode(
190                (
191                    <Mat4 as fidl::encoding::ValueTypeMarker>::borrow(&self.value),
192                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.variable_id),
193                ),
194                encoder,
195                offset,
196                _depth,
197            )
198        }
199    }
200    unsafe impl<
201        D: fidl::encoding::ResourceDialect,
202        T0: fidl::encoding::Encode<Mat4, D>,
203        T1: fidl::encoding::Encode<u32, D>,
204    > fidl::encoding::Encode<Matrix4Value, D> for (T0, T1)
205    {
206        #[inline]
207        unsafe fn encode(
208            self,
209            encoder: &mut fidl::encoding::Encoder<'_, D>,
210            offset: usize,
211            depth: fidl::encoding::Depth,
212        ) -> fidl::Result<()> {
213            encoder.debug_check_bounds::<Matrix4Value>(offset);
214            // Zero out padding regions. There's no need to apply masks
215            // because the unmasked parts will be overwritten by fields.
216            // Write the fields.
217            self.0.encode(encoder, offset + 0, depth)?;
218            self.1.encode(encoder, offset + 64, depth)?;
219            Ok(())
220        }
221    }
222
223    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Matrix4Value {
224        #[inline(always)]
225        fn new_empty() -> Self {
226            Self { value: fidl::new_empty!(Mat4, D), variable_id: fidl::new_empty!(u32, D) }
227        }
228
229        #[inline]
230        unsafe fn decode(
231            &mut self,
232            decoder: &mut fidl::encoding::Decoder<'_, D>,
233            offset: usize,
234            _depth: fidl::encoding::Depth,
235        ) -> fidl::Result<()> {
236            decoder.debug_check_bounds::<Self>(offset);
237            // Verify that padding bytes are zero.
238            fidl::decode!(Mat4, D, &mut self.value, decoder, offset + 0, _depth)?;
239            fidl::decode!(u32, D, &mut self.variable_id, decoder, offset + 64, _depth)?;
240            Ok(())
241        }
242    }
243
244    impl fidl::encoding::ValueTypeMarker for Mat4 {
245        type Borrowed<'a> = &'a Self;
246        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
247            value
248        }
249    }
250
251    unsafe impl fidl::encoding::TypeMarker for Mat4 {
252        type Owned = Self;
253
254        #[inline(always)]
255        fn inline_align(_context: fidl::encoding::Context) -> usize {
256            4
257        }
258
259        #[inline(always)]
260        fn inline_size(_context: fidl::encoding::Context) -> usize {
261            64
262        }
263    }
264
265    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Mat4, D> for &Mat4 {
266        #[inline]
267        unsafe fn encode(
268            self,
269            encoder: &mut fidl::encoding::Encoder<'_, D>,
270            offset: usize,
271            _depth: fidl::encoding::Depth,
272        ) -> fidl::Result<()> {
273            encoder.debug_check_bounds::<Mat4>(offset);
274            // Delegate to tuple encoding.
275            fidl::encoding::Encode::<Mat4, D>::encode(
276                (<fidl::encoding::Array<f32, 16> as fidl::encoding::ValueTypeMarker>::borrow(
277                    &self.matrix,
278                ),),
279                encoder,
280                offset,
281                _depth,
282            )
283        }
284    }
285    unsafe impl<
286        D: fidl::encoding::ResourceDialect,
287        T0: fidl::encoding::Encode<fidl::encoding::Array<f32, 16>, D>,
288    > fidl::encoding::Encode<Mat4, D> for (T0,)
289    {
290        #[inline]
291        unsafe fn encode(
292            self,
293            encoder: &mut fidl::encoding::Encoder<'_, D>,
294            offset: usize,
295            depth: fidl::encoding::Depth,
296        ) -> fidl::Result<()> {
297            encoder.debug_check_bounds::<Mat4>(offset);
298            // Zero out padding regions. There's no need to apply masks
299            // because the unmasked parts will be overwritten by fields.
300            // Write the fields.
301            self.0.encode(encoder, offset + 0, depth)?;
302            Ok(())
303        }
304    }
305
306    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Mat4 {
307        #[inline(always)]
308        fn new_empty() -> Self {
309            Self { matrix: fidl::new_empty!(fidl::encoding::Array<f32, 16>, D) }
310        }
311
312        #[inline]
313        unsafe fn decode(
314            &mut self,
315            decoder: &mut fidl::encoding::Decoder<'_, D>,
316            offset: usize,
317            _depth: fidl::encoding::Depth,
318        ) -> fidl::Result<()> {
319            decoder.debug_check_bounds::<Self>(offset);
320            // Verify that padding bytes are zero.
321            fidl::decode!(fidl::encoding::Array<f32, 16>, D, &mut self.matrix, decoder, offset + 0, _depth)?;
322            Ok(())
323        }
324    }
325
326    impl fidl::encoding::ValueTypeMarker for Vec2 {
327        type Borrowed<'a> = &'a Self;
328        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
329            value
330        }
331    }
332
333    unsafe impl fidl::encoding::TypeMarker for Vec2 {
334        type Owned = Self;
335
336        #[inline(always)]
337        fn inline_align(_context: fidl::encoding::Context) -> usize {
338            4
339        }
340
341        #[inline(always)]
342        fn inline_size(_context: fidl::encoding::Context) -> usize {
343            8
344        }
345    }
346
347    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Vec2, D> for &Vec2 {
348        #[inline]
349        unsafe fn encode(
350            self,
351            encoder: &mut fidl::encoding::Encoder<'_, D>,
352            offset: usize,
353            _depth: fidl::encoding::Depth,
354        ) -> fidl::Result<()> {
355            encoder.debug_check_bounds::<Vec2>(offset);
356            // Delegate to tuple encoding.
357            fidl::encoding::Encode::<Vec2, D>::encode(
358                (
359                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.x),
360                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.y),
361                ),
362                encoder,
363                offset,
364                _depth,
365            )
366        }
367    }
368    unsafe impl<
369        D: fidl::encoding::ResourceDialect,
370        T0: fidl::encoding::Encode<f32, D>,
371        T1: fidl::encoding::Encode<f32, D>,
372    > fidl::encoding::Encode<Vec2, D> for (T0, T1)
373    {
374        #[inline]
375        unsafe fn encode(
376            self,
377            encoder: &mut fidl::encoding::Encoder<'_, D>,
378            offset: usize,
379            depth: fidl::encoding::Depth,
380        ) -> fidl::Result<()> {
381            encoder.debug_check_bounds::<Vec2>(offset);
382            // Zero out padding regions. There's no need to apply masks
383            // because the unmasked parts will be overwritten by fields.
384            // Write the fields.
385            self.0.encode(encoder, offset + 0, depth)?;
386            self.1.encode(encoder, offset + 4, depth)?;
387            Ok(())
388        }
389    }
390
391    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Vec2 {
392        #[inline(always)]
393        fn new_empty() -> Self {
394            Self { x: fidl::new_empty!(f32, D), y: fidl::new_empty!(f32, D) }
395        }
396
397        #[inline]
398        unsafe fn decode(
399            &mut self,
400            decoder: &mut fidl::encoding::Decoder<'_, D>,
401            offset: usize,
402            _depth: fidl::encoding::Depth,
403        ) -> fidl::Result<()> {
404            decoder.debug_check_bounds::<Self>(offset);
405            // Verify that padding bytes are zero.
406            fidl::decode!(f32, D, &mut self.x, decoder, offset + 0, _depth)?;
407            fidl::decode!(f32, D, &mut self.y, decoder, offset + 4, _depth)?;
408            Ok(())
409        }
410    }
411
412    impl fidl::encoding::ValueTypeMarker for Vec3 {
413        type Borrowed<'a> = &'a Self;
414        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
415            value
416        }
417    }
418
419    unsafe impl fidl::encoding::TypeMarker for Vec3 {
420        type Owned = Self;
421
422        #[inline(always)]
423        fn inline_align(_context: fidl::encoding::Context) -> usize {
424            4
425        }
426
427        #[inline(always)]
428        fn inline_size(_context: fidl::encoding::Context) -> usize {
429            12
430        }
431    }
432
433    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Vec3, D> for &Vec3 {
434        #[inline]
435        unsafe fn encode(
436            self,
437            encoder: &mut fidl::encoding::Encoder<'_, D>,
438            offset: usize,
439            _depth: fidl::encoding::Depth,
440        ) -> fidl::Result<()> {
441            encoder.debug_check_bounds::<Vec3>(offset);
442            // Delegate to tuple encoding.
443            fidl::encoding::Encode::<Vec3, D>::encode(
444                (
445                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.x),
446                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.y),
447                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.z),
448                ),
449                encoder,
450                offset,
451                _depth,
452            )
453        }
454    }
455    unsafe impl<
456        D: fidl::encoding::ResourceDialect,
457        T0: fidl::encoding::Encode<f32, D>,
458        T1: fidl::encoding::Encode<f32, D>,
459        T2: fidl::encoding::Encode<f32, D>,
460    > fidl::encoding::Encode<Vec3, D> for (T0, T1, T2)
461    {
462        #[inline]
463        unsafe fn encode(
464            self,
465            encoder: &mut fidl::encoding::Encoder<'_, D>,
466            offset: usize,
467            depth: fidl::encoding::Depth,
468        ) -> fidl::Result<()> {
469            encoder.debug_check_bounds::<Vec3>(offset);
470            // Zero out padding regions. There's no need to apply masks
471            // because the unmasked parts will be overwritten by fields.
472            // Write the fields.
473            self.0.encode(encoder, offset + 0, depth)?;
474            self.1.encode(encoder, offset + 4, depth)?;
475            self.2.encode(encoder, offset + 8, depth)?;
476            Ok(())
477        }
478    }
479
480    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Vec3 {
481        #[inline(always)]
482        fn new_empty() -> Self {
483            Self {
484                x: fidl::new_empty!(f32, D),
485                y: fidl::new_empty!(f32, D),
486                z: fidl::new_empty!(f32, D),
487            }
488        }
489
490        #[inline]
491        unsafe fn decode(
492            &mut self,
493            decoder: &mut fidl::encoding::Decoder<'_, D>,
494            offset: usize,
495            _depth: fidl::encoding::Depth,
496        ) -> fidl::Result<()> {
497            decoder.debug_check_bounds::<Self>(offset);
498            // Verify that padding bytes are zero.
499            fidl::decode!(f32, D, &mut self.x, decoder, offset + 0, _depth)?;
500            fidl::decode!(f32, D, &mut self.y, decoder, offset + 4, _depth)?;
501            fidl::decode!(f32, D, &mut self.z, decoder, offset + 8, _depth)?;
502            Ok(())
503        }
504    }
505}