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