fidl_fuchsia_settings/
fidl_fuchsia_settings.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_settings_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct AccessibilityMarker;
16
17impl fidl::endpoints::ProtocolMarker for AccessibilityMarker {
18    type Proxy = AccessibilityProxy;
19    type RequestStream = AccessibilityRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = AccessibilitySynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.settings.Accessibility";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for AccessibilityMarker {}
26pub type AccessibilitySetResult = Result<(), Error>;
27
28pub trait AccessibilityProxyInterface: Send + Sync {
29    type WatchResponseFut: std::future::Future<Output = Result<AccessibilitySettings, fidl::Error>>
30        + Send;
31    fn r#watch(&self) -> Self::WatchResponseFut;
32    type SetResponseFut: std::future::Future<Output = Result<AccessibilitySetResult, fidl::Error>>
33        + Send;
34    fn r#set(&self, settings: &AccessibilitySettings) -> Self::SetResponseFut;
35}
36#[derive(Debug)]
37#[cfg(target_os = "fuchsia")]
38pub struct AccessibilitySynchronousProxy {
39    client: fidl::client::sync::Client,
40}
41
42#[cfg(target_os = "fuchsia")]
43impl fidl::endpoints::SynchronousProxy for AccessibilitySynchronousProxy {
44    type Proxy = AccessibilityProxy;
45    type Protocol = AccessibilityMarker;
46
47    fn from_channel(inner: fidl::Channel) -> Self {
48        Self::new(inner)
49    }
50
51    fn into_channel(self) -> fidl::Channel {
52        self.client.into_channel()
53    }
54
55    fn as_channel(&self) -> &fidl::Channel {
56        self.client.as_channel()
57    }
58}
59
60#[cfg(target_os = "fuchsia")]
61impl AccessibilitySynchronousProxy {
62    pub fn new(channel: fidl::Channel) -> Self {
63        let protocol_name = <AccessibilityMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
64        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
65    }
66
67    pub fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    /// Waits until an event arrives and returns it. It is safe for other
72    /// threads to make concurrent requests while waiting for an event.
73    pub fn wait_for_event(
74        &self,
75        deadline: zx::MonotonicInstant,
76    ) -> Result<AccessibilityEvent, fidl::Error> {
77        AccessibilityEvent::decode(self.client.wait_for_event(deadline)?)
78    }
79
80    /// Gets the current value of all accessibility settings. Returns
81    /// immediately on first call; subsequent calls return when any of the
82    /// values change.
83    ///
84    /// - `settings` all current values of the accessibility settings.
85    /// * see [`AccessibilitySettings`] for their meaning.
86    ///
87    /// If this call fails, it is considered a fatal error and the channel
88    /// will be closed.
89    pub fn r#watch(
90        &self,
91        ___deadline: zx::MonotonicInstant,
92    ) -> Result<AccessibilitySettings, fidl::Error> {
93        let _response =
94            self.client.send_query::<fidl::encoding::EmptyPayload, AccessibilityWatchResponse>(
95                (),
96                0x417d0b95ddbf7674,
97                fidl::encoding::DynamicFlags::empty(),
98                ___deadline,
99            )?;
100        Ok(_response.settings)
101    }
102
103    /// Sets [AccessibilitySettings] settings. Any field not explicitly set in the table performs a
104    /// no-op, and will not make any changes.
105    pub fn r#set(
106        &self,
107        mut settings: &AccessibilitySettings,
108        ___deadline: zx::MonotonicInstant,
109    ) -> Result<AccessibilitySetResult, fidl::Error> {
110        let _response = self.client.send_query::<
111            AccessibilitySetRequest,
112            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
113        >(
114            (settings,),
115            0x298485ef354fb8cb,
116            fidl::encoding::DynamicFlags::empty(),
117            ___deadline,
118        )?;
119        Ok(_response.map(|x| x))
120    }
121}
122
123#[derive(Debug, Clone)]
124pub struct AccessibilityProxy {
125    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
126}
127
128impl fidl::endpoints::Proxy for AccessibilityProxy {
129    type Protocol = AccessibilityMarker;
130
131    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
132        Self::new(inner)
133    }
134
135    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
136        self.client.into_channel().map_err(|client| Self { client })
137    }
138
139    fn as_channel(&self) -> &::fidl::AsyncChannel {
140        self.client.as_channel()
141    }
142}
143
144impl AccessibilityProxy {
145    /// Create a new Proxy for fuchsia.settings/Accessibility.
146    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
147        let protocol_name = <AccessibilityMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
148        Self { client: fidl::client::Client::new(channel, protocol_name) }
149    }
150
151    /// Get a Stream of events from the remote end of the protocol.
152    ///
153    /// # Panics
154    ///
155    /// Panics if the event stream was already taken.
156    pub fn take_event_stream(&self) -> AccessibilityEventStream {
157        AccessibilityEventStream { event_receiver: self.client.take_event_receiver() }
158    }
159
160    /// Gets the current value of all accessibility settings. Returns
161    /// immediately on first call; subsequent calls return when any of the
162    /// values change.
163    ///
164    /// - `settings` all current values of the accessibility settings.
165    /// * see [`AccessibilitySettings`] for their meaning.
166    ///
167    /// If this call fails, it is considered a fatal error and the channel
168    /// will be closed.
169    pub fn r#watch(
170        &self,
171    ) -> fidl::client::QueryResponseFut<
172        AccessibilitySettings,
173        fidl::encoding::DefaultFuchsiaResourceDialect,
174    > {
175        AccessibilityProxyInterface::r#watch(self)
176    }
177
178    /// Sets [AccessibilitySettings] settings. Any field not explicitly set in the table performs a
179    /// no-op, and will not make any changes.
180    pub fn r#set(
181        &self,
182        mut settings: &AccessibilitySettings,
183    ) -> fidl::client::QueryResponseFut<
184        AccessibilitySetResult,
185        fidl::encoding::DefaultFuchsiaResourceDialect,
186    > {
187        AccessibilityProxyInterface::r#set(self, settings)
188    }
189}
190
191impl AccessibilityProxyInterface for AccessibilityProxy {
192    type WatchResponseFut = fidl::client::QueryResponseFut<
193        AccessibilitySettings,
194        fidl::encoding::DefaultFuchsiaResourceDialect,
195    >;
196    fn r#watch(&self) -> Self::WatchResponseFut {
197        fn _decode(
198            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
199        ) -> Result<AccessibilitySettings, fidl::Error> {
200            let _response = fidl::client::decode_transaction_body::<
201                AccessibilityWatchResponse,
202                fidl::encoding::DefaultFuchsiaResourceDialect,
203                0x417d0b95ddbf7674,
204            >(_buf?)?;
205            Ok(_response.settings)
206        }
207        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AccessibilitySettings>(
208            (),
209            0x417d0b95ddbf7674,
210            fidl::encoding::DynamicFlags::empty(),
211            _decode,
212        )
213    }
214
215    type SetResponseFut = fidl::client::QueryResponseFut<
216        AccessibilitySetResult,
217        fidl::encoding::DefaultFuchsiaResourceDialect,
218    >;
219    fn r#set(&self, mut settings: &AccessibilitySettings) -> Self::SetResponseFut {
220        fn _decode(
221            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
222        ) -> Result<AccessibilitySetResult, fidl::Error> {
223            let _response = fidl::client::decode_transaction_body::<
224                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
225                fidl::encoding::DefaultFuchsiaResourceDialect,
226                0x298485ef354fb8cb,
227            >(_buf?)?;
228            Ok(_response.map(|x| x))
229        }
230        self.client.send_query_and_decode::<AccessibilitySetRequest, AccessibilitySetResult>(
231            (settings,),
232            0x298485ef354fb8cb,
233            fidl::encoding::DynamicFlags::empty(),
234            _decode,
235        )
236    }
237}
238
239pub struct AccessibilityEventStream {
240    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
241}
242
243impl std::marker::Unpin for AccessibilityEventStream {}
244
245impl futures::stream::FusedStream for AccessibilityEventStream {
246    fn is_terminated(&self) -> bool {
247        self.event_receiver.is_terminated()
248    }
249}
250
251impl futures::Stream for AccessibilityEventStream {
252    type Item = Result<AccessibilityEvent, fidl::Error>;
253
254    fn poll_next(
255        mut self: std::pin::Pin<&mut Self>,
256        cx: &mut std::task::Context<'_>,
257    ) -> std::task::Poll<Option<Self::Item>> {
258        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
259            &mut self.event_receiver,
260            cx
261        )?) {
262            Some(buf) => std::task::Poll::Ready(Some(AccessibilityEvent::decode(buf))),
263            None => std::task::Poll::Ready(None),
264        }
265    }
266}
267
268#[derive(Debug)]
269pub enum AccessibilityEvent {}
270
271impl AccessibilityEvent {
272    /// Decodes a message buffer as a [`AccessibilityEvent`].
273    fn decode(
274        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
275    ) -> Result<AccessibilityEvent, fidl::Error> {
276        let (bytes, _handles) = buf.split_mut();
277        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
278        debug_assert_eq!(tx_header.tx_id, 0);
279        match tx_header.ordinal {
280            _ => Err(fidl::Error::UnknownOrdinal {
281                ordinal: tx_header.ordinal,
282                protocol_name: <AccessibilityMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
283            }),
284        }
285    }
286}
287
288/// A Stream of incoming requests for fuchsia.settings/Accessibility.
289pub struct AccessibilityRequestStream {
290    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
291    is_terminated: bool,
292}
293
294impl std::marker::Unpin for AccessibilityRequestStream {}
295
296impl futures::stream::FusedStream for AccessibilityRequestStream {
297    fn is_terminated(&self) -> bool {
298        self.is_terminated
299    }
300}
301
302impl fidl::endpoints::RequestStream for AccessibilityRequestStream {
303    type Protocol = AccessibilityMarker;
304    type ControlHandle = AccessibilityControlHandle;
305
306    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
307        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
308    }
309
310    fn control_handle(&self) -> Self::ControlHandle {
311        AccessibilityControlHandle { inner: self.inner.clone() }
312    }
313
314    fn into_inner(
315        self,
316    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
317    {
318        (self.inner, self.is_terminated)
319    }
320
321    fn from_inner(
322        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
323        is_terminated: bool,
324    ) -> Self {
325        Self { inner, is_terminated }
326    }
327}
328
329impl futures::Stream for AccessibilityRequestStream {
330    type Item = Result<AccessibilityRequest, fidl::Error>;
331
332    fn poll_next(
333        mut self: std::pin::Pin<&mut Self>,
334        cx: &mut std::task::Context<'_>,
335    ) -> std::task::Poll<Option<Self::Item>> {
336        let this = &mut *self;
337        if this.inner.check_shutdown(cx) {
338            this.is_terminated = true;
339            return std::task::Poll::Ready(None);
340        }
341        if this.is_terminated {
342            panic!("polled AccessibilityRequestStream after completion");
343        }
344        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
345            |bytes, handles| {
346                match this.inner.channel().read_etc(cx, bytes, handles) {
347                    std::task::Poll::Ready(Ok(())) => {}
348                    std::task::Poll::Pending => return std::task::Poll::Pending,
349                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
350                        this.is_terminated = true;
351                        return std::task::Poll::Ready(None);
352                    }
353                    std::task::Poll::Ready(Err(e)) => {
354                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
355                            e.into(),
356                        ))))
357                    }
358                }
359
360                // A message has been received from the channel
361                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
362
363                std::task::Poll::Ready(Some(match header.ordinal {
364                    0x417d0b95ddbf7674 => {
365                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
366                        let mut req = fidl::new_empty!(
367                            fidl::encoding::EmptyPayload,
368                            fidl::encoding::DefaultFuchsiaResourceDialect
369                        );
370                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
371                        let control_handle =
372                            AccessibilityControlHandle { inner: this.inner.clone() };
373                        Ok(AccessibilityRequest::Watch {
374                            responder: AccessibilityWatchResponder {
375                                control_handle: std::mem::ManuallyDrop::new(control_handle),
376                                tx_id: header.tx_id,
377                            },
378                        })
379                    }
380                    0x298485ef354fb8cb => {
381                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
382                        let mut req = fidl::new_empty!(
383                            AccessibilitySetRequest,
384                            fidl::encoding::DefaultFuchsiaResourceDialect
385                        );
386                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessibilitySetRequest>(&header, _body_bytes, handles, &mut req)?;
387                        let control_handle =
388                            AccessibilityControlHandle { inner: this.inner.clone() };
389                        Ok(AccessibilityRequest::Set {
390                            settings: req.settings,
391
392                            responder: AccessibilitySetResponder {
393                                control_handle: std::mem::ManuallyDrop::new(control_handle),
394                                tx_id: header.tx_id,
395                            },
396                        })
397                    }
398                    _ => Err(fidl::Error::UnknownOrdinal {
399                        ordinal: header.ordinal,
400                        protocol_name:
401                            <AccessibilityMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
402                    }),
403                }))
404            },
405        )
406    }
407}
408
409/// Modify or watch accessibility settings that are persisted.
410///
411/// Supported SettingsEpitaph enums:
412/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR
413#[derive(Debug)]
414pub enum AccessibilityRequest {
415    /// Gets the current value of all accessibility settings. Returns
416    /// immediately on first call; subsequent calls return when any of the
417    /// values change.
418    ///
419    /// - `settings` all current values of the accessibility settings.
420    /// * see [`AccessibilitySettings`] for their meaning.
421    ///
422    /// If this call fails, it is considered a fatal error and the channel
423    /// will be closed.
424    Watch { responder: AccessibilityWatchResponder },
425    /// Sets [AccessibilitySettings] settings. Any field not explicitly set in the table performs a
426    /// no-op, and will not make any changes.
427    Set { settings: AccessibilitySettings, responder: AccessibilitySetResponder },
428}
429
430impl AccessibilityRequest {
431    #[allow(irrefutable_let_patterns)]
432    pub fn into_watch(self) -> Option<(AccessibilityWatchResponder)> {
433        if let AccessibilityRequest::Watch { responder } = self {
434            Some((responder))
435        } else {
436            None
437        }
438    }
439
440    #[allow(irrefutable_let_patterns)]
441    pub fn into_set(self) -> Option<(AccessibilitySettings, AccessibilitySetResponder)> {
442        if let AccessibilityRequest::Set { settings, responder } = self {
443            Some((settings, responder))
444        } else {
445            None
446        }
447    }
448
449    /// Name of the method defined in FIDL
450    pub fn method_name(&self) -> &'static str {
451        match *self {
452            AccessibilityRequest::Watch { .. } => "watch",
453            AccessibilityRequest::Set { .. } => "set",
454        }
455    }
456}
457
458#[derive(Debug, Clone)]
459pub struct AccessibilityControlHandle {
460    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
461}
462
463impl fidl::endpoints::ControlHandle for AccessibilityControlHandle {
464    fn shutdown(&self) {
465        self.inner.shutdown()
466    }
467    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
468        self.inner.shutdown_with_epitaph(status)
469    }
470
471    fn is_closed(&self) -> bool {
472        self.inner.channel().is_closed()
473    }
474    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
475        self.inner.channel().on_closed()
476    }
477
478    #[cfg(target_os = "fuchsia")]
479    fn signal_peer(
480        &self,
481        clear_mask: zx::Signals,
482        set_mask: zx::Signals,
483    ) -> Result<(), zx_status::Status> {
484        use fidl::Peered;
485        self.inner.channel().signal_peer(clear_mask, set_mask)
486    }
487}
488
489impl AccessibilityControlHandle {}
490
491#[must_use = "FIDL methods require a response to be sent"]
492#[derive(Debug)]
493pub struct AccessibilityWatchResponder {
494    control_handle: std::mem::ManuallyDrop<AccessibilityControlHandle>,
495    tx_id: u32,
496}
497
498/// Set the the channel to be shutdown (see [`AccessibilityControlHandle::shutdown`])
499/// if the responder is dropped without sending a response, so that the client
500/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
501impl std::ops::Drop for AccessibilityWatchResponder {
502    fn drop(&mut self) {
503        self.control_handle.shutdown();
504        // Safety: drops once, never accessed again
505        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
506    }
507}
508
509impl fidl::endpoints::Responder for AccessibilityWatchResponder {
510    type ControlHandle = AccessibilityControlHandle;
511
512    fn control_handle(&self) -> &AccessibilityControlHandle {
513        &self.control_handle
514    }
515
516    fn drop_without_shutdown(mut self) {
517        // Safety: drops once, never accessed again due to mem::forget
518        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
519        // Prevent Drop from running (which would shut down the channel)
520        std::mem::forget(self);
521    }
522}
523
524impl AccessibilityWatchResponder {
525    /// Sends a response to the FIDL transaction.
526    ///
527    /// Sets the channel to shutdown if an error occurs.
528    pub fn send(self, mut settings: &AccessibilitySettings) -> Result<(), fidl::Error> {
529        let _result = self.send_raw(settings);
530        if _result.is_err() {
531            self.control_handle.shutdown();
532        }
533        self.drop_without_shutdown();
534        _result
535    }
536
537    /// Similar to "send" but does not shutdown the channel if an error occurs.
538    pub fn send_no_shutdown_on_err(
539        self,
540        mut settings: &AccessibilitySettings,
541    ) -> Result<(), fidl::Error> {
542        let _result = self.send_raw(settings);
543        self.drop_without_shutdown();
544        _result
545    }
546
547    fn send_raw(&self, mut settings: &AccessibilitySettings) -> Result<(), fidl::Error> {
548        self.control_handle.inner.send::<AccessibilityWatchResponse>(
549            (settings,),
550            self.tx_id,
551            0x417d0b95ddbf7674,
552            fidl::encoding::DynamicFlags::empty(),
553        )
554    }
555}
556
557#[must_use = "FIDL methods require a response to be sent"]
558#[derive(Debug)]
559pub struct AccessibilitySetResponder {
560    control_handle: std::mem::ManuallyDrop<AccessibilityControlHandle>,
561    tx_id: u32,
562}
563
564/// Set the the channel to be shutdown (see [`AccessibilityControlHandle::shutdown`])
565/// if the responder is dropped without sending a response, so that the client
566/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
567impl std::ops::Drop for AccessibilitySetResponder {
568    fn drop(&mut self) {
569        self.control_handle.shutdown();
570        // Safety: drops once, never accessed again
571        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
572    }
573}
574
575impl fidl::endpoints::Responder for AccessibilitySetResponder {
576    type ControlHandle = AccessibilityControlHandle;
577
578    fn control_handle(&self) -> &AccessibilityControlHandle {
579        &self.control_handle
580    }
581
582    fn drop_without_shutdown(mut self) {
583        // Safety: drops once, never accessed again due to mem::forget
584        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
585        // Prevent Drop from running (which would shut down the channel)
586        std::mem::forget(self);
587    }
588}
589
590impl AccessibilitySetResponder {
591    /// Sends a response to the FIDL transaction.
592    ///
593    /// Sets the channel to shutdown if an error occurs.
594    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
595        let _result = self.send_raw(result);
596        if _result.is_err() {
597            self.control_handle.shutdown();
598        }
599        self.drop_without_shutdown();
600        _result
601    }
602
603    /// Similar to "send" but does not shutdown the channel if an error occurs.
604    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
605        let _result = self.send_raw(result);
606        self.drop_without_shutdown();
607        _result
608    }
609
610    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
611        self.control_handle
612            .inner
613            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
614                result,
615                self.tx_id,
616                0x298485ef354fb8cb,
617                fidl::encoding::DynamicFlags::empty(),
618            )
619    }
620}
621
622#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
623pub struct AudioMarker;
624
625impl fidl::endpoints::ProtocolMarker for AudioMarker {
626    type Proxy = AudioProxy;
627    type RequestStream = AudioRequestStream;
628    #[cfg(target_os = "fuchsia")]
629    type SynchronousProxy = AudioSynchronousProxy;
630
631    const DEBUG_NAME: &'static str = "fuchsia.settings.Audio";
632}
633impl fidl::endpoints::DiscoverableProtocolMarker for AudioMarker {}
634pub type AudioSetResult = Result<(), Error>;
635pub type AudioSet2Result = Result<(), Error>;
636
637pub trait AudioProxyInterface: Send + Sync {
638    type WatchResponseFut: std::future::Future<Output = Result<AudioSettings, fidl::Error>> + Send;
639    fn r#watch(&self) -> Self::WatchResponseFut;
640    type Watch2ResponseFut: std::future::Future<Output = Result<AudioSettings2, fidl::Error>> + Send;
641    fn r#watch2(&self) -> Self::Watch2ResponseFut;
642    type SetResponseFut: std::future::Future<Output = Result<AudioSetResult, fidl::Error>> + Send;
643    fn r#set(&self, settings: &AudioSettings) -> Self::SetResponseFut;
644    type Set2ResponseFut: std::future::Future<Output = Result<AudioSet2Result, fidl::Error>> + Send;
645    fn r#set2(&self, settings: &AudioSettings2) -> Self::Set2ResponseFut;
646}
647#[derive(Debug)]
648#[cfg(target_os = "fuchsia")]
649pub struct AudioSynchronousProxy {
650    client: fidl::client::sync::Client,
651}
652
653#[cfg(target_os = "fuchsia")]
654impl fidl::endpoints::SynchronousProxy for AudioSynchronousProxy {
655    type Proxy = AudioProxy;
656    type Protocol = AudioMarker;
657
658    fn from_channel(inner: fidl::Channel) -> Self {
659        Self::new(inner)
660    }
661
662    fn into_channel(self) -> fidl::Channel {
663        self.client.into_channel()
664    }
665
666    fn as_channel(&self) -> &fidl::Channel {
667        self.client.as_channel()
668    }
669}
670
671#[cfg(target_os = "fuchsia")]
672impl AudioSynchronousProxy {
673    pub fn new(channel: fidl::Channel) -> Self {
674        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
675        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
676    }
677
678    pub fn into_channel(self) -> fidl::Channel {
679        self.client.into_channel()
680    }
681
682    /// Waits until an event arrives and returns it. It is safe for other
683    /// threads to make concurrent requests while waiting for an event.
684    pub fn wait_for_event(
685        &self,
686        deadline: zx::MonotonicInstant,
687    ) -> Result<AudioEvent, fidl::Error> {
688        AudioEvent::decode(self.client.wait_for_event(deadline)?)
689    }
690
691    /// Gets the current [AudioSettings]. Returns immediately on first call;
692    /// subsequent calls return when the value changes.
693    ///
694    /// If this call fails, it is considered a fatal error and the channel
695    /// will be closed.
696    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<AudioSettings, fidl::Error> {
697        let _response =
698            self.client.send_query::<fidl::encoding::EmptyPayload, AudioWatchResponse>(
699                (),
700                0x2995cf83f9d0f805,
701                fidl::encoding::DynamicFlags::empty(),
702                ___deadline,
703            )?;
704        Ok(_response.settings)
705    }
706
707    /// Gets the current [AudioSettings2]. Returns immediately on first call;
708    /// subsequent calls return when the value changes.
709    ///
710    /// If this call fails, it is considered a fatal error and the channel will be closed.
711    pub fn r#watch2(
712        &self,
713        ___deadline: zx::MonotonicInstant,
714    ) -> Result<AudioSettings2, fidl::Error> {
715        let _response = self.client.send_query::<
716            fidl::encoding::EmptyPayload,
717            fidl::encoding::FlexibleType<AudioWatch2Response>,
718        >(
719            (),
720            0x4d10b204de1796e2,
721            fidl::encoding::DynamicFlags::FLEXIBLE,
722            ___deadline,
723        )?
724        .into_result::<AudioMarker>("watch2")?;
725        Ok(_response.settings)
726    }
727
728    /// Sets audio settings. Any field not explicitly set in the table performs a
729    /// no-op, and will not make any changes.
730    pub fn r#set(
731        &self,
732        mut settings: &AudioSettings,
733        ___deadline: zx::MonotonicInstant,
734    ) -> Result<AudioSetResult, fidl::Error> {
735        let _response = self.client.send_query::<AudioSetRequest, fidl::encoding::ResultType<
736            fidl::encoding::EmptyStruct,
737            Error,
738        >>(
739            (settings,),
740            0x4f3865db04da626c,
741            fidl::encoding::DynamicFlags::empty(),
742            ___deadline,
743        )?;
744        Ok(_response.map(|x| x))
745    }
746
747    /// Sets audio settings. Only table fields that are set will lead to any changes; otherwise
748    /// existing settings are unchanged.
749    pub fn r#set2(
750        &self,
751        mut settings: &AudioSettings2,
752        ___deadline: zx::MonotonicInstant,
753    ) -> Result<AudioSet2Result, fidl::Error> {
754        let _response = self.client.send_query::<
755            AudioSet2Request,
756            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
757        >(
758            (settings,),
759            0x1f027e9ed7beefe3,
760            fidl::encoding::DynamicFlags::FLEXIBLE,
761            ___deadline,
762        )?
763        .into_result::<AudioMarker>("set2")?;
764        Ok(_response.map(|x| x))
765    }
766}
767
768#[derive(Debug, Clone)]
769pub struct AudioProxy {
770    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
771}
772
773impl fidl::endpoints::Proxy for AudioProxy {
774    type Protocol = AudioMarker;
775
776    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
777        Self::new(inner)
778    }
779
780    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
781        self.client.into_channel().map_err(|client| Self { client })
782    }
783
784    fn as_channel(&self) -> &::fidl::AsyncChannel {
785        self.client.as_channel()
786    }
787}
788
789impl AudioProxy {
790    /// Create a new Proxy for fuchsia.settings/Audio.
791    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
792        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
793        Self { client: fidl::client::Client::new(channel, protocol_name) }
794    }
795
796    /// Get a Stream of events from the remote end of the protocol.
797    ///
798    /// # Panics
799    ///
800    /// Panics if the event stream was already taken.
801    pub fn take_event_stream(&self) -> AudioEventStream {
802        AudioEventStream { event_receiver: self.client.take_event_receiver() }
803    }
804
805    /// Gets the current [AudioSettings]. Returns immediately on first call;
806    /// subsequent calls return when the value changes.
807    ///
808    /// If this call fails, it is considered a fatal error and the channel
809    /// will be closed.
810    pub fn r#watch(
811        &self,
812    ) -> fidl::client::QueryResponseFut<AudioSettings, fidl::encoding::DefaultFuchsiaResourceDialect>
813    {
814        AudioProxyInterface::r#watch(self)
815    }
816
817    /// Gets the current [AudioSettings2]. Returns immediately on first call;
818    /// subsequent calls return when the value changes.
819    ///
820    /// If this call fails, it is considered a fatal error and the channel will be closed.
821    pub fn r#watch2(
822        &self,
823    ) -> fidl::client::QueryResponseFut<AudioSettings2, fidl::encoding::DefaultFuchsiaResourceDialect>
824    {
825        AudioProxyInterface::r#watch2(self)
826    }
827
828    /// Sets audio settings. Any field not explicitly set in the table performs a
829    /// no-op, and will not make any changes.
830    pub fn r#set(
831        &self,
832        mut settings: &AudioSettings,
833    ) -> fidl::client::QueryResponseFut<AudioSetResult, fidl::encoding::DefaultFuchsiaResourceDialect>
834    {
835        AudioProxyInterface::r#set(self, settings)
836    }
837
838    /// Sets audio settings. Only table fields that are set will lead to any changes; otherwise
839    /// existing settings are unchanged.
840    pub fn r#set2(
841        &self,
842        mut settings: &AudioSettings2,
843    ) -> fidl::client::QueryResponseFut<
844        AudioSet2Result,
845        fidl::encoding::DefaultFuchsiaResourceDialect,
846    > {
847        AudioProxyInterface::r#set2(self, settings)
848    }
849}
850
851impl AudioProxyInterface for AudioProxy {
852    type WatchResponseFut = fidl::client::QueryResponseFut<
853        AudioSettings,
854        fidl::encoding::DefaultFuchsiaResourceDialect,
855    >;
856    fn r#watch(&self) -> Self::WatchResponseFut {
857        fn _decode(
858            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
859        ) -> Result<AudioSettings, fidl::Error> {
860            let _response = fidl::client::decode_transaction_body::<
861                AudioWatchResponse,
862                fidl::encoding::DefaultFuchsiaResourceDialect,
863                0x2995cf83f9d0f805,
864            >(_buf?)?;
865            Ok(_response.settings)
866        }
867        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioSettings>(
868            (),
869            0x2995cf83f9d0f805,
870            fidl::encoding::DynamicFlags::empty(),
871            _decode,
872        )
873    }
874
875    type Watch2ResponseFut = fidl::client::QueryResponseFut<
876        AudioSettings2,
877        fidl::encoding::DefaultFuchsiaResourceDialect,
878    >;
879    fn r#watch2(&self) -> Self::Watch2ResponseFut {
880        fn _decode(
881            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
882        ) -> Result<AudioSettings2, fidl::Error> {
883            let _response = fidl::client::decode_transaction_body::<
884                fidl::encoding::FlexibleType<AudioWatch2Response>,
885                fidl::encoding::DefaultFuchsiaResourceDialect,
886                0x4d10b204de1796e2,
887            >(_buf?)?
888            .into_result::<AudioMarker>("watch2")?;
889            Ok(_response.settings)
890        }
891        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioSettings2>(
892            (),
893            0x4d10b204de1796e2,
894            fidl::encoding::DynamicFlags::FLEXIBLE,
895            _decode,
896        )
897    }
898
899    type SetResponseFut = fidl::client::QueryResponseFut<
900        AudioSetResult,
901        fidl::encoding::DefaultFuchsiaResourceDialect,
902    >;
903    fn r#set(&self, mut settings: &AudioSettings) -> Self::SetResponseFut {
904        fn _decode(
905            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
906        ) -> Result<AudioSetResult, fidl::Error> {
907            let _response = fidl::client::decode_transaction_body::<
908                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
909                fidl::encoding::DefaultFuchsiaResourceDialect,
910                0x4f3865db04da626c,
911            >(_buf?)?;
912            Ok(_response.map(|x| x))
913        }
914        self.client.send_query_and_decode::<AudioSetRequest, AudioSetResult>(
915            (settings,),
916            0x4f3865db04da626c,
917            fidl::encoding::DynamicFlags::empty(),
918            _decode,
919        )
920    }
921
922    type Set2ResponseFut = fidl::client::QueryResponseFut<
923        AudioSet2Result,
924        fidl::encoding::DefaultFuchsiaResourceDialect,
925    >;
926    fn r#set2(&self, mut settings: &AudioSettings2) -> Self::Set2ResponseFut {
927        fn _decode(
928            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
929        ) -> Result<AudioSet2Result, fidl::Error> {
930            let _response = fidl::client::decode_transaction_body::<
931                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
932                fidl::encoding::DefaultFuchsiaResourceDialect,
933                0x1f027e9ed7beefe3,
934            >(_buf?)?
935            .into_result::<AudioMarker>("set2")?;
936            Ok(_response.map(|x| x))
937        }
938        self.client.send_query_and_decode::<AudioSet2Request, AudioSet2Result>(
939            (settings,),
940            0x1f027e9ed7beefe3,
941            fidl::encoding::DynamicFlags::FLEXIBLE,
942            _decode,
943        )
944    }
945}
946
947pub struct AudioEventStream {
948    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
949}
950
951impl std::marker::Unpin for AudioEventStream {}
952
953impl futures::stream::FusedStream for AudioEventStream {
954    fn is_terminated(&self) -> bool {
955        self.event_receiver.is_terminated()
956    }
957}
958
959impl futures::Stream for AudioEventStream {
960    type Item = Result<AudioEvent, fidl::Error>;
961
962    fn poll_next(
963        mut self: std::pin::Pin<&mut Self>,
964        cx: &mut std::task::Context<'_>,
965    ) -> std::task::Poll<Option<Self::Item>> {
966        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
967            &mut self.event_receiver,
968            cx
969        )?) {
970            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
971            None => std::task::Poll::Ready(None),
972        }
973    }
974}
975
976#[derive(Debug)]
977pub enum AudioEvent {
978    #[non_exhaustive]
979    _UnknownEvent {
980        /// Ordinal of the event that was sent.
981        ordinal: u64,
982    },
983}
984
985impl AudioEvent {
986    /// Decodes a message buffer as a [`AudioEvent`].
987    fn decode(
988        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
989    ) -> Result<AudioEvent, fidl::Error> {
990        let (bytes, _handles) = buf.split_mut();
991        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
992        debug_assert_eq!(tx_header.tx_id, 0);
993        match tx_header.ordinal {
994            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
995                Ok(AudioEvent::_UnknownEvent { ordinal: tx_header.ordinal })
996            }
997            _ => Err(fidl::Error::UnknownOrdinal {
998                ordinal: tx_header.ordinal,
999                protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1000            }),
1001        }
1002    }
1003}
1004
1005/// A Stream of incoming requests for fuchsia.settings/Audio.
1006pub struct AudioRequestStream {
1007    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1008    is_terminated: bool,
1009}
1010
1011impl std::marker::Unpin for AudioRequestStream {}
1012
1013impl futures::stream::FusedStream for AudioRequestStream {
1014    fn is_terminated(&self) -> bool {
1015        self.is_terminated
1016    }
1017}
1018
1019impl fidl::endpoints::RequestStream for AudioRequestStream {
1020    type Protocol = AudioMarker;
1021    type ControlHandle = AudioControlHandle;
1022
1023    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1024        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1025    }
1026
1027    fn control_handle(&self) -> Self::ControlHandle {
1028        AudioControlHandle { inner: self.inner.clone() }
1029    }
1030
1031    fn into_inner(
1032        self,
1033    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1034    {
1035        (self.inner, self.is_terminated)
1036    }
1037
1038    fn from_inner(
1039        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1040        is_terminated: bool,
1041    ) -> Self {
1042        Self { inner, is_terminated }
1043    }
1044}
1045
1046impl futures::Stream for AudioRequestStream {
1047    type Item = Result<AudioRequest, fidl::Error>;
1048
1049    fn poll_next(
1050        mut self: std::pin::Pin<&mut Self>,
1051        cx: &mut std::task::Context<'_>,
1052    ) -> std::task::Poll<Option<Self::Item>> {
1053        let this = &mut *self;
1054        if this.inner.check_shutdown(cx) {
1055            this.is_terminated = true;
1056            return std::task::Poll::Ready(None);
1057        }
1058        if this.is_terminated {
1059            panic!("polled AudioRequestStream after completion");
1060        }
1061        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1062            |bytes, handles| {
1063                match this.inner.channel().read_etc(cx, bytes, handles) {
1064                    std::task::Poll::Ready(Ok(())) => {}
1065                    std::task::Poll::Pending => return std::task::Poll::Pending,
1066                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1067                        this.is_terminated = true;
1068                        return std::task::Poll::Ready(None);
1069                    }
1070                    std::task::Poll::Ready(Err(e)) => {
1071                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1072                            e.into(),
1073                        ))))
1074                    }
1075                }
1076
1077                // A message has been received from the channel
1078                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1079
1080                std::task::Poll::Ready(Some(match header.ordinal {
1081                    0x2995cf83f9d0f805 => {
1082                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1083                        let mut req = fidl::new_empty!(
1084                            fidl::encoding::EmptyPayload,
1085                            fidl::encoding::DefaultFuchsiaResourceDialect
1086                        );
1087                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1088                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1089                        Ok(AudioRequest::Watch {
1090                            responder: AudioWatchResponder {
1091                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1092                                tx_id: header.tx_id,
1093                            },
1094                        })
1095                    }
1096                    0x4d10b204de1796e2 => {
1097                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1098                        let mut req = fidl::new_empty!(
1099                            fidl::encoding::EmptyPayload,
1100                            fidl::encoding::DefaultFuchsiaResourceDialect
1101                        );
1102                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1103                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1104                        Ok(AudioRequest::Watch2 {
1105                            responder: AudioWatch2Responder {
1106                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1107                                tx_id: header.tx_id,
1108                            },
1109                        })
1110                    }
1111                    0x4f3865db04da626c => {
1112                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1113                        let mut req = fidl::new_empty!(
1114                            AudioSetRequest,
1115                            fidl::encoding::DefaultFuchsiaResourceDialect
1116                        );
1117                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioSetRequest>(&header, _body_bytes, handles, &mut req)?;
1118                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1119                        Ok(AudioRequest::Set {
1120                            settings: req.settings,
1121
1122                            responder: AudioSetResponder {
1123                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1124                                tx_id: header.tx_id,
1125                            },
1126                        })
1127                    }
1128                    0x1f027e9ed7beefe3 => {
1129                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1130                        let mut req = fidl::new_empty!(
1131                            AudioSet2Request,
1132                            fidl::encoding::DefaultFuchsiaResourceDialect
1133                        );
1134                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioSet2Request>(&header, _body_bytes, handles, &mut req)?;
1135                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1136                        Ok(AudioRequest::Set2 {
1137                            settings: req.settings,
1138
1139                            responder: AudioSet2Responder {
1140                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1141                                tx_id: header.tx_id,
1142                            },
1143                        })
1144                    }
1145                    _ if header.tx_id == 0
1146                        && header
1147                            .dynamic_flags()
1148                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1149                    {
1150                        Ok(AudioRequest::_UnknownMethod {
1151                            ordinal: header.ordinal,
1152                            control_handle: AudioControlHandle { inner: this.inner.clone() },
1153                            method_type: fidl::MethodType::OneWay,
1154                        })
1155                    }
1156                    _ if header
1157                        .dynamic_flags()
1158                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1159                    {
1160                        this.inner.send_framework_err(
1161                            fidl::encoding::FrameworkErr::UnknownMethod,
1162                            header.tx_id,
1163                            header.ordinal,
1164                            header.dynamic_flags(),
1165                            (bytes, handles),
1166                        )?;
1167                        Ok(AudioRequest::_UnknownMethod {
1168                            ordinal: header.ordinal,
1169                            control_handle: AudioControlHandle { inner: this.inner.clone() },
1170                            method_type: fidl::MethodType::TwoWay,
1171                        })
1172                    }
1173                    _ => Err(fidl::Error::UnknownOrdinal {
1174                        ordinal: header.ordinal,
1175                        protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1176                    }),
1177                }))
1178            },
1179        )
1180    }
1181}
1182
1183/// Settings related to audio.
1184///
1185/// Supported SettingsEpitaph enums:
1186/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR
1187#[derive(Debug)]
1188pub enum AudioRequest {
1189    /// Gets the current [AudioSettings]. Returns immediately on first call;
1190    /// subsequent calls return when the value changes.
1191    ///
1192    /// If this call fails, it is considered a fatal error and the channel
1193    /// will be closed.
1194    Watch { responder: AudioWatchResponder },
1195    /// Gets the current [AudioSettings2]. Returns immediately on first call;
1196    /// subsequent calls return when the value changes.
1197    ///
1198    /// If this call fails, it is considered a fatal error and the channel will be closed.
1199    Watch2 { responder: AudioWatch2Responder },
1200    /// Sets audio settings. Any field not explicitly set in the table performs a
1201    /// no-op, and will not make any changes.
1202    Set { settings: AudioSettings, responder: AudioSetResponder },
1203    /// Sets audio settings. Only table fields that are set will lead to any changes; otherwise
1204    /// existing settings are unchanged.
1205    Set2 { settings: AudioSettings2, responder: AudioSet2Responder },
1206    /// An interaction was received which does not match any known method.
1207    #[non_exhaustive]
1208    _UnknownMethod {
1209        /// Ordinal of the method that was called.
1210        ordinal: u64,
1211        control_handle: AudioControlHandle,
1212        method_type: fidl::MethodType,
1213    },
1214}
1215
1216impl AudioRequest {
1217    #[allow(irrefutable_let_patterns)]
1218    pub fn into_watch(self) -> Option<(AudioWatchResponder)> {
1219        if let AudioRequest::Watch { responder } = self {
1220            Some((responder))
1221        } else {
1222            None
1223        }
1224    }
1225
1226    #[allow(irrefutable_let_patterns)]
1227    pub fn into_watch2(self) -> Option<(AudioWatch2Responder)> {
1228        if let AudioRequest::Watch2 { responder } = self {
1229            Some((responder))
1230        } else {
1231            None
1232        }
1233    }
1234
1235    #[allow(irrefutable_let_patterns)]
1236    pub fn into_set(self) -> Option<(AudioSettings, AudioSetResponder)> {
1237        if let AudioRequest::Set { settings, responder } = self {
1238            Some((settings, responder))
1239        } else {
1240            None
1241        }
1242    }
1243
1244    #[allow(irrefutable_let_patterns)]
1245    pub fn into_set2(self) -> Option<(AudioSettings2, AudioSet2Responder)> {
1246        if let AudioRequest::Set2 { settings, responder } = self {
1247            Some((settings, responder))
1248        } else {
1249            None
1250        }
1251    }
1252
1253    /// Name of the method defined in FIDL
1254    pub fn method_name(&self) -> &'static str {
1255        match *self {
1256            AudioRequest::Watch { .. } => "watch",
1257            AudioRequest::Watch2 { .. } => "watch2",
1258            AudioRequest::Set { .. } => "set",
1259            AudioRequest::Set2 { .. } => "set2",
1260            AudioRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1261                "unknown one-way method"
1262            }
1263            AudioRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1264                "unknown two-way method"
1265            }
1266        }
1267    }
1268}
1269
1270#[derive(Debug, Clone)]
1271pub struct AudioControlHandle {
1272    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1273}
1274
1275impl fidl::endpoints::ControlHandle for AudioControlHandle {
1276    fn shutdown(&self) {
1277        self.inner.shutdown()
1278    }
1279    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1280        self.inner.shutdown_with_epitaph(status)
1281    }
1282
1283    fn is_closed(&self) -> bool {
1284        self.inner.channel().is_closed()
1285    }
1286    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1287        self.inner.channel().on_closed()
1288    }
1289
1290    #[cfg(target_os = "fuchsia")]
1291    fn signal_peer(
1292        &self,
1293        clear_mask: zx::Signals,
1294        set_mask: zx::Signals,
1295    ) -> Result<(), zx_status::Status> {
1296        use fidl::Peered;
1297        self.inner.channel().signal_peer(clear_mask, set_mask)
1298    }
1299}
1300
1301impl AudioControlHandle {}
1302
1303#[must_use = "FIDL methods require a response to be sent"]
1304#[derive(Debug)]
1305pub struct AudioWatchResponder {
1306    control_handle: std::mem::ManuallyDrop<AudioControlHandle>,
1307    tx_id: u32,
1308}
1309
1310/// Set the the channel to be shutdown (see [`AudioControlHandle::shutdown`])
1311/// if the responder is dropped without sending a response, so that the client
1312/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1313impl std::ops::Drop for AudioWatchResponder {
1314    fn drop(&mut self) {
1315        self.control_handle.shutdown();
1316        // Safety: drops once, never accessed again
1317        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1318    }
1319}
1320
1321impl fidl::endpoints::Responder for AudioWatchResponder {
1322    type ControlHandle = AudioControlHandle;
1323
1324    fn control_handle(&self) -> &AudioControlHandle {
1325        &self.control_handle
1326    }
1327
1328    fn drop_without_shutdown(mut self) {
1329        // Safety: drops once, never accessed again due to mem::forget
1330        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1331        // Prevent Drop from running (which would shut down the channel)
1332        std::mem::forget(self);
1333    }
1334}
1335
1336impl AudioWatchResponder {
1337    /// Sends a response to the FIDL transaction.
1338    ///
1339    /// Sets the channel to shutdown if an error occurs.
1340    pub fn send(self, mut settings: &AudioSettings) -> Result<(), fidl::Error> {
1341        let _result = self.send_raw(settings);
1342        if _result.is_err() {
1343            self.control_handle.shutdown();
1344        }
1345        self.drop_without_shutdown();
1346        _result
1347    }
1348
1349    /// Similar to "send" but does not shutdown the channel if an error occurs.
1350    pub fn send_no_shutdown_on_err(self, mut settings: &AudioSettings) -> Result<(), fidl::Error> {
1351        let _result = self.send_raw(settings);
1352        self.drop_without_shutdown();
1353        _result
1354    }
1355
1356    fn send_raw(&self, mut settings: &AudioSettings) -> Result<(), fidl::Error> {
1357        self.control_handle.inner.send::<AudioWatchResponse>(
1358            (settings,),
1359            self.tx_id,
1360            0x2995cf83f9d0f805,
1361            fidl::encoding::DynamicFlags::empty(),
1362        )
1363    }
1364}
1365
1366#[must_use = "FIDL methods require a response to be sent"]
1367#[derive(Debug)]
1368pub struct AudioWatch2Responder {
1369    control_handle: std::mem::ManuallyDrop<AudioControlHandle>,
1370    tx_id: u32,
1371}
1372
1373/// Set the the channel to be shutdown (see [`AudioControlHandle::shutdown`])
1374/// if the responder is dropped without sending a response, so that the client
1375/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1376impl std::ops::Drop for AudioWatch2Responder {
1377    fn drop(&mut self) {
1378        self.control_handle.shutdown();
1379        // Safety: drops once, never accessed again
1380        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1381    }
1382}
1383
1384impl fidl::endpoints::Responder for AudioWatch2Responder {
1385    type ControlHandle = AudioControlHandle;
1386
1387    fn control_handle(&self) -> &AudioControlHandle {
1388        &self.control_handle
1389    }
1390
1391    fn drop_without_shutdown(mut self) {
1392        // Safety: drops once, never accessed again due to mem::forget
1393        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1394        // Prevent Drop from running (which would shut down the channel)
1395        std::mem::forget(self);
1396    }
1397}
1398
1399impl AudioWatch2Responder {
1400    /// Sends a response to the FIDL transaction.
1401    ///
1402    /// Sets the channel to shutdown if an error occurs.
1403    pub fn send(self, mut settings: &AudioSettings2) -> Result<(), fidl::Error> {
1404        let _result = self.send_raw(settings);
1405        if _result.is_err() {
1406            self.control_handle.shutdown();
1407        }
1408        self.drop_without_shutdown();
1409        _result
1410    }
1411
1412    /// Similar to "send" but does not shutdown the channel if an error occurs.
1413    pub fn send_no_shutdown_on_err(self, mut settings: &AudioSettings2) -> Result<(), fidl::Error> {
1414        let _result = self.send_raw(settings);
1415        self.drop_without_shutdown();
1416        _result
1417    }
1418
1419    fn send_raw(&self, mut settings: &AudioSettings2) -> Result<(), fidl::Error> {
1420        self.control_handle.inner.send::<fidl::encoding::FlexibleType<AudioWatch2Response>>(
1421            fidl::encoding::Flexible::new((settings,)),
1422            self.tx_id,
1423            0x4d10b204de1796e2,
1424            fidl::encoding::DynamicFlags::FLEXIBLE,
1425        )
1426    }
1427}
1428
1429#[must_use = "FIDL methods require a response to be sent"]
1430#[derive(Debug)]
1431pub struct AudioSetResponder {
1432    control_handle: std::mem::ManuallyDrop<AudioControlHandle>,
1433    tx_id: u32,
1434}
1435
1436/// Set the the channel to be shutdown (see [`AudioControlHandle::shutdown`])
1437/// if the responder is dropped without sending a response, so that the client
1438/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1439impl std::ops::Drop for AudioSetResponder {
1440    fn drop(&mut self) {
1441        self.control_handle.shutdown();
1442        // Safety: drops once, never accessed again
1443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1444    }
1445}
1446
1447impl fidl::endpoints::Responder for AudioSetResponder {
1448    type ControlHandle = AudioControlHandle;
1449
1450    fn control_handle(&self) -> &AudioControlHandle {
1451        &self.control_handle
1452    }
1453
1454    fn drop_without_shutdown(mut self) {
1455        // Safety: drops once, never accessed again due to mem::forget
1456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1457        // Prevent Drop from running (which would shut down the channel)
1458        std::mem::forget(self);
1459    }
1460}
1461
1462impl AudioSetResponder {
1463    /// Sends a response to the FIDL transaction.
1464    ///
1465    /// Sets the channel to shutdown if an error occurs.
1466    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1467        let _result = self.send_raw(result);
1468        if _result.is_err() {
1469            self.control_handle.shutdown();
1470        }
1471        self.drop_without_shutdown();
1472        _result
1473    }
1474
1475    /// Similar to "send" but does not shutdown the channel if an error occurs.
1476    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1477        let _result = self.send_raw(result);
1478        self.drop_without_shutdown();
1479        _result
1480    }
1481
1482    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1483        self.control_handle
1484            .inner
1485            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1486                result,
1487                self.tx_id,
1488                0x4f3865db04da626c,
1489                fidl::encoding::DynamicFlags::empty(),
1490            )
1491    }
1492}
1493
1494#[must_use = "FIDL methods require a response to be sent"]
1495#[derive(Debug)]
1496pub struct AudioSet2Responder {
1497    control_handle: std::mem::ManuallyDrop<AudioControlHandle>,
1498    tx_id: u32,
1499}
1500
1501/// Set the the channel to be shutdown (see [`AudioControlHandle::shutdown`])
1502/// if the responder is dropped without sending a response, so that the client
1503/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1504impl std::ops::Drop for AudioSet2Responder {
1505    fn drop(&mut self) {
1506        self.control_handle.shutdown();
1507        // Safety: drops once, never accessed again
1508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1509    }
1510}
1511
1512impl fidl::endpoints::Responder for AudioSet2Responder {
1513    type ControlHandle = AudioControlHandle;
1514
1515    fn control_handle(&self) -> &AudioControlHandle {
1516        &self.control_handle
1517    }
1518
1519    fn drop_without_shutdown(mut self) {
1520        // Safety: drops once, never accessed again due to mem::forget
1521        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1522        // Prevent Drop from running (which would shut down the channel)
1523        std::mem::forget(self);
1524    }
1525}
1526
1527impl AudioSet2Responder {
1528    /// Sends a response to the FIDL transaction.
1529    ///
1530    /// Sets the channel to shutdown if an error occurs.
1531    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1532        let _result = self.send_raw(result);
1533        if _result.is_err() {
1534            self.control_handle.shutdown();
1535        }
1536        self.drop_without_shutdown();
1537        _result
1538    }
1539
1540    /// Similar to "send" but does not shutdown the channel if an error occurs.
1541    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1542        let _result = self.send_raw(result);
1543        self.drop_without_shutdown();
1544        _result
1545    }
1546
1547    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1548        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1549            fidl::encoding::EmptyStruct,
1550            Error,
1551        >>(
1552            fidl::encoding::FlexibleResult::new(result),
1553            self.tx_id,
1554            0x1f027e9ed7beefe3,
1555            fidl::encoding::DynamicFlags::FLEXIBLE,
1556        )
1557    }
1558}
1559
1560#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1561pub struct DisplayMarker;
1562
1563impl fidl::endpoints::ProtocolMarker for DisplayMarker {
1564    type Proxy = DisplayProxy;
1565    type RequestStream = DisplayRequestStream;
1566    #[cfg(target_os = "fuchsia")]
1567    type SynchronousProxy = DisplaySynchronousProxy;
1568
1569    const DEBUG_NAME: &'static str = "fuchsia.settings.Display";
1570}
1571impl fidl::endpoints::DiscoverableProtocolMarker for DisplayMarker {}
1572pub type DisplaySetResult = Result<(), Error>;
1573
1574pub trait DisplayProxyInterface: Send + Sync {
1575    type WatchResponseFut: std::future::Future<Output = Result<DisplaySettings, fidl::Error>> + Send;
1576    fn r#watch(&self) -> Self::WatchResponseFut;
1577    type SetResponseFut: std::future::Future<Output = Result<DisplaySetResult, fidl::Error>> + Send;
1578    fn r#set(&self, settings: &DisplaySettings) -> Self::SetResponseFut;
1579}
1580#[derive(Debug)]
1581#[cfg(target_os = "fuchsia")]
1582pub struct DisplaySynchronousProxy {
1583    client: fidl::client::sync::Client,
1584}
1585
1586#[cfg(target_os = "fuchsia")]
1587impl fidl::endpoints::SynchronousProxy for DisplaySynchronousProxy {
1588    type Proxy = DisplayProxy;
1589    type Protocol = DisplayMarker;
1590
1591    fn from_channel(inner: fidl::Channel) -> Self {
1592        Self::new(inner)
1593    }
1594
1595    fn into_channel(self) -> fidl::Channel {
1596        self.client.into_channel()
1597    }
1598
1599    fn as_channel(&self) -> &fidl::Channel {
1600        self.client.as_channel()
1601    }
1602}
1603
1604#[cfg(target_os = "fuchsia")]
1605impl DisplaySynchronousProxy {
1606    pub fn new(channel: fidl::Channel) -> Self {
1607        let protocol_name = <DisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1608        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1609    }
1610
1611    pub fn into_channel(self) -> fidl::Channel {
1612        self.client.into_channel()
1613    }
1614
1615    /// Waits until an event arrives and returns it. It is safe for other
1616    /// threads to make concurrent requests while waiting for an event.
1617    pub fn wait_for_event(
1618        &self,
1619        deadline: zx::MonotonicInstant,
1620    ) -> Result<DisplayEvent, fidl::Error> {
1621        DisplayEvent::decode(self.client.wait_for_event(deadline)?)
1622    }
1623
1624    /// Gets the current [DisplaySettings]. Returns immediately on first call;
1625    /// subsequent calls return when the value changes.
1626    ///
1627    /// If this call fails, it is considered a fatal error and the channel
1628    /// will be closed.
1629    pub fn r#watch(
1630        &self,
1631        ___deadline: zx::MonotonicInstant,
1632    ) -> Result<DisplaySettings, fidl::Error> {
1633        let _response =
1634            self.client.send_query::<fidl::encoding::EmptyPayload, DisplayWatchResponse>(
1635                (),
1636                0x7da3212470364db1,
1637                fidl::encoding::DynamicFlags::empty(),
1638                ___deadline,
1639            )?;
1640        Ok(_response.settings)
1641    }
1642
1643    /// Sets display settings. Any field not explicitly set in the table performs a
1644    /// no-op, and will not make any changes.
1645    pub fn r#set(
1646        &self,
1647        mut settings: &DisplaySettings,
1648        ___deadline: zx::MonotonicInstant,
1649    ) -> Result<DisplaySetResult, fidl::Error> {
1650        let _response = self.client.send_query::<DisplaySetRequest, fidl::encoding::ResultType<
1651            fidl::encoding::EmptyStruct,
1652            Error,
1653        >>(
1654            (settings,),
1655            0x1029e06ace17479c,
1656            fidl::encoding::DynamicFlags::empty(),
1657            ___deadline,
1658        )?;
1659        Ok(_response.map(|x| x))
1660    }
1661}
1662
1663#[derive(Debug, Clone)]
1664pub struct DisplayProxy {
1665    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1666}
1667
1668impl fidl::endpoints::Proxy for DisplayProxy {
1669    type Protocol = DisplayMarker;
1670
1671    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1672        Self::new(inner)
1673    }
1674
1675    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1676        self.client.into_channel().map_err(|client| Self { client })
1677    }
1678
1679    fn as_channel(&self) -> &::fidl::AsyncChannel {
1680        self.client.as_channel()
1681    }
1682}
1683
1684impl DisplayProxy {
1685    /// Create a new Proxy for fuchsia.settings/Display.
1686    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1687        let protocol_name = <DisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1688        Self { client: fidl::client::Client::new(channel, protocol_name) }
1689    }
1690
1691    /// Get a Stream of events from the remote end of the protocol.
1692    ///
1693    /// # Panics
1694    ///
1695    /// Panics if the event stream was already taken.
1696    pub fn take_event_stream(&self) -> DisplayEventStream {
1697        DisplayEventStream { event_receiver: self.client.take_event_receiver() }
1698    }
1699
1700    /// Gets the current [DisplaySettings]. Returns immediately on first call;
1701    /// subsequent calls return when the value changes.
1702    ///
1703    /// If this call fails, it is considered a fatal error and the channel
1704    /// will be closed.
1705    pub fn r#watch(
1706        &self,
1707    ) -> fidl::client::QueryResponseFut<
1708        DisplaySettings,
1709        fidl::encoding::DefaultFuchsiaResourceDialect,
1710    > {
1711        DisplayProxyInterface::r#watch(self)
1712    }
1713
1714    /// Sets display settings. Any field not explicitly set in the table performs a
1715    /// no-op, and will not make any changes.
1716    pub fn r#set(
1717        &self,
1718        mut settings: &DisplaySettings,
1719    ) -> fidl::client::QueryResponseFut<
1720        DisplaySetResult,
1721        fidl::encoding::DefaultFuchsiaResourceDialect,
1722    > {
1723        DisplayProxyInterface::r#set(self, settings)
1724    }
1725}
1726
1727impl DisplayProxyInterface for DisplayProxy {
1728    type WatchResponseFut = fidl::client::QueryResponseFut<
1729        DisplaySettings,
1730        fidl::encoding::DefaultFuchsiaResourceDialect,
1731    >;
1732    fn r#watch(&self) -> Self::WatchResponseFut {
1733        fn _decode(
1734            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1735        ) -> Result<DisplaySettings, fidl::Error> {
1736            let _response = fidl::client::decode_transaction_body::<
1737                DisplayWatchResponse,
1738                fidl::encoding::DefaultFuchsiaResourceDialect,
1739                0x7da3212470364db1,
1740            >(_buf?)?;
1741            Ok(_response.settings)
1742        }
1743        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DisplaySettings>(
1744            (),
1745            0x7da3212470364db1,
1746            fidl::encoding::DynamicFlags::empty(),
1747            _decode,
1748        )
1749    }
1750
1751    type SetResponseFut = fidl::client::QueryResponseFut<
1752        DisplaySetResult,
1753        fidl::encoding::DefaultFuchsiaResourceDialect,
1754    >;
1755    fn r#set(&self, mut settings: &DisplaySettings) -> Self::SetResponseFut {
1756        fn _decode(
1757            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1758        ) -> Result<DisplaySetResult, fidl::Error> {
1759            let _response = fidl::client::decode_transaction_body::<
1760                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1761                fidl::encoding::DefaultFuchsiaResourceDialect,
1762                0x1029e06ace17479c,
1763            >(_buf?)?;
1764            Ok(_response.map(|x| x))
1765        }
1766        self.client.send_query_and_decode::<DisplaySetRequest, DisplaySetResult>(
1767            (settings,),
1768            0x1029e06ace17479c,
1769            fidl::encoding::DynamicFlags::empty(),
1770            _decode,
1771        )
1772    }
1773}
1774
1775pub struct DisplayEventStream {
1776    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1777}
1778
1779impl std::marker::Unpin for DisplayEventStream {}
1780
1781impl futures::stream::FusedStream for DisplayEventStream {
1782    fn is_terminated(&self) -> bool {
1783        self.event_receiver.is_terminated()
1784    }
1785}
1786
1787impl futures::Stream for DisplayEventStream {
1788    type Item = Result<DisplayEvent, fidl::Error>;
1789
1790    fn poll_next(
1791        mut self: std::pin::Pin<&mut Self>,
1792        cx: &mut std::task::Context<'_>,
1793    ) -> std::task::Poll<Option<Self::Item>> {
1794        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1795            &mut self.event_receiver,
1796            cx
1797        )?) {
1798            Some(buf) => std::task::Poll::Ready(Some(DisplayEvent::decode(buf))),
1799            None => std::task::Poll::Ready(None),
1800        }
1801    }
1802}
1803
1804#[derive(Debug)]
1805pub enum DisplayEvent {}
1806
1807impl DisplayEvent {
1808    /// Decodes a message buffer as a [`DisplayEvent`].
1809    fn decode(
1810        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1811    ) -> Result<DisplayEvent, fidl::Error> {
1812        let (bytes, _handles) = buf.split_mut();
1813        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1814        debug_assert_eq!(tx_header.tx_id, 0);
1815        match tx_header.ordinal {
1816            _ => Err(fidl::Error::UnknownOrdinal {
1817                ordinal: tx_header.ordinal,
1818                protocol_name: <DisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1819            }),
1820        }
1821    }
1822}
1823
1824/// A Stream of incoming requests for fuchsia.settings/Display.
1825pub struct DisplayRequestStream {
1826    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1827    is_terminated: bool,
1828}
1829
1830impl std::marker::Unpin for DisplayRequestStream {}
1831
1832impl futures::stream::FusedStream for DisplayRequestStream {
1833    fn is_terminated(&self) -> bool {
1834        self.is_terminated
1835    }
1836}
1837
1838impl fidl::endpoints::RequestStream for DisplayRequestStream {
1839    type Protocol = DisplayMarker;
1840    type ControlHandle = DisplayControlHandle;
1841
1842    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1843        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1844    }
1845
1846    fn control_handle(&self) -> Self::ControlHandle {
1847        DisplayControlHandle { inner: self.inner.clone() }
1848    }
1849
1850    fn into_inner(
1851        self,
1852    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1853    {
1854        (self.inner, self.is_terminated)
1855    }
1856
1857    fn from_inner(
1858        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1859        is_terminated: bool,
1860    ) -> Self {
1861        Self { inner, is_terminated }
1862    }
1863}
1864
1865impl futures::Stream for DisplayRequestStream {
1866    type Item = Result<DisplayRequest, fidl::Error>;
1867
1868    fn poll_next(
1869        mut self: std::pin::Pin<&mut Self>,
1870        cx: &mut std::task::Context<'_>,
1871    ) -> std::task::Poll<Option<Self::Item>> {
1872        let this = &mut *self;
1873        if this.inner.check_shutdown(cx) {
1874            this.is_terminated = true;
1875            return std::task::Poll::Ready(None);
1876        }
1877        if this.is_terminated {
1878            panic!("polled DisplayRequestStream after completion");
1879        }
1880        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1881            |bytes, handles| {
1882                match this.inner.channel().read_etc(cx, bytes, handles) {
1883                    std::task::Poll::Ready(Ok(())) => {}
1884                    std::task::Poll::Pending => return std::task::Poll::Pending,
1885                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1886                        this.is_terminated = true;
1887                        return std::task::Poll::Ready(None);
1888                    }
1889                    std::task::Poll::Ready(Err(e)) => {
1890                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1891                            e.into(),
1892                        ))))
1893                    }
1894                }
1895
1896                // A message has been received from the channel
1897                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1898
1899                std::task::Poll::Ready(Some(match header.ordinal {
1900                    0x7da3212470364db1 => {
1901                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1902                        let mut req = fidl::new_empty!(
1903                            fidl::encoding::EmptyPayload,
1904                            fidl::encoding::DefaultFuchsiaResourceDialect
1905                        );
1906                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1907                        let control_handle = DisplayControlHandle { inner: this.inner.clone() };
1908                        Ok(DisplayRequest::Watch {
1909                            responder: DisplayWatchResponder {
1910                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1911                                tx_id: header.tx_id,
1912                            },
1913                        })
1914                    }
1915                    0x1029e06ace17479c => {
1916                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1917                        let mut req = fidl::new_empty!(
1918                            DisplaySetRequest,
1919                            fidl::encoding::DefaultFuchsiaResourceDialect
1920                        );
1921                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DisplaySetRequest>(&header, _body_bytes, handles, &mut req)?;
1922                        let control_handle = DisplayControlHandle { inner: this.inner.clone() };
1923                        Ok(DisplayRequest::Set {
1924                            settings: req.settings,
1925
1926                            responder: DisplaySetResponder {
1927                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1928                                tx_id: header.tx_id,
1929                            },
1930                        })
1931                    }
1932                    _ => Err(fidl::Error::UnknownOrdinal {
1933                        ordinal: header.ordinal,
1934                        protocol_name:
1935                            <DisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1936                    }),
1937                }))
1938            },
1939        )
1940    }
1941}
1942
1943/// Settings related to display.
1944///
1945/// Supported SettingsEpitaph enums:
1946/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR
1947#[derive(Debug)]
1948pub enum DisplayRequest {
1949    /// Gets the current [DisplaySettings]. Returns immediately on first call;
1950    /// subsequent calls return when the value changes.
1951    ///
1952    /// If this call fails, it is considered a fatal error and the channel
1953    /// will be closed.
1954    Watch { responder: DisplayWatchResponder },
1955    /// Sets display settings. Any field not explicitly set in the table performs a
1956    /// no-op, and will not make any changes.
1957    Set { settings: DisplaySettings, responder: DisplaySetResponder },
1958}
1959
1960impl DisplayRequest {
1961    #[allow(irrefutable_let_patterns)]
1962    pub fn into_watch(self) -> Option<(DisplayWatchResponder)> {
1963        if let DisplayRequest::Watch { responder } = self {
1964            Some((responder))
1965        } else {
1966            None
1967        }
1968    }
1969
1970    #[allow(irrefutable_let_patterns)]
1971    pub fn into_set(self) -> Option<(DisplaySettings, DisplaySetResponder)> {
1972        if let DisplayRequest::Set { settings, responder } = self {
1973            Some((settings, responder))
1974        } else {
1975            None
1976        }
1977    }
1978
1979    /// Name of the method defined in FIDL
1980    pub fn method_name(&self) -> &'static str {
1981        match *self {
1982            DisplayRequest::Watch { .. } => "watch",
1983            DisplayRequest::Set { .. } => "set",
1984        }
1985    }
1986}
1987
1988#[derive(Debug, Clone)]
1989pub struct DisplayControlHandle {
1990    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1991}
1992
1993impl fidl::endpoints::ControlHandle for DisplayControlHandle {
1994    fn shutdown(&self) {
1995        self.inner.shutdown()
1996    }
1997    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1998        self.inner.shutdown_with_epitaph(status)
1999    }
2000
2001    fn is_closed(&self) -> bool {
2002        self.inner.channel().is_closed()
2003    }
2004    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2005        self.inner.channel().on_closed()
2006    }
2007
2008    #[cfg(target_os = "fuchsia")]
2009    fn signal_peer(
2010        &self,
2011        clear_mask: zx::Signals,
2012        set_mask: zx::Signals,
2013    ) -> Result<(), zx_status::Status> {
2014        use fidl::Peered;
2015        self.inner.channel().signal_peer(clear_mask, set_mask)
2016    }
2017}
2018
2019impl DisplayControlHandle {}
2020
2021#[must_use = "FIDL methods require a response to be sent"]
2022#[derive(Debug)]
2023pub struct DisplayWatchResponder {
2024    control_handle: std::mem::ManuallyDrop<DisplayControlHandle>,
2025    tx_id: u32,
2026}
2027
2028/// Set the the channel to be shutdown (see [`DisplayControlHandle::shutdown`])
2029/// if the responder is dropped without sending a response, so that the client
2030/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2031impl std::ops::Drop for DisplayWatchResponder {
2032    fn drop(&mut self) {
2033        self.control_handle.shutdown();
2034        // Safety: drops once, never accessed again
2035        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2036    }
2037}
2038
2039impl fidl::endpoints::Responder for DisplayWatchResponder {
2040    type ControlHandle = DisplayControlHandle;
2041
2042    fn control_handle(&self) -> &DisplayControlHandle {
2043        &self.control_handle
2044    }
2045
2046    fn drop_without_shutdown(mut self) {
2047        // Safety: drops once, never accessed again due to mem::forget
2048        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2049        // Prevent Drop from running (which would shut down the channel)
2050        std::mem::forget(self);
2051    }
2052}
2053
2054impl DisplayWatchResponder {
2055    /// Sends a response to the FIDL transaction.
2056    ///
2057    /// Sets the channel to shutdown if an error occurs.
2058    pub fn send(self, mut settings: &DisplaySettings) -> Result<(), fidl::Error> {
2059        let _result = self.send_raw(settings);
2060        if _result.is_err() {
2061            self.control_handle.shutdown();
2062        }
2063        self.drop_without_shutdown();
2064        _result
2065    }
2066
2067    /// Similar to "send" but does not shutdown the channel if an error occurs.
2068    pub fn send_no_shutdown_on_err(
2069        self,
2070        mut settings: &DisplaySettings,
2071    ) -> Result<(), fidl::Error> {
2072        let _result = self.send_raw(settings);
2073        self.drop_without_shutdown();
2074        _result
2075    }
2076
2077    fn send_raw(&self, mut settings: &DisplaySettings) -> Result<(), fidl::Error> {
2078        self.control_handle.inner.send::<DisplayWatchResponse>(
2079            (settings,),
2080            self.tx_id,
2081            0x7da3212470364db1,
2082            fidl::encoding::DynamicFlags::empty(),
2083        )
2084    }
2085}
2086
2087#[must_use = "FIDL methods require a response to be sent"]
2088#[derive(Debug)]
2089pub struct DisplaySetResponder {
2090    control_handle: std::mem::ManuallyDrop<DisplayControlHandle>,
2091    tx_id: u32,
2092}
2093
2094/// Set the the channel to be shutdown (see [`DisplayControlHandle::shutdown`])
2095/// if the responder is dropped without sending a response, so that the client
2096/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2097impl std::ops::Drop for DisplaySetResponder {
2098    fn drop(&mut self) {
2099        self.control_handle.shutdown();
2100        // Safety: drops once, never accessed again
2101        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2102    }
2103}
2104
2105impl fidl::endpoints::Responder for DisplaySetResponder {
2106    type ControlHandle = DisplayControlHandle;
2107
2108    fn control_handle(&self) -> &DisplayControlHandle {
2109        &self.control_handle
2110    }
2111
2112    fn drop_without_shutdown(mut self) {
2113        // Safety: drops once, never accessed again due to mem::forget
2114        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2115        // Prevent Drop from running (which would shut down the channel)
2116        std::mem::forget(self);
2117    }
2118}
2119
2120impl DisplaySetResponder {
2121    /// Sends a response to the FIDL transaction.
2122    ///
2123    /// Sets the channel to shutdown if an error occurs.
2124    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2125        let _result = self.send_raw(result);
2126        if _result.is_err() {
2127            self.control_handle.shutdown();
2128        }
2129        self.drop_without_shutdown();
2130        _result
2131    }
2132
2133    /// Similar to "send" but does not shutdown the channel if an error occurs.
2134    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2135        let _result = self.send_raw(result);
2136        self.drop_without_shutdown();
2137        _result
2138    }
2139
2140    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2141        self.control_handle
2142            .inner
2143            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2144                result,
2145                self.tx_id,
2146                0x1029e06ace17479c,
2147                fidl::encoding::DynamicFlags::empty(),
2148            )
2149    }
2150}
2151
2152#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2153pub struct DoNotDisturbMarker;
2154
2155impl fidl::endpoints::ProtocolMarker for DoNotDisturbMarker {
2156    type Proxy = DoNotDisturbProxy;
2157    type RequestStream = DoNotDisturbRequestStream;
2158    #[cfg(target_os = "fuchsia")]
2159    type SynchronousProxy = DoNotDisturbSynchronousProxy;
2160
2161    const DEBUG_NAME: &'static str = "fuchsia.settings.DoNotDisturb";
2162}
2163impl fidl::endpoints::DiscoverableProtocolMarker for DoNotDisturbMarker {}
2164pub type DoNotDisturbSetResult = Result<(), Error>;
2165
2166pub trait DoNotDisturbProxyInterface: Send + Sync {
2167    type WatchResponseFut: std::future::Future<Output = Result<DoNotDisturbSettings, fidl::Error>>
2168        + Send;
2169    fn r#watch(&self) -> Self::WatchResponseFut;
2170    type SetResponseFut: std::future::Future<Output = Result<DoNotDisturbSetResult, fidl::Error>>
2171        + Send;
2172    fn r#set(&self, settings: &DoNotDisturbSettings) -> Self::SetResponseFut;
2173}
2174#[derive(Debug)]
2175#[cfg(target_os = "fuchsia")]
2176pub struct DoNotDisturbSynchronousProxy {
2177    client: fidl::client::sync::Client,
2178}
2179
2180#[cfg(target_os = "fuchsia")]
2181impl fidl::endpoints::SynchronousProxy for DoNotDisturbSynchronousProxy {
2182    type Proxy = DoNotDisturbProxy;
2183    type Protocol = DoNotDisturbMarker;
2184
2185    fn from_channel(inner: fidl::Channel) -> Self {
2186        Self::new(inner)
2187    }
2188
2189    fn into_channel(self) -> fidl::Channel {
2190        self.client.into_channel()
2191    }
2192
2193    fn as_channel(&self) -> &fidl::Channel {
2194        self.client.as_channel()
2195    }
2196}
2197
2198#[cfg(target_os = "fuchsia")]
2199impl DoNotDisturbSynchronousProxy {
2200    pub fn new(channel: fidl::Channel) -> Self {
2201        let protocol_name = <DoNotDisturbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2202        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2203    }
2204
2205    pub fn into_channel(self) -> fidl::Channel {
2206        self.client.into_channel()
2207    }
2208
2209    /// Waits until an event arrives and returns it. It is safe for other
2210    /// threads to make concurrent requests while waiting for an event.
2211    pub fn wait_for_event(
2212        &self,
2213        deadline: zx::MonotonicInstant,
2214    ) -> Result<DoNotDisturbEvent, fidl::Error> {
2215        DoNotDisturbEvent::decode(self.client.wait_for_event(deadline)?)
2216    }
2217
2218    /// Gets the current [`DoNotDisturbSettings`]. Returns immediately on first
2219    /// call; subsequent calls return when the values change.
2220    ///
2221    /// If this call fails, it is considered a fatal error and the channel
2222    /// will be closed.
2223    pub fn r#watch(
2224        &self,
2225        ___deadline: zx::MonotonicInstant,
2226    ) -> Result<DoNotDisturbSettings, fidl::Error> {
2227        let _response =
2228            self.client.send_query::<fidl::encoding::EmptyPayload, DoNotDisturbWatchResponse>(
2229                (),
2230                0x1eeae2f97a5547fb,
2231                fidl::encoding::DynamicFlags::empty(),
2232                ___deadline,
2233            )?;
2234        Ok(_response.settings)
2235    }
2236
2237    /// Sets [`DoNotDisturbSettings`] settings. Any field not explicitly set in
2238    /// the table performs a no-op, and will not make any changes.
2239    pub fn r#set(
2240        &self,
2241        mut settings: &DoNotDisturbSettings,
2242        ___deadline: zx::MonotonicInstant,
2243    ) -> Result<DoNotDisturbSetResult, fidl::Error> {
2244        let _response = self.client.send_query::<
2245            DoNotDisturbSetRequest,
2246            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2247        >(
2248            (settings,),
2249            0x7fef934e7f5777b0,
2250            fidl::encoding::DynamicFlags::empty(),
2251            ___deadline,
2252        )?;
2253        Ok(_response.map(|x| x))
2254    }
2255}
2256
2257#[derive(Debug, Clone)]
2258pub struct DoNotDisturbProxy {
2259    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2260}
2261
2262impl fidl::endpoints::Proxy for DoNotDisturbProxy {
2263    type Protocol = DoNotDisturbMarker;
2264
2265    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2266        Self::new(inner)
2267    }
2268
2269    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2270        self.client.into_channel().map_err(|client| Self { client })
2271    }
2272
2273    fn as_channel(&self) -> &::fidl::AsyncChannel {
2274        self.client.as_channel()
2275    }
2276}
2277
2278impl DoNotDisturbProxy {
2279    /// Create a new Proxy for fuchsia.settings/DoNotDisturb.
2280    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2281        let protocol_name = <DoNotDisturbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2282        Self { client: fidl::client::Client::new(channel, protocol_name) }
2283    }
2284
2285    /// Get a Stream of events from the remote end of the protocol.
2286    ///
2287    /// # Panics
2288    ///
2289    /// Panics if the event stream was already taken.
2290    pub fn take_event_stream(&self) -> DoNotDisturbEventStream {
2291        DoNotDisturbEventStream { event_receiver: self.client.take_event_receiver() }
2292    }
2293
2294    /// Gets the current [`DoNotDisturbSettings`]. Returns immediately on first
2295    /// call; subsequent calls return when the values change.
2296    ///
2297    /// If this call fails, it is considered a fatal error and the channel
2298    /// will be closed.
2299    pub fn r#watch(
2300        &self,
2301    ) -> fidl::client::QueryResponseFut<
2302        DoNotDisturbSettings,
2303        fidl::encoding::DefaultFuchsiaResourceDialect,
2304    > {
2305        DoNotDisturbProxyInterface::r#watch(self)
2306    }
2307
2308    /// Sets [`DoNotDisturbSettings`] settings. Any field not explicitly set in
2309    /// the table performs a no-op, and will not make any changes.
2310    pub fn r#set(
2311        &self,
2312        mut settings: &DoNotDisturbSettings,
2313    ) -> fidl::client::QueryResponseFut<
2314        DoNotDisturbSetResult,
2315        fidl::encoding::DefaultFuchsiaResourceDialect,
2316    > {
2317        DoNotDisturbProxyInterface::r#set(self, settings)
2318    }
2319}
2320
2321impl DoNotDisturbProxyInterface for DoNotDisturbProxy {
2322    type WatchResponseFut = fidl::client::QueryResponseFut<
2323        DoNotDisturbSettings,
2324        fidl::encoding::DefaultFuchsiaResourceDialect,
2325    >;
2326    fn r#watch(&self) -> Self::WatchResponseFut {
2327        fn _decode(
2328            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2329        ) -> Result<DoNotDisturbSettings, fidl::Error> {
2330            let _response = fidl::client::decode_transaction_body::<
2331                DoNotDisturbWatchResponse,
2332                fidl::encoding::DefaultFuchsiaResourceDialect,
2333                0x1eeae2f97a5547fb,
2334            >(_buf?)?;
2335            Ok(_response.settings)
2336        }
2337        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DoNotDisturbSettings>(
2338            (),
2339            0x1eeae2f97a5547fb,
2340            fidl::encoding::DynamicFlags::empty(),
2341            _decode,
2342        )
2343    }
2344
2345    type SetResponseFut = fidl::client::QueryResponseFut<
2346        DoNotDisturbSetResult,
2347        fidl::encoding::DefaultFuchsiaResourceDialect,
2348    >;
2349    fn r#set(&self, mut settings: &DoNotDisturbSettings) -> Self::SetResponseFut {
2350        fn _decode(
2351            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2352        ) -> Result<DoNotDisturbSetResult, fidl::Error> {
2353            let _response = fidl::client::decode_transaction_body::<
2354                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2355                fidl::encoding::DefaultFuchsiaResourceDialect,
2356                0x7fef934e7f5777b0,
2357            >(_buf?)?;
2358            Ok(_response.map(|x| x))
2359        }
2360        self.client.send_query_and_decode::<DoNotDisturbSetRequest, DoNotDisturbSetResult>(
2361            (settings,),
2362            0x7fef934e7f5777b0,
2363            fidl::encoding::DynamicFlags::empty(),
2364            _decode,
2365        )
2366    }
2367}
2368
2369pub struct DoNotDisturbEventStream {
2370    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2371}
2372
2373impl std::marker::Unpin for DoNotDisturbEventStream {}
2374
2375impl futures::stream::FusedStream for DoNotDisturbEventStream {
2376    fn is_terminated(&self) -> bool {
2377        self.event_receiver.is_terminated()
2378    }
2379}
2380
2381impl futures::Stream for DoNotDisturbEventStream {
2382    type Item = Result<DoNotDisturbEvent, fidl::Error>;
2383
2384    fn poll_next(
2385        mut self: std::pin::Pin<&mut Self>,
2386        cx: &mut std::task::Context<'_>,
2387    ) -> std::task::Poll<Option<Self::Item>> {
2388        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2389            &mut self.event_receiver,
2390            cx
2391        )?) {
2392            Some(buf) => std::task::Poll::Ready(Some(DoNotDisturbEvent::decode(buf))),
2393            None => std::task::Poll::Ready(None),
2394        }
2395    }
2396}
2397
2398#[derive(Debug)]
2399pub enum DoNotDisturbEvent {}
2400
2401impl DoNotDisturbEvent {
2402    /// Decodes a message buffer as a [`DoNotDisturbEvent`].
2403    fn decode(
2404        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2405    ) -> Result<DoNotDisturbEvent, fidl::Error> {
2406        let (bytes, _handles) = buf.split_mut();
2407        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2408        debug_assert_eq!(tx_header.tx_id, 0);
2409        match tx_header.ordinal {
2410            _ => Err(fidl::Error::UnknownOrdinal {
2411                ordinal: tx_header.ordinal,
2412                protocol_name: <DoNotDisturbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2413            }),
2414        }
2415    }
2416}
2417
2418/// A Stream of incoming requests for fuchsia.settings/DoNotDisturb.
2419pub struct DoNotDisturbRequestStream {
2420    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2421    is_terminated: bool,
2422}
2423
2424impl std::marker::Unpin for DoNotDisturbRequestStream {}
2425
2426impl futures::stream::FusedStream for DoNotDisturbRequestStream {
2427    fn is_terminated(&self) -> bool {
2428        self.is_terminated
2429    }
2430}
2431
2432impl fidl::endpoints::RequestStream for DoNotDisturbRequestStream {
2433    type Protocol = DoNotDisturbMarker;
2434    type ControlHandle = DoNotDisturbControlHandle;
2435
2436    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2437        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2438    }
2439
2440    fn control_handle(&self) -> Self::ControlHandle {
2441        DoNotDisturbControlHandle { inner: self.inner.clone() }
2442    }
2443
2444    fn into_inner(
2445        self,
2446    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2447    {
2448        (self.inner, self.is_terminated)
2449    }
2450
2451    fn from_inner(
2452        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2453        is_terminated: bool,
2454    ) -> Self {
2455        Self { inner, is_terminated }
2456    }
2457}
2458
2459impl futures::Stream for DoNotDisturbRequestStream {
2460    type Item = Result<DoNotDisturbRequest, fidl::Error>;
2461
2462    fn poll_next(
2463        mut self: std::pin::Pin<&mut Self>,
2464        cx: &mut std::task::Context<'_>,
2465    ) -> std::task::Poll<Option<Self::Item>> {
2466        let this = &mut *self;
2467        if this.inner.check_shutdown(cx) {
2468            this.is_terminated = true;
2469            return std::task::Poll::Ready(None);
2470        }
2471        if this.is_terminated {
2472            panic!("polled DoNotDisturbRequestStream after completion");
2473        }
2474        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2475            |bytes, handles| {
2476                match this.inner.channel().read_etc(cx, bytes, handles) {
2477                    std::task::Poll::Ready(Ok(())) => {}
2478                    std::task::Poll::Pending => return std::task::Poll::Pending,
2479                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2480                        this.is_terminated = true;
2481                        return std::task::Poll::Ready(None);
2482                    }
2483                    std::task::Poll::Ready(Err(e)) => {
2484                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2485                            e.into(),
2486                        ))))
2487                    }
2488                }
2489
2490                // A message has been received from the channel
2491                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2492
2493                std::task::Poll::Ready(Some(match header.ordinal {
2494                    0x1eeae2f97a5547fb => {
2495                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2496                        let mut req = fidl::new_empty!(
2497                            fidl::encoding::EmptyPayload,
2498                            fidl::encoding::DefaultFuchsiaResourceDialect
2499                        );
2500                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2501                        let control_handle =
2502                            DoNotDisturbControlHandle { inner: this.inner.clone() };
2503                        Ok(DoNotDisturbRequest::Watch {
2504                            responder: DoNotDisturbWatchResponder {
2505                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2506                                tx_id: header.tx_id,
2507                            },
2508                        })
2509                    }
2510                    0x7fef934e7f5777b0 => {
2511                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2512                        let mut req = fidl::new_empty!(
2513                            DoNotDisturbSetRequest,
2514                            fidl::encoding::DefaultFuchsiaResourceDialect
2515                        );
2516                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DoNotDisturbSetRequest>(&header, _body_bytes, handles, &mut req)?;
2517                        let control_handle =
2518                            DoNotDisturbControlHandle { inner: this.inner.clone() };
2519                        Ok(DoNotDisturbRequest::Set {
2520                            settings: req.settings,
2521
2522                            responder: DoNotDisturbSetResponder {
2523                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2524                                tx_id: header.tx_id,
2525                            },
2526                        })
2527                    }
2528                    _ => Err(fidl::Error::UnknownOrdinal {
2529                        ordinal: header.ordinal,
2530                        protocol_name:
2531                            <DoNotDisturbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2532                    }),
2533                }))
2534            },
2535        )
2536    }
2537}
2538
2539/// Modify or watch do-not-disturb (DND) mode. While DND is active, distractions
2540/// created by the device are reduced or eliminated. E.g. bootup is silent,
2541/// incoming calls could be rejected or silent, and notifications could be
2542/// paused, silent, or hidden. High-priority disruptions like alarms can be
2543/// allowed.
2544///
2545/// Supported SettingsEpitaph enums:
2546/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR
2547#[derive(Debug)]
2548pub enum DoNotDisturbRequest {
2549    /// Gets the current [`DoNotDisturbSettings`]. Returns immediately on first
2550    /// call; subsequent calls return when the values change.
2551    ///
2552    /// If this call fails, it is considered a fatal error and the channel
2553    /// will be closed.
2554    Watch { responder: DoNotDisturbWatchResponder },
2555    /// Sets [`DoNotDisturbSettings`] settings. Any field not explicitly set in
2556    /// the table performs a no-op, and will not make any changes.
2557    Set { settings: DoNotDisturbSettings, responder: DoNotDisturbSetResponder },
2558}
2559
2560impl DoNotDisturbRequest {
2561    #[allow(irrefutable_let_patterns)]
2562    pub fn into_watch(self) -> Option<(DoNotDisturbWatchResponder)> {
2563        if let DoNotDisturbRequest::Watch { responder } = self {
2564            Some((responder))
2565        } else {
2566            None
2567        }
2568    }
2569
2570    #[allow(irrefutable_let_patterns)]
2571    pub fn into_set(self) -> Option<(DoNotDisturbSettings, DoNotDisturbSetResponder)> {
2572        if let DoNotDisturbRequest::Set { settings, responder } = self {
2573            Some((settings, responder))
2574        } else {
2575            None
2576        }
2577    }
2578
2579    /// Name of the method defined in FIDL
2580    pub fn method_name(&self) -> &'static str {
2581        match *self {
2582            DoNotDisturbRequest::Watch { .. } => "watch",
2583            DoNotDisturbRequest::Set { .. } => "set",
2584        }
2585    }
2586}
2587
2588#[derive(Debug, Clone)]
2589pub struct DoNotDisturbControlHandle {
2590    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2591}
2592
2593impl fidl::endpoints::ControlHandle for DoNotDisturbControlHandle {
2594    fn shutdown(&self) {
2595        self.inner.shutdown()
2596    }
2597    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2598        self.inner.shutdown_with_epitaph(status)
2599    }
2600
2601    fn is_closed(&self) -> bool {
2602        self.inner.channel().is_closed()
2603    }
2604    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2605        self.inner.channel().on_closed()
2606    }
2607
2608    #[cfg(target_os = "fuchsia")]
2609    fn signal_peer(
2610        &self,
2611        clear_mask: zx::Signals,
2612        set_mask: zx::Signals,
2613    ) -> Result<(), zx_status::Status> {
2614        use fidl::Peered;
2615        self.inner.channel().signal_peer(clear_mask, set_mask)
2616    }
2617}
2618
2619impl DoNotDisturbControlHandle {}
2620
2621#[must_use = "FIDL methods require a response to be sent"]
2622#[derive(Debug)]
2623pub struct DoNotDisturbWatchResponder {
2624    control_handle: std::mem::ManuallyDrop<DoNotDisturbControlHandle>,
2625    tx_id: u32,
2626}
2627
2628/// Set the the channel to be shutdown (see [`DoNotDisturbControlHandle::shutdown`])
2629/// if the responder is dropped without sending a response, so that the client
2630/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2631impl std::ops::Drop for DoNotDisturbWatchResponder {
2632    fn drop(&mut self) {
2633        self.control_handle.shutdown();
2634        // Safety: drops once, never accessed again
2635        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2636    }
2637}
2638
2639impl fidl::endpoints::Responder for DoNotDisturbWatchResponder {
2640    type ControlHandle = DoNotDisturbControlHandle;
2641
2642    fn control_handle(&self) -> &DoNotDisturbControlHandle {
2643        &self.control_handle
2644    }
2645
2646    fn drop_without_shutdown(mut self) {
2647        // Safety: drops once, never accessed again due to mem::forget
2648        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2649        // Prevent Drop from running (which would shut down the channel)
2650        std::mem::forget(self);
2651    }
2652}
2653
2654impl DoNotDisturbWatchResponder {
2655    /// Sends a response to the FIDL transaction.
2656    ///
2657    /// Sets the channel to shutdown if an error occurs.
2658    pub fn send(self, mut settings: &DoNotDisturbSettings) -> Result<(), fidl::Error> {
2659        let _result = self.send_raw(settings);
2660        if _result.is_err() {
2661            self.control_handle.shutdown();
2662        }
2663        self.drop_without_shutdown();
2664        _result
2665    }
2666
2667    /// Similar to "send" but does not shutdown the channel if an error occurs.
2668    pub fn send_no_shutdown_on_err(
2669        self,
2670        mut settings: &DoNotDisturbSettings,
2671    ) -> Result<(), fidl::Error> {
2672        let _result = self.send_raw(settings);
2673        self.drop_without_shutdown();
2674        _result
2675    }
2676
2677    fn send_raw(&self, mut settings: &DoNotDisturbSettings) -> Result<(), fidl::Error> {
2678        self.control_handle.inner.send::<DoNotDisturbWatchResponse>(
2679            (settings,),
2680            self.tx_id,
2681            0x1eeae2f97a5547fb,
2682            fidl::encoding::DynamicFlags::empty(),
2683        )
2684    }
2685}
2686
2687#[must_use = "FIDL methods require a response to be sent"]
2688#[derive(Debug)]
2689pub struct DoNotDisturbSetResponder {
2690    control_handle: std::mem::ManuallyDrop<DoNotDisturbControlHandle>,
2691    tx_id: u32,
2692}
2693
2694/// Set the the channel to be shutdown (see [`DoNotDisturbControlHandle::shutdown`])
2695/// if the responder is dropped without sending a response, so that the client
2696/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2697impl std::ops::Drop for DoNotDisturbSetResponder {
2698    fn drop(&mut self) {
2699        self.control_handle.shutdown();
2700        // Safety: drops once, never accessed again
2701        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2702    }
2703}
2704
2705impl fidl::endpoints::Responder for DoNotDisturbSetResponder {
2706    type ControlHandle = DoNotDisturbControlHandle;
2707
2708    fn control_handle(&self) -> &DoNotDisturbControlHandle {
2709        &self.control_handle
2710    }
2711
2712    fn drop_without_shutdown(mut self) {
2713        // Safety: drops once, never accessed again due to mem::forget
2714        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2715        // Prevent Drop from running (which would shut down the channel)
2716        std::mem::forget(self);
2717    }
2718}
2719
2720impl DoNotDisturbSetResponder {
2721    /// Sends a response to the FIDL transaction.
2722    ///
2723    /// Sets the channel to shutdown if an error occurs.
2724    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2725        let _result = self.send_raw(result);
2726        if _result.is_err() {
2727            self.control_handle.shutdown();
2728        }
2729        self.drop_without_shutdown();
2730        _result
2731    }
2732
2733    /// Similar to "send" but does not shutdown the channel if an error occurs.
2734    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2735        let _result = self.send_raw(result);
2736        self.drop_without_shutdown();
2737        _result
2738    }
2739
2740    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2741        self.control_handle
2742            .inner
2743            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2744                result,
2745                self.tx_id,
2746                0x7fef934e7f5777b0,
2747                fidl::encoding::DynamicFlags::empty(),
2748            )
2749    }
2750}
2751
2752#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2753pub struct FactoryResetMarker;
2754
2755impl fidl::endpoints::ProtocolMarker for FactoryResetMarker {
2756    type Proxy = FactoryResetProxy;
2757    type RequestStream = FactoryResetRequestStream;
2758    #[cfg(target_os = "fuchsia")]
2759    type SynchronousProxy = FactoryResetSynchronousProxy;
2760
2761    const DEBUG_NAME: &'static str = "fuchsia.settings.FactoryReset";
2762}
2763impl fidl::endpoints::DiscoverableProtocolMarker for FactoryResetMarker {}
2764pub type FactoryResetSetResult = Result<(), Error>;
2765
2766pub trait FactoryResetProxyInterface: Send + Sync {
2767    type WatchResponseFut: std::future::Future<Output = Result<FactoryResetSettings, fidl::Error>>
2768        + Send;
2769    fn r#watch(&self) -> Self::WatchResponseFut;
2770    type SetResponseFut: std::future::Future<Output = Result<FactoryResetSetResult, fidl::Error>>
2771        + Send;
2772    fn r#set(&self, settings: &FactoryResetSettings) -> Self::SetResponseFut;
2773}
2774#[derive(Debug)]
2775#[cfg(target_os = "fuchsia")]
2776pub struct FactoryResetSynchronousProxy {
2777    client: fidl::client::sync::Client,
2778}
2779
2780#[cfg(target_os = "fuchsia")]
2781impl fidl::endpoints::SynchronousProxy for FactoryResetSynchronousProxy {
2782    type Proxy = FactoryResetProxy;
2783    type Protocol = FactoryResetMarker;
2784
2785    fn from_channel(inner: fidl::Channel) -> Self {
2786        Self::new(inner)
2787    }
2788
2789    fn into_channel(self) -> fidl::Channel {
2790        self.client.into_channel()
2791    }
2792
2793    fn as_channel(&self) -> &fidl::Channel {
2794        self.client.as_channel()
2795    }
2796}
2797
2798#[cfg(target_os = "fuchsia")]
2799impl FactoryResetSynchronousProxy {
2800    pub fn new(channel: fidl::Channel) -> Self {
2801        let protocol_name = <FactoryResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2802        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2803    }
2804
2805    pub fn into_channel(self) -> fidl::Channel {
2806        self.client.into_channel()
2807    }
2808
2809    /// Waits until an event arrives and returns it. It is safe for other
2810    /// threads to make concurrent requests while waiting for an event.
2811    pub fn wait_for_event(
2812        &self,
2813        deadline: zx::MonotonicInstant,
2814    ) -> Result<FactoryResetEvent, fidl::Error> {
2815        FactoryResetEvent::decode(self.client.wait_for_event(deadline)?)
2816    }
2817
2818    /// Notifies of a change in information about the factory reset settings.
2819    ///
2820    /// On a given connection, the first call will return the current `settings`
2821    /// value while subsequent calls will only return the new `settings` value
2822    /// upon a value change. This follows the hanging get pattern.
2823    ///
2824    /// If this call fails, it is considered a fatal error and the channel will
2825    /// be closed.
2826    pub fn r#watch(
2827        &self,
2828        ___deadline: zx::MonotonicInstant,
2829    ) -> Result<FactoryResetSettings, fidl::Error> {
2830        let _response =
2831            self.client.send_query::<fidl::encoding::EmptyPayload, FactoryResetWatchResponse>(
2832                (),
2833                0x50cfc9906eb406a1,
2834                fidl::encoding::DynamicFlags::empty(),
2835                ___deadline,
2836            )?;
2837        Ok(_response.settings)
2838    }
2839
2840    /// Sets factory reset settings. Any field not explicitly set in the table
2841    /// performs a no-op, and will not make any changes.
2842    pub fn r#set(
2843        &self,
2844        mut settings: &FactoryResetSettings,
2845        ___deadline: zx::MonotonicInstant,
2846    ) -> Result<FactoryResetSetResult, fidl::Error> {
2847        let _response = self.client.send_query::<
2848            FactoryResetSetRequest,
2849            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2850        >(
2851            (settings,),
2852            0x5b35942c1cb1eca8,
2853            fidl::encoding::DynamicFlags::empty(),
2854            ___deadline,
2855        )?;
2856        Ok(_response.map(|x| x))
2857    }
2858}
2859
2860#[derive(Debug, Clone)]
2861pub struct FactoryResetProxy {
2862    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2863}
2864
2865impl fidl::endpoints::Proxy for FactoryResetProxy {
2866    type Protocol = FactoryResetMarker;
2867
2868    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2869        Self::new(inner)
2870    }
2871
2872    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2873        self.client.into_channel().map_err(|client| Self { client })
2874    }
2875
2876    fn as_channel(&self) -> &::fidl::AsyncChannel {
2877        self.client.as_channel()
2878    }
2879}
2880
2881impl FactoryResetProxy {
2882    /// Create a new Proxy for fuchsia.settings/FactoryReset.
2883    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2884        let protocol_name = <FactoryResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2885        Self { client: fidl::client::Client::new(channel, protocol_name) }
2886    }
2887
2888    /// Get a Stream of events from the remote end of the protocol.
2889    ///
2890    /// # Panics
2891    ///
2892    /// Panics if the event stream was already taken.
2893    pub fn take_event_stream(&self) -> FactoryResetEventStream {
2894        FactoryResetEventStream { event_receiver: self.client.take_event_receiver() }
2895    }
2896
2897    /// Notifies of a change in information about the factory reset settings.
2898    ///
2899    /// On a given connection, the first call will return the current `settings`
2900    /// value while subsequent calls will only return the new `settings` value
2901    /// upon a value change. This follows the hanging get pattern.
2902    ///
2903    /// If this call fails, it is considered a fatal error and the channel will
2904    /// be closed.
2905    pub fn r#watch(
2906        &self,
2907    ) -> fidl::client::QueryResponseFut<
2908        FactoryResetSettings,
2909        fidl::encoding::DefaultFuchsiaResourceDialect,
2910    > {
2911        FactoryResetProxyInterface::r#watch(self)
2912    }
2913
2914    /// Sets factory reset settings. Any field not explicitly set in the table
2915    /// performs a no-op, and will not make any changes.
2916    pub fn r#set(
2917        &self,
2918        mut settings: &FactoryResetSettings,
2919    ) -> fidl::client::QueryResponseFut<
2920        FactoryResetSetResult,
2921        fidl::encoding::DefaultFuchsiaResourceDialect,
2922    > {
2923        FactoryResetProxyInterface::r#set(self, settings)
2924    }
2925}
2926
2927impl FactoryResetProxyInterface for FactoryResetProxy {
2928    type WatchResponseFut = fidl::client::QueryResponseFut<
2929        FactoryResetSettings,
2930        fidl::encoding::DefaultFuchsiaResourceDialect,
2931    >;
2932    fn r#watch(&self) -> Self::WatchResponseFut {
2933        fn _decode(
2934            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2935        ) -> Result<FactoryResetSettings, fidl::Error> {
2936            let _response = fidl::client::decode_transaction_body::<
2937                FactoryResetWatchResponse,
2938                fidl::encoding::DefaultFuchsiaResourceDialect,
2939                0x50cfc9906eb406a1,
2940            >(_buf?)?;
2941            Ok(_response.settings)
2942        }
2943        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, FactoryResetSettings>(
2944            (),
2945            0x50cfc9906eb406a1,
2946            fidl::encoding::DynamicFlags::empty(),
2947            _decode,
2948        )
2949    }
2950
2951    type SetResponseFut = fidl::client::QueryResponseFut<
2952        FactoryResetSetResult,
2953        fidl::encoding::DefaultFuchsiaResourceDialect,
2954    >;
2955    fn r#set(&self, mut settings: &FactoryResetSettings) -> Self::SetResponseFut {
2956        fn _decode(
2957            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2958        ) -> Result<FactoryResetSetResult, fidl::Error> {
2959            let _response = fidl::client::decode_transaction_body::<
2960                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2961                fidl::encoding::DefaultFuchsiaResourceDialect,
2962                0x5b35942c1cb1eca8,
2963            >(_buf?)?;
2964            Ok(_response.map(|x| x))
2965        }
2966        self.client.send_query_and_decode::<FactoryResetSetRequest, FactoryResetSetResult>(
2967            (settings,),
2968            0x5b35942c1cb1eca8,
2969            fidl::encoding::DynamicFlags::empty(),
2970            _decode,
2971        )
2972    }
2973}
2974
2975pub struct FactoryResetEventStream {
2976    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2977}
2978
2979impl std::marker::Unpin for FactoryResetEventStream {}
2980
2981impl futures::stream::FusedStream for FactoryResetEventStream {
2982    fn is_terminated(&self) -> bool {
2983        self.event_receiver.is_terminated()
2984    }
2985}
2986
2987impl futures::Stream for FactoryResetEventStream {
2988    type Item = Result<FactoryResetEvent, fidl::Error>;
2989
2990    fn poll_next(
2991        mut self: std::pin::Pin<&mut Self>,
2992        cx: &mut std::task::Context<'_>,
2993    ) -> std::task::Poll<Option<Self::Item>> {
2994        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2995            &mut self.event_receiver,
2996            cx
2997        )?) {
2998            Some(buf) => std::task::Poll::Ready(Some(FactoryResetEvent::decode(buf))),
2999            None => std::task::Poll::Ready(None),
3000        }
3001    }
3002}
3003
3004#[derive(Debug)]
3005pub enum FactoryResetEvent {}
3006
3007impl FactoryResetEvent {
3008    /// Decodes a message buffer as a [`FactoryResetEvent`].
3009    fn decode(
3010        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3011    ) -> Result<FactoryResetEvent, fidl::Error> {
3012        let (bytes, _handles) = buf.split_mut();
3013        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3014        debug_assert_eq!(tx_header.tx_id, 0);
3015        match tx_header.ordinal {
3016            _ => Err(fidl::Error::UnknownOrdinal {
3017                ordinal: tx_header.ordinal,
3018                protocol_name: <FactoryResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3019            }),
3020        }
3021    }
3022}
3023
3024/// A Stream of incoming requests for fuchsia.settings/FactoryReset.
3025pub struct FactoryResetRequestStream {
3026    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3027    is_terminated: bool,
3028}
3029
3030impl std::marker::Unpin for FactoryResetRequestStream {}
3031
3032impl futures::stream::FusedStream for FactoryResetRequestStream {
3033    fn is_terminated(&self) -> bool {
3034        self.is_terminated
3035    }
3036}
3037
3038impl fidl::endpoints::RequestStream for FactoryResetRequestStream {
3039    type Protocol = FactoryResetMarker;
3040    type ControlHandle = FactoryResetControlHandle;
3041
3042    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3043        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3044    }
3045
3046    fn control_handle(&self) -> Self::ControlHandle {
3047        FactoryResetControlHandle { inner: self.inner.clone() }
3048    }
3049
3050    fn into_inner(
3051        self,
3052    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3053    {
3054        (self.inner, self.is_terminated)
3055    }
3056
3057    fn from_inner(
3058        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3059        is_terminated: bool,
3060    ) -> Self {
3061        Self { inner, is_terminated }
3062    }
3063}
3064
3065impl futures::Stream for FactoryResetRequestStream {
3066    type Item = Result<FactoryResetRequest, fidl::Error>;
3067
3068    fn poll_next(
3069        mut self: std::pin::Pin<&mut Self>,
3070        cx: &mut std::task::Context<'_>,
3071    ) -> std::task::Poll<Option<Self::Item>> {
3072        let this = &mut *self;
3073        if this.inner.check_shutdown(cx) {
3074            this.is_terminated = true;
3075            return std::task::Poll::Ready(None);
3076        }
3077        if this.is_terminated {
3078            panic!("polled FactoryResetRequestStream after completion");
3079        }
3080        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3081            |bytes, handles| {
3082                match this.inner.channel().read_etc(cx, bytes, handles) {
3083                    std::task::Poll::Ready(Ok(())) => {}
3084                    std::task::Poll::Pending => return std::task::Poll::Pending,
3085                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3086                        this.is_terminated = true;
3087                        return std::task::Poll::Ready(None);
3088                    }
3089                    std::task::Poll::Ready(Err(e)) => {
3090                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3091                            e.into(),
3092                        ))))
3093                    }
3094                }
3095
3096                // A message has been received from the channel
3097                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3098
3099                std::task::Poll::Ready(Some(match header.ordinal {
3100                    0x50cfc9906eb406a1 => {
3101                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3102                        let mut req = fidl::new_empty!(
3103                            fidl::encoding::EmptyPayload,
3104                            fidl::encoding::DefaultFuchsiaResourceDialect
3105                        );
3106                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3107                        let control_handle =
3108                            FactoryResetControlHandle { inner: this.inner.clone() };
3109                        Ok(FactoryResetRequest::Watch {
3110                            responder: FactoryResetWatchResponder {
3111                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3112                                tx_id: header.tx_id,
3113                            },
3114                        })
3115                    }
3116                    0x5b35942c1cb1eca8 => {
3117                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3118                        let mut req = fidl::new_empty!(
3119                            FactoryResetSetRequest,
3120                            fidl::encoding::DefaultFuchsiaResourceDialect
3121                        );
3122                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryResetSetRequest>(&header, _body_bytes, handles, &mut req)?;
3123                        let control_handle =
3124                            FactoryResetControlHandle { inner: this.inner.clone() };
3125                        Ok(FactoryResetRequest::Set {
3126                            settings: req.settings,
3127
3128                            responder: FactoryResetSetResponder {
3129                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3130                                tx_id: header.tx_id,
3131                            },
3132                        })
3133                    }
3134                    _ => Err(fidl::Error::UnknownOrdinal {
3135                        ordinal: header.ordinal,
3136                        protocol_name:
3137                            <FactoryResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3138                    }),
3139                }))
3140            },
3141        )
3142    }
3143}
3144
3145/// Settings related to factory reset.
3146#[derive(Debug)]
3147pub enum FactoryResetRequest {
3148    /// Notifies of a change in information about the factory reset settings.
3149    ///
3150    /// On a given connection, the first call will return the current `settings`
3151    /// value while subsequent calls will only return the new `settings` value
3152    /// upon a value change. This follows the hanging get pattern.
3153    ///
3154    /// If this call fails, it is considered a fatal error and the channel will
3155    /// be closed.
3156    Watch { responder: FactoryResetWatchResponder },
3157    /// Sets factory reset settings. Any field not explicitly set in the table
3158    /// performs a no-op, and will not make any changes.
3159    Set { settings: FactoryResetSettings, responder: FactoryResetSetResponder },
3160}
3161
3162impl FactoryResetRequest {
3163    #[allow(irrefutable_let_patterns)]
3164    pub fn into_watch(self) -> Option<(FactoryResetWatchResponder)> {
3165        if let FactoryResetRequest::Watch { responder } = self {
3166            Some((responder))
3167        } else {
3168            None
3169        }
3170    }
3171
3172    #[allow(irrefutable_let_patterns)]
3173    pub fn into_set(self) -> Option<(FactoryResetSettings, FactoryResetSetResponder)> {
3174        if let FactoryResetRequest::Set { settings, responder } = self {
3175            Some((settings, responder))
3176        } else {
3177            None
3178        }
3179    }
3180
3181    /// Name of the method defined in FIDL
3182    pub fn method_name(&self) -> &'static str {
3183        match *self {
3184            FactoryResetRequest::Watch { .. } => "watch",
3185            FactoryResetRequest::Set { .. } => "set",
3186        }
3187    }
3188}
3189
3190#[derive(Debug, Clone)]
3191pub struct FactoryResetControlHandle {
3192    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3193}
3194
3195impl fidl::endpoints::ControlHandle for FactoryResetControlHandle {
3196    fn shutdown(&self) {
3197        self.inner.shutdown()
3198    }
3199    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3200        self.inner.shutdown_with_epitaph(status)
3201    }
3202
3203    fn is_closed(&self) -> bool {
3204        self.inner.channel().is_closed()
3205    }
3206    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3207        self.inner.channel().on_closed()
3208    }
3209
3210    #[cfg(target_os = "fuchsia")]
3211    fn signal_peer(
3212        &self,
3213        clear_mask: zx::Signals,
3214        set_mask: zx::Signals,
3215    ) -> Result<(), zx_status::Status> {
3216        use fidl::Peered;
3217        self.inner.channel().signal_peer(clear_mask, set_mask)
3218    }
3219}
3220
3221impl FactoryResetControlHandle {}
3222
3223#[must_use = "FIDL methods require a response to be sent"]
3224#[derive(Debug)]
3225pub struct FactoryResetWatchResponder {
3226    control_handle: std::mem::ManuallyDrop<FactoryResetControlHandle>,
3227    tx_id: u32,
3228}
3229
3230/// Set the the channel to be shutdown (see [`FactoryResetControlHandle::shutdown`])
3231/// if the responder is dropped without sending a response, so that the client
3232/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3233impl std::ops::Drop for FactoryResetWatchResponder {
3234    fn drop(&mut self) {
3235        self.control_handle.shutdown();
3236        // Safety: drops once, never accessed again
3237        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3238    }
3239}
3240
3241impl fidl::endpoints::Responder for FactoryResetWatchResponder {
3242    type ControlHandle = FactoryResetControlHandle;
3243
3244    fn control_handle(&self) -> &FactoryResetControlHandle {
3245        &self.control_handle
3246    }
3247
3248    fn drop_without_shutdown(mut self) {
3249        // Safety: drops once, never accessed again due to mem::forget
3250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3251        // Prevent Drop from running (which would shut down the channel)
3252        std::mem::forget(self);
3253    }
3254}
3255
3256impl FactoryResetWatchResponder {
3257    /// Sends a response to the FIDL transaction.
3258    ///
3259    /// Sets the channel to shutdown if an error occurs.
3260    pub fn send(self, mut settings: &FactoryResetSettings) -> Result<(), fidl::Error> {
3261        let _result = self.send_raw(settings);
3262        if _result.is_err() {
3263            self.control_handle.shutdown();
3264        }
3265        self.drop_without_shutdown();
3266        _result
3267    }
3268
3269    /// Similar to "send" but does not shutdown the channel if an error occurs.
3270    pub fn send_no_shutdown_on_err(
3271        self,
3272        mut settings: &FactoryResetSettings,
3273    ) -> Result<(), fidl::Error> {
3274        let _result = self.send_raw(settings);
3275        self.drop_without_shutdown();
3276        _result
3277    }
3278
3279    fn send_raw(&self, mut settings: &FactoryResetSettings) -> Result<(), fidl::Error> {
3280        self.control_handle.inner.send::<FactoryResetWatchResponse>(
3281            (settings,),
3282            self.tx_id,
3283            0x50cfc9906eb406a1,
3284            fidl::encoding::DynamicFlags::empty(),
3285        )
3286    }
3287}
3288
3289#[must_use = "FIDL methods require a response to be sent"]
3290#[derive(Debug)]
3291pub struct FactoryResetSetResponder {
3292    control_handle: std::mem::ManuallyDrop<FactoryResetControlHandle>,
3293    tx_id: u32,
3294}
3295
3296/// Set the the channel to be shutdown (see [`FactoryResetControlHandle::shutdown`])
3297/// if the responder is dropped without sending a response, so that the client
3298/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3299impl std::ops::Drop for FactoryResetSetResponder {
3300    fn drop(&mut self) {
3301        self.control_handle.shutdown();
3302        // Safety: drops once, never accessed again
3303        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3304    }
3305}
3306
3307impl fidl::endpoints::Responder for FactoryResetSetResponder {
3308    type ControlHandle = FactoryResetControlHandle;
3309
3310    fn control_handle(&self) -> &FactoryResetControlHandle {
3311        &self.control_handle
3312    }
3313
3314    fn drop_without_shutdown(mut self) {
3315        // Safety: drops once, never accessed again due to mem::forget
3316        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3317        // Prevent Drop from running (which would shut down the channel)
3318        std::mem::forget(self);
3319    }
3320}
3321
3322impl FactoryResetSetResponder {
3323    /// Sends a response to the FIDL transaction.
3324    ///
3325    /// Sets the channel to shutdown if an error occurs.
3326    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3327        let _result = self.send_raw(result);
3328        if _result.is_err() {
3329            self.control_handle.shutdown();
3330        }
3331        self.drop_without_shutdown();
3332        _result
3333    }
3334
3335    /// Similar to "send" but does not shutdown the channel if an error occurs.
3336    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3337        let _result = self.send_raw(result);
3338        self.drop_without_shutdown();
3339        _result
3340    }
3341
3342    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3343        self.control_handle
3344            .inner
3345            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
3346                result,
3347                self.tx_id,
3348                0x5b35942c1cb1eca8,
3349                fidl::encoding::DynamicFlags::empty(),
3350            )
3351    }
3352}
3353
3354#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3355pub struct InputMarker;
3356
3357impl fidl::endpoints::ProtocolMarker for InputMarker {
3358    type Proxy = InputProxy;
3359    type RequestStream = InputRequestStream;
3360    #[cfg(target_os = "fuchsia")]
3361    type SynchronousProxy = InputSynchronousProxy;
3362
3363    const DEBUG_NAME: &'static str = "fuchsia.settings.Input";
3364}
3365impl fidl::endpoints::DiscoverableProtocolMarker for InputMarker {}
3366pub type InputSetResult = Result<(), Error>;
3367
3368pub trait InputProxyInterface: Send + Sync {
3369    type WatchResponseFut: std::future::Future<Output = Result<InputSettings, fidl::Error>> + Send;
3370    fn r#watch(&self) -> Self::WatchResponseFut;
3371    type SetResponseFut: std::future::Future<Output = Result<InputSetResult, fidl::Error>> + Send;
3372    fn r#set(&self, input_states: &[InputState]) -> Self::SetResponseFut;
3373}
3374#[derive(Debug)]
3375#[cfg(target_os = "fuchsia")]
3376pub struct InputSynchronousProxy {
3377    client: fidl::client::sync::Client,
3378}
3379
3380#[cfg(target_os = "fuchsia")]
3381impl fidl::endpoints::SynchronousProxy for InputSynchronousProxy {
3382    type Proxy = InputProxy;
3383    type Protocol = InputMarker;
3384
3385    fn from_channel(inner: fidl::Channel) -> Self {
3386        Self::new(inner)
3387    }
3388
3389    fn into_channel(self) -> fidl::Channel {
3390        self.client.into_channel()
3391    }
3392
3393    fn as_channel(&self) -> &fidl::Channel {
3394        self.client.as_channel()
3395    }
3396}
3397
3398#[cfg(target_os = "fuchsia")]
3399impl InputSynchronousProxy {
3400    pub fn new(channel: fidl::Channel) -> Self {
3401        let protocol_name = <InputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3402        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3403    }
3404
3405    pub fn into_channel(self) -> fidl::Channel {
3406        self.client.into_channel()
3407    }
3408
3409    /// Waits until an event arrives and returns it. It is safe for other
3410    /// threads to make concurrent requests while waiting for an event.
3411    pub fn wait_for_event(
3412        &self,
3413        deadline: zx::MonotonicInstant,
3414    ) -> Result<InputEvent, fidl::Error> {
3415        InputEvent::decode(self.client.wait_for_event(deadline)?)
3416    }
3417
3418    /// Gets the current |InputSettings|. Returns immediately on first call;
3419    /// subsequent calls return when the value changes.
3420    ///
3421    /// When any of the input devices' states change, this will return the
3422    /// full [InputSettings] object, containing the states for all the
3423    /// available input devices on the target device.
3424    ///
3425    /// To find the state of a specific input device, the devices vector
3426    /// contained in settings can be iterated through to find a specific
3427    /// [DeviceType]. If there are multiple devices of the same [DeviceType],
3428    /// the [InputDevice]'s device_name can be examined in conjunction with
3429    /// the [DeviceType] to find the desired input device. Together, the
3430    /// device_name and [DeviceType] uniquely identify an [InputDevice].
3431    ///
3432    /// If this call fails, it is considered a fatal error and the channel
3433    /// will be closed.
3434    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<InputSettings, fidl::Error> {
3435        let _response =
3436            self.client.send_query::<fidl::encoding::EmptyPayload, InputWatchResponse>(
3437                (),
3438                0x1bc41a7e0edd19c9,
3439                fidl::encoding::DynamicFlags::empty(),
3440                ___deadline,
3441            )?;
3442        Ok(_response.settings)
3443    }
3444
3445    /// Requests software input devices to set their software state. May
3446    /// not necessarily change the overall state of the device, depending on
3447    /// the hardware state. Will modify the software state of the existing
3448    /// device if a known device_name and device_type are passed. Otherwise
3449    /// it will add a new input device. Devices not included in input_states
3450    /// will not be modified.
3451    pub fn r#set(
3452        &self,
3453        mut input_states: &[InputState],
3454        ___deadline: zx::MonotonicInstant,
3455    ) -> Result<InputSetResult, fidl::Error> {
3456        let _response = self.client.send_query::<InputSetRequest, fidl::encoding::ResultType<
3457            fidl::encoding::EmptyStruct,
3458            Error,
3459        >>(
3460            (input_states,),
3461            0x2447379e693141ca,
3462            fidl::encoding::DynamicFlags::empty(),
3463            ___deadline,
3464        )?;
3465        Ok(_response.map(|x| x))
3466    }
3467}
3468
3469#[derive(Debug, Clone)]
3470pub struct InputProxy {
3471    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3472}
3473
3474impl fidl::endpoints::Proxy for InputProxy {
3475    type Protocol = InputMarker;
3476
3477    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3478        Self::new(inner)
3479    }
3480
3481    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3482        self.client.into_channel().map_err(|client| Self { client })
3483    }
3484
3485    fn as_channel(&self) -> &::fidl::AsyncChannel {
3486        self.client.as_channel()
3487    }
3488}
3489
3490impl InputProxy {
3491    /// Create a new Proxy for fuchsia.settings/Input.
3492    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3493        let protocol_name = <InputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3494        Self { client: fidl::client::Client::new(channel, protocol_name) }
3495    }
3496
3497    /// Get a Stream of events from the remote end of the protocol.
3498    ///
3499    /// # Panics
3500    ///
3501    /// Panics if the event stream was already taken.
3502    pub fn take_event_stream(&self) -> InputEventStream {
3503        InputEventStream { event_receiver: self.client.take_event_receiver() }
3504    }
3505
3506    /// Gets the current |InputSettings|. Returns immediately on first call;
3507    /// subsequent calls return when the value changes.
3508    ///
3509    /// When any of the input devices' states change, this will return the
3510    /// full [InputSettings] object, containing the states for all the
3511    /// available input devices on the target device.
3512    ///
3513    /// To find the state of a specific input device, the devices vector
3514    /// contained in settings can be iterated through to find a specific
3515    /// [DeviceType]. If there are multiple devices of the same [DeviceType],
3516    /// the [InputDevice]'s device_name can be examined in conjunction with
3517    /// the [DeviceType] to find the desired input device. Together, the
3518    /// device_name and [DeviceType] uniquely identify an [InputDevice].
3519    ///
3520    /// If this call fails, it is considered a fatal error and the channel
3521    /// will be closed.
3522    pub fn r#watch(
3523        &self,
3524    ) -> fidl::client::QueryResponseFut<InputSettings, fidl::encoding::DefaultFuchsiaResourceDialect>
3525    {
3526        InputProxyInterface::r#watch(self)
3527    }
3528
3529    /// Requests software input devices to set their software state. May
3530    /// not necessarily change the overall state of the device, depending on
3531    /// the hardware state. Will modify the software state of the existing
3532    /// device if a known device_name and device_type are passed. Otherwise
3533    /// it will add a new input device. Devices not included in input_states
3534    /// will not be modified.
3535    pub fn r#set(
3536        &self,
3537        mut input_states: &[InputState],
3538    ) -> fidl::client::QueryResponseFut<InputSetResult, fidl::encoding::DefaultFuchsiaResourceDialect>
3539    {
3540        InputProxyInterface::r#set(self, input_states)
3541    }
3542}
3543
3544impl InputProxyInterface for InputProxy {
3545    type WatchResponseFut = fidl::client::QueryResponseFut<
3546        InputSettings,
3547        fidl::encoding::DefaultFuchsiaResourceDialect,
3548    >;
3549    fn r#watch(&self) -> Self::WatchResponseFut {
3550        fn _decode(
3551            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3552        ) -> Result<InputSettings, fidl::Error> {
3553            let _response = fidl::client::decode_transaction_body::<
3554                InputWatchResponse,
3555                fidl::encoding::DefaultFuchsiaResourceDialect,
3556                0x1bc41a7e0edd19c9,
3557            >(_buf?)?;
3558            Ok(_response.settings)
3559        }
3560        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InputSettings>(
3561            (),
3562            0x1bc41a7e0edd19c9,
3563            fidl::encoding::DynamicFlags::empty(),
3564            _decode,
3565        )
3566    }
3567
3568    type SetResponseFut = fidl::client::QueryResponseFut<
3569        InputSetResult,
3570        fidl::encoding::DefaultFuchsiaResourceDialect,
3571    >;
3572    fn r#set(&self, mut input_states: &[InputState]) -> Self::SetResponseFut {
3573        fn _decode(
3574            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3575        ) -> Result<InputSetResult, fidl::Error> {
3576            let _response = fidl::client::decode_transaction_body::<
3577                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
3578                fidl::encoding::DefaultFuchsiaResourceDialect,
3579                0x2447379e693141ca,
3580            >(_buf?)?;
3581            Ok(_response.map(|x| x))
3582        }
3583        self.client.send_query_and_decode::<InputSetRequest, InputSetResult>(
3584            (input_states,),
3585            0x2447379e693141ca,
3586            fidl::encoding::DynamicFlags::empty(),
3587            _decode,
3588        )
3589    }
3590}
3591
3592pub struct InputEventStream {
3593    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3594}
3595
3596impl std::marker::Unpin for InputEventStream {}
3597
3598impl futures::stream::FusedStream for InputEventStream {
3599    fn is_terminated(&self) -> bool {
3600        self.event_receiver.is_terminated()
3601    }
3602}
3603
3604impl futures::Stream for InputEventStream {
3605    type Item = Result<InputEvent, fidl::Error>;
3606
3607    fn poll_next(
3608        mut self: std::pin::Pin<&mut Self>,
3609        cx: &mut std::task::Context<'_>,
3610    ) -> std::task::Poll<Option<Self::Item>> {
3611        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3612            &mut self.event_receiver,
3613            cx
3614        )?) {
3615            Some(buf) => std::task::Poll::Ready(Some(InputEvent::decode(buf))),
3616            None => std::task::Poll::Ready(None),
3617        }
3618    }
3619}
3620
3621#[derive(Debug)]
3622pub enum InputEvent {}
3623
3624impl InputEvent {
3625    /// Decodes a message buffer as a [`InputEvent`].
3626    fn decode(
3627        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3628    ) -> Result<InputEvent, fidl::Error> {
3629        let (bytes, _handles) = buf.split_mut();
3630        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3631        debug_assert_eq!(tx_header.tx_id, 0);
3632        match tx_header.ordinal {
3633            _ => Err(fidl::Error::UnknownOrdinal {
3634                ordinal: tx_header.ordinal,
3635                protocol_name: <InputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3636            }),
3637        }
3638    }
3639}
3640
3641/// A Stream of incoming requests for fuchsia.settings/Input.
3642pub struct InputRequestStream {
3643    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3644    is_terminated: bool,
3645}
3646
3647impl std::marker::Unpin for InputRequestStream {}
3648
3649impl futures::stream::FusedStream for InputRequestStream {
3650    fn is_terminated(&self) -> bool {
3651        self.is_terminated
3652    }
3653}
3654
3655impl fidl::endpoints::RequestStream for InputRequestStream {
3656    type Protocol = InputMarker;
3657    type ControlHandle = InputControlHandle;
3658
3659    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3660        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3661    }
3662
3663    fn control_handle(&self) -> Self::ControlHandle {
3664        InputControlHandle { inner: self.inner.clone() }
3665    }
3666
3667    fn into_inner(
3668        self,
3669    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3670    {
3671        (self.inner, self.is_terminated)
3672    }
3673
3674    fn from_inner(
3675        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3676        is_terminated: bool,
3677    ) -> Self {
3678        Self { inner, is_terminated }
3679    }
3680}
3681
3682impl futures::Stream for InputRequestStream {
3683    type Item = Result<InputRequest, fidl::Error>;
3684
3685    fn poll_next(
3686        mut self: std::pin::Pin<&mut Self>,
3687        cx: &mut std::task::Context<'_>,
3688    ) -> std::task::Poll<Option<Self::Item>> {
3689        let this = &mut *self;
3690        if this.inner.check_shutdown(cx) {
3691            this.is_terminated = true;
3692            return std::task::Poll::Ready(None);
3693        }
3694        if this.is_terminated {
3695            panic!("polled InputRequestStream after completion");
3696        }
3697        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3698            |bytes, handles| {
3699                match this.inner.channel().read_etc(cx, bytes, handles) {
3700                    std::task::Poll::Ready(Ok(())) => {}
3701                    std::task::Poll::Pending => return std::task::Poll::Pending,
3702                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3703                        this.is_terminated = true;
3704                        return std::task::Poll::Ready(None);
3705                    }
3706                    std::task::Poll::Ready(Err(e)) => {
3707                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3708                            e.into(),
3709                        ))))
3710                    }
3711                }
3712
3713                // A message has been received from the channel
3714                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3715
3716                std::task::Poll::Ready(Some(match header.ordinal {
3717                    0x1bc41a7e0edd19c9 => {
3718                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3719                        let mut req = fidl::new_empty!(
3720                            fidl::encoding::EmptyPayload,
3721                            fidl::encoding::DefaultFuchsiaResourceDialect
3722                        );
3723                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3724                        let control_handle = InputControlHandle { inner: this.inner.clone() };
3725                        Ok(InputRequest::Watch {
3726                            responder: InputWatchResponder {
3727                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3728                                tx_id: header.tx_id,
3729                            },
3730                        })
3731                    }
3732                    0x2447379e693141ca => {
3733                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3734                        let mut req = fidl::new_empty!(
3735                            InputSetRequest,
3736                            fidl::encoding::DefaultFuchsiaResourceDialect
3737                        );
3738                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputSetRequest>(&header, _body_bytes, handles, &mut req)?;
3739                        let control_handle = InputControlHandle { inner: this.inner.clone() };
3740                        Ok(InputRequest::Set {
3741                            input_states: req.input_states,
3742
3743                            responder: InputSetResponder {
3744                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3745                                tx_id: header.tx_id,
3746                            },
3747                        })
3748                    }
3749                    _ => Err(fidl::Error::UnknownOrdinal {
3750                        ordinal: header.ordinal,
3751                        protocol_name: <InputMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3752                    }),
3753                }))
3754            },
3755        )
3756    }
3757}
3758
3759/// Settings related to input to the device.
3760///
3761/// Supported SettingsEpitaph enums:
3762/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR
3763#[derive(Debug)]
3764pub enum InputRequest {
3765    /// Gets the current |InputSettings|. Returns immediately on first call;
3766    /// subsequent calls return when the value changes.
3767    ///
3768    /// When any of the input devices' states change, this will return the
3769    /// full [InputSettings] object, containing the states for all the
3770    /// available input devices on the target device.
3771    ///
3772    /// To find the state of a specific input device, the devices vector
3773    /// contained in settings can be iterated through to find a specific
3774    /// [DeviceType]. If there are multiple devices of the same [DeviceType],
3775    /// the [InputDevice]'s device_name can be examined in conjunction with
3776    /// the [DeviceType] to find the desired input device. Together, the
3777    /// device_name and [DeviceType] uniquely identify an [InputDevice].
3778    ///
3779    /// If this call fails, it is considered a fatal error and the channel
3780    /// will be closed.
3781    Watch { responder: InputWatchResponder },
3782    /// Requests software input devices to set their software state. May
3783    /// not necessarily change the overall state of the device, depending on
3784    /// the hardware state. Will modify the software state of the existing
3785    /// device if a known device_name and device_type are passed. Otherwise
3786    /// it will add a new input device. Devices not included in input_states
3787    /// will not be modified.
3788    Set { input_states: Vec<InputState>, responder: InputSetResponder },
3789}
3790
3791impl InputRequest {
3792    #[allow(irrefutable_let_patterns)]
3793    pub fn into_watch(self) -> Option<(InputWatchResponder)> {
3794        if let InputRequest::Watch { responder } = self {
3795            Some((responder))
3796        } else {
3797            None
3798        }
3799    }
3800
3801    #[allow(irrefutable_let_patterns)]
3802    pub fn into_set(self) -> Option<(Vec<InputState>, InputSetResponder)> {
3803        if let InputRequest::Set { input_states, responder } = self {
3804            Some((input_states, responder))
3805        } else {
3806            None
3807        }
3808    }
3809
3810    /// Name of the method defined in FIDL
3811    pub fn method_name(&self) -> &'static str {
3812        match *self {
3813            InputRequest::Watch { .. } => "watch",
3814            InputRequest::Set { .. } => "set",
3815        }
3816    }
3817}
3818
3819#[derive(Debug, Clone)]
3820pub struct InputControlHandle {
3821    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3822}
3823
3824impl fidl::endpoints::ControlHandle for InputControlHandle {
3825    fn shutdown(&self) {
3826        self.inner.shutdown()
3827    }
3828    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3829        self.inner.shutdown_with_epitaph(status)
3830    }
3831
3832    fn is_closed(&self) -> bool {
3833        self.inner.channel().is_closed()
3834    }
3835    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3836        self.inner.channel().on_closed()
3837    }
3838
3839    #[cfg(target_os = "fuchsia")]
3840    fn signal_peer(
3841        &self,
3842        clear_mask: zx::Signals,
3843        set_mask: zx::Signals,
3844    ) -> Result<(), zx_status::Status> {
3845        use fidl::Peered;
3846        self.inner.channel().signal_peer(clear_mask, set_mask)
3847    }
3848}
3849
3850impl InputControlHandle {}
3851
3852#[must_use = "FIDL methods require a response to be sent"]
3853#[derive(Debug)]
3854pub struct InputWatchResponder {
3855    control_handle: std::mem::ManuallyDrop<InputControlHandle>,
3856    tx_id: u32,
3857}
3858
3859/// Set the the channel to be shutdown (see [`InputControlHandle::shutdown`])
3860/// if the responder is dropped without sending a response, so that the client
3861/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3862impl std::ops::Drop for InputWatchResponder {
3863    fn drop(&mut self) {
3864        self.control_handle.shutdown();
3865        // Safety: drops once, never accessed again
3866        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3867    }
3868}
3869
3870impl fidl::endpoints::Responder for InputWatchResponder {
3871    type ControlHandle = InputControlHandle;
3872
3873    fn control_handle(&self) -> &InputControlHandle {
3874        &self.control_handle
3875    }
3876
3877    fn drop_without_shutdown(mut self) {
3878        // Safety: drops once, never accessed again due to mem::forget
3879        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3880        // Prevent Drop from running (which would shut down the channel)
3881        std::mem::forget(self);
3882    }
3883}
3884
3885impl InputWatchResponder {
3886    /// Sends a response to the FIDL transaction.
3887    ///
3888    /// Sets the channel to shutdown if an error occurs.
3889    pub fn send(self, mut settings: &InputSettings) -> Result<(), fidl::Error> {
3890        let _result = self.send_raw(settings);
3891        if _result.is_err() {
3892            self.control_handle.shutdown();
3893        }
3894        self.drop_without_shutdown();
3895        _result
3896    }
3897
3898    /// Similar to "send" but does not shutdown the channel if an error occurs.
3899    pub fn send_no_shutdown_on_err(self, mut settings: &InputSettings) -> Result<(), fidl::Error> {
3900        let _result = self.send_raw(settings);
3901        self.drop_without_shutdown();
3902        _result
3903    }
3904
3905    fn send_raw(&self, mut settings: &InputSettings) -> Result<(), fidl::Error> {
3906        self.control_handle.inner.send::<InputWatchResponse>(
3907            (settings,),
3908            self.tx_id,
3909            0x1bc41a7e0edd19c9,
3910            fidl::encoding::DynamicFlags::empty(),
3911        )
3912    }
3913}
3914
3915#[must_use = "FIDL methods require a response to be sent"]
3916#[derive(Debug)]
3917pub struct InputSetResponder {
3918    control_handle: std::mem::ManuallyDrop<InputControlHandle>,
3919    tx_id: u32,
3920}
3921
3922/// Set the the channel to be shutdown (see [`InputControlHandle::shutdown`])
3923/// if the responder is dropped without sending a response, so that the client
3924/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3925impl std::ops::Drop for InputSetResponder {
3926    fn drop(&mut self) {
3927        self.control_handle.shutdown();
3928        // Safety: drops once, never accessed again
3929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3930    }
3931}
3932
3933impl fidl::endpoints::Responder for InputSetResponder {
3934    type ControlHandle = InputControlHandle;
3935
3936    fn control_handle(&self) -> &InputControlHandle {
3937        &self.control_handle
3938    }
3939
3940    fn drop_without_shutdown(mut self) {
3941        // Safety: drops once, never accessed again due to mem::forget
3942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3943        // Prevent Drop from running (which would shut down the channel)
3944        std::mem::forget(self);
3945    }
3946}
3947
3948impl InputSetResponder {
3949    /// Sends a response to the FIDL transaction.
3950    ///
3951    /// Sets the channel to shutdown if an error occurs.
3952    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3953        let _result = self.send_raw(result);
3954        if _result.is_err() {
3955            self.control_handle.shutdown();
3956        }
3957        self.drop_without_shutdown();
3958        _result
3959    }
3960
3961    /// Similar to "send" but does not shutdown the channel if an error occurs.
3962    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3963        let _result = self.send_raw(result);
3964        self.drop_without_shutdown();
3965        _result
3966    }
3967
3968    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3969        self.control_handle
3970            .inner
3971            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
3972                result,
3973                self.tx_id,
3974                0x2447379e693141ca,
3975                fidl::encoding::DynamicFlags::empty(),
3976            )
3977    }
3978}
3979
3980#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3981pub struct IntlMarker;
3982
3983impl fidl::endpoints::ProtocolMarker for IntlMarker {
3984    type Proxy = IntlProxy;
3985    type RequestStream = IntlRequestStream;
3986    #[cfg(target_os = "fuchsia")]
3987    type SynchronousProxy = IntlSynchronousProxy;
3988
3989    const DEBUG_NAME: &'static str = "fuchsia.settings.Intl";
3990}
3991impl fidl::endpoints::DiscoverableProtocolMarker for IntlMarker {}
3992pub type IntlSetResult = Result<(), Error>;
3993
3994pub trait IntlProxyInterface: Send + Sync {
3995    type WatchResponseFut: std::future::Future<Output = Result<IntlSettings, fidl::Error>> + Send;
3996    fn r#watch(&self) -> Self::WatchResponseFut;
3997    type SetResponseFut: std::future::Future<Output = Result<IntlSetResult, fidl::Error>> + Send;
3998    fn r#set(&self, settings: &IntlSettings) -> Self::SetResponseFut;
3999}
4000#[derive(Debug)]
4001#[cfg(target_os = "fuchsia")]
4002pub struct IntlSynchronousProxy {
4003    client: fidl::client::sync::Client,
4004}
4005
4006#[cfg(target_os = "fuchsia")]
4007impl fidl::endpoints::SynchronousProxy for IntlSynchronousProxy {
4008    type Proxy = IntlProxy;
4009    type Protocol = IntlMarker;
4010
4011    fn from_channel(inner: fidl::Channel) -> Self {
4012        Self::new(inner)
4013    }
4014
4015    fn into_channel(self) -> fidl::Channel {
4016        self.client.into_channel()
4017    }
4018
4019    fn as_channel(&self) -> &fidl::Channel {
4020        self.client.as_channel()
4021    }
4022}
4023
4024#[cfg(target_os = "fuchsia")]
4025impl IntlSynchronousProxy {
4026    pub fn new(channel: fidl::Channel) -> Self {
4027        let protocol_name = <IntlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4028        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4029    }
4030
4031    pub fn into_channel(self) -> fidl::Channel {
4032        self.client.into_channel()
4033    }
4034
4035    /// Waits until an event arrives and returns it. It is safe for other
4036    /// threads to make concurrent requests while waiting for an event.
4037    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<IntlEvent, fidl::Error> {
4038        IntlEvent::decode(self.client.wait_for_event(deadline)?)
4039    }
4040
4041    /// Gets the current [IntlSettings]. Returns immediately on first call;
4042    /// subsequent calls return when the value changes.
4043    ///
4044    /// If this call fails, it is considered a fatal error and the channel
4045    /// will be closed.
4046    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<IntlSettings, fidl::Error> {
4047        let _response = self.client.send_query::<fidl::encoding::EmptyPayload, IntlWatchResponse>(
4048            (),
4049            0x3c85d6b8a85ab6e3,
4050            fidl::encoding::DynamicFlags::empty(),
4051            ___deadline,
4052        )?;
4053        Ok(_response.settings)
4054    }
4055
4056    /// Sets [IntlSettings] settings. Any field not explicitly set in the table performs a
4057    /// no-op, and will not make any changes.
4058    pub fn r#set(
4059        &self,
4060        mut settings: &IntlSettings,
4061        ___deadline: zx::MonotonicInstant,
4062    ) -> Result<IntlSetResult, fidl::Error> {
4063        let _response = self.client.send_query::<IntlSetRequest, fidl::encoding::ResultType<
4064            fidl::encoding::EmptyStruct,
4065            Error,
4066        >>(
4067            (settings,),
4068            0x273014eb4d880c5a,
4069            fidl::encoding::DynamicFlags::empty(),
4070            ___deadline,
4071        )?;
4072        Ok(_response.map(|x| x))
4073    }
4074}
4075
4076#[derive(Debug, Clone)]
4077pub struct IntlProxy {
4078    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4079}
4080
4081impl fidl::endpoints::Proxy for IntlProxy {
4082    type Protocol = IntlMarker;
4083
4084    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4085        Self::new(inner)
4086    }
4087
4088    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4089        self.client.into_channel().map_err(|client| Self { client })
4090    }
4091
4092    fn as_channel(&self) -> &::fidl::AsyncChannel {
4093        self.client.as_channel()
4094    }
4095}
4096
4097impl IntlProxy {
4098    /// Create a new Proxy for fuchsia.settings/Intl.
4099    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4100        let protocol_name = <IntlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4101        Self { client: fidl::client::Client::new(channel, protocol_name) }
4102    }
4103
4104    /// Get a Stream of events from the remote end of the protocol.
4105    ///
4106    /// # Panics
4107    ///
4108    /// Panics if the event stream was already taken.
4109    pub fn take_event_stream(&self) -> IntlEventStream {
4110        IntlEventStream { event_receiver: self.client.take_event_receiver() }
4111    }
4112
4113    /// Gets the current [IntlSettings]. Returns immediately on first call;
4114    /// subsequent calls return when the value changes.
4115    ///
4116    /// If this call fails, it is considered a fatal error and the channel
4117    /// will be closed.
4118    pub fn r#watch(
4119        &self,
4120    ) -> fidl::client::QueryResponseFut<IntlSettings, fidl::encoding::DefaultFuchsiaResourceDialect>
4121    {
4122        IntlProxyInterface::r#watch(self)
4123    }
4124
4125    /// Sets [IntlSettings] settings. Any field not explicitly set in the table performs a
4126    /// no-op, and will not make any changes.
4127    pub fn r#set(
4128        &self,
4129        mut settings: &IntlSettings,
4130    ) -> fidl::client::QueryResponseFut<IntlSetResult, fidl::encoding::DefaultFuchsiaResourceDialect>
4131    {
4132        IntlProxyInterface::r#set(self, settings)
4133    }
4134}
4135
4136impl IntlProxyInterface for IntlProxy {
4137    type WatchResponseFut =
4138        fidl::client::QueryResponseFut<IntlSettings, fidl::encoding::DefaultFuchsiaResourceDialect>;
4139    fn r#watch(&self) -> Self::WatchResponseFut {
4140        fn _decode(
4141            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4142        ) -> Result<IntlSettings, fidl::Error> {
4143            let _response = fidl::client::decode_transaction_body::<
4144                IntlWatchResponse,
4145                fidl::encoding::DefaultFuchsiaResourceDialect,
4146                0x3c85d6b8a85ab6e3,
4147            >(_buf?)?;
4148            Ok(_response.settings)
4149        }
4150        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, IntlSettings>(
4151            (),
4152            0x3c85d6b8a85ab6e3,
4153            fidl::encoding::DynamicFlags::empty(),
4154            _decode,
4155        )
4156    }
4157
4158    type SetResponseFut = fidl::client::QueryResponseFut<
4159        IntlSetResult,
4160        fidl::encoding::DefaultFuchsiaResourceDialect,
4161    >;
4162    fn r#set(&self, mut settings: &IntlSettings) -> Self::SetResponseFut {
4163        fn _decode(
4164            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4165        ) -> Result<IntlSetResult, fidl::Error> {
4166            let _response = fidl::client::decode_transaction_body::<
4167                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
4168                fidl::encoding::DefaultFuchsiaResourceDialect,
4169                0x273014eb4d880c5a,
4170            >(_buf?)?;
4171            Ok(_response.map(|x| x))
4172        }
4173        self.client.send_query_and_decode::<IntlSetRequest, IntlSetResult>(
4174            (settings,),
4175            0x273014eb4d880c5a,
4176            fidl::encoding::DynamicFlags::empty(),
4177            _decode,
4178        )
4179    }
4180}
4181
4182pub struct IntlEventStream {
4183    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4184}
4185
4186impl std::marker::Unpin for IntlEventStream {}
4187
4188impl futures::stream::FusedStream for IntlEventStream {
4189    fn is_terminated(&self) -> bool {
4190        self.event_receiver.is_terminated()
4191    }
4192}
4193
4194impl futures::Stream for IntlEventStream {
4195    type Item = Result<IntlEvent, fidl::Error>;
4196
4197    fn poll_next(
4198        mut self: std::pin::Pin<&mut Self>,
4199        cx: &mut std::task::Context<'_>,
4200    ) -> std::task::Poll<Option<Self::Item>> {
4201        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4202            &mut self.event_receiver,
4203            cx
4204        )?) {
4205            Some(buf) => std::task::Poll::Ready(Some(IntlEvent::decode(buf))),
4206            None => std::task::Poll::Ready(None),
4207        }
4208    }
4209}
4210
4211#[derive(Debug)]
4212pub enum IntlEvent {}
4213
4214impl IntlEvent {
4215    /// Decodes a message buffer as a [`IntlEvent`].
4216    fn decode(
4217        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4218    ) -> Result<IntlEvent, fidl::Error> {
4219        let (bytes, _handles) = buf.split_mut();
4220        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4221        debug_assert_eq!(tx_header.tx_id, 0);
4222        match tx_header.ordinal {
4223            _ => Err(fidl::Error::UnknownOrdinal {
4224                ordinal: tx_header.ordinal,
4225                protocol_name: <IntlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4226            }),
4227        }
4228    }
4229}
4230
4231/// A Stream of incoming requests for fuchsia.settings/Intl.
4232pub struct IntlRequestStream {
4233    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4234    is_terminated: bool,
4235}
4236
4237impl std::marker::Unpin for IntlRequestStream {}
4238
4239impl futures::stream::FusedStream for IntlRequestStream {
4240    fn is_terminated(&self) -> bool {
4241        self.is_terminated
4242    }
4243}
4244
4245impl fidl::endpoints::RequestStream for IntlRequestStream {
4246    type Protocol = IntlMarker;
4247    type ControlHandle = IntlControlHandle;
4248
4249    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4250        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4251    }
4252
4253    fn control_handle(&self) -> Self::ControlHandle {
4254        IntlControlHandle { inner: self.inner.clone() }
4255    }
4256
4257    fn into_inner(
4258        self,
4259    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4260    {
4261        (self.inner, self.is_terminated)
4262    }
4263
4264    fn from_inner(
4265        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4266        is_terminated: bool,
4267    ) -> Self {
4268        Self { inner, is_terminated }
4269    }
4270}
4271
4272impl futures::Stream for IntlRequestStream {
4273    type Item = Result<IntlRequest, fidl::Error>;
4274
4275    fn poll_next(
4276        mut self: std::pin::Pin<&mut Self>,
4277        cx: &mut std::task::Context<'_>,
4278    ) -> std::task::Poll<Option<Self::Item>> {
4279        let this = &mut *self;
4280        if this.inner.check_shutdown(cx) {
4281            this.is_terminated = true;
4282            return std::task::Poll::Ready(None);
4283        }
4284        if this.is_terminated {
4285            panic!("polled IntlRequestStream after completion");
4286        }
4287        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4288            |bytes, handles| {
4289                match this.inner.channel().read_etc(cx, bytes, handles) {
4290                    std::task::Poll::Ready(Ok(())) => {}
4291                    std::task::Poll::Pending => return std::task::Poll::Pending,
4292                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4293                        this.is_terminated = true;
4294                        return std::task::Poll::Ready(None);
4295                    }
4296                    std::task::Poll::Ready(Err(e)) => {
4297                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4298                            e.into(),
4299                        ))))
4300                    }
4301                }
4302
4303                // A message has been received from the channel
4304                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4305
4306                std::task::Poll::Ready(Some(match header.ordinal {
4307                    0x3c85d6b8a85ab6e3 => {
4308                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4309                        let mut req = fidl::new_empty!(
4310                            fidl::encoding::EmptyPayload,
4311                            fidl::encoding::DefaultFuchsiaResourceDialect
4312                        );
4313                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4314                        let control_handle = IntlControlHandle { inner: this.inner.clone() };
4315                        Ok(IntlRequest::Watch {
4316                            responder: IntlWatchResponder {
4317                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4318                                tx_id: header.tx_id,
4319                            },
4320                        })
4321                    }
4322                    0x273014eb4d880c5a => {
4323                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4324                        let mut req = fidl::new_empty!(
4325                            IntlSetRequest,
4326                            fidl::encoding::DefaultFuchsiaResourceDialect
4327                        );
4328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IntlSetRequest>(&header, _body_bytes, handles, &mut req)?;
4329                        let control_handle = IntlControlHandle { inner: this.inner.clone() };
4330                        Ok(IntlRequest::Set {
4331                            settings: req.settings,
4332
4333                            responder: IntlSetResponder {
4334                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4335                                tx_id: header.tx_id,
4336                            },
4337                        })
4338                    }
4339                    _ => Err(fidl::Error::UnknownOrdinal {
4340                        ordinal: header.ordinal,
4341                        protocol_name: <IntlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4342                    }),
4343                }))
4344            },
4345        )
4346    }
4347}
4348
4349/// Settings related to internationalization such as locale, time zone, and
4350/// temperature units.
4351///
4352/// Supported SettingsEpitaph enums:
4353/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR,
4354/// FILE_READ_ERROR
4355#[derive(Debug)]
4356pub enum IntlRequest {
4357    /// Gets the current [IntlSettings]. Returns immediately on first call;
4358    /// subsequent calls return when the value changes.
4359    ///
4360    /// If this call fails, it is considered a fatal error and the channel
4361    /// will be closed.
4362    Watch { responder: IntlWatchResponder },
4363    /// Sets [IntlSettings] settings. Any field not explicitly set in the table performs a
4364    /// no-op, and will not make any changes.
4365    Set { settings: IntlSettings, responder: IntlSetResponder },
4366}
4367
4368impl IntlRequest {
4369    #[allow(irrefutable_let_patterns)]
4370    pub fn into_watch(self) -> Option<(IntlWatchResponder)> {
4371        if let IntlRequest::Watch { responder } = self {
4372            Some((responder))
4373        } else {
4374            None
4375        }
4376    }
4377
4378    #[allow(irrefutable_let_patterns)]
4379    pub fn into_set(self) -> Option<(IntlSettings, IntlSetResponder)> {
4380        if let IntlRequest::Set { settings, responder } = self {
4381            Some((settings, responder))
4382        } else {
4383            None
4384        }
4385    }
4386
4387    /// Name of the method defined in FIDL
4388    pub fn method_name(&self) -> &'static str {
4389        match *self {
4390            IntlRequest::Watch { .. } => "watch",
4391            IntlRequest::Set { .. } => "set",
4392        }
4393    }
4394}
4395
4396#[derive(Debug, Clone)]
4397pub struct IntlControlHandle {
4398    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4399}
4400
4401impl fidl::endpoints::ControlHandle for IntlControlHandle {
4402    fn shutdown(&self) {
4403        self.inner.shutdown()
4404    }
4405    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4406        self.inner.shutdown_with_epitaph(status)
4407    }
4408
4409    fn is_closed(&self) -> bool {
4410        self.inner.channel().is_closed()
4411    }
4412    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4413        self.inner.channel().on_closed()
4414    }
4415
4416    #[cfg(target_os = "fuchsia")]
4417    fn signal_peer(
4418        &self,
4419        clear_mask: zx::Signals,
4420        set_mask: zx::Signals,
4421    ) -> Result<(), zx_status::Status> {
4422        use fidl::Peered;
4423        self.inner.channel().signal_peer(clear_mask, set_mask)
4424    }
4425}
4426
4427impl IntlControlHandle {}
4428
4429#[must_use = "FIDL methods require a response to be sent"]
4430#[derive(Debug)]
4431pub struct IntlWatchResponder {
4432    control_handle: std::mem::ManuallyDrop<IntlControlHandle>,
4433    tx_id: u32,
4434}
4435
4436/// Set the the channel to be shutdown (see [`IntlControlHandle::shutdown`])
4437/// if the responder is dropped without sending a response, so that the client
4438/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4439impl std::ops::Drop for IntlWatchResponder {
4440    fn drop(&mut self) {
4441        self.control_handle.shutdown();
4442        // Safety: drops once, never accessed again
4443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4444    }
4445}
4446
4447impl fidl::endpoints::Responder for IntlWatchResponder {
4448    type ControlHandle = IntlControlHandle;
4449
4450    fn control_handle(&self) -> &IntlControlHandle {
4451        &self.control_handle
4452    }
4453
4454    fn drop_without_shutdown(mut self) {
4455        // Safety: drops once, never accessed again due to mem::forget
4456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4457        // Prevent Drop from running (which would shut down the channel)
4458        std::mem::forget(self);
4459    }
4460}
4461
4462impl IntlWatchResponder {
4463    /// Sends a response to the FIDL transaction.
4464    ///
4465    /// Sets the channel to shutdown if an error occurs.
4466    pub fn send(self, mut settings: &IntlSettings) -> Result<(), fidl::Error> {
4467        let _result = self.send_raw(settings);
4468        if _result.is_err() {
4469            self.control_handle.shutdown();
4470        }
4471        self.drop_without_shutdown();
4472        _result
4473    }
4474
4475    /// Similar to "send" but does not shutdown the channel if an error occurs.
4476    pub fn send_no_shutdown_on_err(self, mut settings: &IntlSettings) -> Result<(), fidl::Error> {
4477        let _result = self.send_raw(settings);
4478        self.drop_without_shutdown();
4479        _result
4480    }
4481
4482    fn send_raw(&self, mut settings: &IntlSettings) -> Result<(), fidl::Error> {
4483        self.control_handle.inner.send::<IntlWatchResponse>(
4484            (settings,),
4485            self.tx_id,
4486            0x3c85d6b8a85ab6e3,
4487            fidl::encoding::DynamicFlags::empty(),
4488        )
4489    }
4490}
4491
4492#[must_use = "FIDL methods require a response to be sent"]
4493#[derive(Debug)]
4494pub struct IntlSetResponder {
4495    control_handle: std::mem::ManuallyDrop<IntlControlHandle>,
4496    tx_id: u32,
4497}
4498
4499/// Set the the channel to be shutdown (see [`IntlControlHandle::shutdown`])
4500/// if the responder is dropped without sending a response, so that the client
4501/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4502impl std::ops::Drop for IntlSetResponder {
4503    fn drop(&mut self) {
4504        self.control_handle.shutdown();
4505        // Safety: drops once, never accessed again
4506        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4507    }
4508}
4509
4510impl fidl::endpoints::Responder for IntlSetResponder {
4511    type ControlHandle = IntlControlHandle;
4512
4513    fn control_handle(&self) -> &IntlControlHandle {
4514        &self.control_handle
4515    }
4516
4517    fn drop_without_shutdown(mut self) {
4518        // Safety: drops once, never accessed again due to mem::forget
4519        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4520        // Prevent Drop from running (which would shut down the channel)
4521        std::mem::forget(self);
4522    }
4523}
4524
4525impl IntlSetResponder {
4526    /// Sends a response to the FIDL transaction.
4527    ///
4528    /// Sets the channel to shutdown if an error occurs.
4529    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4530        let _result = self.send_raw(result);
4531        if _result.is_err() {
4532            self.control_handle.shutdown();
4533        }
4534        self.drop_without_shutdown();
4535        _result
4536    }
4537
4538    /// Similar to "send" but does not shutdown the channel if an error occurs.
4539    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4540        let _result = self.send_raw(result);
4541        self.drop_without_shutdown();
4542        _result
4543    }
4544
4545    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4546        self.control_handle
4547            .inner
4548            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
4549                result,
4550                self.tx_id,
4551                0x273014eb4d880c5a,
4552                fidl::encoding::DynamicFlags::empty(),
4553            )
4554    }
4555}
4556
4557#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4558pub struct KeyboardMarker;
4559
4560impl fidl::endpoints::ProtocolMarker for KeyboardMarker {
4561    type Proxy = KeyboardProxy;
4562    type RequestStream = KeyboardRequestStream;
4563    #[cfg(target_os = "fuchsia")]
4564    type SynchronousProxy = KeyboardSynchronousProxy;
4565
4566    const DEBUG_NAME: &'static str = "fuchsia.settings.Keyboard";
4567}
4568impl fidl::endpoints::DiscoverableProtocolMarker for KeyboardMarker {}
4569
4570pub trait KeyboardProxyInterface: Send + Sync {
4571    type SetResponseFut: std::future::Future<Output = Result<KeyboardSetSetResult, fidl::Error>>
4572        + Send;
4573    fn r#set(&self, settings: &KeyboardSettings) -> Self::SetResponseFut;
4574    type WatchResponseFut: std::future::Future<Output = Result<KeyboardSettings, fidl::Error>>
4575        + Send;
4576    fn r#watch(&self) -> Self::WatchResponseFut;
4577}
4578#[derive(Debug)]
4579#[cfg(target_os = "fuchsia")]
4580pub struct KeyboardSynchronousProxy {
4581    client: fidl::client::sync::Client,
4582}
4583
4584#[cfg(target_os = "fuchsia")]
4585impl fidl::endpoints::SynchronousProxy for KeyboardSynchronousProxy {
4586    type Proxy = KeyboardProxy;
4587    type Protocol = KeyboardMarker;
4588
4589    fn from_channel(inner: fidl::Channel) -> Self {
4590        Self::new(inner)
4591    }
4592
4593    fn into_channel(self) -> fidl::Channel {
4594        self.client.into_channel()
4595    }
4596
4597    fn as_channel(&self) -> &fidl::Channel {
4598        self.client.as_channel()
4599    }
4600}
4601
4602#[cfg(target_os = "fuchsia")]
4603impl KeyboardSynchronousProxy {
4604    pub fn new(channel: fidl::Channel) -> Self {
4605        let protocol_name = <KeyboardMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4606        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4607    }
4608
4609    pub fn into_channel(self) -> fidl::Channel {
4610        self.client.into_channel()
4611    }
4612
4613    /// Waits until an event arrives and returns it. It is safe for other
4614    /// threads to make concurrent requests while waiting for an event.
4615    pub fn wait_for_event(
4616        &self,
4617        deadline: zx::MonotonicInstant,
4618    ) -> Result<KeyboardEvent, fidl::Error> {
4619        KeyboardEvent::decode(self.client.wait_for_event(deadline)?)
4620    }
4621
4622    /// Setting protocol: if a field is left unset, it is not modified.
4623    /// To clear a field, set it to its type's "zero" value.
4624    pub fn r#set(
4625        &self,
4626        mut settings: &KeyboardSettings,
4627        ___deadline: zx::MonotonicInstant,
4628    ) -> Result<KeyboardSetSetResult, fidl::Error> {
4629        let _response = self.client.send_query::<
4630            KeyboardSetSetRequest,
4631            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
4632        >(
4633            (settings,),
4634            0x691f4493d263c843,
4635            fidl::encoding::DynamicFlags::empty(),
4636            ___deadline,
4637        )?;
4638        Ok(_response.map(|x| x))
4639    }
4640
4641    /// The Watch protocol is the same as in the other `fuchsia.settings.*` protocols.
4642    ///
4643    /// Returns immediately on first call; on subsequent calls it blocks until the settings
4644    /// change, and then returns following the "hanging get" pattern.
4645    pub fn r#watch(
4646        &self,
4647        ___deadline: zx::MonotonicInstant,
4648    ) -> Result<KeyboardSettings, fidl::Error> {
4649        let _response =
4650            self.client.send_query::<fidl::encoding::EmptyPayload, KeyboardWatchWatchResponse>(
4651                (),
4652                0x357f6213b3a54527,
4653                fidl::encoding::DynamicFlags::empty(),
4654                ___deadline,
4655            )?;
4656        Ok(_response.settings)
4657    }
4658}
4659
4660#[derive(Debug, Clone)]
4661pub struct KeyboardProxy {
4662    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4663}
4664
4665impl fidl::endpoints::Proxy for KeyboardProxy {
4666    type Protocol = KeyboardMarker;
4667
4668    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4669        Self::new(inner)
4670    }
4671
4672    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4673        self.client.into_channel().map_err(|client| Self { client })
4674    }
4675
4676    fn as_channel(&self) -> &::fidl::AsyncChannel {
4677        self.client.as_channel()
4678    }
4679}
4680
4681impl KeyboardProxy {
4682    /// Create a new Proxy for fuchsia.settings/Keyboard.
4683    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4684        let protocol_name = <KeyboardMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4685        Self { client: fidl::client::Client::new(channel, protocol_name) }
4686    }
4687
4688    /// Get a Stream of events from the remote end of the protocol.
4689    ///
4690    /// # Panics
4691    ///
4692    /// Panics if the event stream was already taken.
4693    pub fn take_event_stream(&self) -> KeyboardEventStream {
4694        KeyboardEventStream { event_receiver: self.client.take_event_receiver() }
4695    }
4696
4697    /// Setting protocol: if a field is left unset, it is not modified.
4698    /// To clear a field, set it to its type's "zero" value.
4699    pub fn r#set(
4700        &self,
4701        mut settings: &KeyboardSettings,
4702    ) -> fidl::client::QueryResponseFut<
4703        KeyboardSetSetResult,
4704        fidl::encoding::DefaultFuchsiaResourceDialect,
4705    > {
4706        KeyboardProxyInterface::r#set(self, settings)
4707    }
4708
4709    /// The Watch protocol is the same as in the other `fuchsia.settings.*` protocols.
4710    ///
4711    /// Returns immediately on first call; on subsequent calls it blocks until the settings
4712    /// change, and then returns following the "hanging get" pattern.
4713    pub fn r#watch(
4714        &self,
4715    ) -> fidl::client::QueryResponseFut<
4716        KeyboardSettings,
4717        fidl::encoding::DefaultFuchsiaResourceDialect,
4718    > {
4719        KeyboardProxyInterface::r#watch(self)
4720    }
4721}
4722
4723impl KeyboardProxyInterface for KeyboardProxy {
4724    type SetResponseFut = fidl::client::QueryResponseFut<
4725        KeyboardSetSetResult,
4726        fidl::encoding::DefaultFuchsiaResourceDialect,
4727    >;
4728    fn r#set(&self, mut settings: &KeyboardSettings) -> Self::SetResponseFut {
4729        fn _decode(
4730            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4731        ) -> Result<KeyboardSetSetResult, fidl::Error> {
4732            let _response = fidl::client::decode_transaction_body::<
4733                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
4734                fidl::encoding::DefaultFuchsiaResourceDialect,
4735                0x691f4493d263c843,
4736            >(_buf?)?;
4737            Ok(_response.map(|x| x))
4738        }
4739        self.client.send_query_and_decode::<KeyboardSetSetRequest, KeyboardSetSetResult>(
4740            (settings,),
4741            0x691f4493d263c843,
4742            fidl::encoding::DynamicFlags::empty(),
4743            _decode,
4744        )
4745    }
4746
4747    type WatchResponseFut = fidl::client::QueryResponseFut<
4748        KeyboardSettings,
4749        fidl::encoding::DefaultFuchsiaResourceDialect,
4750    >;
4751    fn r#watch(&self) -> Self::WatchResponseFut {
4752        fn _decode(
4753            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4754        ) -> Result<KeyboardSettings, fidl::Error> {
4755            let _response = fidl::client::decode_transaction_body::<
4756                KeyboardWatchWatchResponse,
4757                fidl::encoding::DefaultFuchsiaResourceDialect,
4758                0x357f6213b3a54527,
4759            >(_buf?)?;
4760            Ok(_response.settings)
4761        }
4762        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, KeyboardSettings>(
4763            (),
4764            0x357f6213b3a54527,
4765            fidl::encoding::DynamicFlags::empty(),
4766            _decode,
4767        )
4768    }
4769}
4770
4771pub struct KeyboardEventStream {
4772    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4773}
4774
4775impl std::marker::Unpin for KeyboardEventStream {}
4776
4777impl futures::stream::FusedStream for KeyboardEventStream {
4778    fn is_terminated(&self) -> bool {
4779        self.event_receiver.is_terminated()
4780    }
4781}
4782
4783impl futures::Stream for KeyboardEventStream {
4784    type Item = Result<KeyboardEvent, fidl::Error>;
4785
4786    fn poll_next(
4787        mut self: std::pin::Pin<&mut Self>,
4788        cx: &mut std::task::Context<'_>,
4789    ) -> std::task::Poll<Option<Self::Item>> {
4790        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4791            &mut self.event_receiver,
4792            cx
4793        )?) {
4794            Some(buf) => std::task::Poll::Ready(Some(KeyboardEvent::decode(buf))),
4795            None => std::task::Poll::Ready(None),
4796        }
4797    }
4798}
4799
4800#[derive(Debug)]
4801pub enum KeyboardEvent {}
4802
4803impl KeyboardEvent {
4804    /// Decodes a message buffer as a [`KeyboardEvent`].
4805    fn decode(
4806        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4807    ) -> Result<KeyboardEvent, fidl::Error> {
4808        let (bytes, _handles) = buf.split_mut();
4809        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4810        debug_assert_eq!(tx_header.tx_id, 0);
4811        match tx_header.ordinal {
4812            _ => Err(fidl::Error::UnknownOrdinal {
4813                ordinal: tx_header.ordinal,
4814                protocol_name: <KeyboardMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4815            }),
4816        }
4817    }
4818}
4819
4820/// A Stream of incoming requests for fuchsia.settings/Keyboard.
4821pub struct KeyboardRequestStream {
4822    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4823    is_terminated: bool,
4824}
4825
4826impl std::marker::Unpin for KeyboardRequestStream {}
4827
4828impl futures::stream::FusedStream for KeyboardRequestStream {
4829    fn is_terminated(&self) -> bool {
4830        self.is_terminated
4831    }
4832}
4833
4834impl fidl::endpoints::RequestStream for KeyboardRequestStream {
4835    type Protocol = KeyboardMarker;
4836    type ControlHandle = KeyboardControlHandle;
4837
4838    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4839        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4840    }
4841
4842    fn control_handle(&self) -> Self::ControlHandle {
4843        KeyboardControlHandle { inner: self.inner.clone() }
4844    }
4845
4846    fn into_inner(
4847        self,
4848    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4849    {
4850        (self.inner, self.is_terminated)
4851    }
4852
4853    fn from_inner(
4854        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4855        is_terminated: bool,
4856    ) -> Self {
4857        Self { inner, is_terminated }
4858    }
4859}
4860
4861impl futures::Stream for KeyboardRequestStream {
4862    type Item = Result<KeyboardRequest, fidl::Error>;
4863
4864    fn poll_next(
4865        mut self: std::pin::Pin<&mut Self>,
4866        cx: &mut std::task::Context<'_>,
4867    ) -> std::task::Poll<Option<Self::Item>> {
4868        let this = &mut *self;
4869        if this.inner.check_shutdown(cx) {
4870            this.is_terminated = true;
4871            return std::task::Poll::Ready(None);
4872        }
4873        if this.is_terminated {
4874            panic!("polled KeyboardRequestStream after completion");
4875        }
4876        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4877            |bytes, handles| {
4878                match this.inner.channel().read_etc(cx, bytes, handles) {
4879                    std::task::Poll::Ready(Ok(())) => {}
4880                    std::task::Poll::Pending => return std::task::Poll::Pending,
4881                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4882                        this.is_terminated = true;
4883                        return std::task::Poll::Ready(None);
4884                    }
4885                    std::task::Poll::Ready(Err(e)) => {
4886                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4887                            e.into(),
4888                        ))))
4889                    }
4890                }
4891
4892                // A message has been received from the channel
4893                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4894
4895                std::task::Poll::Ready(Some(match header.ordinal {
4896                    0x691f4493d263c843 => {
4897                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4898                        let mut req = fidl::new_empty!(
4899                            KeyboardSetSetRequest,
4900                            fidl::encoding::DefaultFuchsiaResourceDialect
4901                        );
4902                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<KeyboardSetSetRequest>(&header, _body_bytes, handles, &mut req)?;
4903                        let control_handle = KeyboardControlHandle { inner: this.inner.clone() };
4904                        Ok(KeyboardRequest::Set {
4905                            settings: req.settings,
4906
4907                            responder: KeyboardSetResponder {
4908                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4909                                tx_id: header.tx_id,
4910                            },
4911                        })
4912                    }
4913                    0x357f6213b3a54527 => {
4914                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4915                        let mut req = fidl::new_empty!(
4916                            fidl::encoding::EmptyPayload,
4917                            fidl::encoding::DefaultFuchsiaResourceDialect
4918                        );
4919                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4920                        let control_handle = KeyboardControlHandle { inner: this.inner.clone() };
4921                        Ok(KeyboardRequest::Watch {
4922                            responder: KeyboardWatchResponder {
4923                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4924                                tx_id: header.tx_id,
4925                            },
4926                        })
4927                    }
4928                    _ => Err(fidl::Error::UnknownOrdinal {
4929                        ordinal: header.ordinal,
4930                        protocol_name:
4931                            <KeyboardMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4932                    }),
4933                }))
4934            },
4935        )
4936    }
4937}
4938
4939/// The SetUI protocol for reading and modifying the keyboard settings.
4940#[derive(Debug)]
4941pub enum KeyboardRequest {
4942    /// Setting protocol: if a field is left unset, it is not modified.
4943    /// To clear a field, set it to its type's "zero" value.
4944    Set { settings: KeyboardSettings, responder: KeyboardSetResponder },
4945    /// The Watch protocol is the same as in the other `fuchsia.settings.*` protocols.
4946    ///
4947    /// Returns immediately on first call; on subsequent calls it blocks until the settings
4948    /// change, and then returns following the "hanging get" pattern.
4949    Watch { responder: KeyboardWatchResponder },
4950}
4951
4952impl KeyboardRequest {
4953    #[allow(irrefutable_let_patterns)]
4954    pub fn into_set(self) -> Option<(KeyboardSettings, KeyboardSetResponder)> {
4955        if let KeyboardRequest::Set { settings, responder } = self {
4956            Some((settings, responder))
4957        } else {
4958            None
4959        }
4960    }
4961
4962    #[allow(irrefutable_let_patterns)]
4963    pub fn into_watch(self) -> Option<(KeyboardWatchResponder)> {
4964        if let KeyboardRequest::Watch { responder } = self {
4965            Some((responder))
4966        } else {
4967            None
4968        }
4969    }
4970
4971    /// Name of the method defined in FIDL
4972    pub fn method_name(&self) -> &'static str {
4973        match *self {
4974            KeyboardRequest::Set { .. } => "set",
4975            KeyboardRequest::Watch { .. } => "watch",
4976        }
4977    }
4978}
4979
4980#[derive(Debug, Clone)]
4981pub struct KeyboardControlHandle {
4982    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4983}
4984
4985impl fidl::endpoints::ControlHandle for KeyboardControlHandle {
4986    fn shutdown(&self) {
4987        self.inner.shutdown()
4988    }
4989    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4990        self.inner.shutdown_with_epitaph(status)
4991    }
4992
4993    fn is_closed(&self) -> bool {
4994        self.inner.channel().is_closed()
4995    }
4996    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4997        self.inner.channel().on_closed()
4998    }
4999
5000    #[cfg(target_os = "fuchsia")]
5001    fn signal_peer(
5002        &self,
5003        clear_mask: zx::Signals,
5004        set_mask: zx::Signals,
5005    ) -> Result<(), zx_status::Status> {
5006        use fidl::Peered;
5007        self.inner.channel().signal_peer(clear_mask, set_mask)
5008    }
5009}
5010
5011impl KeyboardControlHandle {}
5012
5013#[must_use = "FIDL methods require a response to be sent"]
5014#[derive(Debug)]
5015pub struct KeyboardSetResponder {
5016    control_handle: std::mem::ManuallyDrop<KeyboardControlHandle>,
5017    tx_id: u32,
5018}
5019
5020/// Set the the channel to be shutdown (see [`KeyboardControlHandle::shutdown`])
5021/// if the responder is dropped without sending a response, so that the client
5022/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5023impl std::ops::Drop for KeyboardSetResponder {
5024    fn drop(&mut self) {
5025        self.control_handle.shutdown();
5026        // Safety: drops once, never accessed again
5027        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5028    }
5029}
5030
5031impl fidl::endpoints::Responder for KeyboardSetResponder {
5032    type ControlHandle = KeyboardControlHandle;
5033
5034    fn control_handle(&self) -> &KeyboardControlHandle {
5035        &self.control_handle
5036    }
5037
5038    fn drop_without_shutdown(mut self) {
5039        // Safety: drops once, never accessed again due to mem::forget
5040        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5041        // Prevent Drop from running (which would shut down the channel)
5042        std::mem::forget(self);
5043    }
5044}
5045
5046impl KeyboardSetResponder {
5047    /// Sends a response to the FIDL transaction.
5048    ///
5049    /// Sets the channel to shutdown if an error occurs.
5050    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
5051        let _result = self.send_raw(result);
5052        if _result.is_err() {
5053            self.control_handle.shutdown();
5054        }
5055        self.drop_without_shutdown();
5056        _result
5057    }
5058
5059    /// Similar to "send" but does not shutdown the channel if an error occurs.
5060    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
5061        let _result = self.send_raw(result);
5062        self.drop_without_shutdown();
5063        _result
5064    }
5065
5066    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
5067        self.control_handle
5068            .inner
5069            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
5070                result,
5071                self.tx_id,
5072                0x691f4493d263c843,
5073                fidl::encoding::DynamicFlags::empty(),
5074            )
5075    }
5076}
5077
5078#[must_use = "FIDL methods require a response to be sent"]
5079#[derive(Debug)]
5080pub struct KeyboardWatchResponder {
5081    control_handle: std::mem::ManuallyDrop<KeyboardControlHandle>,
5082    tx_id: u32,
5083}
5084
5085/// Set the the channel to be shutdown (see [`KeyboardControlHandle::shutdown`])
5086/// if the responder is dropped without sending a response, so that the client
5087/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5088impl std::ops::Drop for KeyboardWatchResponder {
5089    fn drop(&mut self) {
5090        self.control_handle.shutdown();
5091        // Safety: drops once, never accessed again
5092        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5093    }
5094}
5095
5096impl fidl::endpoints::Responder for KeyboardWatchResponder {
5097    type ControlHandle = KeyboardControlHandle;
5098
5099    fn control_handle(&self) -> &KeyboardControlHandle {
5100        &self.control_handle
5101    }
5102
5103    fn drop_without_shutdown(mut self) {
5104        // Safety: drops once, never accessed again due to mem::forget
5105        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5106        // Prevent Drop from running (which would shut down the channel)
5107        std::mem::forget(self);
5108    }
5109}
5110
5111impl KeyboardWatchResponder {
5112    /// Sends a response to the FIDL transaction.
5113    ///
5114    /// Sets the channel to shutdown if an error occurs.
5115    pub fn send(self, mut settings: &KeyboardSettings) -> Result<(), fidl::Error> {
5116        let _result = self.send_raw(settings);
5117        if _result.is_err() {
5118            self.control_handle.shutdown();
5119        }
5120        self.drop_without_shutdown();
5121        _result
5122    }
5123
5124    /// Similar to "send" but does not shutdown the channel if an error occurs.
5125    pub fn send_no_shutdown_on_err(
5126        self,
5127        mut settings: &KeyboardSettings,
5128    ) -> Result<(), fidl::Error> {
5129        let _result = self.send_raw(settings);
5130        self.drop_without_shutdown();
5131        _result
5132    }
5133
5134    fn send_raw(&self, mut settings: &KeyboardSettings) -> Result<(), fidl::Error> {
5135        self.control_handle.inner.send::<KeyboardWatchWatchResponse>(
5136            (settings,),
5137            self.tx_id,
5138            0x357f6213b3a54527,
5139            fidl::encoding::DynamicFlags::empty(),
5140        )
5141    }
5142}
5143
5144#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5145pub struct KeyboardSetMarker;
5146
5147impl fidl::endpoints::ProtocolMarker for KeyboardSetMarker {
5148    type Proxy = KeyboardSetProxy;
5149    type RequestStream = KeyboardSetRequestStream;
5150    #[cfg(target_os = "fuchsia")]
5151    type SynchronousProxy = KeyboardSetSynchronousProxy;
5152
5153    const DEBUG_NAME: &'static str = "(anonymous) KeyboardSet";
5154}
5155pub type KeyboardSetSetResult = Result<(), Error>;
5156
5157pub trait KeyboardSetProxyInterface: Send + Sync {
5158    type SetResponseFut: std::future::Future<Output = Result<KeyboardSetSetResult, fidl::Error>>
5159        + Send;
5160    fn r#set(&self, settings: &KeyboardSettings) -> Self::SetResponseFut;
5161}
5162#[derive(Debug)]
5163#[cfg(target_os = "fuchsia")]
5164pub struct KeyboardSetSynchronousProxy {
5165    client: fidl::client::sync::Client,
5166}
5167
5168#[cfg(target_os = "fuchsia")]
5169impl fidl::endpoints::SynchronousProxy for KeyboardSetSynchronousProxy {
5170    type Proxy = KeyboardSetProxy;
5171    type Protocol = KeyboardSetMarker;
5172
5173    fn from_channel(inner: fidl::Channel) -> Self {
5174        Self::new(inner)
5175    }
5176
5177    fn into_channel(self) -> fidl::Channel {
5178        self.client.into_channel()
5179    }
5180
5181    fn as_channel(&self) -> &fidl::Channel {
5182        self.client.as_channel()
5183    }
5184}
5185
5186#[cfg(target_os = "fuchsia")]
5187impl KeyboardSetSynchronousProxy {
5188    pub fn new(channel: fidl::Channel) -> Self {
5189        let protocol_name = <KeyboardSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5190        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5191    }
5192
5193    pub fn into_channel(self) -> fidl::Channel {
5194        self.client.into_channel()
5195    }
5196
5197    /// Waits until an event arrives and returns it. It is safe for other
5198    /// threads to make concurrent requests while waiting for an event.
5199    pub fn wait_for_event(
5200        &self,
5201        deadline: zx::MonotonicInstant,
5202    ) -> Result<KeyboardSetEvent, fidl::Error> {
5203        KeyboardSetEvent::decode(self.client.wait_for_event(deadline)?)
5204    }
5205
5206    /// Setting protocol: if a field is left unset, it is not modified.
5207    /// To clear a field, set it to its type's "zero" value.
5208    pub fn r#set(
5209        &self,
5210        mut settings: &KeyboardSettings,
5211        ___deadline: zx::MonotonicInstant,
5212    ) -> Result<KeyboardSetSetResult, fidl::Error> {
5213        let _response = self.client.send_query::<
5214            KeyboardSetSetRequest,
5215            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
5216        >(
5217            (settings,),
5218            0x691f4493d263c843,
5219            fidl::encoding::DynamicFlags::empty(),
5220            ___deadline,
5221        )?;
5222        Ok(_response.map(|x| x))
5223    }
5224}
5225
5226#[derive(Debug, Clone)]
5227pub struct KeyboardSetProxy {
5228    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5229}
5230
5231impl fidl::endpoints::Proxy for KeyboardSetProxy {
5232    type Protocol = KeyboardSetMarker;
5233
5234    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5235        Self::new(inner)
5236    }
5237
5238    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5239        self.client.into_channel().map_err(|client| Self { client })
5240    }
5241
5242    fn as_channel(&self) -> &::fidl::AsyncChannel {
5243        self.client.as_channel()
5244    }
5245}
5246
5247impl KeyboardSetProxy {
5248    /// Create a new Proxy for fuchsia.settings/KeyboardSet.
5249    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5250        let protocol_name = <KeyboardSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5251        Self { client: fidl::client::Client::new(channel, protocol_name) }
5252    }
5253
5254    /// Get a Stream of events from the remote end of the protocol.
5255    ///
5256    /// # Panics
5257    ///
5258    /// Panics if the event stream was already taken.
5259    pub fn take_event_stream(&self) -> KeyboardSetEventStream {
5260        KeyboardSetEventStream { event_receiver: self.client.take_event_receiver() }
5261    }
5262
5263    /// Setting protocol: if a field is left unset, it is not modified.
5264    /// To clear a field, set it to its type's "zero" value.
5265    pub fn r#set(
5266        &self,
5267        mut settings: &KeyboardSettings,
5268    ) -> fidl::client::QueryResponseFut<
5269        KeyboardSetSetResult,
5270        fidl::encoding::DefaultFuchsiaResourceDialect,
5271    > {
5272        KeyboardSetProxyInterface::r#set(self, settings)
5273    }
5274}
5275
5276impl KeyboardSetProxyInterface for KeyboardSetProxy {
5277    type SetResponseFut = fidl::client::QueryResponseFut<
5278        KeyboardSetSetResult,
5279        fidl::encoding::DefaultFuchsiaResourceDialect,
5280    >;
5281    fn r#set(&self, mut settings: &KeyboardSettings) -> Self::SetResponseFut {
5282        fn _decode(
5283            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5284        ) -> Result<KeyboardSetSetResult, fidl::Error> {
5285            let _response = fidl::client::decode_transaction_body::<
5286                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
5287                fidl::encoding::DefaultFuchsiaResourceDialect,
5288                0x691f4493d263c843,
5289            >(_buf?)?;
5290            Ok(_response.map(|x| x))
5291        }
5292        self.client.send_query_and_decode::<KeyboardSetSetRequest, KeyboardSetSetResult>(
5293            (settings,),
5294            0x691f4493d263c843,
5295            fidl::encoding::DynamicFlags::empty(),
5296            _decode,
5297        )
5298    }
5299}
5300
5301pub struct KeyboardSetEventStream {
5302    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5303}
5304
5305impl std::marker::Unpin for KeyboardSetEventStream {}
5306
5307impl futures::stream::FusedStream for KeyboardSetEventStream {
5308    fn is_terminated(&self) -> bool {
5309        self.event_receiver.is_terminated()
5310    }
5311}
5312
5313impl futures::Stream for KeyboardSetEventStream {
5314    type Item = Result<KeyboardSetEvent, fidl::Error>;
5315
5316    fn poll_next(
5317        mut self: std::pin::Pin<&mut Self>,
5318        cx: &mut std::task::Context<'_>,
5319    ) -> std::task::Poll<Option<Self::Item>> {
5320        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5321            &mut self.event_receiver,
5322            cx
5323        )?) {
5324            Some(buf) => std::task::Poll::Ready(Some(KeyboardSetEvent::decode(buf))),
5325            None => std::task::Poll::Ready(None),
5326        }
5327    }
5328}
5329
5330#[derive(Debug)]
5331pub enum KeyboardSetEvent {}
5332
5333impl KeyboardSetEvent {
5334    /// Decodes a message buffer as a [`KeyboardSetEvent`].
5335    fn decode(
5336        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5337    ) -> Result<KeyboardSetEvent, fidl::Error> {
5338        let (bytes, _handles) = buf.split_mut();
5339        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5340        debug_assert_eq!(tx_header.tx_id, 0);
5341        match tx_header.ordinal {
5342            _ => Err(fidl::Error::UnknownOrdinal {
5343                ordinal: tx_header.ordinal,
5344                protocol_name: <KeyboardSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5345            }),
5346        }
5347    }
5348}
5349
5350/// A Stream of incoming requests for fuchsia.settings/KeyboardSet.
5351pub struct KeyboardSetRequestStream {
5352    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5353    is_terminated: bool,
5354}
5355
5356impl std::marker::Unpin for KeyboardSetRequestStream {}
5357
5358impl futures::stream::FusedStream for KeyboardSetRequestStream {
5359    fn is_terminated(&self) -> bool {
5360        self.is_terminated
5361    }
5362}
5363
5364impl fidl::endpoints::RequestStream for KeyboardSetRequestStream {
5365    type Protocol = KeyboardSetMarker;
5366    type ControlHandle = KeyboardSetControlHandle;
5367
5368    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5369        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5370    }
5371
5372    fn control_handle(&self) -> Self::ControlHandle {
5373        KeyboardSetControlHandle { inner: self.inner.clone() }
5374    }
5375
5376    fn into_inner(
5377        self,
5378    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5379    {
5380        (self.inner, self.is_terminated)
5381    }
5382
5383    fn from_inner(
5384        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5385        is_terminated: bool,
5386    ) -> Self {
5387        Self { inner, is_terminated }
5388    }
5389}
5390
5391impl futures::Stream for KeyboardSetRequestStream {
5392    type Item = Result<KeyboardSetRequest, fidl::Error>;
5393
5394    fn poll_next(
5395        mut self: std::pin::Pin<&mut Self>,
5396        cx: &mut std::task::Context<'_>,
5397    ) -> std::task::Poll<Option<Self::Item>> {
5398        let this = &mut *self;
5399        if this.inner.check_shutdown(cx) {
5400            this.is_terminated = true;
5401            return std::task::Poll::Ready(None);
5402        }
5403        if this.is_terminated {
5404            panic!("polled KeyboardSetRequestStream after completion");
5405        }
5406        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5407            |bytes, handles| {
5408                match this.inner.channel().read_etc(cx, bytes, handles) {
5409                    std::task::Poll::Ready(Ok(())) => {}
5410                    std::task::Poll::Pending => return std::task::Poll::Pending,
5411                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5412                        this.is_terminated = true;
5413                        return std::task::Poll::Ready(None);
5414                    }
5415                    std::task::Poll::Ready(Err(e)) => {
5416                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5417                            e.into(),
5418                        ))))
5419                    }
5420                }
5421
5422                // A message has been received from the channel
5423                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5424
5425                std::task::Poll::Ready(Some(match header.ordinal {
5426                    0x691f4493d263c843 => {
5427                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5428                        let mut req = fidl::new_empty!(
5429                            KeyboardSetSetRequest,
5430                            fidl::encoding::DefaultFuchsiaResourceDialect
5431                        );
5432                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<KeyboardSetSetRequest>(&header, _body_bytes, handles, &mut req)?;
5433                        let control_handle = KeyboardSetControlHandle { inner: this.inner.clone() };
5434                        Ok(KeyboardSetRequest::Set {
5435                            settings: req.settings,
5436
5437                            responder: KeyboardSetSetResponder {
5438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5439                                tx_id: header.tx_id,
5440                            },
5441                        })
5442                    }
5443                    _ => Err(fidl::Error::UnknownOrdinal {
5444                        ordinal: header.ordinal,
5445                        protocol_name:
5446                            <KeyboardSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5447                    }),
5448                }))
5449            },
5450        )
5451    }
5452}
5453
5454/// The mutable API for modifying the keyboard settings.
5455#[derive(Debug)]
5456pub enum KeyboardSetRequest {
5457    /// Setting protocol: if a field is left unset, it is not modified.
5458    /// To clear a field, set it to its type's "zero" value.
5459    Set { settings: KeyboardSettings, responder: KeyboardSetSetResponder },
5460}
5461
5462impl KeyboardSetRequest {
5463    #[allow(irrefutable_let_patterns)]
5464    pub fn into_set(self) -> Option<(KeyboardSettings, KeyboardSetSetResponder)> {
5465        if let KeyboardSetRequest::Set { settings, responder } = self {
5466            Some((settings, responder))
5467        } else {
5468            None
5469        }
5470    }
5471
5472    /// Name of the method defined in FIDL
5473    pub fn method_name(&self) -> &'static str {
5474        match *self {
5475            KeyboardSetRequest::Set { .. } => "set",
5476        }
5477    }
5478}
5479
5480#[derive(Debug, Clone)]
5481pub struct KeyboardSetControlHandle {
5482    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5483}
5484
5485impl fidl::endpoints::ControlHandle for KeyboardSetControlHandle {
5486    fn shutdown(&self) {
5487        self.inner.shutdown()
5488    }
5489    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5490        self.inner.shutdown_with_epitaph(status)
5491    }
5492
5493    fn is_closed(&self) -> bool {
5494        self.inner.channel().is_closed()
5495    }
5496    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5497        self.inner.channel().on_closed()
5498    }
5499
5500    #[cfg(target_os = "fuchsia")]
5501    fn signal_peer(
5502        &self,
5503        clear_mask: zx::Signals,
5504        set_mask: zx::Signals,
5505    ) -> Result<(), zx_status::Status> {
5506        use fidl::Peered;
5507        self.inner.channel().signal_peer(clear_mask, set_mask)
5508    }
5509}
5510
5511impl KeyboardSetControlHandle {}
5512
5513#[must_use = "FIDL methods require a response to be sent"]
5514#[derive(Debug)]
5515pub struct KeyboardSetSetResponder {
5516    control_handle: std::mem::ManuallyDrop<KeyboardSetControlHandle>,
5517    tx_id: u32,
5518}
5519
5520/// Set the the channel to be shutdown (see [`KeyboardSetControlHandle::shutdown`])
5521/// if the responder is dropped without sending a response, so that the client
5522/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5523impl std::ops::Drop for KeyboardSetSetResponder {
5524    fn drop(&mut self) {
5525        self.control_handle.shutdown();
5526        // Safety: drops once, never accessed again
5527        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5528    }
5529}
5530
5531impl fidl::endpoints::Responder for KeyboardSetSetResponder {
5532    type ControlHandle = KeyboardSetControlHandle;
5533
5534    fn control_handle(&self) -> &KeyboardSetControlHandle {
5535        &self.control_handle
5536    }
5537
5538    fn drop_without_shutdown(mut self) {
5539        // Safety: drops once, never accessed again due to mem::forget
5540        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5541        // Prevent Drop from running (which would shut down the channel)
5542        std::mem::forget(self);
5543    }
5544}
5545
5546impl KeyboardSetSetResponder {
5547    /// Sends a response to the FIDL transaction.
5548    ///
5549    /// Sets the channel to shutdown if an error occurs.
5550    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
5551        let _result = self.send_raw(result);
5552        if _result.is_err() {
5553            self.control_handle.shutdown();
5554        }
5555        self.drop_without_shutdown();
5556        _result
5557    }
5558
5559    /// Similar to "send" but does not shutdown the channel if an error occurs.
5560    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
5561        let _result = self.send_raw(result);
5562        self.drop_without_shutdown();
5563        _result
5564    }
5565
5566    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
5567        self.control_handle
5568            .inner
5569            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
5570                result,
5571                self.tx_id,
5572                0x691f4493d263c843,
5573                fidl::encoding::DynamicFlags::empty(),
5574            )
5575    }
5576}
5577
5578#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5579pub struct KeyboardWatchMarker;
5580
5581impl fidl::endpoints::ProtocolMarker for KeyboardWatchMarker {
5582    type Proxy = KeyboardWatchProxy;
5583    type RequestStream = KeyboardWatchRequestStream;
5584    #[cfg(target_os = "fuchsia")]
5585    type SynchronousProxy = KeyboardWatchSynchronousProxy;
5586
5587    const DEBUG_NAME: &'static str = "(anonymous) KeyboardWatch";
5588}
5589
5590pub trait KeyboardWatchProxyInterface: Send + Sync {
5591    type WatchResponseFut: std::future::Future<Output = Result<KeyboardSettings, fidl::Error>>
5592        + Send;
5593    fn r#watch(&self) -> Self::WatchResponseFut;
5594}
5595#[derive(Debug)]
5596#[cfg(target_os = "fuchsia")]
5597pub struct KeyboardWatchSynchronousProxy {
5598    client: fidl::client::sync::Client,
5599}
5600
5601#[cfg(target_os = "fuchsia")]
5602impl fidl::endpoints::SynchronousProxy for KeyboardWatchSynchronousProxy {
5603    type Proxy = KeyboardWatchProxy;
5604    type Protocol = KeyboardWatchMarker;
5605
5606    fn from_channel(inner: fidl::Channel) -> Self {
5607        Self::new(inner)
5608    }
5609
5610    fn into_channel(self) -> fidl::Channel {
5611        self.client.into_channel()
5612    }
5613
5614    fn as_channel(&self) -> &fidl::Channel {
5615        self.client.as_channel()
5616    }
5617}
5618
5619#[cfg(target_os = "fuchsia")]
5620impl KeyboardWatchSynchronousProxy {
5621    pub fn new(channel: fidl::Channel) -> Self {
5622        let protocol_name = <KeyboardWatchMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5623        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5624    }
5625
5626    pub fn into_channel(self) -> fidl::Channel {
5627        self.client.into_channel()
5628    }
5629
5630    /// Waits until an event arrives and returns it. It is safe for other
5631    /// threads to make concurrent requests while waiting for an event.
5632    pub fn wait_for_event(
5633        &self,
5634        deadline: zx::MonotonicInstant,
5635    ) -> Result<KeyboardWatchEvent, fidl::Error> {
5636        KeyboardWatchEvent::decode(self.client.wait_for_event(deadline)?)
5637    }
5638
5639    /// The Watch protocol is the same as in the other `fuchsia.settings.*` protocols.
5640    ///
5641    /// Returns immediately on first call; on subsequent calls it blocks until the settings
5642    /// change, and then returns following the "hanging get" pattern.
5643    pub fn r#watch(
5644        &self,
5645        ___deadline: zx::MonotonicInstant,
5646    ) -> Result<KeyboardSettings, fidl::Error> {
5647        let _response =
5648            self.client.send_query::<fidl::encoding::EmptyPayload, KeyboardWatchWatchResponse>(
5649                (),
5650                0x357f6213b3a54527,
5651                fidl::encoding::DynamicFlags::empty(),
5652                ___deadline,
5653            )?;
5654        Ok(_response.settings)
5655    }
5656}
5657
5658#[derive(Debug, Clone)]
5659pub struct KeyboardWatchProxy {
5660    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5661}
5662
5663impl fidl::endpoints::Proxy for KeyboardWatchProxy {
5664    type Protocol = KeyboardWatchMarker;
5665
5666    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5667        Self::new(inner)
5668    }
5669
5670    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5671        self.client.into_channel().map_err(|client| Self { client })
5672    }
5673
5674    fn as_channel(&self) -> &::fidl::AsyncChannel {
5675        self.client.as_channel()
5676    }
5677}
5678
5679impl KeyboardWatchProxy {
5680    /// Create a new Proxy for fuchsia.settings/KeyboardWatch.
5681    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5682        let protocol_name = <KeyboardWatchMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5683        Self { client: fidl::client::Client::new(channel, protocol_name) }
5684    }
5685
5686    /// Get a Stream of events from the remote end of the protocol.
5687    ///
5688    /// # Panics
5689    ///
5690    /// Panics if the event stream was already taken.
5691    pub fn take_event_stream(&self) -> KeyboardWatchEventStream {
5692        KeyboardWatchEventStream { event_receiver: self.client.take_event_receiver() }
5693    }
5694
5695    /// The Watch protocol is the same as in the other `fuchsia.settings.*` protocols.
5696    ///
5697    /// Returns immediately on first call; on subsequent calls it blocks until the settings
5698    /// change, and then returns following the "hanging get" pattern.
5699    pub fn r#watch(
5700        &self,
5701    ) -> fidl::client::QueryResponseFut<
5702        KeyboardSettings,
5703        fidl::encoding::DefaultFuchsiaResourceDialect,
5704    > {
5705        KeyboardWatchProxyInterface::r#watch(self)
5706    }
5707}
5708
5709impl KeyboardWatchProxyInterface for KeyboardWatchProxy {
5710    type WatchResponseFut = fidl::client::QueryResponseFut<
5711        KeyboardSettings,
5712        fidl::encoding::DefaultFuchsiaResourceDialect,
5713    >;
5714    fn r#watch(&self) -> Self::WatchResponseFut {
5715        fn _decode(
5716            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5717        ) -> Result<KeyboardSettings, fidl::Error> {
5718            let _response = fidl::client::decode_transaction_body::<
5719                KeyboardWatchWatchResponse,
5720                fidl::encoding::DefaultFuchsiaResourceDialect,
5721                0x357f6213b3a54527,
5722            >(_buf?)?;
5723            Ok(_response.settings)
5724        }
5725        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, KeyboardSettings>(
5726            (),
5727            0x357f6213b3a54527,
5728            fidl::encoding::DynamicFlags::empty(),
5729            _decode,
5730        )
5731    }
5732}
5733
5734pub struct KeyboardWatchEventStream {
5735    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5736}
5737
5738impl std::marker::Unpin for KeyboardWatchEventStream {}
5739
5740impl futures::stream::FusedStream for KeyboardWatchEventStream {
5741    fn is_terminated(&self) -> bool {
5742        self.event_receiver.is_terminated()
5743    }
5744}
5745
5746impl futures::Stream for KeyboardWatchEventStream {
5747    type Item = Result<KeyboardWatchEvent, fidl::Error>;
5748
5749    fn poll_next(
5750        mut self: std::pin::Pin<&mut Self>,
5751        cx: &mut std::task::Context<'_>,
5752    ) -> std::task::Poll<Option<Self::Item>> {
5753        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5754            &mut self.event_receiver,
5755            cx
5756        )?) {
5757            Some(buf) => std::task::Poll::Ready(Some(KeyboardWatchEvent::decode(buf))),
5758            None => std::task::Poll::Ready(None),
5759        }
5760    }
5761}
5762
5763#[derive(Debug)]
5764pub enum KeyboardWatchEvent {}
5765
5766impl KeyboardWatchEvent {
5767    /// Decodes a message buffer as a [`KeyboardWatchEvent`].
5768    fn decode(
5769        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5770    ) -> Result<KeyboardWatchEvent, fidl::Error> {
5771        let (bytes, _handles) = buf.split_mut();
5772        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5773        debug_assert_eq!(tx_header.tx_id, 0);
5774        match tx_header.ordinal {
5775            _ => Err(fidl::Error::UnknownOrdinal {
5776                ordinal: tx_header.ordinal,
5777                protocol_name: <KeyboardWatchMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5778            }),
5779        }
5780    }
5781}
5782
5783/// A Stream of incoming requests for fuchsia.settings/KeyboardWatch.
5784pub struct KeyboardWatchRequestStream {
5785    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5786    is_terminated: bool,
5787}
5788
5789impl std::marker::Unpin for KeyboardWatchRequestStream {}
5790
5791impl futures::stream::FusedStream for KeyboardWatchRequestStream {
5792    fn is_terminated(&self) -> bool {
5793        self.is_terminated
5794    }
5795}
5796
5797impl fidl::endpoints::RequestStream for KeyboardWatchRequestStream {
5798    type Protocol = KeyboardWatchMarker;
5799    type ControlHandle = KeyboardWatchControlHandle;
5800
5801    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5802        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5803    }
5804
5805    fn control_handle(&self) -> Self::ControlHandle {
5806        KeyboardWatchControlHandle { inner: self.inner.clone() }
5807    }
5808
5809    fn into_inner(
5810        self,
5811    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5812    {
5813        (self.inner, self.is_terminated)
5814    }
5815
5816    fn from_inner(
5817        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5818        is_terminated: bool,
5819    ) -> Self {
5820        Self { inner, is_terminated }
5821    }
5822}
5823
5824impl futures::Stream for KeyboardWatchRequestStream {
5825    type Item = Result<KeyboardWatchRequest, fidl::Error>;
5826
5827    fn poll_next(
5828        mut self: std::pin::Pin<&mut Self>,
5829        cx: &mut std::task::Context<'_>,
5830    ) -> std::task::Poll<Option<Self::Item>> {
5831        let this = &mut *self;
5832        if this.inner.check_shutdown(cx) {
5833            this.is_terminated = true;
5834            return std::task::Poll::Ready(None);
5835        }
5836        if this.is_terminated {
5837            panic!("polled KeyboardWatchRequestStream after completion");
5838        }
5839        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5840            |bytes, handles| {
5841                match this.inner.channel().read_etc(cx, bytes, handles) {
5842                    std::task::Poll::Ready(Ok(())) => {}
5843                    std::task::Poll::Pending => return std::task::Poll::Pending,
5844                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5845                        this.is_terminated = true;
5846                        return std::task::Poll::Ready(None);
5847                    }
5848                    std::task::Poll::Ready(Err(e)) => {
5849                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5850                            e.into(),
5851                        ))))
5852                    }
5853                }
5854
5855                // A message has been received from the channel
5856                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5857
5858                std::task::Poll::Ready(Some(match header.ordinal {
5859                    0x357f6213b3a54527 => {
5860                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5861                        let mut req = fidl::new_empty!(
5862                            fidl::encoding::EmptyPayload,
5863                            fidl::encoding::DefaultFuchsiaResourceDialect
5864                        );
5865                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5866                        let control_handle =
5867                            KeyboardWatchControlHandle { inner: this.inner.clone() };
5868                        Ok(KeyboardWatchRequest::Watch {
5869                            responder: KeyboardWatchWatchResponder {
5870                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5871                                tx_id: header.tx_id,
5872                            },
5873                        })
5874                    }
5875                    _ => Err(fidl::Error::UnknownOrdinal {
5876                        ordinal: header.ordinal,
5877                        protocol_name:
5878                            <KeyboardWatchMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5879                    }),
5880                }))
5881            },
5882        )
5883    }
5884}
5885
5886/// The read-only API for monitoring the changes to the keyboard settings.
5887#[derive(Debug)]
5888pub enum KeyboardWatchRequest {
5889    /// The Watch protocol is the same as in the other `fuchsia.settings.*` protocols.
5890    ///
5891    /// Returns immediately on first call; on subsequent calls it blocks until the settings
5892    /// change, and then returns following the "hanging get" pattern.
5893    Watch { responder: KeyboardWatchWatchResponder },
5894}
5895
5896impl KeyboardWatchRequest {
5897    #[allow(irrefutable_let_patterns)]
5898    pub fn into_watch(self) -> Option<(KeyboardWatchWatchResponder)> {
5899        if let KeyboardWatchRequest::Watch { responder } = self {
5900            Some((responder))
5901        } else {
5902            None
5903        }
5904    }
5905
5906    /// Name of the method defined in FIDL
5907    pub fn method_name(&self) -> &'static str {
5908        match *self {
5909            KeyboardWatchRequest::Watch { .. } => "watch",
5910        }
5911    }
5912}
5913
5914#[derive(Debug, Clone)]
5915pub struct KeyboardWatchControlHandle {
5916    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5917}
5918
5919impl fidl::endpoints::ControlHandle for KeyboardWatchControlHandle {
5920    fn shutdown(&self) {
5921        self.inner.shutdown()
5922    }
5923    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5924        self.inner.shutdown_with_epitaph(status)
5925    }
5926
5927    fn is_closed(&self) -> bool {
5928        self.inner.channel().is_closed()
5929    }
5930    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5931        self.inner.channel().on_closed()
5932    }
5933
5934    #[cfg(target_os = "fuchsia")]
5935    fn signal_peer(
5936        &self,
5937        clear_mask: zx::Signals,
5938        set_mask: zx::Signals,
5939    ) -> Result<(), zx_status::Status> {
5940        use fidl::Peered;
5941        self.inner.channel().signal_peer(clear_mask, set_mask)
5942    }
5943}
5944
5945impl KeyboardWatchControlHandle {}
5946
5947#[must_use = "FIDL methods require a response to be sent"]
5948#[derive(Debug)]
5949pub struct KeyboardWatchWatchResponder {
5950    control_handle: std::mem::ManuallyDrop<KeyboardWatchControlHandle>,
5951    tx_id: u32,
5952}
5953
5954/// Set the the channel to be shutdown (see [`KeyboardWatchControlHandle::shutdown`])
5955/// if the responder is dropped without sending a response, so that the client
5956/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5957impl std::ops::Drop for KeyboardWatchWatchResponder {
5958    fn drop(&mut self) {
5959        self.control_handle.shutdown();
5960        // Safety: drops once, never accessed again
5961        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5962    }
5963}
5964
5965impl fidl::endpoints::Responder for KeyboardWatchWatchResponder {
5966    type ControlHandle = KeyboardWatchControlHandle;
5967
5968    fn control_handle(&self) -> &KeyboardWatchControlHandle {
5969        &self.control_handle
5970    }
5971
5972    fn drop_without_shutdown(mut self) {
5973        // Safety: drops once, never accessed again due to mem::forget
5974        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5975        // Prevent Drop from running (which would shut down the channel)
5976        std::mem::forget(self);
5977    }
5978}
5979
5980impl KeyboardWatchWatchResponder {
5981    /// Sends a response to the FIDL transaction.
5982    ///
5983    /// Sets the channel to shutdown if an error occurs.
5984    pub fn send(self, mut settings: &KeyboardSettings) -> Result<(), fidl::Error> {
5985        let _result = self.send_raw(settings);
5986        if _result.is_err() {
5987            self.control_handle.shutdown();
5988        }
5989        self.drop_without_shutdown();
5990        _result
5991    }
5992
5993    /// Similar to "send" but does not shutdown the channel if an error occurs.
5994    pub fn send_no_shutdown_on_err(
5995        self,
5996        mut settings: &KeyboardSettings,
5997    ) -> Result<(), fidl::Error> {
5998        let _result = self.send_raw(settings);
5999        self.drop_without_shutdown();
6000        _result
6001    }
6002
6003    fn send_raw(&self, mut settings: &KeyboardSettings) -> Result<(), fidl::Error> {
6004        self.control_handle.inner.send::<KeyboardWatchWatchResponse>(
6005            (settings,),
6006            self.tx_id,
6007            0x357f6213b3a54527,
6008            fidl::encoding::DynamicFlags::empty(),
6009        )
6010    }
6011}
6012
6013#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6014pub struct LightMarker;
6015
6016impl fidl::endpoints::ProtocolMarker for LightMarker {
6017    type Proxy = LightProxy;
6018    type RequestStream = LightRequestStream;
6019    #[cfg(target_os = "fuchsia")]
6020    type SynchronousProxy = LightSynchronousProxy;
6021
6022    const DEBUG_NAME: &'static str = "fuchsia.settings.Light";
6023}
6024impl fidl::endpoints::DiscoverableProtocolMarker for LightMarker {}
6025pub type LightSetLightGroupValuesResult = Result<(), LightError>;
6026
6027pub trait LightProxyInterface: Send + Sync {
6028    type WatchLightGroupsResponseFut: std::future::Future<Output = Result<Vec<LightGroup>, fidl::Error>>
6029        + Send;
6030    fn r#watch_light_groups(&self) -> Self::WatchLightGroupsResponseFut;
6031    type WatchLightGroupResponseFut: std::future::Future<Output = Result<LightGroup, fidl::Error>>
6032        + Send;
6033    fn r#watch_light_group(&self, name: &str) -> Self::WatchLightGroupResponseFut;
6034    type SetLightGroupValuesResponseFut: std::future::Future<Output = Result<LightSetLightGroupValuesResult, fidl::Error>>
6035        + Send;
6036    fn r#set_light_group_values(
6037        &self,
6038        name: &str,
6039        state: &[LightState],
6040    ) -> Self::SetLightGroupValuesResponseFut;
6041}
6042#[derive(Debug)]
6043#[cfg(target_os = "fuchsia")]
6044pub struct LightSynchronousProxy {
6045    client: fidl::client::sync::Client,
6046}
6047
6048#[cfg(target_os = "fuchsia")]
6049impl fidl::endpoints::SynchronousProxy for LightSynchronousProxy {
6050    type Proxy = LightProxy;
6051    type Protocol = LightMarker;
6052
6053    fn from_channel(inner: fidl::Channel) -> Self {
6054        Self::new(inner)
6055    }
6056
6057    fn into_channel(self) -> fidl::Channel {
6058        self.client.into_channel()
6059    }
6060
6061    fn as_channel(&self) -> &fidl::Channel {
6062        self.client.as_channel()
6063    }
6064}
6065
6066#[cfg(target_os = "fuchsia")]
6067impl LightSynchronousProxy {
6068    pub fn new(channel: fidl::Channel) -> Self {
6069        let protocol_name = <LightMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6070        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6071    }
6072
6073    pub fn into_channel(self) -> fidl::Channel {
6074        self.client.into_channel()
6075    }
6076
6077    /// Waits until an event arrives and returns it. It is safe for other
6078    /// threads to make concurrent requests while waiting for an event.
6079    pub fn wait_for_event(
6080        &self,
6081        deadline: zx::MonotonicInstant,
6082    ) -> Result<LightEvent, fidl::Error> {
6083        LightEvent::decode(self.client.wait_for_event(deadline)?)
6084    }
6085
6086    /// Fetches information on the controllable light groups on the device.
6087    /// Returns immediately on first call; subsequent calls return when the
6088    /// value changes.
6089    ///
6090    /// If this call fails, it is considered a fatal error and the channel
6091    /// will be closed.
6092    pub fn r#watch_light_groups(
6093        &self,
6094        ___deadline: zx::MonotonicInstant,
6095    ) -> Result<Vec<LightGroup>, fidl::Error> {
6096        let _response =
6097            self.client.send_query::<fidl::encoding::EmptyPayload, LightWatchLightGroupsResponse>(
6098                (),
6099                0x3f506de229db5930,
6100                fidl::encoding::DynamicFlags::empty(),
6101                ___deadline,
6102            )?;
6103        Ok(_response.groups)
6104    }
6105
6106    /// Fetches information on an individual light group on the device with the
6107    /// given name. Returns immediately on first call; subsequent calls return
6108    /// when the value changes.
6109    ///
6110    /// If this call fails, it is considered a fatal error and the channel
6111    /// will be closed. If the failure is due to an invalid light group name,
6112    /// the channel will be closed with a NOT_FOUND epitaph.
6113    pub fn r#watch_light_group(
6114        &self,
6115        mut name: &str,
6116        ___deadline: zx::MonotonicInstant,
6117    ) -> Result<LightGroup, fidl::Error> {
6118        let _response =
6119            self.client.send_query::<LightWatchLightGroupRequest, LightWatchLightGroupResponse>(
6120                (name,),
6121                0x3ef0331c388d56a3,
6122                fidl::encoding::DynamicFlags::empty(),
6123                ___deadline,
6124            )?;
6125        Ok(_response.group)
6126    }
6127
6128    /// Sets the values for the lights in the group with the given name.
6129    ///
6130    /// If the provided value does not match the light group's type, this
6131    /// call will fail.
6132    ///
6133    /// The requested changes may not take immediate effect if
6134    /// the light is forced to a certain state by the device's hardware. This
6135    /// call will still succeed, but the light's value may not change.
6136    pub fn r#set_light_group_values(
6137        &self,
6138        mut name: &str,
6139        mut state: &[LightState],
6140        ___deadline: zx::MonotonicInstant,
6141    ) -> Result<LightSetLightGroupValuesResult, fidl::Error> {
6142        let _response = self.client.send_query::<
6143            LightSetLightGroupValuesRequest,
6144            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LightError>,
6145        >(
6146            (name, state,),
6147            0x15d9b62431fdf8d5,
6148            fidl::encoding::DynamicFlags::empty(),
6149            ___deadline,
6150        )?;
6151        Ok(_response.map(|x| x))
6152    }
6153}
6154
6155#[derive(Debug, Clone)]
6156pub struct LightProxy {
6157    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6158}
6159
6160impl fidl::endpoints::Proxy for LightProxy {
6161    type Protocol = LightMarker;
6162
6163    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6164        Self::new(inner)
6165    }
6166
6167    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6168        self.client.into_channel().map_err(|client| Self { client })
6169    }
6170
6171    fn as_channel(&self) -> &::fidl::AsyncChannel {
6172        self.client.as_channel()
6173    }
6174}
6175
6176impl LightProxy {
6177    /// Create a new Proxy for fuchsia.settings/Light.
6178    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6179        let protocol_name = <LightMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6180        Self { client: fidl::client::Client::new(channel, protocol_name) }
6181    }
6182
6183    /// Get a Stream of events from the remote end of the protocol.
6184    ///
6185    /// # Panics
6186    ///
6187    /// Panics if the event stream was already taken.
6188    pub fn take_event_stream(&self) -> LightEventStream {
6189        LightEventStream { event_receiver: self.client.take_event_receiver() }
6190    }
6191
6192    /// Fetches information on the controllable light groups on the device.
6193    /// Returns immediately on first call; subsequent calls return when the
6194    /// value changes.
6195    ///
6196    /// If this call fails, it is considered a fatal error and the channel
6197    /// will be closed.
6198    pub fn r#watch_light_groups(
6199        &self,
6200    ) -> fidl::client::QueryResponseFut<
6201        Vec<LightGroup>,
6202        fidl::encoding::DefaultFuchsiaResourceDialect,
6203    > {
6204        LightProxyInterface::r#watch_light_groups(self)
6205    }
6206
6207    /// Fetches information on an individual light group on the device with the
6208    /// given name. Returns immediately on first call; subsequent calls return
6209    /// when the value changes.
6210    ///
6211    /// If this call fails, it is considered a fatal error and the channel
6212    /// will be closed. If the failure is due to an invalid light group name,
6213    /// the channel will be closed with a NOT_FOUND epitaph.
6214    pub fn r#watch_light_group(
6215        &self,
6216        mut name: &str,
6217    ) -> fidl::client::QueryResponseFut<LightGroup, fidl::encoding::DefaultFuchsiaResourceDialect>
6218    {
6219        LightProxyInterface::r#watch_light_group(self, name)
6220    }
6221
6222    /// Sets the values for the lights in the group with the given name.
6223    ///
6224    /// If the provided value does not match the light group's type, this
6225    /// call will fail.
6226    ///
6227    /// The requested changes may not take immediate effect if
6228    /// the light is forced to a certain state by the device's hardware. This
6229    /// call will still succeed, but the light's value may not change.
6230    pub fn r#set_light_group_values(
6231        &self,
6232        mut name: &str,
6233        mut state: &[LightState],
6234    ) -> fidl::client::QueryResponseFut<
6235        LightSetLightGroupValuesResult,
6236        fidl::encoding::DefaultFuchsiaResourceDialect,
6237    > {
6238        LightProxyInterface::r#set_light_group_values(self, name, state)
6239    }
6240}
6241
6242impl LightProxyInterface for LightProxy {
6243    type WatchLightGroupsResponseFut = fidl::client::QueryResponseFut<
6244        Vec<LightGroup>,
6245        fidl::encoding::DefaultFuchsiaResourceDialect,
6246    >;
6247    fn r#watch_light_groups(&self) -> Self::WatchLightGroupsResponseFut {
6248        fn _decode(
6249            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6250        ) -> Result<Vec<LightGroup>, fidl::Error> {
6251            let _response = fidl::client::decode_transaction_body::<
6252                LightWatchLightGroupsResponse,
6253                fidl::encoding::DefaultFuchsiaResourceDialect,
6254                0x3f506de229db5930,
6255            >(_buf?)?;
6256            Ok(_response.groups)
6257        }
6258        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<LightGroup>>(
6259            (),
6260            0x3f506de229db5930,
6261            fidl::encoding::DynamicFlags::empty(),
6262            _decode,
6263        )
6264    }
6265
6266    type WatchLightGroupResponseFut =
6267        fidl::client::QueryResponseFut<LightGroup, fidl::encoding::DefaultFuchsiaResourceDialect>;
6268    fn r#watch_light_group(&self, mut name: &str) -> Self::WatchLightGroupResponseFut {
6269        fn _decode(
6270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6271        ) -> Result<LightGroup, fidl::Error> {
6272            let _response = fidl::client::decode_transaction_body::<
6273                LightWatchLightGroupResponse,
6274                fidl::encoding::DefaultFuchsiaResourceDialect,
6275                0x3ef0331c388d56a3,
6276            >(_buf?)?;
6277            Ok(_response.group)
6278        }
6279        self.client.send_query_and_decode::<LightWatchLightGroupRequest, LightGroup>(
6280            (name,),
6281            0x3ef0331c388d56a3,
6282            fidl::encoding::DynamicFlags::empty(),
6283            _decode,
6284        )
6285    }
6286
6287    type SetLightGroupValuesResponseFut = fidl::client::QueryResponseFut<
6288        LightSetLightGroupValuesResult,
6289        fidl::encoding::DefaultFuchsiaResourceDialect,
6290    >;
6291    fn r#set_light_group_values(
6292        &self,
6293        mut name: &str,
6294        mut state: &[LightState],
6295    ) -> Self::SetLightGroupValuesResponseFut {
6296        fn _decode(
6297            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6298        ) -> Result<LightSetLightGroupValuesResult, fidl::Error> {
6299            let _response = fidl::client::decode_transaction_body::<
6300                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LightError>,
6301                fidl::encoding::DefaultFuchsiaResourceDialect,
6302                0x15d9b62431fdf8d5,
6303            >(_buf?)?;
6304            Ok(_response.map(|x| x))
6305        }
6306        self.client.send_query_and_decode::<
6307            LightSetLightGroupValuesRequest,
6308            LightSetLightGroupValuesResult,
6309        >(
6310            (name, state,),
6311            0x15d9b62431fdf8d5,
6312            fidl::encoding::DynamicFlags::empty(),
6313            _decode,
6314        )
6315    }
6316}
6317
6318pub struct LightEventStream {
6319    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6320}
6321
6322impl std::marker::Unpin for LightEventStream {}
6323
6324impl futures::stream::FusedStream for LightEventStream {
6325    fn is_terminated(&self) -> bool {
6326        self.event_receiver.is_terminated()
6327    }
6328}
6329
6330impl futures::Stream for LightEventStream {
6331    type Item = Result<LightEvent, fidl::Error>;
6332
6333    fn poll_next(
6334        mut self: std::pin::Pin<&mut Self>,
6335        cx: &mut std::task::Context<'_>,
6336    ) -> std::task::Poll<Option<Self::Item>> {
6337        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6338            &mut self.event_receiver,
6339            cx
6340        )?) {
6341            Some(buf) => std::task::Poll::Ready(Some(LightEvent::decode(buf))),
6342            None => std::task::Poll::Ready(None),
6343        }
6344    }
6345}
6346
6347#[derive(Debug)]
6348pub enum LightEvent {}
6349
6350impl LightEvent {
6351    /// Decodes a message buffer as a [`LightEvent`].
6352    fn decode(
6353        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6354    ) -> Result<LightEvent, fidl::Error> {
6355        let (bytes, _handles) = buf.split_mut();
6356        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6357        debug_assert_eq!(tx_header.tx_id, 0);
6358        match tx_header.ordinal {
6359            _ => Err(fidl::Error::UnknownOrdinal {
6360                ordinal: tx_header.ordinal,
6361                protocol_name: <LightMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6362            }),
6363        }
6364    }
6365}
6366
6367/// A Stream of incoming requests for fuchsia.settings/Light.
6368pub struct LightRequestStream {
6369    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6370    is_terminated: bool,
6371}
6372
6373impl std::marker::Unpin for LightRequestStream {}
6374
6375impl futures::stream::FusedStream for LightRequestStream {
6376    fn is_terminated(&self) -> bool {
6377        self.is_terminated
6378    }
6379}
6380
6381impl fidl::endpoints::RequestStream for LightRequestStream {
6382    type Protocol = LightMarker;
6383    type ControlHandle = LightControlHandle;
6384
6385    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6386        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6387    }
6388
6389    fn control_handle(&self) -> Self::ControlHandle {
6390        LightControlHandle { inner: self.inner.clone() }
6391    }
6392
6393    fn into_inner(
6394        self,
6395    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6396    {
6397        (self.inner, self.is_terminated)
6398    }
6399
6400    fn from_inner(
6401        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6402        is_terminated: bool,
6403    ) -> Self {
6404        Self { inner, is_terminated }
6405    }
6406}
6407
6408impl futures::Stream for LightRequestStream {
6409    type Item = Result<LightRequest, fidl::Error>;
6410
6411    fn poll_next(
6412        mut self: std::pin::Pin<&mut Self>,
6413        cx: &mut std::task::Context<'_>,
6414    ) -> std::task::Poll<Option<Self::Item>> {
6415        let this = &mut *self;
6416        if this.inner.check_shutdown(cx) {
6417            this.is_terminated = true;
6418            return std::task::Poll::Ready(None);
6419        }
6420        if this.is_terminated {
6421            panic!("polled LightRequestStream after completion");
6422        }
6423        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6424            |bytes, handles| {
6425                match this.inner.channel().read_etc(cx, bytes, handles) {
6426                    std::task::Poll::Ready(Ok(())) => {}
6427                    std::task::Poll::Pending => return std::task::Poll::Pending,
6428                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6429                        this.is_terminated = true;
6430                        return std::task::Poll::Ready(None);
6431                    }
6432                    std::task::Poll::Ready(Err(e)) => {
6433                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6434                            e.into(),
6435                        ))))
6436                    }
6437                }
6438
6439                // A message has been received from the channel
6440                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6441
6442                std::task::Poll::Ready(Some(match header.ordinal {
6443                    0x3f506de229db5930 => {
6444                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6445                        let mut req = fidl::new_empty!(
6446                            fidl::encoding::EmptyPayload,
6447                            fidl::encoding::DefaultFuchsiaResourceDialect
6448                        );
6449                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6450                        let control_handle = LightControlHandle { inner: this.inner.clone() };
6451                        Ok(LightRequest::WatchLightGroups {
6452                            responder: LightWatchLightGroupsResponder {
6453                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6454                                tx_id: header.tx_id,
6455                            },
6456                        })
6457                    }
6458                    0x3ef0331c388d56a3 => {
6459                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6460                        let mut req = fidl::new_empty!(
6461                            LightWatchLightGroupRequest,
6462                            fidl::encoding::DefaultFuchsiaResourceDialect
6463                        );
6464                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LightWatchLightGroupRequest>(&header, _body_bytes, handles, &mut req)?;
6465                        let control_handle = LightControlHandle { inner: this.inner.clone() };
6466                        Ok(LightRequest::WatchLightGroup {
6467                            name: req.name,
6468
6469                            responder: LightWatchLightGroupResponder {
6470                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6471                                tx_id: header.tx_id,
6472                            },
6473                        })
6474                    }
6475                    0x15d9b62431fdf8d5 => {
6476                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6477                        let mut req = fidl::new_empty!(
6478                            LightSetLightGroupValuesRequest,
6479                            fidl::encoding::DefaultFuchsiaResourceDialect
6480                        );
6481                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LightSetLightGroupValuesRequest>(&header, _body_bytes, handles, &mut req)?;
6482                        let control_handle = LightControlHandle { inner: this.inner.clone() };
6483                        Ok(LightRequest::SetLightGroupValues {
6484                            name: req.name,
6485                            state: req.state,
6486
6487                            responder: LightSetLightGroupValuesResponder {
6488                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6489                                tx_id: header.tx_id,
6490                            },
6491                        })
6492                    }
6493                    _ => Err(fidl::Error::UnknownOrdinal {
6494                        ordinal: header.ordinal,
6495                        protocol_name: <LightMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6496                    }),
6497                }))
6498            },
6499        )
6500    }
6501}
6502
6503#[derive(Debug)]
6504pub enum LightRequest {
6505    /// Fetches information on the controllable light groups on the device.
6506    /// Returns immediately on first call; subsequent calls return when the
6507    /// value changes.
6508    ///
6509    /// If this call fails, it is considered a fatal error and the channel
6510    /// will be closed.
6511    WatchLightGroups { responder: LightWatchLightGroupsResponder },
6512    /// Fetches information on an individual light group on the device with the
6513    /// given name. Returns immediately on first call; subsequent calls return
6514    /// when the value changes.
6515    ///
6516    /// If this call fails, it is considered a fatal error and the channel
6517    /// will be closed. If the failure is due to an invalid light group name,
6518    /// the channel will be closed with a NOT_FOUND epitaph.
6519    WatchLightGroup { name: String, responder: LightWatchLightGroupResponder },
6520    /// Sets the values for the lights in the group with the given name.
6521    ///
6522    /// If the provided value does not match the light group's type, this
6523    /// call will fail.
6524    ///
6525    /// The requested changes may not take immediate effect if
6526    /// the light is forced to a certain state by the device's hardware. This
6527    /// call will still succeed, but the light's value may not change.
6528    SetLightGroupValues {
6529        name: String,
6530        state: Vec<LightState>,
6531        responder: LightSetLightGroupValuesResponder,
6532    },
6533}
6534
6535impl LightRequest {
6536    #[allow(irrefutable_let_patterns)]
6537    pub fn into_watch_light_groups(self) -> Option<(LightWatchLightGroupsResponder)> {
6538        if let LightRequest::WatchLightGroups { responder } = self {
6539            Some((responder))
6540        } else {
6541            None
6542        }
6543    }
6544
6545    #[allow(irrefutable_let_patterns)]
6546    pub fn into_watch_light_group(self) -> Option<(String, LightWatchLightGroupResponder)> {
6547        if let LightRequest::WatchLightGroup { name, responder } = self {
6548            Some((name, responder))
6549        } else {
6550            None
6551        }
6552    }
6553
6554    #[allow(irrefutable_let_patterns)]
6555    pub fn into_set_light_group_values(
6556        self,
6557    ) -> Option<(String, Vec<LightState>, LightSetLightGroupValuesResponder)> {
6558        if let LightRequest::SetLightGroupValues { name, state, responder } = self {
6559            Some((name, state, responder))
6560        } else {
6561            None
6562        }
6563    }
6564
6565    /// Name of the method defined in FIDL
6566    pub fn method_name(&self) -> &'static str {
6567        match *self {
6568            LightRequest::WatchLightGroups { .. } => "watch_light_groups",
6569            LightRequest::WatchLightGroup { .. } => "watch_light_group",
6570            LightRequest::SetLightGroupValues { .. } => "set_light_group_values",
6571        }
6572    }
6573}
6574
6575#[derive(Debug, Clone)]
6576pub struct LightControlHandle {
6577    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6578}
6579
6580impl fidl::endpoints::ControlHandle for LightControlHandle {
6581    fn shutdown(&self) {
6582        self.inner.shutdown()
6583    }
6584    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6585        self.inner.shutdown_with_epitaph(status)
6586    }
6587
6588    fn is_closed(&self) -> bool {
6589        self.inner.channel().is_closed()
6590    }
6591    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6592        self.inner.channel().on_closed()
6593    }
6594
6595    #[cfg(target_os = "fuchsia")]
6596    fn signal_peer(
6597        &self,
6598        clear_mask: zx::Signals,
6599        set_mask: zx::Signals,
6600    ) -> Result<(), zx_status::Status> {
6601        use fidl::Peered;
6602        self.inner.channel().signal_peer(clear_mask, set_mask)
6603    }
6604}
6605
6606impl LightControlHandle {}
6607
6608#[must_use = "FIDL methods require a response to be sent"]
6609#[derive(Debug)]
6610pub struct LightWatchLightGroupsResponder {
6611    control_handle: std::mem::ManuallyDrop<LightControlHandle>,
6612    tx_id: u32,
6613}
6614
6615/// Set the the channel to be shutdown (see [`LightControlHandle::shutdown`])
6616/// if the responder is dropped without sending a response, so that the client
6617/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6618impl std::ops::Drop for LightWatchLightGroupsResponder {
6619    fn drop(&mut self) {
6620        self.control_handle.shutdown();
6621        // Safety: drops once, never accessed again
6622        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6623    }
6624}
6625
6626impl fidl::endpoints::Responder for LightWatchLightGroupsResponder {
6627    type ControlHandle = LightControlHandle;
6628
6629    fn control_handle(&self) -> &LightControlHandle {
6630        &self.control_handle
6631    }
6632
6633    fn drop_without_shutdown(mut self) {
6634        // Safety: drops once, never accessed again due to mem::forget
6635        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6636        // Prevent Drop from running (which would shut down the channel)
6637        std::mem::forget(self);
6638    }
6639}
6640
6641impl LightWatchLightGroupsResponder {
6642    /// Sends a response to the FIDL transaction.
6643    ///
6644    /// Sets the channel to shutdown if an error occurs.
6645    pub fn send(self, mut groups: &[LightGroup]) -> Result<(), fidl::Error> {
6646        let _result = self.send_raw(groups);
6647        if _result.is_err() {
6648            self.control_handle.shutdown();
6649        }
6650        self.drop_without_shutdown();
6651        _result
6652    }
6653
6654    /// Similar to "send" but does not shutdown the channel if an error occurs.
6655    pub fn send_no_shutdown_on_err(self, mut groups: &[LightGroup]) -> Result<(), fidl::Error> {
6656        let _result = self.send_raw(groups);
6657        self.drop_without_shutdown();
6658        _result
6659    }
6660
6661    fn send_raw(&self, mut groups: &[LightGroup]) -> Result<(), fidl::Error> {
6662        self.control_handle.inner.send::<LightWatchLightGroupsResponse>(
6663            (groups,),
6664            self.tx_id,
6665            0x3f506de229db5930,
6666            fidl::encoding::DynamicFlags::empty(),
6667        )
6668    }
6669}
6670
6671#[must_use = "FIDL methods require a response to be sent"]
6672#[derive(Debug)]
6673pub struct LightWatchLightGroupResponder {
6674    control_handle: std::mem::ManuallyDrop<LightControlHandle>,
6675    tx_id: u32,
6676}
6677
6678/// Set the the channel to be shutdown (see [`LightControlHandle::shutdown`])
6679/// if the responder is dropped without sending a response, so that the client
6680/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6681impl std::ops::Drop for LightWatchLightGroupResponder {
6682    fn drop(&mut self) {
6683        self.control_handle.shutdown();
6684        // Safety: drops once, never accessed again
6685        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6686    }
6687}
6688
6689impl fidl::endpoints::Responder for LightWatchLightGroupResponder {
6690    type ControlHandle = LightControlHandle;
6691
6692    fn control_handle(&self) -> &LightControlHandle {
6693        &self.control_handle
6694    }
6695
6696    fn drop_without_shutdown(mut self) {
6697        // Safety: drops once, never accessed again due to mem::forget
6698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6699        // Prevent Drop from running (which would shut down the channel)
6700        std::mem::forget(self);
6701    }
6702}
6703
6704impl LightWatchLightGroupResponder {
6705    /// Sends a response to the FIDL transaction.
6706    ///
6707    /// Sets the channel to shutdown if an error occurs.
6708    pub fn send(self, mut group: &LightGroup) -> Result<(), fidl::Error> {
6709        let _result = self.send_raw(group);
6710        if _result.is_err() {
6711            self.control_handle.shutdown();
6712        }
6713        self.drop_without_shutdown();
6714        _result
6715    }
6716
6717    /// Similar to "send" but does not shutdown the channel if an error occurs.
6718    pub fn send_no_shutdown_on_err(self, mut group: &LightGroup) -> Result<(), fidl::Error> {
6719        let _result = self.send_raw(group);
6720        self.drop_without_shutdown();
6721        _result
6722    }
6723
6724    fn send_raw(&self, mut group: &LightGroup) -> Result<(), fidl::Error> {
6725        self.control_handle.inner.send::<LightWatchLightGroupResponse>(
6726            (group,),
6727            self.tx_id,
6728            0x3ef0331c388d56a3,
6729            fidl::encoding::DynamicFlags::empty(),
6730        )
6731    }
6732}
6733
6734#[must_use = "FIDL methods require a response to be sent"]
6735#[derive(Debug)]
6736pub struct LightSetLightGroupValuesResponder {
6737    control_handle: std::mem::ManuallyDrop<LightControlHandle>,
6738    tx_id: u32,
6739}
6740
6741/// Set the the channel to be shutdown (see [`LightControlHandle::shutdown`])
6742/// if the responder is dropped without sending a response, so that the client
6743/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6744impl std::ops::Drop for LightSetLightGroupValuesResponder {
6745    fn drop(&mut self) {
6746        self.control_handle.shutdown();
6747        // Safety: drops once, never accessed again
6748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6749    }
6750}
6751
6752impl fidl::endpoints::Responder for LightSetLightGroupValuesResponder {
6753    type ControlHandle = LightControlHandle;
6754
6755    fn control_handle(&self) -> &LightControlHandle {
6756        &self.control_handle
6757    }
6758
6759    fn drop_without_shutdown(mut self) {
6760        // Safety: drops once, never accessed again due to mem::forget
6761        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6762        // Prevent Drop from running (which would shut down the channel)
6763        std::mem::forget(self);
6764    }
6765}
6766
6767impl LightSetLightGroupValuesResponder {
6768    /// Sends a response to the FIDL transaction.
6769    ///
6770    /// Sets the channel to shutdown if an error occurs.
6771    pub fn send(self, mut result: Result<(), LightError>) -> Result<(), fidl::Error> {
6772        let _result = self.send_raw(result);
6773        if _result.is_err() {
6774            self.control_handle.shutdown();
6775        }
6776        self.drop_without_shutdown();
6777        _result
6778    }
6779
6780    /// Similar to "send" but does not shutdown the channel if an error occurs.
6781    pub fn send_no_shutdown_on_err(
6782        self,
6783        mut result: Result<(), LightError>,
6784    ) -> Result<(), fidl::Error> {
6785        let _result = self.send_raw(result);
6786        self.drop_without_shutdown();
6787        _result
6788    }
6789
6790    fn send_raw(&self, mut result: Result<(), LightError>) -> Result<(), fidl::Error> {
6791        self.control_handle
6792            .inner
6793            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LightError>>(
6794                result,
6795                self.tx_id,
6796                0x15d9b62431fdf8d5,
6797                fidl::encoding::DynamicFlags::empty(),
6798            )
6799    }
6800}
6801
6802#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6803pub struct NightModeMarker;
6804
6805impl fidl::endpoints::ProtocolMarker for NightModeMarker {
6806    type Proxy = NightModeProxy;
6807    type RequestStream = NightModeRequestStream;
6808    #[cfg(target_os = "fuchsia")]
6809    type SynchronousProxy = NightModeSynchronousProxy;
6810
6811    const DEBUG_NAME: &'static str = "fuchsia.settings.NightMode";
6812}
6813impl fidl::endpoints::DiscoverableProtocolMarker for NightModeMarker {}
6814pub type NightModeSetResult = Result<(), Error>;
6815
6816pub trait NightModeProxyInterface: Send + Sync {
6817    type WatchResponseFut: std::future::Future<Output = Result<NightModeSettings, fidl::Error>>
6818        + Send;
6819    fn r#watch(&self) -> Self::WatchResponseFut;
6820    type SetResponseFut: std::future::Future<Output = Result<NightModeSetResult, fidl::Error>>
6821        + Send;
6822    fn r#set(&self, settings: &NightModeSettings) -> Self::SetResponseFut;
6823}
6824#[derive(Debug)]
6825#[cfg(target_os = "fuchsia")]
6826pub struct NightModeSynchronousProxy {
6827    client: fidl::client::sync::Client,
6828}
6829
6830#[cfg(target_os = "fuchsia")]
6831impl fidl::endpoints::SynchronousProxy for NightModeSynchronousProxy {
6832    type Proxy = NightModeProxy;
6833    type Protocol = NightModeMarker;
6834
6835    fn from_channel(inner: fidl::Channel) -> Self {
6836        Self::new(inner)
6837    }
6838
6839    fn into_channel(self) -> fidl::Channel {
6840        self.client.into_channel()
6841    }
6842
6843    fn as_channel(&self) -> &fidl::Channel {
6844        self.client.as_channel()
6845    }
6846}
6847
6848#[cfg(target_os = "fuchsia")]
6849impl NightModeSynchronousProxy {
6850    pub fn new(channel: fidl::Channel) -> Self {
6851        let protocol_name = <NightModeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6852        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6853    }
6854
6855    pub fn into_channel(self) -> fidl::Channel {
6856        self.client.into_channel()
6857    }
6858
6859    /// Waits until an event arrives and returns it. It is safe for other
6860    /// threads to make concurrent requests while waiting for an event.
6861    pub fn wait_for_event(
6862        &self,
6863        deadline: zx::MonotonicInstant,
6864    ) -> Result<NightModeEvent, fidl::Error> {
6865        NightModeEvent::decode(self.client.wait_for_event(deadline)?)
6866    }
6867
6868    /// Gets the current [`NightModeSettings`]. Returns immediately on first
6869    /// call; subsequent calls return when the values change.
6870    ///
6871    /// If this call fails, it is considered a fatal error and the channel
6872    /// will be closed.
6873    pub fn r#watch(
6874        &self,
6875        ___deadline: zx::MonotonicInstant,
6876    ) -> Result<NightModeSettings, fidl::Error> {
6877        let _response =
6878            self.client.send_query::<fidl::encoding::EmptyPayload, NightModeWatchResponse>(
6879                (),
6880                0x7e1509bf8c7582f6,
6881                fidl::encoding::DynamicFlags::empty(),
6882                ___deadline,
6883            )?;
6884        Ok(_response.settings)
6885    }
6886
6887    /// Sets [`NightModeSettings`] settings. Any field not explicitly set in
6888    /// the table performs a no-op, and will not make any changes.
6889    pub fn r#set(
6890        &self,
6891        mut settings: &NightModeSettings,
6892        ___deadline: zx::MonotonicInstant,
6893    ) -> Result<NightModeSetResult, fidl::Error> {
6894        let _response = self.client.send_query::<NightModeSetRequest, fidl::encoding::ResultType<
6895            fidl::encoding::EmptyStruct,
6896            Error,
6897        >>(
6898            (settings,),
6899            0x28c3d78ab05b55cd,
6900            fidl::encoding::DynamicFlags::empty(),
6901            ___deadline,
6902        )?;
6903        Ok(_response.map(|x| x))
6904    }
6905}
6906
6907#[derive(Debug, Clone)]
6908pub struct NightModeProxy {
6909    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6910}
6911
6912impl fidl::endpoints::Proxy for NightModeProxy {
6913    type Protocol = NightModeMarker;
6914
6915    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6916        Self::new(inner)
6917    }
6918
6919    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6920        self.client.into_channel().map_err(|client| Self { client })
6921    }
6922
6923    fn as_channel(&self) -> &::fidl::AsyncChannel {
6924        self.client.as_channel()
6925    }
6926}
6927
6928impl NightModeProxy {
6929    /// Create a new Proxy for fuchsia.settings/NightMode.
6930    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6931        let protocol_name = <NightModeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6932        Self { client: fidl::client::Client::new(channel, protocol_name) }
6933    }
6934
6935    /// Get a Stream of events from the remote end of the protocol.
6936    ///
6937    /// # Panics
6938    ///
6939    /// Panics if the event stream was already taken.
6940    pub fn take_event_stream(&self) -> NightModeEventStream {
6941        NightModeEventStream { event_receiver: self.client.take_event_receiver() }
6942    }
6943
6944    /// Gets the current [`NightModeSettings`]. Returns immediately on first
6945    /// call; subsequent calls return when the values change.
6946    ///
6947    /// If this call fails, it is considered a fatal error and the channel
6948    /// will be closed.
6949    pub fn r#watch(
6950        &self,
6951    ) -> fidl::client::QueryResponseFut<
6952        NightModeSettings,
6953        fidl::encoding::DefaultFuchsiaResourceDialect,
6954    > {
6955        NightModeProxyInterface::r#watch(self)
6956    }
6957
6958    /// Sets [`NightModeSettings`] settings. Any field not explicitly set in
6959    /// the table performs a no-op, and will not make any changes.
6960    pub fn r#set(
6961        &self,
6962        mut settings: &NightModeSettings,
6963    ) -> fidl::client::QueryResponseFut<
6964        NightModeSetResult,
6965        fidl::encoding::DefaultFuchsiaResourceDialect,
6966    > {
6967        NightModeProxyInterface::r#set(self, settings)
6968    }
6969}
6970
6971impl NightModeProxyInterface for NightModeProxy {
6972    type WatchResponseFut = fidl::client::QueryResponseFut<
6973        NightModeSettings,
6974        fidl::encoding::DefaultFuchsiaResourceDialect,
6975    >;
6976    fn r#watch(&self) -> Self::WatchResponseFut {
6977        fn _decode(
6978            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6979        ) -> Result<NightModeSettings, fidl::Error> {
6980            let _response = fidl::client::decode_transaction_body::<
6981                NightModeWatchResponse,
6982                fidl::encoding::DefaultFuchsiaResourceDialect,
6983                0x7e1509bf8c7582f6,
6984            >(_buf?)?;
6985            Ok(_response.settings)
6986        }
6987        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NightModeSettings>(
6988            (),
6989            0x7e1509bf8c7582f6,
6990            fidl::encoding::DynamicFlags::empty(),
6991            _decode,
6992        )
6993    }
6994
6995    type SetResponseFut = fidl::client::QueryResponseFut<
6996        NightModeSetResult,
6997        fidl::encoding::DefaultFuchsiaResourceDialect,
6998    >;
6999    fn r#set(&self, mut settings: &NightModeSettings) -> Self::SetResponseFut {
7000        fn _decode(
7001            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7002        ) -> Result<NightModeSetResult, fidl::Error> {
7003            let _response = fidl::client::decode_transaction_body::<
7004                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
7005                fidl::encoding::DefaultFuchsiaResourceDialect,
7006                0x28c3d78ab05b55cd,
7007            >(_buf?)?;
7008            Ok(_response.map(|x| x))
7009        }
7010        self.client.send_query_and_decode::<NightModeSetRequest, NightModeSetResult>(
7011            (settings,),
7012            0x28c3d78ab05b55cd,
7013            fidl::encoding::DynamicFlags::empty(),
7014            _decode,
7015        )
7016    }
7017}
7018
7019pub struct NightModeEventStream {
7020    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7021}
7022
7023impl std::marker::Unpin for NightModeEventStream {}
7024
7025impl futures::stream::FusedStream for NightModeEventStream {
7026    fn is_terminated(&self) -> bool {
7027        self.event_receiver.is_terminated()
7028    }
7029}
7030
7031impl futures::Stream for NightModeEventStream {
7032    type Item = Result<NightModeEvent, fidl::Error>;
7033
7034    fn poll_next(
7035        mut self: std::pin::Pin<&mut Self>,
7036        cx: &mut std::task::Context<'_>,
7037    ) -> std::task::Poll<Option<Self::Item>> {
7038        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7039            &mut self.event_receiver,
7040            cx
7041        )?) {
7042            Some(buf) => std::task::Poll::Ready(Some(NightModeEvent::decode(buf))),
7043            None => std::task::Poll::Ready(None),
7044        }
7045    }
7046}
7047
7048#[derive(Debug)]
7049pub enum NightModeEvent {}
7050
7051impl NightModeEvent {
7052    /// Decodes a message buffer as a [`NightModeEvent`].
7053    fn decode(
7054        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7055    ) -> Result<NightModeEvent, fidl::Error> {
7056        let (bytes, _handles) = buf.split_mut();
7057        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7058        debug_assert_eq!(tx_header.tx_id, 0);
7059        match tx_header.ordinal {
7060            _ => Err(fidl::Error::UnknownOrdinal {
7061                ordinal: tx_header.ordinal,
7062                protocol_name: <NightModeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7063            }),
7064        }
7065    }
7066}
7067
7068/// A Stream of incoming requests for fuchsia.settings/NightMode.
7069pub struct NightModeRequestStream {
7070    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7071    is_terminated: bool,
7072}
7073
7074impl std::marker::Unpin for NightModeRequestStream {}
7075
7076impl futures::stream::FusedStream for NightModeRequestStream {
7077    fn is_terminated(&self) -> bool {
7078        self.is_terminated
7079    }
7080}
7081
7082impl fidl::endpoints::RequestStream for NightModeRequestStream {
7083    type Protocol = NightModeMarker;
7084    type ControlHandle = NightModeControlHandle;
7085
7086    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7087        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7088    }
7089
7090    fn control_handle(&self) -> Self::ControlHandle {
7091        NightModeControlHandle { inner: self.inner.clone() }
7092    }
7093
7094    fn into_inner(
7095        self,
7096    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7097    {
7098        (self.inner, self.is_terminated)
7099    }
7100
7101    fn from_inner(
7102        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7103        is_terminated: bool,
7104    ) -> Self {
7105        Self { inner, is_terminated }
7106    }
7107}
7108
7109impl futures::Stream for NightModeRequestStream {
7110    type Item = Result<NightModeRequest, fidl::Error>;
7111
7112    fn poll_next(
7113        mut self: std::pin::Pin<&mut Self>,
7114        cx: &mut std::task::Context<'_>,
7115    ) -> std::task::Poll<Option<Self::Item>> {
7116        let this = &mut *self;
7117        if this.inner.check_shutdown(cx) {
7118            this.is_terminated = true;
7119            return std::task::Poll::Ready(None);
7120        }
7121        if this.is_terminated {
7122            panic!("polled NightModeRequestStream after completion");
7123        }
7124        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7125            |bytes, handles| {
7126                match this.inner.channel().read_etc(cx, bytes, handles) {
7127                    std::task::Poll::Ready(Ok(())) => {}
7128                    std::task::Poll::Pending => return std::task::Poll::Pending,
7129                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7130                        this.is_terminated = true;
7131                        return std::task::Poll::Ready(None);
7132                    }
7133                    std::task::Poll::Ready(Err(e)) => {
7134                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7135                            e.into(),
7136                        ))))
7137                    }
7138                }
7139
7140                // A message has been received from the channel
7141                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7142
7143                std::task::Poll::Ready(Some(match header.ordinal {
7144                    0x7e1509bf8c7582f6 => {
7145                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7146                        let mut req = fidl::new_empty!(
7147                            fidl::encoding::EmptyPayload,
7148                            fidl::encoding::DefaultFuchsiaResourceDialect
7149                        );
7150                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7151                        let control_handle = NightModeControlHandle { inner: this.inner.clone() };
7152                        Ok(NightModeRequest::Watch {
7153                            responder: NightModeWatchResponder {
7154                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7155                                tx_id: header.tx_id,
7156                            },
7157                        })
7158                    }
7159                    0x28c3d78ab05b55cd => {
7160                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7161                        let mut req = fidl::new_empty!(
7162                            NightModeSetRequest,
7163                            fidl::encoding::DefaultFuchsiaResourceDialect
7164                        );
7165                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NightModeSetRequest>(&header, _body_bytes, handles, &mut req)?;
7166                        let control_handle = NightModeControlHandle { inner: this.inner.clone() };
7167                        Ok(NightModeRequest::Set {
7168                            settings: req.settings,
7169
7170                            responder: NightModeSetResponder {
7171                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7172                                tx_id: header.tx_id,
7173                            },
7174                        })
7175                    }
7176                    _ => Err(fidl::Error::UnknownOrdinal {
7177                        ordinal: header.ordinal,
7178                        protocol_name:
7179                            <NightModeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7180                    }),
7181                }))
7182            },
7183        )
7184    }
7185}
7186
7187/// Modify or watch Night Mode setting. Night mode puts the device in a
7188/// restricted mode which can be overrided if the user prefers. During night
7189/// mode, the following settings apply as per night mode parameters:
7190/// 1. DoNotDisturb is enabled/not.
7191/// 2. System volume is set to an override maximum.
7192/// 3. LED Brightness is set to an overridable maximum.
7193/// 4. Sleep mode is enabled/not.
7194///
7195/// Supported SettingsEpitaph enums:
7196/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR
7197#[derive(Debug)]
7198pub enum NightModeRequest {
7199    /// Gets the current [`NightModeSettings`]. Returns immediately on first
7200    /// call; subsequent calls return when the values change.
7201    ///
7202    /// If this call fails, it is considered a fatal error and the channel
7203    /// will be closed.
7204    Watch { responder: NightModeWatchResponder },
7205    /// Sets [`NightModeSettings`] settings. Any field not explicitly set in
7206    /// the table performs a no-op, and will not make any changes.
7207    Set { settings: NightModeSettings, responder: NightModeSetResponder },
7208}
7209
7210impl NightModeRequest {
7211    #[allow(irrefutable_let_patterns)]
7212    pub fn into_watch(self) -> Option<(NightModeWatchResponder)> {
7213        if let NightModeRequest::Watch { responder } = self {
7214            Some((responder))
7215        } else {
7216            None
7217        }
7218    }
7219
7220    #[allow(irrefutable_let_patterns)]
7221    pub fn into_set(self) -> Option<(NightModeSettings, NightModeSetResponder)> {
7222        if let NightModeRequest::Set { settings, responder } = self {
7223            Some((settings, responder))
7224        } else {
7225            None
7226        }
7227    }
7228
7229    /// Name of the method defined in FIDL
7230    pub fn method_name(&self) -> &'static str {
7231        match *self {
7232            NightModeRequest::Watch { .. } => "watch",
7233            NightModeRequest::Set { .. } => "set",
7234        }
7235    }
7236}
7237
7238#[derive(Debug, Clone)]
7239pub struct NightModeControlHandle {
7240    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7241}
7242
7243impl fidl::endpoints::ControlHandle for NightModeControlHandle {
7244    fn shutdown(&self) {
7245        self.inner.shutdown()
7246    }
7247    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7248        self.inner.shutdown_with_epitaph(status)
7249    }
7250
7251    fn is_closed(&self) -> bool {
7252        self.inner.channel().is_closed()
7253    }
7254    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7255        self.inner.channel().on_closed()
7256    }
7257
7258    #[cfg(target_os = "fuchsia")]
7259    fn signal_peer(
7260        &self,
7261        clear_mask: zx::Signals,
7262        set_mask: zx::Signals,
7263    ) -> Result<(), zx_status::Status> {
7264        use fidl::Peered;
7265        self.inner.channel().signal_peer(clear_mask, set_mask)
7266    }
7267}
7268
7269impl NightModeControlHandle {}
7270
7271#[must_use = "FIDL methods require a response to be sent"]
7272#[derive(Debug)]
7273pub struct NightModeWatchResponder {
7274    control_handle: std::mem::ManuallyDrop<NightModeControlHandle>,
7275    tx_id: u32,
7276}
7277
7278/// Set the the channel to be shutdown (see [`NightModeControlHandle::shutdown`])
7279/// if the responder is dropped without sending a response, so that the client
7280/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7281impl std::ops::Drop for NightModeWatchResponder {
7282    fn drop(&mut self) {
7283        self.control_handle.shutdown();
7284        // Safety: drops once, never accessed again
7285        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7286    }
7287}
7288
7289impl fidl::endpoints::Responder for NightModeWatchResponder {
7290    type ControlHandle = NightModeControlHandle;
7291
7292    fn control_handle(&self) -> &NightModeControlHandle {
7293        &self.control_handle
7294    }
7295
7296    fn drop_without_shutdown(mut self) {
7297        // Safety: drops once, never accessed again due to mem::forget
7298        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7299        // Prevent Drop from running (which would shut down the channel)
7300        std::mem::forget(self);
7301    }
7302}
7303
7304impl NightModeWatchResponder {
7305    /// Sends a response to the FIDL transaction.
7306    ///
7307    /// Sets the channel to shutdown if an error occurs.
7308    pub fn send(self, mut settings: &NightModeSettings) -> Result<(), fidl::Error> {
7309        let _result = self.send_raw(settings);
7310        if _result.is_err() {
7311            self.control_handle.shutdown();
7312        }
7313        self.drop_without_shutdown();
7314        _result
7315    }
7316
7317    /// Similar to "send" but does not shutdown the channel if an error occurs.
7318    pub fn send_no_shutdown_on_err(
7319        self,
7320        mut settings: &NightModeSettings,
7321    ) -> Result<(), fidl::Error> {
7322        let _result = self.send_raw(settings);
7323        self.drop_without_shutdown();
7324        _result
7325    }
7326
7327    fn send_raw(&self, mut settings: &NightModeSettings) -> Result<(), fidl::Error> {
7328        self.control_handle.inner.send::<NightModeWatchResponse>(
7329            (settings,),
7330            self.tx_id,
7331            0x7e1509bf8c7582f6,
7332            fidl::encoding::DynamicFlags::empty(),
7333        )
7334    }
7335}
7336
7337#[must_use = "FIDL methods require a response to be sent"]
7338#[derive(Debug)]
7339pub struct NightModeSetResponder {
7340    control_handle: std::mem::ManuallyDrop<NightModeControlHandle>,
7341    tx_id: u32,
7342}
7343
7344/// Set the the channel to be shutdown (see [`NightModeControlHandle::shutdown`])
7345/// if the responder is dropped without sending a response, so that the client
7346/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7347impl std::ops::Drop for NightModeSetResponder {
7348    fn drop(&mut self) {
7349        self.control_handle.shutdown();
7350        // Safety: drops once, never accessed again
7351        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7352    }
7353}
7354
7355impl fidl::endpoints::Responder for NightModeSetResponder {
7356    type ControlHandle = NightModeControlHandle;
7357
7358    fn control_handle(&self) -> &NightModeControlHandle {
7359        &self.control_handle
7360    }
7361
7362    fn drop_without_shutdown(mut self) {
7363        // Safety: drops once, never accessed again due to mem::forget
7364        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7365        // Prevent Drop from running (which would shut down the channel)
7366        std::mem::forget(self);
7367    }
7368}
7369
7370impl NightModeSetResponder {
7371    /// Sends a response to the FIDL transaction.
7372    ///
7373    /// Sets the channel to shutdown if an error occurs.
7374    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
7375        let _result = self.send_raw(result);
7376        if _result.is_err() {
7377            self.control_handle.shutdown();
7378        }
7379        self.drop_without_shutdown();
7380        _result
7381    }
7382
7383    /// Similar to "send" but does not shutdown the channel if an error occurs.
7384    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
7385        let _result = self.send_raw(result);
7386        self.drop_without_shutdown();
7387        _result
7388    }
7389
7390    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
7391        self.control_handle
7392            .inner
7393            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
7394                result,
7395                self.tx_id,
7396                0x28c3d78ab05b55cd,
7397                fidl::encoding::DynamicFlags::empty(),
7398            )
7399    }
7400}
7401
7402#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7403pub struct PrivacyMarker;
7404
7405impl fidl::endpoints::ProtocolMarker for PrivacyMarker {
7406    type Proxy = PrivacyProxy;
7407    type RequestStream = PrivacyRequestStream;
7408    #[cfg(target_os = "fuchsia")]
7409    type SynchronousProxy = PrivacySynchronousProxy;
7410
7411    const DEBUG_NAME: &'static str = "fuchsia.settings.Privacy";
7412}
7413impl fidl::endpoints::DiscoverableProtocolMarker for PrivacyMarker {}
7414pub type PrivacySetResult = Result<(), Error>;
7415
7416pub trait PrivacyProxyInterface: Send + Sync {
7417    type WatchResponseFut: std::future::Future<Output = Result<PrivacySettings, fidl::Error>> + Send;
7418    fn r#watch(&self) -> Self::WatchResponseFut;
7419    type SetResponseFut: std::future::Future<Output = Result<PrivacySetResult, fidl::Error>> + Send;
7420    fn r#set(&self, settings: &PrivacySettings) -> Self::SetResponseFut;
7421}
7422#[derive(Debug)]
7423#[cfg(target_os = "fuchsia")]
7424pub struct PrivacySynchronousProxy {
7425    client: fidl::client::sync::Client,
7426}
7427
7428#[cfg(target_os = "fuchsia")]
7429impl fidl::endpoints::SynchronousProxy for PrivacySynchronousProxy {
7430    type Proxy = PrivacyProxy;
7431    type Protocol = PrivacyMarker;
7432
7433    fn from_channel(inner: fidl::Channel) -> Self {
7434        Self::new(inner)
7435    }
7436
7437    fn into_channel(self) -> fidl::Channel {
7438        self.client.into_channel()
7439    }
7440
7441    fn as_channel(&self) -> &fidl::Channel {
7442        self.client.as_channel()
7443    }
7444}
7445
7446#[cfg(target_os = "fuchsia")]
7447impl PrivacySynchronousProxy {
7448    pub fn new(channel: fidl::Channel) -> Self {
7449        let protocol_name = <PrivacyMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7450        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7451    }
7452
7453    pub fn into_channel(self) -> fidl::Channel {
7454        self.client.into_channel()
7455    }
7456
7457    /// Waits until an event arrives and returns it. It is safe for other
7458    /// threads to make concurrent requests while waiting for an event.
7459    pub fn wait_for_event(
7460        &self,
7461        deadline: zx::MonotonicInstant,
7462    ) -> Result<PrivacyEvent, fidl::Error> {
7463        PrivacyEvent::decode(self.client.wait_for_event(deadline)?)
7464    }
7465
7466    /// Notifies of a change in privacy settings.
7467    ///
7468    /// On a given connection, the server will return immediately if this is the first call made,
7469    /// or if the `settings` value has changed since a previous call. Otherwise, the server will
7470    /// wait on a value change before returning the new value. This follows the hanging get pattern.
7471    ///
7472    /// If this call fails, it is considered a fatal error and the channel will be closed.
7473    pub fn r#watch(
7474        &self,
7475        ___deadline: zx::MonotonicInstant,
7476    ) -> Result<PrivacySettings, fidl::Error> {
7477        let _response =
7478            self.client.send_query::<fidl::encoding::EmptyPayload, PrivacyWatchResponse>(
7479                (),
7480                0x1cb0c420ed81f47c,
7481                fidl::encoding::DynamicFlags::empty(),
7482                ___deadline,
7483            )?;
7484        Ok(_response.settings)
7485    }
7486
7487    /// Sets the privacy settings.
7488    ///
7489    /// Any field not explicitly set in `settings` performs a no-op, and will not make any changes.
7490    pub fn r#set(
7491        &self,
7492        mut settings: &PrivacySettings,
7493        ___deadline: zx::MonotonicInstant,
7494    ) -> Result<PrivacySetResult, fidl::Error> {
7495        let _response = self.client.send_query::<PrivacySetRequest, fidl::encoding::ResultType<
7496            fidl::encoding::EmptyStruct,
7497            Error,
7498        >>(
7499            (settings,),
7500            0xe2f4a1c85885537,
7501            fidl::encoding::DynamicFlags::empty(),
7502            ___deadline,
7503        )?;
7504        Ok(_response.map(|x| x))
7505    }
7506}
7507
7508#[derive(Debug, Clone)]
7509pub struct PrivacyProxy {
7510    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7511}
7512
7513impl fidl::endpoints::Proxy for PrivacyProxy {
7514    type Protocol = PrivacyMarker;
7515
7516    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7517        Self::new(inner)
7518    }
7519
7520    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7521        self.client.into_channel().map_err(|client| Self { client })
7522    }
7523
7524    fn as_channel(&self) -> &::fidl::AsyncChannel {
7525        self.client.as_channel()
7526    }
7527}
7528
7529impl PrivacyProxy {
7530    /// Create a new Proxy for fuchsia.settings/Privacy.
7531    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7532        let protocol_name = <PrivacyMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7533        Self { client: fidl::client::Client::new(channel, protocol_name) }
7534    }
7535
7536    /// Get a Stream of events from the remote end of the protocol.
7537    ///
7538    /// # Panics
7539    ///
7540    /// Panics if the event stream was already taken.
7541    pub fn take_event_stream(&self) -> PrivacyEventStream {
7542        PrivacyEventStream { event_receiver: self.client.take_event_receiver() }
7543    }
7544
7545    /// Notifies of a change in privacy settings.
7546    ///
7547    /// On a given connection, the server will return immediately if this is the first call made,
7548    /// or if the `settings` value has changed since a previous call. Otherwise, the server will
7549    /// wait on a value change before returning the new value. This follows the hanging get pattern.
7550    ///
7551    /// If this call fails, it is considered a fatal error and the channel will be closed.
7552    pub fn r#watch(
7553        &self,
7554    ) -> fidl::client::QueryResponseFut<
7555        PrivacySettings,
7556        fidl::encoding::DefaultFuchsiaResourceDialect,
7557    > {
7558        PrivacyProxyInterface::r#watch(self)
7559    }
7560
7561    /// Sets the privacy settings.
7562    ///
7563    /// Any field not explicitly set in `settings` performs a no-op, and will not make any changes.
7564    pub fn r#set(
7565        &self,
7566        mut settings: &PrivacySettings,
7567    ) -> fidl::client::QueryResponseFut<
7568        PrivacySetResult,
7569        fidl::encoding::DefaultFuchsiaResourceDialect,
7570    > {
7571        PrivacyProxyInterface::r#set(self, settings)
7572    }
7573}
7574
7575impl PrivacyProxyInterface for PrivacyProxy {
7576    type WatchResponseFut = fidl::client::QueryResponseFut<
7577        PrivacySettings,
7578        fidl::encoding::DefaultFuchsiaResourceDialect,
7579    >;
7580    fn r#watch(&self) -> Self::WatchResponseFut {
7581        fn _decode(
7582            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7583        ) -> Result<PrivacySettings, fidl::Error> {
7584            let _response = fidl::client::decode_transaction_body::<
7585                PrivacyWatchResponse,
7586                fidl::encoding::DefaultFuchsiaResourceDialect,
7587                0x1cb0c420ed81f47c,
7588            >(_buf?)?;
7589            Ok(_response.settings)
7590        }
7591        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PrivacySettings>(
7592            (),
7593            0x1cb0c420ed81f47c,
7594            fidl::encoding::DynamicFlags::empty(),
7595            _decode,
7596        )
7597    }
7598
7599    type SetResponseFut = fidl::client::QueryResponseFut<
7600        PrivacySetResult,
7601        fidl::encoding::DefaultFuchsiaResourceDialect,
7602    >;
7603    fn r#set(&self, mut settings: &PrivacySettings) -> Self::SetResponseFut {
7604        fn _decode(
7605            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7606        ) -> Result<PrivacySetResult, fidl::Error> {
7607            let _response = fidl::client::decode_transaction_body::<
7608                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
7609                fidl::encoding::DefaultFuchsiaResourceDialect,
7610                0xe2f4a1c85885537,
7611            >(_buf?)?;
7612            Ok(_response.map(|x| x))
7613        }
7614        self.client.send_query_and_decode::<PrivacySetRequest, PrivacySetResult>(
7615            (settings,),
7616            0xe2f4a1c85885537,
7617            fidl::encoding::DynamicFlags::empty(),
7618            _decode,
7619        )
7620    }
7621}
7622
7623pub struct PrivacyEventStream {
7624    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7625}
7626
7627impl std::marker::Unpin for PrivacyEventStream {}
7628
7629impl futures::stream::FusedStream for PrivacyEventStream {
7630    fn is_terminated(&self) -> bool {
7631        self.event_receiver.is_terminated()
7632    }
7633}
7634
7635impl futures::Stream for PrivacyEventStream {
7636    type Item = Result<PrivacyEvent, fidl::Error>;
7637
7638    fn poll_next(
7639        mut self: std::pin::Pin<&mut Self>,
7640        cx: &mut std::task::Context<'_>,
7641    ) -> std::task::Poll<Option<Self::Item>> {
7642        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7643            &mut self.event_receiver,
7644            cx
7645        )?) {
7646            Some(buf) => std::task::Poll::Ready(Some(PrivacyEvent::decode(buf))),
7647            None => std::task::Poll::Ready(None),
7648        }
7649    }
7650}
7651
7652#[derive(Debug)]
7653pub enum PrivacyEvent {}
7654
7655impl PrivacyEvent {
7656    /// Decodes a message buffer as a [`PrivacyEvent`].
7657    fn decode(
7658        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7659    ) -> Result<PrivacyEvent, fidl::Error> {
7660        let (bytes, _handles) = buf.split_mut();
7661        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7662        debug_assert_eq!(tx_header.tx_id, 0);
7663        match tx_header.ordinal {
7664            _ => Err(fidl::Error::UnknownOrdinal {
7665                ordinal: tx_header.ordinal,
7666                protocol_name: <PrivacyMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7667            }),
7668        }
7669    }
7670}
7671
7672/// A Stream of incoming requests for fuchsia.settings/Privacy.
7673pub struct PrivacyRequestStream {
7674    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7675    is_terminated: bool,
7676}
7677
7678impl std::marker::Unpin for PrivacyRequestStream {}
7679
7680impl futures::stream::FusedStream for PrivacyRequestStream {
7681    fn is_terminated(&self) -> bool {
7682        self.is_terminated
7683    }
7684}
7685
7686impl fidl::endpoints::RequestStream for PrivacyRequestStream {
7687    type Protocol = PrivacyMarker;
7688    type ControlHandle = PrivacyControlHandle;
7689
7690    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7691        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7692    }
7693
7694    fn control_handle(&self) -> Self::ControlHandle {
7695        PrivacyControlHandle { inner: self.inner.clone() }
7696    }
7697
7698    fn into_inner(
7699        self,
7700    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7701    {
7702        (self.inner, self.is_terminated)
7703    }
7704
7705    fn from_inner(
7706        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7707        is_terminated: bool,
7708    ) -> Self {
7709        Self { inner, is_terminated }
7710    }
7711}
7712
7713impl futures::Stream for PrivacyRequestStream {
7714    type Item = Result<PrivacyRequest, fidl::Error>;
7715
7716    fn poll_next(
7717        mut self: std::pin::Pin<&mut Self>,
7718        cx: &mut std::task::Context<'_>,
7719    ) -> std::task::Poll<Option<Self::Item>> {
7720        let this = &mut *self;
7721        if this.inner.check_shutdown(cx) {
7722            this.is_terminated = true;
7723            return std::task::Poll::Ready(None);
7724        }
7725        if this.is_terminated {
7726            panic!("polled PrivacyRequestStream after completion");
7727        }
7728        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7729            |bytes, handles| {
7730                match this.inner.channel().read_etc(cx, bytes, handles) {
7731                    std::task::Poll::Ready(Ok(())) => {}
7732                    std::task::Poll::Pending => return std::task::Poll::Pending,
7733                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7734                        this.is_terminated = true;
7735                        return std::task::Poll::Ready(None);
7736                    }
7737                    std::task::Poll::Ready(Err(e)) => {
7738                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7739                            e.into(),
7740                        ))))
7741                    }
7742                }
7743
7744                // A message has been received from the channel
7745                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7746
7747                std::task::Poll::Ready(Some(match header.ordinal {
7748                    0x1cb0c420ed81f47c => {
7749                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7750                        let mut req = fidl::new_empty!(
7751                            fidl::encoding::EmptyPayload,
7752                            fidl::encoding::DefaultFuchsiaResourceDialect
7753                        );
7754                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7755                        let control_handle = PrivacyControlHandle { inner: this.inner.clone() };
7756                        Ok(PrivacyRequest::Watch {
7757                            responder: PrivacyWatchResponder {
7758                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7759                                tx_id: header.tx_id,
7760                            },
7761                        })
7762                    }
7763                    0xe2f4a1c85885537 => {
7764                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7765                        let mut req = fidl::new_empty!(
7766                            PrivacySetRequest,
7767                            fidl::encoding::DefaultFuchsiaResourceDialect
7768                        );
7769                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrivacySetRequest>(&header, _body_bytes, handles, &mut req)?;
7770                        let control_handle = PrivacyControlHandle { inner: this.inner.clone() };
7771                        Ok(PrivacyRequest::Set {
7772                            settings: req.settings,
7773
7774                            responder: PrivacySetResponder {
7775                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7776                                tx_id: header.tx_id,
7777                            },
7778                        })
7779                    }
7780                    _ => Err(fidl::Error::UnknownOrdinal {
7781                        ordinal: header.ordinal,
7782                        protocol_name:
7783                            <PrivacyMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7784                    }),
7785                }))
7786            },
7787        )
7788    }
7789}
7790
7791/// Settings related to privacy.
7792///
7793/// Supported SettingsEpitaph enums:
7794/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR
7795#[derive(Debug)]
7796pub enum PrivacyRequest {
7797    /// Notifies of a change in privacy settings.
7798    ///
7799    /// On a given connection, the server will return immediately if this is the first call made,
7800    /// or if the `settings` value has changed since a previous call. Otherwise, the server will
7801    /// wait on a value change before returning the new value. This follows the hanging get pattern.
7802    ///
7803    /// If this call fails, it is considered a fatal error and the channel will be closed.
7804    Watch { responder: PrivacyWatchResponder },
7805    /// Sets the privacy settings.
7806    ///
7807    /// Any field not explicitly set in `settings` performs a no-op, and will not make any changes.
7808    Set { settings: PrivacySettings, responder: PrivacySetResponder },
7809}
7810
7811impl PrivacyRequest {
7812    #[allow(irrefutable_let_patterns)]
7813    pub fn into_watch(self) -> Option<(PrivacyWatchResponder)> {
7814        if let PrivacyRequest::Watch { responder } = self {
7815            Some((responder))
7816        } else {
7817            None
7818        }
7819    }
7820
7821    #[allow(irrefutable_let_patterns)]
7822    pub fn into_set(self) -> Option<(PrivacySettings, PrivacySetResponder)> {
7823        if let PrivacyRequest::Set { settings, responder } = self {
7824            Some((settings, responder))
7825        } else {
7826            None
7827        }
7828    }
7829
7830    /// Name of the method defined in FIDL
7831    pub fn method_name(&self) -> &'static str {
7832        match *self {
7833            PrivacyRequest::Watch { .. } => "watch",
7834            PrivacyRequest::Set { .. } => "set",
7835        }
7836    }
7837}
7838
7839#[derive(Debug, Clone)]
7840pub struct PrivacyControlHandle {
7841    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7842}
7843
7844impl fidl::endpoints::ControlHandle for PrivacyControlHandle {
7845    fn shutdown(&self) {
7846        self.inner.shutdown()
7847    }
7848    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7849        self.inner.shutdown_with_epitaph(status)
7850    }
7851
7852    fn is_closed(&self) -> bool {
7853        self.inner.channel().is_closed()
7854    }
7855    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7856        self.inner.channel().on_closed()
7857    }
7858
7859    #[cfg(target_os = "fuchsia")]
7860    fn signal_peer(
7861        &self,
7862        clear_mask: zx::Signals,
7863        set_mask: zx::Signals,
7864    ) -> Result<(), zx_status::Status> {
7865        use fidl::Peered;
7866        self.inner.channel().signal_peer(clear_mask, set_mask)
7867    }
7868}
7869
7870impl PrivacyControlHandle {}
7871
7872#[must_use = "FIDL methods require a response to be sent"]
7873#[derive(Debug)]
7874pub struct PrivacyWatchResponder {
7875    control_handle: std::mem::ManuallyDrop<PrivacyControlHandle>,
7876    tx_id: u32,
7877}
7878
7879/// Set the the channel to be shutdown (see [`PrivacyControlHandle::shutdown`])
7880/// if the responder is dropped without sending a response, so that the client
7881/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7882impl std::ops::Drop for PrivacyWatchResponder {
7883    fn drop(&mut self) {
7884        self.control_handle.shutdown();
7885        // Safety: drops once, never accessed again
7886        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7887    }
7888}
7889
7890impl fidl::endpoints::Responder for PrivacyWatchResponder {
7891    type ControlHandle = PrivacyControlHandle;
7892
7893    fn control_handle(&self) -> &PrivacyControlHandle {
7894        &self.control_handle
7895    }
7896
7897    fn drop_without_shutdown(mut self) {
7898        // Safety: drops once, never accessed again due to mem::forget
7899        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7900        // Prevent Drop from running (which would shut down the channel)
7901        std::mem::forget(self);
7902    }
7903}
7904
7905impl PrivacyWatchResponder {
7906    /// Sends a response to the FIDL transaction.
7907    ///
7908    /// Sets the channel to shutdown if an error occurs.
7909    pub fn send(self, mut settings: &PrivacySettings) -> Result<(), fidl::Error> {
7910        let _result = self.send_raw(settings);
7911        if _result.is_err() {
7912            self.control_handle.shutdown();
7913        }
7914        self.drop_without_shutdown();
7915        _result
7916    }
7917
7918    /// Similar to "send" but does not shutdown the channel if an error occurs.
7919    pub fn send_no_shutdown_on_err(
7920        self,
7921        mut settings: &PrivacySettings,
7922    ) -> Result<(), fidl::Error> {
7923        let _result = self.send_raw(settings);
7924        self.drop_without_shutdown();
7925        _result
7926    }
7927
7928    fn send_raw(&self, mut settings: &PrivacySettings) -> Result<(), fidl::Error> {
7929        self.control_handle.inner.send::<PrivacyWatchResponse>(
7930            (settings,),
7931            self.tx_id,
7932            0x1cb0c420ed81f47c,
7933            fidl::encoding::DynamicFlags::empty(),
7934        )
7935    }
7936}
7937
7938#[must_use = "FIDL methods require a response to be sent"]
7939#[derive(Debug)]
7940pub struct PrivacySetResponder {
7941    control_handle: std::mem::ManuallyDrop<PrivacyControlHandle>,
7942    tx_id: u32,
7943}
7944
7945/// Set the the channel to be shutdown (see [`PrivacyControlHandle::shutdown`])
7946/// if the responder is dropped without sending a response, so that the client
7947/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7948impl std::ops::Drop for PrivacySetResponder {
7949    fn drop(&mut self) {
7950        self.control_handle.shutdown();
7951        // Safety: drops once, never accessed again
7952        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7953    }
7954}
7955
7956impl fidl::endpoints::Responder for PrivacySetResponder {
7957    type ControlHandle = PrivacyControlHandle;
7958
7959    fn control_handle(&self) -> &PrivacyControlHandle {
7960        &self.control_handle
7961    }
7962
7963    fn drop_without_shutdown(mut self) {
7964        // Safety: drops once, never accessed again due to mem::forget
7965        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7966        // Prevent Drop from running (which would shut down the channel)
7967        std::mem::forget(self);
7968    }
7969}
7970
7971impl PrivacySetResponder {
7972    /// Sends a response to the FIDL transaction.
7973    ///
7974    /// Sets the channel to shutdown if an error occurs.
7975    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
7976        let _result = self.send_raw(result);
7977        if _result.is_err() {
7978            self.control_handle.shutdown();
7979        }
7980        self.drop_without_shutdown();
7981        _result
7982    }
7983
7984    /// Similar to "send" but does not shutdown the channel if an error occurs.
7985    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
7986        let _result = self.send_raw(result);
7987        self.drop_without_shutdown();
7988        _result
7989    }
7990
7991    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
7992        self.control_handle
7993            .inner
7994            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
7995                result,
7996                self.tx_id,
7997                0xe2f4a1c85885537,
7998                fidl::encoding::DynamicFlags::empty(),
7999            )
8000    }
8001}
8002
8003#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8004pub struct SetupMarker;
8005
8006impl fidl::endpoints::ProtocolMarker for SetupMarker {
8007    type Proxy = SetupProxy;
8008    type RequestStream = SetupRequestStream;
8009    #[cfg(target_os = "fuchsia")]
8010    type SynchronousProxy = SetupSynchronousProxy;
8011
8012    const DEBUG_NAME: &'static str = "fuchsia.settings.Setup";
8013}
8014impl fidl::endpoints::DiscoverableProtocolMarker for SetupMarker {}
8015pub type SetupSetResult = Result<(), Error>;
8016
8017pub trait SetupProxyInterface: Send + Sync {
8018    type WatchResponseFut: std::future::Future<Output = Result<SetupSettings, fidl::Error>> + Send;
8019    fn r#watch(&self) -> Self::WatchResponseFut;
8020    type SetResponseFut: std::future::Future<Output = Result<SetupSetResult, fidl::Error>> + Send;
8021    fn r#set(&self, settings: &SetupSettings, reboot_device: bool) -> Self::SetResponseFut;
8022}
8023#[derive(Debug)]
8024#[cfg(target_os = "fuchsia")]
8025pub struct SetupSynchronousProxy {
8026    client: fidl::client::sync::Client,
8027}
8028
8029#[cfg(target_os = "fuchsia")]
8030impl fidl::endpoints::SynchronousProxy for SetupSynchronousProxy {
8031    type Proxy = SetupProxy;
8032    type Protocol = SetupMarker;
8033
8034    fn from_channel(inner: fidl::Channel) -> Self {
8035        Self::new(inner)
8036    }
8037
8038    fn into_channel(self) -> fidl::Channel {
8039        self.client.into_channel()
8040    }
8041
8042    fn as_channel(&self) -> &fidl::Channel {
8043        self.client.as_channel()
8044    }
8045}
8046
8047#[cfg(target_os = "fuchsia")]
8048impl SetupSynchronousProxy {
8049    pub fn new(channel: fidl::Channel) -> Self {
8050        let protocol_name = <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8051        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8052    }
8053
8054    pub fn into_channel(self) -> fidl::Channel {
8055        self.client.into_channel()
8056    }
8057
8058    /// Waits until an event arrives and returns it. It is safe for other
8059    /// threads to make concurrent requests while waiting for an event.
8060    pub fn wait_for_event(
8061        &self,
8062        deadline: zx::MonotonicInstant,
8063    ) -> Result<SetupEvent, fidl::Error> {
8064        SetupEvent::decode(self.client.wait_for_event(deadline)?)
8065    }
8066
8067    /// Gets the current [SetupSettings]. Returns immediately on first call;
8068    /// subsequent calls return when the value changes.
8069    ///
8070    /// If this call fails, it is considered a fatal error and the channel
8071    /// will be closed.
8072    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<SetupSettings, fidl::Error> {
8073        let _response =
8074            self.client.send_query::<fidl::encoding::EmptyPayload, SetupWatchResponse>(
8075                (),
8076                0xd3893c0e63c0a6e,
8077                fidl::encoding::DynamicFlags::empty(),
8078                ___deadline,
8079            )?;
8080        Ok(_response.settings)
8081    }
8082
8083    /// Changes the settings specified in [SetupSettings]. Any field not set in
8084    /// the table will not perform any system operation. An error will be
8085    /// returned if the provided settings is an invalid change (for example, if
8086    /// it is empty).
8087    pub fn r#set(
8088        &self,
8089        mut settings: &SetupSettings,
8090        mut reboot_device: bool,
8091        ___deadline: zx::MonotonicInstant,
8092    ) -> Result<SetupSetResult, fidl::Error> {
8093        let _response = self.client.send_query::<SetupSetRequest, fidl::encoding::ResultType<
8094            fidl::encoding::EmptyStruct,
8095            Error,
8096        >>(
8097            (settings, reboot_device),
8098            0x66a20be769388128,
8099            fidl::encoding::DynamicFlags::empty(),
8100            ___deadline,
8101        )?;
8102        Ok(_response.map(|x| x))
8103    }
8104}
8105
8106#[derive(Debug, Clone)]
8107pub struct SetupProxy {
8108    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8109}
8110
8111impl fidl::endpoints::Proxy for SetupProxy {
8112    type Protocol = SetupMarker;
8113
8114    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8115        Self::new(inner)
8116    }
8117
8118    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8119        self.client.into_channel().map_err(|client| Self { client })
8120    }
8121
8122    fn as_channel(&self) -> &::fidl::AsyncChannel {
8123        self.client.as_channel()
8124    }
8125}
8126
8127impl SetupProxy {
8128    /// Create a new Proxy for fuchsia.settings/Setup.
8129    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8130        let protocol_name = <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8131        Self { client: fidl::client::Client::new(channel, protocol_name) }
8132    }
8133
8134    /// Get a Stream of events from the remote end of the protocol.
8135    ///
8136    /// # Panics
8137    ///
8138    /// Panics if the event stream was already taken.
8139    pub fn take_event_stream(&self) -> SetupEventStream {
8140        SetupEventStream { event_receiver: self.client.take_event_receiver() }
8141    }
8142
8143    /// Gets the current [SetupSettings]. Returns immediately on first call;
8144    /// subsequent calls return when the value changes.
8145    ///
8146    /// If this call fails, it is considered a fatal error and the channel
8147    /// will be closed.
8148    pub fn r#watch(
8149        &self,
8150    ) -> fidl::client::QueryResponseFut<SetupSettings, fidl::encoding::DefaultFuchsiaResourceDialect>
8151    {
8152        SetupProxyInterface::r#watch(self)
8153    }
8154
8155    /// Changes the settings specified in [SetupSettings]. Any field not set in
8156    /// the table will not perform any system operation. An error will be
8157    /// returned if the provided settings is an invalid change (for example, if
8158    /// it is empty).
8159    pub fn r#set(
8160        &self,
8161        mut settings: &SetupSettings,
8162        mut reboot_device: bool,
8163    ) -> fidl::client::QueryResponseFut<SetupSetResult, fidl::encoding::DefaultFuchsiaResourceDialect>
8164    {
8165        SetupProxyInterface::r#set(self, settings, reboot_device)
8166    }
8167}
8168
8169impl SetupProxyInterface for SetupProxy {
8170    type WatchResponseFut = fidl::client::QueryResponseFut<
8171        SetupSettings,
8172        fidl::encoding::DefaultFuchsiaResourceDialect,
8173    >;
8174    fn r#watch(&self) -> Self::WatchResponseFut {
8175        fn _decode(
8176            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8177        ) -> Result<SetupSettings, fidl::Error> {
8178            let _response = fidl::client::decode_transaction_body::<
8179                SetupWatchResponse,
8180                fidl::encoding::DefaultFuchsiaResourceDialect,
8181                0xd3893c0e63c0a6e,
8182            >(_buf?)?;
8183            Ok(_response.settings)
8184        }
8185        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, SetupSettings>(
8186            (),
8187            0xd3893c0e63c0a6e,
8188            fidl::encoding::DynamicFlags::empty(),
8189            _decode,
8190        )
8191    }
8192
8193    type SetResponseFut = fidl::client::QueryResponseFut<
8194        SetupSetResult,
8195        fidl::encoding::DefaultFuchsiaResourceDialect,
8196    >;
8197    fn r#set(&self, mut settings: &SetupSettings, mut reboot_device: bool) -> Self::SetResponseFut {
8198        fn _decode(
8199            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8200        ) -> Result<SetupSetResult, fidl::Error> {
8201            let _response = fidl::client::decode_transaction_body::<
8202                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
8203                fidl::encoding::DefaultFuchsiaResourceDialect,
8204                0x66a20be769388128,
8205            >(_buf?)?;
8206            Ok(_response.map(|x| x))
8207        }
8208        self.client.send_query_and_decode::<SetupSetRequest, SetupSetResult>(
8209            (settings, reboot_device),
8210            0x66a20be769388128,
8211            fidl::encoding::DynamicFlags::empty(),
8212            _decode,
8213        )
8214    }
8215}
8216
8217pub struct SetupEventStream {
8218    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8219}
8220
8221impl std::marker::Unpin for SetupEventStream {}
8222
8223impl futures::stream::FusedStream for SetupEventStream {
8224    fn is_terminated(&self) -> bool {
8225        self.event_receiver.is_terminated()
8226    }
8227}
8228
8229impl futures::Stream for SetupEventStream {
8230    type Item = Result<SetupEvent, fidl::Error>;
8231
8232    fn poll_next(
8233        mut self: std::pin::Pin<&mut Self>,
8234        cx: &mut std::task::Context<'_>,
8235    ) -> std::task::Poll<Option<Self::Item>> {
8236        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8237            &mut self.event_receiver,
8238            cx
8239        )?) {
8240            Some(buf) => std::task::Poll::Ready(Some(SetupEvent::decode(buf))),
8241            None => std::task::Poll::Ready(None),
8242        }
8243    }
8244}
8245
8246#[derive(Debug)]
8247pub enum SetupEvent {}
8248
8249impl SetupEvent {
8250    /// Decodes a message buffer as a [`SetupEvent`].
8251    fn decode(
8252        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8253    ) -> Result<SetupEvent, fidl::Error> {
8254        let (bytes, _handles) = buf.split_mut();
8255        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8256        debug_assert_eq!(tx_header.tx_id, 0);
8257        match tx_header.ordinal {
8258            _ => Err(fidl::Error::UnknownOrdinal {
8259                ordinal: tx_header.ordinal,
8260                protocol_name: <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8261            }),
8262        }
8263    }
8264}
8265
8266/// A Stream of incoming requests for fuchsia.settings/Setup.
8267pub struct SetupRequestStream {
8268    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8269    is_terminated: bool,
8270}
8271
8272impl std::marker::Unpin for SetupRequestStream {}
8273
8274impl futures::stream::FusedStream for SetupRequestStream {
8275    fn is_terminated(&self) -> bool {
8276        self.is_terminated
8277    }
8278}
8279
8280impl fidl::endpoints::RequestStream for SetupRequestStream {
8281    type Protocol = SetupMarker;
8282    type ControlHandle = SetupControlHandle;
8283
8284    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8285        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8286    }
8287
8288    fn control_handle(&self) -> Self::ControlHandle {
8289        SetupControlHandle { inner: self.inner.clone() }
8290    }
8291
8292    fn into_inner(
8293        self,
8294    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8295    {
8296        (self.inner, self.is_terminated)
8297    }
8298
8299    fn from_inner(
8300        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8301        is_terminated: bool,
8302    ) -> Self {
8303        Self { inner, is_terminated }
8304    }
8305}
8306
8307impl futures::Stream for SetupRequestStream {
8308    type Item = Result<SetupRequest, fidl::Error>;
8309
8310    fn poll_next(
8311        mut self: std::pin::Pin<&mut Self>,
8312        cx: &mut std::task::Context<'_>,
8313    ) -> std::task::Poll<Option<Self::Item>> {
8314        let this = &mut *self;
8315        if this.inner.check_shutdown(cx) {
8316            this.is_terminated = true;
8317            return std::task::Poll::Ready(None);
8318        }
8319        if this.is_terminated {
8320            panic!("polled SetupRequestStream after completion");
8321        }
8322        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8323            |bytes, handles| {
8324                match this.inner.channel().read_etc(cx, bytes, handles) {
8325                    std::task::Poll::Ready(Ok(())) => {}
8326                    std::task::Poll::Pending => return std::task::Poll::Pending,
8327                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8328                        this.is_terminated = true;
8329                        return std::task::Poll::Ready(None);
8330                    }
8331                    std::task::Poll::Ready(Err(e)) => {
8332                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8333                            e.into(),
8334                        ))))
8335                    }
8336                }
8337
8338                // A message has been received from the channel
8339                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8340
8341                std::task::Poll::Ready(Some(match header.ordinal {
8342                    0xd3893c0e63c0a6e => {
8343                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8344                        let mut req = fidl::new_empty!(
8345                            fidl::encoding::EmptyPayload,
8346                            fidl::encoding::DefaultFuchsiaResourceDialect
8347                        );
8348                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8349                        let control_handle = SetupControlHandle { inner: this.inner.clone() };
8350                        Ok(SetupRequest::Watch {
8351                            responder: SetupWatchResponder {
8352                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8353                                tx_id: header.tx_id,
8354                            },
8355                        })
8356                    }
8357                    0x66a20be769388128 => {
8358                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8359                        let mut req = fidl::new_empty!(
8360                            SetupSetRequest,
8361                            fidl::encoding::DefaultFuchsiaResourceDialect
8362                        );
8363                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SetupSetRequest>(&header, _body_bytes, handles, &mut req)?;
8364                        let control_handle = SetupControlHandle { inner: this.inner.clone() };
8365                        Ok(SetupRequest::Set {
8366                            settings: req.settings,
8367                            reboot_device: req.reboot_device,
8368
8369                            responder: SetupSetResponder {
8370                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8371                                tx_id: header.tx_id,
8372                            },
8373                        })
8374                    }
8375                    _ => Err(fidl::Error::UnknownOrdinal {
8376                        ordinal: header.ordinal,
8377                        protocol_name: <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8378                    }),
8379                }))
8380            },
8381        )
8382    }
8383}
8384
8385/// Settings that influence the device's setup behavior.
8386///
8387/// Supported SettingsEpitaph enums:
8388/// REQUEST_NOT_SUPPORTED, INTERNAL_SERVICE_ERROR, PERSISTENT_STORAGE_ERROR
8389#[derive(Debug)]
8390pub enum SetupRequest {
8391    /// Gets the current [SetupSettings]. Returns immediately on first call;
8392    /// subsequent calls return when the value changes.
8393    ///
8394    /// If this call fails, it is considered a fatal error and the channel
8395    /// will be closed.
8396    Watch { responder: SetupWatchResponder },
8397    /// Changes the settings specified in [SetupSettings]. Any field not set in
8398    /// the table will not perform any system operation. An error will be
8399    /// returned if the provided settings is an invalid change (for example, if
8400    /// it is empty).
8401    Set { settings: SetupSettings, reboot_device: bool, responder: SetupSetResponder },
8402}
8403
8404impl SetupRequest {
8405    #[allow(irrefutable_let_patterns)]
8406    pub fn into_watch(self) -> Option<(SetupWatchResponder)> {
8407        if let SetupRequest::Watch { responder } = self {
8408            Some((responder))
8409        } else {
8410            None
8411        }
8412    }
8413
8414    #[allow(irrefutable_let_patterns)]
8415    pub fn into_set(self) -> Option<(SetupSettings, bool, SetupSetResponder)> {
8416        if let SetupRequest::Set { settings, reboot_device, responder } = self {
8417            Some((settings, reboot_device, responder))
8418        } else {
8419            None
8420        }
8421    }
8422
8423    /// Name of the method defined in FIDL
8424    pub fn method_name(&self) -> &'static str {
8425        match *self {
8426            SetupRequest::Watch { .. } => "watch",
8427            SetupRequest::Set { .. } => "set",
8428        }
8429    }
8430}
8431
8432#[derive(Debug, Clone)]
8433pub struct SetupControlHandle {
8434    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8435}
8436
8437impl fidl::endpoints::ControlHandle for SetupControlHandle {
8438    fn shutdown(&self) {
8439        self.inner.shutdown()
8440    }
8441    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8442        self.inner.shutdown_with_epitaph(status)
8443    }
8444
8445    fn is_closed(&self) -> bool {
8446        self.inner.channel().is_closed()
8447    }
8448    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8449        self.inner.channel().on_closed()
8450    }
8451
8452    #[cfg(target_os = "fuchsia")]
8453    fn signal_peer(
8454        &self,
8455        clear_mask: zx::Signals,
8456        set_mask: zx::Signals,
8457    ) -> Result<(), zx_status::Status> {
8458        use fidl::Peered;
8459        self.inner.channel().signal_peer(clear_mask, set_mask)
8460    }
8461}
8462
8463impl SetupControlHandle {}
8464
8465#[must_use = "FIDL methods require a response to be sent"]
8466#[derive(Debug)]
8467pub struct SetupWatchResponder {
8468    control_handle: std::mem::ManuallyDrop<SetupControlHandle>,
8469    tx_id: u32,
8470}
8471
8472/// Set the the channel to be shutdown (see [`SetupControlHandle::shutdown`])
8473/// if the responder is dropped without sending a response, so that the client
8474/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8475impl std::ops::Drop for SetupWatchResponder {
8476    fn drop(&mut self) {
8477        self.control_handle.shutdown();
8478        // Safety: drops once, never accessed again
8479        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8480    }
8481}
8482
8483impl fidl::endpoints::Responder for SetupWatchResponder {
8484    type ControlHandle = SetupControlHandle;
8485
8486    fn control_handle(&self) -> &SetupControlHandle {
8487        &self.control_handle
8488    }
8489
8490    fn drop_without_shutdown(mut self) {
8491        // Safety: drops once, never accessed again due to mem::forget
8492        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8493        // Prevent Drop from running (which would shut down the channel)
8494        std::mem::forget(self);
8495    }
8496}
8497
8498impl SetupWatchResponder {
8499    /// Sends a response to the FIDL transaction.
8500    ///
8501    /// Sets the channel to shutdown if an error occurs.
8502    pub fn send(self, mut settings: &SetupSettings) -> Result<(), fidl::Error> {
8503        let _result = self.send_raw(settings);
8504        if _result.is_err() {
8505            self.control_handle.shutdown();
8506        }
8507        self.drop_without_shutdown();
8508        _result
8509    }
8510
8511    /// Similar to "send" but does not shutdown the channel if an error occurs.
8512    pub fn send_no_shutdown_on_err(self, mut settings: &SetupSettings) -> Result<(), fidl::Error> {
8513        let _result = self.send_raw(settings);
8514        self.drop_without_shutdown();
8515        _result
8516    }
8517
8518    fn send_raw(&self, mut settings: &SetupSettings) -> Result<(), fidl::Error> {
8519        self.control_handle.inner.send::<SetupWatchResponse>(
8520            (settings,),
8521            self.tx_id,
8522            0xd3893c0e63c0a6e,
8523            fidl::encoding::DynamicFlags::empty(),
8524        )
8525    }
8526}
8527
8528#[must_use = "FIDL methods require a response to be sent"]
8529#[derive(Debug)]
8530pub struct SetupSetResponder {
8531    control_handle: std::mem::ManuallyDrop<SetupControlHandle>,
8532    tx_id: u32,
8533}
8534
8535/// Set the the channel to be shutdown (see [`SetupControlHandle::shutdown`])
8536/// if the responder is dropped without sending a response, so that the client
8537/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8538impl std::ops::Drop for SetupSetResponder {
8539    fn drop(&mut self) {
8540        self.control_handle.shutdown();
8541        // Safety: drops once, never accessed again
8542        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8543    }
8544}
8545
8546impl fidl::endpoints::Responder for SetupSetResponder {
8547    type ControlHandle = SetupControlHandle;
8548
8549    fn control_handle(&self) -> &SetupControlHandle {
8550        &self.control_handle
8551    }
8552
8553    fn drop_without_shutdown(mut self) {
8554        // Safety: drops once, never accessed again due to mem::forget
8555        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8556        // Prevent Drop from running (which would shut down the channel)
8557        std::mem::forget(self);
8558    }
8559}
8560
8561impl SetupSetResponder {
8562    /// Sends a response to the FIDL transaction.
8563    ///
8564    /// Sets the channel to shutdown if an error occurs.
8565    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
8566        let _result = self.send_raw(result);
8567        if _result.is_err() {
8568            self.control_handle.shutdown();
8569        }
8570        self.drop_without_shutdown();
8571        _result
8572    }
8573
8574    /// Similar to "send" but does not shutdown the channel if an error occurs.
8575    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
8576        let _result = self.send_raw(result);
8577        self.drop_without_shutdown();
8578        _result
8579    }
8580
8581    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
8582        self.control_handle
8583            .inner
8584            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
8585                result,
8586                self.tx_id,
8587                0x66a20be769388128,
8588                fidl::encoding::DynamicFlags::empty(),
8589            )
8590    }
8591}
8592
8593mod internal {
8594    use super::*;
8595}