Skip to main content

fidl_fuchsia_ui_brightness/
fidl_fuchsia_ui_brightness.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_ui_brightness__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ColorAdjustmentMarker;
16
17impl fidl::endpoints::ProtocolMarker for ColorAdjustmentMarker {
18    type Proxy = ColorAdjustmentProxy;
19    type RequestStream = ColorAdjustmentRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ColorAdjustmentSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.ui.brightness.ColorAdjustment";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ColorAdjustmentMarker {}
26
27pub trait ColorAdjustmentProxyInterface: Send + Sync {
28    type SetDiscreteColorAdjustmentResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
29        + Send;
30    fn r#set_discrete_color_adjustment(
31        &self,
32        color_adjustment: &ColorAdjustmentTable,
33    ) -> Self::SetDiscreteColorAdjustmentResponseFut;
34}
35#[derive(Debug)]
36#[cfg(target_os = "fuchsia")]
37pub struct ColorAdjustmentSynchronousProxy {
38    client: fidl::client::sync::Client,
39}
40
41#[cfg(target_os = "fuchsia")]
42impl fidl::endpoints::SynchronousProxy for ColorAdjustmentSynchronousProxy {
43    type Proxy = ColorAdjustmentProxy;
44    type Protocol = ColorAdjustmentMarker;
45
46    fn from_channel(inner: fidl::Channel) -> Self {
47        Self::new(inner)
48    }
49
50    fn into_channel(self) -> fidl::Channel {
51        self.client.into_channel()
52    }
53
54    fn as_channel(&self) -> &fidl::Channel {
55        self.client.as_channel()
56    }
57}
58
59#[cfg(target_os = "fuchsia")]
60impl ColorAdjustmentSynchronousProxy {
61    pub fn new(channel: fidl::Channel) -> Self {
62        Self { client: fidl::client::sync::Client::new(channel) }
63    }
64
65    pub fn into_channel(self) -> fidl::Channel {
66        self.client.into_channel()
67    }
68
69    /// Waits until an event arrives and returns it. It is safe for other
70    /// threads to make concurrent requests while waiting for an event.
71    pub fn wait_for_event(
72        &self,
73        deadline: zx::MonotonicInstant,
74    ) -> Result<ColorAdjustmentEvent, fidl::Error> {
75        ColorAdjustmentEvent::decode(self.client.wait_for_event::<ColorAdjustmentMarker>(deadline)?)
76    }
77
78    /// Called to change the color adjustment to a discrete value.
79    /// The server will send a response once the request has been serviced.
80    /// A client can then use this response to determine when to make
81    /// additional calls when limiting the amount of requests being sent.
82    pub fn r#set_discrete_color_adjustment(
83        &self,
84        mut color_adjustment: &ColorAdjustmentTable,
85        ___deadline: zx::MonotonicInstant,
86    ) -> Result<(), fidl::Error> {
87        let _response = self.client.send_query::<
88            ColorAdjustmentSetDiscreteColorAdjustmentRequest,
89            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
90            ColorAdjustmentMarker,
91        >(
92            (color_adjustment,),
93            0x48d90d2e62d451c4,
94            fidl::encoding::DynamicFlags::FLEXIBLE,
95            ___deadline,
96        )?
97        .into_result::<ColorAdjustmentMarker>("set_discrete_color_adjustment")?;
98        Ok(_response)
99    }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl From<ColorAdjustmentSynchronousProxy> for zx::NullableHandle {
104    fn from(value: ColorAdjustmentSynchronousProxy) -> Self {
105        value.into_channel().into()
106    }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl From<fidl::Channel> for ColorAdjustmentSynchronousProxy {
111    fn from(value: fidl::Channel) -> Self {
112        Self::new(value)
113    }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl fidl::endpoints::FromClient for ColorAdjustmentSynchronousProxy {
118    type Protocol = ColorAdjustmentMarker;
119
120    fn from_client(value: fidl::endpoints::ClientEnd<ColorAdjustmentMarker>) -> Self {
121        Self::new(value.into_channel())
122    }
123}
124
125#[derive(Debug, Clone)]
126pub struct ColorAdjustmentProxy {
127    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
128}
129
130impl fidl::endpoints::Proxy for ColorAdjustmentProxy {
131    type Protocol = ColorAdjustmentMarker;
132
133    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
134        Self::new(inner)
135    }
136
137    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
138        self.client.into_channel().map_err(|client| Self { client })
139    }
140
141    fn as_channel(&self) -> &::fidl::AsyncChannel {
142        self.client.as_channel()
143    }
144}
145
146impl ColorAdjustmentProxy {
147    /// Create a new Proxy for fuchsia.ui.brightness/ColorAdjustment.
148    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
149        let protocol_name = <ColorAdjustmentMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
150        Self { client: fidl::client::Client::new(channel, protocol_name) }
151    }
152
153    /// Get a Stream of events from the remote end of the protocol.
154    ///
155    /// # Panics
156    ///
157    /// Panics if the event stream was already taken.
158    pub fn take_event_stream(&self) -> ColorAdjustmentEventStream {
159        ColorAdjustmentEventStream { event_receiver: self.client.take_event_receiver() }
160    }
161
162    /// Called to change the color adjustment to a discrete value.
163    /// The server will send a response once the request has been serviced.
164    /// A client can then use this response to determine when to make
165    /// additional calls when limiting the amount of requests being sent.
166    pub fn r#set_discrete_color_adjustment(
167        &self,
168        mut color_adjustment: &ColorAdjustmentTable,
169    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
170        ColorAdjustmentProxyInterface::r#set_discrete_color_adjustment(self, color_adjustment)
171    }
172}
173
174impl ColorAdjustmentProxyInterface for ColorAdjustmentProxy {
175    type SetDiscreteColorAdjustmentResponseFut =
176        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
177    fn r#set_discrete_color_adjustment(
178        &self,
179        mut color_adjustment: &ColorAdjustmentTable,
180    ) -> Self::SetDiscreteColorAdjustmentResponseFut {
181        fn _decode(
182            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
183        ) -> Result<(), fidl::Error> {
184            let _response = fidl::client::decode_transaction_body::<
185                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
186                fidl::encoding::DefaultFuchsiaResourceDialect,
187                0x48d90d2e62d451c4,
188            >(_buf?)?
189            .into_result::<ColorAdjustmentMarker>("set_discrete_color_adjustment")?;
190            Ok(_response)
191        }
192        self.client.send_query_and_decode::<ColorAdjustmentSetDiscreteColorAdjustmentRequest, ()>(
193            (color_adjustment,),
194            0x48d90d2e62d451c4,
195            fidl::encoding::DynamicFlags::FLEXIBLE,
196            _decode,
197        )
198    }
199}
200
201pub struct ColorAdjustmentEventStream {
202    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
203}
204
205impl std::marker::Unpin for ColorAdjustmentEventStream {}
206
207impl futures::stream::FusedStream for ColorAdjustmentEventStream {
208    fn is_terminated(&self) -> bool {
209        self.event_receiver.is_terminated()
210    }
211}
212
213impl futures::Stream for ColorAdjustmentEventStream {
214    type Item = Result<ColorAdjustmentEvent, fidl::Error>;
215
216    fn poll_next(
217        mut self: std::pin::Pin<&mut Self>,
218        cx: &mut std::task::Context<'_>,
219    ) -> std::task::Poll<Option<Self::Item>> {
220        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
221            &mut self.event_receiver,
222            cx
223        )?) {
224            Some(buf) => std::task::Poll::Ready(Some(ColorAdjustmentEvent::decode(buf))),
225            None => std::task::Poll::Ready(None),
226        }
227    }
228}
229
230#[derive(Debug)]
231pub enum ColorAdjustmentEvent {
232    #[non_exhaustive]
233    _UnknownEvent {
234        /// Ordinal of the event that was sent.
235        ordinal: u64,
236    },
237}
238
239impl ColorAdjustmentEvent {
240    /// Decodes a message buffer as a [`ColorAdjustmentEvent`].
241    fn decode(
242        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
243    ) -> Result<ColorAdjustmentEvent, fidl::Error> {
244        let (bytes, _handles) = buf.split_mut();
245        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
246        debug_assert_eq!(tx_header.tx_id, 0);
247        match tx_header.ordinal {
248            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
249                Ok(ColorAdjustmentEvent::_UnknownEvent { ordinal: tx_header.ordinal })
250            }
251            _ => Err(fidl::Error::UnknownOrdinal {
252                ordinal: tx_header.ordinal,
253                protocol_name:
254                    <ColorAdjustmentMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
255            }),
256        }
257    }
258}
259
260/// A Stream of incoming requests for fuchsia.ui.brightness/ColorAdjustment.
261pub struct ColorAdjustmentRequestStream {
262    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
263    is_terminated: bool,
264}
265
266impl std::marker::Unpin for ColorAdjustmentRequestStream {}
267
268impl futures::stream::FusedStream for ColorAdjustmentRequestStream {
269    fn is_terminated(&self) -> bool {
270        self.is_terminated
271    }
272}
273
274impl fidl::endpoints::RequestStream for ColorAdjustmentRequestStream {
275    type Protocol = ColorAdjustmentMarker;
276    type ControlHandle = ColorAdjustmentControlHandle;
277
278    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
279        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
280    }
281
282    fn control_handle(&self) -> Self::ControlHandle {
283        ColorAdjustmentControlHandle { inner: self.inner.clone() }
284    }
285
286    fn into_inner(
287        self,
288    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
289    {
290        (self.inner, self.is_terminated)
291    }
292
293    fn from_inner(
294        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
295        is_terminated: bool,
296    ) -> Self {
297        Self { inner, is_terminated }
298    }
299}
300
301impl futures::Stream for ColorAdjustmentRequestStream {
302    type Item = Result<ColorAdjustmentRequest, fidl::Error>;
303
304    fn poll_next(
305        mut self: std::pin::Pin<&mut Self>,
306        cx: &mut std::task::Context<'_>,
307    ) -> std::task::Poll<Option<Self::Item>> {
308        let this = &mut *self;
309        if this.inner.check_shutdown(cx) {
310            this.is_terminated = true;
311            return std::task::Poll::Ready(None);
312        }
313        if this.is_terminated {
314            panic!("polled ColorAdjustmentRequestStream after completion");
315        }
316        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
317            |bytes, handles| {
318                match this.inner.channel().read_etc(cx, bytes, handles) {
319                    std::task::Poll::Ready(Ok(())) => {}
320                    std::task::Poll::Pending => return std::task::Poll::Pending,
321                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
322                        this.is_terminated = true;
323                        return std::task::Poll::Ready(None);
324                    }
325                    std::task::Poll::Ready(Err(e)) => {
326                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
327                            e.into(),
328                        ))));
329                    }
330                }
331
332                // A message has been received from the channel
333                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
334
335                std::task::Poll::Ready(Some(match header.ordinal {
336                    0x48d90d2e62d451c4 => {
337                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
338                        let mut req = fidl::new_empty!(
339                            ColorAdjustmentSetDiscreteColorAdjustmentRequest,
340                            fidl::encoding::DefaultFuchsiaResourceDialect
341                        );
342                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ColorAdjustmentSetDiscreteColorAdjustmentRequest>(&header, _body_bytes, handles, &mut req)?;
343                        let control_handle =
344                            ColorAdjustmentControlHandle { inner: this.inner.clone() };
345                        Ok(ColorAdjustmentRequest::SetDiscreteColorAdjustment {
346                            color_adjustment: req.color_adjustment,
347
348                            responder: ColorAdjustmentSetDiscreteColorAdjustmentResponder {
349                                control_handle: std::mem::ManuallyDrop::new(control_handle),
350                                tx_id: header.tx_id,
351                            },
352                        })
353                    }
354                    _ if header.tx_id == 0
355                        && header
356                            .dynamic_flags()
357                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
358                    {
359                        Ok(ColorAdjustmentRequest::_UnknownMethod {
360                            ordinal: header.ordinal,
361                            control_handle: ColorAdjustmentControlHandle {
362                                inner: this.inner.clone(),
363                            },
364                            method_type: fidl::MethodType::OneWay,
365                        })
366                    }
367                    _ if header
368                        .dynamic_flags()
369                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
370                    {
371                        this.inner.send_framework_err(
372                            fidl::encoding::FrameworkErr::UnknownMethod,
373                            header.tx_id,
374                            header.ordinal,
375                            header.dynamic_flags(),
376                            (bytes, handles),
377                        )?;
378                        Ok(ColorAdjustmentRequest::_UnknownMethod {
379                            ordinal: header.ordinal,
380                            control_handle: ColorAdjustmentControlHandle {
381                                inner: this.inner.clone(),
382                            },
383                            method_type: fidl::MethodType::TwoWay,
384                        })
385                    }
386                    _ => Err(fidl::Error::UnknownOrdinal {
387                        ordinal: header.ordinal,
388                        protocol_name:
389                            <ColorAdjustmentMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
390                    }),
391                }))
392            },
393        )
394    }
395}
396
397/// Allows clients to request changes to the screen's color adjustment matrix.
398/// This protocol should be implemented and served by the owner of screen presentation.
399#[derive(Debug)]
400pub enum ColorAdjustmentRequest {
401    /// Called to change the color adjustment to a discrete value.
402    /// The server will send a response once the request has been serviced.
403    /// A client can then use this response to determine when to make
404    /// additional calls when limiting the amount of requests being sent.
405    SetDiscreteColorAdjustment {
406        color_adjustment: ColorAdjustmentTable,
407        responder: ColorAdjustmentSetDiscreteColorAdjustmentResponder,
408    },
409    /// An interaction was received which does not match any known method.
410    #[non_exhaustive]
411    _UnknownMethod {
412        /// Ordinal of the method that was called.
413        ordinal: u64,
414        control_handle: ColorAdjustmentControlHandle,
415        method_type: fidl::MethodType,
416    },
417}
418
419impl ColorAdjustmentRequest {
420    #[allow(irrefutable_let_patterns)]
421    pub fn into_set_discrete_color_adjustment(
422        self,
423    ) -> Option<(ColorAdjustmentTable, ColorAdjustmentSetDiscreteColorAdjustmentResponder)> {
424        if let ColorAdjustmentRequest::SetDiscreteColorAdjustment { color_adjustment, responder } =
425            self
426        {
427            Some((color_adjustment, responder))
428        } else {
429            None
430        }
431    }
432
433    /// Name of the method defined in FIDL
434    pub fn method_name(&self) -> &'static str {
435        match *self {
436            ColorAdjustmentRequest::SetDiscreteColorAdjustment { .. } => {
437                "set_discrete_color_adjustment"
438            }
439            ColorAdjustmentRequest::_UnknownMethod {
440                method_type: fidl::MethodType::OneWay,
441                ..
442            } => "unknown one-way method",
443            ColorAdjustmentRequest::_UnknownMethod {
444                method_type: fidl::MethodType::TwoWay,
445                ..
446            } => "unknown two-way method",
447        }
448    }
449}
450
451#[derive(Debug, Clone)]
452pub struct ColorAdjustmentControlHandle {
453    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
454}
455
456impl fidl::endpoints::ControlHandle for ColorAdjustmentControlHandle {
457    fn shutdown(&self) {
458        self.inner.shutdown()
459    }
460
461    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
462        self.inner.shutdown_with_epitaph(status)
463    }
464
465    fn is_closed(&self) -> bool {
466        self.inner.channel().is_closed()
467    }
468    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
469        self.inner.channel().on_closed()
470    }
471
472    #[cfg(target_os = "fuchsia")]
473    fn signal_peer(
474        &self,
475        clear_mask: zx::Signals,
476        set_mask: zx::Signals,
477    ) -> Result<(), zx_status::Status> {
478        use fidl::Peered;
479        self.inner.channel().signal_peer(clear_mask, set_mask)
480    }
481}
482
483impl ColorAdjustmentControlHandle {}
484
485#[must_use = "FIDL methods require a response to be sent"]
486#[derive(Debug)]
487pub struct ColorAdjustmentSetDiscreteColorAdjustmentResponder {
488    control_handle: std::mem::ManuallyDrop<ColorAdjustmentControlHandle>,
489    tx_id: u32,
490}
491
492/// Set the the channel to be shutdown (see [`ColorAdjustmentControlHandle::shutdown`])
493/// if the responder is dropped without sending a response, so that the client
494/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
495impl std::ops::Drop for ColorAdjustmentSetDiscreteColorAdjustmentResponder {
496    fn drop(&mut self) {
497        self.control_handle.shutdown();
498        // Safety: drops once, never accessed again
499        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
500    }
501}
502
503impl fidl::endpoints::Responder for ColorAdjustmentSetDiscreteColorAdjustmentResponder {
504    type ControlHandle = ColorAdjustmentControlHandle;
505
506    fn control_handle(&self) -> &ColorAdjustmentControlHandle {
507        &self.control_handle
508    }
509
510    fn drop_without_shutdown(mut self) {
511        // Safety: drops once, never accessed again due to mem::forget
512        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
513        // Prevent Drop from running (which would shut down the channel)
514        std::mem::forget(self);
515    }
516}
517
518impl ColorAdjustmentSetDiscreteColorAdjustmentResponder {
519    /// Sends a response to the FIDL transaction.
520    ///
521    /// Sets the channel to shutdown if an error occurs.
522    pub fn send(self) -> Result<(), fidl::Error> {
523        let _result = self.send_raw();
524        if _result.is_err() {
525            self.control_handle.shutdown();
526        }
527        self.drop_without_shutdown();
528        _result
529    }
530
531    /// Similar to "send" but does not shutdown the channel if an error occurs.
532    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
533        let _result = self.send_raw();
534        self.drop_without_shutdown();
535        _result
536    }
537
538    fn send_raw(&self) -> Result<(), fidl::Error> {
539        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
540            fidl::encoding::Flexible::new(()),
541            self.tx_id,
542            0x48d90d2e62d451c4,
543            fidl::encoding::DynamicFlags::FLEXIBLE,
544        )
545    }
546}
547
548#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
549pub struct ColorAdjustmentHandlerMarker;
550
551impl fidl::endpoints::ProtocolMarker for ColorAdjustmentHandlerMarker {
552    type Proxy = ColorAdjustmentHandlerProxy;
553    type RequestStream = ColorAdjustmentHandlerRequestStream;
554    #[cfg(target_os = "fuchsia")]
555    type SynchronousProxy = ColorAdjustmentHandlerSynchronousProxy;
556
557    const DEBUG_NAME: &'static str = "fuchsia.ui.brightness.ColorAdjustmentHandler";
558}
559impl fidl::endpoints::DiscoverableProtocolMarker for ColorAdjustmentHandlerMarker {}
560
561pub trait ColorAdjustmentHandlerProxyInterface: Send + Sync {
562    fn r#set_color_adjustment(
563        &self,
564        color_adjustment: &ColorAdjustmentTable,
565    ) -> Result<(), fidl::Error>;
566}
567#[derive(Debug)]
568#[cfg(target_os = "fuchsia")]
569pub struct ColorAdjustmentHandlerSynchronousProxy {
570    client: fidl::client::sync::Client,
571}
572
573#[cfg(target_os = "fuchsia")]
574impl fidl::endpoints::SynchronousProxy for ColorAdjustmentHandlerSynchronousProxy {
575    type Proxy = ColorAdjustmentHandlerProxy;
576    type Protocol = ColorAdjustmentHandlerMarker;
577
578    fn from_channel(inner: fidl::Channel) -> Self {
579        Self::new(inner)
580    }
581
582    fn into_channel(self) -> fidl::Channel {
583        self.client.into_channel()
584    }
585
586    fn as_channel(&self) -> &fidl::Channel {
587        self.client.as_channel()
588    }
589}
590
591#[cfg(target_os = "fuchsia")]
592impl ColorAdjustmentHandlerSynchronousProxy {
593    pub fn new(channel: fidl::Channel) -> Self {
594        Self { client: fidl::client::sync::Client::new(channel) }
595    }
596
597    pub fn into_channel(self) -> fidl::Channel {
598        self.client.into_channel()
599    }
600
601    /// Waits until an event arrives and returns it. It is safe for other
602    /// threads to make concurrent requests while waiting for an event.
603    pub fn wait_for_event(
604        &self,
605        deadline: zx::MonotonicInstant,
606    ) -> Result<ColorAdjustmentHandlerEvent, fidl::Error> {
607        ColorAdjustmentHandlerEvent::decode(
608            self.client.wait_for_event::<ColorAdjustmentHandlerMarker>(deadline)?,
609        )
610    }
611
612    /// Called when the color adjustment  has changed.
613    pub fn r#set_color_adjustment(
614        &self,
615        mut color_adjustment: &ColorAdjustmentTable,
616    ) -> Result<(), fidl::Error> {
617        self.client.send::<ColorAdjustmentHandlerSetColorAdjustmentRequest>(
618            (color_adjustment,),
619            0x6277992fee8aea3d,
620            fidl::encoding::DynamicFlags::empty(),
621        )
622    }
623}
624
625#[cfg(target_os = "fuchsia")]
626impl From<ColorAdjustmentHandlerSynchronousProxy> for zx::NullableHandle {
627    fn from(value: ColorAdjustmentHandlerSynchronousProxy) -> Self {
628        value.into_channel().into()
629    }
630}
631
632#[cfg(target_os = "fuchsia")]
633impl From<fidl::Channel> for ColorAdjustmentHandlerSynchronousProxy {
634    fn from(value: fidl::Channel) -> Self {
635        Self::new(value)
636    }
637}
638
639#[cfg(target_os = "fuchsia")]
640impl fidl::endpoints::FromClient for ColorAdjustmentHandlerSynchronousProxy {
641    type Protocol = ColorAdjustmentHandlerMarker;
642
643    fn from_client(value: fidl::endpoints::ClientEnd<ColorAdjustmentHandlerMarker>) -> Self {
644        Self::new(value.into_channel())
645    }
646}
647
648#[derive(Debug, Clone)]
649pub struct ColorAdjustmentHandlerProxy {
650    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
651}
652
653impl fidl::endpoints::Proxy for ColorAdjustmentHandlerProxy {
654    type Protocol = ColorAdjustmentHandlerMarker;
655
656    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
657        Self::new(inner)
658    }
659
660    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
661        self.client.into_channel().map_err(|client| Self { client })
662    }
663
664    fn as_channel(&self) -> &::fidl::AsyncChannel {
665        self.client.as_channel()
666    }
667}
668
669impl ColorAdjustmentHandlerProxy {
670    /// Create a new Proxy for fuchsia.ui.brightness/ColorAdjustmentHandler.
671    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
672        let protocol_name =
673            <ColorAdjustmentHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
674        Self { client: fidl::client::Client::new(channel, protocol_name) }
675    }
676
677    /// Get a Stream of events from the remote end of the protocol.
678    ///
679    /// # Panics
680    ///
681    /// Panics if the event stream was already taken.
682    pub fn take_event_stream(&self) -> ColorAdjustmentHandlerEventStream {
683        ColorAdjustmentHandlerEventStream { event_receiver: self.client.take_event_receiver() }
684    }
685
686    /// Called when the color adjustment  has changed.
687    pub fn r#set_color_adjustment(
688        &self,
689        mut color_adjustment: &ColorAdjustmentTable,
690    ) -> Result<(), fidl::Error> {
691        ColorAdjustmentHandlerProxyInterface::r#set_color_adjustment(self, color_adjustment)
692    }
693}
694
695impl ColorAdjustmentHandlerProxyInterface for ColorAdjustmentHandlerProxy {
696    fn r#set_color_adjustment(
697        &self,
698        mut color_adjustment: &ColorAdjustmentTable,
699    ) -> Result<(), fidl::Error> {
700        self.client.send::<ColorAdjustmentHandlerSetColorAdjustmentRequest>(
701            (color_adjustment,),
702            0x6277992fee8aea3d,
703            fidl::encoding::DynamicFlags::empty(),
704        )
705    }
706}
707
708pub struct ColorAdjustmentHandlerEventStream {
709    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
710}
711
712impl std::marker::Unpin for ColorAdjustmentHandlerEventStream {}
713
714impl futures::stream::FusedStream for ColorAdjustmentHandlerEventStream {
715    fn is_terminated(&self) -> bool {
716        self.event_receiver.is_terminated()
717    }
718}
719
720impl futures::Stream for ColorAdjustmentHandlerEventStream {
721    type Item = Result<ColorAdjustmentHandlerEvent, fidl::Error>;
722
723    fn poll_next(
724        mut self: std::pin::Pin<&mut Self>,
725        cx: &mut std::task::Context<'_>,
726    ) -> std::task::Poll<Option<Self::Item>> {
727        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
728            &mut self.event_receiver,
729            cx
730        )?) {
731            Some(buf) => std::task::Poll::Ready(Some(ColorAdjustmentHandlerEvent::decode(buf))),
732            None => std::task::Poll::Ready(None),
733        }
734    }
735}
736
737#[derive(Debug)]
738pub enum ColorAdjustmentHandlerEvent {}
739
740impl ColorAdjustmentHandlerEvent {
741    /// Decodes a message buffer as a [`ColorAdjustmentHandlerEvent`].
742    fn decode(
743        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
744    ) -> Result<ColorAdjustmentHandlerEvent, fidl::Error> {
745        let (bytes, _handles) = buf.split_mut();
746        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
747        debug_assert_eq!(tx_header.tx_id, 0);
748        match tx_header.ordinal {
749            _ => Err(fidl::Error::UnknownOrdinal {
750                ordinal: tx_header.ordinal,
751                protocol_name:
752                    <ColorAdjustmentHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
753            }),
754        }
755    }
756}
757
758/// A Stream of incoming requests for fuchsia.ui.brightness/ColorAdjustmentHandler.
759pub struct ColorAdjustmentHandlerRequestStream {
760    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
761    is_terminated: bool,
762}
763
764impl std::marker::Unpin for ColorAdjustmentHandlerRequestStream {}
765
766impl futures::stream::FusedStream for ColorAdjustmentHandlerRequestStream {
767    fn is_terminated(&self) -> bool {
768        self.is_terminated
769    }
770}
771
772impl fidl::endpoints::RequestStream for ColorAdjustmentHandlerRequestStream {
773    type Protocol = ColorAdjustmentHandlerMarker;
774    type ControlHandle = ColorAdjustmentHandlerControlHandle;
775
776    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
777        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
778    }
779
780    fn control_handle(&self) -> Self::ControlHandle {
781        ColorAdjustmentHandlerControlHandle { inner: self.inner.clone() }
782    }
783
784    fn into_inner(
785        self,
786    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
787    {
788        (self.inner, self.is_terminated)
789    }
790
791    fn from_inner(
792        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
793        is_terminated: bool,
794    ) -> Self {
795        Self { inner, is_terminated }
796    }
797}
798
799impl futures::Stream for ColorAdjustmentHandlerRequestStream {
800    type Item = Result<ColorAdjustmentHandlerRequest, fidl::Error>;
801
802    fn poll_next(
803        mut self: std::pin::Pin<&mut Self>,
804        cx: &mut std::task::Context<'_>,
805    ) -> std::task::Poll<Option<Self::Item>> {
806        let this = &mut *self;
807        if this.inner.check_shutdown(cx) {
808            this.is_terminated = true;
809            return std::task::Poll::Ready(None);
810        }
811        if this.is_terminated {
812            panic!("polled ColorAdjustmentHandlerRequestStream after completion");
813        }
814        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
815            |bytes, handles| {
816                match this.inner.channel().read_etc(cx, bytes, handles) {
817                    std::task::Poll::Ready(Ok(())) => {}
818                    std::task::Poll::Pending => return std::task::Poll::Pending,
819                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
820                        this.is_terminated = true;
821                        return std::task::Poll::Ready(None);
822                    }
823                    std::task::Poll::Ready(Err(e)) => {
824                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
825                            e.into(),
826                        ))));
827                    }
828                }
829
830                // A message has been received from the channel
831                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
832
833                std::task::Poll::Ready(Some(match header.ordinal {
834                0x6277992fee8aea3d => {
835                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
836                    let mut req = fidl::new_empty!(ColorAdjustmentHandlerSetColorAdjustmentRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
837                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ColorAdjustmentHandlerSetColorAdjustmentRequest>(&header, _body_bytes, handles, &mut req)?;
838                    let control_handle = ColorAdjustmentHandlerControlHandle {
839                        inner: this.inner.clone(),
840                    };
841                    Ok(ColorAdjustmentHandlerRequest::SetColorAdjustment {color_adjustment: req.color_adjustment,
842
843                        control_handle,
844                    })
845                }
846                _ => Err(fidl::Error::UnknownOrdinal {
847                    ordinal: header.ordinal,
848                    protocol_name: <ColorAdjustmentHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
849                }),
850            }))
851            },
852        )
853    }
854}
855
856/// Handler implemented by the owner of the presentation.
857/// The UI component that controls brightness and screen tint uses this protocol to request changes
858/// to the screen's color adjustment matrix.
859#[derive(Debug)]
860pub enum ColorAdjustmentHandlerRequest {
861    /// Called when the color adjustment  has changed.
862    SetColorAdjustment {
863        color_adjustment: ColorAdjustmentTable,
864        control_handle: ColorAdjustmentHandlerControlHandle,
865    },
866}
867
868impl ColorAdjustmentHandlerRequest {
869    #[allow(irrefutable_let_patterns)]
870    pub fn into_set_color_adjustment(
871        self,
872    ) -> Option<(ColorAdjustmentTable, ColorAdjustmentHandlerControlHandle)> {
873        if let ColorAdjustmentHandlerRequest::SetColorAdjustment {
874            color_adjustment,
875            control_handle,
876        } = self
877        {
878            Some((color_adjustment, control_handle))
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            ColorAdjustmentHandlerRequest::SetColorAdjustment { .. } => "set_color_adjustment",
888        }
889    }
890}
891
892#[derive(Debug, Clone)]
893pub struct ColorAdjustmentHandlerControlHandle {
894    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
895}
896
897impl fidl::endpoints::ControlHandle for ColorAdjustmentHandlerControlHandle {
898    fn shutdown(&self) {
899        self.inner.shutdown()
900    }
901
902    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
903        self.inner.shutdown_with_epitaph(status)
904    }
905
906    fn is_closed(&self) -> bool {
907        self.inner.channel().is_closed()
908    }
909    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
910        self.inner.channel().on_closed()
911    }
912
913    #[cfg(target_os = "fuchsia")]
914    fn signal_peer(
915        &self,
916        clear_mask: zx::Signals,
917        set_mask: zx::Signals,
918    ) -> Result<(), zx_status::Status> {
919        use fidl::Peered;
920        self.inner.channel().signal_peer(clear_mask, set_mask)
921    }
922}
923
924impl ColorAdjustmentHandlerControlHandle {}
925
926#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
927pub struct ControlMarker;
928
929impl fidl::endpoints::ProtocolMarker for ControlMarker {
930    type Proxy = ControlProxy;
931    type RequestStream = ControlRequestStream;
932    #[cfg(target_os = "fuchsia")]
933    type SynchronousProxy = ControlSynchronousProxy;
934
935    const DEBUG_NAME: &'static str = "fuchsia.ui.brightness.Control";
936}
937impl fidl::endpoints::DiscoverableProtocolMarker for ControlMarker {}
938pub type ControlGetMaxAbsoluteBrightnessResult = Result<f64, i32>;
939
940pub trait ControlProxyInterface: Send + Sync {
941    fn r#set_auto_brightness(&self) -> Result<(), fidl::Error>;
942    type WatchAutoBrightnessResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
943        + Send;
944    fn r#watch_auto_brightness(&self) -> Self::WatchAutoBrightnessResponseFut;
945    fn r#set_manual_brightness(&self, value: f32) -> Result<(), fidl::Error>;
946    fn r#set_manual_brightness_smooth(&self, value: f32, duration: i64) -> Result<(), fidl::Error>;
947    type WatchCurrentBrightnessResponseFut: std::future::Future<Output = Result<f32, fidl::Error>>
948        + Send;
949    fn r#watch_current_brightness(&self) -> Self::WatchCurrentBrightnessResponseFut;
950    fn r#set_auto_brightness_adjustment(&self, adjustment: f32) -> Result<(), fidl::Error>;
951    type WatchAutoBrightnessAdjustmentResponseFut: std::future::Future<Output = Result<f32, fidl::Error>>
952        + Send;
953    fn r#watch_auto_brightness_adjustment(&self) -> Self::WatchAutoBrightnessAdjustmentResponseFut;
954    fn r#set_brightness_table(&self, table: &BrightnessTable) -> Result<(), fidl::Error>;
955    type GetMaxAbsoluteBrightnessResponseFut: std::future::Future<Output = Result<ControlGetMaxAbsoluteBrightnessResult, fidl::Error>>
956        + Send;
957    fn r#get_max_absolute_brightness(&self) -> Self::GetMaxAbsoluteBrightnessResponseFut;
958}
959#[derive(Debug)]
960#[cfg(target_os = "fuchsia")]
961pub struct ControlSynchronousProxy {
962    client: fidl::client::sync::Client,
963}
964
965#[cfg(target_os = "fuchsia")]
966impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
967    type Proxy = ControlProxy;
968    type Protocol = ControlMarker;
969
970    fn from_channel(inner: fidl::Channel) -> Self {
971        Self::new(inner)
972    }
973
974    fn into_channel(self) -> fidl::Channel {
975        self.client.into_channel()
976    }
977
978    fn as_channel(&self) -> &fidl::Channel {
979        self.client.as_channel()
980    }
981}
982
983#[cfg(target_os = "fuchsia")]
984impl ControlSynchronousProxy {
985    pub fn new(channel: fidl::Channel) -> Self {
986        Self { client: fidl::client::sync::Client::new(channel) }
987    }
988
989    pub fn into_channel(self) -> fidl::Channel {
990        self.client.into_channel()
991    }
992
993    /// Waits until an event arrives and returns it. It is safe for other
994    /// threads to make concurrent requests while waiting for an event.
995    pub fn wait_for_event(
996        &self,
997        deadline: zx::MonotonicInstant,
998    ) -> Result<ControlEvent, fidl::Error> {
999        ControlEvent::decode(self.client.wait_for_event::<ControlMarker>(deadline)?)
1000    }
1001
1002    /// Turns the auto-brightness mode on.
1003    /// SetManualBrightness will turn it off.
1004    pub fn r#set_auto_brightness(&self) -> Result<(), fidl::Error> {
1005        self.client.send::<fidl::encoding::EmptyPayload>(
1006            (),
1007            0x46b623a7fa77a979,
1008            fidl::encoding::DynamicFlags::empty(),
1009        )
1010    }
1011
1012    /// Requests the current auto-brightness mode.
1013    /// This call implements the Hanging Get protocol.
1014    pub fn r#watch_auto_brightness(
1015        &self,
1016        ___deadline: zx::MonotonicInstant,
1017    ) -> Result<bool, fidl::Error> {
1018        let _response = self.client.send_query::<
1019            fidl::encoding::EmptyPayload,
1020            ControlWatchAutoBrightnessResponse,
1021            ControlMarker,
1022        >(
1023            (),
1024            0xd956a90c115186b,
1025            fidl::encoding::DynamicFlags::empty(),
1026            ___deadline,
1027        )?;
1028        Ok(_response.enabled)
1029    }
1030
1031    /// Turns auto-brightness mode off.
1032    /// Used by e.g. Settings to set manual brightness using a slider
1033    /// Value is in the range 0.0 to 1.0 representing min to max and
1034    /// will be clamped if out of range.
1035    pub fn r#set_manual_brightness(&self, mut value: f32) -> Result<(), fidl::Error> {
1036        self.client.send::<ControlSetManualBrightnessRequest>(
1037            (value,),
1038            0x1e333aa49771e1eb,
1039            fidl::encoding::DynamicFlags::empty(),
1040        )
1041    }
1042
1043    /// Set manual brightness specifying the duration over which the
1044    /// target brightness will be set.
1045    pub fn r#set_manual_brightness_smooth(
1046        &self,
1047        mut value: f32,
1048        mut duration: i64,
1049    ) -> Result<(), fidl::Error> {
1050        self.client.send::<ControlSetManualBrightnessSmoothRequest>(
1051            (value, duration),
1052            0x7b7d273c20a61d0c,
1053            fidl::encoding::DynamicFlags::empty(),
1054        )
1055    }
1056
1057    /// Gets the current brightness in the range 0.0 to 1.0.
1058    /// This result is valid for both manual and auto-brightness modes
1059    /// and is typically used to show the current brightness on a slider.
1060    /// This call implements the Hanging Get protocol.
1061    pub fn r#watch_current_brightness(
1062        &self,
1063        ___deadline: zx::MonotonicInstant,
1064    ) -> Result<f32, fidl::Error> {
1065        let _response = self.client.send_query::<
1066            fidl::encoding::EmptyPayload,
1067            ControlWatchCurrentBrightnessResponse,
1068            ControlMarker,
1069        >(
1070            (),
1071            0x2cc3011e2326d4d8,
1072            fidl::encoding::DynamicFlags::empty(),
1073            ___deadline,
1074        )?;
1075        Ok(_response.value)
1076    }
1077
1078    /// Sets the brightness adjustment.
1079    /// This will change the brightness curve by the factor of the adjustment.
1080    /// The adjustment is in the range of -1.0 to 1.0.
1081    pub fn r#set_auto_brightness_adjustment(&self, mut adjustment: f32) -> Result<(), fidl::Error> {
1082        self.client.send::<ControlSetAutoBrightnessAdjustmentRequest>(
1083            (adjustment,),
1084            0x678ee26bc217d996,
1085            fidl::encoding::DynamicFlags::empty(),
1086        )
1087    }
1088
1089    /// Gets the current auto brightness adjustment.
1090    /// This call implements the Hanging Get protocol.
1091    pub fn r#watch_auto_brightness_adjustment(
1092        &self,
1093        ___deadline: zx::MonotonicInstant,
1094    ) -> Result<f32, fidl::Error> {
1095        let _response = self.client.send_query::<
1096            fidl::encoding::EmptyPayload,
1097            ControlWatchAutoBrightnessAdjustmentResponse,
1098            ControlMarker,
1099        >(
1100            (),
1101            0x7c373aafe0058135,
1102            fidl::encoding::DynamicFlags::empty(),
1103            ___deadline,
1104        )?;
1105        Ok(_response.adjustment)
1106    }
1107
1108    /// Sets the brightness curve as a set of points.
1109    /// This will override the built-in brightness curve.
1110    /// The default brightness curve will be used if the table is empty.
1111    /// The connection will be closed if table errors are detected.
1112    pub fn r#set_brightness_table(&self, mut table: &BrightnessTable) -> Result<(), fidl::Error> {
1113        self.client.send::<ControlSetBrightnessTableRequest>(
1114            (table,),
1115            0x11d419413129dcee,
1116            fidl::encoding::DynamicFlags::empty(),
1117        )
1118    }
1119
1120    /// Gets the maximum supported backlight brightness in nits, if known.
1121    pub fn r#get_max_absolute_brightness(
1122        &self,
1123        ___deadline: zx::MonotonicInstant,
1124    ) -> Result<ControlGetMaxAbsoluteBrightnessResult, fidl::Error> {
1125        let _response = self.client.send_query::<
1126            fidl::encoding::EmptyPayload,
1127            fidl::encoding::ResultType<ControlGetMaxAbsoluteBrightnessResponse, i32>,
1128            ControlMarker,
1129        >(
1130            (),
1131            0x73055a8d6422caf8,
1132            fidl::encoding::DynamicFlags::empty(),
1133            ___deadline,
1134        )?;
1135        Ok(_response.map(|x| x.max_brightness))
1136    }
1137}
1138
1139#[cfg(target_os = "fuchsia")]
1140impl From<ControlSynchronousProxy> for zx::NullableHandle {
1141    fn from(value: ControlSynchronousProxy) -> Self {
1142        value.into_channel().into()
1143    }
1144}
1145
1146#[cfg(target_os = "fuchsia")]
1147impl From<fidl::Channel> for ControlSynchronousProxy {
1148    fn from(value: fidl::Channel) -> Self {
1149        Self::new(value)
1150    }
1151}
1152
1153#[cfg(target_os = "fuchsia")]
1154impl fidl::endpoints::FromClient for ControlSynchronousProxy {
1155    type Protocol = ControlMarker;
1156
1157    fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
1158        Self::new(value.into_channel())
1159    }
1160}
1161
1162#[derive(Debug, Clone)]
1163pub struct ControlProxy {
1164    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1165}
1166
1167impl fidl::endpoints::Proxy for ControlProxy {
1168    type Protocol = ControlMarker;
1169
1170    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1171        Self::new(inner)
1172    }
1173
1174    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1175        self.client.into_channel().map_err(|client| Self { client })
1176    }
1177
1178    fn as_channel(&self) -> &::fidl::AsyncChannel {
1179        self.client.as_channel()
1180    }
1181}
1182
1183impl ControlProxy {
1184    /// Create a new Proxy for fuchsia.ui.brightness/Control.
1185    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1186        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1187        Self { client: fidl::client::Client::new(channel, protocol_name) }
1188    }
1189
1190    /// Get a Stream of events from the remote end of the protocol.
1191    ///
1192    /// # Panics
1193    ///
1194    /// Panics if the event stream was already taken.
1195    pub fn take_event_stream(&self) -> ControlEventStream {
1196        ControlEventStream { event_receiver: self.client.take_event_receiver() }
1197    }
1198
1199    /// Turns the auto-brightness mode on.
1200    /// SetManualBrightness will turn it off.
1201    pub fn r#set_auto_brightness(&self) -> Result<(), fidl::Error> {
1202        ControlProxyInterface::r#set_auto_brightness(self)
1203    }
1204
1205    /// Requests the current auto-brightness mode.
1206    /// This call implements the Hanging Get protocol.
1207    pub fn r#watch_auto_brightness(
1208        &self,
1209    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
1210        ControlProxyInterface::r#watch_auto_brightness(self)
1211    }
1212
1213    /// Turns auto-brightness mode off.
1214    /// Used by e.g. Settings to set manual brightness using a slider
1215    /// Value is in the range 0.0 to 1.0 representing min to max and
1216    /// will be clamped if out of range.
1217    pub fn r#set_manual_brightness(&self, mut value: f32) -> Result<(), fidl::Error> {
1218        ControlProxyInterface::r#set_manual_brightness(self, value)
1219    }
1220
1221    /// Set manual brightness specifying the duration over which the
1222    /// target brightness will be set.
1223    pub fn r#set_manual_brightness_smooth(
1224        &self,
1225        mut value: f32,
1226        mut duration: i64,
1227    ) -> Result<(), fidl::Error> {
1228        ControlProxyInterface::r#set_manual_brightness_smooth(self, value, duration)
1229    }
1230
1231    /// Gets the current brightness in the range 0.0 to 1.0.
1232    /// This result is valid for both manual and auto-brightness modes
1233    /// and is typically used to show the current brightness on a slider.
1234    /// This call implements the Hanging Get protocol.
1235    pub fn r#watch_current_brightness(
1236        &self,
1237    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1238        ControlProxyInterface::r#watch_current_brightness(self)
1239    }
1240
1241    /// Sets the brightness adjustment.
1242    /// This will change the brightness curve by the factor of the adjustment.
1243    /// The adjustment is in the range of -1.0 to 1.0.
1244    pub fn r#set_auto_brightness_adjustment(&self, mut adjustment: f32) -> Result<(), fidl::Error> {
1245        ControlProxyInterface::r#set_auto_brightness_adjustment(self, adjustment)
1246    }
1247
1248    /// Gets the current auto brightness adjustment.
1249    /// This call implements the Hanging Get protocol.
1250    pub fn r#watch_auto_brightness_adjustment(
1251        &self,
1252    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1253        ControlProxyInterface::r#watch_auto_brightness_adjustment(self)
1254    }
1255
1256    /// Sets the brightness curve as a set of points.
1257    /// This will override the built-in brightness curve.
1258    /// The default brightness curve will be used if the table is empty.
1259    /// The connection will be closed if table errors are detected.
1260    pub fn r#set_brightness_table(&self, mut table: &BrightnessTable) -> Result<(), fidl::Error> {
1261        ControlProxyInterface::r#set_brightness_table(self, table)
1262    }
1263
1264    /// Gets the maximum supported backlight brightness in nits, if known.
1265    pub fn r#get_max_absolute_brightness(
1266        &self,
1267    ) -> fidl::client::QueryResponseFut<
1268        ControlGetMaxAbsoluteBrightnessResult,
1269        fidl::encoding::DefaultFuchsiaResourceDialect,
1270    > {
1271        ControlProxyInterface::r#get_max_absolute_brightness(self)
1272    }
1273}
1274
1275impl ControlProxyInterface for ControlProxy {
1276    fn r#set_auto_brightness(&self) -> Result<(), fidl::Error> {
1277        self.client.send::<fidl::encoding::EmptyPayload>(
1278            (),
1279            0x46b623a7fa77a979,
1280            fidl::encoding::DynamicFlags::empty(),
1281        )
1282    }
1283
1284    type WatchAutoBrightnessResponseFut =
1285        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
1286    fn r#watch_auto_brightness(&self) -> Self::WatchAutoBrightnessResponseFut {
1287        fn _decode(
1288            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1289        ) -> Result<bool, fidl::Error> {
1290            let _response = fidl::client::decode_transaction_body::<
1291                ControlWatchAutoBrightnessResponse,
1292                fidl::encoding::DefaultFuchsiaResourceDialect,
1293                0xd956a90c115186b,
1294            >(_buf?)?;
1295            Ok(_response.enabled)
1296        }
1297        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
1298            (),
1299            0xd956a90c115186b,
1300            fidl::encoding::DynamicFlags::empty(),
1301            _decode,
1302        )
1303    }
1304
1305    fn r#set_manual_brightness(&self, mut value: f32) -> Result<(), fidl::Error> {
1306        self.client.send::<ControlSetManualBrightnessRequest>(
1307            (value,),
1308            0x1e333aa49771e1eb,
1309            fidl::encoding::DynamicFlags::empty(),
1310        )
1311    }
1312
1313    fn r#set_manual_brightness_smooth(
1314        &self,
1315        mut value: f32,
1316        mut duration: i64,
1317    ) -> Result<(), fidl::Error> {
1318        self.client.send::<ControlSetManualBrightnessSmoothRequest>(
1319            (value, duration),
1320            0x7b7d273c20a61d0c,
1321            fidl::encoding::DynamicFlags::empty(),
1322        )
1323    }
1324
1325    type WatchCurrentBrightnessResponseFut =
1326        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1327    fn r#watch_current_brightness(&self) -> Self::WatchCurrentBrightnessResponseFut {
1328        fn _decode(
1329            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1330        ) -> Result<f32, fidl::Error> {
1331            let _response = fidl::client::decode_transaction_body::<
1332                ControlWatchCurrentBrightnessResponse,
1333                fidl::encoding::DefaultFuchsiaResourceDialect,
1334                0x2cc3011e2326d4d8,
1335            >(_buf?)?;
1336            Ok(_response.value)
1337        }
1338        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, f32>(
1339            (),
1340            0x2cc3011e2326d4d8,
1341            fidl::encoding::DynamicFlags::empty(),
1342            _decode,
1343        )
1344    }
1345
1346    fn r#set_auto_brightness_adjustment(&self, mut adjustment: f32) -> Result<(), fidl::Error> {
1347        self.client.send::<ControlSetAutoBrightnessAdjustmentRequest>(
1348            (adjustment,),
1349            0x678ee26bc217d996,
1350            fidl::encoding::DynamicFlags::empty(),
1351        )
1352    }
1353
1354    type WatchAutoBrightnessAdjustmentResponseFut =
1355        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1356    fn r#watch_auto_brightness_adjustment(&self) -> Self::WatchAutoBrightnessAdjustmentResponseFut {
1357        fn _decode(
1358            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1359        ) -> Result<f32, fidl::Error> {
1360            let _response = fidl::client::decode_transaction_body::<
1361                ControlWatchAutoBrightnessAdjustmentResponse,
1362                fidl::encoding::DefaultFuchsiaResourceDialect,
1363                0x7c373aafe0058135,
1364            >(_buf?)?;
1365            Ok(_response.adjustment)
1366        }
1367        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, f32>(
1368            (),
1369            0x7c373aafe0058135,
1370            fidl::encoding::DynamicFlags::empty(),
1371            _decode,
1372        )
1373    }
1374
1375    fn r#set_brightness_table(&self, mut table: &BrightnessTable) -> Result<(), fidl::Error> {
1376        self.client.send::<ControlSetBrightnessTableRequest>(
1377            (table,),
1378            0x11d419413129dcee,
1379            fidl::encoding::DynamicFlags::empty(),
1380        )
1381    }
1382
1383    type GetMaxAbsoluteBrightnessResponseFut = fidl::client::QueryResponseFut<
1384        ControlGetMaxAbsoluteBrightnessResult,
1385        fidl::encoding::DefaultFuchsiaResourceDialect,
1386    >;
1387    fn r#get_max_absolute_brightness(&self) -> Self::GetMaxAbsoluteBrightnessResponseFut {
1388        fn _decode(
1389            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1390        ) -> Result<ControlGetMaxAbsoluteBrightnessResult, fidl::Error> {
1391            let _response = fidl::client::decode_transaction_body::<
1392                fidl::encoding::ResultType<ControlGetMaxAbsoluteBrightnessResponse, i32>,
1393                fidl::encoding::DefaultFuchsiaResourceDialect,
1394                0x73055a8d6422caf8,
1395            >(_buf?)?;
1396            Ok(_response.map(|x| x.max_brightness))
1397        }
1398        self.client.send_query_and_decode::<
1399            fidl::encoding::EmptyPayload,
1400            ControlGetMaxAbsoluteBrightnessResult,
1401        >(
1402            (),
1403            0x73055a8d6422caf8,
1404            fidl::encoding::DynamicFlags::empty(),
1405            _decode,
1406        )
1407    }
1408}
1409
1410pub struct ControlEventStream {
1411    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1412}
1413
1414impl std::marker::Unpin for ControlEventStream {}
1415
1416impl futures::stream::FusedStream for ControlEventStream {
1417    fn is_terminated(&self) -> bool {
1418        self.event_receiver.is_terminated()
1419    }
1420}
1421
1422impl futures::Stream for ControlEventStream {
1423    type Item = Result<ControlEvent, fidl::Error>;
1424
1425    fn poll_next(
1426        mut self: std::pin::Pin<&mut Self>,
1427        cx: &mut std::task::Context<'_>,
1428    ) -> std::task::Poll<Option<Self::Item>> {
1429        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1430            &mut self.event_receiver,
1431            cx
1432        )?) {
1433            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
1434            None => std::task::Poll::Ready(None),
1435        }
1436    }
1437}
1438
1439#[derive(Debug)]
1440pub enum ControlEvent {}
1441
1442impl ControlEvent {
1443    /// Decodes a message buffer as a [`ControlEvent`].
1444    fn decode(
1445        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1446    ) -> Result<ControlEvent, fidl::Error> {
1447        let (bytes, _handles) = buf.split_mut();
1448        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1449        debug_assert_eq!(tx_header.tx_id, 0);
1450        match tx_header.ordinal {
1451            _ => Err(fidl::Error::UnknownOrdinal {
1452                ordinal: tx_header.ordinal,
1453                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1454            }),
1455        }
1456    }
1457}
1458
1459/// A Stream of incoming requests for fuchsia.ui.brightness/Control.
1460pub struct ControlRequestStream {
1461    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1462    is_terminated: bool,
1463}
1464
1465impl std::marker::Unpin for ControlRequestStream {}
1466
1467impl futures::stream::FusedStream for ControlRequestStream {
1468    fn is_terminated(&self) -> bool {
1469        self.is_terminated
1470    }
1471}
1472
1473impl fidl::endpoints::RequestStream for ControlRequestStream {
1474    type Protocol = ControlMarker;
1475    type ControlHandle = ControlControlHandle;
1476
1477    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1478        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1479    }
1480
1481    fn control_handle(&self) -> Self::ControlHandle {
1482        ControlControlHandle { inner: self.inner.clone() }
1483    }
1484
1485    fn into_inner(
1486        self,
1487    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1488    {
1489        (self.inner, self.is_terminated)
1490    }
1491
1492    fn from_inner(
1493        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1494        is_terminated: bool,
1495    ) -> Self {
1496        Self { inner, is_terminated }
1497    }
1498}
1499
1500impl futures::Stream for ControlRequestStream {
1501    type Item = Result<ControlRequest, fidl::Error>;
1502
1503    fn poll_next(
1504        mut self: std::pin::Pin<&mut Self>,
1505        cx: &mut std::task::Context<'_>,
1506    ) -> std::task::Poll<Option<Self::Item>> {
1507        let this = &mut *self;
1508        if this.inner.check_shutdown(cx) {
1509            this.is_terminated = true;
1510            return std::task::Poll::Ready(None);
1511        }
1512        if this.is_terminated {
1513            panic!("polled ControlRequestStream after completion");
1514        }
1515        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1516            |bytes, handles| {
1517                match this.inner.channel().read_etc(cx, bytes, handles) {
1518                    std::task::Poll::Ready(Ok(())) => {}
1519                    std::task::Poll::Pending => return std::task::Poll::Pending,
1520                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1521                        this.is_terminated = true;
1522                        return std::task::Poll::Ready(None);
1523                    }
1524                    std::task::Poll::Ready(Err(e)) => {
1525                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1526                            e.into(),
1527                        ))));
1528                    }
1529                }
1530
1531                // A message has been received from the channel
1532                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1533
1534                std::task::Poll::Ready(Some(match header.ordinal {
1535                    0x46b623a7fa77a979 => {
1536                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1537                        let mut req = fidl::new_empty!(
1538                            fidl::encoding::EmptyPayload,
1539                            fidl::encoding::DefaultFuchsiaResourceDialect
1540                        );
1541                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1542                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1543                        Ok(ControlRequest::SetAutoBrightness { control_handle })
1544                    }
1545                    0xd956a90c115186b => {
1546                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1547                        let mut req = fidl::new_empty!(
1548                            fidl::encoding::EmptyPayload,
1549                            fidl::encoding::DefaultFuchsiaResourceDialect
1550                        );
1551                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1552                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1553                        Ok(ControlRequest::WatchAutoBrightness {
1554                            responder: ControlWatchAutoBrightnessResponder {
1555                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1556                                tx_id: header.tx_id,
1557                            },
1558                        })
1559                    }
1560                    0x1e333aa49771e1eb => {
1561                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1562                        let mut req = fidl::new_empty!(
1563                            ControlSetManualBrightnessRequest,
1564                            fidl::encoding::DefaultFuchsiaResourceDialect
1565                        );
1566                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetManualBrightnessRequest>(&header, _body_bytes, handles, &mut req)?;
1567                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1568                        Ok(ControlRequest::SetManualBrightness { value: req.value, control_handle })
1569                    }
1570                    0x7b7d273c20a61d0c => {
1571                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1572                        let mut req = fidl::new_empty!(
1573                            ControlSetManualBrightnessSmoothRequest,
1574                            fidl::encoding::DefaultFuchsiaResourceDialect
1575                        );
1576                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetManualBrightnessSmoothRequest>(&header, _body_bytes, handles, &mut req)?;
1577                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1578                        Ok(ControlRequest::SetManualBrightnessSmooth {
1579                            value: req.value,
1580                            duration: req.duration,
1581
1582                            control_handle,
1583                        })
1584                    }
1585                    0x2cc3011e2326d4d8 => {
1586                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1587                        let mut req = fidl::new_empty!(
1588                            fidl::encoding::EmptyPayload,
1589                            fidl::encoding::DefaultFuchsiaResourceDialect
1590                        );
1591                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1592                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1593                        Ok(ControlRequest::WatchCurrentBrightness {
1594                            responder: ControlWatchCurrentBrightnessResponder {
1595                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1596                                tx_id: header.tx_id,
1597                            },
1598                        })
1599                    }
1600                    0x678ee26bc217d996 => {
1601                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1602                        let mut req = fidl::new_empty!(
1603                            ControlSetAutoBrightnessAdjustmentRequest,
1604                            fidl::encoding::DefaultFuchsiaResourceDialect
1605                        );
1606                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetAutoBrightnessAdjustmentRequest>(&header, _body_bytes, handles, &mut req)?;
1607                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1608                        Ok(ControlRequest::SetAutoBrightnessAdjustment {
1609                            adjustment: req.adjustment,
1610
1611                            control_handle,
1612                        })
1613                    }
1614                    0x7c373aafe0058135 => {
1615                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1616                        let mut req = fidl::new_empty!(
1617                            fidl::encoding::EmptyPayload,
1618                            fidl::encoding::DefaultFuchsiaResourceDialect
1619                        );
1620                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1621                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1622                        Ok(ControlRequest::WatchAutoBrightnessAdjustment {
1623                            responder: ControlWatchAutoBrightnessAdjustmentResponder {
1624                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1625                                tx_id: header.tx_id,
1626                            },
1627                        })
1628                    }
1629                    0x11d419413129dcee => {
1630                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1631                        let mut req = fidl::new_empty!(
1632                            ControlSetBrightnessTableRequest,
1633                            fidl::encoding::DefaultFuchsiaResourceDialect
1634                        );
1635                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetBrightnessTableRequest>(&header, _body_bytes, handles, &mut req)?;
1636                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1637                        Ok(ControlRequest::SetBrightnessTable { table: req.table, control_handle })
1638                    }
1639                    0x73055a8d6422caf8 => {
1640                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1641                        let mut req = fidl::new_empty!(
1642                            fidl::encoding::EmptyPayload,
1643                            fidl::encoding::DefaultFuchsiaResourceDialect
1644                        );
1645                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1646                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1647                        Ok(ControlRequest::GetMaxAbsoluteBrightness {
1648                            responder: ControlGetMaxAbsoluteBrightnessResponder {
1649                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1650                                tx_id: header.tx_id,
1651                            },
1652                        })
1653                    }
1654                    _ => Err(fidl::Error::UnknownOrdinal {
1655                        ordinal: header.ordinal,
1656                        protocol_name:
1657                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1658                    }),
1659                }))
1660            },
1661        )
1662    }
1663}
1664
1665/// Control provides an interface to manage the brightness component.
1666#[derive(Debug)]
1667pub enum ControlRequest {
1668    /// Turns the auto-brightness mode on.
1669    /// SetManualBrightness will turn it off.
1670    SetAutoBrightness { control_handle: ControlControlHandle },
1671    /// Requests the current auto-brightness mode.
1672    /// This call implements the Hanging Get protocol.
1673    WatchAutoBrightness { responder: ControlWatchAutoBrightnessResponder },
1674    /// Turns auto-brightness mode off.
1675    /// Used by e.g. Settings to set manual brightness using a slider
1676    /// Value is in the range 0.0 to 1.0 representing min to max and
1677    /// will be clamped if out of range.
1678    SetManualBrightness { value: f32, control_handle: ControlControlHandle },
1679    /// Set manual brightness specifying the duration over which the
1680    /// target brightness will be set.
1681    SetManualBrightnessSmooth { value: f32, duration: i64, control_handle: ControlControlHandle },
1682    /// Gets the current brightness in the range 0.0 to 1.0.
1683    /// This result is valid for both manual and auto-brightness modes
1684    /// and is typically used to show the current brightness on a slider.
1685    /// This call implements the Hanging Get protocol.
1686    WatchCurrentBrightness { responder: ControlWatchCurrentBrightnessResponder },
1687    /// Sets the brightness adjustment.
1688    /// This will change the brightness curve by the factor of the adjustment.
1689    /// The adjustment is in the range of -1.0 to 1.0.
1690    SetAutoBrightnessAdjustment { adjustment: f32, control_handle: ControlControlHandle },
1691    /// Gets the current auto brightness adjustment.
1692    /// This call implements the Hanging Get protocol.
1693    WatchAutoBrightnessAdjustment { responder: ControlWatchAutoBrightnessAdjustmentResponder },
1694    /// Sets the brightness curve as a set of points.
1695    /// This will override the built-in brightness curve.
1696    /// The default brightness curve will be used if the table is empty.
1697    /// The connection will be closed if table errors are detected.
1698    SetBrightnessTable { table: BrightnessTable, control_handle: ControlControlHandle },
1699    /// Gets the maximum supported backlight brightness in nits, if known.
1700    GetMaxAbsoluteBrightness { responder: ControlGetMaxAbsoluteBrightnessResponder },
1701}
1702
1703impl ControlRequest {
1704    #[allow(irrefutable_let_patterns)]
1705    pub fn into_set_auto_brightness(self) -> Option<(ControlControlHandle)> {
1706        if let ControlRequest::SetAutoBrightness { control_handle } = self {
1707            Some((control_handle))
1708        } else {
1709            None
1710        }
1711    }
1712
1713    #[allow(irrefutable_let_patterns)]
1714    pub fn into_watch_auto_brightness(self) -> Option<(ControlWatchAutoBrightnessResponder)> {
1715        if let ControlRequest::WatchAutoBrightness { responder } = self {
1716            Some((responder))
1717        } else {
1718            None
1719        }
1720    }
1721
1722    #[allow(irrefutable_let_patterns)]
1723    pub fn into_set_manual_brightness(self) -> Option<(f32, ControlControlHandle)> {
1724        if let ControlRequest::SetManualBrightness { value, control_handle } = self {
1725            Some((value, control_handle))
1726        } else {
1727            None
1728        }
1729    }
1730
1731    #[allow(irrefutable_let_patterns)]
1732    pub fn into_set_manual_brightness_smooth(self) -> Option<(f32, i64, ControlControlHandle)> {
1733        if let ControlRequest::SetManualBrightnessSmooth { value, duration, control_handle } = self
1734        {
1735            Some((value, duration, control_handle))
1736        } else {
1737            None
1738        }
1739    }
1740
1741    #[allow(irrefutable_let_patterns)]
1742    pub fn into_watch_current_brightness(self) -> Option<(ControlWatchCurrentBrightnessResponder)> {
1743        if let ControlRequest::WatchCurrentBrightness { responder } = self {
1744            Some((responder))
1745        } else {
1746            None
1747        }
1748    }
1749
1750    #[allow(irrefutable_let_patterns)]
1751    pub fn into_set_auto_brightness_adjustment(self) -> Option<(f32, ControlControlHandle)> {
1752        if let ControlRequest::SetAutoBrightnessAdjustment { adjustment, control_handle } = self {
1753            Some((adjustment, control_handle))
1754        } else {
1755            None
1756        }
1757    }
1758
1759    #[allow(irrefutable_let_patterns)]
1760    pub fn into_watch_auto_brightness_adjustment(
1761        self,
1762    ) -> Option<(ControlWatchAutoBrightnessAdjustmentResponder)> {
1763        if let ControlRequest::WatchAutoBrightnessAdjustment { responder } = self {
1764            Some((responder))
1765        } else {
1766            None
1767        }
1768    }
1769
1770    #[allow(irrefutable_let_patterns)]
1771    pub fn into_set_brightness_table(self) -> Option<(BrightnessTable, ControlControlHandle)> {
1772        if let ControlRequest::SetBrightnessTable { table, control_handle } = self {
1773            Some((table, control_handle))
1774        } else {
1775            None
1776        }
1777    }
1778
1779    #[allow(irrefutable_let_patterns)]
1780    pub fn into_get_max_absolute_brightness(
1781        self,
1782    ) -> Option<(ControlGetMaxAbsoluteBrightnessResponder)> {
1783        if let ControlRequest::GetMaxAbsoluteBrightness { responder } = self {
1784            Some((responder))
1785        } else {
1786            None
1787        }
1788    }
1789
1790    /// Name of the method defined in FIDL
1791    pub fn method_name(&self) -> &'static str {
1792        match *self {
1793            ControlRequest::SetAutoBrightness { .. } => "set_auto_brightness",
1794            ControlRequest::WatchAutoBrightness { .. } => "watch_auto_brightness",
1795            ControlRequest::SetManualBrightness { .. } => "set_manual_brightness",
1796            ControlRequest::SetManualBrightnessSmooth { .. } => "set_manual_brightness_smooth",
1797            ControlRequest::WatchCurrentBrightness { .. } => "watch_current_brightness",
1798            ControlRequest::SetAutoBrightnessAdjustment { .. } => "set_auto_brightness_adjustment",
1799            ControlRequest::WatchAutoBrightnessAdjustment { .. } => {
1800                "watch_auto_brightness_adjustment"
1801            }
1802            ControlRequest::SetBrightnessTable { .. } => "set_brightness_table",
1803            ControlRequest::GetMaxAbsoluteBrightness { .. } => "get_max_absolute_brightness",
1804        }
1805    }
1806}
1807
1808#[derive(Debug, Clone)]
1809pub struct ControlControlHandle {
1810    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1811}
1812
1813impl fidl::endpoints::ControlHandle for ControlControlHandle {
1814    fn shutdown(&self) {
1815        self.inner.shutdown()
1816    }
1817
1818    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1819        self.inner.shutdown_with_epitaph(status)
1820    }
1821
1822    fn is_closed(&self) -> bool {
1823        self.inner.channel().is_closed()
1824    }
1825    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1826        self.inner.channel().on_closed()
1827    }
1828
1829    #[cfg(target_os = "fuchsia")]
1830    fn signal_peer(
1831        &self,
1832        clear_mask: zx::Signals,
1833        set_mask: zx::Signals,
1834    ) -> Result<(), zx_status::Status> {
1835        use fidl::Peered;
1836        self.inner.channel().signal_peer(clear_mask, set_mask)
1837    }
1838}
1839
1840impl ControlControlHandle {}
1841
1842#[must_use = "FIDL methods require a response to be sent"]
1843#[derive(Debug)]
1844pub struct ControlWatchAutoBrightnessResponder {
1845    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1846    tx_id: u32,
1847}
1848
1849/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1850/// if the responder is dropped without sending a response, so that the client
1851/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1852impl std::ops::Drop for ControlWatchAutoBrightnessResponder {
1853    fn drop(&mut self) {
1854        self.control_handle.shutdown();
1855        // Safety: drops once, never accessed again
1856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1857    }
1858}
1859
1860impl fidl::endpoints::Responder for ControlWatchAutoBrightnessResponder {
1861    type ControlHandle = ControlControlHandle;
1862
1863    fn control_handle(&self) -> &ControlControlHandle {
1864        &self.control_handle
1865    }
1866
1867    fn drop_without_shutdown(mut self) {
1868        // Safety: drops once, never accessed again due to mem::forget
1869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1870        // Prevent Drop from running (which would shut down the channel)
1871        std::mem::forget(self);
1872    }
1873}
1874
1875impl ControlWatchAutoBrightnessResponder {
1876    /// Sends a response to the FIDL transaction.
1877    ///
1878    /// Sets the channel to shutdown if an error occurs.
1879    pub fn send(self, mut enabled: bool) -> Result<(), fidl::Error> {
1880        let _result = self.send_raw(enabled);
1881        if _result.is_err() {
1882            self.control_handle.shutdown();
1883        }
1884        self.drop_without_shutdown();
1885        _result
1886    }
1887
1888    /// Similar to "send" but does not shutdown the channel if an error occurs.
1889    pub fn send_no_shutdown_on_err(self, mut enabled: bool) -> Result<(), fidl::Error> {
1890        let _result = self.send_raw(enabled);
1891        self.drop_without_shutdown();
1892        _result
1893    }
1894
1895    fn send_raw(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1896        self.control_handle.inner.send::<ControlWatchAutoBrightnessResponse>(
1897            (enabled,),
1898            self.tx_id,
1899            0xd956a90c115186b,
1900            fidl::encoding::DynamicFlags::empty(),
1901        )
1902    }
1903}
1904
1905#[must_use = "FIDL methods require a response to be sent"]
1906#[derive(Debug)]
1907pub struct ControlWatchCurrentBrightnessResponder {
1908    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1909    tx_id: u32,
1910}
1911
1912/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1913/// if the responder is dropped without sending a response, so that the client
1914/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1915impl std::ops::Drop for ControlWatchCurrentBrightnessResponder {
1916    fn drop(&mut self) {
1917        self.control_handle.shutdown();
1918        // Safety: drops once, never accessed again
1919        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1920    }
1921}
1922
1923impl fidl::endpoints::Responder for ControlWatchCurrentBrightnessResponder {
1924    type ControlHandle = ControlControlHandle;
1925
1926    fn control_handle(&self) -> &ControlControlHandle {
1927        &self.control_handle
1928    }
1929
1930    fn drop_without_shutdown(mut self) {
1931        // Safety: drops once, never accessed again due to mem::forget
1932        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1933        // Prevent Drop from running (which would shut down the channel)
1934        std::mem::forget(self);
1935    }
1936}
1937
1938impl ControlWatchCurrentBrightnessResponder {
1939    /// Sends a response to the FIDL transaction.
1940    ///
1941    /// Sets the channel to shutdown if an error occurs.
1942    pub fn send(self, mut value: f32) -> Result<(), fidl::Error> {
1943        let _result = self.send_raw(value);
1944        if _result.is_err() {
1945            self.control_handle.shutdown();
1946        }
1947        self.drop_without_shutdown();
1948        _result
1949    }
1950
1951    /// Similar to "send" but does not shutdown the channel if an error occurs.
1952    pub fn send_no_shutdown_on_err(self, mut value: f32) -> Result<(), fidl::Error> {
1953        let _result = self.send_raw(value);
1954        self.drop_without_shutdown();
1955        _result
1956    }
1957
1958    fn send_raw(&self, mut value: f32) -> Result<(), fidl::Error> {
1959        self.control_handle.inner.send::<ControlWatchCurrentBrightnessResponse>(
1960            (value,),
1961            self.tx_id,
1962            0x2cc3011e2326d4d8,
1963            fidl::encoding::DynamicFlags::empty(),
1964        )
1965    }
1966}
1967
1968#[must_use = "FIDL methods require a response to be sent"]
1969#[derive(Debug)]
1970pub struct ControlWatchAutoBrightnessAdjustmentResponder {
1971    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1972    tx_id: u32,
1973}
1974
1975/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1976/// if the responder is dropped without sending a response, so that the client
1977/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1978impl std::ops::Drop for ControlWatchAutoBrightnessAdjustmentResponder {
1979    fn drop(&mut self) {
1980        self.control_handle.shutdown();
1981        // Safety: drops once, never accessed again
1982        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1983    }
1984}
1985
1986impl fidl::endpoints::Responder for ControlWatchAutoBrightnessAdjustmentResponder {
1987    type ControlHandle = ControlControlHandle;
1988
1989    fn control_handle(&self) -> &ControlControlHandle {
1990        &self.control_handle
1991    }
1992
1993    fn drop_without_shutdown(mut self) {
1994        // Safety: drops once, never accessed again due to mem::forget
1995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1996        // Prevent Drop from running (which would shut down the channel)
1997        std::mem::forget(self);
1998    }
1999}
2000
2001impl ControlWatchAutoBrightnessAdjustmentResponder {
2002    /// Sends a response to the FIDL transaction.
2003    ///
2004    /// Sets the channel to shutdown if an error occurs.
2005    pub fn send(self, mut adjustment: f32) -> Result<(), fidl::Error> {
2006        let _result = self.send_raw(adjustment);
2007        if _result.is_err() {
2008            self.control_handle.shutdown();
2009        }
2010        self.drop_without_shutdown();
2011        _result
2012    }
2013
2014    /// Similar to "send" but does not shutdown the channel if an error occurs.
2015    pub fn send_no_shutdown_on_err(self, mut adjustment: f32) -> Result<(), fidl::Error> {
2016        let _result = self.send_raw(adjustment);
2017        self.drop_without_shutdown();
2018        _result
2019    }
2020
2021    fn send_raw(&self, mut adjustment: f32) -> Result<(), fidl::Error> {
2022        self.control_handle.inner.send::<ControlWatchAutoBrightnessAdjustmentResponse>(
2023            (adjustment,),
2024            self.tx_id,
2025            0x7c373aafe0058135,
2026            fidl::encoding::DynamicFlags::empty(),
2027        )
2028    }
2029}
2030
2031#[must_use = "FIDL methods require a response to be sent"]
2032#[derive(Debug)]
2033pub struct ControlGetMaxAbsoluteBrightnessResponder {
2034    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2035    tx_id: u32,
2036}
2037
2038/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2039/// if the responder is dropped without sending a response, so that the client
2040/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2041impl std::ops::Drop for ControlGetMaxAbsoluteBrightnessResponder {
2042    fn drop(&mut self) {
2043        self.control_handle.shutdown();
2044        // Safety: drops once, never accessed again
2045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2046    }
2047}
2048
2049impl fidl::endpoints::Responder for ControlGetMaxAbsoluteBrightnessResponder {
2050    type ControlHandle = ControlControlHandle;
2051
2052    fn control_handle(&self) -> &ControlControlHandle {
2053        &self.control_handle
2054    }
2055
2056    fn drop_without_shutdown(mut self) {
2057        // Safety: drops once, never accessed again due to mem::forget
2058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2059        // Prevent Drop from running (which would shut down the channel)
2060        std::mem::forget(self);
2061    }
2062}
2063
2064impl ControlGetMaxAbsoluteBrightnessResponder {
2065    /// Sends a response to the FIDL transaction.
2066    ///
2067    /// Sets the channel to shutdown if an error occurs.
2068    pub fn send(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
2069        let _result = self.send_raw(result);
2070        if _result.is_err() {
2071            self.control_handle.shutdown();
2072        }
2073        self.drop_without_shutdown();
2074        _result
2075    }
2076
2077    /// Similar to "send" but does not shutdown the channel if an error occurs.
2078    pub fn send_no_shutdown_on_err(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
2079        let _result = self.send_raw(result);
2080        self.drop_without_shutdown();
2081        _result
2082    }
2083
2084    fn send_raw(&self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
2085        self.control_handle.inner.send::<fidl::encoding::ResultType<
2086            ControlGetMaxAbsoluteBrightnessResponse,
2087            i32,
2088        >>(
2089            result.map(|max_brightness| (max_brightness,)),
2090            self.tx_id,
2091            0x73055a8d6422caf8,
2092            fidl::encoding::DynamicFlags::empty(),
2093        )
2094    }
2095}
2096
2097mod internal {
2098    use super::*;
2099}