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        let protocol_name = <ColorAdjustmentMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
63        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
64    }
65
66    pub fn into_channel(self) -> fidl::Channel {
67        self.client.into_channel()
68    }
69
70    /// Waits until an event arrives and returns it. It is safe for other
71    /// threads to make concurrent requests while waiting for an event.
72    pub fn wait_for_event(
73        &self,
74        deadline: zx::MonotonicInstant,
75    ) -> Result<ColorAdjustmentEvent, fidl::Error> {
76        ColorAdjustmentEvent::decode(self.client.wait_for_event(deadline)?)
77    }
78
79    /// Called to change the color adjustment to a discrete value.
80    /// The server will send a response once the request has been serviced.
81    /// A client can then use this response to determine when to make
82    /// additional calls when limiting the amount of requests being sent.
83    pub fn r#set_discrete_color_adjustment(
84        &self,
85        mut color_adjustment: &ColorAdjustmentTable,
86        ___deadline: zx::MonotonicInstant,
87    ) -> Result<(), fidl::Error> {
88        let _response = self.client.send_query::<
89            ColorAdjustmentSetDiscreteColorAdjustmentRequest,
90            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
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        let protocol_name =
595            <ColorAdjustmentHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
596        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
597    }
598
599    pub fn into_channel(self) -> fidl::Channel {
600        self.client.into_channel()
601    }
602
603    /// Waits until an event arrives and returns it. It is safe for other
604    /// threads to make concurrent requests while waiting for an event.
605    pub fn wait_for_event(
606        &self,
607        deadline: zx::MonotonicInstant,
608    ) -> Result<ColorAdjustmentHandlerEvent, fidl::Error> {
609        ColorAdjustmentHandlerEvent::decode(self.client.wait_for_event(deadline)?)
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        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
987        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
988    }
989
990    pub fn into_channel(self) -> fidl::Channel {
991        self.client.into_channel()
992    }
993
994    /// Waits until an event arrives and returns it. It is safe for other
995    /// threads to make concurrent requests while waiting for an event.
996    pub fn wait_for_event(
997        &self,
998        deadline: zx::MonotonicInstant,
999    ) -> Result<ControlEvent, fidl::Error> {
1000        ControlEvent::decode(self.client.wait_for_event(deadline)?)
1001    }
1002
1003    /// Turns the auto-brightness mode on.
1004    /// SetManualBrightness will turn it off.
1005    pub fn r#set_auto_brightness(&self) -> Result<(), fidl::Error> {
1006        self.client.send::<fidl::encoding::EmptyPayload>(
1007            (),
1008            0x46b623a7fa77a979,
1009            fidl::encoding::DynamicFlags::empty(),
1010        )
1011    }
1012
1013    /// Requests the current auto-brightness mode.
1014    /// This call implements the Hanging Get protocol.
1015    pub fn r#watch_auto_brightness(
1016        &self,
1017        ___deadline: zx::MonotonicInstant,
1018    ) -> Result<bool, fidl::Error> {
1019        let _response = self
1020            .client
1021            .send_query::<fidl::encoding::EmptyPayload, ControlWatchAutoBrightnessResponse>(
1022                (),
1023                0xd956a90c115186b,
1024                fidl::encoding::DynamicFlags::empty(),
1025                ___deadline,
1026            )?;
1027        Ok(_response.enabled)
1028    }
1029
1030    /// Turns auto-brightness mode off.
1031    /// Used by e.g. Settings to set manual brightness using a slider
1032    /// Value is in the range 0.0 to 1.0 representing min to max and
1033    /// will be clamped if out of range.
1034    pub fn r#set_manual_brightness(&self, mut value: f32) -> Result<(), fidl::Error> {
1035        self.client.send::<ControlSetManualBrightnessRequest>(
1036            (value,),
1037            0x1e333aa49771e1eb,
1038            fidl::encoding::DynamicFlags::empty(),
1039        )
1040    }
1041
1042    /// Set manual brightness specifying the duration over which the
1043    /// target brightness will be set.
1044    pub fn r#set_manual_brightness_smooth(
1045        &self,
1046        mut value: f32,
1047        mut duration: i64,
1048    ) -> Result<(), fidl::Error> {
1049        self.client.send::<ControlSetManualBrightnessSmoothRequest>(
1050            (value, duration),
1051            0x7b7d273c20a61d0c,
1052            fidl::encoding::DynamicFlags::empty(),
1053        )
1054    }
1055
1056    /// Gets the current brightness in the range 0.0 to 1.0.
1057    /// This result is valid for both manual and auto-brightness modes
1058    /// and is typically used to show the current brightness on a slider.
1059    /// This call implements the Hanging Get protocol.
1060    pub fn r#watch_current_brightness(
1061        &self,
1062        ___deadline: zx::MonotonicInstant,
1063    ) -> Result<f32, fidl::Error> {
1064        let _response = self
1065            .client
1066            .send_query::<fidl::encoding::EmptyPayload, ControlWatchCurrentBrightnessResponse>(
1067                (),
1068                0x2cc3011e2326d4d8,
1069                fidl::encoding::DynamicFlags::empty(),
1070                ___deadline,
1071            )?;
1072        Ok(_response.value)
1073    }
1074
1075    /// Sets the brightness adjustment.
1076    /// This will change the brightness curve by the factor of the adjustment.
1077    /// The adjustment is in the range of -1.0 to 1.0.
1078    pub fn r#set_auto_brightness_adjustment(&self, mut adjustment: f32) -> Result<(), fidl::Error> {
1079        self.client.send::<ControlSetAutoBrightnessAdjustmentRequest>(
1080            (adjustment,),
1081            0x678ee26bc217d996,
1082            fidl::encoding::DynamicFlags::empty(),
1083        )
1084    }
1085
1086    /// Gets the current auto brightness adjustment.
1087    /// This call implements the Hanging Get protocol.
1088    pub fn r#watch_auto_brightness_adjustment(
1089        &self,
1090        ___deadline: zx::MonotonicInstant,
1091    ) -> Result<f32, fidl::Error> {
1092        let _response = self.client.send_query::<
1093            fidl::encoding::EmptyPayload,
1094            ControlWatchAutoBrightnessAdjustmentResponse,
1095        >(
1096            (),
1097            0x7c373aafe0058135,
1098            fidl::encoding::DynamicFlags::empty(),
1099            ___deadline,
1100        )?;
1101        Ok(_response.adjustment)
1102    }
1103
1104    /// Sets the brightness curve as a set of points.
1105    /// This will override the built-in brightness curve.
1106    /// The default brightness curve will be used if the table is empty.
1107    /// The connection will be closed if table errors are detected.
1108    pub fn r#set_brightness_table(&self, mut table: &BrightnessTable) -> Result<(), fidl::Error> {
1109        self.client.send::<ControlSetBrightnessTableRequest>(
1110            (table,),
1111            0x11d419413129dcee,
1112            fidl::encoding::DynamicFlags::empty(),
1113        )
1114    }
1115
1116    /// Gets the maximum supported backlight brightness in nits, if known.
1117    pub fn r#get_max_absolute_brightness(
1118        &self,
1119        ___deadline: zx::MonotonicInstant,
1120    ) -> Result<ControlGetMaxAbsoluteBrightnessResult, fidl::Error> {
1121        let _response = self.client.send_query::<
1122            fidl::encoding::EmptyPayload,
1123            fidl::encoding::ResultType<ControlGetMaxAbsoluteBrightnessResponse, i32>,
1124        >(
1125            (),
1126            0x73055a8d6422caf8,
1127            fidl::encoding::DynamicFlags::empty(),
1128            ___deadline,
1129        )?;
1130        Ok(_response.map(|x| x.max_brightness))
1131    }
1132}
1133
1134#[cfg(target_os = "fuchsia")]
1135impl From<ControlSynchronousProxy> for zx::NullableHandle {
1136    fn from(value: ControlSynchronousProxy) -> Self {
1137        value.into_channel().into()
1138    }
1139}
1140
1141#[cfg(target_os = "fuchsia")]
1142impl From<fidl::Channel> for ControlSynchronousProxy {
1143    fn from(value: fidl::Channel) -> Self {
1144        Self::new(value)
1145    }
1146}
1147
1148#[cfg(target_os = "fuchsia")]
1149impl fidl::endpoints::FromClient for ControlSynchronousProxy {
1150    type Protocol = ControlMarker;
1151
1152    fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
1153        Self::new(value.into_channel())
1154    }
1155}
1156
1157#[derive(Debug, Clone)]
1158pub struct ControlProxy {
1159    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1160}
1161
1162impl fidl::endpoints::Proxy for ControlProxy {
1163    type Protocol = ControlMarker;
1164
1165    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1166        Self::new(inner)
1167    }
1168
1169    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1170        self.client.into_channel().map_err(|client| Self { client })
1171    }
1172
1173    fn as_channel(&self) -> &::fidl::AsyncChannel {
1174        self.client.as_channel()
1175    }
1176}
1177
1178impl ControlProxy {
1179    /// Create a new Proxy for fuchsia.ui.brightness/Control.
1180    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1181        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1182        Self { client: fidl::client::Client::new(channel, protocol_name) }
1183    }
1184
1185    /// Get a Stream of events from the remote end of the protocol.
1186    ///
1187    /// # Panics
1188    ///
1189    /// Panics if the event stream was already taken.
1190    pub fn take_event_stream(&self) -> ControlEventStream {
1191        ControlEventStream { event_receiver: self.client.take_event_receiver() }
1192    }
1193
1194    /// Turns the auto-brightness mode on.
1195    /// SetManualBrightness will turn it off.
1196    pub fn r#set_auto_brightness(&self) -> Result<(), fidl::Error> {
1197        ControlProxyInterface::r#set_auto_brightness(self)
1198    }
1199
1200    /// Requests the current auto-brightness mode.
1201    /// This call implements the Hanging Get protocol.
1202    pub fn r#watch_auto_brightness(
1203        &self,
1204    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
1205        ControlProxyInterface::r#watch_auto_brightness(self)
1206    }
1207
1208    /// Turns auto-brightness mode off.
1209    /// Used by e.g. Settings to set manual brightness using a slider
1210    /// Value is in the range 0.0 to 1.0 representing min to max and
1211    /// will be clamped if out of range.
1212    pub fn r#set_manual_brightness(&self, mut value: f32) -> Result<(), fidl::Error> {
1213        ControlProxyInterface::r#set_manual_brightness(self, value)
1214    }
1215
1216    /// Set manual brightness specifying the duration over which the
1217    /// target brightness will be set.
1218    pub fn r#set_manual_brightness_smooth(
1219        &self,
1220        mut value: f32,
1221        mut duration: i64,
1222    ) -> Result<(), fidl::Error> {
1223        ControlProxyInterface::r#set_manual_brightness_smooth(self, value, duration)
1224    }
1225
1226    /// Gets the current brightness in the range 0.0 to 1.0.
1227    /// This result is valid for both manual and auto-brightness modes
1228    /// and is typically used to show the current brightness on a slider.
1229    /// This call implements the Hanging Get protocol.
1230    pub fn r#watch_current_brightness(
1231        &self,
1232    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1233        ControlProxyInterface::r#watch_current_brightness(self)
1234    }
1235
1236    /// Sets the brightness adjustment.
1237    /// This will change the brightness curve by the factor of the adjustment.
1238    /// The adjustment is in the range of -1.0 to 1.0.
1239    pub fn r#set_auto_brightness_adjustment(&self, mut adjustment: f32) -> Result<(), fidl::Error> {
1240        ControlProxyInterface::r#set_auto_brightness_adjustment(self, adjustment)
1241    }
1242
1243    /// Gets the current auto brightness adjustment.
1244    /// This call implements the Hanging Get protocol.
1245    pub fn r#watch_auto_brightness_adjustment(
1246        &self,
1247    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1248        ControlProxyInterface::r#watch_auto_brightness_adjustment(self)
1249    }
1250
1251    /// Sets the brightness curve as a set of points.
1252    /// This will override the built-in brightness curve.
1253    /// The default brightness curve will be used if the table is empty.
1254    /// The connection will be closed if table errors are detected.
1255    pub fn r#set_brightness_table(&self, mut table: &BrightnessTable) -> Result<(), fidl::Error> {
1256        ControlProxyInterface::r#set_brightness_table(self, table)
1257    }
1258
1259    /// Gets the maximum supported backlight brightness in nits, if known.
1260    pub fn r#get_max_absolute_brightness(
1261        &self,
1262    ) -> fidl::client::QueryResponseFut<
1263        ControlGetMaxAbsoluteBrightnessResult,
1264        fidl::encoding::DefaultFuchsiaResourceDialect,
1265    > {
1266        ControlProxyInterface::r#get_max_absolute_brightness(self)
1267    }
1268}
1269
1270impl ControlProxyInterface for ControlProxy {
1271    fn r#set_auto_brightness(&self) -> Result<(), fidl::Error> {
1272        self.client.send::<fidl::encoding::EmptyPayload>(
1273            (),
1274            0x46b623a7fa77a979,
1275            fidl::encoding::DynamicFlags::empty(),
1276        )
1277    }
1278
1279    type WatchAutoBrightnessResponseFut =
1280        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
1281    fn r#watch_auto_brightness(&self) -> Self::WatchAutoBrightnessResponseFut {
1282        fn _decode(
1283            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1284        ) -> Result<bool, fidl::Error> {
1285            let _response = fidl::client::decode_transaction_body::<
1286                ControlWatchAutoBrightnessResponse,
1287                fidl::encoding::DefaultFuchsiaResourceDialect,
1288                0xd956a90c115186b,
1289            >(_buf?)?;
1290            Ok(_response.enabled)
1291        }
1292        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
1293            (),
1294            0xd956a90c115186b,
1295            fidl::encoding::DynamicFlags::empty(),
1296            _decode,
1297        )
1298    }
1299
1300    fn r#set_manual_brightness(&self, mut value: f32) -> Result<(), fidl::Error> {
1301        self.client.send::<ControlSetManualBrightnessRequest>(
1302            (value,),
1303            0x1e333aa49771e1eb,
1304            fidl::encoding::DynamicFlags::empty(),
1305        )
1306    }
1307
1308    fn r#set_manual_brightness_smooth(
1309        &self,
1310        mut value: f32,
1311        mut duration: i64,
1312    ) -> Result<(), fidl::Error> {
1313        self.client.send::<ControlSetManualBrightnessSmoothRequest>(
1314            (value, duration),
1315            0x7b7d273c20a61d0c,
1316            fidl::encoding::DynamicFlags::empty(),
1317        )
1318    }
1319
1320    type WatchCurrentBrightnessResponseFut =
1321        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1322    fn r#watch_current_brightness(&self) -> Self::WatchCurrentBrightnessResponseFut {
1323        fn _decode(
1324            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1325        ) -> Result<f32, fidl::Error> {
1326            let _response = fidl::client::decode_transaction_body::<
1327                ControlWatchCurrentBrightnessResponse,
1328                fidl::encoding::DefaultFuchsiaResourceDialect,
1329                0x2cc3011e2326d4d8,
1330            >(_buf?)?;
1331            Ok(_response.value)
1332        }
1333        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, f32>(
1334            (),
1335            0x2cc3011e2326d4d8,
1336            fidl::encoding::DynamicFlags::empty(),
1337            _decode,
1338        )
1339    }
1340
1341    fn r#set_auto_brightness_adjustment(&self, mut adjustment: f32) -> Result<(), fidl::Error> {
1342        self.client.send::<ControlSetAutoBrightnessAdjustmentRequest>(
1343            (adjustment,),
1344            0x678ee26bc217d996,
1345            fidl::encoding::DynamicFlags::empty(),
1346        )
1347    }
1348
1349    type WatchAutoBrightnessAdjustmentResponseFut =
1350        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1351    fn r#watch_auto_brightness_adjustment(&self) -> Self::WatchAutoBrightnessAdjustmentResponseFut {
1352        fn _decode(
1353            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1354        ) -> Result<f32, fidl::Error> {
1355            let _response = fidl::client::decode_transaction_body::<
1356                ControlWatchAutoBrightnessAdjustmentResponse,
1357                fidl::encoding::DefaultFuchsiaResourceDialect,
1358                0x7c373aafe0058135,
1359            >(_buf?)?;
1360            Ok(_response.adjustment)
1361        }
1362        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, f32>(
1363            (),
1364            0x7c373aafe0058135,
1365            fidl::encoding::DynamicFlags::empty(),
1366            _decode,
1367        )
1368    }
1369
1370    fn r#set_brightness_table(&self, mut table: &BrightnessTable) -> Result<(), fidl::Error> {
1371        self.client.send::<ControlSetBrightnessTableRequest>(
1372            (table,),
1373            0x11d419413129dcee,
1374            fidl::encoding::DynamicFlags::empty(),
1375        )
1376    }
1377
1378    type GetMaxAbsoluteBrightnessResponseFut = fidl::client::QueryResponseFut<
1379        ControlGetMaxAbsoluteBrightnessResult,
1380        fidl::encoding::DefaultFuchsiaResourceDialect,
1381    >;
1382    fn r#get_max_absolute_brightness(&self) -> Self::GetMaxAbsoluteBrightnessResponseFut {
1383        fn _decode(
1384            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1385        ) -> Result<ControlGetMaxAbsoluteBrightnessResult, fidl::Error> {
1386            let _response = fidl::client::decode_transaction_body::<
1387                fidl::encoding::ResultType<ControlGetMaxAbsoluteBrightnessResponse, i32>,
1388                fidl::encoding::DefaultFuchsiaResourceDialect,
1389                0x73055a8d6422caf8,
1390            >(_buf?)?;
1391            Ok(_response.map(|x| x.max_brightness))
1392        }
1393        self.client.send_query_and_decode::<
1394            fidl::encoding::EmptyPayload,
1395            ControlGetMaxAbsoluteBrightnessResult,
1396        >(
1397            (),
1398            0x73055a8d6422caf8,
1399            fidl::encoding::DynamicFlags::empty(),
1400            _decode,
1401        )
1402    }
1403}
1404
1405pub struct ControlEventStream {
1406    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1407}
1408
1409impl std::marker::Unpin for ControlEventStream {}
1410
1411impl futures::stream::FusedStream for ControlEventStream {
1412    fn is_terminated(&self) -> bool {
1413        self.event_receiver.is_terminated()
1414    }
1415}
1416
1417impl futures::Stream for ControlEventStream {
1418    type Item = Result<ControlEvent, fidl::Error>;
1419
1420    fn poll_next(
1421        mut self: std::pin::Pin<&mut Self>,
1422        cx: &mut std::task::Context<'_>,
1423    ) -> std::task::Poll<Option<Self::Item>> {
1424        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1425            &mut self.event_receiver,
1426            cx
1427        )?) {
1428            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
1429            None => std::task::Poll::Ready(None),
1430        }
1431    }
1432}
1433
1434#[derive(Debug)]
1435pub enum ControlEvent {}
1436
1437impl ControlEvent {
1438    /// Decodes a message buffer as a [`ControlEvent`].
1439    fn decode(
1440        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1441    ) -> Result<ControlEvent, fidl::Error> {
1442        let (bytes, _handles) = buf.split_mut();
1443        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1444        debug_assert_eq!(tx_header.tx_id, 0);
1445        match tx_header.ordinal {
1446            _ => Err(fidl::Error::UnknownOrdinal {
1447                ordinal: tx_header.ordinal,
1448                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1449            }),
1450        }
1451    }
1452}
1453
1454/// A Stream of incoming requests for fuchsia.ui.brightness/Control.
1455pub struct ControlRequestStream {
1456    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1457    is_terminated: bool,
1458}
1459
1460impl std::marker::Unpin for ControlRequestStream {}
1461
1462impl futures::stream::FusedStream for ControlRequestStream {
1463    fn is_terminated(&self) -> bool {
1464        self.is_terminated
1465    }
1466}
1467
1468impl fidl::endpoints::RequestStream for ControlRequestStream {
1469    type Protocol = ControlMarker;
1470    type ControlHandle = ControlControlHandle;
1471
1472    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1473        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1474    }
1475
1476    fn control_handle(&self) -> Self::ControlHandle {
1477        ControlControlHandle { inner: self.inner.clone() }
1478    }
1479
1480    fn into_inner(
1481        self,
1482    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1483    {
1484        (self.inner, self.is_terminated)
1485    }
1486
1487    fn from_inner(
1488        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1489        is_terminated: bool,
1490    ) -> Self {
1491        Self { inner, is_terminated }
1492    }
1493}
1494
1495impl futures::Stream for ControlRequestStream {
1496    type Item = Result<ControlRequest, fidl::Error>;
1497
1498    fn poll_next(
1499        mut self: std::pin::Pin<&mut Self>,
1500        cx: &mut std::task::Context<'_>,
1501    ) -> std::task::Poll<Option<Self::Item>> {
1502        let this = &mut *self;
1503        if this.inner.check_shutdown(cx) {
1504            this.is_terminated = true;
1505            return std::task::Poll::Ready(None);
1506        }
1507        if this.is_terminated {
1508            panic!("polled ControlRequestStream after completion");
1509        }
1510        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1511            |bytes, handles| {
1512                match this.inner.channel().read_etc(cx, bytes, handles) {
1513                    std::task::Poll::Ready(Ok(())) => {}
1514                    std::task::Poll::Pending => return std::task::Poll::Pending,
1515                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1516                        this.is_terminated = true;
1517                        return std::task::Poll::Ready(None);
1518                    }
1519                    std::task::Poll::Ready(Err(e)) => {
1520                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1521                            e.into(),
1522                        ))));
1523                    }
1524                }
1525
1526                // A message has been received from the channel
1527                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1528
1529                std::task::Poll::Ready(Some(match header.ordinal {
1530                    0x46b623a7fa77a979 => {
1531                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1532                        let mut req = fidl::new_empty!(
1533                            fidl::encoding::EmptyPayload,
1534                            fidl::encoding::DefaultFuchsiaResourceDialect
1535                        );
1536                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1537                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1538                        Ok(ControlRequest::SetAutoBrightness { control_handle })
1539                    }
1540                    0xd956a90c115186b => {
1541                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1542                        let mut req = fidl::new_empty!(
1543                            fidl::encoding::EmptyPayload,
1544                            fidl::encoding::DefaultFuchsiaResourceDialect
1545                        );
1546                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1547                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1548                        Ok(ControlRequest::WatchAutoBrightness {
1549                            responder: ControlWatchAutoBrightnessResponder {
1550                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1551                                tx_id: header.tx_id,
1552                            },
1553                        })
1554                    }
1555                    0x1e333aa49771e1eb => {
1556                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1557                        let mut req = fidl::new_empty!(
1558                            ControlSetManualBrightnessRequest,
1559                            fidl::encoding::DefaultFuchsiaResourceDialect
1560                        );
1561                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetManualBrightnessRequest>(&header, _body_bytes, handles, &mut req)?;
1562                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1563                        Ok(ControlRequest::SetManualBrightness { value: req.value, control_handle })
1564                    }
1565                    0x7b7d273c20a61d0c => {
1566                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1567                        let mut req = fidl::new_empty!(
1568                            ControlSetManualBrightnessSmoothRequest,
1569                            fidl::encoding::DefaultFuchsiaResourceDialect
1570                        );
1571                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetManualBrightnessSmoothRequest>(&header, _body_bytes, handles, &mut req)?;
1572                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1573                        Ok(ControlRequest::SetManualBrightnessSmooth {
1574                            value: req.value,
1575                            duration: req.duration,
1576
1577                            control_handle,
1578                        })
1579                    }
1580                    0x2cc3011e2326d4d8 => {
1581                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1582                        let mut req = fidl::new_empty!(
1583                            fidl::encoding::EmptyPayload,
1584                            fidl::encoding::DefaultFuchsiaResourceDialect
1585                        );
1586                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1587                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1588                        Ok(ControlRequest::WatchCurrentBrightness {
1589                            responder: ControlWatchCurrentBrightnessResponder {
1590                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1591                                tx_id: header.tx_id,
1592                            },
1593                        })
1594                    }
1595                    0x678ee26bc217d996 => {
1596                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1597                        let mut req = fidl::new_empty!(
1598                            ControlSetAutoBrightnessAdjustmentRequest,
1599                            fidl::encoding::DefaultFuchsiaResourceDialect
1600                        );
1601                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetAutoBrightnessAdjustmentRequest>(&header, _body_bytes, handles, &mut req)?;
1602                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1603                        Ok(ControlRequest::SetAutoBrightnessAdjustment {
1604                            adjustment: req.adjustment,
1605
1606                            control_handle,
1607                        })
1608                    }
1609                    0x7c373aafe0058135 => {
1610                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1611                        let mut req = fidl::new_empty!(
1612                            fidl::encoding::EmptyPayload,
1613                            fidl::encoding::DefaultFuchsiaResourceDialect
1614                        );
1615                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1616                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1617                        Ok(ControlRequest::WatchAutoBrightnessAdjustment {
1618                            responder: ControlWatchAutoBrightnessAdjustmentResponder {
1619                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1620                                tx_id: header.tx_id,
1621                            },
1622                        })
1623                    }
1624                    0x11d419413129dcee => {
1625                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1626                        let mut req = fidl::new_empty!(
1627                            ControlSetBrightnessTableRequest,
1628                            fidl::encoding::DefaultFuchsiaResourceDialect
1629                        );
1630                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetBrightnessTableRequest>(&header, _body_bytes, handles, &mut req)?;
1631                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1632                        Ok(ControlRequest::SetBrightnessTable { table: req.table, control_handle })
1633                    }
1634                    0x73055a8d6422caf8 => {
1635                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1636                        let mut req = fidl::new_empty!(
1637                            fidl::encoding::EmptyPayload,
1638                            fidl::encoding::DefaultFuchsiaResourceDialect
1639                        );
1640                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1641                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1642                        Ok(ControlRequest::GetMaxAbsoluteBrightness {
1643                            responder: ControlGetMaxAbsoluteBrightnessResponder {
1644                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1645                                tx_id: header.tx_id,
1646                            },
1647                        })
1648                    }
1649                    _ => Err(fidl::Error::UnknownOrdinal {
1650                        ordinal: header.ordinal,
1651                        protocol_name:
1652                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1653                    }),
1654                }))
1655            },
1656        )
1657    }
1658}
1659
1660/// Control provides an interface to manage the brightness component.
1661#[derive(Debug)]
1662pub enum ControlRequest {
1663    /// Turns the auto-brightness mode on.
1664    /// SetManualBrightness will turn it off.
1665    SetAutoBrightness { control_handle: ControlControlHandle },
1666    /// Requests the current auto-brightness mode.
1667    /// This call implements the Hanging Get protocol.
1668    WatchAutoBrightness { responder: ControlWatchAutoBrightnessResponder },
1669    /// Turns auto-brightness mode off.
1670    /// Used by e.g. Settings to set manual brightness using a slider
1671    /// Value is in the range 0.0 to 1.0 representing min to max and
1672    /// will be clamped if out of range.
1673    SetManualBrightness { value: f32, control_handle: ControlControlHandle },
1674    /// Set manual brightness specifying the duration over which the
1675    /// target brightness will be set.
1676    SetManualBrightnessSmooth { value: f32, duration: i64, control_handle: ControlControlHandle },
1677    /// Gets the current brightness in the range 0.0 to 1.0.
1678    /// This result is valid for both manual and auto-brightness modes
1679    /// and is typically used to show the current brightness on a slider.
1680    /// This call implements the Hanging Get protocol.
1681    WatchCurrentBrightness { responder: ControlWatchCurrentBrightnessResponder },
1682    /// Sets the brightness adjustment.
1683    /// This will change the brightness curve by the factor of the adjustment.
1684    /// The adjustment is in the range of -1.0 to 1.0.
1685    SetAutoBrightnessAdjustment { adjustment: f32, control_handle: ControlControlHandle },
1686    /// Gets the current auto brightness adjustment.
1687    /// This call implements the Hanging Get protocol.
1688    WatchAutoBrightnessAdjustment { responder: ControlWatchAutoBrightnessAdjustmentResponder },
1689    /// Sets the brightness curve as a set of points.
1690    /// This will override the built-in brightness curve.
1691    /// The default brightness curve will be used if the table is empty.
1692    /// The connection will be closed if table errors are detected.
1693    SetBrightnessTable { table: BrightnessTable, control_handle: ControlControlHandle },
1694    /// Gets the maximum supported backlight brightness in nits, if known.
1695    GetMaxAbsoluteBrightness { responder: ControlGetMaxAbsoluteBrightnessResponder },
1696}
1697
1698impl ControlRequest {
1699    #[allow(irrefutable_let_patterns)]
1700    pub fn into_set_auto_brightness(self) -> Option<(ControlControlHandle)> {
1701        if let ControlRequest::SetAutoBrightness { control_handle } = self {
1702            Some((control_handle))
1703        } else {
1704            None
1705        }
1706    }
1707
1708    #[allow(irrefutable_let_patterns)]
1709    pub fn into_watch_auto_brightness(self) -> Option<(ControlWatchAutoBrightnessResponder)> {
1710        if let ControlRequest::WatchAutoBrightness { responder } = self {
1711            Some((responder))
1712        } else {
1713            None
1714        }
1715    }
1716
1717    #[allow(irrefutable_let_patterns)]
1718    pub fn into_set_manual_brightness(self) -> Option<(f32, ControlControlHandle)> {
1719        if let ControlRequest::SetManualBrightness { value, control_handle } = self {
1720            Some((value, control_handle))
1721        } else {
1722            None
1723        }
1724    }
1725
1726    #[allow(irrefutable_let_patterns)]
1727    pub fn into_set_manual_brightness_smooth(self) -> Option<(f32, i64, ControlControlHandle)> {
1728        if let ControlRequest::SetManualBrightnessSmooth { value, duration, control_handle } = self
1729        {
1730            Some((value, duration, control_handle))
1731        } else {
1732            None
1733        }
1734    }
1735
1736    #[allow(irrefutable_let_patterns)]
1737    pub fn into_watch_current_brightness(self) -> Option<(ControlWatchCurrentBrightnessResponder)> {
1738        if let ControlRequest::WatchCurrentBrightness { responder } = self {
1739            Some((responder))
1740        } else {
1741            None
1742        }
1743    }
1744
1745    #[allow(irrefutable_let_patterns)]
1746    pub fn into_set_auto_brightness_adjustment(self) -> Option<(f32, ControlControlHandle)> {
1747        if let ControlRequest::SetAutoBrightnessAdjustment { adjustment, control_handle } = self {
1748            Some((adjustment, control_handle))
1749        } else {
1750            None
1751        }
1752    }
1753
1754    #[allow(irrefutable_let_patterns)]
1755    pub fn into_watch_auto_brightness_adjustment(
1756        self,
1757    ) -> Option<(ControlWatchAutoBrightnessAdjustmentResponder)> {
1758        if let ControlRequest::WatchAutoBrightnessAdjustment { responder } = self {
1759            Some((responder))
1760        } else {
1761            None
1762        }
1763    }
1764
1765    #[allow(irrefutable_let_patterns)]
1766    pub fn into_set_brightness_table(self) -> Option<(BrightnessTable, ControlControlHandle)> {
1767        if let ControlRequest::SetBrightnessTable { table, control_handle } = self {
1768            Some((table, control_handle))
1769        } else {
1770            None
1771        }
1772    }
1773
1774    #[allow(irrefutable_let_patterns)]
1775    pub fn into_get_max_absolute_brightness(
1776        self,
1777    ) -> Option<(ControlGetMaxAbsoluteBrightnessResponder)> {
1778        if let ControlRequest::GetMaxAbsoluteBrightness { responder } = self {
1779            Some((responder))
1780        } else {
1781            None
1782        }
1783    }
1784
1785    /// Name of the method defined in FIDL
1786    pub fn method_name(&self) -> &'static str {
1787        match *self {
1788            ControlRequest::SetAutoBrightness { .. } => "set_auto_brightness",
1789            ControlRequest::WatchAutoBrightness { .. } => "watch_auto_brightness",
1790            ControlRequest::SetManualBrightness { .. } => "set_manual_brightness",
1791            ControlRequest::SetManualBrightnessSmooth { .. } => "set_manual_brightness_smooth",
1792            ControlRequest::WatchCurrentBrightness { .. } => "watch_current_brightness",
1793            ControlRequest::SetAutoBrightnessAdjustment { .. } => "set_auto_brightness_adjustment",
1794            ControlRequest::WatchAutoBrightnessAdjustment { .. } => {
1795                "watch_auto_brightness_adjustment"
1796            }
1797            ControlRequest::SetBrightnessTable { .. } => "set_brightness_table",
1798            ControlRequest::GetMaxAbsoluteBrightness { .. } => "get_max_absolute_brightness",
1799        }
1800    }
1801}
1802
1803#[derive(Debug, Clone)]
1804pub struct ControlControlHandle {
1805    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1806}
1807
1808impl fidl::endpoints::ControlHandle for ControlControlHandle {
1809    fn shutdown(&self) {
1810        self.inner.shutdown()
1811    }
1812
1813    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1814        self.inner.shutdown_with_epitaph(status)
1815    }
1816
1817    fn is_closed(&self) -> bool {
1818        self.inner.channel().is_closed()
1819    }
1820    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1821        self.inner.channel().on_closed()
1822    }
1823
1824    #[cfg(target_os = "fuchsia")]
1825    fn signal_peer(
1826        &self,
1827        clear_mask: zx::Signals,
1828        set_mask: zx::Signals,
1829    ) -> Result<(), zx_status::Status> {
1830        use fidl::Peered;
1831        self.inner.channel().signal_peer(clear_mask, set_mask)
1832    }
1833}
1834
1835impl ControlControlHandle {}
1836
1837#[must_use = "FIDL methods require a response to be sent"]
1838#[derive(Debug)]
1839pub struct ControlWatchAutoBrightnessResponder {
1840    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1841    tx_id: u32,
1842}
1843
1844/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1845/// if the responder is dropped without sending a response, so that the client
1846/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1847impl std::ops::Drop for ControlWatchAutoBrightnessResponder {
1848    fn drop(&mut self) {
1849        self.control_handle.shutdown();
1850        // Safety: drops once, never accessed again
1851        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1852    }
1853}
1854
1855impl fidl::endpoints::Responder for ControlWatchAutoBrightnessResponder {
1856    type ControlHandle = ControlControlHandle;
1857
1858    fn control_handle(&self) -> &ControlControlHandle {
1859        &self.control_handle
1860    }
1861
1862    fn drop_without_shutdown(mut self) {
1863        // Safety: drops once, never accessed again due to mem::forget
1864        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1865        // Prevent Drop from running (which would shut down the channel)
1866        std::mem::forget(self);
1867    }
1868}
1869
1870impl ControlWatchAutoBrightnessResponder {
1871    /// Sends a response to the FIDL transaction.
1872    ///
1873    /// Sets the channel to shutdown if an error occurs.
1874    pub fn send(self, mut enabled: bool) -> Result<(), fidl::Error> {
1875        let _result = self.send_raw(enabled);
1876        if _result.is_err() {
1877            self.control_handle.shutdown();
1878        }
1879        self.drop_without_shutdown();
1880        _result
1881    }
1882
1883    /// Similar to "send" but does not shutdown the channel if an error occurs.
1884    pub fn send_no_shutdown_on_err(self, mut enabled: bool) -> Result<(), fidl::Error> {
1885        let _result = self.send_raw(enabled);
1886        self.drop_without_shutdown();
1887        _result
1888    }
1889
1890    fn send_raw(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1891        self.control_handle.inner.send::<ControlWatchAutoBrightnessResponse>(
1892            (enabled,),
1893            self.tx_id,
1894            0xd956a90c115186b,
1895            fidl::encoding::DynamicFlags::empty(),
1896        )
1897    }
1898}
1899
1900#[must_use = "FIDL methods require a response to be sent"]
1901#[derive(Debug)]
1902pub struct ControlWatchCurrentBrightnessResponder {
1903    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1904    tx_id: u32,
1905}
1906
1907/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1908/// if the responder is dropped without sending a response, so that the client
1909/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1910impl std::ops::Drop for ControlWatchCurrentBrightnessResponder {
1911    fn drop(&mut self) {
1912        self.control_handle.shutdown();
1913        // Safety: drops once, never accessed again
1914        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1915    }
1916}
1917
1918impl fidl::endpoints::Responder for ControlWatchCurrentBrightnessResponder {
1919    type ControlHandle = ControlControlHandle;
1920
1921    fn control_handle(&self) -> &ControlControlHandle {
1922        &self.control_handle
1923    }
1924
1925    fn drop_without_shutdown(mut self) {
1926        // Safety: drops once, never accessed again due to mem::forget
1927        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1928        // Prevent Drop from running (which would shut down the channel)
1929        std::mem::forget(self);
1930    }
1931}
1932
1933impl ControlWatchCurrentBrightnessResponder {
1934    /// Sends a response to the FIDL transaction.
1935    ///
1936    /// Sets the channel to shutdown if an error occurs.
1937    pub fn send(self, mut value: f32) -> Result<(), fidl::Error> {
1938        let _result = self.send_raw(value);
1939        if _result.is_err() {
1940            self.control_handle.shutdown();
1941        }
1942        self.drop_without_shutdown();
1943        _result
1944    }
1945
1946    /// Similar to "send" but does not shutdown the channel if an error occurs.
1947    pub fn send_no_shutdown_on_err(self, mut value: f32) -> Result<(), fidl::Error> {
1948        let _result = self.send_raw(value);
1949        self.drop_without_shutdown();
1950        _result
1951    }
1952
1953    fn send_raw(&self, mut value: f32) -> Result<(), fidl::Error> {
1954        self.control_handle.inner.send::<ControlWatchCurrentBrightnessResponse>(
1955            (value,),
1956            self.tx_id,
1957            0x2cc3011e2326d4d8,
1958            fidl::encoding::DynamicFlags::empty(),
1959        )
1960    }
1961}
1962
1963#[must_use = "FIDL methods require a response to be sent"]
1964#[derive(Debug)]
1965pub struct ControlWatchAutoBrightnessAdjustmentResponder {
1966    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1967    tx_id: u32,
1968}
1969
1970/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1971/// if the responder is dropped without sending a response, so that the client
1972/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1973impl std::ops::Drop for ControlWatchAutoBrightnessAdjustmentResponder {
1974    fn drop(&mut self) {
1975        self.control_handle.shutdown();
1976        // Safety: drops once, never accessed again
1977        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1978    }
1979}
1980
1981impl fidl::endpoints::Responder for ControlWatchAutoBrightnessAdjustmentResponder {
1982    type ControlHandle = ControlControlHandle;
1983
1984    fn control_handle(&self) -> &ControlControlHandle {
1985        &self.control_handle
1986    }
1987
1988    fn drop_without_shutdown(mut self) {
1989        // Safety: drops once, never accessed again due to mem::forget
1990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1991        // Prevent Drop from running (which would shut down the channel)
1992        std::mem::forget(self);
1993    }
1994}
1995
1996impl ControlWatchAutoBrightnessAdjustmentResponder {
1997    /// Sends a response to the FIDL transaction.
1998    ///
1999    /// Sets the channel to shutdown if an error occurs.
2000    pub fn send(self, mut adjustment: f32) -> Result<(), fidl::Error> {
2001        let _result = self.send_raw(adjustment);
2002        if _result.is_err() {
2003            self.control_handle.shutdown();
2004        }
2005        self.drop_without_shutdown();
2006        _result
2007    }
2008
2009    /// Similar to "send" but does not shutdown the channel if an error occurs.
2010    pub fn send_no_shutdown_on_err(self, mut adjustment: f32) -> Result<(), fidl::Error> {
2011        let _result = self.send_raw(adjustment);
2012        self.drop_without_shutdown();
2013        _result
2014    }
2015
2016    fn send_raw(&self, mut adjustment: f32) -> Result<(), fidl::Error> {
2017        self.control_handle.inner.send::<ControlWatchAutoBrightnessAdjustmentResponse>(
2018            (adjustment,),
2019            self.tx_id,
2020            0x7c373aafe0058135,
2021            fidl::encoding::DynamicFlags::empty(),
2022        )
2023    }
2024}
2025
2026#[must_use = "FIDL methods require a response to be sent"]
2027#[derive(Debug)]
2028pub struct ControlGetMaxAbsoluteBrightnessResponder {
2029    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2030    tx_id: u32,
2031}
2032
2033/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2034/// if the responder is dropped without sending a response, so that the client
2035/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2036impl std::ops::Drop for ControlGetMaxAbsoluteBrightnessResponder {
2037    fn drop(&mut self) {
2038        self.control_handle.shutdown();
2039        // Safety: drops once, never accessed again
2040        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2041    }
2042}
2043
2044impl fidl::endpoints::Responder for ControlGetMaxAbsoluteBrightnessResponder {
2045    type ControlHandle = ControlControlHandle;
2046
2047    fn control_handle(&self) -> &ControlControlHandle {
2048        &self.control_handle
2049    }
2050
2051    fn drop_without_shutdown(mut self) {
2052        // Safety: drops once, never accessed again due to mem::forget
2053        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2054        // Prevent Drop from running (which would shut down the channel)
2055        std::mem::forget(self);
2056    }
2057}
2058
2059impl ControlGetMaxAbsoluteBrightnessResponder {
2060    /// Sends a response to the FIDL transaction.
2061    ///
2062    /// Sets the channel to shutdown if an error occurs.
2063    pub fn send(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
2064        let _result = self.send_raw(result);
2065        if _result.is_err() {
2066            self.control_handle.shutdown();
2067        }
2068        self.drop_without_shutdown();
2069        _result
2070    }
2071
2072    /// Similar to "send" but does not shutdown the channel if an error occurs.
2073    pub fn send_no_shutdown_on_err(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
2074        let _result = self.send_raw(result);
2075        self.drop_without_shutdown();
2076        _result
2077    }
2078
2079    fn send_raw(&self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
2080        self.control_handle.inner.send::<fidl::encoding::ResultType<
2081            ControlGetMaxAbsoluteBrightnessResponse,
2082            i32,
2083        >>(
2084            result.map(|max_brightness| (max_brightness,)),
2085            self.tx_id,
2086            0x73055a8d6422caf8,
2087            fidl::encoding::DynamicFlags::empty(),
2088        )
2089    }
2090}
2091
2092mod internal {
2093    use super::*;
2094}