Skip to main content

fidl_fuchsia_ui_input/
fidl_fuchsia_ui_input.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_input_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<DeviceListenerMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DeviceListenerRegistryRegisterListenerRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct DeviceListenerRegistryRegisterListenerResponse {
26    pub iterator: fidl::endpoints::ClientEnd<DeviceIteratorMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for DeviceListenerRegistryRegisterListenerResponse
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct ImeServiceGetInputMethodEditorRequest {
36    pub keyboard_type: KeyboardType,
37    pub action: InputMethodAction,
38    pub initial_state: TextInputState,
39    pub client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
40    pub editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
41}
42
43impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
44    for ImeServiceGetInputMethodEditorRequest
45{
46}
47
48#[derive(Debug, Default, PartialEq)]
49pub struct MediaButtonsEvent {
50    pub volume: Option<i8>,
51    pub mic_mute: Option<bool>,
52    pub pause: Option<bool>,
53    pub camera_disable: Option<bool>,
54    pub power: Option<bool>,
55    pub function: Option<bool>,
56    pub device_id: Option<u32>,
57    /// Optional wake lease for power baton passing.
58    pub wake_lease: Option<fidl::EventPair>,
59    /// Optional trace flow ID to connect the event flow.
60    pub trace_flow_id: Option<u64>,
61    #[doc(hidden)]
62    pub __source_breaking: fidl::marker::SourceBreaking,
63}
64
65impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for MediaButtonsEvent {}
66
67#[derive(Debug, Default, PartialEq)]
68pub struct TouchButtonsEvent {
69    pub event_time: Option<fidl::MonotonicInstant>,
70    pub device_info: Option<TouchDeviceInfo>,
71    pub pressed_buttons: Option<Vec<TouchButton>>,
72    /// Optional wake lease for power baton passing.
73    pub wake_lease: Option<fidl::EventPair>,
74    /// Optional trace flow ID to connect the event flow.
75    pub trace_flow_id: Option<u64>,
76    #[doc(hidden)]
77    pub __source_breaking: fidl::marker::SourceBreaking,
78}
79
80impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TouchButtonsEvent {}
81
82#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
83pub struct DeviceIteratorMarker;
84
85impl fidl::endpoints::ProtocolMarker for DeviceIteratorMarker {
86    type Proxy = DeviceIteratorProxy;
87    type RequestStream = DeviceIteratorRequestStream;
88    #[cfg(target_os = "fuchsia")]
89    type SynchronousProxy = DeviceIteratorSynchronousProxy;
90
91    const DEBUG_NAME: &'static str = "(anonymous) DeviceIterator";
92}
93
94pub trait DeviceIteratorProxyInterface: Send + Sync {
95    type GetNextResponseFut: std::future::Future<Output = Result<Vec<DeviceEvent>, fidl::Error>>
96        + Send;
97    fn r#get_next(&self) -> Self::GetNextResponseFut;
98}
99#[derive(Debug)]
100#[cfg(target_os = "fuchsia")]
101pub struct DeviceIteratorSynchronousProxy {
102    client: fidl::client::sync::Client,
103}
104
105#[cfg(target_os = "fuchsia")]
106impl fidl::endpoints::SynchronousProxy for DeviceIteratorSynchronousProxy {
107    type Proxy = DeviceIteratorProxy;
108    type Protocol = DeviceIteratorMarker;
109
110    fn from_channel(inner: fidl::Channel) -> Self {
111        Self::new(inner)
112    }
113
114    fn into_channel(self) -> fidl::Channel {
115        self.client.into_channel()
116    }
117
118    fn as_channel(&self) -> &fidl::Channel {
119        self.client.as_channel()
120    }
121}
122
123#[cfg(target_os = "fuchsia")]
124impl DeviceIteratorSynchronousProxy {
125    pub fn new(channel: fidl::Channel) -> Self {
126        Self { client: fidl::client::sync::Client::new(channel) }
127    }
128
129    pub fn into_channel(self) -> fidl::Channel {
130        self.client.into_channel()
131    }
132
133    /// Waits until an event arrives and returns it. It is safe for other
134    /// threads to make concurrent requests while waiting for an event.
135    pub fn wait_for_event(
136        &self,
137        deadline: zx::MonotonicInstant,
138    ) -> Result<DeviceIteratorEvent, fidl::Error> {
139        DeviceIteratorEvent::decode(self.client.wait_for_event::<DeviceIteratorMarker>(deadline)?)
140    }
141
142    /// Returns the next batch of active devices.
143    ///
144    /// Returns an empty vector when all existing devices have been iterated
145    /// through. The client should then close this channel and rely on the
146    /// `DeviceListener` for subsequent events.
147    pub fn r#get_next(
148        &self,
149        ___deadline: zx::MonotonicInstant,
150    ) -> Result<Vec<DeviceEvent>, fidl::Error> {
151        let _response = self.client.send_query::<
152            fidl::encoding::EmptyPayload,
153            DeviceIteratorGetNextResponse,
154            DeviceIteratorMarker,
155        >(
156            (),
157            0x79d55fdbc97fd5fc,
158            fidl::encoding::DynamicFlags::empty(),
159            ___deadline,
160        )?;
161        Ok(_response.devices)
162    }
163}
164
165#[cfg(target_os = "fuchsia")]
166impl From<DeviceIteratorSynchronousProxy> for zx::NullableHandle {
167    fn from(value: DeviceIteratorSynchronousProxy) -> Self {
168        value.into_channel().into()
169    }
170}
171
172#[cfg(target_os = "fuchsia")]
173impl From<fidl::Channel> for DeviceIteratorSynchronousProxy {
174    fn from(value: fidl::Channel) -> Self {
175        Self::new(value)
176    }
177}
178
179#[cfg(target_os = "fuchsia")]
180impl fidl::endpoints::FromClient for DeviceIteratorSynchronousProxy {
181    type Protocol = DeviceIteratorMarker;
182
183    fn from_client(value: fidl::endpoints::ClientEnd<DeviceIteratorMarker>) -> Self {
184        Self::new(value.into_channel())
185    }
186}
187
188#[derive(Debug, Clone)]
189pub struct DeviceIteratorProxy {
190    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
191}
192
193impl fidl::endpoints::Proxy for DeviceIteratorProxy {
194    type Protocol = DeviceIteratorMarker;
195
196    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
197        Self::new(inner)
198    }
199
200    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
201        self.client.into_channel().map_err(|client| Self { client })
202    }
203
204    fn as_channel(&self) -> &::fidl::AsyncChannel {
205        self.client.as_channel()
206    }
207}
208
209impl DeviceIteratorProxy {
210    /// Create a new Proxy for fuchsia.ui.input/DeviceIterator.
211    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
212        let protocol_name = <DeviceIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
213        Self { client: fidl::client::Client::new(channel, protocol_name) }
214    }
215
216    /// Get a Stream of events from the remote end of the protocol.
217    ///
218    /// # Panics
219    ///
220    /// Panics if the event stream was already taken.
221    pub fn take_event_stream(&self) -> DeviceIteratorEventStream {
222        DeviceIteratorEventStream { event_receiver: self.client.take_event_receiver() }
223    }
224
225    /// Returns the next batch of active devices.
226    ///
227    /// Returns an empty vector when all existing devices have been iterated
228    /// through. The client should then close this channel and rely on the
229    /// `DeviceListener` for subsequent events.
230    pub fn r#get_next(
231        &self,
232    ) -> fidl::client::QueryResponseFut<
233        Vec<DeviceEvent>,
234        fidl::encoding::DefaultFuchsiaResourceDialect,
235    > {
236        DeviceIteratorProxyInterface::r#get_next(self)
237    }
238}
239
240impl DeviceIteratorProxyInterface for DeviceIteratorProxy {
241    type GetNextResponseFut = fidl::client::QueryResponseFut<
242        Vec<DeviceEvent>,
243        fidl::encoding::DefaultFuchsiaResourceDialect,
244    >;
245    fn r#get_next(&self) -> Self::GetNextResponseFut {
246        fn _decode(
247            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
248        ) -> Result<Vec<DeviceEvent>, fidl::Error> {
249            let _response = fidl::client::decode_transaction_body::<
250                DeviceIteratorGetNextResponse,
251                fidl::encoding::DefaultFuchsiaResourceDialect,
252                0x79d55fdbc97fd5fc,
253            >(_buf?)?;
254            Ok(_response.devices)
255        }
256        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<DeviceEvent>>(
257            (),
258            0x79d55fdbc97fd5fc,
259            fidl::encoding::DynamicFlags::empty(),
260            _decode,
261        )
262    }
263}
264
265pub struct DeviceIteratorEventStream {
266    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
267}
268
269impl std::marker::Unpin for DeviceIteratorEventStream {}
270
271impl futures::stream::FusedStream for DeviceIteratorEventStream {
272    fn is_terminated(&self) -> bool {
273        self.event_receiver.is_terminated()
274    }
275}
276
277impl futures::Stream for DeviceIteratorEventStream {
278    type Item = Result<DeviceIteratorEvent, fidl::Error>;
279
280    fn poll_next(
281        mut self: std::pin::Pin<&mut Self>,
282        cx: &mut std::task::Context<'_>,
283    ) -> std::task::Poll<Option<Self::Item>> {
284        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
285            &mut self.event_receiver,
286            cx
287        )?) {
288            Some(buf) => std::task::Poll::Ready(Some(DeviceIteratorEvent::decode(buf))),
289            None => std::task::Poll::Ready(None),
290        }
291    }
292}
293
294#[derive(Debug)]
295pub enum DeviceIteratorEvent {}
296
297impl DeviceIteratorEvent {
298    /// Decodes a message buffer as a [`DeviceIteratorEvent`].
299    fn decode(
300        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
301    ) -> Result<DeviceIteratorEvent, fidl::Error> {
302        let (bytes, _handles) = buf.split_mut();
303        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
304        debug_assert_eq!(tx_header.tx_id, 0);
305        match tx_header.ordinal {
306            _ => Err(fidl::Error::UnknownOrdinal {
307                ordinal: tx_header.ordinal,
308                protocol_name:
309                    <DeviceIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
310            }),
311        }
312    }
313}
314
315/// A Stream of incoming requests for fuchsia.ui.input/DeviceIterator.
316pub struct DeviceIteratorRequestStream {
317    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
318    is_terminated: bool,
319}
320
321impl std::marker::Unpin for DeviceIteratorRequestStream {}
322
323impl futures::stream::FusedStream for DeviceIteratorRequestStream {
324    fn is_terminated(&self) -> bool {
325        self.is_terminated
326    }
327}
328
329impl fidl::endpoints::RequestStream for DeviceIteratorRequestStream {
330    type Protocol = DeviceIteratorMarker;
331    type ControlHandle = DeviceIteratorControlHandle;
332
333    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
334        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
335    }
336
337    fn control_handle(&self) -> Self::ControlHandle {
338        DeviceIteratorControlHandle { inner: self.inner.clone() }
339    }
340
341    fn into_inner(
342        self,
343    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
344    {
345        (self.inner, self.is_terminated)
346    }
347
348    fn from_inner(
349        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
350        is_terminated: bool,
351    ) -> Self {
352        Self { inner, is_terminated }
353    }
354}
355
356impl futures::Stream for DeviceIteratorRequestStream {
357    type Item = Result<DeviceIteratorRequest, fidl::Error>;
358
359    fn poll_next(
360        mut self: std::pin::Pin<&mut Self>,
361        cx: &mut std::task::Context<'_>,
362    ) -> std::task::Poll<Option<Self::Item>> {
363        let this = &mut *self;
364        if this.inner.check_shutdown(cx) {
365            this.is_terminated = true;
366            return std::task::Poll::Ready(None);
367        }
368        if this.is_terminated {
369            panic!("polled DeviceIteratorRequestStream after completion");
370        }
371        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
372            |bytes, handles| {
373                match this.inner.channel().read_etc(cx, bytes, handles) {
374                    std::task::Poll::Ready(Ok(())) => {}
375                    std::task::Poll::Pending => return std::task::Poll::Pending,
376                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
377                        this.is_terminated = true;
378                        return std::task::Poll::Ready(None);
379                    }
380                    std::task::Poll::Ready(Err(e)) => {
381                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
382                            e.into(),
383                        ))));
384                    }
385                }
386
387                // A message has been received from the channel
388                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
389
390                std::task::Poll::Ready(Some(match header.ordinal {
391                    0x79d55fdbc97fd5fc => {
392                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
393                        let mut req = fidl::new_empty!(
394                            fidl::encoding::EmptyPayload,
395                            fidl::encoding::DefaultFuchsiaResourceDialect
396                        );
397                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
398                        let control_handle =
399                            DeviceIteratorControlHandle { inner: this.inner.clone() };
400                        Ok(DeviceIteratorRequest::GetNext {
401                            responder: DeviceIteratorGetNextResponder {
402                                control_handle: std::mem::ManuallyDrop::new(control_handle),
403                                tx_id: header.tx_id,
404                            },
405                        })
406                    }
407                    _ => Err(fidl::Error::UnknownOrdinal {
408                        ordinal: header.ordinal,
409                        protocol_name:
410                            <DeviceIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
411                    }),
412                }))
413            },
414        )
415    }
416}
417
418/// Protocol for iterating over the initial set of active devices.
419///
420/// This iterator is returned upon registering a listener and is used to bootstrap
421/// the client's state with the devices that are already present.
422#[derive(Debug)]
423pub enum DeviceIteratorRequest {
424    /// Returns the next batch of active devices.
425    ///
426    /// Returns an empty vector when all existing devices have been iterated
427    /// through. The client should then close this channel and rely on the
428    /// `DeviceListener` for subsequent events.
429    GetNext { responder: DeviceIteratorGetNextResponder },
430}
431
432impl DeviceIteratorRequest {
433    #[allow(irrefutable_let_patterns)]
434    pub fn into_get_next(self) -> Option<(DeviceIteratorGetNextResponder)> {
435        if let DeviceIteratorRequest::GetNext { responder } = self {
436            Some((responder))
437        } else {
438            None
439        }
440    }
441
442    /// Name of the method defined in FIDL
443    pub fn method_name(&self) -> &'static str {
444        match *self {
445            DeviceIteratorRequest::GetNext { .. } => "get_next",
446        }
447    }
448}
449
450#[derive(Debug, Clone)]
451pub struct DeviceIteratorControlHandle {
452    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
453}
454
455impl DeviceIteratorControlHandle {
456    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
457        self.inner.shutdown_with_epitaph(status.into())
458    }
459}
460
461impl fidl::endpoints::ControlHandle for DeviceIteratorControlHandle {
462    fn shutdown(&self) {
463        self.inner.shutdown()
464    }
465
466    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
467        self.inner.shutdown_with_epitaph(status)
468    }
469
470    fn is_closed(&self) -> bool {
471        self.inner.channel().is_closed()
472    }
473    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
474        self.inner.channel().on_closed()
475    }
476
477    #[cfg(target_os = "fuchsia")]
478    fn signal_peer(
479        &self,
480        clear_mask: zx::Signals,
481        set_mask: zx::Signals,
482    ) -> Result<(), zx_status::Status> {
483        use fidl::Peered;
484        self.inner.channel().signal_peer(clear_mask, set_mask)
485    }
486}
487
488impl DeviceIteratorControlHandle {}
489
490#[must_use = "FIDL methods require a response to be sent"]
491#[derive(Debug)]
492pub struct DeviceIteratorGetNextResponder {
493    control_handle: std::mem::ManuallyDrop<DeviceIteratorControlHandle>,
494    tx_id: u32,
495}
496
497/// Set the the channel to be shutdown (see [`DeviceIteratorControlHandle::shutdown`])
498/// if the responder is dropped without sending a response, so that the client
499/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
500impl std::ops::Drop for DeviceIteratorGetNextResponder {
501    fn drop(&mut self) {
502        self.control_handle.shutdown();
503        // Safety: drops once, never accessed again
504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
505    }
506}
507
508impl fidl::endpoints::Responder for DeviceIteratorGetNextResponder {
509    type ControlHandle = DeviceIteratorControlHandle;
510
511    fn control_handle(&self) -> &DeviceIteratorControlHandle {
512        &self.control_handle
513    }
514
515    fn drop_without_shutdown(mut self) {
516        // Safety: drops once, never accessed again due to mem::forget
517        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
518        // Prevent Drop from running (which would shut down the channel)
519        std::mem::forget(self);
520    }
521}
522
523impl DeviceIteratorGetNextResponder {
524    /// Sends a response to the FIDL transaction.
525    ///
526    /// Sets the channel to shutdown if an error occurs.
527    pub fn send(self, mut devices: &[DeviceEvent]) -> Result<(), fidl::Error> {
528        let _result = self.send_raw(devices);
529        if _result.is_err() {
530            self.control_handle.shutdown();
531        }
532        self.drop_without_shutdown();
533        _result
534    }
535
536    /// Similar to "send" but does not shutdown the channel if an error occurs.
537    pub fn send_no_shutdown_on_err(self, mut devices: &[DeviceEvent]) -> Result<(), fidl::Error> {
538        let _result = self.send_raw(devices);
539        self.drop_without_shutdown();
540        _result
541    }
542
543    fn send_raw(&self, mut devices: &[DeviceEvent]) -> Result<(), fidl::Error> {
544        self.control_handle.inner.send::<DeviceIteratorGetNextResponse>(
545            (devices,),
546            self.tx_id,
547            0x79d55fdbc97fd5fc,
548            fidl::encoding::DynamicFlags::empty(),
549        )
550    }
551}
552
553#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
554pub struct DeviceListenerMarker;
555
556impl fidl::endpoints::ProtocolMarker for DeviceListenerMarker {
557    type Proxy = DeviceListenerProxy;
558    type RequestStream = DeviceListenerRequestStream;
559    #[cfg(target_os = "fuchsia")]
560    type SynchronousProxy = DeviceListenerSynchronousProxy;
561
562    const DEBUG_NAME: &'static str = "(anonymous) DeviceListener";
563}
564
565pub trait DeviceListenerProxyInterface: Send + Sync {
566    fn r#on_device_changed(&self, event: &DeviceEvent) -> Result<(), fidl::Error>;
567}
568#[derive(Debug)]
569#[cfg(target_os = "fuchsia")]
570pub struct DeviceListenerSynchronousProxy {
571    client: fidl::client::sync::Client,
572}
573
574#[cfg(target_os = "fuchsia")]
575impl fidl::endpoints::SynchronousProxy for DeviceListenerSynchronousProxy {
576    type Proxy = DeviceListenerProxy;
577    type Protocol = DeviceListenerMarker;
578
579    fn from_channel(inner: fidl::Channel) -> Self {
580        Self::new(inner)
581    }
582
583    fn into_channel(self) -> fidl::Channel {
584        self.client.into_channel()
585    }
586
587    fn as_channel(&self) -> &fidl::Channel {
588        self.client.as_channel()
589    }
590}
591
592#[cfg(target_os = "fuchsia")]
593impl DeviceListenerSynchronousProxy {
594    pub fn new(channel: fidl::Channel) -> Self {
595        Self { client: fidl::client::sync::Client::new(channel) }
596    }
597
598    pub fn into_channel(self) -> fidl::Channel {
599        self.client.into_channel()
600    }
601
602    /// Waits until an event arrives and returns it. It is safe for other
603    /// threads to make concurrent requests while waiting for an event.
604    pub fn wait_for_event(
605        &self,
606        deadline: zx::MonotonicInstant,
607    ) -> Result<DeviceListenerEvent, fidl::Error> {
608        DeviceListenerEvent::decode(self.client.wait_for_event::<DeviceListenerMarker>(deadline)?)
609    }
610
611    /// Called when a device change event occurs.
612    pub fn r#on_device_changed(&self, mut event: &DeviceEvent) -> Result<(), fidl::Error> {
613        self.client.send::<DeviceListenerOnDeviceChangedRequest>(
614            (event,),
615            0x24025aac5d70a184,
616            fidl::encoding::DynamicFlags::empty(),
617        )
618    }
619}
620
621#[cfg(target_os = "fuchsia")]
622impl From<DeviceListenerSynchronousProxy> for zx::NullableHandle {
623    fn from(value: DeviceListenerSynchronousProxy) -> Self {
624        value.into_channel().into()
625    }
626}
627
628#[cfg(target_os = "fuchsia")]
629impl From<fidl::Channel> for DeviceListenerSynchronousProxy {
630    fn from(value: fidl::Channel) -> Self {
631        Self::new(value)
632    }
633}
634
635#[cfg(target_os = "fuchsia")]
636impl fidl::endpoints::FromClient for DeviceListenerSynchronousProxy {
637    type Protocol = DeviceListenerMarker;
638
639    fn from_client(value: fidl::endpoints::ClientEnd<DeviceListenerMarker>) -> Self {
640        Self::new(value.into_channel())
641    }
642}
643
644#[derive(Debug, Clone)]
645pub struct DeviceListenerProxy {
646    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
647}
648
649impl fidl::endpoints::Proxy for DeviceListenerProxy {
650    type Protocol = DeviceListenerMarker;
651
652    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
653        Self::new(inner)
654    }
655
656    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
657        self.client.into_channel().map_err(|client| Self { client })
658    }
659
660    fn as_channel(&self) -> &::fidl::AsyncChannel {
661        self.client.as_channel()
662    }
663}
664
665impl DeviceListenerProxy {
666    /// Create a new Proxy for fuchsia.ui.input/DeviceListener.
667    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
668        let protocol_name = <DeviceListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
669        Self { client: fidl::client::Client::new(channel, protocol_name) }
670    }
671
672    /// Get a Stream of events from the remote end of the protocol.
673    ///
674    /// # Panics
675    ///
676    /// Panics if the event stream was already taken.
677    pub fn take_event_stream(&self) -> DeviceListenerEventStream {
678        DeviceListenerEventStream { event_receiver: self.client.take_event_receiver() }
679    }
680
681    /// Called when a device change event occurs.
682    pub fn r#on_device_changed(&self, mut event: &DeviceEvent) -> Result<(), fidl::Error> {
683        DeviceListenerProxyInterface::r#on_device_changed(self, event)
684    }
685}
686
687impl DeviceListenerProxyInterface for DeviceListenerProxy {
688    fn r#on_device_changed(&self, mut event: &DeviceEvent) -> Result<(), fidl::Error> {
689        self.client.send::<DeviceListenerOnDeviceChangedRequest>(
690            (event,),
691            0x24025aac5d70a184,
692            fidl::encoding::DynamicFlags::empty(),
693        )
694    }
695}
696
697pub struct DeviceListenerEventStream {
698    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
699}
700
701impl std::marker::Unpin for DeviceListenerEventStream {}
702
703impl futures::stream::FusedStream for DeviceListenerEventStream {
704    fn is_terminated(&self) -> bool {
705        self.event_receiver.is_terminated()
706    }
707}
708
709impl futures::Stream for DeviceListenerEventStream {
710    type Item = Result<DeviceListenerEvent, fidl::Error>;
711
712    fn poll_next(
713        mut self: std::pin::Pin<&mut Self>,
714        cx: &mut std::task::Context<'_>,
715    ) -> std::task::Poll<Option<Self::Item>> {
716        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
717            &mut self.event_receiver,
718            cx
719        )?) {
720            Some(buf) => std::task::Poll::Ready(Some(DeviceListenerEvent::decode(buf))),
721            None => std::task::Poll::Ready(None),
722        }
723    }
724}
725
726#[derive(Debug)]
727pub enum DeviceListenerEvent {}
728
729impl DeviceListenerEvent {
730    /// Decodes a message buffer as a [`DeviceListenerEvent`].
731    fn decode(
732        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
733    ) -> Result<DeviceListenerEvent, fidl::Error> {
734        let (bytes, _handles) = buf.split_mut();
735        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
736        debug_assert_eq!(tx_header.tx_id, 0);
737        match tx_header.ordinal {
738            _ => Err(fidl::Error::UnknownOrdinal {
739                ordinal: tx_header.ordinal,
740                protocol_name:
741                    <DeviceListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
742            }),
743        }
744    }
745}
746
747/// A Stream of incoming requests for fuchsia.ui.input/DeviceListener.
748pub struct DeviceListenerRequestStream {
749    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
750    is_terminated: bool,
751}
752
753impl std::marker::Unpin for DeviceListenerRequestStream {}
754
755impl futures::stream::FusedStream for DeviceListenerRequestStream {
756    fn is_terminated(&self) -> bool {
757        self.is_terminated
758    }
759}
760
761impl fidl::endpoints::RequestStream for DeviceListenerRequestStream {
762    type Protocol = DeviceListenerMarker;
763    type ControlHandle = DeviceListenerControlHandle;
764
765    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
766        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
767    }
768
769    fn control_handle(&self) -> Self::ControlHandle {
770        DeviceListenerControlHandle { inner: self.inner.clone() }
771    }
772
773    fn into_inner(
774        self,
775    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
776    {
777        (self.inner, self.is_terminated)
778    }
779
780    fn from_inner(
781        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
782        is_terminated: bool,
783    ) -> Self {
784        Self { inner, is_terminated }
785    }
786}
787
788impl futures::Stream for DeviceListenerRequestStream {
789    type Item = Result<DeviceListenerRequest, fidl::Error>;
790
791    fn poll_next(
792        mut self: std::pin::Pin<&mut Self>,
793        cx: &mut std::task::Context<'_>,
794    ) -> std::task::Poll<Option<Self::Item>> {
795        let this = &mut *self;
796        if this.inner.check_shutdown(cx) {
797            this.is_terminated = true;
798            return std::task::Poll::Ready(None);
799        }
800        if this.is_terminated {
801            panic!("polled DeviceListenerRequestStream after completion");
802        }
803        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
804            |bytes, handles| {
805                match this.inner.channel().read_etc(cx, bytes, handles) {
806                    std::task::Poll::Ready(Ok(())) => {}
807                    std::task::Poll::Pending => return std::task::Poll::Pending,
808                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
809                        this.is_terminated = true;
810                        return std::task::Poll::Ready(None);
811                    }
812                    std::task::Poll::Ready(Err(e)) => {
813                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
814                            e.into(),
815                        ))));
816                    }
817                }
818
819                // A message has been received from the channel
820                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
821
822                std::task::Poll::Ready(Some(match header.ordinal {
823                    0x24025aac5d70a184 => {
824                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
825                        let mut req = fidl::new_empty!(
826                            DeviceListenerOnDeviceChangedRequest,
827                            fidl::encoding::DefaultFuchsiaResourceDialect
828                        );
829                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceListenerOnDeviceChangedRequest>(&header, _body_bytes, handles, &mut req)?;
830                        let control_handle =
831                            DeviceListenerControlHandle { inner: this.inner.clone() };
832                        Ok(DeviceListenerRequest::OnDeviceChanged {
833                            event: req.event,
834
835                            control_handle,
836                        })
837                    }
838                    _ => Err(fidl::Error::UnknownOrdinal {
839                        ordinal: header.ordinal,
840                        protocol_name:
841                            <DeviceListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
842                    }),
843                }))
844            },
845        )
846    }
847}
848
849/// Callback protocol implemented by clients to receive live device change events.
850///
851/// Events are sent to this listener only for changes occurring after registration
852/// is complete.
853#[derive(Debug)]
854pub enum DeviceListenerRequest {
855    /// Called when a device change event occurs.
856    OnDeviceChanged { event: DeviceEvent, control_handle: DeviceListenerControlHandle },
857}
858
859impl DeviceListenerRequest {
860    #[allow(irrefutable_let_patterns)]
861    pub fn into_on_device_changed(self) -> Option<(DeviceEvent, DeviceListenerControlHandle)> {
862        if let DeviceListenerRequest::OnDeviceChanged { event, control_handle } = self {
863            Some((event, control_handle))
864        } else {
865            None
866        }
867    }
868
869    /// Name of the method defined in FIDL
870    pub fn method_name(&self) -> &'static str {
871        match *self {
872            DeviceListenerRequest::OnDeviceChanged { .. } => "on_device_changed",
873        }
874    }
875}
876
877#[derive(Debug, Clone)]
878pub struct DeviceListenerControlHandle {
879    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
880}
881
882impl DeviceListenerControlHandle {
883    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
884        self.inner.shutdown_with_epitaph(status.into())
885    }
886}
887
888impl fidl::endpoints::ControlHandle for DeviceListenerControlHandle {
889    fn shutdown(&self) {
890        self.inner.shutdown()
891    }
892
893    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
894        self.inner.shutdown_with_epitaph(status)
895    }
896
897    fn is_closed(&self) -> bool {
898        self.inner.channel().is_closed()
899    }
900    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
901        self.inner.channel().on_closed()
902    }
903
904    #[cfg(target_os = "fuchsia")]
905    fn signal_peer(
906        &self,
907        clear_mask: zx::Signals,
908        set_mask: zx::Signals,
909    ) -> Result<(), zx_status::Status> {
910        use fidl::Peered;
911        self.inner.channel().signal_peer(clear_mask, set_mask)
912    }
913}
914
915impl DeviceListenerControlHandle {}
916
917#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
918pub struct DeviceListenerRegistryMarker;
919
920impl fidl::endpoints::ProtocolMarker for DeviceListenerRegistryMarker {
921    type Proxy = DeviceListenerRegistryProxy;
922    type RequestStream = DeviceListenerRegistryRequestStream;
923    #[cfg(target_os = "fuchsia")]
924    type SynchronousProxy = DeviceListenerRegistrySynchronousProxy;
925
926    const DEBUG_NAME: &'static str = "fuchsia.ui.input.DeviceListenerRegistry";
927}
928impl fidl::endpoints::DiscoverableProtocolMarker for DeviceListenerRegistryMarker {}
929
930pub trait DeviceListenerRegistryProxyInterface: Send + Sync {
931    type RegisterListenerResponseFut: std::future::Future<
932            Output = Result<fidl::endpoints::ClientEnd<DeviceIteratorMarker>, fidl::Error>,
933        > + Send;
934    fn r#register_listener(
935        &self,
936        listener: fidl::endpoints::ClientEnd<DeviceListenerMarker>,
937    ) -> Self::RegisterListenerResponseFut;
938}
939#[derive(Debug)]
940#[cfg(target_os = "fuchsia")]
941pub struct DeviceListenerRegistrySynchronousProxy {
942    client: fidl::client::sync::Client,
943}
944
945#[cfg(target_os = "fuchsia")]
946impl fidl::endpoints::SynchronousProxy for DeviceListenerRegistrySynchronousProxy {
947    type Proxy = DeviceListenerRegistryProxy;
948    type Protocol = DeviceListenerRegistryMarker;
949
950    fn from_channel(inner: fidl::Channel) -> Self {
951        Self::new(inner)
952    }
953
954    fn into_channel(self) -> fidl::Channel {
955        self.client.into_channel()
956    }
957
958    fn as_channel(&self) -> &fidl::Channel {
959        self.client.as_channel()
960    }
961}
962
963#[cfg(target_os = "fuchsia")]
964impl DeviceListenerRegistrySynchronousProxy {
965    pub fn new(channel: fidl::Channel) -> Self {
966        Self { client: fidl::client::sync::Client::new(channel) }
967    }
968
969    pub fn into_channel(self) -> fidl::Channel {
970        self.client.into_channel()
971    }
972
973    /// Waits until an event arrives and returns it. It is safe for other
974    /// threads to make concurrent requests while waiting for an event.
975    pub fn wait_for_event(
976        &self,
977        deadline: zx::MonotonicInstant,
978    ) -> Result<DeviceListenerRegistryEvent, fidl::Error> {
979        DeviceListenerRegistryEvent::decode(
980            self.client.wait_for_event::<DeviceListenerRegistryMarker>(deadline)?,
981        )
982    }
983
984    /// Registers a listener to receive future device change events.
985    ///
986    /// Returns a `DeviceIterator` which the client MUST use to drain the list
987    /// of devices that were already active at the time of registration.
988    pub fn r#register_listener(
989        &self,
990        mut listener: fidl::endpoints::ClientEnd<DeviceListenerMarker>,
991        ___deadline: zx::MonotonicInstant,
992    ) -> Result<fidl::endpoints::ClientEnd<DeviceIteratorMarker>, fidl::Error> {
993        let _response = self.client.send_query::<
994            DeviceListenerRegistryRegisterListenerRequest,
995            DeviceListenerRegistryRegisterListenerResponse,
996            DeviceListenerRegistryMarker,
997        >(
998            (listener,),
999            0x27c87ae726db6009,
1000            fidl::encoding::DynamicFlags::empty(),
1001            ___deadline,
1002        )?;
1003        Ok(_response.iterator)
1004    }
1005}
1006
1007#[cfg(target_os = "fuchsia")]
1008impl From<DeviceListenerRegistrySynchronousProxy> for zx::NullableHandle {
1009    fn from(value: DeviceListenerRegistrySynchronousProxy) -> Self {
1010        value.into_channel().into()
1011    }
1012}
1013
1014#[cfg(target_os = "fuchsia")]
1015impl From<fidl::Channel> for DeviceListenerRegistrySynchronousProxy {
1016    fn from(value: fidl::Channel) -> Self {
1017        Self::new(value)
1018    }
1019}
1020
1021#[cfg(target_os = "fuchsia")]
1022impl fidl::endpoints::FromClient for DeviceListenerRegistrySynchronousProxy {
1023    type Protocol = DeviceListenerRegistryMarker;
1024
1025    fn from_client(value: fidl::endpoints::ClientEnd<DeviceListenerRegistryMarker>) -> Self {
1026        Self::new(value.into_channel())
1027    }
1028}
1029
1030#[derive(Debug, Clone)]
1031pub struct DeviceListenerRegistryProxy {
1032    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1033}
1034
1035impl fidl::endpoints::Proxy for DeviceListenerRegistryProxy {
1036    type Protocol = DeviceListenerRegistryMarker;
1037
1038    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1039        Self::new(inner)
1040    }
1041
1042    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1043        self.client.into_channel().map_err(|client| Self { client })
1044    }
1045
1046    fn as_channel(&self) -> &::fidl::AsyncChannel {
1047        self.client.as_channel()
1048    }
1049}
1050
1051impl DeviceListenerRegistryProxy {
1052    /// Create a new Proxy for fuchsia.ui.input/DeviceListenerRegistry.
1053    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1054        let protocol_name =
1055            <DeviceListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1056        Self { client: fidl::client::Client::new(channel, protocol_name) }
1057    }
1058
1059    /// Get a Stream of events from the remote end of the protocol.
1060    ///
1061    /// # Panics
1062    ///
1063    /// Panics if the event stream was already taken.
1064    pub fn take_event_stream(&self) -> DeviceListenerRegistryEventStream {
1065        DeviceListenerRegistryEventStream { event_receiver: self.client.take_event_receiver() }
1066    }
1067
1068    /// Registers a listener to receive future device change events.
1069    ///
1070    /// Returns a `DeviceIterator` which the client MUST use to drain the list
1071    /// of devices that were already active at the time of registration.
1072    pub fn r#register_listener(
1073        &self,
1074        mut listener: fidl::endpoints::ClientEnd<DeviceListenerMarker>,
1075    ) -> fidl::client::QueryResponseFut<
1076        fidl::endpoints::ClientEnd<DeviceIteratorMarker>,
1077        fidl::encoding::DefaultFuchsiaResourceDialect,
1078    > {
1079        DeviceListenerRegistryProxyInterface::r#register_listener(self, listener)
1080    }
1081}
1082
1083impl DeviceListenerRegistryProxyInterface for DeviceListenerRegistryProxy {
1084    type RegisterListenerResponseFut = fidl::client::QueryResponseFut<
1085        fidl::endpoints::ClientEnd<DeviceIteratorMarker>,
1086        fidl::encoding::DefaultFuchsiaResourceDialect,
1087    >;
1088    fn r#register_listener(
1089        &self,
1090        mut listener: fidl::endpoints::ClientEnd<DeviceListenerMarker>,
1091    ) -> Self::RegisterListenerResponseFut {
1092        fn _decode(
1093            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1094        ) -> Result<fidl::endpoints::ClientEnd<DeviceIteratorMarker>, fidl::Error> {
1095            let _response = fidl::client::decode_transaction_body::<
1096                DeviceListenerRegistryRegisterListenerResponse,
1097                fidl::encoding::DefaultFuchsiaResourceDialect,
1098                0x27c87ae726db6009,
1099            >(_buf?)?;
1100            Ok(_response.iterator)
1101        }
1102        self.client.send_query_and_decode::<
1103            DeviceListenerRegistryRegisterListenerRequest,
1104            fidl::endpoints::ClientEnd<DeviceIteratorMarker>,
1105        >(
1106            (listener,),
1107            0x27c87ae726db6009,
1108            fidl::encoding::DynamicFlags::empty(),
1109            _decode,
1110        )
1111    }
1112}
1113
1114pub struct DeviceListenerRegistryEventStream {
1115    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1116}
1117
1118impl std::marker::Unpin for DeviceListenerRegistryEventStream {}
1119
1120impl futures::stream::FusedStream for DeviceListenerRegistryEventStream {
1121    fn is_terminated(&self) -> bool {
1122        self.event_receiver.is_terminated()
1123    }
1124}
1125
1126impl futures::Stream for DeviceListenerRegistryEventStream {
1127    type Item = Result<DeviceListenerRegistryEvent, fidl::Error>;
1128
1129    fn poll_next(
1130        mut self: std::pin::Pin<&mut Self>,
1131        cx: &mut std::task::Context<'_>,
1132    ) -> std::task::Poll<Option<Self::Item>> {
1133        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1134            &mut self.event_receiver,
1135            cx
1136        )?) {
1137            Some(buf) => std::task::Poll::Ready(Some(DeviceListenerRegistryEvent::decode(buf))),
1138            None => std::task::Poll::Ready(None),
1139        }
1140    }
1141}
1142
1143#[derive(Debug)]
1144pub enum DeviceListenerRegistryEvent {
1145    #[non_exhaustive]
1146    _UnknownEvent {
1147        /// Ordinal of the event that was sent.
1148        ordinal: u64,
1149    },
1150}
1151
1152impl DeviceListenerRegistryEvent {
1153    /// Decodes a message buffer as a [`DeviceListenerRegistryEvent`].
1154    fn decode(
1155        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1156    ) -> Result<DeviceListenerRegistryEvent, fidl::Error> {
1157        let (bytes, _handles) = buf.split_mut();
1158        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1159        debug_assert_eq!(tx_header.tx_id, 0);
1160        match tx_header.ordinal {
1161            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1162                Ok(DeviceListenerRegistryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1163            }
1164            _ => Err(fidl::Error::UnknownOrdinal {
1165                ordinal: tx_header.ordinal,
1166                protocol_name:
1167                    <DeviceListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1168            }),
1169        }
1170    }
1171}
1172
1173/// A Stream of incoming requests for fuchsia.ui.input/DeviceListenerRegistry.
1174pub struct DeviceListenerRegistryRequestStream {
1175    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1176    is_terminated: bool,
1177}
1178
1179impl std::marker::Unpin for DeviceListenerRegistryRequestStream {}
1180
1181impl futures::stream::FusedStream for DeviceListenerRegistryRequestStream {
1182    fn is_terminated(&self) -> bool {
1183        self.is_terminated
1184    }
1185}
1186
1187impl fidl::endpoints::RequestStream for DeviceListenerRegistryRequestStream {
1188    type Protocol = DeviceListenerRegistryMarker;
1189    type ControlHandle = DeviceListenerRegistryControlHandle;
1190
1191    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1192        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1193    }
1194
1195    fn control_handle(&self) -> Self::ControlHandle {
1196        DeviceListenerRegistryControlHandle { inner: self.inner.clone() }
1197    }
1198
1199    fn into_inner(
1200        self,
1201    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1202    {
1203        (self.inner, self.is_terminated)
1204    }
1205
1206    fn from_inner(
1207        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1208        is_terminated: bool,
1209    ) -> Self {
1210        Self { inner, is_terminated }
1211    }
1212}
1213
1214impl futures::Stream for DeviceListenerRegistryRequestStream {
1215    type Item = Result<DeviceListenerRegistryRequest, fidl::Error>;
1216
1217    fn poll_next(
1218        mut self: std::pin::Pin<&mut Self>,
1219        cx: &mut std::task::Context<'_>,
1220    ) -> std::task::Poll<Option<Self::Item>> {
1221        let this = &mut *self;
1222        if this.inner.check_shutdown(cx) {
1223            this.is_terminated = true;
1224            return std::task::Poll::Ready(None);
1225        }
1226        if this.is_terminated {
1227            panic!("polled DeviceListenerRegistryRequestStream after completion");
1228        }
1229        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1230            |bytes, handles| {
1231                match this.inner.channel().read_etc(cx, bytes, handles) {
1232                    std::task::Poll::Ready(Ok(())) => {}
1233                    std::task::Poll::Pending => return std::task::Poll::Pending,
1234                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1235                        this.is_terminated = true;
1236                        return std::task::Poll::Ready(None);
1237                    }
1238                    std::task::Poll::Ready(Err(e)) => {
1239                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1240                            e.into(),
1241                        ))));
1242                    }
1243                }
1244
1245                // A message has been received from the channel
1246                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1247
1248                std::task::Poll::Ready(Some(match header.ordinal {
1249                0x27c87ae726db6009 => {
1250                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1251                    let mut req = fidl::new_empty!(DeviceListenerRegistryRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1252                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceListenerRegistryRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
1253                    let control_handle = DeviceListenerRegistryControlHandle {
1254                        inner: this.inner.clone(),
1255                    };
1256                    Ok(DeviceListenerRegistryRequest::RegisterListener {listener: req.listener,
1257
1258                        responder: DeviceListenerRegistryRegisterListenerResponder {
1259                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1260                            tx_id: header.tx_id,
1261                        },
1262                    })
1263                }
1264                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1265                    Ok(DeviceListenerRegistryRequest::_UnknownMethod {
1266                        ordinal: header.ordinal,
1267                        control_handle: DeviceListenerRegistryControlHandle { inner: this.inner.clone() },
1268                        method_type: fidl::MethodType::OneWay,
1269                    })
1270                }
1271                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1272                    this.inner.send_framework_err(
1273                        fidl::encoding::FrameworkErr::UnknownMethod,
1274                        header.tx_id,
1275                        header.ordinal,
1276                        header.dynamic_flags(),
1277                        (bytes, handles),
1278                    )?;
1279                    Ok(DeviceListenerRegistryRequest::_UnknownMethod {
1280                        ordinal: header.ordinal,
1281                        control_handle: DeviceListenerRegistryControlHandle { inner: this.inner.clone() },
1282                        method_type: fidl::MethodType::TwoWay,
1283                    })
1284                }
1285                _ => Err(fidl::Error::UnknownOrdinal {
1286                    ordinal: header.ordinal,
1287                    protocol_name: <DeviceListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1288                }),
1289            }))
1290            },
1291        )
1292    }
1293}
1294
1295/// Registry service that allows clients to monitor input device changes.
1296#[derive(Debug)]
1297pub enum DeviceListenerRegistryRequest {
1298    /// Registers a listener to receive future device change events.
1299    ///
1300    /// Returns a `DeviceIterator` which the client MUST use to drain the list
1301    /// of devices that were already active at the time of registration.
1302    RegisterListener {
1303        listener: fidl::endpoints::ClientEnd<DeviceListenerMarker>,
1304        responder: DeviceListenerRegistryRegisterListenerResponder,
1305    },
1306    /// An interaction was received which does not match any known method.
1307    #[non_exhaustive]
1308    _UnknownMethod {
1309        /// Ordinal of the method that was called.
1310        ordinal: u64,
1311        control_handle: DeviceListenerRegistryControlHandle,
1312        method_type: fidl::MethodType,
1313    },
1314}
1315
1316impl DeviceListenerRegistryRequest {
1317    #[allow(irrefutable_let_patterns)]
1318    pub fn into_register_listener(
1319        self,
1320    ) -> Option<(
1321        fidl::endpoints::ClientEnd<DeviceListenerMarker>,
1322        DeviceListenerRegistryRegisterListenerResponder,
1323    )> {
1324        if let DeviceListenerRegistryRequest::RegisterListener { listener, responder } = self {
1325            Some((listener, responder))
1326        } else {
1327            None
1328        }
1329    }
1330
1331    /// Name of the method defined in FIDL
1332    pub fn method_name(&self) -> &'static str {
1333        match *self {
1334            DeviceListenerRegistryRequest::RegisterListener { .. } => "register_listener",
1335            DeviceListenerRegistryRequest::_UnknownMethod {
1336                method_type: fidl::MethodType::OneWay,
1337                ..
1338            } => "unknown one-way method",
1339            DeviceListenerRegistryRequest::_UnknownMethod {
1340                method_type: fidl::MethodType::TwoWay,
1341                ..
1342            } => "unknown two-way method",
1343        }
1344    }
1345}
1346
1347#[derive(Debug, Clone)]
1348pub struct DeviceListenerRegistryControlHandle {
1349    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1350}
1351
1352impl DeviceListenerRegistryControlHandle {
1353    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1354        self.inner.shutdown_with_epitaph(status.into())
1355    }
1356}
1357
1358impl fidl::endpoints::ControlHandle for DeviceListenerRegistryControlHandle {
1359    fn shutdown(&self) {
1360        self.inner.shutdown()
1361    }
1362
1363    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1364        self.inner.shutdown_with_epitaph(status)
1365    }
1366
1367    fn is_closed(&self) -> bool {
1368        self.inner.channel().is_closed()
1369    }
1370    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1371        self.inner.channel().on_closed()
1372    }
1373
1374    #[cfg(target_os = "fuchsia")]
1375    fn signal_peer(
1376        &self,
1377        clear_mask: zx::Signals,
1378        set_mask: zx::Signals,
1379    ) -> Result<(), zx_status::Status> {
1380        use fidl::Peered;
1381        self.inner.channel().signal_peer(clear_mask, set_mask)
1382    }
1383}
1384
1385impl DeviceListenerRegistryControlHandle {}
1386
1387#[must_use = "FIDL methods require a response to be sent"]
1388#[derive(Debug)]
1389pub struct DeviceListenerRegistryRegisterListenerResponder {
1390    control_handle: std::mem::ManuallyDrop<DeviceListenerRegistryControlHandle>,
1391    tx_id: u32,
1392}
1393
1394/// Set the the channel to be shutdown (see [`DeviceListenerRegistryControlHandle::shutdown`])
1395/// if the responder is dropped without sending a response, so that the client
1396/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1397impl std::ops::Drop for DeviceListenerRegistryRegisterListenerResponder {
1398    fn drop(&mut self) {
1399        self.control_handle.shutdown();
1400        // Safety: drops once, never accessed again
1401        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1402    }
1403}
1404
1405impl fidl::endpoints::Responder for DeviceListenerRegistryRegisterListenerResponder {
1406    type ControlHandle = DeviceListenerRegistryControlHandle;
1407
1408    fn control_handle(&self) -> &DeviceListenerRegistryControlHandle {
1409        &self.control_handle
1410    }
1411
1412    fn drop_without_shutdown(mut self) {
1413        // Safety: drops once, never accessed again due to mem::forget
1414        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1415        // Prevent Drop from running (which would shut down the channel)
1416        std::mem::forget(self);
1417    }
1418}
1419
1420impl DeviceListenerRegistryRegisterListenerResponder {
1421    /// Sends a response to the FIDL transaction.
1422    ///
1423    /// Sets the channel to shutdown if an error occurs.
1424    pub fn send(
1425        self,
1426        mut iterator: fidl::endpoints::ClientEnd<DeviceIteratorMarker>,
1427    ) -> Result<(), fidl::Error> {
1428        let _result = self.send_raw(iterator);
1429        if _result.is_err() {
1430            self.control_handle.shutdown();
1431        }
1432        self.drop_without_shutdown();
1433        _result
1434    }
1435
1436    /// Similar to "send" but does not shutdown the channel if an error occurs.
1437    pub fn send_no_shutdown_on_err(
1438        self,
1439        mut iterator: fidl::endpoints::ClientEnd<DeviceIteratorMarker>,
1440    ) -> Result<(), fidl::Error> {
1441        let _result = self.send_raw(iterator);
1442        self.drop_without_shutdown();
1443        _result
1444    }
1445
1446    fn send_raw(
1447        &self,
1448        mut iterator: fidl::endpoints::ClientEnd<DeviceIteratorMarker>,
1449    ) -> Result<(), fidl::Error> {
1450        self.control_handle.inner.send::<DeviceListenerRegistryRegisterListenerResponse>(
1451            (iterator,),
1452            self.tx_id,
1453            0x27c87ae726db6009,
1454            fidl::encoding::DynamicFlags::empty(),
1455        )
1456    }
1457}
1458
1459#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1460pub struct ImeServiceMarker;
1461
1462impl fidl::endpoints::ProtocolMarker for ImeServiceMarker {
1463    type Proxy = ImeServiceProxy;
1464    type RequestStream = ImeServiceRequestStream;
1465    #[cfg(target_os = "fuchsia")]
1466    type SynchronousProxy = ImeServiceSynchronousProxy;
1467
1468    const DEBUG_NAME: &'static str = "fuchsia.ui.input.ImeService";
1469}
1470impl fidl::endpoints::DiscoverableProtocolMarker for ImeServiceMarker {}
1471
1472pub trait ImeServiceProxyInterface: Send + Sync {
1473    fn r#get_input_method_editor(
1474        &self,
1475        keyboard_type: KeyboardType,
1476        action: InputMethodAction,
1477        initial_state: &TextInputState,
1478        client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
1479        editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
1480    ) -> Result<(), fidl::Error>;
1481    fn r#show_keyboard(&self) -> Result<(), fidl::Error>;
1482    fn r#hide_keyboard(&self) -> Result<(), fidl::Error>;
1483}
1484#[derive(Debug)]
1485#[cfg(target_os = "fuchsia")]
1486pub struct ImeServiceSynchronousProxy {
1487    client: fidl::client::sync::Client,
1488}
1489
1490#[cfg(target_os = "fuchsia")]
1491impl fidl::endpoints::SynchronousProxy for ImeServiceSynchronousProxy {
1492    type Proxy = ImeServiceProxy;
1493    type Protocol = ImeServiceMarker;
1494
1495    fn from_channel(inner: fidl::Channel) -> Self {
1496        Self::new(inner)
1497    }
1498
1499    fn into_channel(self) -> fidl::Channel {
1500        self.client.into_channel()
1501    }
1502
1503    fn as_channel(&self) -> &fidl::Channel {
1504        self.client.as_channel()
1505    }
1506}
1507
1508#[cfg(target_os = "fuchsia")]
1509impl ImeServiceSynchronousProxy {
1510    pub fn new(channel: fidl::Channel) -> Self {
1511        Self { client: fidl::client::sync::Client::new(channel) }
1512    }
1513
1514    pub fn into_channel(self) -> fidl::Channel {
1515        self.client.into_channel()
1516    }
1517
1518    /// Waits until an event arrives and returns it. It is safe for other
1519    /// threads to make concurrent requests while waiting for an event.
1520    pub fn wait_for_event(
1521        &self,
1522        deadline: zx::MonotonicInstant,
1523    ) -> Result<ImeServiceEvent, fidl::Error> {
1524        ImeServiceEvent::decode(self.client.wait_for_event::<ImeServiceMarker>(deadline)?)
1525    }
1526
1527    pub fn r#get_input_method_editor(
1528        &self,
1529        mut keyboard_type: KeyboardType,
1530        mut action: InputMethodAction,
1531        mut initial_state: &TextInputState,
1532        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
1533        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
1534    ) -> Result<(), fidl::Error> {
1535        self.client.send::<ImeServiceGetInputMethodEditorRequest>(
1536            (keyboard_type, action, initial_state, client, editor),
1537            0x148d2e42a1f461fc,
1538            fidl::encoding::DynamicFlags::empty(),
1539        )
1540    }
1541
1542    pub fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
1543        self.client.send::<fidl::encoding::EmptyPayload>(
1544            (),
1545            0x38ed2a1de28cfcf0,
1546            fidl::encoding::DynamicFlags::empty(),
1547        )
1548    }
1549
1550    pub fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
1551        self.client.send::<fidl::encoding::EmptyPayload>(
1552            (),
1553            0x7667f098198d09fd,
1554            fidl::encoding::DynamicFlags::empty(),
1555        )
1556    }
1557}
1558
1559#[cfg(target_os = "fuchsia")]
1560impl From<ImeServiceSynchronousProxy> for zx::NullableHandle {
1561    fn from(value: ImeServiceSynchronousProxy) -> Self {
1562        value.into_channel().into()
1563    }
1564}
1565
1566#[cfg(target_os = "fuchsia")]
1567impl From<fidl::Channel> for ImeServiceSynchronousProxy {
1568    fn from(value: fidl::Channel) -> Self {
1569        Self::new(value)
1570    }
1571}
1572
1573#[cfg(target_os = "fuchsia")]
1574impl fidl::endpoints::FromClient for ImeServiceSynchronousProxy {
1575    type Protocol = ImeServiceMarker;
1576
1577    fn from_client(value: fidl::endpoints::ClientEnd<ImeServiceMarker>) -> Self {
1578        Self::new(value.into_channel())
1579    }
1580}
1581
1582#[derive(Debug, Clone)]
1583pub struct ImeServiceProxy {
1584    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1585}
1586
1587impl fidl::endpoints::Proxy for ImeServiceProxy {
1588    type Protocol = ImeServiceMarker;
1589
1590    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1591        Self::new(inner)
1592    }
1593
1594    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1595        self.client.into_channel().map_err(|client| Self { client })
1596    }
1597
1598    fn as_channel(&self) -> &::fidl::AsyncChannel {
1599        self.client.as_channel()
1600    }
1601}
1602
1603impl ImeServiceProxy {
1604    /// Create a new Proxy for fuchsia.ui.input/ImeService.
1605    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1606        let protocol_name = <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1607        Self { client: fidl::client::Client::new(channel, protocol_name) }
1608    }
1609
1610    /// Get a Stream of events from the remote end of the protocol.
1611    ///
1612    /// # Panics
1613    ///
1614    /// Panics if the event stream was already taken.
1615    pub fn take_event_stream(&self) -> ImeServiceEventStream {
1616        ImeServiceEventStream { event_receiver: self.client.take_event_receiver() }
1617    }
1618
1619    pub fn r#get_input_method_editor(
1620        &self,
1621        mut keyboard_type: KeyboardType,
1622        mut action: InputMethodAction,
1623        mut initial_state: &TextInputState,
1624        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
1625        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
1626    ) -> Result<(), fidl::Error> {
1627        ImeServiceProxyInterface::r#get_input_method_editor(
1628            self,
1629            keyboard_type,
1630            action,
1631            initial_state,
1632            client,
1633            editor,
1634        )
1635    }
1636
1637    pub fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
1638        ImeServiceProxyInterface::r#show_keyboard(self)
1639    }
1640
1641    pub fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
1642        ImeServiceProxyInterface::r#hide_keyboard(self)
1643    }
1644}
1645
1646impl ImeServiceProxyInterface for ImeServiceProxy {
1647    fn r#get_input_method_editor(
1648        &self,
1649        mut keyboard_type: KeyboardType,
1650        mut action: InputMethodAction,
1651        mut initial_state: &TextInputState,
1652        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
1653        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
1654    ) -> Result<(), fidl::Error> {
1655        self.client.send::<ImeServiceGetInputMethodEditorRequest>(
1656            (keyboard_type, action, initial_state, client, editor),
1657            0x148d2e42a1f461fc,
1658            fidl::encoding::DynamicFlags::empty(),
1659        )
1660    }
1661
1662    fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
1663        self.client.send::<fidl::encoding::EmptyPayload>(
1664            (),
1665            0x38ed2a1de28cfcf0,
1666            fidl::encoding::DynamicFlags::empty(),
1667        )
1668    }
1669
1670    fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
1671        self.client.send::<fidl::encoding::EmptyPayload>(
1672            (),
1673            0x7667f098198d09fd,
1674            fidl::encoding::DynamicFlags::empty(),
1675        )
1676    }
1677}
1678
1679pub struct ImeServiceEventStream {
1680    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1681}
1682
1683impl std::marker::Unpin for ImeServiceEventStream {}
1684
1685impl futures::stream::FusedStream for ImeServiceEventStream {
1686    fn is_terminated(&self) -> bool {
1687        self.event_receiver.is_terminated()
1688    }
1689}
1690
1691impl futures::Stream for ImeServiceEventStream {
1692    type Item = Result<ImeServiceEvent, fidl::Error>;
1693
1694    fn poll_next(
1695        mut self: std::pin::Pin<&mut Self>,
1696        cx: &mut std::task::Context<'_>,
1697    ) -> std::task::Poll<Option<Self::Item>> {
1698        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1699            &mut self.event_receiver,
1700            cx
1701        )?) {
1702            Some(buf) => std::task::Poll::Ready(Some(ImeServiceEvent::decode(buf))),
1703            None => std::task::Poll::Ready(None),
1704        }
1705    }
1706}
1707
1708#[derive(Debug)]
1709pub enum ImeServiceEvent {}
1710
1711impl ImeServiceEvent {
1712    /// Decodes a message buffer as a [`ImeServiceEvent`].
1713    fn decode(
1714        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1715    ) -> Result<ImeServiceEvent, fidl::Error> {
1716        let (bytes, _handles) = buf.split_mut();
1717        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1718        debug_assert_eq!(tx_header.tx_id, 0);
1719        match tx_header.ordinal {
1720            _ => Err(fidl::Error::UnknownOrdinal {
1721                ordinal: tx_header.ordinal,
1722                protocol_name: <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1723            }),
1724        }
1725    }
1726}
1727
1728/// A Stream of incoming requests for fuchsia.ui.input/ImeService.
1729pub struct ImeServiceRequestStream {
1730    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1731    is_terminated: bool,
1732}
1733
1734impl std::marker::Unpin for ImeServiceRequestStream {}
1735
1736impl futures::stream::FusedStream for ImeServiceRequestStream {
1737    fn is_terminated(&self) -> bool {
1738        self.is_terminated
1739    }
1740}
1741
1742impl fidl::endpoints::RequestStream for ImeServiceRequestStream {
1743    type Protocol = ImeServiceMarker;
1744    type ControlHandle = ImeServiceControlHandle;
1745
1746    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1747        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1748    }
1749
1750    fn control_handle(&self) -> Self::ControlHandle {
1751        ImeServiceControlHandle { inner: self.inner.clone() }
1752    }
1753
1754    fn into_inner(
1755        self,
1756    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1757    {
1758        (self.inner, self.is_terminated)
1759    }
1760
1761    fn from_inner(
1762        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1763        is_terminated: bool,
1764    ) -> Self {
1765        Self { inner, is_terminated }
1766    }
1767}
1768
1769impl futures::Stream for ImeServiceRequestStream {
1770    type Item = Result<ImeServiceRequest, fidl::Error>;
1771
1772    fn poll_next(
1773        mut self: std::pin::Pin<&mut Self>,
1774        cx: &mut std::task::Context<'_>,
1775    ) -> std::task::Poll<Option<Self::Item>> {
1776        let this = &mut *self;
1777        if this.inner.check_shutdown(cx) {
1778            this.is_terminated = true;
1779            return std::task::Poll::Ready(None);
1780        }
1781        if this.is_terminated {
1782            panic!("polled ImeServiceRequestStream after completion");
1783        }
1784        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1785            |bytes, handles| {
1786                match this.inner.channel().read_etc(cx, bytes, handles) {
1787                    std::task::Poll::Ready(Ok(())) => {}
1788                    std::task::Poll::Pending => return std::task::Poll::Pending,
1789                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1790                        this.is_terminated = true;
1791                        return std::task::Poll::Ready(None);
1792                    }
1793                    std::task::Poll::Ready(Err(e)) => {
1794                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1795                            e.into(),
1796                        ))));
1797                    }
1798                }
1799
1800                // A message has been received from the channel
1801                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1802
1803                std::task::Poll::Ready(Some(match header.ordinal {
1804                    0x148d2e42a1f461fc => {
1805                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1806                        let mut req = fidl::new_empty!(
1807                            ImeServiceGetInputMethodEditorRequest,
1808                            fidl::encoding::DefaultFuchsiaResourceDialect
1809                        );
1810                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImeServiceGetInputMethodEditorRequest>(&header, _body_bytes, handles, &mut req)?;
1811                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
1812                        Ok(ImeServiceRequest::GetInputMethodEditor {
1813                            keyboard_type: req.keyboard_type,
1814                            action: req.action,
1815                            initial_state: req.initial_state,
1816                            client: req.client,
1817                            editor: req.editor,
1818
1819                            control_handle,
1820                        })
1821                    }
1822                    0x38ed2a1de28cfcf0 => {
1823                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1824                        let mut req = fidl::new_empty!(
1825                            fidl::encoding::EmptyPayload,
1826                            fidl::encoding::DefaultFuchsiaResourceDialect
1827                        );
1828                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1829                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
1830                        Ok(ImeServiceRequest::ShowKeyboard { control_handle })
1831                    }
1832                    0x7667f098198d09fd => {
1833                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1834                        let mut req = fidl::new_empty!(
1835                            fidl::encoding::EmptyPayload,
1836                            fidl::encoding::DefaultFuchsiaResourceDialect
1837                        );
1838                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1839                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
1840                        Ok(ImeServiceRequest::HideKeyboard { control_handle })
1841                    }
1842                    _ => Err(fidl::Error::UnknownOrdinal {
1843                        ordinal: header.ordinal,
1844                        protocol_name:
1845                            <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1846                    }),
1847                }))
1848            },
1849        )
1850    }
1851}
1852
1853/// The service provided by an IME
1854#[derive(Debug)]
1855pub enum ImeServiceRequest {
1856    GetInputMethodEditor {
1857        keyboard_type: KeyboardType,
1858        action: InputMethodAction,
1859        initial_state: TextInputState,
1860        client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
1861        editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
1862        control_handle: ImeServiceControlHandle,
1863    },
1864    ShowKeyboard {
1865        control_handle: ImeServiceControlHandle,
1866    },
1867    HideKeyboard {
1868        control_handle: ImeServiceControlHandle,
1869    },
1870}
1871
1872impl ImeServiceRequest {
1873    #[allow(irrefutable_let_patterns)]
1874    pub fn into_get_input_method_editor(
1875        self,
1876    ) -> Option<(
1877        KeyboardType,
1878        InputMethodAction,
1879        TextInputState,
1880        fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
1881        fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
1882        ImeServiceControlHandle,
1883    )> {
1884        if let ImeServiceRequest::GetInputMethodEditor {
1885            keyboard_type,
1886            action,
1887            initial_state,
1888            client,
1889            editor,
1890            control_handle,
1891        } = self
1892        {
1893            Some((keyboard_type, action, initial_state, client, editor, control_handle))
1894        } else {
1895            None
1896        }
1897    }
1898
1899    #[allow(irrefutable_let_patterns)]
1900    pub fn into_show_keyboard(self) -> Option<(ImeServiceControlHandle)> {
1901        if let ImeServiceRequest::ShowKeyboard { control_handle } = self {
1902            Some((control_handle))
1903        } else {
1904            None
1905        }
1906    }
1907
1908    #[allow(irrefutable_let_patterns)]
1909    pub fn into_hide_keyboard(self) -> Option<(ImeServiceControlHandle)> {
1910        if let ImeServiceRequest::HideKeyboard { control_handle } = self {
1911            Some((control_handle))
1912        } else {
1913            None
1914        }
1915    }
1916
1917    /// Name of the method defined in FIDL
1918    pub fn method_name(&self) -> &'static str {
1919        match *self {
1920            ImeServiceRequest::GetInputMethodEditor { .. } => "get_input_method_editor",
1921            ImeServiceRequest::ShowKeyboard { .. } => "show_keyboard",
1922            ImeServiceRequest::HideKeyboard { .. } => "hide_keyboard",
1923        }
1924    }
1925}
1926
1927#[derive(Debug, Clone)]
1928pub struct ImeServiceControlHandle {
1929    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1930}
1931
1932impl ImeServiceControlHandle {
1933    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1934        self.inner.shutdown_with_epitaph(status.into())
1935    }
1936}
1937
1938impl fidl::endpoints::ControlHandle for ImeServiceControlHandle {
1939    fn shutdown(&self) {
1940        self.inner.shutdown()
1941    }
1942
1943    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1944        self.inner.shutdown_with_epitaph(status)
1945    }
1946
1947    fn is_closed(&self) -> bool {
1948        self.inner.channel().is_closed()
1949    }
1950    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1951        self.inner.channel().on_closed()
1952    }
1953
1954    #[cfg(target_os = "fuchsia")]
1955    fn signal_peer(
1956        &self,
1957        clear_mask: zx::Signals,
1958        set_mask: zx::Signals,
1959    ) -> Result<(), zx_status::Status> {
1960        use fidl::Peered;
1961        self.inner.channel().signal_peer(clear_mask, set_mask)
1962    }
1963}
1964
1965impl ImeServiceControlHandle {}
1966
1967#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1968pub struct InputDeviceMarker;
1969
1970impl fidl::endpoints::ProtocolMarker for InputDeviceMarker {
1971    type Proxy = InputDeviceProxy;
1972    type RequestStream = InputDeviceRequestStream;
1973    #[cfg(target_os = "fuchsia")]
1974    type SynchronousProxy = InputDeviceSynchronousProxy;
1975
1976    const DEBUG_NAME: &'static str = "(anonymous) InputDevice";
1977}
1978
1979pub trait InputDeviceProxyInterface: Send + Sync {
1980    fn r#dispatch_report(&self, report: &InputReport) -> Result<(), fidl::Error>;
1981}
1982#[derive(Debug)]
1983#[cfg(target_os = "fuchsia")]
1984pub struct InputDeviceSynchronousProxy {
1985    client: fidl::client::sync::Client,
1986}
1987
1988#[cfg(target_os = "fuchsia")]
1989impl fidl::endpoints::SynchronousProxy for InputDeviceSynchronousProxy {
1990    type Proxy = InputDeviceProxy;
1991    type Protocol = InputDeviceMarker;
1992
1993    fn from_channel(inner: fidl::Channel) -> Self {
1994        Self::new(inner)
1995    }
1996
1997    fn into_channel(self) -> fidl::Channel {
1998        self.client.into_channel()
1999    }
2000
2001    fn as_channel(&self) -> &fidl::Channel {
2002        self.client.as_channel()
2003    }
2004}
2005
2006#[cfg(target_os = "fuchsia")]
2007impl InputDeviceSynchronousProxy {
2008    pub fn new(channel: fidl::Channel) -> Self {
2009        Self { client: fidl::client::sync::Client::new(channel) }
2010    }
2011
2012    pub fn into_channel(self) -> fidl::Channel {
2013        self.client.into_channel()
2014    }
2015
2016    /// Waits until an event arrives and returns it. It is safe for other
2017    /// threads to make concurrent requests while waiting for an event.
2018    pub fn wait_for_event(
2019        &self,
2020        deadline: zx::MonotonicInstant,
2021    ) -> Result<InputDeviceEvent, fidl::Error> {
2022        InputDeviceEvent::decode(self.client.wait_for_event::<InputDeviceMarker>(deadline)?)
2023    }
2024
2025    /// Dispatch an `InputReport` from the device `token`
2026    pub fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
2027        self.client.send::<InputDeviceDispatchReportRequest>(
2028            (report,),
2029            0x7ee375d01c8e149f,
2030            fidl::encoding::DynamicFlags::empty(),
2031        )
2032    }
2033}
2034
2035#[cfg(target_os = "fuchsia")]
2036impl From<InputDeviceSynchronousProxy> for zx::NullableHandle {
2037    fn from(value: InputDeviceSynchronousProxy) -> Self {
2038        value.into_channel().into()
2039    }
2040}
2041
2042#[cfg(target_os = "fuchsia")]
2043impl From<fidl::Channel> for InputDeviceSynchronousProxy {
2044    fn from(value: fidl::Channel) -> Self {
2045        Self::new(value)
2046    }
2047}
2048
2049#[cfg(target_os = "fuchsia")]
2050impl fidl::endpoints::FromClient for InputDeviceSynchronousProxy {
2051    type Protocol = InputDeviceMarker;
2052
2053    fn from_client(value: fidl::endpoints::ClientEnd<InputDeviceMarker>) -> Self {
2054        Self::new(value.into_channel())
2055    }
2056}
2057
2058#[derive(Debug, Clone)]
2059pub struct InputDeviceProxy {
2060    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2061}
2062
2063impl fidl::endpoints::Proxy for InputDeviceProxy {
2064    type Protocol = InputDeviceMarker;
2065
2066    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2067        Self::new(inner)
2068    }
2069
2070    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2071        self.client.into_channel().map_err(|client| Self { client })
2072    }
2073
2074    fn as_channel(&self) -> &::fidl::AsyncChannel {
2075        self.client.as_channel()
2076    }
2077}
2078
2079impl InputDeviceProxy {
2080    /// Create a new Proxy for fuchsia.ui.input/InputDevice.
2081    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2082        let protocol_name = <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2083        Self { client: fidl::client::Client::new(channel, protocol_name) }
2084    }
2085
2086    /// Get a Stream of events from the remote end of the protocol.
2087    ///
2088    /// # Panics
2089    ///
2090    /// Panics if the event stream was already taken.
2091    pub fn take_event_stream(&self) -> InputDeviceEventStream {
2092        InputDeviceEventStream { event_receiver: self.client.take_event_receiver() }
2093    }
2094
2095    /// Dispatch an `InputReport` from the device `token`
2096    pub fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
2097        InputDeviceProxyInterface::r#dispatch_report(self, report)
2098    }
2099}
2100
2101impl InputDeviceProxyInterface for InputDeviceProxy {
2102    fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
2103        self.client.send::<InputDeviceDispatchReportRequest>(
2104            (report,),
2105            0x7ee375d01c8e149f,
2106            fidl::encoding::DynamicFlags::empty(),
2107        )
2108    }
2109}
2110
2111pub struct InputDeviceEventStream {
2112    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2113}
2114
2115impl std::marker::Unpin for InputDeviceEventStream {}
2116
2117impl futures::stream::FusedStream for InputDeviceEventStream {
2118    fn is_terminated(&self) -> bool {
2119        self.event_receiver.is_terminated()
2120    }
2121}
2122
2123impl futures::Stream for InputDeviceEventStream {
2124    type Item = Result<InputDeviceEvent, fidl::Error>;
2125
2126    fn poll_next(
2127        mut self: std::pin::Pin<&mut Self>,
2128        cx: &mut std::task::Context<'_>,
2129    ) -> std::task::Poll<Option<Self::Item>> {
2130        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2131            &mut self.event_receiver,
2132            cx
2133        )?) {
2134            Some(buf) => std::task::Poll::Ready(Some(InputDeviceEvent::decode(buf))),
2135            None => std::task::Poll::Ready(None),
2136        }
2137    }
2138}
2139
2140#[derive(Debug)]
2141pub enum InputDeviceEvent {}
2142
2143impl InputDeviceEvent {
2144    /// Decodes a message buffer as a [`InputDeviceEvent`].
2145    fn decode(
2146        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2147    ) -> Result<InputDeviceEvent, fidl::Error> {
2148        let (bytes, _handles) = buf.split_mut();
2149        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2150        debug_assert_eq!(tx_header.tx_id, 0);
2151        match tx_header.ordinal {
2152            _ => Err(fidl::Error::UnknownOrdinal {
2153                ordinal: tx_header.ordinal,
2154                protocol_name: <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2155            }),
2156        }
2157    }
2158}
2159
2160/// A Stream of incoming requests for fuchsia.ui.input/InputDevice.
2161pub struct InputDeviceRequestStream {
2162    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2163    is_terminated: bool,
2164}
2165
2166impl std::marker::Unpin for InputDeviceRequestStream {}
2167
2168impl futures::stream::FusedStream for InputDeviceRequestStream {
2169    fn is_terminated(&self) -> bool {
2170        self.is_terminated
2171    }
2172}
2173
2174impl fidl::endpoints::RequestStream for InputDeviceRequestStream {
2175    type Protocol = InputDeviceMarker;
2176    type ControlHandle = InputDeviceControlHandle;
2177
2178    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2179        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2180    }
2181
2182    fn control_handle(&self) -> Self::ControlHandle {
2183        InputDeviceControlHandle { inner: self.inner.clone() }
2184    }
2185
2186    fn into_inner(
2187        self,
2188    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2189    {
2190        (self.inner, self.is_terminated)
2191    }
2192
2193    fn from_inner(
2194        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2195        is_terminated: bool,
2196    ) -> Self {
2197        Self { inner, is_terminated }
2198    }
2199}
2200
2201impl futures::Stream for InputDeviceRequestStream {
2202    type Item = Result<InputDeviceRequest, fidl::Error>;
2203
2204    fn poll_next(
2205        mut self: std::pin::Pin<&mut Self>,
2206        cx: &mut std::task::Context<'_>,
2207    ) -> std::task::Poll<Option<Self::Item>> {
2208        let this = &mut *self;
2209        if this.inner.check_shutdown(cx) {
2210            this.is_terminated = true;
2211            return std::task::Poll::Ready(None);
2212        }
2213        if this.is_terminated {
2214            panic!("polled InputDeviceRequestStream after completion");
2215        }
2216        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2217            |bytes, handles| {
2218                match this.inner.channel().read_etc(cx, bytes, handles) {
2219                    std::task::Poll::Ready(Ok(())) => {}
2220                    std::task::Poll::Pending => return std::task::Poll::Pending,
2221                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2222                        this.is_terminated = true;
2223                        return std::task::Poll::Ready(None);
2224                    }
2225                    std::task::Poll::Ready(Err(e)) => {
2226                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2227                            e.into(),
2228                        ))));
2229                    }
2230                }
2231
2232                // A message has been received from the channel
2233                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2234
2235                std::task::Poll::Ready(Some(match header.ordinal {
2236                    0x7ee375d01c8e149f => {
2237                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2238                        let mut req = fidl::new_empty!(
2239                            InputDeviceDispatchReportRequest,
2240                            fidl::encoding::DefaultFuchsiaResourceDialect
2241                        );
2242                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceDispatchReportRequest>(&header, _body_bytes, handles, &mut req)?;
2243                        let control_handle = InputDeviceControlHandle { inner: this.inner.clone() };
2244                        Ok(InputDeviceRequest::DispatchReport {
2245                            report: req.report,
2246
2247                            control_handle,
2248                        })
2249                    }
2250                    _ => Err(fidl::Error::UnknownOrdinal {
2251                        ordinal: header.ordinal,
2252                        protocol_name:
2253                            <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2254                    }),
2255                }))
2256            },
2257        )
2258    }
2259}
2260
2261#[derive(Debug)]
2262pub enum InputDeviceRequest {
2263    /// Dispatch an `InputReport` from the device `token`
2264    DispatchReport { report: InputReport, control_handle: InputDeviceControlHandle },
2265}
2266
2267impl InputDeviceRequest {
2268    #[allow(irrefutable_let_patterns)]
2269    pub fn into_dispatch_report(self) -> Option<(InputReport, InputDeviceControlHandle)> {
2270        if let InputDeviceRequest::DispatchReport { report, control_handle } = self {
2271            Some((report, control_handle))
2272        } else {
2273            None
2274        }
2275    }
2276
2277    /// Name of the method defined in FIDL
2278    pub fn method_name(&self) -> &'static str {
2279        match *self {
2280            InputDeviceRequest::DispatchReport { .. } => "dispatch_report",
2281        }
2282    }
2283}
2284
2285#[derive(Debug, Clone)]
2286pub struct InputDeviceControlHandle {
2287    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2288}
2289
2290impl InputDeviceControlHandle {
2291    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2292        self.inner.shutdown_with_epitaph(status.into())
2293    }
2294}
2295
2296impl fidl::endpoints::ControlHandle for InputDeviceControlHandle {
2297    fn shutdown(&self) {
2298        self.inner.shutdown()
2299    }
2300
2301    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2302        self.inner.shutdown_with_epitaph(status)
2303    }
2304
2305    fn is_closed(&self) -> bool {
2306        self.inner.channel().is_closed()
2307    }
2308    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2309        self.inner.channel().on_closed()
2310    }
2311
2312    #[cfg(target_os = "fuchsia")]
2313    fn signal_peer(
2314        &self,
2315        clear_mask: zx::Signals,
2316        set_mask: zx::Signals,
2317    ) -> Result<(), zx_status::Status> {
2318        use fidl::Peered;
2319        self.inner.channel().signal_peer(clear_mask, set_mask)
2320    }
2321}
2322
2323impl InputDeviceControlHandle {}
2324
2325#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2326pub struct InputMethodEditorMarker;
2327
2328impl fidl::endpoints::ProtocolMarker for InputMethodEditorMarker {
2329    type Proxy = InputMethodEditorProxy;
2330    type RequestStream = InputMethodEditorRequestStream;
2331    #[cfg(target_os = "fuchsia")]
2332    type SynchronousProxy = InputMethodEditorSynchronousProxy;
2333
2334    const DEBUG_NAME: &'static str = "(anonymous) InputMethodEditor";
2335}
2336
2337pub trait InputMethodEditorProxyInterface: Send + Sync {
2338    fn r#set_keyboard_type(&self, keyboard_type: KeyboardType) -> Result<(), fidl::Error>;
2339    fn r#set_state(&self, state: &TextInputState) -> Result<(), fidl::Error>;
2340    fn r#inject_input(&self, event: &InputEvent) -> Result<(), fidl::Error>;
2341    type DispatchKey3ResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
2342    fn r#dispatch_key3(
2343        &self,
2344        event: &fidl_fuchsia_ui_input3::KeyEvent,
2345    ) -> Self::DispatchKey3ResponseFut;
2346    fn r#show(&self) -> Result<(), fidl::Error>;
2347    fn r#hide(&self) -> Result<(), fidl::Error>;
2348}
2349#[derive(Debug)]
2350#[cfg(target_os = "fuchsia")]
2351pub struct InputMethodEditorSynchronousProxy {
2352    client: fidl::client::sync::Client,
2353}
2354
2355#[cfg(target_os = "fuchsia")]
2356impl fidl::endpoints::SynchronousProxy for InputMethodEditorSynchronousProxy {
2357    type Proxy = InputMethodEditorProxy;
2358    type Protocol = InputMethodEditorMarker;
2359
2360    fn from_channel(inner: fidl::Channel) -> Self {
2361        Self::new(inner)
2362    }
2363
2364    fn into_channel(self) -> fidl::Channel {
2365        self.client.into_channel()
2366    }
2367
2368    fn as_channel(&self) -> &fidl::Channel {
2369        self.client.as_channel()
2370    }
2371}
2372
2373#[cfg(target_os = "fuchsia")]
2374impl InputMethodEditorSynchronousProxy {
2375    pub fn new(channel: fidl::Channel) -> Self {
2376        Self { client: fidl::client::sync::Client::new(channel) }
2377    }
2378
2379    pub fn into_channel(self) -> fidl::Channel {
2380        self.client.into_channel()
2381    }
2382
2383    /// Waits until an event arrives and returns it. It is safe for other
2384    /// threads to make concurrent requests while waiting for an event.
2385    pub fn wait_for_event(
2386        &self,
2387        deadline: zx::MonotonicInstant,
2388    ) -> Result<InputMethodEditorEvent, fidl::Error> {
2389        InputMethodEditorEvent::decode(
2390            self.client.wait_for_event::<InputMethodEditorMarker>(deadline)?,
2391        )
2392    }
2393
2394    pub fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
2395        self.client.send::<InputMethodEditorSetKeyboardTypeRequest>(
2396            (keyboard_type,),
2397            0x14fe60e927d7d487,
2398            fidl::encoding::DynamicFlags::empty(),
2399        )
2400    }
2401
2402    pub fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
2403        self.client.send::<InputMethodEditorSetStateRequest>(
2404            (state,),
2405            0x12b477b779818f45,
2406            fidl::encoding::DynamicFlags::empty(),
2407        )
2408    }
2409
2410    pub fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
2411        self.client.send::<InputMethodEditorInjectInputRequest>(
2412            (event,),
2413            0x34af74618a4f82b,
2414            fidl::encoding::DynamicFlags::empty(),
2415        )
2416    }
2417
2418    pub fn r#dispatch_key3(
2419        &self,
2420        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
2421        ___deadline: zx::MonotonicInstant,
2422    ) -> Result<bool, fidl::Error> {
2423        let _response = self.client.send_query::<
2424            InputMethodEditorDispatchKey3Request,
2425            InputMethodEditorDispatchKey3Response,
2426            InputMethodEditorMarker,
2427        >(
2428            (event,),
2429            0x2e13667c827209ac,
2430            fidl::encoding::DynamicFlags::empty(),
2431            ___deadline,
2432        )?;
2433        Ok(_response.handled)
2434    }
2435
2436    pub fn r#show(&self) -> Result<(), fidl::Error> {
2437        self.client.send::<fidl::encoding::EmptyPayload>(
2438            (),
2439            0x19ba00ba1beb002e,
2440            fidl::encoding::DynamicFlags::empty(),
2441        )
2442    }
2443
2444    pub fn r#hide(&self) -> Result<(), fidl::Error> {
2445        self.client.send::<fidl::encoding::EmptyPayload>(
2446            (),
2447            0x283e0cd73f0d6d9e,
2448            fidl::encoding::DynamicFlags::empty(),
2449        )
2450    }
2451}
2452
2453#[cfg(target_os = "fuchsia")]
2454impl From<InputMethodEditorSynchronousProxy> for zx::NullableHandle {
2455    fn from(value: InputMethodEditorSynchronousProxy) -> Self {
2456        value.into_channel().into()
2457    }
2458}
2459
2460#[cfg(target_os = "fuchsia")]
2461impl From<fidl::Channel> for InputMethodEditorSynchronousProxy {
2462    fn from(value: fidl::Channel) -> Self {
2463        Self::new(value)
2464    }
2465}
2466
2467#[cfg(target_os = "fuchsia")]
2468impl fidl::endpoints::FromClient for InputMethodEditorSynchronousProxy {
2469    type Protocol = InputMethodEditorMarker;
2470
2471    fn from_client(value: fidl::endpoints::ClientEnd<InputMethodEditorMarker>) -> Self {
2472        Self::new(value.into_channel())
2473    }
2474}
2475
2476#[derive(Debug, Clone)]
2477pub struct InputMethodEditorProxy {
2478    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2479}
2480
2481impl fidl::endpoints::Proxy for InputMethodEditorProxy {
2482    type Protocol = InputMethodEditorMarker;
2483
2484    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2485        Self::new(inner)
2486    }
2487
2488    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2489        self.client.into_channel().map_err(|client| Self { client })
2490    }
2491
2492    fn as_channel(&self) -> &::fidl::AsyncChannel {
2493        self.client.as_channel()
2494    }
2495}
2496
2497impl InputMethodEditorProxy {
2498    /// Create a new Proxy for fuchsia.ui.input/InputMethodEditor.
2499    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2500        let protocol_name =
2501            <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2502        Self { client: fidl::client::Client::new(channel, protocol_name) }
2503    }
2504
2505    /// Get a Stream of events from the remote end of the protocol.
2506    ///
2507    /// # Panics
2508    ///
2509    /// Panics if the event stream was already taken.
2510    pub fn take_event_stream(&self) -> InputMethodEditorEventStream {
2511        InputMethodEditorEventStream { event_receiver: self.client.take_event_receiver() }
2512    }
2513
2514    pub fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
2515        InputMethodEditorProxyInterface::r#set_keyboard_type(self, keyboard_type)
2516    }
2517
2518    pub fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
2519        InputMethodEditorProxyInterface::r#set_state(self, state)
2520    }
2521
2522    pub fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
2523        InputMethodEditorProxyInterface::r#inject_input(self, event)
2524    }
2525
2526    pub fn r#dispatch_key3(
2527        &self,
2528        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
2529    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
2530        InputMethodEditorProxyInterface::r#dispatch_key3(self, event)
2531    }
2532
2533    pub fn r#show(&self) -> Result<(), fidl::Error> {
2534        InputMethodEditorProxyInterface::r#show(self)
2535    }
2536
2537    pub fn r#hide(&self) -> Result<(), fidl::Error> {
2538        InputMethodEditorProxyInterface::r#hide(self)
2539    }
2540}
2541
2542impl InputMethodEditorProxyInterface for InputMethodEditorProxy {
2543    fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
2544        self.client.send::<InputMethodEditorSetKeyboardTypeRequest>(
2545            (keyboard_type,),
2546            0x14fe60e927d7d487,
2547            fidl::encoding::DynamicFlags::empty(),
2548        )
2549    }
2550
2551    fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
2552        self.client.send::<InputMethodEditorSetStateRequest>(
2553            (state,),
2554            0x12b477b779818f45,
2555            fidl::encoding::DynamicFlags::empty(),
2556        )
2557    }
2558
2559    fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
2560        self.client.send::<InputMethodEditorInjectInputRequest>(
2561            (event,),
2562            0x34af74618a4f82b,
2563            fidl::encoding::DynamicFlags::empty(),
2564        )
2565    }
2566
2567    type DispatchKey3ResponseFut =
2568        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
2569    fn r#dispatch_key3(
2570        &self,
2571        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
2572    ) -> Self::DispatchKey3ResponseFut {
2573        fn _decode(
2574            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2575        ) -> Result<bool, fidl::Error> {
2576            let _response = fidl::client::decode_transaction_body::<
2577                InputMethodEditorDispatchKey3Response,
2578                fidl::encoding::DefaultFuchsiaResourceDialect,
2579                0x2e13667c827209ac,
2580            >(_buf?)?;
2581            Ok(_response.handled)
2582        }
2583        self.client.send_query_and_decode::<InputMethodEditorDispatchKey3Request, bool>(
2584            (event,),
2585            0x2e13667c827209ac,
2586            fidl::encoding::DynamicFlags::empty(),
2587            _decode,
2588        )
2589    }
2590
2591    fn r#show(&self) -> Result<(), fidl::Error> {
2592        self.client.send::<fidl::encoding::EmptyPayload>(
2593            (),
2594            0x19ba00ba1beb002e,
2595            fidl::encoding::DynamicFlags::empty(),
2596        )
2597    }
2598
2599    fn r#hide(&self) -> Result<(), fidl::Error> {
2600        self.client.send::<fidl::encoding::EmptyPayload>(
2601            (),
2602            0x283e0cd73f0d6d9e,
2603            fidl::encoding::DynamicFlags::empty(),
2604        )
2605    }
2606}
2607
2608pub struct InputMethodEditorEventStream {
2609    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2610}
2611
2612impl std::marker::Unpin for InputMethodEditorEventStream {}
2613
2614impl futures::stream::FusedStream for InputMethodEditorEventStream {
2615    fn is_terminated(&self) -> bool {
2616        self.event_receiver.is_terminated()
2617    }
2618}
2619
2620impl futures::Stream for InputMethodEditorEventStream {
2621    type Item = Result<InputMethodEditorEvent, fidl::Error>;
2622
2623    fn poll_next(
2624        mut self: std::pin::Pin<&mut Self>,
2625        cx: &mut std::task::Context<'_>,
2626    ) -> std::task::Poll<Option<Self::Item>> {
2627        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2628            &mut self.event_receiver,
2629            cx
2630        )?) {
2631            Some(buf) => std::task::Poll::Ready(Some(InputMethodEditorEvent::decode(buf))),
2632            None => std::task::Poll::Ready(None),
2633        }
2634    }
2635}
2636
2637#[derive(Debug)]
2638pub enum InputMethodEditorEvent {}
2639
2640impl InputMethodEditorEvent {
2641    /// Decodes a message buffer as a [`InputMethodEditorEvent`].
2642    fn decode(
2643        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2644    ) -> Result<InputMethodEditorEvent, fidl::Error> {
2645        let (bytes, _handles) = buf.split_mut();
2646        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2647        debug_assert_eq!(tx_header.tx_id, 0);
2648        match tx_header.ordinal {
2649            _ => Err(fidl::Error::UnknownOrdinal {
2650                ordinal: tx_header.ordinal,
2651                protocol_name:
2652                    <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2653            }),
2654        }
2655    }
2656}
2657
2658/// A Stream of incoming requests for fuchsia.ui.input/InputMethodEditor.
2659pub struct InputMethodEditorRequestStream {
2660    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2661    is_terminated: bool,
2662}
2663
2664impl std::marker::Unpin for InputMethodEditorRequestStream {}
2665
2666impl futures::stream::FusedStream for InputMethodEditorRequestStream {
2667    fn is_terminated(&self) -> bool {
2668        self.is_terminated
2669    }
2670}
2671
2672impl fidl::endpoints::RequestStream for InputMethodEditorRequestStream {
2673    type Protocol = InputMethodEditorMarker;
2674    type ControlHandle = InputMethodEditorControlHandle;
2675
2676    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2677        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2678    }
2679
2680    fn control_handle(&self) -> Self::ControlHandle {
2681        InputMethodEditorControlHandle { inner: self.inner.clone() }
2682    }
2683
2684    fn into_inner(
2685        self,
2686    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2687    {
2688        (self.inner, self.is_terminated)
2689    }
2690
2691    fn from_inner(
2692        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2693        is_terminated: bool,
2694    ) -> Self {
2695        Self { inner, is_terminated }
2696    }
2697}
2698
2699impl futures::Stream for InputMethodEditorRequestStream {
2700    type Item = Result<InputMethodEditorRequest, fidl::Error>;
2701
2702    fn poll_next(
2703        mut self: std::pin::Pin<&mut Self>,
2704        cx: &mut std::task::Context<'_>,
2705    ) -> std::task::Poll<Option<Self::Item>> {
2706        let this = &mut *self;
2707        if this.inner.check_shutdown(cx) {
2708            this.is_terminated = true;
2709            return std::task::Poll::Ready(None);
2710        }
2711        if this.is_terminated {
2712            panic!("polled InputMethodEditorRequestStream after completion");
2713        }
2714        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2715            |bytes, handles| {
2716                match this.inner.channel().read_etc(cx, bytes, handles) {
2717                    std::task::Poll::Ready(Ok(())) => {}
2718                    std::task::Poll::Pending => return std::task::Poll::Pending,
2719                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2720                        this.is_terminated = true;
2721                        return std::task::Poll::Ready(None);
2722                    }
2723                    std::task::Poll::Ready(Err(e)) => {
2724                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2725                            e.into(),
2726                        ))));
2727                    }
2728                }
2729
2730                // A message has been received from the channel
2731                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2732
2733                std::task::Poll::Ready(Some(match header.ordinal {
2734                    0x14fe60e927d7d487 => {
2735                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2736                        let mut req = fidl::new_empty!(
2737                            InputMethodEditorSetKeyboardTypeRequest,
2738                            fidl::encoding::DefaultFuchsiaResourceDialect
2739                        );
2740                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorSetKeyboardTypeRequest>(&header, _body_bytes, handles, &mut req)?;
2741                        let control_handle =
2742                            InputMethodEditorControlHandle { inner: this.inner.clone() };
2743                        Ok(InputMethodEditorRequest::SetKeyboardType {
2744                            keyboard_type: req.keyboard_type,
2745
2746                            control_handle,
2747                        })
2748                    }
2749                    0x12b477b779818f45 => {
2750                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2751                        let mut req = fidl::new_empty!(
2752                            InputMethodEditorSetStateRequest,
2753                            fidl::encoding::DefaultFuchsiaResourceDialect
2754                        );
2755                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorSetStateRequest>(&header, _body_bytes, handles, &mut req)?;
2756                        let control_handle =
2757                            InputMethodEditorControlHandle { inner: this.inner.clone() };
2758                        Ok(InputMethodEditorRequest::SetState { state: req.state, control_handle })
2759                    }
2760                    0x34af74618a4f82b => {
2761                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2762                        let mut req = fidl::new_empty!(
2763                            InputMethodEditorInjectInputRequest,
2764                            fidl::encoding::DefaultFuchsiaResourceDialect
2765                        );
2766                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorInjectInputRequest>(&header, _body_bytes, handles, &mut req)?;
2767                        let control_handle =
2768                            InputMethodEditorControlHandle { inner: this.inner.clone() };
2769                        Ok(InputMethodEditorRequest::InjectInput {
2770                            event: req.event,
2771
2772                            control_handle,
2773                        })
2774                    }
2775                    0x2e13667c827209ac => {
2776                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2777                        let mut req = fidl::new_empty!(
2778                            InputMethodEditorDispatchKey3Request,
2779                            fidl::encoding::DefaultFuchsiaResourceDialect
2780                        );
2781                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorDispatchKey3Request>(&header, _body_bytes, handles, &mut req)?;
2782                        let control_handle =
2783                            InputMethodEditorControlHandle { inner: this.inner.clone() };
2784                        Ok(InputMethodEditorRequest::DispatchKey3 {
2785                            event: req.event,
2786
2787                            responder: InputMethodEditorDispatchKey3Responder {
2788                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2789                                tx_id: header.tx_id,
2790                            },
2791                        })
2792                    }
2793                    0x19ba00ba1beb002e => {
2794                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2795                        let mut req = fidl::new_empty!(
2796                            fidl::encoding::EmptyPayload,
2797                            fidl::encoding::DefaultFuchsiaResourceDialect
2798                        );
2799                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2800                        let control_handle =
2801                            InputMethodEditorControlHandle { inner: this.inner.clone() };
2802                        Ok(InputMethodEditorRequest::Show { control_handle })
2803                    }
2804                    0x283e0cd73f0d6d9e => {
2805                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2806                        let mut req = fidl::new_empty!(
2807                            fidl::encoding::EmptyPayload,
2808                            fidl::encoding::DefaultFuchsiaResourceDialect
2809                        );
2810                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2811                        let control_handle =
2812                            InputMethodEditorControlHandle { inner: this.inner.clone() };
2813                        Ok(InputMethodEditorRequest::Hide { control_handle })
2814                    }
2815                    _ => Err(fidl::Error::UnknownOrdinal {
2816                        ordinal: header.ordinal,
2817                        protocol_name:
2818                            <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2819                    }),
2820                }))
2821            },
2822        )
2823    }
2824}
2825
2826/// A interface for interacting with a text input control.
2827#[derive(Debug)]
2828pub enum InputMethodEditorRequest {
2829    SetKeyboardType {
2830        keyboard_type: KeyboardType,
2831        control_handle: InputMethodEditorControlHandle,
2832    },
2833    SetState {
2834        state: TextInputState,
2835        control_handle: InputMethodEditorControlHandle,
2836    },
2837    InjectInput {
2838        event: InputEvent,
2839        control_handle: InputMethodEditorControlHandle,
2840    },
2841    DispatchKey3 {
2842        event: fidl_fuchsia_ui_input3::KeyEvent,
2843        responder: InputMethodEditorDispatchKey3Responder,
2844    },
2845    Show {
2846        control_handle: InputMethodEditorControlHandle,
2847    },
2848    Hide {
2849        control_handle: InputMethodEditorControlHandle,
2850    },
2851}
2852
2853impl InputMethodEditorRequest {
2854    #[allow(irrefutable_let_patterns)]
2855    pub fn into_set_keyboard_type(self) -> Option<(KeyboardType, InputMethodEditorControlHandle)> {
2856        if let InputMethodEditorRequest::SetKeyboardType { keyboard_type, control_handle } = self {
2857            Some((keyboard_type, control_handle))
2858        } else {
2859            None
2860        }
2861    }
2862
2863    #[allow(irrefutable_let_patterns)]
2864    pub fn into_set_state(self) -> Option<(TextInputState, InputMethodEditorControlHandle)> {
2865        if let InputMethodEditorRequest::SetState { state, control_handle } = self {
2866            Some((state, control_handle))
2867        } else {
2868            None
2869        }
2870    }
2871
2872    #[allow(irrefutable_let_patterns)]
2873    pub fn into_inject_input(self) -> Option<(InputEvent, InputMethodEditorControlHandle)> {
2874        if let InputMethodEditorRequest::InjectInput { event, control_handle } = self {
2875            Some((event, control_handle))
2876        } else {
2877            None
2878        }
2879    }
2880
2881    #[allow(irrefutable_let_patterns)]
2882    pub fn into_dispatch_key3(
2883        self,
2884    ) -> Option<(fidl_fuchsia_ui_input3::KeyEvent, InputMethodEditorDispatchKey3Responder)> {
2885        if let InputMethodEditorRequest::DispatchKey3 { event, responder } = self {
2886            Some((event, responder))
2887        } else {
2888            None
2889        }
2890    }
2891
2892    #[allow(irrefutable_let_patterns)]
2893    pub fn into_show(self) -> Option<(InputMethodEditorControlHandle)> {
2894        if let InputMethodEditorRequest::Show { control_handle } = self {
2895            Some((control_handle))
2896        } else {
2897            None
2898        }
2899    }
2900
2901    #[allow(irrefutable_let_patterns)]
2902    pub fn into_hide(self) -> Option<(InputMethodEditorControlHandle)> {
2903        if let InputMethodEditorRequest::Hide { control_handle } = self {
2904            Some((control_handle))
2905        } else {
2906            None
2907        }
2908    }
2909
2910    /// Name of the method defined in FIDL
2911    pub fn method_name(&self) -> &'static str {
2912        match *self {
2913            InputMethodEditorRequest::SetKeyboardType { .. } => "set_keyboard_type",
2914            InputMethodEditorRequest::SetState { .. } => "set_state",
2915            InputMethodEditorRequest::InjectInput { .. } => "inject_input",
2916            InputMethodEditorRequest::DispatchKey3 { .. } => "dispatch_key3",
2917            InputMethodEditorRequest::Show { .. } => "show",
2918            InputMethodEditorRequest::Hide { .. } => "hide",
2919        }
2920    }
2921}
2922
2923#[derive(Debug, Clone)]
2924pub struct InputMethodEditorControlHandle {
2925    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2926}
2927
2928impl InputMethodEditorControlHandle {
2929    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2930        self.inner.shutdown_with_epitaph(status.into())
2931    }
2932}
2933
2934impl fidl::endpoints::ControlHandle for InputMethodEditorControlHandle {
2935    fn shutdown(&self) {
2936        self.inner.shutdown()
2937    }
2938
2939    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2940        self.inner.shutdown_with_epitaph(status)
2941    }
2942
2943    fn is_closed(&self) -> bool {
2944        self.inner.channel().is_closed()
2945    }
2946    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2947        self.inner.channel().on_closed()
2948    }
2949
2950    #[cfg(target_os = "fuchsia")]
2951    fn signal_peer(
2952        &self,
2953        clear_mask: zx::Signals,
2954        set_mask: zx::Signals,
2955    ) -> Result<(), zx_status::Status> {
2956        use fidl::Peered;
2957        self.inner.channel().signal_peer(clear_mask, set_mask)
2958    }
2959}
2960
2961impl InputMethodEditorControlHandle {}
2962
2963#[must_use = "FIDL methods require a response to be sent"]
2964#[derive(Debug)]
2965pub struct InputMethodEditorDispatchKey3Responder {
2966    control_handle: std::mem::ManuallyDrop<InputMethodEditorControlHandle>,
2967    tx_id: u32,
2968}
2969
2970/// Set the the channel to be shutdown (see [`InputMethodEditorControlHandle::shutdown`])
2971/// if the responder is dropped without sending a response, so that the client
2972/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2973impl std::ops::Drop for InputMethodEditorDispatchKey3Responder {
2974    fn drop(&mut self) {
2975        self.control_handle.shutdown();
2976        // Safety: drops once, never accessed again
2977        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2978    }
2979}
2980
2981impl fidl::endpoints::Responder for InputMethodEditorDispatchKey3Responder {
2982    type ControlHandle = InputMethodEditorControlHandle;
2983
2984    fn control_handle(&self) -> &InputMethodEditorControlHandle {
2985        &self.control_handle
2986    }
2987
2988    fn drop_without_shutdown(mut self) {
2989        // Safety: drops once, never accessed again due to mem::forget
2990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2991        // Prevent Drop from running (which would shut down the channel)
2992        std::mem::forget(self);
2993    }
2994}
2995
2996impl InputMethodEditorDispatchKey3Responder {
2997    /// Sends a response to the FIDL transaction.
2998    ///
2999    /// Sets the channel to shutdown if an error occurs.
3000    pub fn send(self, mut handled: bool) -> Result<(), fidl::Error> {
3001        let _result = self.send_raw(handled);
3002        if _result.is_err() {
3003            self.control_handle.shutdown();
3004        }
3005        self.drop_without_shutdown();
3006        _result
3007    }
3008
3009    /// Similar to "send" but does not shutdown the channel if an error occurs.
3010    pub fn send_no_shutdown_on_err(self, mut handled: bool) -> Result<(), fidl::Error> {
3011        let _result = self.send_raw(handled);
3012        self.drop_without_shutdown();
3013        _result
3014    }
3015
3016    fn send_raw(&self, mut handled: bool) -> Result<(), fidl::Error> {
3017        self.control_handle.inner.send::<InputMethodEditorDispatchKey3Response>(
3018            (handled,),
3019            self.tx_id,
3020            0x2e13667c827209ac,
3021            fidl::encoding::DynamicFlags::empty(),
3022        )
3023    }
3024}
3025
3026#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3027pub struct InputMethodEditorClientMarker;
3028
3029impl fidl::endpoints::ProtocolMarker for InputMethodEditorClientMarker {
3030    type Proxy = InputMethodEditorClientProxy;
3031    type RequestStream = InputMethodEditorClientRequestStream;
3032    #[cfg(target_os = "fuchsia")]
3033    type SynchronousProxy = InputMethodEditorClientSynchronousProxy;
3034
3035    const DEBUG_NAME: &'static str = "(anonymous) InputMethodEditorClient";
3036}
3037
3038pub trait InputMethodEditorClientProxyInterface: Send + Sync {
3039    fn r#did_update_state(
3040        &self,
3041        state: &TextInputState,
3042        event: Option<&InputEvent>,
3043    ) -> Result<(), fidl::Error>;
3044    fn r#on_action(&self, action: InputMethodAction) -> Result<(), fidl::Error>;
3045}
3046#[derive(Debug)]
3047#[cfg(target_os = "fuchsia")]
3048pub struct InputMethodEditorClientSynchronousProxy {
3049    client: fidl::client::sync::Client,
3050}
3051
3052#[cfg(target_os = "fuchsia")]
3053impl fidl::endpoints::SynchronousProxy for InputMethodEditorClientSynchronousProxy {
3054    type Proxy = InputMethodEditorClientProxy;
3055    type Protocol = InputMethodEditorClientMarker;
3056
3057    fn from_channel(inner: fidl::Channel) -> Self {
3058        Self::new(inner)
3059    }
3060
3061    fn into_channel(self) -> fidl::Channel {
3062        self.client.into_channel()
3063    }
3064
3065    fn as_channel(&self) -> &fidl::Channel {
3066        self.client.as_channel()
3067    }
3068}
3069
3070#[cfg(target_os = "fuchsia")]
3071impl InputMethodEditorClientSynchronousProxy {
3072    pub fn new(channel: fidl::Channel) -> Self {
3073        Self { client: fidl::client::sync::Client::new(channel) }
3074    }
3075
3076    pub fn into_channel(self) -> fidl::Channel {
3077        self.client.into_channel()
3078    }
3079
3080    /// Waits until an event arrives and returns it. It is safe for other
3081    /// threads to make concurrent requests while waiting for an event.
3082    pub fn wait_for_event(
3083        &self,
3084        deadline: zx::MonotonicInstant,
3085    ) -> Result<InputMethodEditorClientEvent, fidl::Error> {
3086        InputMethodEditorClientEvent::decode(
3087            self.client.wait_for_event::<InputMethodEditorClientMarker>(deadline)?,
3088        )
3089    }
3090
3091    pub fn r#did_update_state(
3092        &self,
3093        mut state: &TextInputState,
3094        mut event: Option<&InputEvent>,
3095    ) -> Result<(), fidl::Error> {
3096        self.client.send::<InputMethodEditorClientDidUpdateStateRequest>(
3097            (state, event),
3098            0x26681a6b204b679d,
3099            fidl::encoding::DynamicFlags::empty(),
3100        )
3101    }
3102
3103    pub fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
3104        self.client.send::<InputMethodEditorClientOnActionRequest>(
3105            (action,),
3106            0x19c420f173275398,
3107            fidl::encoding::DynamicFlags::empty(),
3108        )
3109    }
3110}
3111
3112#[cfg(target_os = "fuchsia")]
3113impl From<InputMethodEditorClientSynchronousProxy> for zx::NullableHandle {
3114    fn from(value: InputMethodEditorClientSynchronousProxy) -> Self {
3115        value.into_channel().into()
3116    }
3117}
3118
3119#[cfg(target_os = "fuchsia")]
3120impl From<fidl::Channel> for InputMethodEditorClientSynchronousProxy {
3121    fn from(value: fidl::Channel) -> Self {
3122        Self::new(value)
3123    }
3124}
3125
3126#[cfg(target_os = "fuchsia")]
3127impl fidl::endpoints::FromClient for InputMethodEditorClientSynchronousProxy {
3128    type Protocol = InputMethodEditorClientMarker;
3129
3130    fn from_client(value: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>) -> Self {
3131        Self::new(value.into_channel())
3132    }
3133}
3134
3135#[derive(Debug, Clone)]
3136pub struct InputMethodEditorClientProxy {
3137    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3138}
3139
3140impl fidl::endpoints::Proxy for InputMethodEditorClientProxy {
3141    type Protocol = InputMethodEditorClientMarker;
3142
3143    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3144        Self::new(inner)
3145    }
3146
3147    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3148        self.client.into_channel().map_err(|client| Self { client })
3149    }
3150
3151    fn as_channel(&self) -> &::fidl::AsyncChannel {
3152        self.client.as_channel()
3153    }
3154}
3155
3156impl InputMethodEditorClientProxy {
3157    /// Create a new Proxy for fuchsia.ui.input/InputMethodEditorClient.
3158    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3159        let protocol_name =
3160            <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3161        Self { client: fidl::client::Client::new(channel, protocol_name) }
3162    }
3163
3164    /// Get a Stream of events from the remote end of the protocol.
3165    ///
3166    /// # Panics
3167    ///
3168    /// Panics if the event stream was already taken.
3169    pub fn take_event_stream(&self) -> InputMethodEditorClientEventStream {
3170        InputMethodEditorClientEventStream { event_receiver: self.client.take_event_receiver() }
3171    }
3172
3173    pub fn r#did_update_state(
3174        &self,
3175        mut state: &TextInputState,
3176        mut event: Option<&InputEvent>,
3177    ) -> Result<(), fidl::Error> {
3178        InputMethodEditorClientProxyInterface::r#did_update_state(self, state, event)
3179    }
3180
3181    pub fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
3182        InputMethodEditorClientProxyInterface::r#on_action(self, action)
3183    }
3184}
3185
3186impl InputMethodEditorClientProxyInterface for InputMethodEditorClientProxy {
3187    fn r#did_update_state(
3188        &self,
3189        mut state: &TextInputState,
3190        mut event: Option<&InputEvent>,
3191    ) -> Result<(), fidl::Error> {
3192        self.client.send::<InputMethodEditorClientDidUpdateStateRequest>(
3193            (state, event),
3194            0x26681a6b204b679d,
3195            fidl::encoding::DynamicFlags::empty(),
3196        )
3197    }
3198
3199    fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
3200        self.client.send::<InputMethodEditorClientOnActionRequest>(
3201            (action,),
3202            0x19c420f173275398,
3203            fidl::encoding::DynamicFlags::empty(),
3204        )
3205    }
3206}
3207
3208pub struct InputMethodEditorClientEventStream {
3209    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3210}
3211
3212impl std::marker::Unpin for InputMethodEditorClientEventStream {}
3213
3214impl futures::stream::FusedStream for InputMethodEditorClientEventStream {
3215    fn is_terminated(&self) -> bool {
3216        self.event_receiver.is_terminated()
3217    }
3218}
3219
3220impl futures::Stream for InputMethodEditorClientEventStream {
3221    type Item = Result<InputMethodEditorClientEvent, fidl::Error>;
3222
3223    fn poll_next(
3224        mut self: std::pin::Pin<&mut Self>,
3225        cx: &mut std::task::Context<'_>,
3226    ) -> std::task::Poll<Option<Self::Item>> {
3227        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3228            &mut self.event_receiver,
3229            cx
3230        )?) {
3231            Some(buf) => std::task::Poll::Ready(Some(InputMethodEditorClientEvent::decode(buf))),
3232            None => std::task::Poll::Ready(None),
3233        }
3234    }
3235}
3236
3237#[derive(Debug)]
3238pub enum InputMethodEditorClientEvent {}
3239
3240impl InputMethodEditorClientEvent {
3241    /// Decodes a message buffer as a [`InputMethodEditorClientEvent`].
3242    fn decode(
3243        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3244    ) -> Result<InputMethodEditorClientEvent, fidl::Error> {
3245        let (bytes, _handles) = buf.split_mut();
3246        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3247        debug_assert_eq!(tx_header.tx_id, 0);
3248        match tx_header.ordinal {
3249            _ => Err(fidl::Error::UnknownOrdinal {
3250                ordinal: tx_header.ordinal,
3251                protocol_name:
3252                    <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3253            }),
3254        }
3255    }
3256}
3257
3258/// A Stream of incoming requests for fuchsia.ui.input/InputMethodEditorClient.
3259pub struct InputMethodEditorClientRequestStream {
3260    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3261    is_terminated: bool,
3262}
3263
3264impl std::marker::Unpin for InputMethodEditorClientRequestStream {}
3265
3266impl futures::stream::FusedStream for InputMethodEditorClientRequestStream {
3267    fn is_terminated(&self) -> bool {
3268        self.is_terminated
3269    }
3270}
3271
3272impl fidl::endpoints::RequestStream for InputMethodEditorClientRequestStream {
3273    type Protocol = InputMethodEditorClientMarker;
3274    type ControlHandle = InputMethodEditorClientControlHandle;
3275
3276    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3277        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3278    }
3279
3280    fn control_handle(&self) -> Self::ControlHandle {
3281        InputMethodEditorClientControlHandle { inner: self.inner.clone() }
3282    }
3283
3284    fn into_inner(
3285        self,
3286    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3287    {
3288        (self.inner, self.is_terminated)
3289    }
3290
3291    fn from_inner(
3292        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3293        is_terminated: bool,
3294    ) -> Self {
3295        Self { inner, is_terminated }
3296    }
3297}
3298
3299impl futures::Stream for InputMethodEditorClientRequestStream {
3300    type Item = Result<InputMethodEditorClientRequest, fidl::Error>;
3301
3302    fn poll_next(
3303        mut self: std::pin::Pin<&mut Self>,
3304        cx: &mut std::task::Context<'_>,
3305    ) -> std::task::Poll<Option<Self::Item>> {
3306        let this = &mut *self;
3307        if this.inner.check_shutdown(cx) {
3308            this.is_terminated = true;
3309            return std::task::Poll::Ready(None);
3310        }
3311        if this.is_terminated {
3312            panic!("polled InputMethodEditorClientRequestStream after completion");
3313        }
3314        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3315            |bytes, handles| {
3316                match this.inner.channel().read_etc(cx, bytes, handles) {
3317                    std::task::Poll::Ready(Ok(())) => {}
3318                    std::task::Poll::Pending => return std::task::Poll::Pending,
3319                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3320                        this.is_terminated = true;
3321                        return std::task::Poll::Ready(None);
3322                    }
3323                    std::task::Poll::Ready(Err(e)) => {
3324                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3325                            e.into(),
3326                        ))));
3327                    }
3328                }
3329
3330                // A message has been received from the channel
3331                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3332
3333                std::task::Poll::Ready(Some(match header.ordinal {
3334                0x26681a6b204b679d => {
3335                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3336                    let mut req = fidl::new_empty!(InputMethodEditorClientDidUpdateStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
3337                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorClientDidUpdateStateRequest>(&header, _body_bytes, handles, &mut req)?;
3338                    let control_handle = InputMethodEditorClientControlHandle {
3339                        inner: this.inner.clone(),
3340                    };
3341                    Ok(InputMethodEditorClientRequest::DidUpdateState {state: req.state,
3342event: req.event,
3343
3344                        control_handle,
3345                    })
3346                }
3347                0x19c420f173275398 => {
3348                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3349                    let mut req = fidl::new_empty!(InputMethodEditorClientOnActionRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
3350                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorClientOnActionRequest>(&header, _body_bytes, handles, &mut req)?;
3351                    let control_handle = InputMethodEditorClientControlHandle {
3352                        inner: this.inner.clone(),
3353                    };
3354                    Ok(InputMethodEditorClientRequest::OnAction {action: req.action,
3355
3356                        control_handle,
3357                    })
3358                }
3359                _ => Err(fidl::Error::UnknownOrdinal {
3360                    ordinal: header.ordinal,
3361                    protocol_name: <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3362                }),
3363            }))
3364            },
3365        )
3366    }
3367}
3368
3369/// An interface to receive information from `TextInputService`.
3370#[derive(Debug)]
3371pub enum InputMethodEditorClientRequest {
3372    DidUpdateState {
3373        state: TextInputState,
3374        event: Option<Box<InputEvent>>,
3375        control_handle: InputMethodEditorClientControlHandle,
3376    },
3377    OnAction {
3378        action: InputMethodAction,
3379        control_handle: InputMethodEditorClientControlHandle,
3380    },
3381}
3382
3383impl InputMethodEditorClientRequest {
3384    #[allow(irrefutable_let_patterns)]
3385    pub fn into_did_update_state(
3386        self,
3387    ) -> Option<(TextInputState, Option<Box<InputEvent>>, InputMethodEditorClientControlHandle)>
3388    {
3389        if let InputMethodEditorClientRequest::DidUpdateState { state, event, control_handle } =
3390            self
3391        {
3392            Some((state, event, control_handle))
3393        } else {
3394            None
3395        }
3396    }
3397
3398    #[allow(irrefutable_let_patterns)]
3399    pub fn into_on_action(
3400        self,
3401    ) -> Option<(InputMethodAction, InputMethodEditorClientControlHandle)> {
3402        if let InputMethodEditorClientRequest::OnAction { action, control_handle } = self {
3403            Some((action, control_handle))
3404        } else {
3405            None
3406        }
3407    }
3408
3409    /// Name of the method defined in FIDL
3410    pub fn method_name(&self) -> &'static str {
3411        match *self {
3412            InputMethodEditorClientRequest::DidUpdateState { .. } => "did_update_state",
3413            InputMethodEditorClientRequest::OnAction { .. } => "on_action",
3414        }
3415    }
3416}
3417
3418#[derive(Debug, Clone)]
3419pub struct InputMethodEditorClientControlHandle {
3420    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3421}
3422
3423impl InputMethodEditorClientControlHandle {
3424    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3425        self.inner.shutdown_with_epitaph(status.into())
3426    }
3427}
3428
3429impl fidl::endpoints::ControlHandle for InputMethodEditorClientControlHandle {
3430    fn shutdown(&self) {
3431        self.inner.shutdown()
3432    }
3433
3434    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3435        self.inner.shutdown_with_epitaph(status)
3436    }
3437
3438    fn is_closed(&self) -> bool {
3439        self.inner.channel().is_closed()
3440    }
3441    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3442        self.inner.channel().on_closed()
3443    }
3444
3445    #[cfg(target_os = "fuchsia")]
3446    fn signal_peer(
3447        &self,
3448        clear_mask: zx::Signals,
3449        set_mask: zx::Signals,
3450    ) -> Result<(), zx_status::Status> {
3451        use fidl::Peered;
3452        self.inner.channel().signal_peer(clear_mask, set_mask)
3453    }
3454}
3455
3456impl InputMethodEditorClientControlHandle {}
3457
3458mod internal {
3459    use super::*;
3460
3461    impl fidl::encoding::ResourceTypeMarker for DeviceListenerRegistryRegisterListenerRequest {
3462        type Borrowed<'a> = &'a mut Self;
3463        fn take_or_borrow<'a>(
3464            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3465        ) -> Self::Borrowed<'a> {
3466            value
3467        }
3468    }
3469
3470    unsafe impl fidl::encoding::TypeMarker for DeviceListenerRegistryRegisterListenerRequest {
3471        type Owned = Self;
3472
3473        #[inline(always)]
3474        fn inline_align(_context: fidl::encoding::Context) -> usize {
3475            4
3476        }
3477
3478        #[inline(always)]
3479        fn inline_size(_context: fidl::encoding::Context) -> usize {
3480            4
3481        }
3482    }
3483
3484    unsafe impl
3485        fidl::encoding::Encode<
3486            DeviceListenerRegistryRegisterListenerRequest,
3487            fidl::encoding::DefaultFuchsiaResourceDialect,
3488        > for &mut DeviceListenerRegistryRegisterListenerRequest
3489    {
3490        #[inline]
3491        unsafe fn encode(
3492            self,
3493            encoder: &mut fidl::encoding::Encoder<
3494                '_,
3495                fidl::encoding::DefaultFuchsiaResourceDialect,
3496            >,
3497            offset: usize,
3498            _depth: fidl::encoding::Depth,
3499        ) -> fidl::Result<()> {
3500            encoder.debug_check_bounds::<DeviceListenerRegistryRegisterListenerRequest>(offset);
3501            // Delegate to tuple encoding.
3502            fidl::encoding::Encode::<DeviceListenerRegistryRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3503                (
3504                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DeviceListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listener),
3505                ),
3506                encoder, offset, _depth
3507            )
3508        }
3509    }
3510    unsafe impl<
3511        T0: fidl::encoding::Encode<
3512                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DeviceListenerMarker>>,
3513                fidl::encoding::DefaultFuchsiaResourceDialect,
3514            >,
3515    >
3516        fidl::encoding::Encode<
3517            DeviceListenerRegistryRegisterListenerRequest,
3518            fidl::encoding::DefaultFuchsiaResourceDialect,
3519        > for (T0,)
3520    {
3521        #[inline]
3522        unsafe fn encode(
3523            self,
3524            encoder: &mut fidl::encoding::Encoder<
3525                '_,
3526                fidl::encoding::DefaultFuchsiaResourceDialect,
3527            >,
3528            offset: usize,
3529            depth: fidl::encoding::Depth,
3530        ) -> fidl::Result<()> {
3531            encoder.debug_check_bounds::<DeviceListenerRegistryRegisterListenerRequest>(offset);
3532            // Zero out padding regions. There's no need to apply masks
3533            // because the unmasked parts will be overwritten by fields.
3534            // Write the fields.
3535            self.0.encode(encoder, offset + 0, depth)?;
3536            Ok(())
3537        }
3538    }
3539
3540    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3541        for DeviceListenerRegistryRegisterListenerRequest
3542    {
3543        #[inline(always)]
3544        fn new_empty() -> Self {
3545            Self {
3546                listener: fidl::new_empty!(
3547                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DeviceListenerMarker>>,
3548                    fidl::encoding::DefaultFuchsiaResourceDialect
3549                ),
3550            }
3551        }
3552
3553        #[inline]
3554        unsafe fn decode(
3555            &mut self,
3556            decoder: &mut fidl::encoding::Decoder<
3557                '_,
3558                fidl::encoding::DefaultFuchsiaResourceDialect,
3559            >,
3560            offset: usize,
3561            _depth: fidl::encoding::Depth,
3562        ) -> fidl::Result<()> {
3563            decoder.debug_check_bounds::<Self>(offset);
3564            // Verify that padding bytes are zero.
3565            fidl::decode!(
3566                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DeviceListenerMarker>>,
3567                fidl::encoding::DefaultFuchsiaResourceDialect,
3568                &mut self.listener,
3569                decoder,
3570                offset + 0,
3571                _depth
3572            )?;
3573            Ok(())
3574        }
3575    }
3576
3577    impl fidl::encoding::ResourceTypeMarker for DeviceListenerRegistryRegisterListenerResponse {
3578        type Borrowed<'a> = &'a mut Self;
3579        fn take_or_borrow<'a>(
3580            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3581        ) -> Self::Borrowed<'a> {
3582            value
3583        }
3584    }
3585
3586    unsafe impl fidl::encoding::TypeMarker for DeviceListenerRegistryRegisterListenerResponse {
3587        type Owned = Self;
3588
3589        #[inline(always)]
3590        fn inline_align(_context: fidl::encoding::Context) -> usize {
3591            4
3592        }
3593
3594        #[inline(always)]
3595        fn inline_size(_context: fidl::encoding::Context) -> usize {
3596            4
3597        }
3598    }
3599
3600    unsafe impl
3601        fidl::encoding::Encode<
3602            DeviceListenerRegistryRegisterListenerResponse,
3603            fidl::encoding::DefaultFuchsiaResourceDialect,
3604        > for &mut DeviceListenerRegistryRegisterListenerResponse
3605    {
3606        #[inline]
3607        unsafe fn encode(
3608            self,
3609            encoder: &mut fidl::encoding::Encoder<
3610                '_,
3611                fidl::encoding::DefaultFuchsiaResourceDialect,
3612            >,
3613            offset: usize,
3614            _depth: fidl::encoding::Depth,
3615        ) -> fidl::Result<()> {
3616            encoder.debug_check_bounds::<DeviceListenerRegistryRegisterListenerResponse>(offset);
3617            // Delegate to tuple encoding.
3618            fidl::encoding::Encode::<DeviceListenerRegistryRegisterListenerResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3619                (
3620                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DeviceIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
3621                ),
3622                encoder, offset, _depth
3623            )
3624        }
3625    }
3626    unsafe impl<
3627        T0: fidl::encoding::Encode<
3628                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DeviceIteratorMarker>>,
3629                fidl::encoding::DefaultFuchsiaResourceDialect,
3630            >,
3631    >
3632        fidl::encoding::Encode<
3633            DeviceListenerRegistryRegisterListenerResponse,
3634            fidl::encoding::DefaultFuchsiaResourceDialect,
3635        > for (T0,)
3636    {
3637        #[inline]
3638        unsafe fn encode(
3639            self,
3640            encoder: &mut fidl::encoding::Encoder<
3641                '_,
3642                fidl::encoding::DefaultFuchsiaResourceDialect,
3643            >,
3644            offset: usize,
3645            depth: fidl::encoding::Depth,
3646        ) -> fidl::Result<()> {
3647            encoder.debug_check_bounds::<DeviceListenerRegistryRegisterListenerResponse>(offset);
3648            // Zero out padding regions. There's no need to apply masks
3649            // because the unmasked parts will be overwritten by fields.
3650            // Write the fields.
3651            self.0.encode(encoder, offset + 0, depth)?;
3652            Ok(())
3653        }
3654    }
3655
3656    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3657        for DeviceListenerRegistryRegisterListenerResponse
3658    {
3659        #[inline(always)]
3660        fn new_empty() -> Self {
3661            Self {
3662                iterator: fidl::new_empty!(
3663                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DeviceIteratorMarker>>,
3664                    fidl::encoding::DefaultFuchsiaResourceDialect
3665                ),
3666            }
3667        }
3668
3669        #[inline]
3670        unsafe fn decode(
3671            &mut self,
3672            decoder: &mut fidl::encoding::Decoder<
3673                '_,
3674                fidl::encoding::DefaultFuchsiaResourceDialect,
3675            >,
3676            offset: usize,
3677            _depth: fidl::encoding::Depth,
3678        ) -> fidl::Result<()> {
3679            decoder.debug_check_bounds::<Self>(offset);
3680            // Verify that padding bytes are zero.
3681            fidl::decode!(
3682                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DeviceIteratorMarker>>,
3683                fidl::encoding::DefaultFuchsiaResourceDialect,
3684                &mut self.iterator,
3685                decoder,
3686                offset + 0,
3687                _depth
3688            )?;
3689            Ok(())
3690        }
3691    }
3692
3693    impl fidl::encoding::ResourceTypeMarker for ImeServiceGetInputMethodEditorRequest {
3694        type Borrowed<'a> = &'a mut Self;
3695        fn take_or_borrow<'a>(
3696            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3697        ) -> Self::Borrowed<'a> {
3698            value
3699        }
3700    }
3701
3702    unsafe impl fidl::encoding::TypeMarker for ImeServiceGetInputMethodEditorRequest {
3703        type Owned = Self;
3704
3705        #[inline(always)]
3706        fn inline_align(_context: fidl::encoding::Context) -> usize {
3707            8
3708        }
3709
3710        #[inline(always)]
3711        fn inline_size(_context: fidl::encoding::Context) -> usize {
3712            80
3713        }
3714    }
3715
3716    unsafe impl
3717        fidl::encoding::Encode<
3718            ImeServiceGetInputMethodEditorRequest,
3719            fidl::encoding::DefaultFuchsiaResourceDialect,
3720        > for &mut ImeServiceGetInputMethodEditorRequest
3721    {
3722        #[inline]
3723        unsafe fn encode(
3724            self,
3725            encoder: &mut fidl::encoding::Encoder<
3726                '_,
3727                fidl::encoding::DefaultFuchsiaResourceDialect,
3728            >,
3729            offset: usize,
3730            _depth: fidl::encoding::Depth,
3731        ) -> fidl::Result<()> {
3732            encoder.debug_check_bounds::<ImeServiceGetInputMethodEditorRequest>(offset);
3733            // Delegate to tuple encoding.
3734            fidl::encoding::Encode::<ImeServiceGetInputMethodEditorRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3735                (
3736                    <KeyboardType as fidl::encoding::ValueTypeMarker>::borrow(&self.keyboard_type),
3737                    <InputMethodAction as fidl::encoding::ValueTypeMarker>::borrow(&self.action),
3738                    <TextInputState as fidl::encoding::ValueTypeMarker>::borrow(&self.initial_state),
3739                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.client),
3740                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.editor),
3741                ),
3742                encoder, offset, _depth
3743            )
3744        }
3745    }
3746    unsafe impl<
3747        T0: fidl::encoding::Encode<KeyboardType, fidl::encoding::DefaultFuchsiaResourceDialect>,
3748        T1: fidl::encoding::Encode<InputMethodAction, fidl::encoding::DefaultFuchsiaResourceDialect>,
3749        T2: fidl::encoding::Encode<TextInputState, fidl::encoding::DefaultFuchsiaResourceDialect>,
3750        T3: fidl::encoding::Encode<
3751                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>>,
3752                fidl::encoding::DefaultFuchsiaResourceDialect,
3753            >,
3754        T4: fidl::encoding::Encode<
3755                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
3756                fidl::encoding::DefaultFuchsiaResourceDialect,
3757            >,
3758    >
3759        fidl::encoding::Encode<
3760            ImeServiceGetInputMethodEditorRequest,
3761            fidl::encoding::DefaultFuchsiaResourceDialect,
3762        > for (T0, T1, T2, T3, T4)
3763    {
3764        #[inline]
3765        unsafe fn encode(
3766            self,
3767            encoder: &mut fidl::encoding::Encoder<
3768                '_,
3769                fidl::encoding::DefaultFuchsiaResourceDialect,
3770            >,
3771            offset: usize,
3772            depth: fidl::encoding::Depth,
3773        ) -> fidl::Result<()> {
3774            encoder.debug_check_bounds::<ImeServiceGetInputMethodEditorRequest>(offset);
3775            // Zero out padding regions. There's no need to apply masks
3776            // because the unmasked parts will be overwritten by fields.
3777            // Write the fields.
3778            self.0.encode(encoder, offset + 0, depth)?;
3779            self.1.encode(encoder, offset + 4, depth)?;
3780            self.2.encode(encoder, offset + 8, depth)?;
3781            self.3.encode(encoder, offset + 72, depth)?;
3782            self.4.encode(encoder, offset + 76, depth)?;
3783            Ok(())
3784        }
3785    }
3786
3787    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3788        for ImeServiceGetInputMethodEditorRequest
3789    {
3790        #[inline(always)]
3791        fn new_empty() -> Self {
3792            Self {
3793                keyboard_type: fidl::new_empty!(
3794                    KeyboardType,
3795                    fidl::encoding::DefaultFuchsiaResourceDialect
3796                ),
3797                action: fidl::new_empty!(
3798                    InputMethodAction,
3799                    fidl::encoding::DefaultFuchsiaResourceDialect
3800                ),
3801                initial_state: fidl::new_empty!(
3802                    TextInputState,
3803                    fidl::encoding::DefaultFuchsiaResourceDialect
3804                ),
3805                client: fidl::new_empty!(
3806                    fidl::encoding::Endpoint<
3807                        fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
3808                    >,
3809                    fidl::encoding::DefaultFuchsiaResourceDialect
3810                ),
3811                editor: fidl::new_empty!(
3812                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
3813                    fidl::encoding::DefaultFuchsiaResourceDialect
3814                ),
3815            }
3816        }
3817
3818        #[inline]
3819        unsafe fn decode(
3820            &mut self,
3821            decoder: &mut fidl::encoding::Decoder<
3822                '_,
3823                fidl::encoding::DefaultFuchsiaResourceDialect,
3824            >,
3825            offset: usize,
3826            _depth: fidl::encoding::Depth,
3827        ) -> fidl::Result<()> {
3828            decoder.debug_check_bounds::<Self>(offset);
3829            // Verify that padding bytes are zero.
3830            fidl::decode!(
3831                KeyboardType,
3832                fidl::encoding::DefaultFuchsiaResourceDialect,
3833                &mut self.keyboard_type,
3834                decoder,
3835                offset + 0,
3836                _depth
3837            )?;
3838            fidl::decode!(
3839                InputMethodAction,
3840                fidl::encoding::DefaultFuchsiaResourceDialect,
3841                &mut self.action,
3842                decoder,
3843                offset + 4,
3844                _depth
3845            )?;
3846            fidl::decode!(
3847                TextInputState,
3848                fidl::encoding::DefaultFuchsiaResourceDialect,
3849                &mut self.initial_state,
3850                decoder,
3851                offset + 8,
3852                _depth
3853            )?;
3854            fidl::decode!(
3855                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>>,
3856                fidl::encoding::DefaultFuchsiaResourceDialect,
3857                &mut self.client,
3858                decoder,
3859                offset + 72,
3860                _depth
3861            )?;
3862            fidl::decode!(
3863                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
3864                fidl::encoding::DefaultFuchsiaResourceDialect,
3865                &mut self.editor,
3866                decoder,
3867                offset + 76,
3868                _depth
3869            )?;
3870            Ok(())
3871        }
3872    }
3873
3874    impl MediaButtonsEvent {
3875        #[inline(always)]
3876        fn max_ordinal_present(&self) -> u64 {
3877            if let Some(_) = self.trace_flow_id {
3878                return 9;
3879            }
3880            if let Some(_) = self.wake_lease {
3881                return 8;
3882            }
3883            if let Some(_) = self.device_id {
3884                return 7;
3885            }
3886            if let Some(_) = self.function {
3887                return 6;
3888            }
3889            if let Some(_) = self.power {
3890                return 5;
3891            }
3892            if let Some(_) = self.camera_disable {
3893                return 4;
3894            }
3895            if let Some(_) = self.pause {
3896                return 3;
3897            }
3898            if let Some(_) = self.mic_mute {
3899                return 2;
3900            }
3901            if let Some(_) = self.volume {
3902                return 1;
3903            }
3904            0
3905        }
3906    }
3907
3908    impl fidl::encoding::ResourceTypeMarker for MediaButtonsEvent {
3909        type Borrowed<'a> = &'a mut Self;
3910        fn take_or_borrow<'a>(
3911            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3912        ) -> Self::Borrowed<'a> {
3913            value
3914        }
3915    }
3916
3917    unsafe impl fidl::encoding::TypeMarker for MediaButtonsEvent {
3918        type Owned = Self;
3919
3920        #[inline(always)]
3921        fn inline_align(_context: fidl::encoding::Context) -> usize {
3922            8
3923        }
3924
3925        #[inline(always)]
3926        fn inline_size(_context: fidl::encoding::Context) -> usize {
3927            16
3928        }
3929    }
3930
3931    unsafe impl
3932        fidl::encoding::Encode<MediaButtonsEvent, fidl::encoding::DefaultFuchsiaResourceDialect>
3933        for &mut MediaButtonsEvent
3934    {
3935        unsafe fn encode(
3936            self,
3937            encoder: &mut fidl::encoding::Encoder<
3938                '_,
3939                fidl::encoding::DefaultFuchsiaResourceDialect,
3940            >,
3941            offset: usize,
3942            mut depth: fidl::encoding::Depth,
3943        ) -> fidl::Result<()> {
3944            encoder.debug_check_bounds::<MediaButtonsEvent>(offset);
3945            // Vector header
3946            let max_ordinal: u64 = self.max_ordinal_present();
3947            encoder.write_num(max_ordinal, offset);
3948            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3949            // Calling encoder.out_of_line_offset(0) is not allowed.
3950            if max_ordinal == 0 {
3951                return Ok(());
3952            }
3953            depth.increment()?;
3954            let envelope_size = 8;
3955            let bytes_len = max_ordinal as usize * envelope_size;
3956            #[allow(unused_variables)]
3957            let offset = encoder.out_of_line_offset(bytes_len);
3958            let mut _prev_end_offset: usize = 0;
3959            if 1 > max_ordinal {
3960                return Ok(());
3961            }
3962
3963            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3964            // are envelope_size bytes.
3965            let cur_offset: usize = (1 - 1) * envelope_size;
3966
3967            // Zero reserved fields.
3968            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3969
3970            // Safety:
3971            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3972            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3973            //   envelope_size bytes, there is always sufficient room.
3974            fidl::encoding::encode_in_envelope_optional::<
3975                i8,
3976                fidl::encoding::DefaultFuchsiaResourceDialect,
3977            >(
3978                self.volume.as_ref().map(<i8 as fidl::encoding::ValueTypeMarker>::borrow),
3979                encoder,
3980                offset + cur_offset,
3981                depth,
3982            )?;
3983
3984            _prev_end_offset = cur_offset + envelope_size;
3985            if 2 > max_ordinal {
3986                return Ok(());
3987            }
3988
3989            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3990            // are envelope_size bytes.
3991            let cur_offset: usize = (2 - 1) * envelope_size;
3992
3993            // Zero reserved fields.
3994            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3995
3996            // Safety:
3997            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3998            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3999            //   envelope_size bytes, there is always sufficient room.
4000            fidl::encoding::encode_in_envelope_optional::<
4001                bool,
4002                fidl::encoding::DefaultFuchsiaResourceDialect,
4003            >(
4004                self.mic_mute.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4005                encoder,
4006                offset + cur_offset,
4007                depth,
4008            )?;
4009
4010            _prev_end_offset = cur_offset + envelope_size;
4011            if 3 > max_ordinal {
4012                return Ok(());
4013            }
4014
4015            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4016            // are envelope_size bytes.
4017            let cur_offset: usize = (3 - 1) * envelope_size;
4018
4019            // Zero reserved fields.
4020            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4021
4022            // Safety:
4023            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4024            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4025            //   envelope_size bytes, there is always sufficient room.
4026            fidl::encoding::encode_in_envelope_optional::<
4027                bool,
4028                fidl::encoding::DefaultFuchsiaResourceDialect,
4029            >(
4030                self.pause.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4031                encoder,
4032                offset + cur_offset,
4033                depth,
4034            )?;
4035
4036            _prev_end_offset = cur_offset + envelope_size;
4037            if 4 > max_ordinal {
4038                return Ok(());
4039            }
4040
4041            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4042            // are envelope_size bytes.
4043            let cur_offset: usize = (4 - 1) * envelope_size;
4044
4045            // Zero reserved fields.
4046            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4047
4048            // Safety:
4049            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4050            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4051            //   envelope_size bytes, there is always sufficient room.
4052            fidl::encoding::encode_in_envelope_optional::<
4053                bool,
4054                fidl::encoding::DefaultFuchsiaResourceDialect,
4055            >(
4056                self.camera_disable.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4057                encoder,
4058                offset + cur_offset,
4059                depth,
4060            )?;
4061
4062            _prev_end_offset = cur_offset + envelope_size;
4063            if 5 > max_ordinal {
4064                return Ok(());
4065            }
4066
4067            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4068            // are envelope_size bytes.
4069            let cur_offset: usize = (5 - 1) * envelope_size;
4070
4071            // Zero reserved fields.
4072            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4073
4074            // Safety:
4075            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4076            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4077            //   envelope_size bytes, there is always sufficient room.
4078            fidl::encoding::encode_in_envelope_optional::<
4079                bool,
4080                fidl::encoding::DefaultFuchsiaResourceDialect,
4081            >(
4082                self.power.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4083                encoder,
4084                offset + cur_offset,
4085                depth,
4086            )?;
4087
4088            _prev_end_offset = cur_offset + envelope_size;
4089            if 6 > max_ordinal {
4090                return Ok(());
4091            }
4092
4093            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4094            // are envelope_size bytes.
4095            let cur_offset: usize = (6 - 1) * envelope_size;
4096
4097            // Zero reserved fields.
4098            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4099
4100            // Safety:
4101            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4102            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4103            //   envelope_size bytes, there is always sufficient room.
4104            fidl::encoding::encode_in_envelope_optional::<
4105                bool,
4106                fidl::encoding::DefaultFuchsiaResourceDialect,
4107            >(
4108                self.function.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4109                encoder,
4110                offset + cur_offset,
4111                depth,
4112            )?;
4113
4114            _prev_end_offset = cur_offset + envelope_size;
4115            if 7 > max_ordinal {
4116                return Ok(());
4117            }
4118
4119            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4120            // are envelope_size bytes.
4121            let cur_offset: usize = (7 - 1) * envelope_size;
4122
4123            // Zero reserved fields.
4124            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4125
4126            // Safety:
4127            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4128            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4129            //   envelope_size bytes, there is always sufficient room.
4130            fidl::encoding::encode_in_envelope_optional::<
4131                u32,
4132                fidl::encoding::DefaultFuchsiaResourceDialect,
4133            >(
4134                self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
4135                encoder,
4136                offset + cur_offset,
4137                depth,
4138            )?;
4139
4140            _prev_end_offset = cur_offset + envelope_size;
4141            if 8 > max_ordinal {
4142                return Ok(());
4143            }
4144
4145            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4146            // are envelope_size bytes.
4147            let cur_offset: usize = (8 - 1) * envelope_size;
4148
4149            // Zero reserved fields.
4150            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4151
4152            // Safety:
4153            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4154            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4155            //   envelope_size bytes, there is always sufficient room.
4156            fidl::encoding::encode_in_envelope_optional::<
4157                fidl::encoding::HandleType<
4158                    fidl::EventPair,
4159                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4160                    2147483648,
4161                >,
4162                fidl::encoding::DefaultFuchsiaResourceDialect,
4163            >(
4164                self.wake_lease.as_mut().map(
4165                    <fidl::encoding::HandleType<
4166                        fidl::EventPair,
4167                        { fidl::ObjectType::EVENTPAIR.into_raw() },
4168                        2147483648,
4169                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4170                ),
4171                encoder,
4172                offset + cur_offset,
4173                depth,
4174            )?;
4175
4176            _prev_end_offset = cur_offset + envelope_size;
4177            if 9 > max_ordinal {
4178                return Ok(());
4179            }
4180
4181            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4182            // are envelope_size bytes.
4183            let cur_offset: usize = (9 - 1) * envelope_size;
4184
4185            // Zero reserved fields.
4186            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4187
4188            // Safety:
4189            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4190            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4191            //   envelope_size bytes, there is always sufficient room.
4192            fidl::encoding::encode_in_envelope_optional::<
4193                u64,
4194                fidl::encoding::DefaultFuchsiaResourceDialect,
4195            >(
4196                self.trace_flow_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4197                encoder,
4198                offset + cur_offset,
4199                depth,
4200            )?;
4201
4202            _prev_end_offset = cur_offset + envelope_size;
4203
4204            Ok(())
4205        }
4206    }
4207
4208    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4209        for MediaButtonsEvent
4210    {
4211        #[inline(always)]
4212        fn new_empty() -> Self {
4213            Self::default()
4214        }
4215
4216        unsafe fn decode(
4217            &mut self,
4218            decoder: &mut fidl::encoding::Decoder<
4219                '_,
4220                fidl::encoding::DefaultFuchsiaResourceDialect,
4221            >,
4222            offset: usize,
4223            mut depth: fidl::encoding::Depth,
4224        ) -> fidl::Result<()> {
4225            decoder.debug_check_bounds::<Self>(offset);
4226            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4227                None => return Err(fidl::Error::NotNullable),
4228                Some(len) => len,
4229            };
4230            // Calling decoder.out_of_line_offset(0) is not allowed.
4231            if len == 0 {
4232                return Ok(());
4233            };
4234            depth.increment()?;
4235            let envelope_size = 8;
4236            let bytes_len = len * envelope_size;
4237            let offset = decoder.out_of_line_offset(bytes_len)?;
4238            // Decode the envelope for each type.
4239            let mut _next_ordinal_to_read = 0;
4240            let mut next_offset = offset;
4241            let end_offset = offset + bytes_len;
4242            _next_ordinal_to_read += 1;
4243            if next_offset >= end_offset {
4244                return Ok(());
4245            }
4246
4247            // Decode unknown envelopes for gaps in ordinals.
4248            while _next_ordinal_to_read < 1 {
4249                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4250                _next_ordinal_to_read += 1;
4251                next_offset += envelope_size;
4252            }
4253
4254            let next_out_of_line = decoder.next_out_of_line();
4255            let handles_before = decoder.remaining_handles();
4256            if let Some((inlined, num_bytes, num_handles)) =
4257                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4258            {
4259                let member_inline_size =
4260                    <i8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4261                if inlined != (member_inline_size <= 4) {
4262                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4263                }
4264                let inner_offset;
4265                let mut inner_depth = depth.clone();
4266                if inlined {
4267                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4268                    inner_offset = next_offset;
4269                } else {
4270                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4271                    inner_depth.increment()?;
4272                }
4273                let val_ref = self.volume.get_or_insert_with(|| {
4274                    fidl::new_empty!(i8, fidl::encoding::DefaultFuchsiaResourceDialect)
4275                });
4276                fidl::decode!(
4277                    i8,
4278                    fidl::encoding::DefaultFuchsiaResourceDialect,
4279                    val_ref,
4280                    decoder,
4281                    inner_offset,
4282                    inner_depth
4283                )?;
4284                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4285                {
4286                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4287                }
4288                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4289                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4290                }
4291            }
4292
4293            next_offset += envelope_size;
4294            _next_ordinal_to_read += 1;
4295            if next_offset >= end_offset {
4296                return Ok(());
4297            }
4298
4299            // Decode unknown envelopes for gaps in ordinals.
4300            while _next_ordinal_to_read < 2 {
4301                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4302                _next_ordinal_to_read += 1;
4303                next_offset += envelope_size;
4304            }
4305
4306            let next_out_of_line = decoder.next_out_of_line();
4307            let handles_before = decoder.remaining_handles();
4308            if let Some((inlined, num_bytes, num_handles)) =
4309                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4310            {
4311                let member_inline_size =
4312                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4313                if inlined != (member_inline_size <= 4) {
4314                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4315                }
4316                let inner_offset;
4317                let mut inner_depth = depth.clone();
4318                if inlined {
4319                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4320                    inner_offset = next_offset;
4321                } else {
4322                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4323                    inner_depth.increment()?;
4324                }
4325                let val_ref = self.mic_mute.get_or_insert_with(|| {
4326                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4327                });
4328                fidl::decode!(
4329                    bool,
4330                    fidl::encoding::DefaultFuchsiaResourceDialect,
4331                    val_ref,
4332                    decoder,
4333                    inner_offset,
4334                    inner_depth
4335                )?;
4336                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4337                {
4338                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4339                }
4340                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4341                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4342                }
4343            }
4344
4345            next_offset += envelope_size;
4346            _next_ordinal_to_read += 1;
4347            if next_offset >= end_offset {
4348                return Ok(());
4349            }
4350
4351            // Decode unknown envelopes for gaps in ordinals.
4352            while _next_ordinal_to_read < 3 {
4353                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4354                _next_ordinal_to_read += 1;
4355                next_offset += envelope_size;
4356            }
4357
4358            let next_out_of_line = decoder.next_out_of_line();
4359            let handles_before = decoder.remaining_handles();
4360            if let Some((inlined, num_bytes, num_handles)) =
4361                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4362            {
4363                let member_inline_size =
4364                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4365                if inlined != (member_inline_size <= 4) {
4366                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4367                }
4368                let inner_offset;
4369                let mut inner_depth = depth.clone();
4370                if inlined {
4371                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4372                    inner_offset = next_offset;
4373                } else {
4374                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4375                    inner_depth.increment()?;
4376                }
4377                let val_ref = self.pause.get_or_insert_with(|| {
4378                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4379                });
4380                fidl::decode!(
4381                    bool,
4382                    fidl::encoding::DefaultFuchsiaResourceDialect,
4383                    val_ref,
4384                    decoder,
4385                    inner_offset,
4386                    inner_depth
4387                )?;
4388                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4389                {
4390                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4391                }
4392                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4393                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4394                }
4395            }
4396
4397            next_offset += envelope_size;
4398            _next_ordinal_to_read += 1;
4399            if next_offset >= end_offset {
4400                return Ok(());
4401            }
4402
4403            // Decode unknown envelopes for gaps in ordinals.
4404            while _next_ordinal_to_read < 4 {
4405                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4406                _next_ordinal_to_read += 1;
4407                next_offset += envelope_size;
4408            }
4409
4410            let next_out_of_line = decoder.next_out_of_line();
4411            let handles_before = decoder.remaining_handles();
4412            if let Some((inlined, num_bytes, num_handles)) =
4413                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4414            {
4415                let member_inline_size =
4416                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4417                if inlined != (member_inline_size <= 4) {
4418                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4419                }
4420                let inner_offset;
4421                let mut inner_depth = depth.clone();
4422                if inlined {
4423                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4424                    inner_offset = next_offset;
4425                } else {
4426                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4427                    inner_depth.increment()?;
4428                }
4429                let val_ref = self.camera_disable.get_or_insert_with(|| {
4430                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4431                });
4432                fidl::decode!(
4433                    bool,
4434                    fidl::encoding::DefaultFuchsiaResourceDialect,
4435                    val_ref,
4436                    decoder,
4437                    inner_offset,
4438                    inner_depth
4439                )?;
4440                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4441                {
4442                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4443                }
4444                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4445                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4446                }
4447            }
4448
4449            next_offset += envelope_size;
4450            _next_ordinal_to_read += 1;
4451            if next_offset >= end_offset {
4452                return Ok(());
4453            }
4454
4455            // Decode unknown envelopes for gaps in ordinals.
4456            while _next_ordinal_to_read < 5 {
4457                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4458                _next_ordinal_to_read += 1;
4459                next_offset += envelope_size;
4460            }
4461
4462            let next_out_of_line = decoder.next_out_of_line();
4463            let handles_before = decoder.remaining_handles();
4464            if let Some((inlined, num_bytes, num_handles)) =
4465                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4466            {
4467                let member_inline_size =
4468                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4469                if inlined != (member_inline_size <= 4) {
4470                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4471                }
4472                let inner_offset;
4473                let mut inner_depth = depth.clone();
4474                if inlined {
4475                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4476                    inner_offset = next_offset;
4477                } else {
4478                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4479                    inner_depth.increment()?;
4480                }
4481                let val_ref = self.power.get_or_insert_with(|| {
4482                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4483                });
4484                fidl::decode!(
4485                    bool,
4486                    fidl::encoding::DefaultFuchsiaResourceDialect,
4487                    val_ref,
4488                    decoder,
4489                    inner_offset,
4490                    inner_depth
4491                )?;
4492                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4493                {
4494                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4495                }
4496                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4497                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4498                }
4499            }
4500
4501            next_offset += envelope_size;
4502            _next_ordinal_to_read += 1;
4503            if next_offset >= end_offset {
4504                return Ok(());
4505            }
4506
4507            // Decode unknown envelopes for gaps in ordinals.
4508            while _next_ordinal_to_read < 6 {
4509                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4510                _next_ordinal_to_read += 1;
4511                next_offset += envelope_size;
4512            }
4513
4514            let next_out_of_line = decoder.next_out_of_line();
4515            let handles_before = decoder.remaining_handles();
4516            if let Some((inlined, num_bytes, num_handles)) =
4517                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4518            {
4519                let member_inline_size =
4520                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4521                if inlined != (member_inline_size <= 4) {
4522                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4523                }
4524                let inner_offset;
4525                let mut inner_depth = depth.clone();
4526                if inlined {
4527                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4528                    inner_offset = next_offset;
4529                } else {
4530                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4531                    inner_depth.increment()?;
4532                }
4533                let val_ref = self.function.get_or_insert_with(|| {
4534                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4535                });
4536                fidl::decode!(
4537                    bool,
4538                    fidl::encoding::DefaultFuchsiaResourceDialect,
4539                    val_ref,
4540                    decoder,
4541                    inner_offset,
4542                    inner_depth
4543                )?;
4544                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4545                {
4546                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4547                }
4548                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4549                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4550                }
4551            }
4552
4553            next_offset += envelope_size;
4554            _next_ordinal_to_read += 1;
4555            if next_offset >= end_offset {
4556                return Ok(());
4557            }
4558
4559            // Decode unknown envelopes for gaps in ordinals.
4560            while _next_ordinal_to_read < 7 {
4561                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4562                _next_ordinal_to_read += 1;
4563                next_offset += envelope_size;
4564            }
4565
4566            let next_out_of_line = decoder.next_out_of_line();
4567            let handles_before = decoder.remaining_handles();
4568            if let Some((inlined, num_bytes, num_handles)) =
4569                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4570            {
4571                let member_inline_size =
4572                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4573                if inlined != (member_inline_size <= 4) {
4574                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4575                }
4576                let inner_offset;
4577                let mut inner_depth = depth.clone();
4578                if inlined {
4579                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4580                    inner_offset = next_offset;
4581                } else {
4582                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4583                    inner_depth.increment()?;
4584                }
4585                let val_ref = self.device_id.get_or_insert_with(|| {
4586                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
4587                });
4588                fidl::decode!(
4589                    u32,
4590                    fidl::encoding::DefaultFuchsiaResourceDialect,
4591                    val_ref,
4592                    decoder,
4593                    inner_offset,
4594                    inner_depth
4595                )?;
4596                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4597                {
4598                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4599                }
4600                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4601                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4602                }
4603            }
4604
4605            next_offset += envelope_size;
4606            _next_ordinal_to_read += 1;
4607            if next_offset >= end_offset {
4608                return Ok(());
4609            }
4610
4611            // Decode unknown envelopes for gaps in ordinals.
4612            while _next_ordinal_to_read < 8 {
4613                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4614                _next_ordinal_to_read += 1;
4615                next_offset += envelope_size;
4616            }
4617
4618            let next_out_of_line = decoder.next_out_of_line();
4619            let handles_before = decoder.remaining_handles();
4620            if let Some((inlined, num_bytes, num_handles)) =
4621                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4622            {
4623                let member_inline_size = <fidl::encoding::HandleType<
4624                    fidl::EventPair,
4625                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4626                    2147483648,
4627                > as fidl::encoding::TypeMarker>::inline_size(
4628                    decoder.context
4629                );
4630                if inlined != (member_inline_size <= 4) {
4631                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4632                }
4633                let inner_offset;
4634                let mut inner_depth = depth.clone();
4635                if inlined {
4636                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4637                    inner_offset = next_offset;
4638                } else {
4639                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4640                    inner_depth.increment()?;
4641                }
4642                let val_ref =
4643                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4644                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4645                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4646                {
4647                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4648                }
4649                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4650                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4651                }
4652            }
4653
4654            next_offset += envelope_size;
4655            _next_ordinal_to_read += 1;
4656            if next_offset >= end_offset {
4657                return Ok(());
4658            }
4659
4660            // Decode unknown envelopes for gaps in ordinals.
4661            while _next_ordinal_to_read < 9 {
4662                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4663                _next_ordinal_to_read += 1;
4664                next_offset += envelope_size;
4665            }
4666
4667            let next_out_of_line = decoder.next_out_of_line();
4668            let handles_before = decoder.remaining_handles();
4669            if let Some((inlined, num_bytes, num_handles)) =
4670                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4671            {
4672                let member_inline_size =
4673                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4674                if inlined != (member_inline_size <= 4) {
4675                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4676                }
4677                let inner_offset;
4678                let mut inner_depth = depth.clone();
4679                if inlined {
4680                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4681                    inner_offset = next_offset;
4682                } else {
4683                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4684                    inner_depth.increment()?;
4685                }
4686                let val_ref = self.trace_flow_id.get_or_insert_with(|| {
4687                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
4688                });
4689                fidl::decode!(
4690                    u64,
4691                    fidl::encoding::DefaultFuchsiaResourceDialect,
4692                    val_ref,
4693                    decoder,
4694                    inner_offset,
4695                    inner_depth
4696                )?;
4697                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4698                {
4699                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4700                }
4701                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4702                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4703                }
4704            }
4705
4706            next_offset += envelope_size;
4707
4708            // Decode the remaining unknown envelopes.
4709            while next_offset < end_offset {
4710                _next_ordinal_to_read += 1;
4711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4712                next_offset += envelope_size;
4713            }
4714
4715            Ok(())
4716        }
4717    }
4718
4719    impl TouchButtonsEvent {
4720        #[inline(always)]
4721        fn max_ordinal_present(&self) -> u64 {
4722            if let Some(_) = self.trace_flow_id {
4723                return 5;
4724            }
4725            if let Some(_) = self.wake_lease {
4726                return 4;
4727            }
4728            if let Some(_) = self.pressed_buttons {
4729                return 3;
4730            }
4731            if let Some(_) = self.device_info {
4732                return 2;
4733            }
4734            if let Some(_) = self.event_time {
4735                return 1;
4736            }
4737            0
4738        }
4739    }
4740
4741    impl fidl::encoding::ResourceTypeMarker for TouchButtonsEvent {
4742        type Borrowed<'a> = &'a mut Self;
4743        fn take_or_borrow<'a>(
4744            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4745        ) -> Self::Borrowed<'a> {
4746            value
4747        }
4748    }
4749
4750    unsafe impl fidl::encoding::TypeMarker for TouchButtonsEvent {
4751        type Owned = Self;
4752
4753        #[inline(always)]
4754        fn inline_align(_context: fidl::encoding::Context) -> usize {
4755            8
4756        }
4757
4758        #[inline(always)]
4759        fn inline_size(_context: fidl::encoding::Context) -> usize {
4760            16
4761        }
4762    }
4763
4764    unsafe impl
4765        fidl::encoding::Encode<TouchButtonsEvent, fidl::encoding::DefaultFuchsiaResourceDialect>
4766        for &mut TouchButtonsEvent
4767    {
4768        unsafe fn encode(
4769            self,
4770            encoder: &mut fidl::encoding::Encoder<
4771                '_,
4772                fidl::encoding::DefaultFuchsiaResourceDialect,
4773            >,
4774            offset: usize,
4775            mut depth: fidl::encoding::Depth,
4776        ) -> fidl::Result<()> {
4777            encoder.debug_check_bounds::<TouchButtonsEvent>(offset);
4778            // Vector header
4779            let max_ordinal: u64 = self.max_ordinal_present();
4780            encoder.write_num(max_ordinal, offset);
4781            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4782            // Calling encoder.out_of_line_offset(0) is not allowed.
4783            if max_ordinal == 0 {
4784                return Ok(());
4785            }
4786            depth.increment()?;
4787            let envelope_size = 8;
4788            let bytes_len = max_ordinal as usize * envelope_size;
4789            #[allow(unused_variables)]
4790            let offset = encoder.out_of_line_offset(bytes_len);
4791            let mut _prev_end_offset: usize = 0;
4792            if 1 > max_ordinal {
4793                return Ok(());
4794            }
4795
4796            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4797            // are envelope_size bytes.
4798            let cur_offset: usize = (1 - 1) * envelope_size;
4799
4800            // Zero reserved fields.
4801            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4802
4803            // Safety:
4804            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4805            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4806            //   envelope_size bytes, there is always sufficient room.
4807            fidl::encoding::encode_in_envelope_optional::<
4808                fidl::MonotonicInstant,
4809                fidl::encoding::DefaultFuchsiaResourceDialect,
4810            >(
4811                self.event_time
4812                    .as_ref()
4813                    .map(<fidl::MonotonicInstant as fidl::encoding::ValueTypeMarker>::borrow),
4814                encoder,
4815                offset + cur_offset,
4816                depth,
4817            )?;
4818
4819            _prev_end_offset = cur_offset + envelope_size;
4820            if 2 > max_ordinal {
4821                return Ok(());
4822            }
4823
4824            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4825            // are envelope_size bytes.
4826            let cur_offset: usize = (2 - 1) * envelope_size;
4827
4828            // Zero reserved fields.
4829            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4830
4831            // Safety:
4832            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4833            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4834            //   envelope_size bytes, there is always sufficient room.
4835            fidl::encoding::encode_in_envelope_optional::<
4836                TouchDeviceInfo,
4837                fidl::encoding::DefaultFuchsiaResourceDialect,
4838            >(
4839                self.device_info
4840                    .as_ref()
4841                    .map(<TouchDeviceInfo as fidl::encoding::ValueTypeMarker>::borrow),
4842                encoder,
4843                offset + cur_offset,
4844                depth,
4845            )?;
4846
4847            _prev_end_offset = cur_offset + envelope_size;
4848            if 3 > max_ordinal {
4849                return Ok(());
4850            }
4851
4852            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4853            // are envelope_size bytes.
4854            let cur_offset: usize = (3 - 1) * envelope_size;
4855
4856            // Zero reserved fields.
4857            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4858
4859            // Safety:
4860            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4861            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4862            //   envelope_size bytes, there is always sufficient room.
4863            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<TouchButton>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4864            self.pressed_buttons.as_ref().map(<fidl::encoding::UnboundedVector<TouchButton> as fidl::encoding::ValueTypeMarker>::borrow),
4865            encoder, offset + cur_offset, depth
4866        )?;
4867
4868            _prev_end_offset = cur_offset + envelope_size;
4869            if 4 > max_ordinal {
4870                return Ok(());
4871            }
4872
4873            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4874            // are envelope_size bytes.
4875            let cur_offset: usize = (4 - 1) * envelope_size;
4876
4877            // Zero reserved fields.
4878            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4879
4880            // Safety:
4881            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4882            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4883            //   envelope_size bytes, there is always sufficient room.
4884            fidl::encoding::encode_in_envelope_optional::<
4885                fidl::encoding::HandleType<
4886                    fidl::EventPair,
4887                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4888                    2147483648,
4889                >,
4890                fidl::encoding::DefaultFuchsiaResourceDialect,
4891            >(
4892                self.wake_lease.as_mut().map(
4893                    <fidl::encoding::HandleType<
4894                        fidl::EventPair,
4895                        { fidl::ObjectType::EVENTPAIR.into_raw() },
4896                        2147483648,
4897                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4898                ),
4899                encoder,
4900                offset + cur_offset,
4901                depth,
4902            )?;
4903
4904            _prev_end_offset = cur_offset + envelope_size;
4905            if 5 > max_ordinal {
4906                return Ok(());
4907            }
4908
4909            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4910            // are envelope_size bytes.
4911            let cur_offset: usize = (5 - 1) * envelope_size;
4912
4913            // Zero reserved fields.
4914            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4915
4916            // Safety:
4917            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4918            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4919            //   envelope_size bytes, there is always sufficient room.
4920            fidl::encoding::encode_in_envelope_optional::<
4921                u64,
4922                fidl::encoding::DefaultFuchsiaResourceDialect,
4923            >(
4924                self.trace_flow_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
4925                encoder,
4926                offset + cur_offset,
4927                depth,
4928            )?;
4929
4930            _prev_end_offset = cur_offset + envelope_size;
4931
4932            Ok(())
4933        }
4934    }
4935
4936    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4937        for TouchButtonsEvent
4938    {
4939        #[inline(always)]
4940        fn new_empty() -> Self {
4941            Self::default()
4942        }
4943
4944        unsafe fn decode(
4945            &mut self,
4946            decoder: &mut fidl::encoding::Decoder<
4947                '_,
4948                fidl::encoding::DefaultFuchsiaResourceDialect,
4949            >,
4950            offset: usize,
4951            mut depth: fidl::encoding::Depth,
4952        ) -> fidl::Result<()> {
4953            decoder.debug_check_bounds::<Self>(offset);
4954            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4955                None => return Err(fidl::Error::NotNullable),
4956                Some(len) => len,
4957            };
4958            // Calling decoder.out_of_line_offset(0) is not allowed.
4959            if len == 0 {
4960                return Ok(());
4961            };
4962            depth.increment()?;
4963            let envelope_size = 8;
4964            let bytes_len = len * envelope_size;
4965            let offset = decoder.out_of_line_offset(bytes_len)?;
4966            // Decode the envelope for each type.
4967            let mut _next_ordinal_to_read = 0;
4968            let mut next_offset = offset;
4969            let end_offset = offset + bytes_len;
4970            _next_ordinal_to_read += 1;
4971            if next_offset >= end_offset {
4972                return Ok(());
4973            }
4974
4975            // Decode unknown envelopes for gaps in ordinals.
4976            while _next_ordinal_to_read < 1 {
4977                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4978                _next_ordinal_to_read += 1;
4979                next_offset += envelope_size;
4980            }
4981
4982            let next_out_of_line = decoder.next_out_of_line();
4983            let handles_before = decoder.remaining_handles();
4984            if let Some((inlined, num_bytes, num_handles)) =
4985                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4986            {
4987                let member_inline_size =
4988                    <fidl::MonotonicInstant as fidl::encoding::TypeMarker>::inline_size(
4989                        decoder.context,
4990                    );
4991                if inlined != (member_inline_size <= 4) {
4992                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4993                }
4994                let inner_offset;
4995                let mut inner_depth = depth.clone();
4996                if inlined {
4997                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4998                    inner_offset = next_offset;
4999                } else {
5000                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5001                    inner_depth.increment()?;
5002                }
5003                let val_ref = self.event_time.get_or_insert_with(|| {
5004                    fidl::new_empty!(
5005                        fidl::MonotonicInstant,
5006                        fidl::encoding::DefaultFuchsiaResourceDialect
5007                    )
5008                });
5009                fidl::decode!(
5010                    fidl::MonotonicInstant,
5011                    fidl::encoding::DefaultFuchsiaResourceDialect,
5012                    val_ref,
5013                    decoder,
5014                    inner_offset,
5015                    inner_depth
5016                )?;
5017                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5018                {
5019                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5020                }
5021                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5022                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5023                }
5024            }
5025
5026            next_offset += envelope_size;
5027            _next_ordinal_to_read += 1;
5028            if next_offset >= end_offset {
5029                return Ok(());
5030            }
5031
5032            // Decode unknown envelopes for gaps in ordinals.
5033            while _next_ordinal_to_read < 2 {
5034                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5035                _next_ordinal_to_read += 1;
5036                next_offset += envelope_size;
5037            }
5038
5039            let next_out_of_line = decoder.next_out_of_line();
5040            let handles_before = decoder.remaining_handles();
5041            if let Some((inlined, num_bytes, num_handles)) =
5042                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5043            {
5044                let member_inline_size =
5045                    <TouchDeviceInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5046                if inlined != (member_inline_size <= 4) {
5047                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5048                }
5049                let inner_offset;
5050                let mut inner_depth = depth.clone();
5051                if inlined {
5052                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5053                    inner_offset = next_offset;
5054                } else {
5055                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5056                    inner_depth.increment()?;
5057                }
5058                let val_ref = self.device_info.get_or_insert_with(|| {
5059                    fidl::new_empty!(TouchDeviceInfo, fidl::encoding::DefaultFuchsiaResourceDialect)
5060                });
5061                fidl::decode!(
5062                    TouchDeviceInfo,
5063                    fidl::encoding::DefaultFuchsiaResourceDialect,
5064                    val_ref,
5065                    decoder,
5066                    inner_offset,
5067                    inner_depth
5068                )?;
5069                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5070                {
5071                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5072                }
5073                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5074                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5075                }
5076            }
5077
5078            next_offset += envelope_size;
5079            _next_ordinal_to_read += 1;
5080            if next_offset >= end_offset {
5081                return Ok(());
5082            }
5083
5084            // Decode unknown envelopes for gaps in ordinals.
5085            while _next_ordinal_to_read < 3 {
5086                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5087                _next_ordinal_to_read += 1;
5088                next_offset += envelope_size;
5089            }
5090
5091            let next_out_of_line = decoder.next_out_of_line();
5092            let handles_before = decoder.remaining_handles();
5093            if let Some((inlined, num_bytes, num_handles)) =
5094                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5095            {
5096                let member_inline_size = <fidl::encoding::UnboundedVector<TouchButton> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5097                if inlined != (member_inline_size <= 4) {
5098                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5099                }
5100                let inner_offset;
5101                let mut inner_depth = depth.clone();
5102                if inlined {
5103                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5104                    inner_offset = next_offset;
5105                } else {
5106                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5107                    inner_depth.increment()?;
5108                }
5109                let val_ref = self.pressed_buttons.get_or_insert_with(|| {
5110                    fidl::new_empty!(
5111                        fidl::encoding::UnboundedVector<TouchButton>,
5112                        fidl::encoding::DefaultFuchsiaResourceDialect
5113                    )
5114                });
5115                fidl::decode!(
5116                    fidl::encoding::UnboundedVector<TouchButton>,
5117                    fidl::encoding::DefaultFuchsiaResourceDialect,
5118                    val_ref,
5119                    decoder,
5120                    inner_offset,
5121                    inner_depth
5122                )?;
5123                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5124                {
5125                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5126                }
5127                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5128                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5129                }
5130            }
5131
5132            next_offset += envelope_size;
5133            _next_ordinal_to_read += 1;
5134            if next_offset >= end_offset {
5135                return Ok(());
5136            }
5137
5138            // Decode unknown envelopes for gaps in ordinals.
5139            while _next_ordinal_to_read < 4 {
5140                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5141                _next_ordinal_to_read += 1;
5142                next_offset += envelope_size;
5143            }
5144
5145            let next_out_of_line = decoder.next_out_of_line();
5146            let handles_before = decoder.remaining_handles();
5147            if let Some((inlined, num_bytes, num_handles)) =
5148                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5149            {
5150                let member_inline_size = <fidl::encoding::HandleType<
5151                    fidl::EventPair,
5152                    { fidl::ObjectType::EVENTPAIR.into_raw() },
5153                    2147483648,
5154                > as fidl::encoding::TypeMarker>::inline_size(
5155                    decoder.context
5156                );
5157                if inlined != (member_inline_size <= 4) {
5158                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5159                }
5160                let inner_offset;
5161                let mut inner_depth = depth.clone();
5162                if inlined {
5163                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5164                    inner_offset = next_offset;
5165                } else {
5166                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5167                    inner_depth.increment()?;
5168                }
5169                let val_ref =
5170                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5171                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5172                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5173                {
5174                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5175                }
5176                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5177                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5178                }
5179            }
5180
5181            next_offset += envelope_size;
5182            _next_ordinal_to_read += 1;
5183            if next_offset >= end_offset {
5184                return Ok(());
5185            }
5186
5187            // Decode unknown envelopes for gaps in ordinals.
5188            while _next_ordinal_to_read < 5 {
5189                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5190                _next_ordinal_to_read += 1;
5191                next_offset += envelope_size;
5192            }
5193
5194            let next_out_of_line = decoder.next_out_of_line();
5195            let handles_before = decoder.remaining_handles();
5196            if let Some((inlined, num_bytes, num_handles)) =
5197                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5198            {
5199                let member_inline_size =
5200                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5201                if inlined != (member_inline_size <= 4) {
5202                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5203                }
5204                let inner_offset;
5205                let mut inner_depth = depth.clone();
5206                if inlined {
5207                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5208                    inner_offset = next_offset;
5209                } else {
5210                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5211                    inner_depth.increment()?;
5212                }
5213                let val_ref = self.trace_flow_id.get_or_insert_with(|| {
5214                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
5215                });
5216                fidl::decode!(
5217                    u64,
5218                    fidl::encoding::DefaultFuchsiaResourceDialect,
5219                    val_ref,
5220                    decoder,
5221                    inner_offset,
5222                    inner_depth
5223                )?;
5224                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5225                {
5226                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5227                }
5228                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5229                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5230                }
5231            }
5232
5233            next_offset += envelope_size;
5234
5235            // Decode the remaining unknown envelopes.
5236            while next_offset < end_offset {
5237                _next_ordinal_to_read += 1;
5238                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5239                next_offset += envelope_size;
5240            }
5241
5242            Ok(())
5243        }
5244    }
5245}