fidl_fuchsia_hardware_backlight__common/
fidl_fuchsia_hardware_backlight__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#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
12pub struct DeviceSetStateAbsoluteRequest {
13    pub state: State,
14}
15
16impl fidl::Persistable for DeviceSetStateAbsoluteRequest {}
17
18#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
19pub struct DeviceSetStateNormalizedRequest {
20    pub state: State,
21}
22
23impl fidl::Persistable for DeviceSetStateNormalizedRequest {}
24
25#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
26pub struct DeviceGetMaxAbsoluteBrightnessResponse {
27    pub max_brightness: f64,
28}
29
30impl fidl::Persistable for DeviceGetMaxAbsoluteBrightnessResponse {}
31
32#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
33pub struct DeviceGetStateAbsoluteResponse {
34    pub state: State,
35}
36
37impl fidl::Persistable for DeviceGetStateAbsoluteResponse {}
38
39#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
40pub struct DeviceGetStateNormalizedResponse {
41    pub state: State,
42}
43
44impl fidl::Persistable for DeviceGetStateNormalizedResponse {}
45
46#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
47pub struct State {
48    pub backlight_on: bool,
49    /// `brightness` can either be:
50    /// 1. The unitless brightness value on a linear scale where 0.0 is the minimum
51    ///    brightness and 1.0 is the maximum brightness - represents the current /
52    ///    desired brightness as a percentage within the supported range. Used
53    ///    by the `GetStateNormalized` / `SetStateNormalized` calls. The maximum
54    ///    brightness that can be set using `SetStateNormalized` is
55    ///    GetBrightnessScale() * GetMaxAbsoluteBrightness().
56    /// 2. Absolute brightness in nits. Used by the `GetStateAbsolute` /
57    ///    `SetStateAbsolute` calls.
58    pub brightness: f64,
59}
60
61impl fidl::Persistable for State {}
62
63pub mod device_ordinals {
64    pub const GET_STATE_NORMALIZED: u64 = 0x2506201b5999b9b7;
65    pub const SET_STATE_NORMALIZED: u64 = 0x554ac5cb4f9f5b62;
66    pub const GET_STATE_ABSOLUTE: u64 = 0x1f8ccf01cf526a2b;
67    pub const SET_STATE_ABSOLUTE: u64 = 0x19c100c43faaa178;
68    pub const GET_MAX_ABSOLUTE_BRIGHTNESS: u64 = 0x2aa0699313d4160d;
69}
70
71mod internal {
72    use super::*;
73
74    impl fidl::encoding::ValueTypeMarker for DeviceSetStateAbsoluteRequest {
75        type Borrowed<'a> = &'a Self;
76        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
77            value
78        }
79    }
80
81    unsafe impl fidl::encoding::TypeMarker for DeviceSetStateAbsoluteRequest {
82        type Owned = Self;
83
84        #[inline(always)]
85        fn inline_align(_context: fidl::encoding::Context) -> usize {
86            8
87        }
88
89        #[inline(always)]
90        fn inline_size(_context: fidl::encoding::Context) -> usize {
91            16
92        }
93    }
94
95    unsafe impl<D: fidl::encoding::ResourceDialect>
96        fidl::encoding::Encode<DeviceSetStateAbsoluteRequest, D>
97        for &DeviceSetStateAbsoluteRequest
98    {
99        #[inline]
100        unsafe fn encode(
101            self,
102            encoder: &mut fidl::encoding::Encoder<'_, D>,
103            offset: usize,
104            _depth: fidl::encoding::Depth,
105        ) -> fidl::Result<()> {
106            encoder.debug_check_bounds::<DeviceSetStateAbsoluteRequest>(offset);
107            // Delegate to tuple encoding.
108            fidl::encoding::Encode::<DeviceSetStateAbsoluteRequest, D>::encode(
109                (<State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
110                encoder,
111                offset,
112                _depth,
113            )
114        }
115    }
116    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<State, D>>
117        fidl::encoding::Encode<DeviceSetStateAbsoluteRequest, D> for (T0,)
118    {
119        #[inline]
120        unsafe fn encode(
121            self,
122            encoder: &mut fidl::encoding::Encoder<'_, D>,
123            offset: usize,
124            depth: fidl::encoding::Depth,
125        ) -> fidl::Result<()> {
126            encoder.debug_check_bounds::<DeviceSetStateAbsoluteRequest>(offset);
127            // Zero out padding regions. There's no need to apply masks
128            // because the unmasked parts will be overwritten by fields.
129            // Write the fields.
130            self.0.encode(encoder, offset + 0, depth)?;
131            Ok(())
132        }
133    }
134
135    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
136        for DeviceSetStateAbsoluteRequest
137    {
138        #[inline(always)]
139        fn new_empty() -> Self {
140            Self { state: fidl::new_empty!(State, D) }
141        }
142
143        #[inline]
144        unsafe fn decode(
145            &mut self,
146            decoder: &mut fidl::encoding::Decoder<'_, D>,
147            offset: usize,
148            _depth: fidl::encoding::Depth,
149        ) -> fidl::Result<()> {
150            decoder.debug_check_bounds::<Self>(offset);
151            // Verify that padding bytes are zero.
152            fidl::decode!(State, D, &mut self.state, decoder, offset + 0, _depth)?;
153            Ok(())
154        }
155    }
156
157    impl fidl::encoding::ValueTypeMarker for DeviceSetStateNormalizedRequest {
158        type Borrowed<'a> = &'a Self;
159        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
160            value
161        }
162    }
163
164    unsafe impl fidl::encoding::TypeMarker for DeviceSetStateNormalizedRequest {
165        type Owned = Self;
166
167        #[inline(always)]
168        fn inline_align(_context: fidl::encoding::Context) -> usize {
169            8
170        }
171
172        #[inline(always)]
173        fn inline_size(_context: fidl::encoding::Context) -> usize {
174            16
175        }
176    }
177
178    unsafe impl<D: fidl::encoding::ResourceDialect>
179        fidl::encoding::Encode<DeviceSetStateNormalizedRequest, D>
180        for &DeviceSetStateNormalizedRequest
181    {
182        #[inline]
183        unsafe fn encode(
184            self,
185            encoder: &mut fidl::encoding::Encoder<'_, D>,
186            offset: usize,
187            _depth: fidl::encoding::Depth,
188        ) -> fidl::Result<()> {
189            encoder.debug_check_bounds::<DeviceSetStateNormalizedRequest>(offset);
190            // Delegate to tuple encoding.
191            fidl::encoding::Encode::<DeviceSetStateNormalizedRequest, D>::encode(
192                (<State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
193                encoder,
194                offset,
195                _depth,
196            )
197        }
198    }
199    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<State, D>>
200        fidl::encoding::Encode<DeviceSetStateNormalizedRequest, D> for (T0,)
201    {
202        #[inline]
203        unsafe fn encode(
204            self,
205            encoder: &mut fidl::encoding::Encoder<'_, D>,
206            offset: usize,
207            depth: fidl::encoding::Depth,
208        ) -> fidl::Result<()> {
209            encoder.debug_check_bounds::<DeviceSetStateNormalizedRequest>(offset);
210            // Zero out padding regions. There's no need to apply masks
211            // because the unmasked parts will be overwritten by fields.
212            // Write the fields.
213            self.0.encode(encoder, offset + 0, depth)?;
214            Ok(())
215        }
216    }
217
218    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
219        for DeviceSetStateNormalizedRequest
220    {
221        #[inline(always)]
222        fn new_empty() -> Self {
223            Self { state: fidl::new_empty!(State, D) }
224        }
225
226        #[inline]
227        unsafe fn decode(
228            &mut self,
229            decoder: &mut fidl::encoding::Decoder<'_, D>,
230            offset: usize,
231            _depth: fidl::encoding::Depth,
232        ) -> fidl::Result<()> {
233            decoder.debug_check_bounds::<Self>(offset);
234            // Verify that padding bytes are zero.
235            fidl::decode!(State, D, &mut self.state, decoder, offset + 0, _depth)?;
236            Ok(())
237        }
238    }
239
240    impl fidl::encoding::ValueTypeMarker for DeviceGetMaxAbsoluteBrightnessResponse {
241        type Borrowed<'a> = &'a Self;
242        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
243            value
244        }
245    }
246
247    unsafe impl fidl::encoding::TypeMarker for DeviceGetMaxAbsoluteBrightnessResponse {
248        type Owned = Self;
249
250        #[inline(always)]
251        fn inline_align(_context: fidl::encoding::Context) -> usize {
252            8
253        }
254
255        #[inline(always)]
256        fn inline_size(_context: fidl::encoding::Context) -> usize {
257            8
258        }
259    }
260
261    unsafe impl<D: fidl::encoding::ResourceDialect>
262        fidl::encoding::Encode<DeviceGetMaxAbsoluteBrightnessResponse, D>
263        for &DeviceGetMaxAbsoluteBrightnessResponse
264    {
265        #[inline]
266        unsafe fn encode(
267            self,
268            encoder: &mut fidl::encoding::Encoder<'_, D>,
269            offset: usize,
270            _depth: fidl::encoding::Depth,
271        ) -> fidl::Result<()> {
272            encoder.debug_check_bounds::<DeviceGetMaxAbsoluteBrightnessResponse>(offset);
273            // Delegate to tuple encoding.
274            fidl::encoding::Encode::<DeviceGetMaxAbsoluteBrightnessResponse, D>::encode(
275                (<f64 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_brightness),),
276                encoder,
277                offset,
278                _depth,
279            )
280        }
281    }
282    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<f64, D>>
283        fidl::encoding::Encode<DeviceGetMaxAbsoluteBrightnessResponse, D> for (T0,)
284    {
285        #[inline]
286        unsafe fn encode(
287            self,
288            encoder: &mut fidl::encoding::Encoder<'_, D>,
289            offset: usize,
290            depth: fidl::encoding::Depth,
291        ) -> fidl::Result<()> {
292            encoder.debug_check_bounds::<DeviceGetMaxAbsoluteBrightnessResponse>(offset);
293            // Zero out padding regions. There's no need to apply masks
294            // because the unmasked parts will be overwritten by fields.
295            // Write the fields.
296            self.0.encode(encoder, offset + 0, depth)?;
297            Ok(())
298        }
299    }
300
301    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
302        for DeviceGetMaxAbsoluteBrightnessResponse
303    {
304        #[inline(always)]
305        fn new_empty() -> Self {
306            Self { max_brightness: fidl::new_empty!(f64, D) }
307        }
308
309        #[inline]
310        unsafe fn decode(
311            &mut self,
312            decoder: &mut fidl::encoding::Decoder<'_, D>,
313            offset: usize,
314            _depth: fidl::encoding::Depth,
315        ) -> fidl::Result<()> {
316            decoder.debug_check_bounds::<Self>(offset);
317            // Verify that padding bytes are zero.
318            fidl::decode!(f64, D, &mut self.max_brightness, decoder, offset + 0, _depth)?;
319            Ok(())
320        }
321    }
322
323    impl fidl::encoding::ValueTypeMarker for DeviceGetStateAbsoluteResponse {
324        type Borrowed<'a> = &'a Self;
325        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
326            value
327        }
328    }
329
330    unsafe impl fidl::encoding::TypeMarker for DeviceGetStateAbsoluteResponse {
331        type Owned = Self;
332
333        #[inline(always)]
334        fn inline_align(_context: fidl::encoding::Context) -> usize {
335            8
336        }
337
338        #[inline(always)]
339        fn inline_size(_context: fidl::encoding::Context) -> usize {
340            16
341        }
342    }
343
344    unsafe impl<D: fidl::encoding::ResourceDialect>
345        fidl::encoding::Encode<DeviceGetStateAbsoluteResponse, D>
346        for &DeviceGetStateAbsoluteResponse
347    {
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::<DeviceGetStateAbsoluteResponse>(offset);
356            // Delegate to tuple encoding.
357            fidl::encoding::Encode::<DeviceGetStateAbsoluteResponse, D>::encode(
358                (<State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
359                encoder,
360                offset,
361                _depth,
362            )
363        }
364    }
365    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<State, D>>
366        fidl::encoding::Encode<DeviceGetStateAbsoluteResponse, D> for (T0,)
367    {
368        #[inline]
369        unsafe fn encode(
370            self,
371            encoder: &mut fidl::encoding::Encoder<'_, D>,
372            offset: usize,
373            depth: fidl::encoding::Depth,
374        ) -> fidl::Result<()> {
375            encoder.debug_check_bounds::<DeviceGetStateAbsoluteResponse>(offset);
376            // Zero out padding regions. There's no need to apply masks
377            // because the unmasked parts will be overwritten by fields.
378            // Write the fields.
379            self.0.encode(encoder, offset + 0, depth)?;
380            Ok(())
381        }
382    }
383
384    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
385        for DeviceGetStateAbsoluteResponse
386    {
387        #[inline(always)]
388        fn new_empty() -> Self {
389            Self { state: fidl::new_empty!(State, D) }
390        }
391
392        #[inline]
393        unsafe fn decode(
394            &mut self,
395            decoder: &mut fidl::encoding::Decoder<'_, D>,
396            offset: usize,
397            _depth: fidl::encoding::Depth,
398        ) -> fidl::Result<()> {
399            decoder.debug_check_bounds::<Self>(offset);
400            // Verify that padding bytes are zero.
401            fidl::decode!(State, D, &mut self.state, decoder, offset + 0, _depth)?;
402            Ok(())
403        }
404    }
405
406    impl fidl::encoding::ValueTypeMarker for DeviceGetStateNormalizedResponse {
407        type Borrowed<'a> = &'a Self;
408        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
409            value
410        }
411    }
412
413    unsafe impl fidl::encoding::TypeMarker for DeviceGetStateNormalizedResponse {
414        type Owned = Self;
415
416        #[inline(always)]
417        fn inline_align(_context: fidl::encoding::Context) -> usize {
418            8
419        }
420
421        #[inline(always)]
422        fn inline_size(_context: fidl::encoding::Context) -> usize {
423            16
424        }
425    }
426
427    unsafe impl<D: fidl::encoding::ResourceDialect>
428        fidl::encoding::Encode<DeviceGetStateNormalizedResponse, D>
429        for &DeviceGetStateNormalizedResponse
430    {
431        #[inline]
432        unsafe fn encode(
433            self,
434            encoder: &mut fidl::encoding::Encoder<'_, D>,
435            offset: usize,
436            _depth: fidl::encoding::Depth,
437        ) -> fidl::Result<()> {
438            encoder.debug_check_bounds::<DeviceGetStateNormalizedResponse>(offset);
439            // Delegate to tuple encoding.
440            fidl::encoding::Encode::<DeviceGetStateNormalizedResponse, D>::encode(
441                (<State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
442                encoder,
443                offset,
444                _depth,
445            )
446        }
447    }
448    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<State, D>>
449        fidl::encoding::Encode<DeviceGetStateNormalizedResponse, D> for (T0,)
450    {
451        #[inline]
452        unsafe fn encode(
453            self,
454            encoder: &mut fidl::encoding::Encoder<'_, D>,
455            offset: usize,
456            depth: fidl::encoding::Depth,
457        ) -> fidl::Result<()> {
458            encoder.debug_check_bounds::<DeviceGetStateNormalizedResponse>(offset);
459            // Zero out padding regions. There's no need to apply masks
460            // because the unmasked parts will be overwritten by fields.
461            // Write the fields.
462            self.0.encode(encoder, offset + 0, depth)?;
463            Ok(())
464        }
465    }
466
467    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
468        for DeviceGetStateNormalizedResponse
469    {
470        #[inline(always)]
471        fn new_empty() -> Self {
472            Self { state: fidl::new_empty!(State, D) }
473        }
474
475        #[inline]
476        unsafe fn decode(
477            &mut self,
478            decoder: &mut fidl::encoding::Decoder<'_, D>,
479            offset: usize,
480            _depth: fidl::encoding::Depth,
481        ) -> fidl::Result<()> {
482            decoder.debug_check_bounds::<Self>(offset);
483            // Verify that padding bytes are zero.
484            fidl::decode!(State, D, &mut self.state, decoder, offset + 0, _depth)?;
485            Ok(())
486        }
487    }
488
489    impl fidl::encoding::ValueTypeMarker for State {
490        type Borrowed<'a> = &'a Self;
491        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
492            value
493        }
494    }
495
496    unsafe impl fidl::encoding::TypeMarker for State {
497        type Owned = Self;
498
499        #[inline(always)]
500        fn inline_align(_context: fidl::encoding::Context) -> usize {
501            8
502        }
503
504        #[inline(always)]
505        fn inline_size(_context: fidl::encoding::Context) -> usize {
506            16
507        }
508    }
509
510    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<State, D> for &State {
511        #[inline]
512        unsafe fn encode(
513            self,
514            encoder: &mut fidl::encoding::Encoder<'_, D>,
515            offset: usize,
516            _depth: fidl::encoding::Depth,
517        ) -> fidl::Result<()> {
518            encoder.debug_check_bounds::<State>(offset);
519            // Delegate to tuple encoding.
520            fidl::encoding::Encode::<State, D>::encode(
521                (
522                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.backlight_on),
523                    <f64 as fidl::encoding::ValueTypeMarker>::borrow(&self.brightness),
524                ),
525                encoder,
526                offset,
527                _depth,
528            )
529        }
530    }
531    unsafe impl<
532            D: fidl::encoding::ResourceDialect,
533            T0: fidl::encoding::Encode<bool, D>,
534            T1: fidl::encoding::Encode<f64, D>,
535        > fidl::encoding::Encode<State, D> for (T0, T1)
536    {
537        #[inline]
538        unsafe fn encode(
539            self,
540            encoder: &mut fidl::encoding::Encoder<'_, D>,
541            offset: usize,
542            depth: fidl::encoding::Depth,
543        ) -> fidl::Result<()> {
544            encoder.debug_check_bounds::<State>(offset);
545            // Zero out padding regions. There's no need to apply masks
546            // because the unmasked parts will be overwritten by fields.
547            unsafe {
548                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
549                (ptr as *mut u64).write_unaligned(0);
550            }
551            // Write the fields.
552            self.0.encode(encoder, offset + 0, depth)?;
553            self.1.encode(encoder, offset + 8, depth)?;
554            Ok(())
555        }
556    }
557
558    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for State {
559        #[inline(always)]
560        fn new_empty() -> Self {
561            Self { backlight_on: fidl::new_empty!(bool, D), brightness: fidl::new_empty!(f64, D) }
562        }
563
564        #[inline]
565        unsafe fn decode(
566            &mut self,
567            decoder: &mut fidl::encoding::Decoder<'_, D>,
568            offset: usize,
569            _depth: fidl::encoding::Depth,
570        ) -> fidl::Result<()> {
571            decoder.debug_check_bounds::<Self>(offset);
572            // Verify that padding bytes are zero.
573            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
574            let padval = unsafe { (ptr as *const u64).read_unaligned() };
575            let mask = 0xffffffffffffff00u64;
576            let maskedval = padval & mask;
577            if maskedval != 0 {
578                return Err(fidl::Error::NonZeroPadding {
579                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
580                });
581            }
582            fidl::decode!(bool, D, &mut self.backlight_on, decoder, offset + 0, _depth)?;
583            fidl::decode!(f64, D, &mut self.brightness, decoder, offset + 8, _depth)?;
584            Ok(())
585        }
586    }
587}