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