fidl_fuchsia_hardware_backlight/
fidl_fuchsia_hardware_backlight.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::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_backlight_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18    type Proxy = DeviceProxy;
19    type RequestStream = DeviceRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DeviceSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) Device";
24}
25pub type DeviceGetStateNormalizedResult = Result<State, i32>;
26pub type DeviceSetStateNormalizedResult = Result<(), i32>;
27pub type DeviceGetStateAbsoluteResult = Result<State, i32>;
28pub type DeviceSetStateAbsoluteResult = Result<(), i32>;
29pub type DeviceGetMaxAbsoluteBrightnessResult = Result<f64, i32>;
30pub type DeviceSetNormalizedBrightnessScaleResult = Result<(), i32>;
31pub type DeviceGetNormalizedBrightnessScaleResult = Result<f64, i32>;
32
33pub trait DeviceProxyInterface: Send + Sync {
34    type GetStateNormalizedResponseFut: std::future::Future<Output = Result<DeviceGetStateNormalizedResult, fidl::Error>>
35        + Send;
36    fn r#get_state_normalized(&self) -> Self::GetStateNormalizedResponseFut;
37    type SetStateNormalizedResponseFut: std::future::Future<Output = Result<DeviceSetStateNormalizedResult, fidl::Error>>
38        + Send;
39    fn r#set_state_normalized(&self, state: &State) -> Self::SetStateNormalizedResponseFut;
40    type GetStateAbsoluteResponseFut: std::future::Future<Output = Result<DeviceGetStateAbsoluteResult, fidl::Error>>
41        + Send;
42    fn r#get_state_absolute(&self) -> Self::GetStateAbsoluteResponseFut;
43    type SetStateAbsoluteResponseFut: std::future::Future<Output = Result<DeviceSetStateAbsoluteResult, fidl::Error>>
44        + Send;
45    fn r#set_state_absolute(&self, state: &State) -> Self::SetStateAbsoluteResponseFut;
46    type GetMaxAbsoluteBrightnessResponseFut: std::future::Future<Output = Result<DeviceGetMaxAbsoluteBrightnessResult, fidl::Error>>
47        + Send;
48    fn r#get_max_absolute_brightness(&self) -> Self::GetMaxAbsoluteBrightnessResponseFut;
49    type SetNormalizedBrightnessScaleResponseFut: std::future::Future<Output = Result<DeviceSetNormalizedBrightnessScaleResult, fidl::Error>>
50        + Send;
51    fn r#set_normalized_brightness_scale(
52        &self,
53        scale: f64,
54    ) -> Self::SetNormalizedBrightnessScaleResponseFut;
55    type GetNormalizedBrightnessScaleResponseFut: std::future::Future<Output = Result<DeviceGetNormalizedBrightnessScaleResult, fidl::Error>>
56        + Send;
57    fn r#get_normalized_brightness_scale(&self) -> Self::GetNormalizedBrightnessScaleResponseFut;
58}
59#[derive(Debug)]
60#[cfg(target_os = "fuchsia")]
61pub struct DeviceSynchronousProxy {
62    client: fidl::client::sync::Client,
63}
64
65#[cfg(target_os = "fuchsia")]
66impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
67    type Proxy = DeviceProxy;
68    type Protocol = DeviceMarker;
69
70    fn from_channel(inner: fidl::Channel) -> Self {
71        Self::new(inner)
72    }
73
74    fn into_channel(self) -> fidl::Channel {
75        self.client.into_channel()
76    }
77
78    fn as_channel(&self) -> &fidl::Channel {
79        self.client.as_channel()
80    }
81}
82
83#[cfg(target_os = "fuchsia")]
84impl DeviceSynchronousProxy {
85    pub fn new(channel: fidl::Channel) -> Self {
86        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
87        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
88    }
89
90    pub fn into_channel(self) -> fidl::Channel {
91        self.client.into_channel()
92    }
93
94    /// Waits until an event arrives and returns it. It is safe for other
95    /// threads to make concurrent requests while waiting for an event.
96    pub fn wait_for_event(
97        &self,
98        deadline: zx::MonotonicInstant,
99    ) -> Result<DeviceEvent, fidl::Error> {
100        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
101    }
102
103    /// Gets the current backlight brightness as a percentage value between 0.0
104    /// and 1.0
105    pub fn r#get_state_normalized(
106        &self,
107        ___deadline: zx::MonotonicInstant,
108    ) -> Result<DeviceGetStateNormalizedResult, fidl::Error> {
109        let _response = self.client.send_query::<
110            fidl::encoding::EmptyPayload,
111            fidl::encoding::ResultType<DeviceGetStateNormalizedResponse, i32>,
112        >(
113            (),
114            0x2506201b5999b9b7,
115            fidl::encoding::DynamicFlags::empty(),
116            ___deadline,
117        )?;
118        Ok(_response.map(|x| x.state))
119    }
120
121    /// Sets the current backlight brightness as a percentage value between 0.0
122    /// and 1.0
123    pub fn r#set_state_normalized(
124        &self,
125        mut state: &State,
126        ___deadline: zx::MonotonicInstant,
127    ) -> Result<DeviceSetStateNormalizedResult, fidl::Error> {
128        let _response = self.client.send_query::<
129            DeviceSetStateNormalizedRequest,
130            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
131        >(
132            (state,),
133            0x554ac5cb4f9f5b62,
134            fidl::encoding::DynamicFlags::empty(),
135            ___deadline,
136        )?;
137        Ok(_response.map(|x| x))
138    }
139
140    /// Gets the current backlight brightness in nits
141    pub fn r#get_state_absolute(
142        &self,
143        ___deadline: zx::MonotonicInstant,
144    ) -> Result<DeviceGetStateAbsoluteResult, fidl::Error> {
145        let _response = self.client.send_query::<
146            fidl::encoding::EmptyPayload,
147            fidl::encoding::ResultType<DeviceGetStateAbsoluteResponse, i32>,
148        >(
149            (),
150            0x1f8ccf01cf526a2b,
151            fidl::encoding::DynamicFlags::empty(),
152            ___deadline,
153        )?;
154        Ok(_response.map(|x| x.state))
155    }
156
157    /// Sets the current backlight brightness in nits. Not affected by the scale
158    /// set by SetNormalizedBrightnessScale.
159    pub fn r#set_state_absolute(
160        &self,
161        mut state: &State,
162        ___deadline: zx::MonotonicInstant,
163    ) -> Result<DeviceSetStateAbsoluteResult, fidl::Error> {
164        let _response = self.client.send_query::<
165            DeviceSetStateAbsoluteRequest,
166            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
167        >(
168            (state,),
169            0x19c100c43faaa178,
170            fidl::encoding::DynamicFlags::empty(),
171            ___deadline,
172        )?;
173        Ok(_response.map(|x| x))
174    }
175
176    /// Gets the maximum supported backlight brightness in nits, if known.
177    /// Otherwise returns error ZX_ERR_NOT_SUPPORTED.
178    pub fn r#get_max_absolute_brightness(
179        &self,
180        ___deadline: zx::MonotonicInstant,
181    ) -> Result<DeviceGetMaxAbsoluteBrightnessResult, fidl::Error> {
182        let _response = self.client.send_query::<
183            fidl::encoding::EmptyPayload,
184            fidl::encoding::ResultType<DeviceGetMaxAbsoluteBrightnessResponse, i32>,
185        >(
186            (),
187            0x2aa0699313d4160d,
188            fidl::encoding::DynamicFlags::empty(),
189            ___deadline,
190        )?;
191        Ok(_response.map(|x| x.max_brightness))
192    }
193
194    /// Scales the maximum normalized brightness by a percentage value in
195    /// [0.0, 1.0], if supported. Otherwise returns error ZX_ERR_NOT_SUPPORTED.
196    /// Values passed to SetStateNormalized will correspond to a maximum
197    /// brightness of scale * GetMaxAbsoluteBrightness(). Calling this may
198    /// change the current absolute brightness.
199    pub fn r#set_normalized_brightness_scale(
200        &self,
201        mut scale: f64,
202        ___deadline: zx::MonotonicInstant,
203    ) -> Result<DeviceSetNormalizedBrightnessScaleResult, fidl::Error> {
204        let _response = self.client.send_query::<
205            DeviceSetNormalizedBrightnessScaleRequest,
206            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
207        >(
208            (scale,),
209            0x34ee4d2bbf4b2863,
210            fidl::encoding::DynamicFlags::empty(),
211            ___deadline,
212        )?;
213        Ok(_response.map(|x| x))
214    }
215
216    /// Gets the current normalized brightness scale as a percentage value in
217    /// [0.0, 1.0].
218    pub fn r#get_normalized_brightness_scale(
219        &self,
220        ___deadline: zx::MonotonicInstant,
221    ) -> Result<DeviceGetNormalizedBrightnessScaleResult, fidl::Error> {
222        let _response =
223            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
224                DeviceGetNormalizedBrightnessScaleResponse,
225                i32,
226            >>(
227                (),
228                0x4f57df8da3bcb26b,
229                fidl::encoding::DynamicFlags::empty(),
230                ___deadline,
231            )?;
232        Ok(_response.map(|x| x.scale))
233    }
234}
235
236#[derive(Debug, Clone)]
237pub struct DeviceProxy {
238    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
239}
240
241impl fidl::endpoints::Proxy for DeviceProxy {
242    type Protocol = DeviceMarker;
243
244    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
245        Self::new(inner)
246    }
247
248    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
249        self.client.into_channel().map_err(|client| Self { client })
250    }
251
252    fn as_channel(&self) -> &::fidl::AsyncChannel {
253        self.client.as_channel()
254    }
255}
256
257impl DeviceProxy {
258    /// Create a new Proxy for fuchsia.hardware.backlight/Device.
259    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
260        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
261        Self { client: fidl::client::Client::new(channel, protocol_name) }
262    }
263
264    /// Get a Stream of events from the remote end of the protocol.
265    ///
266    /// # Panics
267    ///
268    /// Panics if the event stream was already taken.
269    pub fn take_event_stream(&self) -> DeviceEventStream {
270        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
271    }
272
273    /// Gets the current backlight brightness as a percentage value between 0.0
274    /// and 1.0
275    pub fn r#get_state_normalized(
276        &self,
277    ) -> fidl::client::QueryResponseFut<
278        DeviceGetStateNormalizedResult,
279        fidl::encoding::DefaultFuchsiaResourceDialect,
280    > {
281        DeviceProxyInterface::r#get_state_normalized(self)
282    }
283
284    /// Sets the current backlight brightness as a percentage value between 0.0
285    /// and 1.0
286    pub fn r#set_state_normalized(
287        &self,
288        mut state: &State,
289    ) -> fidl::client::QueryResponseFut<
290        DeviceSetStateNormalizedResult,
291        fidl::encoding::DefaultFuchsiaResourceDialect,
292    > {
293        DeviceProxyInterface::r#set_state_normalized(self, state)
294    }
295
296    /// Gets the current backlight brightness in nits
297    pub fn r#get_state_absolute(
298        &self,
299    ) -> fidl::client::QueryResponseFut<
300        DeviceGetStateAbsoluteResult,
301        fidl::encoding::DefaultFuchsiaResourceDialect,
302    > {
303        DeviceProxyInterface::r#get_state_absolute(self)
304    }
305
306    /// Sets the current backlight brightness in nits. Not affected by the scale
307    /// set by SetNormalizedBrightnessScale.
308    pub fn r#set_state_absolute(
309        &self,
310        mut state: &State,
311    ) -> fidl::client::QueryResponseFut<
312        DeviceSetStateAbsoluteResult,
313        fidl::encoding::DefaultFuchsiaResourceDialect,
314    > {
315        DeviceProxyInterface::r#set_state_absolute(self, state)
316    }
317
318    /// Gets the maximum supported backlight brightness in nits, if known.
319    /// Otherwise returns error ZX_ERR_NOT_SUPPORTED.
320    pub fn r#get_max_absolute_brightness(
321        &self,
322    ) -> fidl::client::QueryResponseFut<
323        DeviceGetMaxAbsoluteBrightnessResult,
324        fidl::encoding::DefaultFuchsiaResourceDialect,
325    > {
326        DeviceProxyInterface::r#get_max_absolute_brightness(self)
327    }
328
329    /// Scales the maximum normalized brightness by a percentage value in
330    /// [0.0, 1.0], if supported. Otherwise returns error ZX_ERR_NOT_SUPPORTED.
331    /// Values passed to SetStateNormalized will correspond to a maximum
332    /// brightness of scale * GetMaxAbsoluteBrightness(). Calling this may
333    /// change the current absolute brightness.
334    pub fn r#set_normalized_brightness_scale(
335        &self,
336        mut scale: f64,
337    ) -> fidl::client::QueryResponseFut<
338        DeviceSetNormalizedBrightnessScaleResult,
339        fidl::encoding::DefaultFuchsiaResourceDialect,
340    > {
341        DeviceProxyInterface::r#set_normalized_brightness_scale(self, scale)
342    }
343
344    /// Gets the current normalized brightness scale as a percentage value in
345    /// [0.0, 1.0].
346    pub fn r#get_normalized_brightness_scale(
347        &self,
348    ) -> fidl::client::QueryResponseFut<
349        DeviceGetNormalizedBrightnessScaleResult,
350        fidl::encoding::DefaultFuchsiaResourceDialect,
351    > {
352        DeviceProxyInterface::r#get_normalized_brightness_scale(self)
353    }
354}
355
356impl DeviceProxyInterface for DeviceProxy {
357    type GetStateNormalizedResponseFut = fidl::client::QueryResponseFut<
358        DeviceGetStateNormalizedResult,
359        fidl::encoding::DefaultFuchsiaResourceDialect,
360    >;
361    fn r#get_state_normalized(&self) -> Self::GetStateNormalizedResponseFut {
362        fn _decode(
363            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
364        ) -> Result<DeviceGetStateNormalizedResult, fidl::Error> {
365            let _response = fidl::client::decode_transaction_body::<
366                fidl::encoding::ResultType<DeviceGetStateNormalizedResponse, i32>,
367                fidl::encoding::DefaultFuchsiaResourceDialect,
368                0x2506201b5999b9b7,
369            >(_buf?)?;
370            Ok(_response.map(|x| x.state))
371        }
372        self.client
373            .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetStateNormalizedResult>(
374                (),
375                0x2506201b5999b9b7,
376                fidl::encoding::DynamicFlags::empty(),
377                _decode,
378            )
379    }
380
381    type SetStateNormalizedResponseFut = fidl::client::QueryResponseFut<
382        DeviceSetStateNormalizedResult,
383        fidl::encoding::DefaultFuchsiaResourceDialect,
384    >;
385    fn r#set_state_normalized(&self, mut state: &State) -> Self::SetStateNormalizedResponseFut {
386        fn _decode(
387            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
388        ) -> Result<DeviceSetStateNormalizedResult, fidl::Error> {
389            let _response = fidl::client::decode_transaction_body::<
390                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
391                fidl::encoding::DefaultFuchsiaResourceDialect,
392                0x554ac5cb4f9f5b62,
393            >(_buf?)?;
394            Ok(_response.map(|x| x))
395        }
396        self.client.send_query_and_decode::<
397            DeviceSetStateNormalizedRequest,
398            DeviceSetStateNormalizedResult,
399        >(
400            (state,),
401            0x554ac5cb4f9f5b62,
402            fidl::encoding::DynamicFlags::empty(),
403            _decode,
404        )
405    }
406
407    type GetStateAbsoluteResponseFut = fidl::client::QueryResponseFut<
408        DeviceGetStateAbsoluteResult,
409        fidl::encoding::DefaultFuchsiaResourceDialect,
410    >;
411    fn r#get_state_absolute(&self) -> Self::GetStateAbsoluteResponseFut {
412        fn _decode(
413            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
414        ) -> Result<DeviceGetStateAbsoluteResult, fidl::Error> {
415            let _response = fidl::client::decode_transaction_body::<
416                fidl::encoding::ResultType<DeviceGetStateAbsoluteResponse, i32>,
417                fidl::encoding::DefaultFuchsiaResourceDialect,
418                0x1f8ccf01cf526a2b,
419            >(_buf?)?;
420            Ok(_response.map(|x| x.state))
421        }
422        self.client
423            .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetStateAbsoluteResult>(
424                (),
425                0x1f8ccf01cf526a2b,
426                fidl::encoding::DynamicFlags::empty(),
427                _decode,
428            )
429    }
430
431    type SetStateAbsoluteResponseFut = fidl::client::QueryResponseFut<
432        DeviceSetStateAbsoluteResult,
433        fidl::encoding::DefaultFuchsiaResourceDialect,
434    >;
435    fn r#set_state_absolute(&self, mut state: &State) -> Self::SetStateAbsoluteResponseFut {
436        fn _decode(
437            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
438        ) -> Result<DeviceSetStateAbsoluteResult, fidl::Error> {
439            let _response = fidl::client::decode_transaction_body::<
440                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
441                fidl::encoding::DefaultFuchsiaResourceDialect,
442                0x19c100c43faaa178,
443            >(_buf?)?;
444            Ok(_response.map(|x| x))
445        }
446        self.client
447            .send_query_and_decode::<DeviceSetStateAbsoluteRequest, DeviceSetStateAbsoluteResult>(
448                (state,),
449                0x19c100c43faaa178,
450                fidl::encoding::DynamicFlags::empty(),
451                _decode,
452            )
453    }
454
455    type GetMaxAbsoluteBrightnessResponseFut = fidl::client::QueryResponseFut<
456        DeviceGetMaxAbsoluteBrightnessResult,
457        fidl::encoding::DefaultFuchsiaResourceDialect,
458    >;
459    fn r#get_max_absolute_brightness(&self) -> Self::GetMaxAbsoluteBrightnessResponseFut {
460        fn _decode(
461            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
462        ) -> Result<DeviceGetMaxAbsoluteBrightnessResult, fidl::Error> {
463            let _response = fidl::client::decode_transaction_body::<
464                fidl::encoding::ResultType<DeviceGetMaxAbsoluteBrightnessResponse, i32>,
465                fidl::encoding::DefaultFuchsiaResourceDialect,
466                0x2aa0699313d4160d,
467            >(_buf?)?;
468            Ok(_response.map(|x| x.max_brightness))
469        }
470        self.client.send_query_and_decode::<
471            fidl::encoding::EmptyPayload,
472            DeviceGetMaxAbsoluteBrightnessResult,
473        >(
474            (),
475            0x2aa0699313d4160d,
476            fidl::encoding::DynamicFlags::empty(),
477            _decode,
478        )
479    }
480
481    type SetNormalizedBrightnessScaleResponseFut = fidl::client::QueryResponseFut<
482        DeviceSetNormalizedBrightnessScaleResult,
483        fidl::encoding::DefaultFuchsiaResourceDialect,
484    >;
485    fn r#set_normalized_brightness_scale(
486        &self,
487        mut scale: f64,
488    ) -> Self::SetNormalizedBrightnessScaleResponseFut {
489        fn _decode(
490            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
491        ) -> Result<DeviceSetNormalizedBrightnessScaleResult, fidl::Error> {
492            let _response = fidl::client::decode_transaction_body::<
493                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
494                fidl::encoding::DefaultFuchsiaResourceDialect,
495                0x34ee4d2bbf4b2863,
496            >(_buf?)?;
497            Ok(_response.map(|x| x))
498        }
499        self.client.send_query_and_decode::<
500            DeviceSetNormalizedBrightnessScaleRequest,
501            DeviceSetNormalizedBrightnessScaleResult,
502        >(
503            (scale,),
504            0x34ee4d2bbf4b2863,
505            fidl::encoding::DynamicFlags::empty(),
506            _decode,
507        )
508    }
509
510    type GetNormalizedBrightnessScaleResponseFut = fidl::client::QueryResponseFut<
511        DeviceGetNormalizedBrightnessScaleResult,
512        fidl::encoding::DefaultFuchsiaResourceDialect,
513    >;
514    fn r#get_normalized_brightness_scale(&self) -> Self::GetNormalizedBrightnessScaleResponseFut {
515        fn _decode(
516            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
517        ) -> Result<DeviceGetNormalizedBrightnessScaleResult, fidl::Error> {
518            let _response = fidl::client::decode_transaction_body::<
519                fidl::encoding::ResultType<DeviceGetNormalizedBrightnessScaleResponse, i32>,
520                fidl::encoding::DefaultFuchsiaResourceDialect,
521                0x4f57df8da3bcb26b,
522            >(_buf?)?;
523            Ok(_response.map(|x| x.scale))
524        }
525        self.client.send_query_and_decode::<
526            fidl::encoding::EmptyPayload,
527            DeviceGetNormalizedBrightnessScaleResult,
528        >(
529            (),
530            0x4f57df8da3bcb26b,
531            fidl::encoding::DynamicFlags::empty(),
532            _decode,
533        )
534    }
535}
536
537pub struct DeviceEventStream {
538    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
539}
540
541impl std::marker::Unpin for DeviceEventStream {}
542
543impl futures::stream::FusedStream for DeviceEventStream {
544    fn is_terminated(&self) -> bool {
545        self.event_receiver.is_terminated()
546    }
547}
548
549impl futures::Stream for DeviceEventStream {
550    type Item = Result<DeviceEvent, fidl::Error>;
551
552    fn poll_next(
553        mut self: std::pin::Pin<&mut Self>,
554        cx: &mut std::task::Context<'_>,
555    ) -> std::task::Poll<Option<Self::Item>> {
556        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
557            &mut self.event_receiver,
558            cx
559        )?) {
560            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
561            None => std::task::Poll::Ready(None),
562        }
563    }
564}
565
566#[derive(Debug)]
567pub enum DeviceEvent {}
568
569impl DeviceEvent {
570    /// Decodes a message buffer as a [`DeviceEvent`].
571    fn decode(
572        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
573    ) -> Result<DeviceEvent, fidl::Error> {
574        let (bytes, _handles) = buf.split_mut();
575        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
576        debug_assert_eq!(tx_header.tx_id, 0);
577        match tx_header.ordinal {
578            _ => Err(fidl::Error::UnknownOrdinal {
579                ordinal: tx_header.ordinal,
580                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
581            }),
582        }
583    }
584}
585
586/// A Stream of incoming requests for fuchsia.hardware.backlight/Device.
587pub struct DeviceRequestStream {
588    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
589    is_terminated: bool,
590}
591
592impl std::marker::Unpin for DeviceRequestStream {}
593
594impl futures::stream::FusedStream for DeviceRequestStream {
595    fn is_terminated(&self) -> bool {
596        self.is_terminated
597    }
598}
599
600impl fidl::endpoints::RequestStream for DeviceRequestStream {
601    type Protocol = DeviceMarker;
602    type ControlHandle = DeviceControlHandle;
603
604    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
605        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
606    }
607
608    fn control_handle(&self) -> Self::ControlHandle {
609        DeviceControlHandle { inner: self.inner.clone() }
610    }
611
612    fn into_inner(
613        self,
614    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
615    {
616        (self.inner, self.is_terminated)
617    }
618
619    fn from_inner(
620        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
621        is_terminated: bool,
622    ) -> Self {
623        Self { inner, is_terminated }
624    }
625}
626
627impl futures::Stream for DeviceRequestStream {
628    type Item = Result<DeviceRequest, fidl::Error>;
629
630    fn poll_next(
631        mut self: std::pin::Pin<&mut Self>,
632        cx: &mut std::task::Context<'_>,
633    ) -> std::task::Poll<Option<Self::Item>> {
634        let this = &mut *self;
635        if this.inner.check_shutdown(cx) {
636            this.is_terminated = true;
637            return std::task::Poll::Ready(None);
638        }
639        if this.is_terminated {
640            panic!("polled DeviceRequestStream after completion");
641        }
642        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
643            |bytes, handles| {
644                match this.inner.channel().read_etc(cx, bytes, handles) {
645                    std::task::Poll::Ready(Ok(())) => {}
646                    std::task::Poll::Pending => return std::task::Poll::Pending,
647                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
648                        this.is_terminated = true;
649                        return std::task::Poll::Ready(None);
650                    }
651                    std::task::Poll::Ready(Err(e)) => {
652                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
653                            e.into(),
654                        ))))
655                    }
656                }
657
658                // A message has been received from the channel
659                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
660
661                std::task::Poll::Ready(Some(match header.ordinal {
662                    0x2506201b5999b9b7 => {
663                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
664                        let mut req = fidl::new_empty!(
665                            fidl::encoding::EmptyPayload,
666                            fidl::encoding::DefaultFuchsiaResourceDialect
667                        );
668                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
669                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
670                        Ok(DeviceRequest::GetStateNormalized {
671                            responder: DeviceGetStateNormalizedResponder {
672                                control_handle: std::mem::ManuallyDrop::new(control_handle),
673                                tx_id: header.tx_id,
674                            },
675                        })
676                    }
677                    0x554ac5cb4f9f5b62 => {
678                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
679                        let mut req = fidl::new_empty!(
680                            DeviceSetStateNormalizedRequest,
681                            fidl::encoding::DefaultFuchsiaResourceDialect
682                        );
683                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetStateNormalizedRequest>(&header, _body_bytes, handles, &mut req)?;
684                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
685                        Ok(DeviceRequest::SetStateNormalized {
686                            state: req.state,
687
688                            responder: DeviceSetStateNormalizedResponder {
689                                control_handle: std::mem::ManuallyDrop::new(control_handle),
690                                tx_id: header.tx_id,
691                            },
692                        })
693                    }
694                    0x1f8ccf01cf526a2b => {
695                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
696                        let mut req = fidl::new_empty!(
697                            fidl::encoding::EmptyPayload,
698                            fidl::encoding::DefaultFuchsiaResourceDialect
699                        );
700                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
701                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
702                        Ok(DeviceRequest::GetStateAbsolute {
703                            responder: DeviceGetStateAbsoluteResponder {
704                                control_handle: std::mem::ManuallyDrop::new(control_handle),
705                                tx_id: header.tx_id,
706                            },
707                        })
708                    }
709                    0x19c100c43faaa178 => {
710                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
711                        let mut req = fidl::new_empty!(
712                            DeviceSetStateAbsoluteRequest,
713                            fidl::encoding::DefaultFuchsiaResourceDialect
714                        );
715                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetStateAbsoluteRequest>(&header, _body_bytes, handles, &mut req)?;
716                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
717                        Ok(DeviceRequest::SetStateAbsolute {
718                            state: req.state,
719
720                            responder: DeviceSetStateAbsoluteResponder {
721                                control_handle: std::mem::ManuallyDrop::new(control_handle),
722                                tx_id: header.tx_id,
723                            },
724                        })
725                    }
726                    0x2aa0699313d4160d => {
727                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
728                        let mut req = fidl::new_empty!(
729                            fidl::encoding::EmptyPayload,
730                            fidl::encoding::DefaultFuchsiaResourceDialect
731                        );
732                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
733                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
734                        Ok(DeviceRequest::GetMaxAbsoluteBrightness {
735                            responder: DeviceGetMaxAbsoluteBrightnessResponder {
736                                control_handle: std::mem::ManuallyDrop::new(control_handle),
737                                tx_id: header.tx_id,
738                            },
739                        })
740                    }
741                    0x34ee4d2bbf4b2863 => {
742                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
743                        let mut req = fidl::new_empty!(
744                            DeviceSetNormalizedBrightnessScaleRequest,
745                            fidl::encoding::DefaultFuchsiaResourceDialect
746                        );
747                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetNormalizedBrightnessScaleRequest>(&header, _body_bytes, handles, &mut req)?;
748                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
749                        Ok(DeviceRequest::SetNormalizedBrightnessScale {
750                            scale: req.scale,
751
752                            responder: DeviceSetNormalizedBrightnessScaleResponder {
753                                control_handle: std::mem::ManuallyDrop::new(control_handle),
754                                tx_id: header.tx_id,
755                            },
756                        })
757                    }
758                    0x4f57df8da3bcb26b => {
759                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
760                        let mut req = fidl::new_empty!(
761                            fidl::encoding::EmptyPayload,
762                            fidl::encoding::DefaultFuchsiaResourceDialect
763                        );
764                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
765                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
766                        Ok(DeviceRequest::GetNormalizedBrightnessScale {
767                            responder: DeviceGetNormalizedBrightnessScaleResponder {
768                                control_handle: std::mem::ManuallyDrop::new(control_handle),
769                                tx_id: header.tx_id,
770                            },
771                        })
772                    }
773                    _ => Err(fidl::Error::UnknownOrdinal {
774                        ordinal: header.ordinal,
775                        protocol_name:
776                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
777                    }),
778                }))
779            },
780        )
781    }
782}
783
784#[derive(Debug)]
785pub enum DeviceRequest {
786    /// Gets the current backlight brightness as a percentage value between 0.0
787    /// and 1.0
788    GetStateNormalized { responder: DeviceGetStateNormalizedResponder },
789    /// Sets the current backlight brightness as a percentage value between 0.0
790    /// and 1.0
791    SetStateNormalized { state: State, responder: DeviceSetStateNormalizedResponder },
792    /// Gets the current backlight brightness in nits
793    GetStateAbsolute { responder: DeviceGetStateAbsoluteResponder },
794    /// Sets the current backlight brightness in nits. Not affected by the scale
795    /// set by SetNormalizedBrightnessScale.
796    SetStateAbsolute { state: State, responder: DeviceSetStateAbsoluteResponder },
797    /// Gets the maximum supported backlight brightness in nits, if known.
798    /// Otherwise returns error ZX_ERR_NOT_SUPPORTED.
799    GetMaxAbsoluteBrightness { responder: DeviceGetMaxAbsoluteBrightnessResponder },
800    /// Scales the maximum normalized brightness by a percentage value in
801    /// [0.0, 1.0], if supported. Otherwise returns error ZX_ERR_NOT_SUPPORTED.
802    /// Values passed to SetStateNormalized will correspond to a maximum
803    /// brightness of scale * GetMaxAbsoluteBrightness(). Calling this may
804    /// change the current absolute brightness.
805    SetNormalizedBrightnessScale {
806        scale: f64,
807        responder: DeviceSetNormalizedBrightnessScaleResponder,
808    },
809    /// Gets the current normalized brightness scale as a percentage value in
810    /// [0.0, 1.0].
811    GetNormalizedBrightnessScale { responder: DeviceGetNormalizedBrightnessScaleResponder },
812}
813
814impl DeviceRequest {
815    #[allow(irrefutable_let_patterns)]
816    pub fn into_get_state_normalized(self) -> Option<(DeviceGetStateNormalizedResponder)> {
817        if let DeviceRequest::GetStateNormalized { responder } = self {
818            Some((responder))
819        } else {
820            None
821        }
822    }
823
824    #[allow(irrefutable_let_patterns)]
825    pub fn into_set_state_normalized(self) -> Option<(State, DeviceSetStateNormalizedResponder)> {
826        if let DeviceRequest::SetStateNormalized { state, responder } = self {
827            Some((state, responder))
828        } else {
829            None
830        }
831    }
832
833    #[allow(irrefutable_let_patterns)]
834    pub fn into_get_state_absolute(self) -> Option<(DeviceGetStateAbsoluteResponder)> {
835        if let DeviceRequest::GetStateAbsolute { responder } = self {
836            Some((responder))
837        } else {
838            None
839        }
840    }
841
842    #[allow(irrefutable_let_patterns)]
843    pub fn into_set_state_absolute(self) -> Option<(State, DeviceSetStateAbsoluteResponder)> {
844        if let DeviceRequest::SetStateAbsolute { state, responder } = self {
845            Some((state, responder))
846        } else {
847            None
848        }
849    }
850
851    #[allow(irrefutable_let_patterns)]
852    pub fn into_get_max_absolute_brightness(
853        self,
854    ) -> Option<(DeviceGetMaxAbsoluteBrightnessResponder)> {
855        if let DeviceRequest::GetMaxAbsoluteBrightness { responder } = self {
856            Some((responder))
857        } else {
858            None
859        }
860    }
861
862    #[allow(irrefutable_let_patterns)]
863    pub fn into_set_normalized_brightness_scale(
864        self,
865    ) -> Option<(f64, DeviceSetNormalizedBrightnessScaleResponder)> {
866        if let DeviceRequest::SetNormalizedBrightnessScale { scale, responder } = self {
867            Some((scale, responder))
868        } else {
869            None
870        }
871    }
872
873    #[allow(irrefutable_let_patterns)]
874    pub fn into_get_normalized_brightness_scale(
875        self,
876    ) -> Option<(DeviceGetNormalizedBrightnessScaleResponder)> {
877        if let DeviceRequest::GetNormalizedBrightnessScale { responder } = self {
878            Some((responder))
879        } else {
880            None
881        }
882    }
883
884    /// Name of the method defined in FIDL
885    pub fn method_name(&self) -> &'static str {
886        match *self {
887            DeviceRequest::GetStateNormalized { .. } => "get_state_normalized",
888            DeviceRequest::SetStateNormalized { .. } => "set_state_normalized",
889            DeviceRequest::GetStateAbsolute { .. } => "get_state_absolute",
890            DeviceRequest::SetStateAbsolute { .. } => "set_state_absolute",
891            DeviceRequest::GetMaxAbsoluteBrightness { .. } => "get_max_absolute_brightness",
892            DeviceRequest::SetNormalizedBrightnessScale { .. } => "set_normalized_brightness_scale",
893            DeviceRequest::GetNormalizedBrightnessScale { .. } => "get_normalized_brightness_scale",
894        }
895    }
896}
897
898#[derive(Debug, Clone)]
899pub struct DeviceControlHandle {
900    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
901}
902
903impl fidl::endpoints::ControlHandle for DeviceControlHandle {
904    fn shutdown(&self) {
905        self.inner.shutdown()
906    }
907    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
908        self.inner.shutdown_with_epitaph(status)
909    }
910
911    fn is_closed(&self) -> bool {
912        self.inner.channel().is_closed()
913    }
914    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
915        self.inner.channel().on_closed()
916    }
917
918    #[cfg(target_os = "fuchsia")]
919    fn signal_peer(
920        &self,
921        clear_mask: zx::Signals,
922        set_mask: zx::Signals,
923    ) -> Result<(), zx_status::Status> {
924        use fidl::Peered;
925        self.inner.channel().signal_peer(clear_mask, set_mask)
926    }
927}
928
929impl DeviceControlHandle {}
930
931#[must_use = "FIDL methods require a response to be sent"]
932#[derive(Debug)]
933pub struct DeviceGetStateNormalizedResponder {
934    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
935    tx_id: u32,
936}
937
938/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
939/// if the responder is dropped without sending a response, so that the client
940/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
941impl std::ops::Drop for DeviceGetStateNormalizedResponder {
942    fn drop(&mut self) {
943        self.control_handle.shutdown();
944        // Safety: drops once, never accessed again
945        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
946    }
947}
948
949impl fidl::endpoints::Responder for DeviceGetStateNormalizedResponder {
950    type ControlHandle = DeviceControlHandle;
951
952    fn control_handle(&self) -> &DeviceControlHandle {
953        &self.control_handle
954    }
955
956    fn drop_without_shutdown(mut self) {
957        // Safety: drops once, never accessed again due to mem::forget
958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
959        // Prevent Drop from running (which would shut down the channel)
960        std::mem::forget(self);
961    }
962}
963
964impl DeviceGetStateNormalizedResponder {
965    /// Sends a response to the FIDL transaction.
966    ///
967    /// Sets the channel to shutdown if an error occurs.
968    pub fn send(self, mut result: Result<&State, i32>) -> Result<(), fidl::Error> {
969        let _result = self.send_raw(result);
970        if _result.is_err() {
971            self.control_handle.shutdown();
972        }
973        self.drop_without_shutdown();
974        _result
975    }
976
977    /// Similar to "send" but does not shutdown the channel if an error occurs.
978    pub fn send_no_shutdown_on_err(
979        self,
980        mut result: Result<&State, i32>,
981    ) -> Result<(), fidl::Error> {
982        let _result = self.send_raw(result);
983        self.drop_without_shutdown();
984        _result
985    }
986
987    fn send_raw(&self, mut result: Result<&State, i32>) -> Result<(), fidl::Error> {
988        self.control_handle
989            .inner
990            .send::<fidl::encoding::ResultType<DeviceGetStateNormalizedResponse, i32>>(
991                result.map(|state| (state,)),
992                self.tx_id,
993                0x2506201b5999b9b7,
994                fidl::encoding::DynamicFlags::empty(),
995            )
996    }
997}
998
999#[must_use = "FIDL methods require a response to be sent"]
1000#[derive(Debug)]
1001pub struct DeviceSetStateNormalizedResponder {
1002    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1003    tx_id: u32,
1004}
1005
1006/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1007/// if the responder is dropped without sending a response, so that the client
1008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1009impl std::ops::Drop for DeviceSetStateNormalizedResponder {
1010    fn drop(&mut self) {
1011        self.control_handle.shutdown();
1012        // Safety: drops once, never accessed again
1013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1014    }
1015}
1016
1017impl fidl::endpoints::Responder for DeviceSetStateNormalizedResponder {
1018    type ControlHandle = DeviceControlHandle;
1019
1020    fn control_handle(&self) -> &DeviceControlHandle {
1021        &self.control_handle
1022    }
1023
1024    fn drop_without_shutdown(mut self) {
1025        // Safety: drops once, never accessed again due to mem::forget
1026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1027        // Prevent Drop from running (which would shut down the channel)
1028        std::mem::forget(self);
1029    }
1030}
1031
1032impl DeviceSetStateNormalizedResponder {
1033    /// Sends a response to the FIDL transaction.
1034    ///
1035    /// Sets the channel to shutdown if an error occurs.
1036    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1037        let _result = self.send_raw(result);
1038        if _result.is_err() {
1039            self.control_handle.shutdown();
1040        }
1041        self.drop_without_shutdown();
1042        _result
1043    }
1044
1045    /// Similar to "send" but does not shutdown the channel if an error occurs.
1046    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1047        let _result = self.send_raw(result);
1048        self.drop_without_shutdown();
1049        _result
1050    }
1051
1052    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1053        self.control_handle
1054            .inner
1055            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1056                result,
1057                self.tx_id,
1058                0x554ac5cb4f9f5b62,
1059                fidl::encoding::DynamicFlags::empty(),
1060            )
1061    }
1062}
1063
1064#[must_use = "FIDL methods require a response to be sent"]
1065#[derive(Debug)]
1066pub struct DeviceGetStateAbsoluteResponder {
1067    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1068    tx_id: u32,
1069}
1070
1071/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1072/// if the responder is dropped without sending a response, so that the client
1073/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1074impl std::ops::Drop for DeviceGetStateAbsoluteResponder {
1075    fn drop(&mut self) {
1076        self.control_handle.shutdown();
1077        // Safety: drops once, never accessed again
1078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1079    }
1080}
1081
1082impl fidl::endpoints::Responder for DeviceGetStateAbsoluteResponder {
1083    type ControlHandle = DeviceControlHandle;
1084
1085    fn control_handle(&self) -> &DeviceControlHandle {
1086        &self.control_handle
1087    }
1088
1089    fn drop_without_shutdown(mut self) {
1090        // Safety: drops once, never accessed again due to mem::forget
1091        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1092        // Prevent Drop from running (which would shut down the channel)
1093        std::mem::forget(self);
1094    }
1095}
1096
1097impl DeviceGetStateAbsoluteResponder {
1098    /// Sends a response to the FIDL transaction.
1099    ///
1100    /// Sets the channel to shutdown if an error occurs.
1101    pub fn send(self, mut result: Result<&State, i32>) -> Result<(), fidl::Error> {
1102        let _result = self.send_raw(result);
1103        if _result.is_err() {
1104            self.control_handle.shutdown();
1105        }
1106        self.drop_without_shutdown();
1107        _result
1108    }
1109
1110    /// Similar to "send" but does not shutdown the channel if an error occurs.
1111    pub fn send_no_shutdown_on_err(
1112        self,
1113        mut result: Result<&State, i32>,
1114    ) -> Result<(), fidl::Error> {
1115        let _result = self.send_raw(result);
1116        self.drop_without_shutdown();
1117        _result
1118    }
1119
1120    fn send_raw(&self, mut result: Result<&State, i32>) -> Result<(), fidl::Error> {
1121        self.control_handle
1122            .inner
1123            .send::<fidl::encoding::ResultType<DeviceGetStateAbsoluteResponse, i32>>(
1124                result.map(|state| (state,)),
1125                self.tx_id,
1126                0x1f8ccf01cf526a2b,
1127                fidl::encoding::DynamicFlags::empty(),
1128            )
1129    }
1130}
1131
1132#[must_use = "FIDL methods require a response to be sent"]
1133#[derive(Debug)]
1134pub struct DeviceSetStateAbsoluteResponder {
1135    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1136    tx_id: u32,
1137}
1138
1139/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1140/// if the responder is dropped without sending a response, so that the client
1141/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1142impl std::ops::Drop for DeviceSetStateAbsoluteResponder {
1143    fn drop(&mut self) {
1144        self.control_handle.shutdown();
1145        // Safety: drops once, never accessed again
1146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1147    }
1148}
1149
1150impl fidl::endpoints::Responder for DeviceSetStateAbsoluteResponder {
1151    type ControlHandle = DeviceControlHandle;
1152
1153    fn control_handle(&self) -> &DeviceControlHandle {
1154        &self.control_handle
1155    }
1156
1157    fn drop_without_shutdown(mut self) {
1158        // Safety: drops once, never accessed again due to mem::forget
1159        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1160        // Prevent Drop from running (which would shut down the channel)
1161        std::mem::forget(self);
1162    }
1163}
1164
1165impl DeviceSetStateAbsoluteResponder {
1166    /// Sends a response to the FIDL transaction.
1167    ///
1168    /// Sets the channel to shutdown if an error occurs.
1169    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1170        let _result = self.send_raw(result);
1171        if _result.is_err() {
1172            self.control_handle.shutdown();
1173        }
1174        self.drop_without_shutdown();
1175        _result
1176    }
1177
1178    /// Similar to "send" but does not shutdown the channel if an error occurs.
1179    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1180        let _result = self.send_raw(result);
1181        self.drop_without_shutdown();
1182        _result
1183    }
1184
1185    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1186        self.control_handle
1187            .inner
1188            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1189                result,
1190                self.tx_id,
1191                0x19c100c43faaa178,
1192                fidl::encoding::DynamicFlags::empty(),
1193            )
1194    }
1195}
1196
1197#[must_use = "FIDL methods require a response to be sent"]
1198#[derive(Debug)]
1199pub struct DeviceGetMaxAbsoluteBrightnessResponder {
1200    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1201    tx_id: u32,
1202}
1203
1204/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1205/// if the responder is dropped without sending a response, so that the client
1206/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1207impl std::ops::Drop for DeviceGetMaxAbsoluteBrightnessResponder {
1208    fn drop(&mut self) {
1209        self.control_handle.shutdown();
1210        // Safety: drops once, never accessed again
1211        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1212    }
1213}
1214
1215impl fidl::endpoints::Responder for DeviceGetMaxAbsoluteBrightnessResponder {
1216    type ControlHandle = DeviceControlHandle;
1217
1218    fn control_handle(&self) -> &DeviceControlHandle {
1219        &self.control_handle
1220    }
1221
1222    fn drop_without_shutdown(mut self) {
1223        // Safety: drops once, never accessed again due to mem::forget
1224        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1225        // Prevent Drop from running (which would shut down the channel)
1226        std::mem::forget(self);
1227    }
1228}
1229
1230impl DeviceGetMaxAbsoluteBrightnessResponder {
1231    /// Sends a response to the FIDL transaction.
1232    ///
1233    /// Sets the channel to shutdown if an error occurs.
1234    pub fn send(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1235        let _result = self.send_raw(result);
1236        if _result.is_err() {
1237            self.control_handle.shutdown();
1238        }
1239        self.drop_without_shutdown();
1240        _result
1241    }
1242
1243    /// Similar to "send" but does not shutdown the channel if an error occurs.
1244    pub fn send_no_shutdown_on_err(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1245        let _result = self.send_raw(result);
1246        self.drop_without_shutdown();
1247        _result
1248    }
1249
1250    fn send_raw(&self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1251        self.control_handle.inner.send::<fidl::encoding::ResultType<
1252            DeviceGetMaxAbsoluteBrightnessResponse,
1253            i32,
1254        >>(
1255            result.map(|max_brightness| (max_brightness,)),
1256            self.tx_id,
1257            0x2aa0699313d4160d,
1258            fidl::encoding::DynamicFlags::empty(),
1259        )
1260    }
1261}
1262
1263#[must_use = "FIDL methods require a response to be sent"]
1264#[derive(Debug)]
1265pub struct DeviceSetNormalizedBrightnessScaleResponder {
1266    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1267    tx_id: u32,
1268}
1269
1270/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1271/// if the responder is dropped without sending a response, so that the client
1272/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1273impl std::ops::Drop for DeviceSetNormalizedBrightnessScaleResponder {
1274    fn drop(&mut self) {
1275        self.control_handle.shutdown();
1276        // Safety: drops once, never accessed again
1277        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1278    }
1279}
1280
1281impl fidl::endpoints::Responder for DeviceSetNormalizedBrightnessScaleResponder {
1282    type ControlHandle = DeviceControlHandle;
1283
1284    fn control_handle(&self) -> &DeviceControlHandle {
1285        &self.control_handle
1286    }
1287
1288    fn drop_without_shutdown(mut self) {
1289        // Safety: drops once, never accessed again due to mem::forget
1290        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1291        // Prevent Drop from running (which would shut down the channel)
1292        std::mem::forget(self);
1293    }
1294}
1295
1296impl DeviceSetNormalizedBrightnessScaleResponder {
1297    /// Sends a response to the FIDL transaction.
1298    ///
1299    /// Sets the channel to shutdown if an error occurs.
1300    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1301        let _result = self.send_raw(result);
1302        if _result.is_err() {
1303            self.control_handle.shutdown();
1304        }
1305        self.drop_without_shutdown();
1306        _result
1307    }
1308
1309    /// Similar to "send" but does not shutdown the channel if an error occurs.
1310    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1311        let _result = self.send_raw(result);
1312        self.drop_without_shutdown();
1313        _result
1314    }
1315
1316    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1317        self.control_handle
1318            .inner
1319            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1320                result,
1321                self.tx_id,
1322                0x34ee4d2bbf4b2863,
1323                fidl::encoding::DynamicFlags::empty(),
1324            )
1325    }
1326}
1327
1328#[must_use = "FIDL methods require a response to be sent"]
1329#[derive(Debug)]
1330pub struct DeviceGetNormalizedBrightnessScaleResponder {
1331    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1332    tx_id: u32,
1333}
1334
1335/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1336/// if the responder is dropped without sending a response, so that the client
1337/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1338impl std::ops::Drop for DeviceGetNormalizedBrightnessScaleResponder {
1339    fn drop(&mut self) {
1340        self.control_handle.shutdown();
1341        // Safety: drops once, never accessed again
1342        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1343    }
1344}
1345
1346impl fidl::endpoints::Responder for DeviceGetNormalizedBrightnessScaleResponder {
1347    type ControlHandle = DeviceControlHandle;
1348
1349    fn control_handle(&self) -> &DeviceControlHandle {
1350        &self.control_handle
1351    }
1352
1353    fn drop_without_shutdown(mut self) {
1354        // Safety: drops once, never accessed again due to mem::forget
1355        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1356        // Prevent Drop from running (which would shut down the channel)
1357        std::mem::forget(self);
1358    }
1359}
1360
1361impl DeviceGetNormalizedBrightnessScaleResponder {
1362    /// Sends a response to the FIDL transaction.
1363    ///
1364    /// Sets the channel to shutdown if an error occurs.
1365    pub fn send(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1366        let _result = self.send_raw(result);
1367        if _result.is_err() {
1368            self.control_handle.shutdown();
1369        }
1370        self.drop_without_shutdown();
1371        _result
1372    }
1373
1374    /// Similar to "send" but does not shutdown the channel if an error occurs.
1375    pub fn send_no_shutdown_on_err(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1376        let _result = self.send_raw(result);
1377        self.drop_without_shutdown();
1378        _result
1379    }
1380
1381    fn send_raw(&self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1382        self.control_handle.inner.send::<fidl::encoding::ResultType<
1383            DeviceGetNormalizedBrightnessScaleResponse,
1384            i32,
1385        >>(
1386            result.map(|scale| (scale,)),
1387            self.tx_id,
1388            0x4f57df8da3bcb26b,
1389            fidl::encoding::DynamicFlags::empty(),
1390        )
1391    }
1392}
1393
1394#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1395pub struct ServiceMarker;
1396
1397#[cfg(target_os = "fuchsia")]
1398impl fidl::endpoints::ServiceMarker for ServiceMarker {
1399    type Proxy = ServiceProxy;
1400    type Request = ServiceRequest;
1401    const SERVICE_NAME: &'static str = "fuchsia.hardware.backlight.Service";
1402}
1403
1404/// A request for one of the member protocols of Service.
1405///
1406#[cfg(target_os = "fuchsia")]
1407pub enum ServiceRequest {
1408    Backlight(DeviceRequestStream),
1409}
1410
1411#[cfg(target_os = "fuchsia")]
1412impl fidl::endpoints::ServiceRequest for ServiceRequest {
1413    type Service = ServiceMarker;
1414
1415    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1416        match name {
1417            "backlight" => Self::Backlight(
1418                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1419            ),
1420            _ => panic!("no such member protocol name for service Service"),
1421        }
1422    }
1423
1424    fn member_names() -> &'static [&'static str] {
1425        &["backlight"]
1426    }
1427}
1428#[cfg(target_os = "fuchsia")]
1429pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1430
1431#[cfg(target_os = "fuchsia")]
1432impl fidl::endpoints::ServiceProxy for ServiceProxy {
1433    type Service = ServiceMarker;
1434
1435    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1436        Self(opener)
1437    }
1438}
1439
1440#[cfg(target_os = "fuchsia")]
1441impl ServiceProxy {
1442    pub fn connect_to_backlight(&self) -> Result<DeviceProxy, fidl::Error> {
1443        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1444        self.connect_channel_to_backlight(server_end)?;
1445        Ok(proxy)
1446    }
1447
1448    /// Like `connect_to_backlight`, but returns a sync proxy.
1449    /// See [`Self::connect_to_backlight`] for more details.
1450    pub fn connect_to_backlight_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1451        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1452        self.connect_channel_to_backlight(server_end)?;
1453        Ok(proxy)
1454    }
1455
1456    /// Like `connect_to_backlight`, but accepts a server end.
1457    /// See [`Self::connect_to_backlight`] for more details.
1458    pub fn connect_channel_to_backlight(
1459        &self,
1460        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1461    ) -> Result<(), fidl::Error> {
1462        self.0.open_member("backlight", server_end.into_channel())
1463    }
1464
1465    pub fn instance_name(&self) -> &str {
1466        self.0.instance_name()
1467    }
1468}
1469
1470mod internal {
1471    use super::*;
1472}