fidl_fuchsia_ui_policy/
fidl_fuchsia_ui_policy.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_ui_policy__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceListenerRegistryRegisterListenerRequest {
16    pub listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DeviceListenerRegistryRegisterListenerRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct DeviceListenerRegistryRegisterMediaButtonsListenerRequest {
26    pub listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for DeviceListenerRegistryRegisterMediaButtonsListenerRequest
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct DeviceListenerRegistryRegisterTouchButtonsListenerRequest {
36    pub listener: fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for DeviceListenerRegistryRegisterTouchButtonsListenerRequest
41{
42}
43
44#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
45pub struct DeviceListenerRegistryMarker;
46
47impl fidl::endpoints::ProtocolMarker for DeviceListenerRegistryMarker {
48    type Proxy = DeviceListenerRegistryProxy;
49    type RequestStream = DeviceListenerRegistryRequestStream;
50    #[cfg(target_os = "fuchsia")]
51    type SynchronousProxy = DeviceListenerRegistrySynchronousProxy;
52
53    const DEBUG_NAME: &'static str = "fuchsia.ui.policy.DeviceListenerRegistry";
54}
55impl fidl::endpoints::DiscoverableProtocolMarker for DeviceListenerRegistryMarker {}
56
57pub trait DeviceListenerRegistryProxyInterface: Send + Sync {
58    fn r#register_media_buttons_listener(
59        &self,
60        listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
61    ) -> Result<(), fidl::Error>;
62    type RegisterListenerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
63    fn r#register_listener(
64        &self,
65        listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
66    ) -> Self::RegisterListenerResponseFut;
67    type RegisterTouchButtonsListenerResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
68        + Send;
69    fn r#register_touch_buttons_listener(
70        &self,
71        listener: fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
72    ) -> Self::RegisterTouchButtonsListenerResponseFut;
73}
74#[derive(Debug)]
75#[cfg(target_os = "fuchsia")]
76pub struct DeviceListenerRegistrySynchronousProxy {
77    client: fidl::client::sync::Client,
78}
79
80#[cfg(target_os = "fuchsia")]
81impl fidl::endpoints::SynchronousProxy for DeviceListenerRegistrySynchronousProxy {
82    type Proxy = DeviceListenerRegistryProxy;
83    type Protocol = DeviceListenerRegistryMarker;
84
85    fn from_channel(inner: fidl::Channel) -> Self {
86        Self::new(inner)
87    }
88
89    fn into_channel(self) -> fidl::Channel {
90        self.client.into_channel()
91    }
92
93    fn as_channel(&self) -> &fidl::Channel {
94        self.client.as_channel()
95    }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl DeviceListenerRegistrySynchronousProxy {
100    pub fn new(channel: fidl::Channel) -> Self {
101        let protocol_name =
102            <DeviceListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
103        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
104    }
105
106    pub fn into_channel(self) -> fidl::Channel {
107        self.client.into_channel()
108    }
109
110    /// Waits until an event arrives and returns it. It is safe for other
111    /// threads to make concurrent requests while waiting for an event.
112    pub fn wait_for_event(
113        &self,
114        deadline: zx::MonotonicInstant,
115    ) -> Result<DeviceListenerRegistryEvent, fidl::Error> {
116        DeviceListenerRegistryEvent::decode(self.client.wait_for_event(deadline)?)
117    }
118
119    /// Registers a listener to receive media button related events, such as
120    /// changes from volume buttons and mute switches.
121    pub fn r#register_media_buttons_listener(
122        &self,
123        mut listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
124    ) -> Result<(), fidl::Error> {
125        self.client.send::<DeviceListenerRegistryRegisterMediaButtonsListenerRequest>(
126            (listener,),
127            0x3826318765c72e70,
128            fidl::encoding::DynamicFlags::empty(),
129        )
130    }
131
132    /// Registers a listener to receive media button related events, such as
133    /// changes from volume buttons and mute switches.
134    /// On registration, the `listener` receives the last media button event that
135    /// occurred, if one exists, and all media button events going forward.
136    pub fn r#register_listener(
137        &self,
138        mut listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
139        ___deadline: zx::MonotonicInstant,
140    ) -> Result<(), fidl::Error> {
141        let _response = self.client.send_query::<
142            DeviceListenerRegistryRegisterListenerRequest,
143            fidl::encoding::EmptyPayload,
144        >(
145            (listener,),
146            0x2f9e7eea89485a7b,
147            fidl::encoding::DynamicFlags::empty(),
148            ___deadline,
149        )?;
150        Ok(_response)
151    }
152
153    /// Registers a listener to receive touch button related events.
154    /// On registration, the `listener` receives the last touch button event that
155    /// occurred, if one exists, and all touch button events going forward.
156    pub fn r#register_touch_buttons_listener(
157        &self,
158        mut listener: fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
159        ___deadline: zx::MonotonicInstant,
160    ) -> Result<(), fidl::Error> {
161        let _response = self.client.send_query::<
162            DeviceListenerRegistryRegisterTouchButtonsListenerRequest,
163            fidl::encoding::EmptyPayload,
164        >(
165            (listener,),
166            0x1625430c46f9b84b,
167            fidl::encoding::DynamicFlags::empty(),
168            ___deadline,
169        )?;
170        Ok(_response)
171    }
172}
173
174#[cfg(target_os = "fuchsia")]
175impl From<DeviceListenerRegistrySynchronousProxy> for zx::Handle {
176    fn from(value: DeviceListenerRegistrySynchronousProxy) -> Self {
177        value.into_channel().into()
178    }
179}
180
181#[cfg(target_os = "fuchsia")]
182impl From<fidl::Channel> for DeviceListenerRegistrySynchronousProxy {
183    fn from(value: fidl::Channel) -> Self {
184        Self::new(value)
185    }
186}
187
188#[cfg(target_os = "fuchsia")]
189impl fidl::endpoints::FromClient for DeviceListenerRegistrySynchronousProxy {
190    type Protocol = DeviceListenerRegistryMarker;
191
192    fn from_client(value: fidl::endpoints::ClientEnd<DeviceListenerRegistryMarker>) -> Self {
193        Self::new(value.into_channel())
194    }
195}
196
197#[derive(Debug, Clone)]
198pub struct DeviceListenerRegistryProxy {
199    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
200}
201
202impl fidl::endpoints::Proxy for DeviceListenerRegistryProxy {
203    type Protocol = DeviceListenerRegistryMarker;
204
205    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
206        Self::new(inner)
207    }
208
209    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
210        self.client.into_channel().map_err(|client| Self { client })
211    }
212
213    fn as_channel(&self) -> &::fidl::AsyncChannel {
214        self.client.as_channel()
215    }
216}
217
218impl DeviceListenerRegistryProxy {
219    /// Create a new Proxy for fuchsia.ui.policy/DeviceListenerRegistry.
220    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
221        let protocol_name =
222            <DeviceListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
223        Self { client: fidl::client::Client::new(channel, protocol_name) }
224    }
225
226    /// Get a Stream of events from the remote end of the protocol.
227    ///
228    /// # Panics
229    ///
230    /// Panics if the event stream was already taken.
231    pub fn take_event_stream(&self) -> DeviceListenerRegistryEventStream {
232        DeviceListenerRegistryEventStream { event_receiver: self.client.take_event_receiver() }
233    }
234
235    /// Registers a listener to receive media button related events, such as
236    /// changes from volume buttons and mute switches.
237    pub fn r#register_media_buttons_listener(
238        &self,
239        mut listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
240    ) -> Result<(), fidl::Error> {
241        DeviceListenerRegistryProxyInterface::r#register_media_buttons_listener(self, listener)
242    }
243
244    /// Registers a listener to receive media button related events, such as
245    /// changes from volume buttons and mute switches.
246    /// On registration, the `listener` receives the last media button event that
247    /// occurred, if one exists, and all media button events going forward.
248    pub fn r#register_listener(
249        &self,
250        mut listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
251    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
252        DeviceListenerRegistryProxyInterface::r#register_listener(self, listener)
253    }
254
255    /// Registers a listener to receive touch button related events.
256    /// On registration, the `listener` receives the last touch button event that
257    /// occurred, if one exists, and all touch button events going forward.
258    pub fn r#register_touch_buttons_listener(
259        &self,
260        mut listener: fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
261    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
262        DeviceListenerRegistryProxyInterface::r#register_touch_buttons_listener(self, listener)
263    }
264}
265
266impl DeviceListenerRegistryProxyInterface for DeviceListenerRegistryProxy {
267    fn r#register_media_buttons_listener(
268        &self,
269        mut listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
270    ) -> Result<(), fidl::Error> {
271        self.client.send::<DeviceListenerRegistryRegisterMediaButtonsListenerRequest>(
272            (listener,),
273            0x3826318765c72e70,
274            fidl::encoding::DynamicFlags::empty(),
275        )
276    }
277
278    type RegisterListenerResponseFut =
279        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
280    fn r#register_listener(
281        &self,
282        mut listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
283    ) -> Self::RegisterListenerResponseFut {
284        fn _decode(
285            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
286        ) -> Result<(), fidl::Error> {
287            let _response = fidl::client::decode_transaction_body::<
288                fidl::encoding::EmptyPayload,
289                fidl::encoding::DefaultFuchsiaResourceDialect,
290                0x2f9e7eea89485a7b,
291            >(_buf?)?;
292            Ok(_response)
293        }
294        self.client.send_query_and_decode::<DeviceListenerRegistryRegisterListenerRequest, ()>(
295            (listener,),
296            0x2f9e7eea89485a7b,
297            fidl::encoding::DynamicFlags::empty(),
298            _decode,
299        )
300    }
301
302    type RegisterTouchButtonsListenerResponseFut =
303        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
304    fn r#register_touch_buttons_listener(
305        &self,
306        mut listener: fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
307    ) -> Self::RegisterTouchButtonsListenerResponseFut {
308        fn _decode(
309            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
310        ) -> Result<(), fidl::Error> {
311            let _response = fidl::client::decode_transaction_body::<
312                fidl::encoding::EmptyPayload,
313                fidl::encoding::DefaultFuchsiaResourceDialect,
314                0x1625430c46f9b84b,
315            >(_buf?)?;
316            Ok(_response)
317        }
318        self.client
319            .send_query_and_decode::<DeviceListenerRegistryRegisterTouchButtonsListenerRequest, ()>(
320                (listener,),
321                0x1625430c46f9b84b,
322                fidl::encoding::DynamicFlags::empty(),
323                _decode,
324            )
325    }
326}
327
328pub struct DeviceListenerRegistryEventStream {
329    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
330}
331
332impl std::marker::Unpin for DeviceListenerRegistryEventStream {}
333
334impl futures::stream::FusedStream for DeviceListenerRegistryEventStream {
335    fn is_terminated(&self) -> bool {
336        self.event_receiver.is_terminated()
337    }
338}
339
340impl futures::Stream for DeviceListenerRegistryEventStream {
341    type Item = Result<DeviceListenerRegistryEvent, fidl::Error>;
342
343    fn poll_next(
344        mut self: std::pin::Pin<&mut Self>,
345        cx: &mut std::task::Context<'_>,
346    ) -> std::task::Poll<Option<Self::Item>> {
347        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
348            &mut self.event_receiver,
349            cx
350        )?) {
351            Some(buf) => std::task::Poll::Ready(Some(DeviceListenerRegistryEvent::decode(buf))),
352            None => std::task::Poll::Ready(None),
353        }
354    }
355}
356
357#[derive(Debug)]
358pub enum DeviceListenerRegistryEvent {}
359
360impl DeviceListenerRegistryEvent {
361    /// Decodes a message buffer as a [`DeviceListenerRegistryEvent`].
362    fn decode(
363        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
364    ) -> Result<DeviceListenerRegistryEvent, fidl::Error> {
365        let (bytes, _handles) = buf.split_mut();
366        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
367        debug_assert_eq!(tx_header.tx_id, 0);
368        match tx_header.ordinal {
369            _ => Err(fidl::Error::UnknownOrdinal {
370                ordinal: tx_header.ordinal,
371                protocol_name:
372                    <DeviceListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
373            }),
374        }
375    }
376}
377
378/// A Stream of incoming requests for fuchsia.ui.policy/DeviceListenerRegistry.
379pub struct DeviceListenerRegistryRequestStream {
380    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
381    is_terminated: bool,
382}
383
384impl std::marker::Unpin for DeviceListenerRegistryRequestStream {}
385
386impl futures::stream::FusedStream for DeviceListenerRegistryRequestStream {
387    fn is_terminated(&self) -> bool {
388        self.is_terminated
389    }
390}
391
392impl fidl::endpoints::RequestStream for DeviceListenerRegistryRequestStream {
393    type Protocol = DeviceListenerRegistryMarker;
394    type ControlHandle = DeviceListenerRegistryControlHandle;
395
396    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
397        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
398    }
399
400    fn control_handle(&self) -> Self::ControlHandle {
401        DeviceListenerRegistryControlHandle { inner: self.inner.clone() }
402    }
403
404    fn into_inner(
405        self,
406    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
407    {
408        (self.inner, self.is_terminated)
409    }
410
411    fn from_inner(
412        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
413        is_terminated: bool,
414    ) -> Self {
415        Self { inner, is_terminated }
416    }
417}
418
419impl futures::Stream for DeviceListenerRegistryRequestStream {
420    type Item = Result<DeviceListenerRegistryRequest, fidl::Error>;
421
422    fn poll_next(
423        mut self: std::pin::Pin<&mut Self>,
424        cx: &mut std::task::Context<'_>,
425    ) -> std::task::Poll<Option<Self::Item>> {
426        let this = &mut *self;
427        if this.inner.check_shutdown(cx) {
428            this.is_terminated = true;
429            return std::task::Poll::Ready(None);
430        }
431        if this.is_terminated {
432            panic!("polled DeviceListenerRegistryRequestStream after completion");
433        }
434        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
435            |bytes, handles| {
436                match this.inner.channel().read_etc(cx, bytes, handles) {
437                    std::task::Poll::Ready(Ok(())) => {}
438                    std::task::Poll::Pending => return std::task::Poll::Pending,
439                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
440                        this.is_terminated = true;
441                        return std::task::Poll::Ready(None);
442                    }
443                    std::task::Poll::Ready(Err(e)) => {
444                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
445                            e.into(),
446                        ))))
447                    }
448                }
449
450                // A message has been received from the channel
451                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
452
453                std::task::Poll::Ready(Some(match header.ordinal {
454                0x3826318765c72e70 => {
455                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
456                    let mut req = fidl::new_empty!(DeviceListenerRegistryRegisterMediaButtonsListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
457                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceListenerRegistryRegisterMediaButtonsListenerRequest>(&header, _body_bytes, handles, &mut req)?;
458                    let control_handle = DeviceListenerRegistryControlHandle {
459                        inner: this.inner.clone(),
460                    };
461                    Ok(DeviceListenerRegistryRequest::RegisterMediaButtonsListener {listener: req.listener,
462
463                        control_handle,
464                    })
465                }
466                0x2f9e7eea89485a7b => {
467                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
468                    let mut req = fidl::new_empty!(DeviceListenerRegistryRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
469                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceListenerRegistryRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
470                    let control_handle = DeviceListenerRegistryControlHandle {
471                        inner: this.inner.clone(),
472                    };
473                    Ok(DeviceListenerRegistryRequest::RegisterListener {listener: req.listener,
474
475                        responder: DeviceListenerRegistryRegisterListenerResponder {
476                            control_handle: std::mem::ManuallyDrop::new(control_handle),
477                            tx_id: header.tx_id,
478                        },
479                    })
480                }
481                0x1625430c46f9b84b => {
482                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
483                    let mut req = fidl::new_empty!(DeviceListenerRegistryRegisterTouchButtonsListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
484                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceListenerRegistryRegisterTouchButtonsListenerRequest>(&header, _body_bytes, handles, &mut req)?;
485                    let control_handle = DeviceListenerRegistryControlHandle {
486                        inner: this.inner.clone(),
487                    };
488                    Ok(DeviceListenerRegistryRequest::RegisterTouchButtonsListener {listener: req.listener,
489
490                        responder: DeviceListenerRegistryRegisterTouchButtonsListenerResponder {
491                            control_handle: std::mem::ManuallyDrop::new(control_handle),
492                            tx_id: header.tx_id,
493                        },
494                    })
495                }
496                _ => Err(fidl::Error::UnknownOrdinal {
497                    ordinal: header.ordinal,
498                    protocol_name: <DeviceListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
499                }),
500            }))
501            },
502        )
503    }
504}
505
506/// Service for exposing state and events of devices, such as media buttons.
507#[derive(Debug)]
508pub enum DeviceListenerRegistryRequest {
509    /// Registers a listener to receive media button related events, such as
510    /// changes from volume buttons and mute switches.
511    RegisterMediaButtonsListener {
512        listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
513        control_handle: DeviceListenerRegistryControlHandle,
514    },
515    /// Registers a listener to receive media button related events, such as
516    /// changes from volume buttons and mute switches.
517    /// On registration, the `listener` receives the last media button event that
518    /// occurred, if one exists, and all media button events going forward.
519    RegisterListener {
520        listener: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
521        responder: DeviceListenerRegistryRegisterListenerResponder,
522    },
523    /// Registers a listener to receive touch button related events.
524    /// On registration, the `listener` receives the last touch button event that
525    /// occurred, if one exists, and all touch button events going forward.
526    RegisterTouchButtonsListener {
527        listener: fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
528        responder: DeviceListenerRegistryRegisterTouchButtonsListenerResponder,
529    },
530}
531
532impl DeviceListenerRegistryRequest {
533    #[allow(irrefutable_let_patterns)]
534    pub fn into_register_media_buttons_listener(
535        self,
536    ) -> Option<(
537        fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
538        DeviceListenerRegistryControlHandle,
539    )> {
540        if let DeviceListenerRegistryRequest::RegisterMediaButtonsListener {
541            listener,
542            control_handle,
543        } = self
544        {
545            Some((listener, control_handle))
546        } else {
547            None
548        }
549    }
550
551    #[allow(irrefutable_let_patterns)]
552    pub fn into_register_listener(
553        self,
554    ) -> Option<(
555        fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
556        DeviceListenerRegistryRegisterListenerResponder,
557    )> {
558        if let DeviceListenerRegistryRequest::RegisterListener { listener, responder } = self {
559            Some((listener, responder))
560        } else {
561            None
562        }
563    }
564
565    #[allow(irrefutable_let_patterns)]
566    pub fn into_register_touch_buttons_listener(
567        self,
568    ) -> Option<(
569        fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
570        DeviceListenerRegistryRegisterTouchButtonsListenerResponder,
571    )> {
572        if let DeviceListenerRegistryRequest::RegisterTouchButtonsListener { listener, responder } =
573            self
574        {
575            Some((listener, responder))
576        } else {
577            None
578        }
579    }
580
581    /// Name of the method defined in FIDL
582    pub fn method_name(&self) -> &'static str {
583        match *self {
584            DeviceListenerRegistryRequest::RegisterMediaButtonsListener { .. } => {
585                "register_media_buttons_listener"
586            }
587            DeviceListenerRegistryRequest::RegisterListener { .. } => "register_listener",
588            DeviceListenerRegistryRequest::RegisterTouchButtonsListener { .. } => {
589                "register_touch_buttons_listener"
590            }
591        }
592    }
593}
594
595#[derive(Debug, Clone)]
596pub struct DeviceListenerRegistryControlHandle {
597    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
598}
599
600impl fidl::endpoints::ControlHandle for DeviceListenerRegistryControlHandle {
601    fn shutdown(&self) {
602        self.inner.shutdown()
603    }
604    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
605        self.inner.shutdown_with_epitaph(status)
606    }
607
608    fn is_closed(&self) -> bool {
609        self.inner.channel().is_closed()
610    }
611    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
612        self.inner.channel().on_closed()
613    }
614
615    #[cfg(target_os = "fuchsia")]
616    fn signal_peer(
617        &self,
618        clear_mask: zx::Signals,
619        set_mask: zx::Signals,
620    ) -> Result<(), zx_status::Status> {
621        use fidl::Peered;
622        self.inner.channel().signal_peer(clear_mask, set_mask)
623    }
624}
625
626impl DeviceListenerRegistryControlHandle {}
627
628#[must_use = "FIDL methods require a response to be sent"]
629#[derive(Debug)]
630pub struct DeviceListenerRegistryRegisterListenerResponder {
631    control_handle: std::mem::ManuallyDrop<DeviceListenerRegistryControlHandle>,
632    tx_id: u32,
633}
634
635/// Set the the channel to be shutdown (see [`DeviceListenerRegistryControlHandle::shutdown`])
636/// if the responder is dropped without sending a response, so that the client
637/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
638impl std::ops::Drop for DeviceListenerRegistryRegisterListenerResponder {
639    fn drop(&mut self) {
640        self.control_handle.shutdown();
641        // Safety: drops once, never accessed again
642        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
643    }
644}
645
646impl fidl::endpoints::Responder for DeviceListenerRegistryRegisterListenerResponder {
647    type ControlHandle = DeviceListenerRegistryControlHandle;
648
649    fn control_handle(&self) -> &DeviceListenerRegistryControlHandle {
650        &self.control_handle
651    }
652
653    fn drop_without_shutdown(mut self) {
654        // Safety: drops once, never accessed again due to mem::forget
655        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
656        // Prevent Drop from running (which would shut down the channel)
657        std::mem::forget(self);
658    }
659}
660
661impl DeviceListenerRegistryRegisterListenerResponder {
662    /// Sends a response to the FIDL transaction.
663    ///
664    /// Sets the channel to shutdown if an error occurs.
665    pub fn send(self) -> Result<(), fidl::Error> {
666        let _result = self.send_raw();
667        if _result.is_err() {
668            self.control_handle.shutdown();
669        }
670        self.drop_without_shutdown();
671        _result
672    }
673
674    /// Similar to "send" but does not shutdown the channel if an error occurs.
675    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
676        let _result = self.send_raw();
677        self.drop_without_shutdown();
678        _result
679    }
680
681    fn send_raw(&self) -> Result<(), fidl::Error> {
682        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
683            (),
684            self.tx_id,
685            0x2f9e7eea89485a7b,
686            fidl::encoding::DynamicFlags::empty(),
687        )
688    }
689}
690
691#[must_use = "FIDL methods require a response to be sent"]
692#[derive(Debug)]
693pub struct DeviceListenerRegistryRegisterTouchButtonsListenerResponder {
694    control_handle: std::mem::ManuallyDrop<DeviceListenerRegistryControlHandle>,
695    tx_id: u32,
696}
697
698/// Set the the channel to be shutdown (see [`DeviceListenerRegistryControlHandle::shutdown`])
699/// if the responder is dropped without sending a response, so that the client
700/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
701impl std::ops::Drop for DeviceListenerRegistryRegisterTouchButtonsListenerResponder {
702    fn drop(&mut self) {
703        self.control_handle.shutdown();
704        // Safety: drops once, never accessed again
705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
706    }
707}
708
709impl fidl::endpoints::Responder for DeviceListenerRegistryRegisterTouchButtonsListenerResponder {
710    type ControlHandle = DeviceListenerRegistryControlHandle;
711
712    fn control_handle(&self) -> &DeviceListenerRegistryControlHandle {
713        &self.control_handle
714    }
715
716    fn drop_without_shutdown(mut self) {
717        // Safety: drops once, never accessed again due to mem::forget
718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
719        // Prevent Drop from running (which would shut down the channel)
720        std::mem::forget(self);
721    }
722}
723
724impl DeviceListenerRegistryRegisterTouchButtonsListenerResponder {
725    /// Sends a response to the FIDL transaction.
726    ///
727    /// Sets the channel to shutdown if an error occurs.
728    pub fn send(self) -> Result<(), fidl::Error> {
729        let _result = self.send_raw();
730        if _result.is_err() {
731            self.control_handle.shutdown();
732        }
733        self.drop_without_shutdown();
734        _result
735    }
736
737    /// Similar to "send" but does not shutdown the channel if an error occurs.
738    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
739        let _result = self.send_raw();
740        self.drop_without_shutdown();
741        _result
742    }
743
744    fn send_raw(&self) -> Result<(), fidl::Error> {
745        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
746            (),
747            self.tx_id,
748            0x1625430c46f9b84b,
749            fidl::encoding::DynamicFlags::empty(),
750        )
751    }
752}
753
754#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
755pub struct DisplayBacklightMarker;
756
757impl fidl::endpoints::ProtocolMarker for DisplayBacklightMarker {
758    type Proxy = DisplayBacklightProxy;
759    type RequestStream = DisplayBacklightRequestStream;
760    #[cfg(target_os = "fuchsia")]
761    type SynchronousProxy = DisplayBacklightSynchronousProxy;
762
763    const DEBUG_NAME: &'static str = "fuchsia.ui.policy.DisplayBacklight";
764}
765impl fidl::endpoints::DiscoverableProtocolMarker for DisplayBacklightMarker {}
766
767pub trait DisplayBacklightProxyInterface: Send + Sync {
768    type SetMinimumRgbResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
769    fn r#set_minimum_rgb(&self, minimum_rgb: u8) -> Self::SetMinimumRgbResponseFut;
770}
771#[derive(Debug)]
772#[cfg(target_os = "fuchsia")]
773pub struct DisplayBacklightSynchronousProxy {
774    client: fidl::client::sync::Client,
775}
776
777#[cfg(target_os = "fuchsia")]
778impl fidl::endpoints::SynchronousProxy for DisplayBacklightSynchronousProxy {
779    type Proxy = DisplayBacklightProxy;
780    type Protocol = DisplayBacklightMarker;
781
782    fn from_channel(inner: fidl::Channel) -> Self {
783        Self::new(inner)
784    }
785
786    fn into_channel(self) -> fidl::Channel {
787        self.client.into_channel()
788    }
789
790    fn as_channel(&self) -> &fidl::Channel {
791        self.client.as_channel()
792    }
793}
794
795#[cfg(target_os = "fuchsia")]
796impl DisplayBacklightSynchronousProxy {
797    pub fn new(channel: fidl::Channel) -> Self {
798        let protocol_name = <DisplayBacklightMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
799        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
800    }
801
802    pub fn into_channel(self) -> fidl::Channel {
803        self.client.into_channel()
804    }
805
806    /// Waits until an event arrives and returns it. It is safe for other
807    /// threads to make concurrent requests while waiting for an event.
808    pub fn wait_for_event(
809        &self,
810        deadline: zx::MonotonicInstant,
811    ) -> Result<DisplayBacklightEvent, fidl::Error> {
812        DisplayBacklightEvent::decode(self.client.wait_for_event(deadline)?)
813    }
814
815    /// Submits a new minimum color channel value for display backlight.
816    ///
817    /// The valid range for a minimum value is [0, 255] (inclusive).  For a new
818    /// minimum value M, each color channel's range will be limited to [M, 255].
819    ///
820    /// Flow control: The caller is allowed at most one in-flight
821    /// |SetMinimumRgb| at at time. Subsequent calls must wait until the
822    /// acknowledgment returns. Non-compliance results in channel closure.
823    pub fn r#set_minimum_rgb(
824        &self,
825        mut minimum_rgb: u8,
826        ___deadline: zx::MonotonicInstant,
827    ) -> Result<(), fidl::Error> {
828        let _response = self
829            .client
830            .send_query::<DisplayBacklightSetMinimumRgbRequest, fidl::encoding::EmptyPayload>(
831                (minimum_rgb,),
832                0x25604347bb8a1ca3,
833                fidl::encoding::DynamicFlags::empty(),
834                ___deadline,
835            )?;
836        Ok(_response)
837    }
838}
839
840#[cfg(target_os = "fuchsia")]
841impl From<DisplayBacklightSynchronousProxy> for zx::Handle {
842    fn from(value: DisplayBacklightSynchronousProxy) -> Self {
843        value.into_channel().into()
844    }
845}
846
847#[cfg(target_os = "fuchsia")]
848impl From<fidl::Channel> for DisplayBacklightSynchronousProxy {
849    fn from(value: fidl::Channel) -> Self {
850        Self::new(value)
851    }
852}
853
854#[cfg(target_os = "fuchsia")]
855impl fidl::endpoints::FromClient for DisplayBacklightSynchronousProxy {
856    type Protocol = DisplayBacklightMarker;
857
858    fn from_client(value: fidl::endpoints::ClientEnd<DisplayBacklightMarker>) -> Self {
859        Self::new(value.into_channel())
860    }
861}
862
863#[derive(Debug, Clone)]
864pub struct DisplayBacklightProxy {
865    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
866}
867
868impl fidl::endpoints::Proxy for DisplayBacklightProxy {
869    type Protocol = DisplayBacklightMarker;
870
871    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
872        Self::new(inner)
873    }
874
875    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
876        self.client.into_channel().map_err(|client| Self { client })
877    }
878
879    fn as_channel(&self) -> &::fidl::AsyncChannel {
880        self.client.as_channel()
881    }
882}
883
884impl DisplayBacklightProxy {
885    /// Create a new Proxy for fuchsia.ui.policy/DisplayBacklight.
886    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
887        let protocol_name = <DisplayBacklightMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
888        Self { client: fidl::client::Client::new(channel, protocol_name) }
889    }
890
891    /// Get a Stream of events from the remote end of the protocol.
892    ///
893    /// # Panics
894    ///
895    /// Panics if the event stream was already taken.
896    pub fn take_event_stream(&self) -> DisplayBacklightEventStream {
897        DisplayBacklightEventStream { event_receiver: self.client.take_event_receiver() }
898    }
899
900    /// Submits a new minimum color channel value for display backlight.
901    ///
902    /// The valid range for a minimum value is [0, 255] (inclusive).  For a new
903    /// minimum value M, each color channel's range will be limited to [M, 255].
904    ///
905    /// Flow control: The caller is allowed at most one in-flight
906    /// |SetMinimumRgb| at at time. Subsequent calls must wait until the
907    /// acknowledgment returns. Non-compliance results in channel closure.
908    pub fn r#set_minimum_rgb(
909        &self,
910        mut minimum_rgb: u8,
911    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
912        DisplayBacklightProxyInterface::r#set_minimum_rgb(self, minimum_rgb)
913    }
914}
915
916impl DisplayBacklightProxyInterface for DisplayBacklightProxy {
917    type SetMinimumRgbResponseFut =
918        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
919    fn r#set_minimum_rgb(&self, mut minimum_rgb: u8) -> Self::SetMinimumRgbResponseFut {
920        fn _decode(
921            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
922        ) -> Result<(), fidl::Error> {
923            let _response = fidl::client::decode_transaction_body::<
924                fidl::encoding::EmptyPayload,
925                fidl::encoding::DefaultFuchsiaResourceDialect,
926                0x25604347bb8a1ca3,
927            >(_buf?)?;
928            Ok(_response)
929        }
930        self.client.send_query_and_decode::<DisplayBacklightSetMinimumRgbRequest, ()>(
931            (minimum_rgb,),
932            0x25604347bb8a1ca3,
933            fidl::encoding::DynamicFlags::empty(),
934            _decode,
935        )
936    }
937}
938
939pub struct DisplayBacklightEventStream {
940    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
941}
942
943impl std::marker::Unpin for DisplayBacklightEventStream {}
944
945impl futures::stream::FusedStream for DisplayBacklightEventStream {
946    fn is_terminated(&self) -> bool {
947        self.event_receiver.is_terminated()
948    }
949}
950
951impl futures::Stream for DisplayBacklightEventStream {
952    type Item = Result<DisplayBacklightEvent, fidl::Error>;
953
954    fn poll_next(
955        mut self: std::pin::Pin<&mut Self>,
956        cx: &mut std::task::Context<'_>,
957    ) -> std::task::Poll<Option<Self::Item>> {
958        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
959            &mut self.event_receiver,
960            cx
961        )?) {
962            Some(buf) => std::task::Poll::Ready(Some(DisplayBacklightEvent::decode(buf))),
963            None => std::task::Poll::Ready(None),
964        }
965    }
966}
967
968#[derive(Debug)]
969pub enum DisplayBacklightEvent {}
970
971impl DisplayBacklightEvent {
972    /// Decodes a message buffer as a [`DisplayBacklightEvent`].
973    fn decode(
974        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
975    ) -> Result<DisplayBacklightEvent, fidl::Error> {
976        let (bytes, _handles) = buf.split_mut();
977        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
978        debug_assert_eq!(tx_header.tx_id, 0);
979        match tx_header.ordinal {
980            _ => Err(fidl::Error::UnknownOrdinal {
981                ordinal: tx_header.ordinal,
982                protocol_name:
983                    <DisplayBacklightMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
984            }),
985        }
986    }
987}
988
989/// A Stream of incoming requests for fuchsia.ui.policy/DisplayBacklight.
990pub struct DisplayBacklightRequestStream {
991    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
992    is_terminated: bool,
993}
994
995impl std::marker::Unpin for DisplayBacklightRequestStream {}
996
997impl futures::stream::FusedStream for DisplayBacklightRequestStream {
998    fn is_terminated(&self) -> bool {
999        self.is_terminated
1000    }
1001}
1002
1003impl fidl::endpoints::RequestStream for DisplayBacklightRequestStream {
1004    type Protocol = DisplayBacklightMarker;
1005    type ControlHandle = DisplayBacklightControlHandle;
1006
1007    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1008        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1009    }
1010
1011    fn control_handle(&self) -> Self::ControlHandle {
1012        DisplayBacklightControlHandle { inner: self.inner.clone() }
1013    }
1014
1015    fn into_inner(
1016        self,
1017    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1018    {
1019        (self.inner, self.is_terminated)
1020    }
1021
1022    fn from_inner(
1023        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1024        is_terminated: bool,
1025    ) -> Self {
1026        Self { inner, is_terminated }
1027    }
1028}
1029
1030impl futures::Stream for DisplayBacklightRequestStream {
1031    type Item = Result<DisplayBacklightRequest, fidl::Error>;
1032
1033    fn poll_next(
1034        mut self: std::pin::Pin<&mut Self>,
1035        cx: &mut std::task::Context<'_>,
1036    ) -> std::task::Poll<Option<Self::Item>> {
1037        let this = &mut *self;
1038        if this.inner.check_shutdown(cx) {
1039            this.is_terminated = true;
1040            return std::task::Poll::Ready(None);
1041        }
1042        if this.is_terminated {
1043            panic!("polled DisplayBacklightRequestStream after completion");
1044        }
1045        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1046            |bytes, handles| {
1047                match this.inner.channel().read_etc(cx, bytes, handles) {
1048                    std::task::Poll::Ready(Ok(())) => {}
1049                    std::task::Poll::Pending => return std::task::Poll::Pending,
1050                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1051                        this.is_terminated = true;
1052                        return std::task::Poll::Ready(None);
1053                    }
1054                    std::task::Poll::Ready(Err(e)) => {
1055                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1056                            e.into(),
1057                        ))))
1058                    }
1059                }
1060
1061                // A message has been received from the channel
1062                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1063
1064                std::task::Poll::Ready(Some(match header.ordinal {
1065                    0x25604347bb8a1ca3 => {
1066                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1067                        let mut req = fidl::new_empty!(
1068                            DisplayBacklightSetMinimumRgbRequest,
1069                            fidl::encoding::DefaultFuchsiaResourceDialect
1070                        );
1071                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DisplayBacklightSetMinimumRgbRequest>(&header, _body_bytes, handles, &mut req)?;
1072                        let control_handle =
1073                            DisplayBacklightControlHandle { inner: this.inner.clone() };
1074                        Ok(DisplayBacklightRequest::SetMinimumRgb {
1075                            minimum_rgb: req.minimum_rgb,
1076
1077                            responder: DisplayBacklightSetMinimumRgbResponder {
1078                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1079                                tx_id: header.tx_id,
1080                            },
1081                        })
1082                    }
1083                    _ => Err(fidl::Error::UnknownOrdinal {
1084                        ordinal: header.ordinal,
1085                        protocol_name:
1086                            <DisplayBacklightMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1087                    }),
1088                }))
1089            },
1090        )
1091    }
1092}
1093
1094/// Manipulates global policy for display backlight. Serves as the main "front
1095/// end" interface for usage by UX components; other protocols (such as
1096/// fuchsia.ui.scenic.Session and fuchsia.hardware.display.Controller) act as
1097/// implementation.
1098///
1099/// Global Scope. All displays, in all display controllers, are affected uniformly.
1100///
1101/// Effect Timing. This protocol does not guarantee a deadline by which the
1102/// minimum value is applied to a display; it is best effort.
1103///
1104/// Multiple clients. This protocol does not guarantee unique access to
1105/// manipulate display backlight functionality.
1106///
1107/// Reference. Related to fuchsia.hardware.display.Controller.
1108#[derive(Debug)]
1109pub enum DisplayBacklightRequest {
1110    /// Submits a new minimum color channel value for display backlight.
1111    ///
1112    /// The valid range for a minimum value is [0, 255] (inclusive).  For a new
1113    /// minimum value M, each color channel's range will be limited to [M, 255].
1114    ///
1115    /// Flow control: The caller is allowed at most one in-flight
1116    /// |SetMinimumRgb| at at time. Subsequent calls must wait until the
1117    /// acknowledgment returns. Non-compliance results in channel closure.
1118    SetMinimumRgb { minimum_rgb: u8, responder: DisplayBacklightSetMinimumRgbResponder },
1119}
1120
1121impl DisplayBacklightRequest {
1122    #[allow(irrefutable_let_patterns)]
1123    pub fn into_set_minimum_rgb(self) -> Option<(u8, DisplayBacklightSetMinimumRgbResponder)> {
1124        if let DisplayBacklightRequest::SetMinimumRgb { minimum_rgb, responder } = self {
1125            Some((minimum_rgb, responder))
1126        } else {
1127            None
1128        }
1129    }
1130
1131    /// Name of the method defined in FIDL
1132    pub fn method_name(&self) -> &'static str {
1133        match *self {
1134            DisplayBacklightRequest::SetMinimumRgb { .. } => "set_minimum_rgb",
1135        }
1136    }
1137}
1138
1139#[derive(Debug, Clone)]
1140pub struct DisplayBacklightControlHandle {
1141    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1142}
1143
1144impl fidl::endpoints::ControlHandle for DisplayBacklightControlHandle {
1145    fn shutdown(&self) {
1146        self.inner.shutdown()
1147    }
1148    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1149        self.inner.shutdown_with_epitaph(status)
1150    }
1151
1152    fn is_closed(&self) -> bool {
1153        self.inner.channel().is_closed()
1154    }
1155    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1156        self.inner.channel().on_closed()
1157    }
1158
1159    #[cfg(target_os = "fuchsia")]
1160    fn signal_peer(
1161        &self,
1162        clear_mask: zx::Signals,
1163        set_mask: zx::Signals,
1164    ) -> Result<(), zx_status::Status> {
1165        use fidl::Peered;
1166        self.inner.channel().signal_peer(clear_mask, set_mask)
1167    }
1168}
1169
1170impl DisplayBacklightControlHandle {}
1171
1172#[must_use = "FIDL methods require a response to be sent"]
1173#[derive(Debug)]
1174pub struct DisplayBacklightSetMinimumRgbResponder {
1175    control_handle: std::mem::ManuallyDrop<DisplayBacklightControlHandle>,
1176    tx_id: u32,
1177}
1178
1179/// Set the the channel to be shutdown (see [`DisplayBacklightControlHandle::shutdown`])
1180/// if the responder is dropped without sending a response, so that the client
1181/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1182impl std::ops::Drop for DisplayBacklightSetMinimumRgbResponder {
1183    fn drop(&mut self) {
1184        self.control_handle.shutdown();
1185        // Safety: drops once, never accessed again
1186        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1187    }
1188}
1189
1190impl fidl::endpoints::Responder for DisplayBacklightSetMinimumRgbResponder {
1191    type ControlHandle = DisplayBacklightControlHandle;
1192
1193    fn control_handle(&self) -> &DisplayBacklightControlHandle {
1194        &self.control_handle
1195    }
1196
1197    fn drop_without_shutdown(mut self) {
1198        // Safety: drops once, never accessed again due to mem::forget
1199        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1200        // Prevent Drop from running (which would shut down the channel)
1201        std::mem::forget(self);
1202    }
1203}
1204
1205impl DisplayBacklightSetMinimumRgbResponder {
1206    /// Sends a response to the FIDL transaction.
1207    ///
1208    /// Sets the channel to shutdown if an error occurs.
1209    pub fn send(self) -> Result<(), fidl::Error> {
1210        let _result = self.send_raw();
1211        if _result.is_err() {
1212            self.control_handle.shutdown();
1213        }
1214        self.drop_without_shutdown();
1215        _result
1216    }
1217
1218    /// Similar to "send" but does not shutdown the channel if an error occurs.
1219    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1220        let _result = self.send_raw();
1221        self.drop_without_shutdown();
1222        _result
1223    }
1224
1225    fn send_raw(&self) -> Result<(), fidl::Error> {
1226        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1227            (),
1228            self.tx_id,
1229            0x25604347bb8a1ca3,
1230            fidl::encoding::DynamicFlags::empty(),
1231        )
1232    }
1233}
1234
1235#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1236pub struct MediaButtonsListenerMarker;
1237
1238impl fidl::endpoints::ProtocolMarker for MediaButtonsListenerMarker {
1239    type Proxy = MediaButtonsListenerProxy;
1240    type RequestStream = MediaButtonsListenerRequestStream;
1241    #[cfg(target_os = "fuchsia")]
1242    type SynchronousProxy = MediaButtonsListenerSynchronousProxy;
1243
1244    const DEBUG_NAME: &'static str = "(anonymous) MediaButtonsListener";
1245}
1246
1247pub trait MediaButtonsListenerProxyInterface: Send + Sync {
1248    fn r#on_media_buttons_event(
1249        &self,
1250        event: &fidl_fuchsia_ui_input::MediaButtonsEvent,
1251    ) -> Result<(), fidl::Error>;
1252    type OnEventResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1253    fn r#on_event(
1254        &self,
1255        event: &fidl_fuchsia_ui_input::MediaButtonsEvent,
1256    ) -> Self::OnEventResponseFut;
1257}
1258#[derive(Debug)]
1259#[cfg(target_os = "fuchsia")]
1260pub struct MediaButtonsListenerSynchronousProxy {
1261    client: fidl::client::sync::Client,
1262}
1263
1264#[cfg(target_os = "fuchsia")]
1265impl fidl::endpoints::SynchronousProxy for MediaButtonsListenerSynchronousProxy {
1266    type Proxy = MediaButtonsListenerProxy;
1267    type Protocol = MediaButtonsListenerMarker;
1268
1269    fn from_channel(inner: fidl::Channel) -> Self {
1270        Self::new(inner)
1271    }
1272
1273    fn into_channel(self) -> fidl::Channel {
1274        self.client.into_channel()
1275    }
1276
1277    fn as_channel(&self) -> &fidl::Channel {
1278        self.client.as_channel()
1279    }
1280}
1281
1282#[cfg(target_os = "fuchsia")]
1283impl MediaButtonsListenerSynchronousProxy {
1284    pub fn new(channel: fidl::Channel) -> Self {
1285        let protocol_name =
1286            <MediaButtonsListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1287        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1288    }
1289
1290    pub fn into_channel(self) -> fidl::Channel {
1291        self.client.into_channel()
1292    }
1293
1294    /// Waits until an event arrives and returns it. It is safe for other
1295    /// threads to make concurrent requests while waiting for an event.
1296    pub fn wait_for_event(
1297        &self,
1298        deadline: zx::MonotonicInstant,
1299    ) -> Result<MediaButtonsListenerEvent, fidl::Error> {
1300        MediaButtonsListenerEvent::decode(self.client.wait_for_event(deadline)?)
1301    }
1302
1303    pub fn r#on_media_buttons_event(
1304        &self,
1305        mut event: &fidl_fuchsia_ui_input::MediaButtonsEvent,
1306    ) -> Result<(), fidl::Error> {
1307        self.client.send::<MediaButtonsListenerOnMediaButtonsEventRequest>(
1308            (event,),
1309            0x2c2068c386964e00,
1310            fidl::encoding::DynamicFlags::empty(),
1311        )
1312    }
1313
1314    pub fn r#on_event(
1315        &self,
1316        mut event: &fidl_fuchsia_ui_input::MediaButtonsEvent,
1317        ___deadline: zx::MonotonicInstant,
1318    ) -> Result<(), fidl::Error> {
1319        let _response = self
1320            .client
1321            .send_query::<MediaButtonsListenerOnEventRequest, fidl::encoding::EmptyPayload>(
1322                (event,),
1323                0x16e7130ddcaf877c,
1324                fidl::encoding::DynamicFlags::empty(),
1325                ___deadline,
1326            )?;
1327        Ok(_response)
1328    }
1329}
1330
1331#[cfg(target_os = "fuchsia")]
1332impl From<MediaButtonsListenerSynchronousProxy> for zx::Handle {
1333    fn from(value: MediaButtonsListenerSynchronousProxy) -> Self {
1334        value.into_channel().into()
1335    }
1336}
1337
1338#[cfg(target_os = "fuchsia")]
1339impl From<fidl::Channel> for MediaButtonsListenerSynchronousProxy {
1340    fn from(value: fidl::Channel) -> Self {
1341        Self::new(value)
1342    }
1343}
1344
1345#[cfg(target_os = "fuchsia")]
1346impl fidl::endpoints::FromClient for MediaButtonsListenerSynchronousProxy {
1347    type Protocol = MediaButtonsListenerMarker;
1348
1349    fn from_client(value: fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>) -> Self {
1350        Self::new(value.into_channel())
1351    }
1352}
1353
1354#[derive(Debug, Clone)]
1355pub struct MediaButtonsListenerProxy {
1356    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1357}
1358
1359impl fidl::endpoints::Proxy for MediaButtonsListenerProxy {
1360    type Protocol = MediaButtonsListenerMarker;
1361
1362    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1363        Self::new(inner)
1364    }
1365
1366    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1367        self.client.into_channel().map_err(|client| Self { client })
1368    }
1369
1370    fn as_channel(&self) -> &::fidl::AsyncChannel {
1371        self.client.as_channel()
1372    }
1373}
1374
1375impl MediaButtonsListenerProxy {
1376    /// Create a new Proxy for fuchsia.ui.policy/MediaButtonsListener.
1377    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1378        let protocol_name =
1379            <MediaButtonsListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1380        Self { client: fidl::client::Client::new(channel, protocol_name) }
1381    }
1382
1383    /// Get a Stream of events from the remote end of the protocol.
1384    ///
1385    /// # Panics
1386    ///
1387    /// Panics if the event stream was already taken.
1388    pub fn take_event_stream(&self) -> MediaButtonsListenerEventStream {
1389        MediaButtonsListenerEventStream { event_receiver: self.client.take_event_receiver() }
1390    }
1391
1392    pub fn r#on_media_buttons_event(
1393        &self,
1394        mut event: &fidl_fuchsia_ui_input::MediaButtonsEvent,
1395    ) -> Result<(), fidl::Error> {
1396        MediaButtonsListenerProxyInterface::r#on_media_buttons_event(self, event)
1397    }
1398
1399    pub fn r#on_event(
1400        &self,
1401        mut event: &fidl_fuchsia_ui_input::MediaButtonsEvent,
1402    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1403        MediaButtonsListenerProxyInterface::r#on_event(self, event)
1404    }
1405}
1406
1407impl MediaButtonsListenerProxyInterface for MediaButtonsListenerProxy {
1408    fn r#on_media_buttons_event(
1409        &self,
1410        mut event: &fidl_fuchsia_ui_input::MediaButtonsEvent,
1411    ) -> Result<(), fidl::Error> {
1412        self.client.send::<MediaButtonsListenerOnMediaButtonsEventRequest>(
1413            (event,),
1414            0x2c2068c386964e00,
1415            fidl::encoding::DynamicFlags::empty(),
1416        )
1417    }
1418
1419    type OnEventResponseFut =
1420        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1421    fn r#on_event(
1422        &self,
1423        mut event: &fidl_fuchsia_ui_input::MediaButtonsEvent,
1424    ) -> Self::OnEventResponseFut {
1425        fn _decode(
1426            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1427        ) -> Result<(), fidl::Error> {
1428            let _response = fidl::client::decode_transaction_body::<
1429                fidl::encoding::EmptyPayload,
1430                fidl::encoding::DefaultFuchsiaResourceDialect,
1431                0x16e7130ddcaf877c,
1432            >(_buf?)?;
1433            Ok(_response)
1434        }
1435        self.client.send_query_and_decode::<MediaButtonsListenerOnEventRequest, ()>(
1436            (event,),
1437            0x16e7130ddcaf877c,
1438            fidl::encoding::DynamicFlags::empty(),
1439            _decode,
1440        )
1441    }
1442}
1443
1444pub struct MediaButtonsListenerEventStream {
1445    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1446}
1447
1448impl std::marker::Unpin for MediaButtonsListenerEventStream {}
1449
1450impl futures::stream::FusedStream for MediaButtonsListenerEventStream {
1451    fn is_terminated(&self) -> bool {
1452        self.event_receiver.is_terminated()
1453    }
1454}
1455
1456impl futures::Stream for MediaButtonsListenerEventStream {
1457    type Item = Result<MediaButtonsListenerEvent, fidl::Error>;
1458
1459    fn poll_next(
1460        mut self: std::pin::Pin<&mut Self>,
1461        cx: &mut std::task::Context<'_>,
1462    ) -> std::task::Poll<Option<Self::Item>> {
1463        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1464            &mut self.event_receiver,
1465            cx
1466        )?) {
1467            Some(buf) => std::task::Poll::Ready(Some(MediaButtonsListenerEvent::decode(buf))),
1468            None => std::task::Poll::Ready(None),
1469        }
1470    }
1471}
1472
1473#[derive(Debug)]
1474pub enum MediaButtonsListenerEvent {}
1475
1476impl MediaButtonsListenerEvent {
1477    /// Decodes a message buffer as a [`MediaButtonsListenerEvent`].
1478    fn decode(
1479        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1480    ) -> Result<MediaButtonsListenerEvent, fidl::Error> {
1481        let (bytes, _handles) = buf.split_mut();
1482        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1483        debug_assert_eq!(tx_header.tx_id, 0);
1484        match tx_header.ordinal {
1485            _ => Err(fidl::Error::UnknownOrdinal {
1486                ordinal: tx_header.ordinal,
1487                protocol_name:
1488                    <MediaButtonsListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1489            }),
1490        }
1491    }
1492}
1493
1494/// A Stream of incoming requests for fuchsia.ui.policy/MediaButtonsListener.
1495pub struct MediaButtonsListenerRequestStream {
1496    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1497    is_terminated: bool,
1498}
1499
1500impl std::marker::Unpin for MediaButtonsListenerRequestStream {}
1501
1502impl futures::stream::FusedStream for MediaButtonsListenerRequestStream {
1503    fn is_terminated(&self) -> bool {
1504        self.is_terminated
1505    }
1506}
1507
1508impl fidl::endpoints::RequestStream for MediaButtonsListenerRequestStream {
1509    type Protocol = MediaButtonsListenerMarker;
1510    type ControlHandle = MediaButtonsListenerControlHandle;
1511
1512    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1513        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1514    }
1515
1516    fn control_handle(&self) -> Self::ControlHandle {
1517        MediaButtonsListenerControlHandle { inner: self.inner.clone() }
1518    }
1519
1520    fn into_inner(
1521        self,
1522    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1523    {
1524        (self.inner, self.is_terminated)
1525    }
1526
1527    fn from_inner(
1528        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1529        is_terminated: bool,
1530    ) -> Self {
1531        Self { inner, is_terminated }
1532    }
1533}
1534
1535impl futures::Stream for MediaButtonsListenerRequestStream {
1536    type Item = Result<MediaButtonsListenerRequest, fidl::Error>;
1537
1538    fn poll_next(
1539        mut self: std::pin::Pin<&mut Self>,
1540        cx: &mut std::task::Context<'_>,
1541    ) -> std::task::Poll<Option<Self::Item>> {
1542        let this = &mut *self;
1543        if this.inner.check_shutdown(cx) {
1544            this.is_terminated = true;
1545            return std::task::Poll::Ready(None);
1546        }
1547        if this.is_terminated {
1548            panic!("polled MediaButtonsListenerRequestStream after completion");
1549        }
1550        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1551            |bytes, handles| {
1552                match this.inner.channel().read_etc(cx, bytes, handles) {
1553                    std::task::Poll::Ready(Ok(())) => {}
1554                    std::task::Poll::Pending => return std::task::Poll::Pending,
1555                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1556                        this.is_terminated = true;
1557                        return std::task::Poll::Ready(None);
1558                    }
1559                    std::task::Poll::Ready(Err(e)) => {
1560                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1561                            e.into(),
1562                        ))))
1563                    }
1564                }
1565
1566                // A message has been received from the channel
1567                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1568
1569                std::task::Poll::Ready(Some(match header.ordinal {
1570                0x2c2068c386964e00 => {
1571                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1572                    let mut req = fidl::new_empty!(MediaButtonsListenerOnMediaButtonsEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1573                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MediaButtonsListenerOnMediaButtonsEventRequest>(&header, _body_bytes, handles, &mut req)?;
1574                    let control_handle = MediaButtonsListenerControlHandle {
1575                        inner: this.inner.clone(),
1576                    };
1577                    Ok(MediaButtonsListenerRequest::OnMediaButtonsEvent {event: req.event,
1578
1579                        control_handle,
1580                    })
1581                }
1582                0x16e7130ddcaf877c => {
1583                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1584                    let mut req = fidl::new_empty!(MediaButtonsListenerOnEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1585                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MediaButtonsListenerOnEventRequest>(&header, _body_bytes, handles, &mut req)?;
1586                    let control_handle = MediaButtonsListenerControlHandle {
1587                        inner: this.inner.clone(),
1588                    };
1589                    Ok(MediaButtonsListenerRequest::OnEvent {event: req.event,
1590
1591                        responder: MediaButtonsListenerOnEventResponder {
1592                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1593                            tx_id: header.tx_id,
1594                        },
1595                    })
1596                }
1597                _ => Err(fidl::Error::UnknownOrdinal {
1598                    ordinal: header.ordinal,
1599                    protocol_name: <MediaButtonsListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1600                }),
1601            }))
1602            },
1603        )
1604    }
1605}
1606
1607/// A listener for media buttons events.
1608/// [`fuchsia.ui.policy/DeviceListenerRegistry.RegisterMediaButtonsListener`]
1609/// will consume this listener interface and call `OnMediaButtonsEvent` when the
1610/// registered media buttons event occurs.
1611#[derive(Debug)]
1612pub enum MediaButtonsListenerRequest {
1613    OnMediaButtonsEvent {
1614        event: fidl_fuchsia_ui_input::MediaButtonsEvent,
1615        control_handle: MediaButtonsListenerControlHandle,
1616    },
1617    OnEvent {
1618        event: fidl_fuchsia_ui_input::MediaButtonsEvent,
1619        responder: MediaButtonsListenerOnEventResponder,
1620    },
1621}
1622
1623impl MediaButtonsListenerRequest {
1624    #[allow(irrefutable_let_patterns)]
1625    pub fn into_on_media_buttons_event(
1626        self,
1627    ) -> Option<(fidl_fuchsia_ui_input::MediaButtonsEvent, MediaButtonsListenerControlHandle)> {
1628        if let MediaButtonsListenerRequest::OnMediaButtonsEvent { event, control_handle } = self {
1629            Some((event, control_handle))
1630        } else {
1631            None
1632        }
1633    }
1634
1635    #[allow(irrefutable_let_patterns)]
1636    pub fn into_on_event(
1637        self,
1638    ) -> Option<(fidl_fuchsia_ui_input::MediaButtonsEvent, MediaButtonsListenerOnEventResponder)>
1639    {
1640        if let MediaButtonsListenerRequest::OnEvent { event, responder } = self {
1641            Some((event, responder))
1642        } else {
1643            None
1644        }
1645    }
1646
1647    /// Name of the method defined in FIDL
1648    pub fn method_name(&self) -> &'static str {
1649        match *self {
1650            MediaButtonsListenerRequest::OnMediaButtonsEvent { .. } => "on_media_buttons_event",
1651            MediaButtonsListenerRequest::OnEvent { .. } => "on_event",
1652        }
1653    }
1654}
1655
1656#[derive(Debug, Clone)]
1657pub struct MediaButtonsListenerControlHandle {
1658    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1659}
1660
1661impl fidl::endpoints::ControlHandle for MediaButtonsListenerControlHandle {
1662    fn shutdown(&self) {
1663        self.inner.shutdown()
1664    }
1665    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1666        self.inner.shutdown_with_epitaph(status)
1667    }
1668
1669    fn is_closed(&self) -> bool {
1670        self.inner.channel().is_closed()
1671    }
1672    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1673        self.inner.channel().on_closed()
1674    }
1675
1676    #[cfg(target_os = "fuchsia")]
1677    fn signal_peer(
1678        &self,
1679        clear_mask: zx::Signals,
1680        set_mask: zx::Signals,
1681    ) -> Result<(), zx_status::Status> {
1682        use fidl::Peered;
1683        self.inner.channel().signal_peer(clear_mask, set_mask)
1684    }
1685}
1686
1687impl MediaButtonsListenerControlHandle {}
1688
1689#[must_use = "FIDL methods require a response to be sent"]
1690#[derive(Debug)]
1691pub struct MediaButtonsListenerOnEventResponder {
1692    control_handle: std::mem::ManuallyDrop<MediaButtonsListenerControlHandle>,
1693    tx_id: u32,
1694}
1695
1696/// Set the the channel to be shutdown (see [`MediaButtonsListenerControlHandle::shutdown`])
1697/// if the responder is dropped without sending a response, so that the client
1698/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1699impl std::ops::Drop for MediaButtonsListenerOnEventResponder {
1700    fn drop(&mut self) {
1701        self.control_handle.shutdown();
1702        // Safety: drops once, never accessed again
1703        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1704    }
1705}
1706
1707impl fidl::endpoints::Responder for MediaButtonsListenerOnEventResponder {
1708    type ControlHandle = MediaButtonsListenerControlHandle;
1709
1710    fn control_handle(&self) -> &MediaButtonsListenerControlHandle {
1711        &self.control_handle
1712    }
1713
1714    fn drop_without_shutdown(mut self) {
1715        // Safety: drops once, never accessed again due to mem::forget
1716        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1717        // Prevent Drop from running (which would shut down the channel)
1718        std::mem::forget(self);
1719    }
1720}
1721
1722impl MediaButtonsListenerOnEventResponder {
1723    /// Sends a response to the FIDL transaction.
1724    ///
1725    /// Sets the channel to shutdown if an error occurs.
1726    pub fn send(self) -> Result<(), fidl::Error> {
1727        let _result = self.send_raw();
1728        if _result.is_err() {
1729            self.control_handle.shutdown();
1730        }
1731        self.drop_without_shutdown();
1732        _result
1733    }
1734
1735    /// Similar to "send" but does not shutdown the channel if an error occurs.
1736    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1737        let _result = self.send_raw();
1738        self.drop_without_shutdown();
1739        _result
1740    }
1741
1742    fn send_raw(&self) -> Result<(), fidl::Error> {
1743        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1744            (),
1745            self.tx_id,
1746            0x16e7130ddcaf877c,
1747            fidl::encoding::DynamicFlags::empty(),
1748        )
1749    }
1750}
1751
1752#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1753pub struct TouchButtonsListenerMarker;
1754
1755impl fidl::endpoints::ProtocolMarker for TouchButtonsListenerMarker {
1756    type Proxy = TouchButtonsListenerProxy;
1757    type RequestStream = TouchButtonsListenerRequestStream;
1758    #[cfg(target_os = "fuchsia")]
1759    type SynchronousProxy = TouchButtonsListenerSynchronousProxy;
1760
1761    const DEBUG_NAME: &'static str = "(anonymous) TouchButtonsListener";
1762}
1763
1764pub trait TouchButtonsListenerProxyInterface: Send + Sync {
1765    type OnEventResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1766    fn r#on_event(
1767        &self,
1768        event: &fidl_fuchsia_ui_input::TouchButtonsEvent,
1769    ) -> Self::OnEventResponseFut;
1770}
1771#[derive(Debug)]
1772#[cfg(target_os = "fuchsia")]
1773pub struct TouchButtonsListenerSynchronousProxy {
1774    client: fidl::client::sync::Client,
1775}
1776
1777#[cfg(target_os = "fuchsia")]
1778impl fidl::endpoints::SynchronousProxy for TouchButtonsListenerSynchronousProxy {
1779    type Proxy = TouchButtonsListenerProxy;
1780    type Protocol = TouchButtonsListenerMarker;
1781
1782    fn from_channel(inner: fidl::Channel) -> Self {
1783        Self::new(inner)
1784    }
1785
1786    fn into_channel(self) -> fidl::Channel {
1787        self.client.into_channel()
1788    }
1789
1790    fn as_channel(&self) -> &fidl::Channel {
1791        self.client.as_channel()
1792    }
1793}
1794
1795#[cfg(target_os = "fuchsia")]
1796impl TouchButtonsListenerSynchronousProxy {
1797    pub fn new(channel: fidl::Channel) -> Self {
1798        let protocol_name =
1799            <TouchButtonsListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1800        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1801    }
1802
1803    pub fn into_channel(self) -> fidl::Channel {
1804        self.client.into_channel()
1805    }
1806
1807    /// Waits until an event arrives and returns it. It is safe for other
1808    /// threads to make concurrent requests while waiting for an event.
1809    pub fn wait_for_event(
1810        &self,
1811        deadline: zx::MonotonicInstant,
1812    ) -> Result<TouchButtonsListenerEvent, fidl::Error> {
1813        TouchButtonsListenerEvent::decode(self.client.wait_for_event(deadline)?)
1814    }
1815
1816    pub fn r#on_event(
1817        &self,
1818        mut event: &fidl_fuchsia_ui_input::TouchButtonsEvent,
1819        ___deadline: zx::MonotonicInstant,
1820    ) -> Result<(), fidl::Error> {
1821        let _response = self
1822            .client
1823            .send_query::<TouchButtonsListenerOnEventRequest, fidl::encoding::EmptyPayload>(
1824                (event,),
1825                0x476b549161542f92,
1826                fidl::encoding::DynamicFlags::empty(),
1827                ___deadline,
1828            )?;
1829        Ok(_response)
1830    }
1831}
1832
1833#[cfg(target_os = "fuchsia")]
1834impl From<TouchButtonsListenerSynchronousProxy> for zx::Handle {
1835    fn from(value: TouchButtonsListenerSynchronousProxy) -> Self {
1836        value.into_channel().into()
1837    }
1838}
1839
1840#[cfg(target_os = "fuchsia")]
1841impl From<fidl::Channel> for TouchButtonsListenerSynchronousProxy {
1842    fn from(value: fidl::Channel) -> Self {
1843        Self::new(value)
1844    }
1845}
1846
1847#[cfg(target_os = "fuchsia")]
1848impl fidl::endpoints::FromClient for TouchButtonsListenerSynchronousProxy {
1849    type Protocol = TouchButtonsListenerMarker;
1850
1851    fn from_client(value: fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>) -> Self {
1852        Self::new(value.into_channel())
1853    }
1854}
1855
1856#[derive(Debug, Clone)]
1857pub struct TouchButtonsListenerProxy {
1858    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1859}
1860
1861impl fidl::endpoints::Proxy for TouchButtonsListenerProxy {
1862    type Protocol = TouchButtonsListenerMarker;
1863
1864    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1865        Self::new(inner)
1866    }
1867
1868    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1869        self.client.into_channel().map_err(|client| Self { client })
1870    }
1871
1872    fn as_channel(&self) -> &::fidl::AsyncChannel {
1873        self.client.as_channel()
1874    }
1875}
1876
1877impl TouchButtonsListenerProxy {
1878    /// Create a new Proxy for fuchsia.ui.policy/TouchButtonsListener.
1879    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1880        let protocol_name =
1881            <TouchButtonsListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1882        Self { client: fidl::client::Client::new(channel, protocol_name) }
1883    }
1884
1885    /// Get a Stream of events from the remote end of the protocol.
1886    ///
1887    /// # Panics
1888    ///
1889    /// Panics if the event stream was already taken.
1890    pub fn take_event_stream(&self) -> TouchButtonsListenerEventStream {
1891        TouchButtonsListenerEventStream { event_receiver: self.client.take_event_receiver() }
1892    }
1893
1894    pub fn r#on_event(
1895        &self,
1896        mut event: &fidl_fuchsia_ui_input::TouchButtonsEvent,
1897    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1898        TouchButtonsListenerProxyInterface::r#on_event(self, event)
1899    }
1900}
1901
1902impl TouchButtonsListenerProxyInterface for TouchButtonsListenerProxy {
1903    type OnEventResponseFut =
1904        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1905    fn r#on_event(
1906        &self,
1907        mut event: &fidl_fuchsia_ui_input::TouchButtonsEvent,
1908    ) -> Self::OnEventResponseFut {
1909        fn _decode(
1910            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1911        ) -> Result<(), fidl::Error> {
1912            let _response = fidl::client::decode_transaction_body::<
1913                fidl::encoding::EmptyPayload,
1914                fidl::encoding::DefaultFuchsiaResourceDialect,
1915                0x476b549161542f92,
1916            >(_buf?)?;
1917            Ok(_response)
1918        }
1919        self.client.send_query_and_decode::<TouchButtonsListenerOnEventRequest, ()>(
1920            (event,),
1921            0x476b549161542f92,
1922            fidl::encoding::DynamicFlags::empty(),
1923            _decode,
1924        )
1925    }
1926}
1927
1928pub struct TouchButtonsListenerEventStream {
1929    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1930}
1931
1932impl std::marker::Unpin for TouchButtonsListenerEventStream {}
1933
1934impl futures::stream::FusedStream for TouchButtonsListenerEventStream {
1935    fn is_terminated(&self) -> bool {
1936        self.event_receiver.is_terminated()
1937    }
1938}
1939
1940impl futures::Stream for TouchButtonsListenerEventStream {
1941    type Item = Result<TouchButtonsListenerEvent, fidl::Error>;
1942
1943    fn poll_next(
1944        mut self: std::pin::Pin<&mut Self>,
1945        cx: &mut std::task::Context<'_>,
1946    ) -> std::task::Poll<Option<Self::Item>> {
1947        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1948            &mut self.event_receiver,
1949            cx
1950        )?) {
1951            Some(buf) => std::task::Poll::Ready(Some(TouchButtonsListenerEvent::decode(buf))),
1952            None => std::task::Poll::Ready(None),
1953        }
1954    }
1955}
1956
1957#[derive(Debug)]
1958pub enum TouchButtonsListenerEvent {}
1959
1960impl TouchButtonsListenerEvent {
1961    /// Decodes a message buffer as a [`TouchButtonsListenerEvent`].
1962    fn decode(
1963        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1964    ) -> Result<TouchButtonsListenerEvent, fidl::Error> {
1965        let (bytes, _handles) = buf.split_mut();
1966        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1967        debug_assert_eq!(tx_header.tx_id, 0);
1968        match tx_header.ordinal {
1969            _ => Err(fidl::Error::UnknownOrdinal {
1970                ordinal: tx_header.ordinal,
1971                protocol_name:
1972                    <TouchButtonsListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1973            }),
1974        }
1975    }
1976}
1977
1978/// A Stream of incoming requests for fuchsia.ui.policy/TouchButtonsListener.
1979pub struct TouchButtonsListenerRequestStream {
1980    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1981    is_terminated: bool,
1982}
1983
1984impl std::marker::Unpin for TouchButtonsListenerRequestStream {}
1985
1986impl futures::stream::FusedStream for TouchButtonsListenerRequestStream {
1987    fn is_terminated(&self) -> bool {
1988        self.is_terminated
1989    }
1990}
1991
1992impl fidl::endpoints::RequestStream for TouchButtonsListenerRequestStream {
1993    type Protocol = TouchButtonsListenerMarker;
1994    type ControlHandle = TouchButtonsListenerControlHandle;
1995
1996    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1997        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1998    }
1999
2000    fn control_handle(&self) -> Self::ControlHandle {
2001        TouchButtonsListenerControlHandle { inner: self.inner.clone() }
2002    }
2003
2004    fn into_inner(
2005        self,
2006    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2007    {
2008        (self.inner, self.is_terminated)
2009    }
2010
2011    fn from_inner(
2012        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2013        is_terminated: bool,
2014    ) -> Self {
2015        Self { inner, is_terminated }
2016    }
2017}
2018
2019impl futures::Stream for TouchButtonsListenerRequestStream {
2020    type Item = Result<TouchButtonsListenerRequest, fidl::Error>;
2021
2022    fn poll_next(
2023        mut self: std::pin::Pin<&mut Self>,
2024        cx: &mut std::task::Context<'_>,
2025    ) -> std::task::Poll<Option<Self::Item>> {
2026        let this = &mut *self;
2027        if this.inner.check_shutdown(cx) {
2028            this.is_terminated = true;
2029            return std::task::Poll::Ready(None);
2030        }
2031        if this.is_terminated {
2032            panic!("polled TouchButtonsListenerRequestStream after completion");
2033        }
2034        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2035            |bytes, handles| {
2036                match this.inner.channel().read_etc(cx, bytes, handles) {
2037                    std::task::Poll::Ready(Ok(())) => {}
2038                    std::task::Poll::Pending => return std::task::Poll::Pending,
2039                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2040                        this.is_terminated = true;
2041                        return std::task::Poll::Ready(None);
2042                    }
2043                    std::task::Poll::Ready(Err(e)) => {
2044                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2045                            e.into(),
2046                        ))))
2047                    }
2048                }
2049
2050                // A message has been received from the channel
2051                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2052
2053                std::task::Poll::Ready(Some(match header.ordinal {
2054                0x476b549161542f92 => {
2055                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2056                    let mut req = fidl::new_empty!(TouchButtonsListenerOnEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2057                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchButtonsListenerOnEventRequest>(&header, _body_bytes, handles, &mut req)?;
2058                    let control_handle = TouchButtonsListenerControlHandle {
2059                        inner: this.inner.clone(),
2060                    };
2061                    Ok(TouchButtonsListenerRequest::OnEvent {event: req.event,
2062
2063                        responder: TouchButtonsListenerOnEventResponder {
2064                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2065                            tx_id: header.tx_id,
2066                        },
2067                    })
2068                }
2069                _ => Err(fidl::Error::UnknownOrdinal {
2070                    ordinal: header.ordinal,
2071                    protocol_name: <TouchButtonsListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2072                }),
2073            }))
2074            },
2075        )
2076    }
2077}
2078
2079/// A listener for touch buttons events.
2080/// [`fuchsia.ui.policy/DeviceListenerRegistry.RegisterTouchButtonsListener`]
2081/// will consume this listener interface and call `OnEvent` when the
2082/// registered touch buttons event occurs.
2083#[derive(Debug)]
2084pub enum TouchButtonsListenerRequest {
2085    OnEvent {
2086        event: fidl_fuchsia_ui_input::TouchButtonsEvent,
2087        responder: TouchButtonsListenerOnEventResponder,
2088    },
2089}
2090
2091impl TouchButtonsListenerRequest {
2092    #[allow(irrefutable_let_patterns)]
2093    pub fn into_on_event(
2094        self,
2095    ) -> Option<(fidl_fuchsia_ui_input::TouchButtonsEvent, TouchButtonsListenerOnEventResponder)>
2096    {
2097        if let TouchButtonsListenerRequest::OnEvent { event, responder } = self {
2098            Some((event, responder))
2099        } else {
2100            None
2101        }
2102    }
2103
2104    /// Name of the method defined in FIDL
2105    pub fn method_name(&self) -> &'static str {
2106        match *self {
2107            TouchButtonsListenerRequest::OnEvent { .. } => "on_event",
2108        }
2109    }
2110}
2111
2112#[derive(Debug, Clone)]
2113pub struct TouchButtonsListenerControlHandle {
2114    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2115}
2116
2117impl fidl::endpoints::ControlHandle for TouchButtonsListenerControlHandle {
2118    fn shutdown(&self) {
2119        self.inner.shutdown()
2120    }
2121    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2122        self.inner.shutdown_with_epitaph(status)
2123    }
2124
2125    fn is_closed(&self) -> bool {
2126        self.inner.channel().is_closed()
2127    }
2128    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2129        self.inner.channel().on_closed()
2130    }
2131
2132    #[cfg(target_os = "fuchsia")]
2133    fn signal_peer(
2134        &self,
2135        clear_mask: zx::Signals,
2136        set_mask: zx::Signals,
2137    ) -> Result<(), zx_status::Status> {
2138        use fidl::Peered;
2139        self.inner.channel().signal_peer(clear_mask, set_mask)
2140    }
2141}
2142
2143impl TouchButtonsListenerControlHandle {}
2144
2145#[must_use = "FIDL methods require a response to be sent"]
2146#[derive(Debug)]
2147pub struct TouchButtonsListenerOnEventResponder {
2148    control_handle: std::mem::ManuallyDrop<TouchButtonsListenerControlHandle>,
2149    tx_id: u32,
2150}
2151
2152/// Set the the channel to be shutdown (see [`TouchButtonsListenerControlHandle::shutdown`])
2153/// if the responder is dropped without sending a response, so that the client
2154/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2155impl std::ops::Drop for TouchButtonsListenerOnEventResponder {
2156    fn drop(&mut self) {
2157        self.control_handle.shutdown();
2158        // Safety: drops once, never accessed again
2159        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2160    }
2161}
2162
2163impl fidl::endpoints::Responder for TouchButtonsListenerOnEventResponder {
2164    type ControlHandle = TouchButtonsListenerControlHandle;
2165
2166    fn control_handle(&self) -> &TouchButtonsListenerControlHandle {
2167        &self.control_handle
2168    }
2169
2170    fn drop_without_shutdown(mut self) {
2171        // Safety: drops once, never accessed again due to mem::forget
2172        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2173        // Prevent Drop from running (which would shut down the channel)
2174        std::mem::forget(self);
2175    }
2176}
2177
2178impl TouchButtonsListenerOnEventResponder {
2179    /// Sends a response to the FIDL transaction.
2180    ///
2181    /// Sets the channel to shutdown if an error occurs.
2182    pub fn send(self) -> Result<(), fidl::Error> {
2183        let _result = self.send_raw();
2184        if _result.is_err() {
2185            self.control_handle.shutdown();
2186        }
2187        self.drop_without_shutdown();
2188        _result
2189    }
2190
2191    /// Similar to "send" but does not shutdown the channel if an error occurs.
2192    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2193        let _result = self.send_raw();
2194        self.drop_without_shutdown();
2195        _result
2196    }
2197
2198    fn send_raw(&self) -> Result<(), fidl::Error> {
2199        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2200            (),
2201            self.tx_id,
2202            0x476b549161542f92,
2203            fidl::encoding::DynamicFlags::empty(),
2204        )
2205    }
2206}
2207
2208mod internal {
2209    use super::*;
2210
2211    impl fidl::encoding::ResourceTypeMarker for DeviceListenerRegistryRegisterListenerRequest {
2212        type Borrowed<'a> = &'a mut Self;
2213        fn take_or_borrow<'a>(
2214            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2215        ) -> Self::Borrowed<'a> {
2216            value
2217        }
2218    }
2219
2220    unsafe impl fidl::encoding::TypeMarker for DeviceListenerRegistryRegisterListenerRequest {
2221        type Owned = Self;
2222
2223        #[inline(always)]
2224        fn inline_align(_context: fidl::encoding::Context) -> usize {
2225            4
2226        }
2227
2228        #[inline(always)]
2229        fn inline_size(_context: fidl::encoding::Context) -> usize {
2230            4
2231        }
2232    }
2233
2234    unsafe impl
2235        fidl::encoding::Encode<
2236            DeviceListenerRegistryRegisterListenerRequest,
2237            fidl::encoding::DefaultFuchsiaResourceDialect,
2238        > for &mut DeviceListenerRegistryRegisterListenerRequest
2239    {
2240        #[inline]
2241        unsafe fn encode(
2242            self,
2243            encoder: &mut fidl::encoding::Encoder<
2244                '_,
2245                fidl::encoding::DefaultFuchsiaResourceDialect,
2246            >,
2247            offset: usize,
2248            _depth: fidl::encoding::Depth,
2249        ) -> fidl::Result<()> {
2250            encoder.debug_check_bounds::<DeviceListenerRegistryRegisterListenerRequest>(offset);
2251            // Delegate to tuple encoding.
2252            fidl::encoding::Encode::<
2253                DeviceListenerRegistryRegisterListenerRequest,
2254                fidl::encoding::DefaultFuchsiaResourceDialect,
2255            >::encode(
2256                (
2257                    <fidl::encoding::Endpoint<
2258                        fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
2259                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2260                        &mut self.listener
2261                    ),
2262                ),
2263                encoder,
2264                offset,
2265                _depth,
2266            )
2267        }
2268    }
2269    unsafe impl<
2270            T0: fidl::encoding::Encode<
2271                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>>,
2272                fidl::encoding::DefaultFuchsiaResourceDialect,
2273            >,
2274        >
2275        fidl::encoding::Encode<
2276            DeviceListenerRegistryRegisterListenerRequest,
2277            fidl::encoding::DefaultFuchsiaResourceDialect,
2278        > for (T0,)
2279    {
2280        #[inline]
2281        unsafe fn encode(
2282            self,
2283            encoder: &mut fidl::encoding::Encoder<
2284                '_,
2285                fidl::encoding::DefaultFuchsiaResourceDialect,
2286            >,
2287            offset: usize,
2288            depth: fidl::encoding::Depth,
2289        ) -> fidl::Result<()> {
2290            encoder.debug_check_bounds::<DeviceListenerRegistryRegisterListenerRequest>(offset);
2291            // Zero out padding regions. There's no need to apply masks
2292            // because the unmasked parts will be overwritten by fields.
2293            // Write the fields.
2294            self.0.encode(encoder, offset + 0, depth)?;
2295            Ok(())
2296        }
2297    }
2298
2299    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2300        for DeviceListenerRegistryRegisterListenerRequest
2301    {
2302        #[inline(always)]
2303        fn new_empty() -> Self {
2304            Self {
2305                listener: fidl::new_empty!(
2306                    fidl::encoding::Endpoint<
2307                        fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
2308                    >,
2309                    fidl::encoding::DefaultFuchsiaResourceDialect
2310                ),
2311            }
2312        }
2313
2314        #[inline]
2315        unsafe fn decode(
2316            &mut self,
2317            decoder: &mut fidl::encoding::Decoder<
2318                '_,
2319                fidl::encoding::DefaultFuchsiaResourceDialect,
2320            >,
2321            offset: usize,
2322            _depth: fidl::encoding::Depth,
2323        ) -> fidl::Result<()> {
2324            decoder.debug_check_bounds::<Self>(offset);
2325            // Verify that padding bytes are zero.
2326            fidl::decode!(
2327                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>>,
2328                fidl::encoding::DefaultFuchsiaResourceDialect,
2329                &mut self.listener,
2330                decoder,
2331                offset + 0,
2332                _depth
2333            )?;
2334            Ok(())
2335        }
2336    }
2337
2338    impl fidl::encoding::ResourceTypeMarker
2339        for DeviceListenerRegistryRegisterMediaButtonsListenerRequest
2340    {
2341        type Borrowed<'a> = &'a mut Self;
2342        fn take_or_borrow<'a>(
2343            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2344        ) -> Self::Borrowed<'a> {
2345            value
2346        }
2347    }
2348
2349    unsafe impl fidl::encoding::TypeMarker
2350        for DeviceListenerRegistryRegisterMediaButtonsListenerRequest
2351    {
2352        type Owned = Self;
2353
2354        #[inline(always)]
2355        fn inline_align(_context: fidl::encoding::Context) -> usize {
2356            4
2357        }
2358
2359        #[inline(always)]
2360        fn inline_size(_context: fidl::encoding::Context) -> usize {
2361            4
2362        }
2363    }
2364
2365    unsafe impl
2366        fidl::encoding::Encode<
2367            DeviceListenerRegistryRegisterMediaButtonsListenerRequest,
2368            fidl::encoding::DefaultFuchsiaResourceDialect,
2369        > for &mut DeviceListenerRegistryRegisterMediaButtonsListenerRequest
2370    {
2371        #[inline]
2372        unsafe fn encode(
2373            self,
2374            encoder: &mut fidl::encoding::Encoder<
2375                '_,
2376                fidl::encoding::DefaultFuchsiaResourceDialect,
2377            >,
2378            offset: usize,
2379            _depth: fidl::encoding::Depth,
2380        ) -> fidl::Result<()> {
2381            encoder
2382                .debug_check_bounds::<DeviceListenerRegistryRegisterMediaButtonsListenerRequest>(
2383                    offset,
2384                );
2385            // Delegate to tuple encoding.
2386            fidl::encoding::Encode::<
2387                DeviceListenerRegistryRegisterMediaButtonsListenerRequest,
2388                fidl::encoding::DefaultFuchsiaResourceDialect,
2389            >::encode(
2390                (
2391                    <fidl::encoding::Endpoint<
2392                        fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
2393                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2394                        &mut self.listener
2395                    ),
2396                ),
2397                encoder,
2398                offset,
2399                _depth,
2400            )
2401        }
2402    }
2403    unsafe impl<
2404            T0: fidl::encoding::Encode<
2405                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>>,
2406                fidl::encoding::DefaultFuchsiaResourceDialect,
2407            >,
2408        >
2409        fidl::encoding::Encode<
2410            DeviceListenerRegistryRegisterMediaButtonsListenerRequest,
2411            fidl::encoding::DefaultFuchsiaResourceDialect,
2412        > for (T0,)
2413    {
2414        #[inline]
2415        unsafe fn encode(
2416            self,
2417            encoder: &mut fidl::encoding::Encoder<
2418                '_,
2419                fidl::encoding::DefaultFuchsiaResourceDialect,
2420            >,
2421            offset: usize,
2422            depth: fidl::encoding::Depth,
2423        ) -> fidl::Result<()> {
2424            encoder
2425                .debug_check_bounds::<DeviceListenerRegistryRegisterMediaButtonsListenerRequest>(
2426                    offset,
2427                );
2428            // Zero out padding regions. There's no need to apply masks
2429            // because the unmasked parts will be overwritten by fields.
2430            // Write the fields.
2431            self.0.encode(encoder, offset + 0, depth)?;
2432            Ok(())
2433        }
2434    }
2435
2436    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2437        for DeviceListenerRegistryRegisterMediaButtonsListenerRequest
2438    {
2439        #[inline(always)]
2440        fn new_empty() -> Self {
2441            Self {
2442                listener: fidl::new_empty!(
2443                    fidl::encoding::Endpoint<
2444                        fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>,
2445                    >,
2446                    fidl::encoding::DefaultFuchsiaResourceDialect
2447                ),
2448            }
2449        }
2450
2451        #[inline]
2452        unsafe fn decode(
2453            &mut self,
2454            decoder: &mut fidl::encoding::Decoder<
2455                '_,
2456                fidl::encoding::DefaultFuchsiaResourceDialect,
2457            >,
2458            offset: usize,
2459            _depth: fidl::encoding::Depth,
2460        ) -> fidl::Result<()> {
2461            decoder.debug_check_bounds::<Self>(offset);
2462            // Verify that padding bytes are zero.
2463            fidl::decode!(
2464                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MediaButtonsListenerMarker>>,
2465                fidl::encoding::DefaultFuchsiaResourceDialect,
2466                &mut self.listener,
2467                decoder,
2468                offset + 0,
2469                _depth
2470            )?;
2471            Ok(())
2472        }
2473    }
2474
2475    impl fidl::encoding::ResourceTypeMarker
2476        for DeviceListenerRegistryRegisterTouchButtonsListenerRequest
2477    {
2478        type Borrowed<'a> = &'a mut Self;
2479        fn take_or_borrow<'a>(
2480            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2481        ) -> Self::Borrowed<'a> {
2482            value
2483        }
2484    }
2485
2486    unsafe impl fidl::encoding::TypeMarker
2487        for DeviceListenerRegistryRegisterTouchButtonsListenerRequest
2488    {
2489        type Owned = Self;
2490
2491        #[inline(always)]
2492        fn inline_align(_context: fidl::encoding::Context) -> usize {
2493            4
2494        }
2495
2496        #[inline(always)]
2497        fn inline_size(_context: fidl::encoding::Context) -> usize {
2498            4
2499        }
2500    }
2501
2502    unsafe impl
2503        fidl::encoding::Encode<
2504            DeviceListenerRegistryRegisterTouchButtonsListenerRequest,
2505            fidl::encoding::DefaultFuchsiaResourceDialect,
2506        > for &mut DeviceListenerRegistryRegisterTouchButtonsListenerRequest
2507    {
2508        #[inline]
2509        unsafe fn encode(
2510            self,
2511            encoder: &mut fidl::encoding::Encoder<
2512                '_,
2513                fidl::encoding::DefaultFuchsiaResourceDialect,
2514            >,
2515            offset: usize,
2516            _depth: fidl::encoding::Depth,
2517        ) -> fidl::Result<()> {
2518            encoder
2519                .debug_check_bounds::<DeviceListenerRegistryRegisterTouchButtonsListenerRequest>(
2520                    offset,
2521                );
2522            // Delegate to tuple encoding.
2523            fidl::encoding::Encode::<
2524                DeviceListenerRegistryRegisterTouchButtonsListenerRequest,
2525                fidl::encoding::DefaultFuchsiaResourceDialect,
2526            >::encode(
2527                (
2528                    <fidl::encoding::Endpoint<
2529                        fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
2530                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2531                        &mut self.listener
2532                    ),
2533                ),
2534                encoder,
2535                offset,
2536                _depth,
2537            )
2538        }
2539    }
2540    unsafe impl<
2541            T0: fidl::encoding::Encode<
2542                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>>,
2543                fidl::encoding::DefaultFuchsiaResourceDialect,
2544            >,
2545        >
2546        fidl::encoding::Encode<
2547            DeviceListenerRegistryRegisterTouchButtonsListenerRequest,
2548            fidl::encoding::DefaultFuchsiaResourceDialect,
2549        > for (T0,)
2550    {
2551        #[inline]
2552        unsafe fn encode(
2553            self,
2554            encoder: &mut fidl::encoding::Encoder<
2555                '_,
2556                fidl::encoding::DefaultFuchsiaResourceDialect,
2557            >,
2558            offset: usize,
2559            depth: fidl::encoding::Depth,
2560        ) -> fidl::Result<()> {
2561            encoder
2562                .debug_check_bounds::<DeviceListenerRegistryRegisterTouchButtonsListenerRequest>(
2563                    offset,
2564                );
2565            // Zero out padding regions. There's no need to apply masks
2566            // because the unmasked parts will be overwritten by fields.
2567            // Write the fields.
2568            self.0.encode(encoder, offset + 0, depth)?;
2569            Ok(())
2570        }
2571    }
2572
2573    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2574        for DeviceListenerRegistryRegisterTouchButtonsListenerRequest
2575    {
2576        #[inline(always)]
2577        fn new_empty() -> Self {
2578            Self {
2579                listener: fidl::new_empty!(
2580                    fidl::encoding::Endpoint<
2581                        fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>,
2582                    >,
2583                    fidl::encoding::DefaultFuchsiaResourceDialect
2584                ),
2585            }
2586        }
2587
2588        #[inline]
2589        unsafe fn decode(
2590            &mut self,
2591            decoder: &mut fidl::encoding::Decoder<
2592                '_,
2593                fidl::encoding::DefaultFuchsiaResourceDialect,
2594            >,
2595            offset: usize,
2596            _depth: fidl::encoding::Depth,
2597        ) -> fidl::Result<()> {
2598            decoder.debug_check_bounds::<Self>(offset);
2599            // Verify that padding bytes are zero.
2600            fidl::decode!(
2601                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TouchButtonsListenerMarker>>,
2602                fidl::encoding::DefaultFuchsiaResourceDialect,
2603                &mut self.listener,
2604                decoder,
2605                offset + 0,
2606                _depth
2607            )?;
2608            Ok(())
2609        }
2610    }
2611}