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 ImeServiceGetInputMethodEditorRequest {
16    pub keyboard_type: KeyboardType,
17    pub action: InputMethodAction,
18    pub initial_state: TextInputState,
19    pub client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
20    pub editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
21}
22
23impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
24    for ImeServiceGetInputMethodEditorRequest
25{
26}
27
28#[derive(Debug, Default, PartialEq)]
29pub struct MediaButtonsEvent {
30    pub volume: Option<i8>,
31    pub mic_mute: Option<bool>,
32    pub pause: Option<bool>,
33    pub camera_disable: Option<bool>,
34    pub power: Option<bool>,
35    pub function: Option<bool>,
36    pub device_id: Option<u32>,
37    /// Optional wake lease for power baton passing.
38    pub wake_lease: Option<fidl::EventPair>,
39    #[doc(hidden)]
40    pub __source_breaking: fidl::marker::SourceBreaking,
41}
42
43impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for MediaButtonsEvent {}
44
45#[derive(Debug, Default, PartialEq)]
46pub struct TouchButtonsEvent {
47    pub event_time: Option<fidl::MonotonicInstant>,
48    pub device_info: Option<TouchDeviceInfo>,
49    pub pressed_buttons: Option<Vec<TouchButton>>,
50    /// Optional wake lease for power baton passing.
51    pub wake_lease: Option<fidl::EventPair>,
52    /// Optional trace flow ID to connect the event flow.
53    pub trace_flow_id: Option<u64>,
54    #[doc(hidden)]
55    pub __source_breaking: fidl::marker::SourceBreaking,
56}
57
58impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TouchButtonsEvent {}
59
60#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
61pub struct ImeServiceMarker;
62
63impl fidl::endpoints::ProtocolMarker for ImeServiceMarker {
64    type Proxy = ImeServiceProxy;
65    type RequestStream = ImeServiceRequestStream;
66    #[cfg(target_os = "fuchsia")]
67    type SynchronousProxy = ImeServiceSynchronousProxy;
68
69    const DEBUG_NAME: &'static str = "fuchsia.ui.input.ImeService";
70}
71impl fidl::endpoints::DiscoverableProtocolMarker for ImeServiceMarker {}
72
73pub trait ImeServiceProxyInterface: Send + Sync {
74    fn r#get_input_method_editor(
75        &self,
76        keyboard_type: KeyboardType,
77        action: InputMethodAction,
78        initial_state: &TextInputState,
79        client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
80        editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
81    ) -> Result<(), fidl::Error>;
82    fn r#show_keyboard(&self) -> Result<(), fidl::Error>;
83    fn r#hide_keyboard(&self) -> Result<(), fidl::Error>;
84}
85#[derive(Debug)]
86#[cfg(target_os = "fuchsia")]
87pub struct ImeServiceSynchronousProxy {
88    client: fidl::client::sync::Client,
89}
90
91#[cfg(target_os = "fuchsia")]
92impl fidl::endpoints::SynchronousProxy for ImeServiceSynchronousProxy {
93    type Proxy = ImeServiceProxy;
94    type Protocol = ImeServiceMarker;
95
96    fn from_channel(inner: fidl::Channel) -> Self {
97        Self::new(inner)
98    }
99
100    fn into_channel(self) -> fidl::Channel {
101        self.client.into_channel()
102    }
103
104    fn as_channel(&self) -> &fidl::Channel {
105        self.client.as_channel()
106    }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl ImeServiceSynchronousProxy {
111    pub fn new(channel: fidl::Channel) -> Self {
112        Self { client: fidl::client::sync::Client::new(channel) }
113    }
114
115    pub fn into_channel(self) -> fidl::Channel {
116        self.client.into_channel()
117    }
118
119    /// Waits until an event arrives and returns it. It is safe for other
120    /// threads to make concurrent requests while waiting for an event.
121    pub fn wait_for_event(
122        &self,
123        deadline: zx::MonotonicInstant,
124    ) -> Result<ImeServiceEvent, fidl::Error> {
125        ImeServiceEvent::decode(self.client.wait_for_event::<ImeServiceMarker>(deadline)?)
126    }
127
128    pub fn r#get_input_method_editor(
129        &self,
130        mut keyboard_type: KeyboardType,
131        mut action: InputMethodAction,
132        mut initial_state: &TextInputState,
133        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
134        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
135    ) -> Result<(), fidl::Error> {
136        self.client.send::<ImeServiceGetInputMethodEditorRequest>(
137            (keyboard_type, action, initial_state, client, editor),
138            0x148d2e42a1f461fc,
139            fidl::encoding::DynamicFlags::empty(),
140        )
141    }
142
143    pub fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
144        self.client.send::<fidl::encoding::EmptyPayload>(
145            (),
146            0x38ed2a1de28cfcf0,
147            fidl::encoding::DynamicFlags::empty(),
148        )
149    }
150
151    pub fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
152        self.client.send::<fidl::encoding::EmptyPayload>(
153            (),
154            0x7667f098198d09fd,
155            fidl::encoding::DynamicFlags::empty(),
156        )
157    }
158}
159
160#[cfg(target_os = "fuchsia")]
161impl From<ImeServiceSynchronousProxy> for zx::NullableHandle {
162    fn from(value: ImeServiceSynchronousProxy) -> Self {
163        value.into_channel().into()
164    }
165}
166
167#[cfg(target_os = "fuchsia")]
168impl From<fidl::Channel> for ImeServiceSynchronousProxy {
169    fn from(value: fidl::Channel) -> Self {
170        Self::new(value)
171    }
172}
173
174#[cfg(target_os = "fuchsia")]
175impl fidl::endpoints::FromClient for ImeServiceSynchronousProxy {
176    type Protocol = ImeServiceMarker;
177
178    fn from_client(value: fidl::endpoints::ClientEnd<ImeServiceMarker>) -> Self {
179        Self::new(value.into_channel())
180    }
181}
182
183#[derive(Debug, Clone)]
184pub struct ImeServiceProxy {
185    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
186}
187
188impl fidl::endpoints::Proxy for ImeServiceProxy {
189    type Protocol = ImeServiceMarker;
190
191    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
192        Self::new(inner)
193    }
194
195    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
196        self.client.into_channel().map_err(|client| Self { client })
197    }
198
199    fn as_channel(&self) -> &::fidl::AsyncChannel {
200        self.client.as_channel()
201    }
202}
203
204impl ImeServiceProxy {
205    /// Create a new Proxy for fuchsia.ui.input/ImeService.
206    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
207        let protocol_name = <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
208        Self { client: fidl::client::Client::new(channel, protocol_name) }
209    }
210
211    /// Get a Stream of events from the remote end of the protocol.
212    ///
213    /// # Panics
214    ///
215    /// Panics if the event stream was already taken.
216    pub fn take_event_stream(&self) -> ImeServiceEventStream {
217        ImeServiceEventStream { event_receiver: self.client.take_event_receiver() }
218    }
219
220    pub fn r#get_input_method_editor(
221        &self,
222        mut keyboard_type: KeyboardType,
223        mut action: InputMethodAction,
224        mut initial_state: &TextInputState,
225        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
226        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
227    ) -> Result<(), fidl::Error> {
228        ImeServiceProxyInterface::r#get_input_method_editor(
229            self,
230            keyboard_type,
231            action,
232            initial_state,
233            client,
234            editor,
235        )
236    }
237
238    pub fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
239        ImeServiceProxyInterface::r#show_keyboard(self)
240    }
241
242    pub fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
243        ImeServiceProxyInterface::r#hide_keyboard(self)
244    }
245}
246
247impl ImeServiceProxyInterface for ImeServiceProxy {
248    fn r#get_input_method_editor(
249        &self,
250        mut keyboard_type: KeyboardType,
251        mut action: InputMethodAction,
252        mut initial_state: &TextInputState,
253        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
254        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
255    ) -> Result<(), fidl::Error> {
256        self.client.send::<ImeServiceGetInputMethodEditorRequest>(
257            (keyboard_type, action, initial_state, client, editor),
258            0x148d2e42a1f461fc,
259            fidl::encoding::DynamicFlags::empty(),
260        )
261    }
262
263    fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
264        self.client.send::<fidl::encoding::EmptyPayload>(
265            (),
266            0x38ed2a1de28cfcf0,
267            fidl::encoding::DynamicFlags::empty(),
268        )
269    }
270
271    fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
272        self.client.send::<fidl::encoding::EmptyPayload>(
273            (),
274            0x7667f098198d09fd,
275            fidl::encoding::DynamicFlags::empty(),
276        )
277    }
278}
279
280pub struct ImeServiceEventStream {
281    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
282}
283
284impl std::marker::Unpin for ImeServiceEventStream {}
285
286impl futures::stream::FusedStream for ImeServiceEventStream {
287    fn is_terminated(&self) -> bool {
288        self.event_receiver.is_terminated()
289    }
290}
291
292impl futures::Stream for ImeServiceEventStream {
293    type Item = Result<ImeServiceEvent, fidl::Error>;
294
295    fn poll_next(
296        mut self: std::pin::Pin<&mut Self>,
297        cx: &mut std::task::Context<'_>,
298    ) -> std::task::Poll<Option<Self::Item>> {
299        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
300            &mut self.event_receiver,
301            cx
302        )?) {
303            Some(buf) => std::task::Poll::Ready(Some(ImeServiceEvent::decode(buf))),
304            None => std::task::Poll::Ready(None),
305        }
306    }
307}
308
309#[derive(Debug)]
310pub enum ImeServiceEvent {}
311
312impl ImeServiceEvent {
313    /// Decodes a message buffer as a [`ImeServiceEvent`].
314    fn decode(
315        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
316    ) -> Result<ImeServiceEvent, fidl::Error> {
317        let (bytes, _handles) = buf.split_mut();
318        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
319        debug_assert_eq!(tx_header.tx_id, 0);
320        match tx_header.ordinal {
321            _ => Err(fidl::Error::UnknownOrdinal {
322                ordinal: tx_header.ordinal,
323                protocol_name: <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
324            }),
325        }
326    }
327}
328
329/// A Stream of incoming requests for fuchsia.ui.input/ImeService.
330pub struct ImeServiceRequestStream {
331    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
332    is_terminated: bool,
333}
334
335impl std::marker::Unpin for ImeServiceRequestStream {}
336
337impl futures::stream::FusedStream for ImeServiceRequestStream {
338    fn is_terminated(&self) -> bool {
339        self.is_terminated
340    }
341}
342
343impl fidl::endpoints::RequestStream for ImeServiceRequestStream {
344    type Protocol = ImeServiceMarker;
345    type ControlHandle = ImeServiceControlHandle;
346
347    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
348        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
349    }
350
351    fn control_handle(&self) -> Self::ControlHandle {
352        ImeServiceControlHandle { inner: self.inner.clone() }
353    }
354
355    fn into_inner(
356        self,
357    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
358    {
359        (self.inner, self.is_terminated)
360    }
361
362    fn from_inner(
363        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
364        is_terminated: bool,
365    ) -> Self {
366        Self { inner, is_terminated }
367    }
368}
369
370impl futures::Stream for ImeServiceRequestStream {
371    type Item = Result<ImeServiceRequest, fidl::Error>;
372
373    fn poll_next(
374        mut self: std::pin::Pin<&mut Self>,
375        cx: &mut std::task::Context<'_>,
376    ) -> std::task::Poll<Option<Self::Item>> {
377        let this = &mut *self;
378        if this.inner.check_shutdown(cx) {
379            this.is_terminated = true;
380            return std::task::Poll::Ready(None);
381        }
382        if this.is_terminated {
383            panic!("polled ImeServiceRequestStream after completion");
384        }
385        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
386            |bytes, handles| {
387                match this.inner.channel().read_etc(cx, bytes, handles) {
388                    std::task::Poll::Ready(Ok(())) => {}
389                    std::task::Poll::Pending => return std::task::Poll::Pending,
390                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
391                        this.is_terminated = true;
392                        return std::task::Poll::Ready(None);
393                    }
394                    std::task::Poll::Ready(Err(e)) => {
395                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
396                            e.into(),
397                        ))));
398                    }
399                }
400
401                // A message has been received from the channel
402                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
403
404                std::task::Poll::Ready(Some(match header.ordinal {
405                    0x148d2e42a1f461fc => {
406                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
407                        let mut req = fidl::new_empty!(
408                            ImeServiceGetInputMethodEditorRequest,
409                            fidl::encoding::DefaultFuchsiaResourceDialect
410                        );
411                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImeServiceGetInputMethodEditorRequest>(&header, _body_bytes, handles, &mut req)?;
412                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
413                        Ok(ImeServiceRequest::GetInputMethodEditor {
414                            keyboard_type: req.keyboard_type,
415                            action: req.action,
416                            initial_state: req.initial_state,
417                            client: req.client,
418                            editor: req.editor,
419
420                            control_handle,
421                        })
422                    }
423                    0x38ed2a1de28cfcf0 => {
424                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
425                        let mut req = fidl::new_empty!(
426                            fidl::encoding::EmptyPayload,
427                            fidl::encoding::DefaultFuchsiaResourceDialect
428                        );
429                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
430                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
431                        Ok(ImeServiceRequest::ShowKeyboard { control_handle })
432                    }
433                    0x7667f098198d09fd => {
434                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
435                        let mut req = fidl::new_empty!(
436                            fidl::encoding::EmptyPayload,
437                            fidl::encoding::DefaultFuchsiaResourceDialect
438                        );
439                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
440                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
441                        Ok(ImeServiceRequest::HideKeyboard { control_handle })
442                    }
443                    _ => Err(fidl::Error::UnknownOrdinal {
444                        ordinal: header.ordinal,
445                        protocol_name:
446                            <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
447                    }),
448                }))
449            },
450        )
451    }
452}
453
454/// The service provided by an IME
455#[derive(Debug)]
456pub enum ImeServiceRequest {
457    GetInputMethodEditor {
458        keyboard_type: KeyboardType,
459        action: InputMethodAction,
460        initial_state: TextInputState,
461        client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
462        editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
463        control_handle: ImeServiceControlHandle,
464    },
465    ShowKeyboard {
466        control_handle: ImeServiceControlHandle,
467    },
468    HideKeyboard {
469        control_handle: ImeServiceControlHandle,
470    },
471}
472
473impl ImeServiceRequest {
474    #[allow(irrefutable_let_patterns)]
475    pub fn into_get_input_method_editor(
476        self,
477    ) -> Option<(
478        KeyboardType,
479        InputMethodAction,
480        TextInputState,
481        fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
482        fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
483        ImeServiceControlHandle,
484    )> {
485        if let ImeServiceRequest::GetInputMethodEditor {
486            keyboard_type,
487            action,
488            initial_state,
489            client,
490            editor,
491            control_handle,
492        } = self
493        {
494            Some((keyboard_type, action, initial_state, client, editor, control_handle))
495        } else {
496            None
497        }
498    }
499
500    #[allow(irrefutable_let_patterns)]
501    pub fn into_show_keyboard(self) -> Option<(ImeServiceControlHandle)> {
502        if let ImeServiceRequest::ShowKeyboard { control_handle } = self {
503            Some((control_handle))
504        } else {
505            None
506        }
507    }
508
509    #[allow(irrefutable_let_patterns)]
510    pub fn into_hide_keyboard(self) -> Option<(ImeServiceControlHandle)> {
511        if let ImeServiceRequest::HideKeyboard { control_handle } = self {
512            Some((control_handle))
513        } else {
514            None
515        }
516    }
517
518    /// Name of the method defined in FIDL
519    pub fn method_name(&self) -> &'static str {
520        match *self {
521            ImeServiceRequest::GetInputMethodEditor { .. } => "get_input_method_editor",
522            ImeServiceRequest::ShowKeyboard { .. } => "show_keyboard",
523            ImeServiceRequest::HideKeyboard { .. } => "hide_keyboard",
524        }
525    }
526}
527
528#[derive(Debug, Clone)]
529pub struct ImeServiceControlHandle {
530    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
531}
532
533impl fidl::endpoints::ControlHandle for ImeServiceControlHandle {
534    fn shutdown(&self) {
535        self.inner.shutdown()
536    }
537
538    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
539        self.inner.shutdown_with_epitaph(status)
540    }
541
542    fn is_closed(&self) -> bool {
543        self.inner.channel().is_closed()
544    }
545    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
546        self.inner.channel().on_closed()
547    }
548
549    #[cfg(target_os = "fuchsia")]
550    fn signal_peer(
551        &self,
552        clear_mask: zx::Signals,
553        set_mask: zx::Signals,
554    ) -> Result<(), zx_status::Status> {
555        use fidl::Peered;
556        self.inner.channel().signal_peer(clear_mask, set_mask)
557    }
558}
559
560impl ImeServiceControlHandle {}
561
562#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
563pub struct InputDeviceMarker;
564
565impl fidl::endpoints::ProtocolMarker for InputDeviceMarker {
566    type Proxy = InputDeviceProxy;
567    type RequestStream = InputDeviceRequestStream;
568    #[cfg(target_os = "fuchsia")]
569    type SynchronousProxy = InputDeviceSynchronousProxy;
570
571    const DEBUG_NAME: &'static str = "(anonymous) InputDevice";
572}
573
574pub trait InputDeviceProxyInterface: Send + Sync {
575    fn r#dispatch_report(&self, report: &InputReport) -> Result<(), fidl::Error>;
576}
577#[derive(Debug)]
578#[cfg(target_os = "fuchsia")]
579pub struct InputDeviceSynchronousProxy {
580    client: fidl::client::sync::Client,
581}
582
583#[cfg(target_os = "fuchsia")]
584impl fidl::endpoints::SynchronousProxy for InputDeviceSynchronousProxy {
585    type Proxy = InputDeviceProxy;
586    type Protocol = InputDeviceMarker;
587
588    fn from_channel(inner: fidl::Channel) -> Self {
589        Self::new(inner)
590    }
591
592    fn into_channel(self) -> fidl::Channel {
593        self.client.into_channel()
594    }
595
596    fn as_channel(&self) -> &fidl::Channel {
597        self.client.as_channel()
598    }
599}
600
601#[cfg(target_os = "fuchsia")]
602impl InputDeviceSynchronousProxy {
603    pub fn new(channel: fidl::Channel) -> Self {
604        Self { client: fidl::client::sync::Client::new(channel) }
605    }
606
607    pub fn into_channel(self) -> fidl::Channel {
608        self.client.into_channel()
609    }
610
611    /// Waits until an event arrives and returns it. It is safe for other
612    /// threads to make concurrent requests while waiting for an event.
613    pub fn wait_for_event(
614        &self,
615        deadline: zx::MonotonicInstant,
616    ) -> Result<InputDeviceEvent, fidl::Error> {
617        InputDeviceEvent::decode(self.client.wait_for_event::<InputDeviceMarker>(deadline)?)
618    }
619
620    /// Dispatch an `InputReport` from the device `token`
621    pub fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
622        self.client.send::<InputDeviceDispatchReportRequest>(
623            (report,),
624            0x7ee375d01c8e149f,
625            fidl::encoding::DynamicFlags::empty(),
626        )
627    }
628}
629
630#[cfg(target_os = "fuchsia")]
631impl From<InputDeviceSynchronousProxy> for zx::NullableHandle {
632    fn from(value: InputDeviceSynchronousProxy) -> Self {
633        value.into_channel().into()
634    }
635}
636
637#[cfg(target_os = "fuchsia")]
638impl From<fidl::Channel> for InputDeviceSynchronousProxy {
639    fn from(value: fidl::Channel) -> Self {
640        Self::new(value)
641    }
642}
643
644#[cfg(target_os = "fuchsia")]
645impl fidl::endpoints::FromClient for InputDeviceSynchronousProxy {
646    type Protocol = InputDeviceMarker;
647
648    fn from_client(value: fidl::endpoints::ClientEnd<InputDeviceMarker>) -> Self {
649        Self::new(value.into_channel())
650    }
651}
652
653#[derive(Debug, Clone)]
654pub struct InputDeviceProxy {
655    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
656}
657
658impl fidl::endpoints::Proxy for InputDeviceProxy {
659    type Protocol = InputDeviceMarker;
660
661    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
662        Self::new(inner)
663    }
664
665    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
666        self.client.into_channel().map_err(|client| Self { client })
667    }
668
669    fn as_channel(&self) -> &::fidl::AsyncChannel {
670        self.client.as_channel()
671    }
672}
673
674impl InputDeviceProxy {
675    /// Create a new Proxy for fuchsia.ui.input/InputDevice.
676    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
677        let protocol_name = <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
678        Self { client: fidl::client::Client::new(channel, protocol_name) }
679    }
680
681    /// Get a Stream of events from the remote end of the protocol.
682    ///
683    /// # Panics
684    ///
685    /// Panics if the event stream was already taken.
686    pub fn take_event_stream(&self) -> InputDeviceEventStream {
687        InputDeviceEventStream { event_receiver: self.client.take_event_receiver() }
688    }
689
690    /// Dispatch an `InputReport` from the device `token`
691    pub fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
692        InputDeviceProxyInterface::r#dispatch_report(self, report)
693    }
694}
695
696impl InputDeviceProxyInterface for InputDeviceProxy {
697    fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
698        self.client.send::<InputDeviceDispatchReportRequest>(
699            (report,),
700            0x7ee375d01c8e149f,
701            fidl::encoding::DynamicFlags::empty(),
702        )
703    }
704}
705
706pub struct InputDeviceEventStream {
707    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
708}
709
710impl std::marker::Unpin for InputDeviceEventStream {}
711
712impl futures::stream::FusedStream for InputDeviceEventStream {
713    fn is_terminated(&self) -> bool {
714        self.event_receiver.is_terminated()
715    }
716}
717
718impl futures::Stream for InputDeviceEventStream {
719    type Item = Result<InputDeviceEvent, fidl::Error>;
720
721    fn poll_next(
722        mut self: std::pin::Pin<&mut Self>,
723        cx: &mut std::task::Context<'_>,
724    ) -> std::task::Poll<Option<Self::Item>> {
725        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
726            &mut self.event_receiver,
727            cx
728        )?) {
729            Some(buf) => std::task::Poll::Ready(Some(InputDeviceEvent::decode(buf))),
730            None => std::task::Poll::Ready(None),
731        }
732    }
733}
734
735#[derive(Debug)]
736pub enum InputDeviceEvent {}
737
738impl InputDeviceEvent {
739    /// Decodes a message buffer as a [`InputDeviceEvent`].
740    fn decode(
741        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
742    ) -> Result<InputDeviceEvent, fidl::Error> {
743        let (bytes, _handles) = buf.split_mut();
744        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
745        debug_assert_eq!(tx_header.tx_id, 0);
746        match tx_header.ordinal {
747            _ => Err(fidl::Error::UnknownOrdinal {
748                ordinal: tx_header.ordinal,
749                protocol_name: <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
750            }),
751        }
752    }
753}
754
755/// A Stream of incoming requests for fuchsia.ui.input/InputDevice.
756pub struct InputDeviceRequestStream {
757    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
758    is_terminated: bool,
759}
760
761impl std::marker::Unpin for InputDeviceRequestStream {}
762
763impl futures::stream::FusedStream for InputDeviceRequestStream {
764    fn is_terminated(&self) -> bool {
765        self.is_terminated
766    }
767}
768
769impl fidl::endpoints::RequestStream for InputDeviceRequestStream {
770    type Protocol = InputDeviceMarker;
771    type ControlHandle = InputDeviceControlHandle;
772
773    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
774        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
775    }
776
777    fn control_handle(&self) -> Self::ControlHandle {
778        InputDeviceControlHandle { inner: self.inner.clone() }
779    }
780
781    fn into_inner(
782        self,
783    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
784    {
785        (self.inner, self.is_terminated)
786    }
787
788    fn from_inner(
789        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
790        is_terminated: bool,
791    ) -> Self {
792        Self { inner, is_terminated }
793    }
794}
795
796impl futures::Stream for InputDeviceRequestStream {
797    type Item = Result<InputDeviceRequest, fidl::Error>;
798
799    fn poll_next(
800        mut self: std::pin::Pin<&mut Self>,
801        cx: &mut std::task::Context<'_>,
802    ) -> std::task::Poll<Option<Self::Item>> {
803        let this = &mut *self;
804        if this.inner.check_shutdown(cx) {
805            this.is_terminated = true;
806            return std::task::Poll::Ready(None);
807        }
808        if this.is_terminated {
809            panic!("polled InputDeviceRequestStream after completion");
810        }
811        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
812            |bytes, handles| {
813                match this.inner.channel().read_etc(cx, bytes, handles) {
814                    std::task::Poll::Ready(Ok(())) => {}
815                    std::task::Poll::Pending => return std::task::Poll::Pending,
816                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
817                        this.is_terminated = true;
818                        return std::task::Poll::Ready(None);
819                    }
820                    std::task::Poll::Ready(Err(e)) => {
821                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
822                            e.into(),
823                        ))));
824                    }
825                }
826
827                // A message has been received from the channel
828                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
829
830                std::task::Poll::Ready(Some(match header.ordinal {
831                    0x7ee375d01c8e149f => {
832                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
833                        let mut req = fidl::new_empty!(
834                            InputDeviceDispatchReportRequest,
835                            fidl::encoding::DefaultFuchsiaResourceDialect
836                        );
837                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceDispatchReportRequest>(&header, _body_bytes, handles, &mut req)?;
838                        let control_handle = InputDeviceControlHandle { inner: this.inner.clone() };
839                        Ok(InputDeviceRequest::DispatchReport {
840                            report: req.report,
841
842                            control_handle,
843                        })
844                    }
845                    _ => Err(fidl::Error::UnknownOrdinal {
846                        ordinal: header.ordinal,
847                        protocol_name:
848                            <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
849                    }),
850                }))
851            },
852        )
853    }
854}
855
856#[derive(Debug)]
857pub enum InputDeviceRequest {
858    /// Dispatch an `InputReport` from the device `token`
859    DispatchReport { report: InputReport, control_handle: InputDeviceControlHandle },
860}
861
862impl InputDeviceRequest {
863    #[allow(irrefutable_let_patterns)]
864    pub fn into_dispatch_report(self) -> Option<(InputReport, InputDeviceControlHandle)> {
865        if let InputDeviceRequest::DispatchReport { report, control_handle } = self {
866            Some((report, control_handle))
867        } else {
868            None
869        }
870    }
871
872    /// Name of the method defined in FIDL
873    pub fn method_name(&self) -> &'static str {
874        match *self {
875            InputDeviceRequest::DispatchReport { .. } => "dispatch_report",
876        }
877    }
878}
879
880#[derive(Debug, Clone)]
881pub struct InputDeviceControlHandle {
882    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
883}
884
885impl fidl::endpoints::ControlHandle for InputDeviceControlHandle {
886    fn shutdown(&self) {
887        self.inner.shutdown()
888    }
889
890    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
891        self.inner.shutdown_with_epitaph(status)
892    }
893
894    fn is_closed(&self) -> bool {
895        self.inner.channel().is_closed()
896    }
897    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
898        self.inner.channel().on_closed()
899    }
900
901    #[cfg(target_os = "fuchsia")]
902    fn signal_peer(
903        &self,
904        clear_mask: zx::Signals,
905        set_mask: zx::Signals,
906    ) -> Result<(), zx_status::Status> {
907        use fidl::Peered;
908        self.inner.channel().signal_peer(clear_mask, set_mask)
909    }
910}
911
912impl InputDeviceControlHandle {}
913
914#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
915pub struct InputMethodEditorMarker;
916
917impl fidl::endpoints::ProtocolMarker for InputMethodEditorMarker {
918    type Proxy = InputMethodEditorProxy;
919    type RequestStream = InputMethodEditorRequestStream;
920    #[cfg(target_os = "fuchsia")]
921    type SynchronousProxy = InputMethodEditorSynchronousProxy;
922
923    const DEBUG_NAME: &'static str = "(anonymous) InputMethodEditor";
924}
925
926pub trait InputMethodEditorProxyInterface: Send + Sync {
927    fn r#set_keyboard_type(&self, keyboard_type: KeyboardType) -> Result<(), fidl::Error>;
928    fn r#set_state(&self, state: &TextInputState) -> Result<(), fidl::Error>;
929    fn r#inject_input(&self, event: &InputEvent) -> Result<(), fidl::Error>;
930    type DispatchKey3ResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
931    fn r#dispatch_key3(
932        &self,
933        event: &fidl_fuchsia_ui_input3::KeyEvent,
934    ) -> Self::DispatchKey3ResponseFut;
935    fn r#show(&self) -> Result<(), fidl::Error>;
936    fn r#hide(&self) -> Result<(), fidl::Error>;
937}
938#[derive(Debug)]
939#[cfg(target_os = "fuchsia")]
940pub struct InputMethodEditorSynchronousProxy {
941    client: fidl::client::sync::Client,
942}
943
944#[cfg(target_os = "fuchsia")]
945impl fidl::endpoints::SynchronousProxy for InputMethodEditorSynchronousProxy {
946    type Proxy = InputMethodEditorProxy;
947    type Protocol = InputMethodEditorMarker;
948
949    fn from_channel(inner: fidl::Channel) -> Self {
950        Self::new(inner)
951    }
952
953    fn into_channel(self) -> fidl::Channel {
954        self.client.into_channel()
955    }
956
957    fn as_channel(&self) -> &fidl::Channel {
958        self.client.as_channel()
959    }
960}
961
962#[cfg(target_os = "fuchsia")]
963impl InputMethodEditorSynchronousProxy {
964    pub fn new(channel: fidl::Channel) -> Self {
965        Self { client: fidl::client::sync::Client::new(channel) }
966    }
967
968    pub fn into_channel(self) -> fidl::Channel {
969        self.client.into_channel()
970    }
971
972    /// Waits until an event arrives and returns it. It is safe for other
973    /// threads to make concurrent requests while waiting for an event.
974    pub fn wait_for_event(
975        &self,
976        deadline: zx::MonotonicInstant,
977    ) -> Result<InputMethodEditorEvent, fidl::Error> {
978        InputMethodEditorEvent::decode(
979            self.client.wait_for_event::<InputMethodEditorMarker>(deadline)?,
980        )
981    }
982
983    pub fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
984        self.client.send::<InputMethodEditorSetKeyboardTypeRequest>(
985            (keyboard_type,),
986            0x14fe60e927d7d487,
987            fidl::encoding::DynamicFlags::empty(),
988        )
989    }
990
991    pub fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
992        self.client.send::<InputMethodEditorSetStateRequest>(
993            (state,),
994            0x12b477b779818f45,
995            fidl::encoding::DynamicFlags::empty(),
996        )
997    }
998
999    pub fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
1000        self.client.send::<InputMethodEditorInjectInputRequest>(
1001            (event,),
1002            0x34af74618a4f82b,
1003            fidl::encoding::DynamicFlags::empty(),
1004        )
1005    }
1006
1007    pub fn r#dispatch_key3(
1008        &self,
1009        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
1010        ___deadline: zx::MonotonicInstant,
1011    ) -> Result<bool, fidl::Error> {
1012        let _response = self.client.send_query::<
1013            InputMethodEditorDispatchKey3Request,
1014            InputMethodEditorDispatchKey3Response,
1015            InputMethodEditorMarker,
1016        >(
1017            (event,),
1018            0x2e13667c827209ac,
1019            fidl::encoding::DynamicFlags::empty(),
1020            ___deadline,
1021        )?;
1022        Ok(_response.handled)
1023    }
1024
1025    pub fn r#show(&self) -> Result<(), fidl::Error> {
1026        self.client.send::<fidl::encoding::EmptyPayload>(
1027            (),
1028            0x19ba00ba1beb002e,
1029            fidl::encoding::DynamicFlags::empty(),
1030        )
1031    }
1032
1033    pub fn r#hide(&self) -> Result<(), fidl::Error> {
1034        self.client.send::<fidl::encoding::EmptyPayload>(
1035            (),
1036            0x283e0cd73f0d6d9e,
1037            fidl::encoding::DynamicFlags::empty(),
1038        )
1039    }
1040}
1041
1042#[cfg(target_os = "fuchsia")]
1043impl From<InputMethodEditorSynchronousProxy> for zx::NullableHandle {
1044    fn from(value: InputMethodEditorSynchronousProxy) -> Self {
1045        value.into_channel().into()
1046    }
1047}
1048
1049#[cfg(target_os = "fuchsia")]
1050impl From<fidl::Channel> for InputMethodEditorSynchronousProxy {
1051    fn from(value: fidl::Channel) -> Self {
1052        Self::new(value)
1053    }
1054}
1055
1056#[cfg(target_os = "fuchsia")]
1057impl fidl::endpoints::FromClient for InputMethodEditorSynchronousProxy {
1058    type Protocol = InputMethodEditorMarker;
1059
1060    fn from_client(value: fidl::endpoints::ClientEnd<InputMethodEditorMarker>) -> Self {
1061        Self::new(value.into_channel())
1062    }
1063}
1064
1065#[derive(Debug, Clone)]
1066pub struct InputMethodEditorProxy {
1067    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1068}
1069
1070impl fidl::endpoints::Proxy for InputMethodEditorProxy {
1071    type Protocol = InputMethodEditorMarker;
1072
1073    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1074        Self::new(inner)
1075    }
1076
1077    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1078        self.client.into_channel().map_err(|client| Self { client })
1079    }
1080
1081    fn as_channel(&self) -> &::fidl::AsyncChannel {
1082        self.client.as_channel()
1083    }
1084}
1085
1086impl InputMethodEditorProxy {
1087    /// Create a new Proxy for fuchsia.ui.input/InputMethodEditor.
1088    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1089        let protocol_name =
1090            <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1091        Self { client: fidl::client::Client::new(channel, protocol_name) }
1092    }
1093
1094    /// Get a Stream of events from the remote end of the protocol.
1095    ///
1096    /// # Panics
1097    ///
1098    /// Panics if the event stream was already taken.
1099    pub fn take_event_stream(&self) -> InputMethodEditorEventStream {
1100        InputMethodEditorEventStream { event_receiver: self.client.take_event_receiver() }
1101    }
1102
1103    pub fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
1104        InputMethodEditorProxyInterface::r#set_keyboard_type(self, keyboard_type)
1105    }
1106
1107    pub fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
1108        InputMethodEditorProxyInterface::r#set_state(self, state)
1109    }
1110
1111    pub fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
1112        InputMethodEditorProxyInterface::r#inject_input(self, event)
1113    }
1114
1115    pub fn r#dispatch_key3(
1116        &self,
1117        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
1118    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
1119        InputMethodEditorProxyInterface::r#dispatch_key3(self, event)
1120    }
1121
1122    pub fn r#show(&self) -> Result<(), fidl::Error> {
1123        InputMethodEditorProxyInterface::r#show(self)
1124    }
1125
1126    pub fn r#hide(&self) -> Result<(), fidl::Error> {
1127        InputMethodEditorProxyInterface::r#hide(self)
1128    }
1129}
1130
1131impl InputMethodEditorProxyInterface for InputMethodEditorProxy {
1132    fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
1133        self.client.send::<InputMethodEditorSetKeyboardTypeRequest>(
1134            (keyboard_type,),
1135            0x14fe60e927d7d487,
1136            fidl::encoding::DynamicFlags::empty(),
1137        )
1138    }
1139
1140    fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
1141        self.client.send::<InputMethodEditorSetStateRequest>(
1142            (state,),
1143            0x12b477b779818f45,
1144            fidl::encoding::DynamicFlags::empty(),
1145        )
1146    }
1147
1148    fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
1149        self.client.send::<InputMethodEditorInjectInputRequest>(
1150            (event,),
1151            0x34af74618a4f82b,
1152            fidl::encoding::DynamicFlags::empty(),
1153        )
1154    }
1155
1156    type DispatchKey3ResponseFut =
1157        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
1158    fn r#dispatch_key3(
1159        &self,
1160        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
1161    ) -> Self::DispatchKey3ResponseFut {
1162        fn _decode(
1163            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1164        ) -> Result<bool, fidl::Error> {
1165            let _response = fidl::client::decode_transaction_body::<
1166                InputMethodEditorDispatchKey3Response,
1167                fidl::encoding::DefaultFuchsiaResourceDialect,
1168                0x2e13667c827209ac,
1169            >(_buf?)?;
1170            Ok(_response.handled)
1171        }
1172        self.client.send_query_and_decode::<InputMethodEditorDispatchKey3Request, bool>(
1173            (event,),
1174            0x2e13667c827209ac,
1175            fidl::encoding::DynamicFlags::empty(),
1176            _decode,
1177        )
1178    }
1179
1180    fn r#show(&self) -> Result<(), fidl::Error> {
1181        self.client.send::<fidl::encoding::EmptyPayload>(
1182            (),
1183            0x19ba00ba1beb002e,
1184            fidl::encoding::DynamicFlags::empty(),
1185        )
1186    }
1187
1188    fn r#hide(&self) -> Result<(), fidl::Error> {
1189        self.client.send::<fidl::encoding::EmptyPayload>(
1190            (),
1191            0x283e0cd73f0d6d9e,
1192            fidl::encoding::DynamicFlags::empty(),
1193        )
1194    }
1195}
1196
1197pub struct InputMethodEditorEventStream {
1198    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1199}
1200
1201impl std::marker::Unpin for InputMethodEditorEventStream {}
1202
1203impl futures::stream::FusedStream for InputMethodEditorEventStream {
1204    fn is_terminated(&self) -> bool {
1205        self.event_receiver.is_terminated()
1206    }
1207}
1208
1209impl futures::Stream for InputMethodEditorEventStream {
1210    type Item = Result<InputMethodEditorEvent, fidl::Error>;
1211
1212    fn poll_next(
1213        mut self: std::pin::Pin<&mut Self>,
1214        cx: &mut std::task::Context<'_>,
1215    ) -> std::task::Poll<Option<Self::Item>> {
1216        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1217            &mut self.event_receiver,
1218            cx
1219        )?) {
1220            Some(buf) => std::task::Poll::Ready(Some(InputMethodEditorEvent::decode(buf))),
1221            None => std::task::Poll::Ready(None),
1222        }
1223    }
1224}
1225
1226#[derive(Debug)]
1227pub enum InputMethodEditorEvent {}
1228
1229impl InputMethodEditorEvent {
1230    /// Decodes a message buffer as a [`InputMethodEditorEvent`].
1231    fn decode(
1232        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1233    ) -> Result<InputMethodEditorEvent, fidl::Error> {
1234        let (bytes, _handles) = buf.split_mut();
1235        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1236        debug_assert_eq!(tx_header.tx_id, 0);
1237        match tx_header.ordinal {
1238            _ => Err(fidl::Error::UnknownOrdinal {
1239                ordinal: tx_header.ordinal,
1240                protocol_name:
1241                    <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1242            }),
1243        }
1244    }
1245}
1246
1247/// A Stream of incoming requests for fuchsia.ui.input/InputMethodEditor.
1248pub struct InputMethodEditorRequestStream {
1249    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1250    is_terminated: bool,
1251}
1252
1253impl std::marker::Unpin for InputMethodEditorRequestStream {}
1254
1255impl futures::stream::FusedStream for InputMethodEditorRequestStream {
1256    fn is_terminated(&self) -> bool {
1257        self.is_terminated
1258    }
1259}
1260
1261impl fidl::endpoints::RequestStream for InputMethodEditorRequestStream {
1262    type Protocol = InputMethodEditorMarker;
1263    type ControlHandle = InputMethodEditorControlHandle;
1264
1265    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1266        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1267    }
1268
1269    fn control_handle(&self) -> Self::ControlHandle {
1270        InputMethodEditorControlHandle { inner: self.inner.clone() }
1271    }
1272
1273    fn into_inner(
1274        self,
1275    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1276    {
1277        (self.inner, self.is_terminated)
1278    }
1279
1280    fn from_inner(
1281        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1282        is_terminated: bool,
1283    ) -> Self {
1284        Self { inner, is_terminated }
1285    }
1286}
1287
1288impl futures::Stream for InputMethodEditorRequestStream {
1289    type Item = Result<InputMethodEditorRequest, fidl::Error>;
1290
1291    fn poll_next(
1292        mut self: std::pin::Pin<&mut Self>,
1293        cx: &mut std::task::Context<'_>,
1294    ) -> std::task::Poll<Option<Self::Item>> {
1295        let this = &mut *self;
1296        if this.inner.check_shutdown(cx) {
1297            this.is_terminated = true;
1298            return std::task::Poll::Ready(None);
1299        }
1300        if this.is_terminated {
1301            panic!("polled InputMethodEditorRequestStream after completion");
1302        }
1303        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1304            |bytes, handles| {
1305                match this.inner.channel().read_etc(cx, bytes, handles) {
1306                    std::task::Poll::Ready(Ok(())) => {}
1307                    std::task::Poll::Pending => return std::task::Poll::Pending,
1308                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1309                        this.is_terminated = true;
1310                        return std::task::Poll::Ready(None);
1311                    }
1312                    std::task::Poll::Ready(Err(e)) => {
1313                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1314                            e.into(),
1315                        ))));
1316                    }
1317                }
1318
1319                // A message has been received from the channel
1320                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1321
1322                std::task::Poll::Ready(Some(match header.ordinal {
1323                    0x14fe60e927d7d487 => {
1324                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1325                        let mut req = fidl::new_empty!(
1326                            InputMethodEditorSetKeyboardTypeRequest,
1327                            fidl::encoding::DefaultFuchsiaResourceDialect
1328                        );
1329                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorSetKeyboardTypeRequest>(&header, _body_bytes, handles, &mut req)?;
1330                        let control_handle =
1331                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1332                        Ok(InputMethodEditorRequest::SetKeyboardType {
1333                            keyboard_type: req.keyboard_type,
1334
1335                            control_handle,
1336                        })
1337                    }
1338                    0x12b477b779818f45 => {
1339                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1340                        let mut req = fidl::new_empty!(
1341                            InputMethodEditorSetStateRequest,
1342                            fidl::encoding::DefaultFuchsiaResourceDialect
1343                        );
1344                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorSetStateRequest>(&header, _body_bytes, handles, &mut req)?;
1345                        let control_handle =
1346                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1347                        Ok(InputMethodEditorRequest::SetState { state: req.state, control_handle })
1348                    }
1349                    0x34af74618a4f82b => {
1350                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1351                        let mut req = fidl::new_empty!(
1352                            InputMethodEditorInjectInputRequest,
1353                            fidl::encoding::DefaultFuchsiaResourceDialect
1354                        );
1355                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorInjectInputRequest>(&header, _body_bytes, handles, &mut req)?;
1356                        let control_handle =
1357                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1358                        Ok(InputMethodEditorRequest::InjectInput {
1359                            event: req.event,
1360
1361                            control_handle,
1362                        })
1363                    }
1364                    0x2e13667c827209ac => {
1365                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1366                        let mut req = fidl::new_empty!(
1367                            InputMethodEditorDispatchKey3Request,
1368                            fidl::encoding::DefaultFuchsiaResourceDialect
1369                        );
1370                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorDispatchKey3Request>(&header, _body_bytes, handles, &mut req)?;
1371                        let control_handle =
1372                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1373                        Ok(InputMethodEditorRequest::DispatchKey3 {
1374                            event: req.event,
1375
1376                            responder: InputMethodEditorDispatchKey3Responder {
1377                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1378                                tx_id: header.tx_id,
1379                            },
1380                        })
1381                    }
1382                    0x19ba00ba1beb002e => {
1383                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1384                        let mut req = fidl::new_empty!(
1385                            fidl::encoding::EmptyPayload,
1386                            fidl::encoding::DefaultFuchsiaResourceDialect
1387                        );
1388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1389                        let control_handle =
1390                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1391                        Ok(InputMethodEditorRequest::Show { control_handle })
1392                    }
1393                    0x283e0cd73f0d6d9e => {
1394                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1395                        let mut req = fidl::new_empty!(
1396                            fidl::encoding::EmptyPayload,
1397                            fidl::encoding::DefaultFuchsiaResourceDialect
1398                        );
1399                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1400                        let control_handle =
1401                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1402                        Ok(InputMethodEditorRequest::Hide { control_handle })
1403                    }
1404                    _ => Err(fidl::Error::UnknownOrdinal {
1405                        ordinal: header.ordinal,
1406                        protocol_name:
1407                            <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1408                    }),
1409                }))
1410            },
1411        )
1412    }
1413}
1414
1415/// A interface for interacting with a text input control.
1416#[derive(Debug)]
1417pub enum InputMethodEditorRequest {
1418    SetKeyboardType {
1419        keyboard_type: KeyboardType,
1420        control_handle: InputMethodEditorControlHandle,
1421    },
1422    SetState {
1423        state: TextInputState,
1424        control_handle: InputMethodEditorControlHandle,
1425    },
1426    InjectInput {
1427        event: InputEvent,
1428        control_handle: InputMethodEditorControlHandle,
1429    },
1430    DispatchKey3 {
1431        event: fidl_fuchsia_ui_input3::KeyEvent,
1432        responder: InputMethodEditorDispatchKey3Responder,
1433    },
1434    Show {
1435        control_handle: InputMethodEditorControlHandle,
1436    },
1437    Hide {
1438        control_handle: InputMethodEditorControlHandle,
1439    },
1440}
1441
1442impl InputMethodEditorRequest {
1443    #[allow(irrefutable_let_patterns)]
1444    pub fn into_set_keyboard_type(self) -> Option<(KeyboardType, InputMethodEditorControlHandle)> {
1445        if let InputMethodEditorRequest::SetKeyboardType { keyboard_type, control_handle } = self {
1446            Some((keyboard_type, control_handle))
1447        } else {
1448            None
1449        }
1450    }
1451
1452    #[allow(irrefutable_let_patterns)]
1453    pub fn into_set_state(self) -> Option<(TextInputState, InputMethodEditorControlHandle)> {
1454        if let InputMethodEditorRequest::SetState { state, control_handle } = self {
1455            Some((state, control_handle))
1456        } else {
1457            None
1458        }
1459    }
1460
1461    #[allow(irrefutable_let_patterns)]
1462    pub fn into_inject_input(self) -> Option<(InputEvent, InputMethodEditorControlHandle)> {
1463        if let InputMethodEditorRequest::InjectInput { event, control_handle } = self {
1464            Some((event, control_handle))
1465        } else {
1466            None
1467        }
1468    }
1469
1470    #[allow(irrefutable_let_patterns)]
1471    pub fn into_dispatch_key3(
1472        self,
1473    ) -> Option<(fidl_fuchsia_ui_input3::KeyEvent, InputMethodEditorDispatchKey3Responder)> {
1474        if let InputMethodEditorRequest::DispatchKey3 { event, responder } = self {
1475            Some((event, responder))
1476        } else {
1477            None
1478        }
1479    }
1480
1481    #[allow(irrefutable_let_patterns)]
1482    pub fn into_show(self) -> Option<(InputMethodEditorControlHandle)> {
1483        if let InputMethodEditorRequest::Show { control_handle } = self {
1484            Some((control_handle))
1485        } else {
1486            None
1487        }
1488    }
1489
1490    #[allow(irrefutable_let_patterns)]
1491    pub fn into_hide(self) -> Option<(InputMethodEditorControlHandle)> {
1492        if let InputMethodEditorRequest::Hide { control_handle } = self {
1493            Some((control_handle))
1494        } else {
1495            None
1496        }
1497    }
1498
1499    /// Name of the method defined in FIDL
1500    pub fn method_name(&self) -> &'static str {
1501        match *self {
1502            InputMethodEditorRequest::SetKeyboardType { .. } => "set_keyboard_type",
1503            InputMethodEditorRequest::SetState { .. } => "set_state",
1504            InputMethodEditorRequest::InjectInput { .. } => "inject_input",
1505            InputMethodEditorRequest::DispatchKey3 { .. } => "dispatch_key3",
1506            InputMethodEditorRequest::Show { .. } => "show",
1507            InputMethodEditorRequest::Hide { .. } => "hide",
1508        }
1509    }
1510}
1511
1512#[derive(Debug, Clone)]
1513pub struct InputMethodEditorControlHandle {
1514    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1515}
1516
1517impl fidl::endpoints::ControlHandle for InputMethodEditorControlHandle {
1518    fn shutdown(&self) {
1519        self.inner.shutdown()
1520    }
1521
1522    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1523        self.inner.shutdown_with_epitaph(status)
1524    }
1525
1526    fn is_closed(&self) -> bool {
1527        self.inner.channel().is_closed()
1528    }
1529    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1530        self.inner.channel().on_closed()
1531    }
1532
1533    #[cfg(target_os = "fuchsia")]
1534    fn signal_peer(
1535        &self,
1536        clear_mask: zx::Signals,
1537        set_mask: zx::Signals,
1538    ) -> Result<(), zx_status::Status> {
1539        use fidl::Peered;
1540        self.inner.channel().signal_peer(clear_mask, set_mask)
1541    }
1542}
1543
1544impl InputMethodEditorControlHandle {}
1545
1546#[must_use = "FIDL methods require a response to be sent"]
1547#[derive(Debug)]
1548pub struct InputMethodEditorDispatchKey3Responder {
1549    control_handle: std::mem::ManuallyDrop<InputMethodEditorControlHandle>,
1550    tx_id: u32,
1551}
1552
1553/// Set the the channel to be shutdown (see [`InputMethodEditorControlHandle::shutdown`])
1554/// if the responder is dropped without sending a response, so that the client
1555/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1556impl std::ops::Drop for InputMethodEditorDispatchKey3Responder {
1557    fn drop(&mut self) {
1558        self.control_handle.shutdown();
1559        // Safety: drops once, never accessed again
1560        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1561    }
1562}
1563
1564impl fidl::endpoints::Responder for InputMethodEditorDispatchKey3Responder {
1565    type ControlHandle = InputMethodEditorControlHandle;
1566
1567    fn control_handle(&self) -> &InputMethodEditorControlHandle {
1568        &self.control_handle
1569    }
1570
1571    fn drop_without_shutdown(mut self) {
1572        // Safety: drops once, never accessed again due to mem::forget
1573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1574        // Prevent Drop from running (which would shut down the channel)
1575        std::mem::forget(self);
1576    }
1577}
1578
1579impl InputMethodEditorDispatchKey3Responder {
1580    /// Sends a response to the FIDL transaction.
1581    ///
1582    /// Sets the channel to shutdown if an error occurs.
1583    pub fn send(self, mut handled: bool) -> Result<(), fidl::Error> {
1584        let _result = self.send_raw(handled);
1585        if _result.is_err() {
1586            self.control_handle.shutdown();
1587        }
1588        self.drop_without_shutdown();
1589        _result
1590    }
1591
1592    /// Similar to "send" but does not shutdown the channel if an error occurs.
1593    pub fn send_no_shutdown_on_err(self, mut handled: bool) -> Result<(), fidl::Error> {
1594        let _result = self.send_raw(handled);
1595        self.drop_without_shutdown();
1596        _result
1597    }
1598
1599    fn send_raw(&self, mut handled: bool) -> Result<(), fidl::Error> {
1600        self.control_handle.inner.send::<InputMethodEditorDispatchKey3Response>(
1601            (handled,),
1602            self.tx_id,
1603            0x2e13667c827209ac,
1604            fidl::encoding::DynamicFlags::empty(),
1605        )
1606    }
1607}
1608
1609#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1610pub struct InputMethodEditorClientMarker;
1611
1612impl fidl::endpoints::ProtocolMarker for InputMethodEditorClientMarker {
1613    type Proxy = InputMethodEditorClientProxy;
1614    type RequestStream = InputMethodEditorClientRequestStream;
1615    #[cfg(target_os = "fuchsia")]
1616    type SynchronousProxy = InputMethodEditorClientSynchronousProxy;
1617
1618    const DEBUG_NAME: &'static str = "(anonymous) InputMethodEditorClient";
1619}
1620
1621pub trait InputMethodEditorClientProxyInterface: Send + Sync {
1622    fn r#did_update_state(
1623        &self,
1624        state: &TextInputState,
1625        event: Option<&InputEvent>,
1626    ) -> Result<(), fidl::Error>;
1627    fn r#on_action(&self, action: InputMethodAction) -> Result<(), fidl::Error>;
1628}
1629#[derive(Debug)]
1630#[cfg(target_os = "fuchsia")]
1631pub struct InputMethodEditorClientSynchronousProxy {
1632    client: fidl::client::sync::Client,
1633}
1634
1635#[cfg(target_os = "fuchsia")]
1636impl fidl::endpoints::SynchronousProxy for InputMethodEditorClientSynchronousProxy {
1637    type Proxy = InputMethodEditorClientProxy;
1638    type Protocol = InputMethodEditorClientMarker;
1639
1640    fn from_channel(inner: fidl::Channel) -> Self {
1641        Self::new(inner)
1642    }
1643
1644    fn into_channel(self) -> fidl::Channel {
1645        self.client.into_channel()
1646    }
1647
1648    fn as_channel(&self) -> &fidl::Channel {
1649        self.client.as_channel()
1650    }
1651}
1652
1653#[cfg(target_os = "fuchsia")]
1654impl InputMethodEditorClientSynchronousProxy {
1655    pub fn new(channel: fidl::Channel) -> Self {
1656        Self { client: fidl::client::sync::Client::new(channel) }
1657    }
1658
1659    pub fn into_channel(self) -> fidl::Channel {
1660        self.client.into_channel()
1661    }
1662
1663    /// Waits until an event arrives and returns it. It is safe for other
1664    /// threads to make concurrent requests while waiting for an event.
1665    pub fn wait_for_event(
1666        &self,
1667        deadline: zx::MonotonicInstant,
1668    ) -> Result<InputMethodEditorClientEvent, fidl::Error> {
1669        InputMethodEditorClientEvent::decode(
1670            self.client.wait_for_event::<InputMethodEditorClientMarker>(deadline)?,
1671        )
1672    }
1673
1674    pub fn r#did_update_state(
1675        &self,
1676        mut state: &TextInputState,
1677        mut event: Option<&InputEvent>,
1678    ) -> Result<(), fidl::Error> {
1679        self.client.send::<InputMethodEditorClientDidUpdateStateRequest>(
1680            (state, event),
1681            0x26681a6b204b679d,
1682            fidl::encoding::DynamicFlags::empty(),
1683        )
1684    }
1685
1686    pub fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
1687        self.client.send::<InputMethodEditorClientOnActionRequest>(
1688            (action,),
1689            0x19c420f173275398,
1690            fidl::encoding::DynamicFlags::empty(),
1691        )
1692    }
1693}
1694
1695#[cfg(target_os = "fuchsia")]
1696impl From<InputMethodEditorClientSynchronousProxy> for zx::NullableHandle {
1697    fn from(value: InputMethodEditorClientSynchronousProxy) -> Self {
1698        value.into_channel().into()
1699    }
1700}
1701
1702#[cfg(target_os = "fuchsia")]
1703impl From<fidl::Channel> for InputMethodEditorClientSynchronousProxy {
1704    fn from(value: fidl::Channel) -> Self {
1705        Self::new(value)
1706    }
1707}
1708
1709#[cfg(target_os = "fuchsia")]
1710impl fidl::endpoints::FromClient for InputMethodEditorClientSynchronousProxy {
1711    type Protocol = InputMethodEditorClientMarker;
1712
1713    fn from_client(value: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>) -> Self {
1714        Self::new(value.into_channel())
1715    }
1716}
1717
1718#[derive(Debug, Clone)]
1719pub struct InputMethodEditorClientProxy {
1720    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1721}
1722
1723impl fidl::endpoints::Proxy for InputMethodEditorClientProxy {
1724    type Protocol = InputMethodEditorClientMarker;
1725
1726    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1727        Self::new(inner)
1728    }
1729
1730    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1731        self.client.into_channel().map_err(|client| Self { client })
1732    }
1733
1734    fn as_channel(&self) -> &::fidl::AsyncChannel {
1735        self.client.as_channel()
1736    }
1737}
1738
1739impl InputMethodEditorClientProxy {
1740    /// Create a new Proxy for fuchsia.ui.input/InputMethodEditorClient.
1741    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1742        let protocol_name =
1743            <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1744        Self { client: fidl::client::Client::new(channel, protocol_name) }
1745    }
1746
1747    /// Get a Stream of events from the remote end of the protocol.
1748    ///
1749    /// # Panics
1750    ///
1751    /// Panics if the event stream was already taken.
1752    pub fn take_event_stream(&self) -> InputMethodEditorClientEventStream {
1753        InputMethodEditorClientEventStream { event_receiver: self.client.take_event_receiver() }
1754    }
1755
1756    pub fn r#did_update_state(
1757        &self,
1758        mut state: &TextInputState,
1759        mut event: Option<&InputEvent>,
1760    ) -> Result<(), fidl::Error> {
1761        InputMethodEditorClientProxyInterface::r#did_update_state(self, state, event)
1762    }
1763
1764    pub fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
1765        InputMethodEditorClientProxyInterface::r#on_action(self, action)
1766    }
1767}
1768
1769impl InputMethodEditorClientProxyInterface for InputMethodEditorClientProxy {
1770    fn r#did_update_state(
1771        &self,
1772        mut state: &TextInputState,
1773        mut event: Option<&InputEvent>,
1774    ) -> Result<(), fidl::Error> {
1775        self.client.send::<InputMethodEditorClientDidUpdateStateRequest>(
1776            (state, event),
1777            0x26681a6b204b679d,
1778            fidl::encoding::DynamicFlags::empty(),
1779        )
1780    }
1781
1782    fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
1783        self.client.send::<InputMethodEditorClientOnActionRequest>(
1784            (action,),
1785            0x19c420f173275398,
1786            fidl::encoding::DynamicFlags::empty(),
1787        )
1788    }
1789}
1790
1791pub struct InputMethodEditorClientEventStream {
1792    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1793}
1794
1795impl std::marker::Unpin for InputMethodEditorClientEventStream {}
1796
1797impl futures::stream::FusedStream for InputMethodEditorClientEventStream {
1798    fn is_terminated(&self) -> bool {
1799        self.event_receiver.is_terminated()
1800    }
1801}
1802
1803impl futures::Stream for InputMethodEditorClientEventStream {
1804    type Item = Result<InputMethodEditorClientEvent, fidl::Error>;
1805
1806    fn poll_next(
1807        mut self: std::pin::Pin<&mut Self>,
1808        cx: &mut std::task::Context<'_>,
1809    ) -> std::task::Poll<Option<Self::Item>> {
1810        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1811            &mut self.event_receiver,
1812            cx
1813        )?) {
1814            Some(buf) => std::task::Poll::Ready(Some(InputMethodEditorClientEvent::decode(buf))),
1815            None => std::task::Poll::Ready(None),
1816        }
1817    }
1818}
1819
1820#[derive(Debug)]
1821pub enum InputMethodEditorClientEvent {}
1822
1823impl InputMethodEditorClientEvent {
1824    /// Decodes a message buffer as a [`InputMethodEditorClientEvent`].
1825    fn decode(
1826        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1827    ) -> Result<InputMethodEditorClientEvent, fidl::Error> {
1828        let (bytes, _handles) = buf.split_mut();
1829        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1830        debug_assert_eq!(tx_header.tx_id, 0);
1831        match tx_header.ordinal {
1832            _ => Err(fidl::Error::UnknownOrdinal {
1833                ordinal: tx_header.ordinal,
1834                protocol_name:
1835                    <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1836            }),
1837        }
1838    }
1839}
1840
1841/// A Stream of incoming requests for fuchsia.ui.input/InputMethodEditorClient.
1842pub struct InputMethodEditorClientRequestStream {
1843    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1844    is_terminated: bool,
1845}
1846
1847impl std::marker::Unpin for InputMethodEditorClientRequestStream {}
1848
1849impl futures::stream::FusedStream for InputMethodEditorClientRequestStream {
1850    fn is_terminated(&self) -> bool {
1851        self.is_terminated
1852    }
1853}
1854
1855impl fidl::endpoints::RequestStream for InputMethodEditorClientRequestStream {
1856    type Protocol = InputMethodEditorClientMarker;
1857    type ControlHandle = InputMethodEditorClientControlHandle;
1858
1859    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1860        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1861    }
1862
1863    fn control_handle(&self) -> Self::ControlHandle {
1864        InputMethodEditorClientControlHandle { inner: self.inner.clone() }
1865    }
1866
1867    fn into_inner(
1868        self,
1869    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1870    {
1871        (self.inner, self.is_terminated)
1872    }
1873
1874    fn from_inner(
1875        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1876        is_terminated: bool,
1877    ) -> Self {
1878        Self { inner, is_terminated }
1879    }
1880}
1881
1882impl futures::Stream for InputMethodEditorClientRequestStream {
1883    type Item = Result<InputMethodEditorClientRequest, fidl::Error>;
1884
1885    fn poll_next(
1886        mut self: std::pin::Pin<&mut Self>,
1887        cx: &mut std::task::Context<'_>,
1888    ) -> std::task::Poll<Option<Self::Item>> {
1889        let this = &mut *self;
1890        if this.inner.check_shutdown(cx) {
1891            this.is_terminated = true;
1892            return std::task::Poll::Ready(None);
1893        }
1894        if this.is_terminated {
1895            panic!("polled InputMethodEditorClientRequestStream after completion");
1896        }
1897        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1898            |bytes, handles| {
1899                match this.inner.channel().read_etc(cx, bytes, handles) {
1900                    std::task::Poll::Ready(Ok(())) => {}
1901                    std::task::Poll::Pending => return std::task::Poll::Pending,
1902                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1903                        this.is_terminated = true;
1904                        return std::task::Poll::Ready(None);
1905                    }
1906                    std::task::Poll::Ready(Err(e)) => {
1907                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1908                            e.into(),
1909                        ))));
1910                    }
1911                }
1912
1913                // A message has been received from the channel
1914                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1915
1916                std::task::Poll::Ready(Some(match header.ordinal {
1917                0x26681a6b204b679d => {
1918                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1919                    let mut req = fidl::new_empty!(InputMethodEditorClientDidUpdateStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1920                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorClientDidUpdateStateRequest>(&header, _body_bytes, handles, &mut req)?;
1921                    let control_handle = InputMethodEditorClientControlHandle {
1922                        inner: this.inner.clone(),
1923                    };
1924                    Ok(InputMethodEditorClientRequest::DidUpdateState {state: req.state,
1925event: req.event,
1926
1927                        control_handle,
1928                    })
1929                }
1930                0x19c420f173275398 => {
1931                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1932                    let mut req = fidl::new_empty!(InputMethodEditorClientOnActionRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1933                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorClientOnActionRequest>(&header, _body_bytes, handles, &mut req)?;
1934                    let control_handle = InputMethodEditorClientControlHandle {
1935                        inner: this.inner.clone(),
1936                    };
1937                    Ok(InputMethodEditorClientRequest::OnAction {action: req.action,
1938
1939                        control_handle,
1940                    })
1941                }
1942                _ => Err(fidl::Error::UnknownOrdinal {
1943                    ordinal: header.ordinal,
1944                    protocol_name: <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1945                }),
1946            }))
1947            },
1948        )
1949    }
1950}
1951
1952/// An interface to receive information from `TextInputService`.
1953#[derive(Debug)]
1954pub enum InputMethodEditorClientRequest {
1955    DidUpdateState {
1956        state: TextInputState,
1957        event: Option<Box<InputEvent>>,
1958        control_handle: InputMethodEditorClientControlHandle,
1959    },
1960    OnAction {
1961        action: InputMethodAction,
1962        control_handle: InputMethodEditorClientControlHandle,
1963    },
1964}
1965
1966impl InputMethodEditorClientRequest {
1967    #[allow(irrefutable_let_patterns)]
1968    pub fn into_did_update_state(
1969        self,
1970    ) -> Option<(TextInputState, Option<Box<InputEvent>>, InputMethodEditorClientControlHandle)>
1971    {
1972        if let InputMethodEditorClientRequest::DidUpdateState { state, event, control_handle } =
1973            self
1974        {
1975            Some((state, event, control_handle))
1976        } else {
1977            None
1978        }
1979    }
1980
1981    #[allow(irrefutable_let_patterns)]
1982    pub fn into_on_action(
1983        self,
1984    ) -> Option<(InputMethodAction, InputMethodEditorClientControlHandle)> {
1985        if let InputMethodEditorClientRequest::OnAction { action, control_handle } = self {
1986            Some((action, control_handle))
1987        } else {
1988            None
1989        }
1990    }
1991
1992    /// Name of the method defined in FIDL
1993    pub fn method_name(&self) -> &'static str {
1994        match *self {
1995            InputMethodEditorClientRequest::DidUpdateState { .. } => "did_update_state",
1996            InputMethodEditorClientRequest::OnAction { .. } => "on_action",
1997        }
1998    }
1999}
2000
2001#[derive(Debug, Clone)]
2002pub struct InputMethodEditorClientControlHandle {
2003    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2004}
2005
2006impl fidl::endpoints::ControlHandle for InputMethodEditorClientControlHandle {
2007    fn shutdown(&self) {
2008        self.inner.shutdown()
2009    }
2010
2011    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2012        self.inner.shutdown_with_epitaph(status)
2013    }
2014
2015    fn is_closed(&self) -> bool {
2016        self.inner.channel().is_closed()
2017    }
2018    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2019        self.inner.channel().on_closed()
2020    }
2021
2022    #[cfg(target_os = "fuchsia")]
2023    fn signal_peer(
2024        &self,
2025        clear_mask: zx::Signals,
2026        set_mask: zx::Signals,
2027    ) -> Result<(), zx_status::Status> {
2028        use fidl::Peered;
2029        self.inner.channel().signal_peer(clear_mask, set_mask)
2030    }
2031}
2032
2033impl InputMethodEditorClientControlHandle {}
2034
2035mod internal {
2036    use super::*;
2037
2038    impl fidl::encoding::ResourceTypeMarker for ImeServiceGetInputMethodEditorRequest {
2039        type Borrowed<'a> = &'a mut Self;
2040        fn take_or_borrow<'a>(
2041            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2042        ) -> Self::Borrowed<'a> {
2043            value
2044        }
2045    }
2046
2047    unsafe impl fidl::encoding::TypeMarker for ImeServiceGetInputMethodEditorRequest {
2048        type Owned = Self;
2049
2050        #[inline(always)]
2051        fn inline_align(_context: fidl::encoding::Context) -> usize {
2052            8
2053        }
2054
2055        #[inline(always)]
2056        fn inline_size(_context: fidl::encoding::Context) -> usize {
2057            80
2058        }
2059    }
2060
2061    unsafe impl
2062        fidl::encoding::Encode<
2063            ImeServiceGetInputMethodEditorRequest,
2064            fidl::encoding::DefaultFuchsiaResourceDialect,
2065        > for &mut ImeServiceGetInputMethodEditorRequest
2066    {
2067        #[inline]
2068        unsafe fn encode(
2069            self,
2070            encoder: &mut fidl::encoding::Encoder<
2071                '_,
2072                fidl::encoding::DefaultFuchsiaResourceDialect,
2073            >,
2074            offset: usize,
2075            _depth: fidl::encoding::Depth,
2076        ) -> fidl::Result<()> {
2077            encoder.debug_check_bounds::<ImeServiceGetInputMethodEditorRequest>(offset);
2078            // Delegate to tuple encoding.
2079            fidl::encoding::Encode::<ImeServiceGetInputMethodEditorRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2080                (
2081                    <KeyboardType as fidl::encoding::ValueTypeMarker>::borrow(&self.keyboard_type),
2082                    <InputMethodAction as fidl::encoding::ValueTypeMarker>::borrow(&self.action),
2083                    <TextInputState as fidl::encoding::ValueTypeMarker>::borrow(&self.initial_state),
2084                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.client),
2085                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.editor),
2086                ),
2087                encoder, offset, _depth
2088            )
2089        }
2090    }
2091    unsafe impl<
2092        T0: fidl::encoding::Encode<KeyboardType, fidl::encoding::DefaultFuchsiaResourceDialect>,
2093        T1: fidl::encoding::Encode<InputMethodAction, fidl::encoding::DefaultFuchsiaResourceDialect>,
2094        T2: fidl::encoding::Encode<TextInputState, fidl::encoding::DefaultFuchsiaResourceDialect>,
2095        T3: fidl::encoding::Encode<
2096                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>>,
2097                fidl::encoding::DefaultFuchsiaResourceDialect,
2098            >,
2099        T4: fidl::encoding::Encode<
2100                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
2101                fidl::encoding::DefaultFuchsiaResourceDialect,
2102            >,
2103    >
2104        fidl::encoding::Encode<
2105            ImeServiceGetInputMethodEditorRequest,
2106            fidl::encoding::DefaultFuchsiaResourceDialect,
2107        > for (T0, T1, T2, T3, T4)
2108    {
2109        #[inline]
2110        unsafe fn encode(
2111            self,
2112            encoder: &mut fidl::encoding::Encoder<
2113                '_,
2114                fidl::encoding::DefaultFuchsiaResourceDialect,
2115            >,
2116            offset: usize,
2117            depth: fidl::encoding::Depth,
2118        ) -> fidl::Result<()> {
2119            encoder.debug_check_bounds::<ImeServiceGetInputMethodEditorRequest>(offset);
2120            // Zero out padding regions. There's no need to apply masks
2121            // because the unmasked parts will be overwritten by fields.
2122            // Write the fields.
2123            self.0.encode(encoder, offset + 0, depth)?;
2124            self.1.encode(encoder, offset + 4, depth)?;
2125            self.2.encode(encoder, offset + 8, depth)?;
2126            self.3.encode(encoder, offset + 72, depth)?;
2127            self.4.encode(encoder, offset + 76, depth)?;
2128            Ok(())
2129        }
2130    }
2131
2132    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2133        for ImeServiceGetInputMethodEditorRequest
2134    {
2135        #[inline(always)]
2136        fn new_empty() -> Self {
2137            Self {
2138                keyboard_type: fidl::new_empty!(
2139                    KeyboardType,
2140                    fidl::encoding::DefaultFuchsiaResourceDialect
2141                ),
2142                action: fidl::new_empty!(
2143                    InputMethodAction,
2144                    fidl::encoding::DefaultFuchsiaResourceDialect
2145                ),
2146                initial_state: fidl::new_empty!(
2147                    TextInputState,
2148                    fidl::encoding::DefaultFuchsiaResourceDialect
2149                ),
2150                client: fidl::new_empty!(
2151                    fidl::encoding::Endpoint<
2152                        fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
2153                    >,
2154                    fidl::encoding::DefaultFuchsiaResourceDialect
2155                ),
2156                editor: fidl::new_empty!(
2157                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
2158                    fidl::encoding::DefaultFuchsiaResourceDialect
2159                ),
2160            }
2161        }
2162
2163        #[inline]
2164        unsafe fn decode(
2165            &mut self,
2166            decoder: &mut fidl::encoding::Decoder<
2167                '_,
2168                fidl::encoding::DefaultFuchsiaResourceDialect,
2169            >,
2170            offset: usize,
2171            _depth: fidl::encoding::Depth,
2172        ) -> fidl::Result<()> {
2173            decoder.debug_check_bounds::<Self>(offset);
2174            // Verify that padding bytes are zero.
2175            fidl::decode!(
2176                KeyboardType,
2177                fidl::encoding::DefaultFuchsiaResourceDialect,
2178                &mut self.keyboard_type,
2179                decoder,
2180                offset + 0,
2181                _depth
2182            )?;
2183            fidl::decode!(
2184                InputMethodAction,
2185                fidl::encoding::DefaultFuchsiaResourceDialect,
2186                &mut self.action,
2187                decoder,
2188                offset + 4,
2189                _depth
2190            )?;
2191            fidl::decode!(
2192                TextInputState,
2193                fidl::encoding::DefaultFuchsiaResourceDialect,
2194                &mut self.initial_state,
2195                decoder,
2196                offset + 8,
2197                _depth
2198            )?;
2199            fidl::decode!(
2200                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>>,
2201                fidl::encoding::DefaultFuchsiaResourceDialect,
2202                &mut self.client,
2203                decoder,
2204                offset + 72,
2205                _depth
2206            )?;
2207            fidl::decode!(
2208                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
2209                fidl::encoding::DefaultFuchsiaResourceDialect,
2210                &mut self.editor,
2211                decoder,
2212                offset + 76,
2213                _depth
2214            )?;
2215            Ok(())
2216        }
2217    }
2218
2219    impl MediaButtonsEvent {
2220        #[inline(always)]
2221        fn max_ordinal_present(&self) -> u64 {
2222            if let Some(_) = self.wake_lease {
2223                return 8;
2224            }
2225            if let Some(_) = self.device_id {
2226                return 7;
2227            }
2228            if let Some(_) = self.function {
2229                return 6;
2230            }
2231            if let Some(_) = self.power {
2232                return 5;
2233            }
2234            if let Some(_) = self.camera_disable {
2235                return 4;
2236            }
2237            if let Some(_) = self.pause {
2238                return 3;
2239            }
2240            if let Some(_) = self.mic_mute {
2241                return 2;
2242            }
2243            if let Some(_) = self.volume {
2244                return 1;
2245            }
2246            0
2247        }
2248    }
2249
2250    impl fidl::encoding::ResourceTypeMarker for MediaButtonsEvent {
2251        type Borrowed<'a> = &'a mut Self;
2252        fn take_or_borrow<'a>(
2253            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2254        ) -> Self::Borrowed<'a> {
2255            value
2256        }
2257    }
2258
2259    unsafe impl fidl::encoding::TypeMarker for MediaButtonsEvent {
2260        type Owned = Self;
2261
2262        #[inline(always)]
2263        fn inline_align(_context: fidl::encoding::Context) -> usize {
2264            8
2265        }
2266
2267        #[inline(always)]
2268        fn inline_size(_context: fidl::encoding::Context) -> usize {
2269            16
2270        }
2271    }
2272
2273    unsafe impl
2274        fidl::encoding::Encode<MediaButtonsEvent, fidl::encoding::DefaultFuchsiaResourceDialect>
2275        for &mut MediaButtonsEvent
2276    {
2277        unsafe fn encode(
2278            self,
2279            encoder: &mut fidl::encoding::Encoder<
2280                '_,
2281                fidl::encoding::DefaultFuchsiaResourceDialect,
2282            >,
2283            offset: usize,
2284            mut depth: fidl::encoding::Depth,
2285        ) -> fidl::Result<()> {
2286            encoder.debug_check_bounds::<MediaButtonsEvent>(offset);
2287            // Vector header
2288            let max_ordinal: u64 = self.max_ordinal_present();
2289            encoder.write_num(max_ordinal, offset);
2290            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2291            // Calling encoder.out_of_line_offset(0) is not allowed.
2292            if max_ordinal == 0 {
2293                return Ok(());
2294            }
2295            depth.increment()?;
2296            let envelope_size = 8;
2297            let bytes_len = max_ordinal as usize * envelope_size;
2298            #[allow(unused_variables)]
2299            let offset = encoder.out_of_line_offset(bytes_len);
2300            let mut _prev_end_offset: usize = 0;
2301            if 1 > max_ordinal {
2302                return Ok(());
2303            }
2304
2305            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2306            // are envelope_size bytes.
2307            let cur_offset: usize = (1 - 1) * envelope_size;
2308
2309            // Zero reserved fields.
2310            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2311
2312            // Safety:
2313            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2314            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2315            //   envelope_size bytes, there is always sufficient room.
2316            fidl::encoding::encode_in_envelope_optional::<
2317                i8,
2318                fidl::encoding::DefaultFuchsiaResourceDialect,
2319            >(
2320                self.volume.as_ref().map(<i8 as fidl::encoding::ValueTypeMarker>::borrow),
2321                encoder,
2322                offset + cur_offset,
2323                depth,
2324            )?;
2325
2326            _prev_end_offset = cur_offset + envelope_size;
2327            if 2 > max_ordinal {
2328                return Ok(());
2329            }
2330
2331            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2332            // are envelope_size bytes.
2333            let cur_offset: usize = (2 - 1) * envelope_size;
2334
2335            // Zero reserved fields.
2336            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2337
2338            // Safety:
2339            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2340            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2341            //   envelope_size bytes, there is always sufficient room.
2342            fidl::encoding::encode_in_envelope_optional::<
2343                bool,
2344                fidl::encoding::DefaultFuchsiaResourceDialect,
2345            >(
2346                self.mic_mute.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2347                encoder,
2348                offset + cur_offset,
2349                depth,
2350            )?;
2351
2352            _prev_end_offset = cur_offset + envelope_size;
2353            if 3 > max_ordinal {
2354                return Ok(());
2355            }
2356
2357            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2358            // are envelope_size bytes.
2359            let cur_offset: usize = (3 - 1) * envelope_size;
2360
2361            // Zero reserved fields.
2362            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2363
2364            // Safety:
2365            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2366            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2367            //   envelope_size bytes, there is always sufficient room.
2368            fidl::encoding::encode_in_envelope_optional::<
2369                bool,
2370                fidl::encoding::DefaultFuchsiaResourceDialect,
2371            >(
2372                self.pause.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2373                encoder,
2374                offset + cur_offset,
2375                depth,
2376            )?;
2377
2378            _prev_end_offset = cur_offset + envelope_size;
2379            if 4 > max_ordinal {
2380                return Ok(());
2381            }
2382
2383            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2384            // are envelope_size bytes.
2385            let cur_offset: usize = (4 - 1) * envelope_size;
2386
2387            // Zero reserved fields.
2388            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2389
2390            // Safety:
2391            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2392            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2393            //   envelope_size bytes, there is always sufficient room.
2394            fidl::encoding::encode_in_envelope_optional::<
2395                bool,
2396                fidl::encoding::DefaultFuchsiaResourceDialect,
2397            >(
2398                self.camera_disable.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2399                encoder,
2400                offset + cur_offset,
2401                depth,
2402            )?;
2403
2404            _prev_end_offset = cur_offset + envelope_size;
2405            if 5 > max_ordinal {
2406                return Ok(());
2407            }
2408
2409            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2410            // are envelope_size bytes.
2411            let cur_offset: usize = (5 - 1) * envelope_size;
2412
2413            // Zero reserved fields.
2414            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2415
2416            // Safety:
2417            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2418            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2419            //   envelope_size bytes, there is always sufficient room.
2420            fidl::encoding::encode_in_envelope_optional::<
2421                bool,
2422                fidl::encoding::DefaultFuchsiaResourceDialect,
2423            >(
2424                self.power.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2425                encoder,
2426                offset + cur_offset,
2427                depth,
2428            )?;
2429
2430            _prev_end_offset = cur_offset + envelope_size;
2431            if 6 > max_ordinal {
2432                return Ok(());
2433            }
2434
2435            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2436            // are envelope_size bytes.
2437            let cur_offset: usize = (6 - 1) * envelope_size;
2438
2439            // Zero reserved fields.
2440            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2441
2442            // Safety:
2443            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2444            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2445            //   envelope_size bytes, there is always sufficient room.
2446            fidl::encoding::encode_in_envelope_optional::<
2447                bool,
2448                fidl::encoding::DefaultFuchsiaResourceDialect,
2449            >(
2450                self.function.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2451                encoder,
2452                offset + cur_offset,
2453                depth,
2454            )?;
2455
2456            _prev_end_offset = cur_offset + envelope_size;
2457            if 7 > max_ordinal {
2458                return Ok(());
2459            }
2460
2461            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2462            // are envelope_size bytes.
2463            let cur_offset: usize = (7 - 1) * envelope_size;
2464
2465            // Zero reserved fields.
2466            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2467
2468            // Safety:
2469            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2470            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2471            //   envelope_size bytes, there is always sufficient room.
2472            fidl::encoding::encode_in_envelope_optional::<
2473                u32,
2474                fidl::encoding::DefaultFuchsiaResourceDialect,
2475            >(
2476                self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2477                encoder,
2478                offset + cur_offset,
2479                depth,
2480            )?;
2481
2482            _prev_end_offset = cur_offset + envelope_size;
2483            if 8 > max_ordinal {
2484                return Ok(());
2485            }
2486
2487            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2488            // are envelope_size bytes.
2489            let cur_offset: usize = (8 - 1) * envelope_size;
2490
2491            // Zero reserved fields.
2492            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2493
2494            // Safety:
2495            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2496            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2497            //   envelope_size bytes, there is always sufficient room.
2498            fidl::encoding::encode_in_envelope_optional::<
2499                fidl::encoding::HandleType<
2500                    fidl::EventPair,
2501                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2502                    2147483648,
2503                >,
2504                fidl::encoding::DefaultFuchsiaResourceDialect,
2505            >(
2506                self.wake_lease.as_mut().map(
2507                    <fidl::encoding::HandleType<
2508                        fidl::EventPair,
2509                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2510                        2147483648,
2511                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2512                ),
2513                encoder,
2514                offset + cur_offset,
2515                depth,
2516            )?;
2517
2518            _prev_end_offset = cur_offset + envelope_size;
2519
2520            Ok(())
2521        }
2522    }
2523
2524    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2525        for MediaButtonsEvent
2526    {
2527        #[inline(always)]
2528        fn new_empty() -> Self {
2529            Self::default()
2530        }
2531
2532        unsafe fn decode(
2533            &mut self,
2534            decoder: &mut fidl::encoding::Decoder<
2535                '_,
2536                fidl::encoding::DefaultFuchsiaResourceDialect,
2537            >,
2538            offset: usize,
2539            mut depth: fidl::encoding::Depth,
2540        ) -> fidl::Result<()> {
2541            decoder.debug_check_bounds::<Self>(offset);
2542            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2543                None => return Err(fidl::Error::NotNullable),
2544                Some(len) => len,
2545            };
2546            // Calling decoder.out_of_line_offset(0) is not allowed.
2547            if len == 0 {
2548                return Ok(());
2549            };
2550            depth.increment()?;
2551            let envelope_size = 8;
2552            let bytes_len = len * envelope_size;
2553            let offset = decoder.out_of_line_offset(bytes_len)?;
2554            // Decode the envelope for each type.
2555            let mut _next_ordinal_to_read = 0;
2556            let mut next_offset = offset;
2557            let end_offset = offset + bytes_len;
2558            _next_ordinal_to_read += 1;
2559            if next_offset >= end_offset {
2560                return Ok(());
2561            }
2562
2563            // Decode unknown envelopes for gaps in ordinals.
2564            while _next_ordinal_to_read < 1 {
2565                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2566                _next_ordinal_to_read += 1;
2567                next_offset += envelope_size;
2568            }
2569
2570            let next_out_of_line = decoder.next_out_of_line();
2571            let handles_before = decoder.remaining_handles();
2572            if let Some((inlined, num_bytes, num_handles)) =
2573                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2574            {
2575                let member_inline_size =
2576                    <i8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2577                if inlined != (member_inline_size <= 4) {
2578                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2579                }
2580                let inner_offset;
2581                let mut inner_depth = depth.clone();
2582                if inlined {
2583                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2584                    inner_offset = next_offset;
2585                } else {
2586                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2587                    inner_depth.increment()?;
2588                }
2589                let val_ref = self.volume.get_or_insert_with(|| {
2590                    fidl::new_empty!(i8, fidl::encoding::DefaultFuchsiaResourceDialect)
2591                });
2592                fidl::decode!(
2593                    i8,
2594                    fidl::encoding::DefaultFuchsiaResourceDialect,
2595                    val_ref,
2596                    decoder,
2597                    inner_offset,
2598                    inner_depth
2599                )?;
2600                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2601                {
2602                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2603                }
2604                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2605                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2606                }
2607            }
2608
2609            next_offset += envelope_size;
2610            _next_ordinal_to_read += 1;
2611            if next_offset >= end_offset {
2612                return Ok(());
2613            }
2614
2615            // Decode unknown envelopes for gaps in ordinals.
2616            while _next_ordinal_to_read < 2 {
2617                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2618                _next_ordinal_to_read += 1;
2619                next_offset += envelope_size;
2620            }
2621
2622            let next_out_of_line = decoder.next_out_of_line();
2623            let handles_before = decoder.remaining_handles();
2624            if let Some((inlined, num_bytes, num_handles)) =
2625                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2626            {
2627                let member_inline_size =
2628                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2629                if inlined != (member_inline_size <= 4) {
2630                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2631                }
2632                let inner_offset;
2633                let mut inner_depth = depth.clone();
2634                if inlined {
2635                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2636                    inner_offset = next_offset;
2637                } else {
2638                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2639                    inner_depth.increment()?;
2640                }
2641                let val_ref = self.mic_mute.get_or_insert_with(|| {
2642                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2643                });
2644                fidl::decode!(
2645                    bool,
2646                    fidl::encoding::DefaultFuchsiaResourceDialect,
2647                    val_ref,
2648                    decoder,
2649                    inner_offset,
2650                    inner_depth
2651                )?;
2652                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2653                {
2654                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2655                }
2656                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2657                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2658                }
2659            }
2660
2661            next_offset += envelope_size;
2662            _next_ordinal_to_read += 1;
2663            if next_offset >= end_offset {
2664                return Ok(());
2665            }
2666
2667            // Decode unknown envelopes for gaps in ordinals.
2668            while _next_ordinal_to_read < 3 {
2669                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2670                _next_ordinal_to_read += 1;
2671                next_offset += envelope_size;
2672            }
2673
2674            let next_out_of_line = decoder.next_out_of_line();
2675            let handles_before = decoder.remaining_handles();
2676            if let Some((inlined, num_bytes, num_handles)) =
2677                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2678            {
2679                let member_inline_size =
2680                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2681                if inlined != (member_inline_size <= 4) {
2682                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2683                }
2684                let inner_offset;
2685                let mut inner_depth = depth.clone();
2686                if inlined {
2687                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2688                    inner_offset = next_offset;
2689                } else {
2690                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2691                    inner_depth.increment()?;
2692                }
2693                let val_ref = self.pause.get_or_insert_with(|| {
2694                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2695                });
2696                fidl::decode!(
2697                    bool,
2698                    fidl::encoding::DefaultFuchsiaResourceDialect,
2699                    val_ref,
2700                    decoder,
2701                    inner_offset,
2702                    inner_depth
2703                )?;
2704                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2705                {
2706                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2707                }
2708                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2709                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2710                }
2711            }
2712
2713            next_offset += envelope_size;
2714            _next_ordinal_to_read += 1;
2715            if next_offset >= end_offset {
2716                return Ok(());
2717            }
2718
2719            // Decode unknown envelopes for gaps in ordinals.
2720            while _next_ordinal_to_read < 4 {
2721                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2722                _next_ordinal_to_read += 1;
2723                next_offset += envelope_size;
2724            }
2725
2726            let next_out_of_line = decoder.next_out_of_line();
2727            let handles_before = decoder.remaining_handles();
2728            if let Some((inlined, num_bytes, num_handles)) =
2729                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2730            {
2731                let member_inline_size =
2732                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2733                if inlined != (member_inline_size <= 4) {
2734                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2735                }
2736                let inner_offset;
2737                let mut inner_depth = depth.clone();
2738                if inlined {
2739                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2740                    inner_offset = next_offset;
2741                } else {
2742                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2743                    inner_depth.increment()?;
2744                }
2745                let val_ref = self.camera_disable.get_or_insert_with(|| {
2746                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2747                });
2748                fidl::decode!(
2749                    bool,
2750                    fidl::encoding::DefaultFuchsiaResourceDialect,
2751                    val_ref,
2752                    decoder,
2753                    inner_offset,
2754                    inner_depth
2755                )?;
2756                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2757                {
2758                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2759                }
2760                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2761                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2762                }
2763            }
2764
2765            next_offset += envelope_size;
2766            _next_ordinal_to_read += 1;
2767            if next_offset >= end_offset {
2768                return Ok(());
2769            }
2770
2771            // Decode unknown envelopes for gaps in ordinals.
2772            while _next_ordinal_to_read < 5 {
2773                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2774                _next_ordinal_to_read += 1;
2775                next_offset += envelope_size;
2776            }
2777
2778            let next_out_of_line = decoder.next_out_of_line();
2779            let handles_before = decoder.remaining_handles();
2780            if let Some((inlined, num_bytes, num_handles)) =
2781                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2782            {
2783                let member_inline_size =
2784                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2785                if inlined != (member_inline_size <= 4) {
2786                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2787                }
2788                let inner_offset;
2789                let mut inner_depth = depth.clone();
2790                if inlined {
2791                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2792                    inner_offset = next_offset;
2793                } else {
2794                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2795                    inner_depth.increment()?;
2796                }
2797                let val_ref = self.power.get_or_insert_with(|| {
2798                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2799                });
2800                fidl::decode!(
2801                    bool,
2802                    fidl::encoding::DefaultFuchsiaResourceDialect,
2803                    val_ref,
2804                    decoder,
2805                    inner_offset,
2806                    inner_depth
2807                )?;
2808                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2809                {
2810                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2811                }
2812                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2813                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2814                }
2815            }
2816
2817            next_offset += envelope_size;
2818            _next_ordinal_to_read += 1;
2819            if next_offset >= end_offset {
2820                return Ok(());
2821            }
2822
2823            // Decode unknown envelopes for gaps in ordinals.
2824            while _next_ordinal_to_read < 6 {
2825                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2826                _next_ordinal_to_read += 1;
2827                next_offset += envelope_size;
2828            }
2829
2830            let next_out_of_line = decoder.next_out_of_line();
2831            let handles_before = decoder.remaining_handles();
2832            if let Some((inlined, num_bytes, num_handles)) =
2833                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2834            {
2835                let member_inline_size =
2836                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2837                if inlined != (member_inline_size <= 4) {
2838                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2839                }
2840                let inner_offset;
2841                let mut inner_depth = depth.clone();
2842                if inlined {
2843                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2844                    inner_offset = next_offset;
2845                } else {
2846                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2847                    inner_depth.increment()?;
2848                }
2849                let val_ref = self.function.get_or_insert_with(|| {
2850                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2851                });
2852                fidl::decode!(
2853                    bool,
2854                    fidl::encoding::DefaultFuchsiaResourceDialect,
2855                    val_ref,
2856                    decoder,
2857                    inner_offset,
2858                    inner_depth
2859                )?;
2860                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2861                {
2862                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2863                }
2864                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2865                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2866                }
2867            }
2868
2869            next_offset += envelope_size;
2870            _next_ordinal_to_read += 1;
2871            if next_offset >= end_offset {
2872                return Ok(());
2873            }
2874
2875            // Decode unknown envelopes for gaps in ordinals.
2876            while _next_ordinal_to_read < 7 {
2877                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2878                _next_ordinal_to_read += 1;
2879                next_offset += envelope_size;
2880            }
2881
2882            let next_out_of_line = decoder.next_out_of_line();
2883            let handles_before = decoder.remaining_handles();
2884            if let Some((inlined, num_bytes, num_handles)) =
2885                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2886            {
2887                let member_inline_size =
2888                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2889                if inlined != (member_inline_size <= 4) {
2890                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2891                }
2892                let inner_offset;
2893                let mut inner_depth = depth.clone();
2894                if inlined {
2895                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2896                    inner_offset = next_offset;
2897                } else {
2898                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2899                    inner_depth.increment()?;
2900                }
2901                let val_ref = self.device_id.get_or_insert_with(|| {
2902                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
2903                });
2904                fidl::decode!(
2905                    u32,
2906                    fidl::encoding::DefaultFuchsiaResourceDialect,
2907                    val_ref,
2908                    decoder,
2909                    inner_offset,
2910                    inner_depth
2911                )?;
2912                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2913                {
2914                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2915                }
2916                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2917                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2918                }
2919            }
2920
2921            next_offset += envelope_size;
2922            _next_ordinal_to_read += 1;
2923            if next_offset >= end_offset {
2924                return Ok(());
2925            }
2926
2927            // Decode unknown envelopes for gaps in ordinals.
2928            while _next_ordinal_to_read < 8 {
2929                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2930                _next_ordinal_to_read += 1;
2931                next_offset += envelope_size;
2932            }
2933
2934            let next_out_of_line = decoder.next_out_of_line();
2935            let handles_before = decoder.remaining_handles();
2936            if let Some((inlined, num_bytes, num_handles)) =
2937                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2938            {
2939                let member_inline_size = <fidl::encoding::HandleType<
2940                    fidl::EventPair,
2941                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2942                    2147483648,
2943                > as fidl::encoding::TypeMarker>::inline_size(
2944                    decoder.context
2945                );
2946                if inlined != (member_inline_size <= 4) {
2947                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2948                }
2949                let inner_offset;
2950                let mut inner_depth = depth.clone();
2951                if inlined {
2952                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2953                    inner_offset = next_offset;
2954                } else {
2955                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2956                    inner_depth.increment()?;
2957                }
2958                let val_ref =
2959                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2960                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2961                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2962                {
2963                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2964                }
2965                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2966                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2967                }
2968            }
2969
2970            next_offset += envelope_size;
2971
2972            // Decode the remaining unknown envelopes.
2973            while next_offset < end_offset {
2974                _next_ordinal_to_read += 1;
2975                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2976                next_offset += envelope_size;
2977            }
2978
2979            Ok(())
2980        }
2981    }
2982
2983    impl TouchButtonsEvent {
2984        #[inline(always)]
2985        fn max_ordinal_present(&self) -> u64 {
2986            if let Some(_) = self.trace_flow_id {
2987                return 5;
2988            }
2989            if let Some(_) = self.wake_lease {
2990                return 4;
2991            }
2992            if let Some(_) = self.pressed_buttons {
2993                return 3;
2994            }
2995            if let Some(_) = self.device_info {
2996                return 2;
2997            }
2998            if let Some(_) = self.event_time {
2999                return 1;
3000            }
3001            0
3002        }
3003    }
3004
3005    impl fidl::encoding::ResourceTypeMarker for TouchButtonsEvent {
3006        type Borrowed<'a> = &'a mut Self;
3007        fn take_or_borrow<'a>(
3008            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3009        ) -> Self::Borrowed<'a> {
3010            value
3011        }
3012    }
3013
3014    unsafe impl fidl::encoding::TypeMarker for TouchButtonsEvent {
3015        type Owned = Self;
3016
3017        #[inline(always)]
3018        fn inline_align(_context: fidl::encoding::Context) -> usize {
3019            8
3020        }
3021
3022        #[inline(always)]
3023        fn inline_size(_context: fidl::encoding::Context) -> usize {
3024            16
3025        }
3026    }
3027
3028    unsafe impl
3029        fidl::encoding::Encode<TouchButtonsEvent, fidl::encoding::DefaultFuchsiaResourceDialect>
3030        for &mut TouchButtonsEvent
3031    {
3032        unsafe fn encode(
3033            self,
3034            encoder: &mut fidl::encoding::Encoder<
3035                '_,
3036                fidl::encoding::DefaultFuchsiaResourceDialect,
3037            >,
3038            offset: usize,
3039            mut depth: fidl::encoding::Depth,
3040        ) -> fidl::Result<()> {
3041            encoder.debug_check_bounds::<TouchButtonsEvent>(offset);
3042            // Vector header
3043            let max_ordinal: u64 = self.max_ordinal_present();
3044            encoder.write_num(max_ordinal, offset);
3045            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3046            // Calling encoder.out_of_line_offset(0) is not allowed.
3047            if max_ordinal == 0 {
3048                return Ok(());
3049            }
3050            depth.increment()?;
3051            let envelope_size = 8;
3052            let bytes_len = max_ordinal as usize * envelope_size;
3053            #[allow(unused_variables)]
3054            let offset = encoder.out_of_line_offset(bytes_len);
3055            let mut _prev_end_offset: usize = 0;
3056            if 1 > max_ordinal {
3057                return Ok(());
3058            }
3059
3060            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3061            // are envelope_size bytes.
3062            let cur_offset: usize = (1 - 1) * envelope_size;
3063
3064            // Zero reserved fields.
3065            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3066
3067            // Safety:
3068            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3069            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3070            //   envelope_size bytes, there is always sufficient room.
3071            fidl::encoding::encode_in_envelope_optional::<
3072                fidl::MonotonicInstant,
3073                fidl::encoding::DefaultFuchsiaResourceDialect,
3074            >(
3075                self.event_time
3076                    .as_ref()
3077                    .map(<fidl::MonotonicInstant as fidl::encoding::ValueTypeMarker>::borrow),
3078                encoder,
3079                offset + cur_offset,
3080                depth,
3081            )?;
3082
3083            _prev_end_offset = cur_offset + envelope_size;
3084            if 2 > max_ordinal {
3085                return Ok(());
3086            }
3087
3088            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3089            // are envelope_size bytes.
3090            let cur_offset: usize = (2 - 1) * envelope_size;
3091
3092            // Zero reserved fields.
3093            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3094
3095            // Safety:
3096            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3097            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3098            //   envelope_size bytes, there is always sufficient room.
3099            fidl::encoding::encode_in_envelope_optional::<
3100                TouchDeviceInfo,
3101                fidl::encoding::DefaultFuchsiaResourceDialect,
3102            >(
3103                self.device_info
3104                    .as_ref()
3105                    .map(<TouchDeviceInfo as fidl::encoding::ValueTypeMarker>::borrow),
3106                encoder,
3107                offset + cur_offset,
3108                depth,
3109            )?;
3110
3111            _prev_end_offset = cur_offset + envelope_size;
3112            if 3 > max_ordinal {
3113                return Ok(());
3114            }
3115
3116            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3117            // are envelope_size bytes.
3118            let cur_offset: usize = (3 - 1) * envelope_size;
3119
3120            // Zero reserved fields.
3121            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3122
3123            // Safety:
3124            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3125            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3126            //   envelope_size bytes, there is always sufficient room.
3127            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<TouchButton>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3128            self.pressed_buttons.as_ref().map(<fidl::encoding::UnboundedVector<TouchButton> as fidl::encoding::ValueTypeMarker>::borrow),
3129            encoder, offset + cur_offset, depth
3130        )?;
3131
3132            _prev_end_offset = cur_offset + envelope_size;
3133            if 4 > max_ordinal {
3134                return Ok(());
3135            }
3136
3137            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3138            // are envelope_size bytes.
3139            let cur_offset: usize = (4 - 1) * envelope_size;
3140
3141            // Zero reserved fields.
3142            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3143
3144            // Safety:
3145            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3146            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3147            //   envelope_size bytes, there is always sufficient room.
3148            fidl::encoding::encode_in_envelope_optional::<
3149                fidl::encoding::HandleType<
3150                    fidl::EventPair,
3151                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3152                    2147483648,
3153                >,
3154                fidl::encoding::DefaultFuchsiaResourceDialect,
3155            >(
3156                self.wake_lease.as_mut().map(
3157                    <fidl::encoding::HandleType<
3158                        fidl::EventPair,
3159                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3160                        2147483648,
3161                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3162                ),
3163                encoder,
3164                offset + cur_offset,
3165                depth,
3166            )?;
3167
3168            _prev_end_offset = cur_offset + envelope_size;
3169            if 5 > max_ordinal {
3170                return Ok(());
3171            }
3172
3173            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3174            // are envelope_size bytes.
3175            let cur_offset: usize = (5 - 1) * envelope_size;
3176
3177            // Zero reserved fields.
3178            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3179
3180            // Safety:
3181            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3182            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3183            //   envelope_size bytes, there is always sufficient room.
3184            fidl::encoding::encode_in_envelope_optional::<
3185                u64,
3186                fidl::encoding::DefaultFuchsiaResourceDialect,
3187            >(
3188                self.trace_flow_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3189                encoder,
3190                offset + cur_offset,
3191                depth,
3192            )?;
3193
3194            _prev_end_offset = cur_offset + envelope_size;
3195
3196            Ok(())
3197        }
3198    }
3199
3200    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3201        for TouchButtonsEvent
3202    {
3203        #[inline(always)]
3204        fn new_empty() -> Self {
3205            Self::default()
3206        }
3207
3208        unsafe fn decode(
3209            &mut self,
3210            decoder: &mut fidl::encoding::Decoder<
3211                '_,
3212                fidl::encoding::DefaultFuchsiaResourceDialect,
3213            >,
3214            offset: usize,
3215            mut depth: fidl::encoding::Depth,
3216        ) -> fidl::Result<()> {
3217            decoder.debug_check_bounds::<Self>(offset);
3218            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3219                None => return Err(fidl::Error::NotNullable),
3220                Some(len) => len,
3221            };
3222            // Calling decoder.out_of_line_offset(0) is not allowed.
3223            if len == 0 {
3224                return Ok(());
3225            };
3226            depth.increment()?;
3227            let envelope_size = 8;
3228            let bytes_len = len * envelope_size;
3229            let offset = decoder.out_of_line_offset(bytes_len)?;
3230            // Decode the envelope for each type.
3231            let mut _next_ordinal_to_read = 0;
3232            let mut next_offset = offset;
3233            let end_offset = offset + bytes_len;
3234            _next_ordinal_to_read += 1;
3235            if next_offset >= end_offset {
3236                return Ok(());
3237            }
3238
3239            // Decode unknown envelopes for gaps in ordinals.
3240            while _next_ordinal_to_read < 1 {
3241                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3242                _next_ordinal_to_read += 1;
3243                next_offset += envelope_size;
3244            }
3245
3246            let next_out_of_line = decoder.next_out_of_line();
3247            let handles_before = decoder.remaining_handles();
3248            if let Some((inlined, num_bytes, num_handles)) =
3249                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3250            {
3251                let member_inline_size =
3252                    <fidl::MonotonicInstant as fidl::encoding::TypeMarker>::inline_size(
3253                        decoder.context,
3254                    );
3255                if inlined != (member_inline_size <= 4) {
3256                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3257                }
3258                let inner_offset;
3259                let mut inner_depth = depth.clone();
3260                if inlined {
3261                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3262                    inner_offset = next_offset;
3263                } else {
3264                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3265                    inner_depth.increment()?;
3266                }
3267                let val_ref = self.event_time.get_or_insert_with(|| {
3268                    fidl::new_empty!(
3269                        fidl::MonotonicInstant,
3270                        fidl::encoding::DefaultFuchsiaResourceDialect
3271                    )
3272                });
3273                fidl::decode!(
3274                    fidl::MonotonicInstant,
3275                    fidl::encoding::DefaultFuchsiaResourceDialect,
3276                    val_ref,
3277                    decoder,
3278                    inner_offset,
3279                    inner_depth
3280                )?;
3281                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3282                {
3283                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3284                }
3285                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3286                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3287                }
3288            }
3289
3290            next_offset += envelope_size;
3291            _next_ordinal_to_read += 1;
3292            if next_offset >= end_offset {
3293                return Ok(());
3294            }
3295
3296            // Decode unknown envelopes for gaps in ordinals.
3297            while _next_ordinal_to_read < 2 {
3298                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3299                _next_ordinal_to_read += 1;
3300                next_offset += envelope_size;
3301            }
3302
3303            let next_out_of_line = decoder.next_out_of_line();
3304            let handles_before = decoder.remaining_handles();
3305            if let Some((inlined, num_bytes, num_handles)) =
3306                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3307            {
3308                let member_inline_size =
3309                    <TouchDeviceInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3310                if inlined != (member_inline_size <= 4) {
3311                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3312                }
3313                let inner_offset;
3314                let mut inner_depth = depth.clone();
3315                if inlined {
3316                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3317                    inner_offset = next_offset;
3318                } else {
3319                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3320                    inner_depth.increment()?;
3321                }
3322                let val_ref = self.device_info.get_or_insert_with(|| {
3323                    fidl::new_empty!(TouchDeviceInfo, fidl::encoding::DefaultFuchsiaResourceDialect)
3324                });
3325                fidl::decode!(
3326                    TouchDeviceInfo,
3327                    fidl::encoding::DefaultFuchsiaResourceDialect,
3328                    val_ref,
3329                    decoder,
3330                    inner_offset,
3331                    inner_depth
3332                )?;
3333                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3334                {
3335                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3336                }
3337                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3338                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3339                }
3340            }
3341
3342            next_offset += envelope_size;
3343            _next_ordinal_to_read += 1;
3344            if next_offset >= end_offset {
3345                return Ok(());
3346            }
3347
3348            // Decode unknown envelopes for gaps in ordinals.
3349            while _next_ordinal_to_read < 3 {
3350                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3351                _next_ordinal_to_read += 1;
3352                next_offset += envelope_size;
3353            }
3354
3355            let next_out_of_line = decoder.next_out_of_line();
3356            let handles_before = decoder.remaining_handles();
3357            if let Some((inlined, num_bytes, num_handles)) =
3358                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3359            {
3360                let member_inline_size = <fidl::encoding::UnboundedVector<TouchButton> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3361                if inlined != (member_inline_size <= 4) {
3362                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3363                }
3364                let inner_offset;
3365                let mut inner_depth = depth.clone();
3366                if inlined {
3367                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3368                    inner_offset = next_offset;
3369                } else {
3370                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3371                    inner_depth.increment()?;
3372                }
3373                let val_ref = self.pressed_buttons.get_or_insert_with(|| {
3374                    fidl::new_empty!(
3375                        fidl::encoding::UnboundedVector<TouchButton>,
3376                        fidl::encoding::DefaultFuchsiaResourceDialect
3377                    )
3378                });
3379                fidl::decode!(
3380                    fidl::encoding::UnboundedVector<TouchButton>,
3381                    fidl::encoding::DefaultFuchsiaResourceDialect,
3382                    val_ref,
3383                    decoder,
3384                    inner_offset,
3385                    inner_depth
3386                )?;
3387                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3388                {
3389                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3390                }
3391                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3392                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3393                }
3394            }
3395
3396            next_offset += envelope_size;
3397            _next_ordinal_to_read += 1;
3398            if next_offset >= end_offset {
3399                return Ok(());
3400            }
3401
3402            // Decode unknown envelopes for gaps in ordinals.
3403            while _next_ordinal_to_read < 4 {
3404                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3405                _next_ordinal_to_read += 1;
3406                next_offset += envelope_size;
3407            }
3408
3409            let next_out_of_line = decoder.next_out_of_line();
3410            let handles_before = decoder.remaining_handles();
3411            if let Some((inlined, num_bytes, num_handles)) =
3412                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3413            {
3414                let member_inline_size = <fidl::encoding::HandleType<
3415                    fidl::EventPair,
3416                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3417                    2147483648,
3418                > as fidl::encoding::TypeMarker>::inline_size(
3419                    decoder.context
3420                );
3421                if inlined != (member_inline_size <= 4) {
3422                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3423                }
3424                let inner_offset;
3425                let mut inner_depth = depth.clone();
3426                if inlined {
3427                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3428                    inner_offset = next_offset;
3429                } else {
3430                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3431                    inner_depth.increment()?;
3432                }
3433                let val_ref =
3434                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3435                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3436                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3437                {
3438                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3439                }
3440                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3441                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3442                }
3443            }
3444
3445            next_offset += envelope_size;
3446            _next_ordinal_to_read += 1;
3447            if next_offset >= end_offset {
3448                return Ok(());
3449            }
3450
3451            // Decode unknown envelopes for gaps in ordinals.
3452            while _next_ordinal_to_read < 5 {
3453                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3454                _next_ordinal_to_read += 1;
3455                next_offset += envelope_size;
3456            }
3457
3458            let next_out_of_line = decoder.next_out_of_line();
3459            let handles_before = decoder.remaining_handles();
3460            if let Some((inlined, num_bytes, num_handles)) =
3461                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3462            {
3463                let member_inline_size =
3464                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3465                if inlined != (member_inline_size <= 4) {
3466                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3467                }
3468                let inner_offset;
3469                let mut inner_depth = depth.clone();
3470                if inlined {
3471                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3472                    inner_offset = next_offset;
3473                } else {
3474                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3475                    inner_depth.increment()?;
3476                }
3477                let val_ref = self.trace_flow_id.get_or_insert_with(|| {
3478                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
3479                });
3480                fidl::decode!(
3481                    u64,
3482                    fidl::encoding::DefaultFuchsiaResourceDialect,
3483                    val_ref,
3484                    decoder,
3485                    inner_offset,
3486                    inner_depth
3487                )?;
3488                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3489                {
3490                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3491                }
3492                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3493                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3494                }
3495            }
3496
3497            next_offset += envelope_size;
3498
3499            // Decode the remaining unknown envelopes.
3500            while next_offset < end_offset {
3501                _next_ordinal_to_read += 1;
3502                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3503                next_offset += envelope_size;
3504            }
3505
3506            Ok(())
3507        }
3508    }
3509}