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