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