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, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
29pub struct ImeServiceMarker;
30
31impl fidl::endpoints::ProtocolMarker for ImeServiceMarker {
32    type Proxy = ImeServiceProxy;
33    type RequestStream = ImeServiceRequestStream;
34    #[cfg(target_os = "fuchsia")]
35    type SynchronousProxy = ImeServiceSynchronousProxy;
36
37    const DEBUG_NAME: &'static str = "fuchsia.ui.input.ImeService";
38}
39impl fidl::endpoints::DiscoverableProtocolMarker for ImeServiceMarker {}
40
41pub trait ImeServiceProxyInterface: Send + Sync {
42    fn r#get_input_method_editor(
43        &self,
44        keyboard_type: KeyboardType,
45        action: InputMethodAction,
46        initial_state: &TextInputState,
47        client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
48        editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
49    ) -> Result<(), fidl::Error>;
50    fn r#show_keyboard(&self) -> Result<(), fidl::Error>;
51    fn r#hide_keyboard(&self) -> Result<(), fidl::Error>;
52}
53#[derive(Debug)]
54#[cfg(target_os = "fuchsia")]
55pub struct ImeServiceSynchronousProxy {
56    client: fidl::client::sync::Client,
57}
58
59#[cfg(target_os = "fuchsia")]
60impl fidl::endpoints::SynchronousProxy for ImeServiceSynchronousProxy {
61    type Proxy = ImeServiceProxy;
62    type Protocol = ImeServiceMarker;
63
64    fn from_channel(inner: fidl::Channel) -> Self {
65        Self::new(inner)
66    }
67
68    fn into_channel(self) -> fidl::Channel {
69        self.client.into_channel()
70    }
71
72    fn as_channel(&self) -> &fidl::Channel {
73        self.client.as_channel()
74    }
75}
76
77#[cfg(target_os = "fuchsia")]
78impl ImeServiceSynchronousProxy {
79    pub fn new(channel: fidl::Channel) -> Self {
80        let protocol_name = <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
81        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
82    }
83
84    pub fn into_channel(self) -> fidl::Channel {
85        self.client.into_channel()
86    }
87
88    /// Waits until an event arrives and returns it. It is safe for other
89    /// threads to make concurrent requests while waiting for an event.
90    pub fn wait_for_event(
91        &self,
92        deadline: zx::MonotonicInstant,
93    ) -> Result<ImeServiceEvent, fidl::Error> {
94        ImeServiceEvent::decode(self.client.wait_for_event(deadline)?)
95    }
96
97    pub fn r#get_input_method_editor(
98        &self,
99        mut keyboard_type: KeyboardType,
100        mut action: InputMethodAction,
101        mut initial_state: &TextInputState,
102        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
103        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
104    ) -> Result<(), fidl::Error> {
105        self.client.send::<ImeServiceGetInputMethodEditorRequest>(
106            (keyboard_type, action, initial_state, client, editor),
107            0x148d2e42a1f461fc,
108            fidl::encoding::DynamicFlags::empty(),
109        )
110    }
111
112    pub fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
113        self.client.send::<fidl::encoding::EmptyPayload>(
114            (),
115            0x38ed2a1de28cfcf0,
116            fidl::encoding::DynamicFlags::empty(),
117        )
118    }
119
120    pub fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
121        self.client.send::<fidl::encoding::EmptyPayload>(
122            (),
123            0x7667f098198d09fd,
124            fidl::encoding::DynamicFlags::empty(),
125        )
126    }
127}
128
129#[derive(Debug, Clone)]
130pub struct ImeServiceProxy {
131    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
132}
133
134impl fidl::endpoints::Proxy for ImeServiceProxy {
135    type Protocol = ImeServiceMarker;
136
137    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
138        Self::new(inner)
139    }
140
141    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
142        self.client.into_channel().map_err(|client| Self { client })
143    }
144
145    fn as_channel(&self) -> &::fidl::AsyncChannel {
146        self.client.as_channel()
147    }
148}
149
150impl ImeServiceProxy {
151    /// Create a new Proxy for fuchsia.ui.input/ImeService.
152    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
153        let protocol_name = <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
154        Self { client: fidl::client::Client::new(channel, protocol_name) }
155    }
156
157    /// Get a Stream of events from the remote end of the protocol.
158    ///
159    /// # Panics
160    ///
161    /// Panics if the event stream was already taken.
162    pub fn take_event_stream(&self) -> ImeServiceEventStream {
163        ImeServiceEventStream { event_receiver: self.client.take_event_receiver() }
164    }
165
166    pub fn r#get_input_method_editor(
167        &self,
168        mut keyboard_type: KeyboardType,
169        mut action: InputMethodAction,
170        mut initial_state: &TextInputState,
171        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
172        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
173    ) -> Result<(), fidl::Error> {
174        ImeServiceProxyInterface::r#get_input_method_editor(
175            self,
176            keyboard_type,
177            action,
178            initial_state,
179            client,
180            editor,
181        )
182    }
183
184    pub fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
185        ImeServiceProxyInterface::r#show_keyboard(self)
186    }
187
188    pub fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
189        ImeServiceProxyInterface::r#hide_keyboard(self)
190    }
191}
192
193impl ImeServiceProxyInterface for ImeServiceProxy {
194    fn r#get_input_method_editor(
195        &self,
196        mut keyboard_type: KeyboardType,
197        mut action: InputMethodAction,
198        mut initial_state: &TextInputState,
199        mut client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
200        mut editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
201    ) -> Result<(), fidl::Error> {
202        self.client.send::<ImeServiceGetInputMethodEditorRequest>(
203            (keyboard_type, action, initial_state, client, editor),
204            0x148d2e42a1f461fc,
205            fidl::encoding::DynamicFlags::empty(),
206        )
207    }
208
209    fn r#show_keyboard(&self) -> Result<(), fidl::Error> {
210        self.client.send::<fidl::encoding::EmptyPayload>(
211            (),
212            0x38ed2a1de28cfcf0,
213            fidl::encoding::DynamicFlags::empty(),
214        )
215    }
216
217    fn r#hide_keyboard(&self) -> Result<(), fidl::Error> {
218        self.client.send::<fidl::encoding::EmptyPayload>(
219            (),
220            0x7667f098198d09fd,
221            fidl::encoding::DynamicFlags::empty(),
222        )
223    }
224}
225
226pub struct ImeServiceEventStream {
227    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
228}
229
230impl std::marker::Unpin for ImeServiceEventStream {}
231
232impl futures::stream::FusedStream for ImeServiceEventStream {
233    fn is_terminated(&self) -> bool {
234        self.event_receiver.is_terminated()
235    }
236}
237
238impl futures::Stream for ImeServiceEventStream {
239    type Item = Result<ImeServiceEvent, fidl::Error>;
240
241    fn poll_next(
242        mut self: std::pin::Pin<&mut Self>,
243        cx: &mut std::task::Context<'_>,
244    ) -> std::task::Poll<Option<Self::Item>> {
245        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
246            &mut self.event_receiver,
247            cx
248        )?) {
249            Some(buf) => std::task::Poll::Ready(Some(ImeServiceEvent::decode(buf))),
250            None => std::task::Poll::Ready(None),
251        }
252    }
253}
254
255#[derive(Debug)]
256pub enum ImeServiceEvent {}
257
258impl ImeServiceEvent {
259    /// Decodes a message buffer as a [`ImeServiceEvent`].
260    fn decode(
261        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
262    ) -> Result<ImeServiceEvent, fidl::Error> {
263        let (bytes, _handles) = buf.split_mut();
264        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
265        debug_assert_eq!(tx_header.tx_id, 0);
266        match tx_header.ordinal {
267            _ => Err(fidl::Error::UnknownOrdinal {
268                ordinal: tx_header.ordinal,
269                protocol_name: <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
270            }),
271        }
272    }
273}
274
275/// A Stream of incoming requests for fuchsia.ui.input/ImeService.
276pub struct ImeServiceRequestStream {
277    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
278    is_terminated: bool,
279}
280
281impl std::marker::Unpin for ImeServiceRequestStream {}
282
283impl futures::stream::FusedStream for ImeServiceRequestStream {
284    fn is_terminated(&self) -> bool {
285        self.is_terminated
286    }
287}
288
289impl fidl::endpoints::RequestStream for ImeServiceRequestStream {
290    type Protocol = ImeServiceMarker;
291    type ControlHandle = ImeServiceControlHandle;
292
293    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
294        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
295    }
296
297    fn control_handle(&self) -> Self::ControlHandle {
298        ImeServiceControlHandle { inner: self.inner.clone() }
299    }
300
301    fn into_inner(
302        self,
303    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
304    {
305        (self.inner, self.is_terminated)
306    }
307
308    fn from_inner(
309        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
310        is_terminated: bool,
311    ) -> Self {
312        Self { inner, is_terminated }
313    }
314}
315
316impl futures::Stream for ImeServiceRequestStream {
317    type Item = Result<ImeServiceRequest, fidl::Error>;
318
319    fn poll_next(
320        mut self: std::pin::Pin<&mut Self>,
321        cx: &mut std::task::Context<'_>,
322    ) -> std::task::Poll<Option<Self::Item>> {
323        let this = &mut *self;
324        if this.inner.check_shutdown(cx) {
325            this.is_terminated = true;
326            return std::task::Poll::Ready(None);
327        }
328        if this.is_terminated {
329            panic!("polled ImeServiceRequestStream after completion");
330        }
331        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
332            |bytes, handles| {
333                match this.inner.channel().read_etc(cx, bytes, handles) {
334                    std::task::Poll::Ready(Ok(())) => {}
335                    std::task::Poll::Pending => return std::task::Poll::Pending,
336                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
337                        this.is_terminated = true;
338                        return std::task::Poll::Ready(None);
339                    }
340                    std::task::Poll::Ready(Err(e)) => {
341                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
342                            e.into(),
343                        ))))
344                    }
345                }
346
347                // A message has been received from the channel
348                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
349
350                std::task::Poll::Ready(Some(match header.ordinal {
351                    0x148d2e42a1f461fc => {
352                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
353                        let mut req = fidl::new_empty!(
354                            ImeServiceGetInputMethodEditorRequest,
355                            fidl::encoding::DefaultFuchsiaResourceDialect
356                        );
357                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImeServiceGetInputMethodEditorRequest>(&header, _body_bytes, handles, &mut req)?;
358                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
359                        Ok(ImeServiceRequest::GetInputMethodEditor {
360                            keyboard_type: req.keyboard_type,
361                            action: req.action,
362                            initial_state: req.initial_state,
363                            client: req.client,
364                            editor: req.editor,
365
366                            control_handle,
367                        })
368                    }
369                    0x38ed2a1de28cfcf0 => {
370                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
371                        let mut req = fidl::new_empty!(
372                            fidl::encoding::EmptyPayload,
373                            fidl::encoding::DefaultFuchsiaResourceDialect
374                        );
375                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
376                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
377                        Ok(ImeServiceRequest::ShowKeyboard { control_handle })
378                    }
379                    0x7667f098198d09fd => {
380                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
381                        let mut req = fidl::new_empty!(
382                            fidl::encoding::EmptyPayload,
383                            fidl::encoding::DefaultFuchsiaResourceDialect
384                        );
385                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
386                        let control_handle = ImeServiceControlHandle { inner: this.inner.clone() };
387                        Ok(ImeServiceRequest::HideKeyboard { control_handle })
388                    }
389                    _ => Err(fidl::Error::UnknownOrdinal {
390                        ordinal: header.ordinal,
391                        protocol_name:
392                            <ImeServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
393                    }),
394                }))
395            },
396        )
397    }
398}
399
400/// The service provided by an IME
401#[derive(Debug)]
402pub enum ImeServiceRequest {
403    GetInputMethodEditor {
404        keyboard_type: KeyboardType,
405        action: InputMethodAction,
406        initial_state: TextInputState,
407        client: fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
408        editor: fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
409        control_handle: ImeServiceControlHandle,
410    },
411    ShowKeyboard {
412        control_handle: ImeServiceControlHandle,
413    },
414    HideKeyboard {
415        control_handle: ImeServiceControlHandle,
416    },
417}
418
419impl ImeServiceRequest {
420    #[allow(irrefutable_let_patterns)]
421    pub fn into_get_input_method_editor(
422        self,
423    ) -> Option<(
424        KeyboardType,
425        InputMethodAction,
426        TextInputState,
427        fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
428        fidl::endpoints::ServerEnd<InputMethodEditorMarker>,
429        ImeServiceControlHandle,
430    )> {
431        if let ImeServiceRequest::GetInputMethodEditor {
432            keyboard_type,
433            action,
434            initial_state,
435            client,
436            editor,
437            control_handle,
438        } = self
439        {
440            Some((keyboard_type, action, initial_state, client, editor, control_handle))
441        } else {
442            None
443        }
444    }
445
446    #[allow(irrefutable_let_patterns)]
447    pub fn into_show_keyboard(self) -> Option<(ImeServiceControlHandle)> {
448        if let ImeServiceRequest::ShowKeyboard { control_handle } = self {
449            Some((control_handle))
450        } else {
451            None
452        }
453    }
454
455    #[allow(irrefutable_let_patterns)]
456    pub fn into_hide_keyboard(self) -> Option<(ImeServiceControlHandle)> {
457        if let ImeServiceRequest::HideKeyboard { control_handle } = self {
458            Some((control_handle))
459        } else {
460            None
461        }
462    }
463
464    /// Name of the method defined in FIDL
465    pub fn method_name(&self) -> &'static str {
466        match *self {
467            ImeServiceRequest::GetInputMethodEditor { .. } => "get_input_method_editor",
468            ImeServiceRequest::ShowKeyboard { .. } => "show_keyboard",
469            ImeServiceRequest::HideKeyboard { .. } => "hide_keyboard",
470        }
471    }
472}
473
474#[derive(Debug, Clone)]
475pub struct ImeServiceControlHandle {
476    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
477}
478
479impl fidl::endpoints::ControlHandle for ImeServiceControlHandle {
480    fn shutdown(&self) {
481        self.inner.shutdown()
482    }
483    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
484        self.inner.shutdown_with_epitaph(status)
485    }
486
487    fn is_closed(&self) -> bool {
488        self.inner.channel().is_closed()
489    }
490    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
491        self.inner.channel().on_closed()
492    }
493
494    #[cfg(target_os = "fuchsia")]
495    fn signal_peer(
496        &self,
497        clear_mask: zx::Signals,
498        set_mask: zx::Signals,
499    ) -> Result<(), zx_status::Status> {
500        use fidl::Peered;
501        self.inner.channel().signal_peer(clear_mask, set_mask)
502    }
503}
504
505impl ImeServiceControlHandle {}
506
507#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
508pub struct InputDeviceMarker;
509
510impl fidl::endpoints::ProtocolMarker for InputDeviceMarker {
511    type Proxy = InputDeviceProxy;
512    type RequestStream = InputDeviceRequestStream;
513    #[cfg(target_os = "fuchsia")]
514    type SynchronousProxy = InputDeviceSynchronousProxy;
515
516    const DEBUG_NAME: &'static str = "(anonymous) InputDevice";
517}
518
519pub trait InputDeviceProxyInterface: Send + Sync {
520    fn r#dispatch_report(&self, report: &InputReport) -> Result<(), fidl::Error>;
521}
522#[derive(Debug)]
523#[cfg(target_os = "fuchsia")]
524pub struct InputDeviceSynchronousProxy {
525    client: fidl::client::sync::Client,
526}
527
528#[cfg(target_os = "fuchsia")]
529impl fidl::endpoints::SynchronousProxy for InputDeviceSynchronousProxy {
530    type Proxy = InputDeviceProxy;
531    type Protocol = InputDeviceMarker;
532
533    fn from_channel(inner: fidl::Channel) -> Self {
534        Self::new(inner)
535    }
536
537    fn into_channel(self) -> fidl::Channel {
538        self.client.into_channel()
539    }
540
541    fn as_channel(&self) -> &fidl::Channel {
542        self.client.as_channel()
543    }
544}
545
546#[cfg(target_os = "fuchsia")]
547impl InputDeviceSynchronousProxy {
548    pub fn new(channel: fidl::Channel) -> Self {
549        let protocol_name = <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
550        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
551    }
552
553    pub fn into_channel(self) -> fidl::Channel {
554        self.client.into_channel()
555    }
556
557    /// Waits until an event arrives and returns it. It is safe for other
558    /// threads to make concurrent requests while waiting for an event.
559    pub fn wait_for_event(
560        &self,
561        deadline: zx::MonotonicInstant,
562    ) -> Result<InputDeviceEvent, fidl::Error> {
563        InputDeviceEvent::decode(self.client.wait_for_event(deadline)?)
564    }
565
566    /// Dispatch an `InputReport` from the device `token`
567    pub fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
568        self.client.send::<InputDeviceDispatchReportRequest>(
569            (report,),
570            0x7ee375d01c8e149f,
571            fidl::encoding::DynamicFlags::empty(),
572        )
573    }
574}
575
576#[derive(Debug, Clone)]
577pub struct InputDeviceProxy {
578    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
579}
580
581impl fidl::endpoints::Proxy for InputDeviceProxy {
582    type Protocol = InputDeviceMarker;
583
584    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
585        Self::new(inner)
586    }
587
588    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
589        self.client.into_channel().map_err(|client| Self { client })
590    }
591
592    fn as_channel(&self) -> &::fidl::AsyncChannel {
593        self.client.as_channel()
594    }
595}
596
597impl InputDeviceProxy {
598    /// Create a new Proxy for fuchsia.ui.input/InputDevice.
599    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
600        let protocol_name = <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
601        Self { client: fidl::client::Client::new(channel, protocol_name) }
602    }
603
604    /// Get a Stream of events from the remote end of the protocol.
605    ///
606    /// # Panics
607    ///
608    /// Panics if the event stream was already taken.
609    pub fn take_event_stream(&self) -> InputDeviceEventStream {
610        InputDeviceEventStream { event_receiver: self.client.take_event_receiver() }
611    }
612
613    /// Dispatch an `InputReport` from the device `token`
614    pub fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
615        InputDeviceProxyInterface::r#dispatch_report(self, report)
616    }
617}
618
619impl InputDeviceProxyInterface for InputDeviceProxy {
620    fn r#dispatch_report(&self, mut report: &InputReport) -> Result<(), fidl::Error> {
621        self.client.send::<InputDeviceDispatchReportRequest>(
622            (report,),
623            0x7ee375d01c8e149f,
624            fidl::encoding::DynamicFlags::empty(),
625        )
626    }
627}
628
629pub struct InputDeviceEventStream {
630    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
631}
632
633impl std::marker::Unpin for InputDeviceEventStream {}
634
635impl futures::stream::FusedStream for InputDeviceEventStream {
636    fn is_terminated(&self) -> bool {
637        self.event_receiver.is_terminated()
638    }
639}
640
641impl futures::Stream for InputDeviceEventStream {
642    type Item = Result<InputDeviceEvent, fidl::Error>;
643
644    fn poll_next(
645        mut self: std::pin::Pin<&mut Self>,
646        cx: &mut std::task::Context<'_>,
647    ) -> std::task::Poll<Option<Self::Item>> {
648        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
649            &mut self.event_receiver,
650            cx
651        )?) {
652            Some(buf) => std::task::Poll::Ready(Some(InputDeviceEvent::decode(buf))),
653            None => std::task::Poll::Ready(None),
654        }
655    }
656}
657
658#[derive(Debug)]
659pub enum InputDeviceEvent {}
660
661impl InputDeviceEvent {
662    /// Decodes a message buffer as a [`InputDeviceEvent`].
663    fn decode(
664        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
665    ) -> Result<InputDeviceEvent, fidl::Error> {
666        let (bytes, _handles) = buf.split_mut();
667        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
668        debug_assert_eq!(tx_header.tx_id, 0);
669        match tx_header.ordinal {
670            _ => Err(fidl::Error::UnknownOrdinal {
671                ordinal: tx_header.ordinal,
672                protocol_name: <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
673            }),
674        }
675    }
676}
677
678/// A Stream of incoming requests for fuchsia.ui.input/InputDevice.
679pub struct InputDeviceRequestStream {
680    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
681    is_terminated: bool,
682}
683
684impl std::marker::Unpin for InputDeviceRequestStream {}
685
686impl futures::stream::FusedStream for InputDeviceRequestStream {
687    fn is_terminated(&self) -> bool {
688        self.is_terminated
689    }
690}
691
692impl fidl::endpoints::RequestStream for InputDeviceRequestStream {
693    type Protocol = InputDeviceMarker;
694    type ControlHandle = InputDeviceControlHandle;
695
696    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
697        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
698    }
699
700    fn control_handle(&self) -> Self::ControlHandle {
701        InputDeviceControlHandle { inner: self.inner.clone() }
702    }
703
704    fn into_inner(
705        self,
706    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
707    {
708        (self.inner, self.is_terminated)
709    }
710
711    fn from_inner(
712        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
713        is_terminated: bool,
714    ) -> Self {
715        Self { inner, is_terminated }
716    }
717}
718
719impl futures::Stream for InputDeviceRequestStream {
720    type Item = Result<InputDeviceRequest, fidl::Error>;
721
722    fn poll_next(
723        mut self: std::pin::Pin<&mut Self>,
724        cx: &mut std::task::Context<'_>,
725    ) -> std::task::Poll<Option<Self::Item>> {
726        let this = &mut *self;
727        if this.inner.check_shutdown(cx) {
728            this.is_terminated = true;
729            return std::task::Poll::Ready(None);
730        }
731        if this.is_terminated {
732            panic!("polled InputDeviceRequestStream after completion");
733        }
734        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
735            |bytes, handles| {
736                match this.inner.channel().read_etc(cx, bytes, handles) {
737                    std::task::Poll::Ready(Ok(())) => {}
738                    std::task::Poll::Pending => return std::task::Poll::Pending,
739                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
740                        this.is_terminated = true;
741                        return std::task::Poll::Ready(None);
742                    }
743                    std::task::Poll::Ready(Err(e)) => {
744                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
745                            e.into(),
746                        ))))
747                    }
748                }
749
750                // A message has been received from the channel
751                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
752
753                std::task::Poll::Ready(Some(match header.ordinal {
754                    0x7ee375d01c8e149f => {
755                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
756                        let mut req = fidl::new_empty!(
757                            InputDeviceDispatchReportRequest,
758                            fidl::encoding::DefaultFuchsiaResourceDialect
759                        );
760                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceDispatchReportRequest>(&header, _body_bytes, handles, &mut req)?;
761                        let control_handle = InputDeviceControlHandle { inner: this.inner.clone() };
762                        Ok(InputDeviceRequest::DispatchReport {
763                            report: req.report,
764
765                            control_handle,
766                        })
767                    }
768                    _ => Err(fidl::Error::UnknownOrdinal {
769                        ordinal: header.ordinal,
770                        protocol_name:
771                            <InputDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
772                    }),
773                }))
774            },
775        )
776    }
777}
778
779#[derive(Debug)]
780pub enum InputDeviceRequest {
781    /// Dispatch an `InputReport` from the device `token`
782    DispatchReport { report: InputReport, control_handle: InputDeviceControlHandle },
783}
784
785impl InputDeviceRequest {
786    #[allow(irrefutable_let_patterns)]
787    pub fn into_dispatch_report(self) -> Option<(InputReport, InputDeviceControlHandle)> {
788        if let InputDeviceRequest::DispatchReport { report, control_handle } = self {
789            Some((report, control_handle))
790        } else {
791            None
792        }
793    }
794
795    /// Name of the method defined in FIDL
796    pub fn method_name(&self) -> &'static str {
797        match *self {
798            InputDeviceRequest::DispatchReport { .. } => "dispatch_report",
799        }
800    }
801}
802
803#[derive(Debug, Clone)]
804pub struct InputDeviceControlHandle {
805    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
806}
807
808impl fidl::endpoints::ControlHandle for InputDeviceControlHandle {
809    fn shutdown(&self) {
810        self.inner.shutdown()
811    }
812    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
813        self.inner.shutdown_with_epitaph(status)
814    }
815
816    fn is_closed(&self) -> bool {
817        self.inner.channel().is_closed()
818    }
819    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
820        self.inner.channel().on_closed()
821    }
822
823    #[cfg(target_os = "fuchsia")]
824    fn signal_peer(
825        &self,
826        clear_mask: zx::Signals,
827        set_mask: zx::Signals,
828    ) -> Result<(), zx_status::Status> {
829        use fidl::Peered;
830        self.inner.channel().signal_peer(clear_mask, set_mask)
831    }
832}
833
834impl InputDeviceControlHandle {}
835
836#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
837pub struct InputMethodEditorMarker;
838
839impl fidl::endpoints::ProtocolMarker for InputMethodEditorMarker {
840    type Proxy = InputMethodEditorProxy;
841    type RequestStream = InputMethodEditorRequestStream;
842    #[cfg(target_os = "fuchsia")]
843    type SynchronousProxy = InputMethodEditorSynchronousProxy;
844
845    const DEBUG_NAME: &'static str = "(anonymous) InputMethodEditor";
846}
847
848pub trait InputMethodEditorProxyInterface: Send + Sync {
849    fn r#set_keyboard_type(&self, keyboard_type: KeyboardType) -> Result<(), fidl::Error>;
850    fn r#set_state(&self, state: &TextInputState) -> Result<(), fidl::Error>;
851    fn r#inject_input(&self, event: &InputEvent) -> Result<(), fidl::Error>;
852    type DispatchKey3ResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
853    fn r#dispatch_key3(
854        &self,
855        event: &fidl_fuchsia_ui_input3::KeyEvent,
856    ) -> Self::DispatchKey3ResponseFut;
857    fn r#show(&self) -> Result<(), fidl::Error>;
858    fn r#hide(&self) -> Result<(), fidl::Error>;
859}
860#[derive(Debug)]
861#[cfg(target_os = "fuchsia")]
862pub struct InputMethodEditorSynchronousProxy {
863    client: fidl::client::sync::Client,
864}
865
866#[cfg(target_os = "fuchsia")]
867impl fidl::endpoints::SynchronousProxy for InputMethodEditorSynchronousProxy {
868    type Proxy = InputMethodEditorProxy;
869    type Protocol = InputMethodEditorMarker;
870
871    fn from_channel(inner: fidl::Channel) -> Self {
872        Self::new(inner)
873    }
874
875    fn into_channel(self) -> fidl::Channel {
876        self.client.into_channel()
877    }
878
879    fn as_channel(&self) -> &fidl::Channel {
880        self.client.as_channel()
881    }
882}
883
884#[cfg(target_os = "fuchsia")]
885impl InputMethodEditorSynchronousProxy {
886    pub fn new(channel: fidl::Channel) -> Self {
887        let protocol_name =
888            <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
889        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
890    }
891
892    pub fn into_channel(self) -> fidl::Channel {
893        self.client.into_channel()
894    }
895
896    /// Waits until an event arrives and returns it. It is safe for other
897    /// threads to make concurrent requests while waiting for an event.
898    pub fn wait_for_event(
899        &self,
900        deadline: zx::MonotonicInstant,
901    ) -> Result<InputMethodEditorEvent, fidl::Error> {
902        InputMethodEditorEvent::decode(self.client.wait_for_event(deadline)?)
903    }
904
905    pub fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
906        self.client.send::<InputMethodEditorSetKeyboardTypeRequest>(
907            (keyboard_type,),
908            0x14fe60e927d7d487,
909            fidl::encoding::DynamicFlags::empty(),
910        )
911    }
912
913    pub fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
914        self.client.send::<InputMethodEditorSetStateRequest>(
915            (state,),
916            0x12b477b779818f45,
917            fidl::encoding::DynamicFlags::empty(),
918        )
919    }
920
921    pub fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
922        self.client.send::<InputMethodEditorInjectInputRequest>(
923            (event,),
924            0x34af74618a4f82b,
925            fidl::encoding::DynamicFlags::empty(),
926        )
927    }
928
929    pub fn r#dispatch_key3(
930        &self,
931        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
932        ___deadline: zx::MonotonicInstant,
933    ) -> Result<bool, fidl::Error> {
934        let _response = self.client.send_query::<
935            InputMethodEditorDispatchKey3Request,
936            InputMethodEditorDispatchKey3Response,
937        >(
938            (event,),
939            0x2e13667c827209ac,
940            fidl::encoding::DynamicFlags::empty(),
941            ___deadline,
942        )?;
943        Ok(_response.handled)
944    }
945
946    pub fn r#show(&self) -> Result<(), fidl::Error> {
947        self.client.send::<fidl::encoding::EmptyPayload>(
948            (),
949            0x19ba00ba1beb002e,
950            fidl::encoding::DynamicFlags::empty(),
951        )
952    }
953
954    pub fn r#hide(&self) -> Result<(), fidl::Error> {
955        self.client.send::<fidl::encoding::EmptyPayload>(
956            (),
957            0x283e0cd73f0d6d9e,
958            fidl::encoding::DynamicFlags::empty(),
959        )
960    }
961}
962
963#[derive(Debug, Clone)]
964pub struct InputMethodEditorProxy {
965    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
966}
967
968impl fidl::endpoints::Proxy for InputMethodEditorProxy {
969    type Protocol = InputMethodEditorMarker;
970
971    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
972        Self::new(inner)
973    }
974
975    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
976        self.client.into_channel().map_err(|client| Self { client })
977    }
978
979    fn as_channel(&self) -> &::fidl::AsyncChannel {
980        self.client.as_channel()
981    }
982}
983
984impl InputMethodEditorProxy {
985    /// Create a new Proxy for fuchsia.ui.input/InputMethodEditor.
986    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
987        let protocol_name =
988            <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
989        Self { client: fidl::client::Client::new(channel, protocol_name) }
990    }
991
992    /// Get a Stream of events from the remote end of the protocol.
993    ///
994    /// # Panics
995    ///
996    /// Panics if the event stream was already taken.
997    pub fn take_event_stream(&self) -> InputMethodEditorEventStream {
998        InputMethodEditorEventStream { event_receiver: self.client.take_event_receiver() }
999    }
1000
1001    pub fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
1002        InputMethodEditorProxyInterface::r#set_keyboard_type(self, keyboard_type)
1003    }
1004
1005    pub fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
1006        InputMethodEditorProxyInterface::r#set_state(self, state)
1007    }
1008
1009    pub fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
1010        InputMethodEditorProxyInterface::r#inject_input(self, event)
1011    }
1012
1013    pub fn r#dispatch_key3(
1014        &self,
1015        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
1016    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
1017        InputMethodEditorProxyInterface::r#dispatch_key3(self, event)
1018    }
1019
1020    pub fn r#show(&self) -> Result<(), fidl::Error> {
1021        InputMethodEditorProxyInterface::r#show(self)
1022    }
1023
1024    pub fn r#hide(&self) -> Result<(), fidl::Error> {
1025        InputMethodEditorProxyInterface::r#hide(self)
1026    }
1027}
1028
1029impl InputMethodEditorProxyInterface for InputMethodEditorProxy {
1030    fn r#set_keyboard_type(&self, mut keyboard_type: KeyboardType) -> Result<(), fidl::Error> {
1031        self.client.send::<InputMethodEditorSetKeyboardTypeRequest>(
1032            (keyboard_type,),
1033            0x14fe60e927d7d487,
1034            fidl::encoding::DynamicFlags::empty(),
1035        )
1036    }
1037
1038    fn r#set_state(&self, mut state: &TextInputState) -> Result<(), fidl::Error> {
1039        self.client.send::<InputMethodEditorSetStateRequest>(
1040            (state,),
1041            0x12b477b779818f45,
1042            fidl::encoding::DynamicFlags::empty(),
1043        )
1044    }
1045
1046    fn r#inject_input(&self, mut event: &InputEvent) -> Result<(), fidl::Error> {
1047        self.client.send::<InputMethodEditorInjectInputRequest>(
1048            (event,),
1049            0x34af74618a4f82b,
1050            fidl::encoding::DynamicFlags::empty(),
1051        )
1052    }
1053
1054    type DispatchKey3ResponseFut =
1055        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
1056    fn r#dispatch_key3(
1057        &self,
1058        mut event: &fidl_fuchsia_ui_input3::KeyEvent,
1059    ) -> Self::DispatchKey3ResponseFut {
1060        fn _decode(
1061            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1062        ) -> Result<bool, fidl::Error> {
1063            let _response = fidl::client::decode_transaction_body::<
1064                InputMethodEditorDispatchKey3Response,
1065                fidl::encoding::DefaultFuchsiaResourceDialect,
1066                0x2e13667c827209ac,
1067            >(_buf?)?;
1068            Ok(_response.handled)
1069        }
1070        self.client.send_query_and_decode::<InputMethodEditorDispatchKey3Request, bool>(
1071            (event,),
1072            0x2e13667c827209ac,
1073            fidl::encoding::DynamicFlags::empty(),
1074            _decode,
1075        )
1076    }
1077
1078    fn r#show(&self) -> Result<(), fidl::Error> {
1079        self.client.send::<fidl::encoding::EmptyPayload>(
1080            (),
1081            0x19ba00ba1beb002e,
1082            fidl::encoding::DynamicFlags::empty(),
1083        )
1084    }
1085
1086    fn r#hide(&self) -> Result<(), fidl::Error> {
1087        self.client.send::<fidl::encoding::EmptyPayload>(
1088            (),
1089            0x283e0cd73f0d6d9e,
1090            fidl::encoding::DynamicFlags::empty(),
1091        )
1092    }
1093}
1094
1095pub struct InputMethodEditorEventStream {
1096    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1097}
1098
1099impl std::marker::Unpin for InputMethodEditorEventStream {}
1100
1101impl futures::stream::FusedStream for InputMethodEditorEventStream {
1102    fn is_terminated(&self) -> bool {
1103        self.event_receiver.is_terminated()
1104    }
1105}
1106
1107impl futures::Stream for InputMethodEditorEventStream {
1108    type Item = Result<InputMethodEditorEvent, fidl::Error>;
1109
1110    fn poll_next(
1111        mut self: std::pin::Pin<&mut Self>,
1112        cx: &mut std::task::Context<'_>,
1113    ) -> std::task::Poll<Option<Self::Item>> {
1114        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1115            &mut self.event_receiver,
1116            cx
1117        )?) {
1118            Some(buf) => std::task::Poll::Ready(Some(InputMethodEditorEvent::decode(buf))),
1119            None => std::task::Poll::Ready(None),
1120        }
1121    }
1122}
1123
1124#[derive(Debug)]
1125pub enum InputMethodEditorEvent {}
1126
1127impl InputMethodEditorEvent {
1128    /// Decodes a message buffer as a [`InputMethodEditorEvent`].
1129    fn decode(
1130        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1131    ) -> Result<InputMethodEditorEvent, fidl::Error> {
1132        let (bytes, _handles) = buf.split_mut();
1133        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1134        debug_assert_eq!(tx_header.tx_id, 0);
1135        match tx_header.ordinal {
1136            _ => Err(fidl::Error::UnknownOrdinal {
1137                ordinal: tx_header.ordinal,
1138                protocol_name:
1139                    <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1140            }),
1141        }
1142    }
1143}
1144
1145/// A Stream of incoming requests for fuchsia.ui.input/InputMethodEditor.
1146pub struct InputMethodEditorRequestStream {
1147    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1148    is_terminated: bool,
1149}
1150
1151impl std::marker::Unpin for InputMethodEditorRequestStream {}
1152
1153impl futures::stream::FusedStream for InputMethodEditorRequestStream {
1154    fn is_terminated(&self) -> bool {
1155        self.is_terminated
1156    }
1157}
1158
1159impl fidl::endpoints::RequestStream for InputMethodEditorRequestStream {
1160    type Protocol = InputMethodEditorMarker;
1161    type ControlHandle = InputMethodEditorControlHandle;
1162
1163    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1164        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1165    }
1166
1167    fn control_handle(&self) -> Self::ControlHandle {
1168        InputMethodEditorControlHandle { inner: self.inner.clone() }
1169    }
1170
1171    fn into_inner(
1172        self,
1173    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1174    {
1175        (self.inner, self.is_terminated)
1176    }
1177
1178    fn from_inner(
1179        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1180        is_terminated: bool,
1181    ) -> Self {
1182        Self { inner, is_terminated }
1183    }
1184}
1185
1186impl futures::Stream for InputMethodEditorRequestStream {
1187    type Item = Result<InputMethodEditorRequest, fidl::Error>;
1188
1189    fn poll_next(
1190        mut self: std::pin::Pin<&mut Self>,
1191        cx: &mut std::task::Context<'_>,
1192    ) -> std::task::Poll<Option<Self::Item>> {
1193        let this = &mut *self;
1194        if this.inner.check_shutdown(cx) {
1195            this.is_terminated = true;
1196            return std::task::Poll::Ready(None);
1197        }
1198        if this.is_terminated {
1199            panic!("polled InputMethodEditorRequestStream after completion");
1200        }
1201        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1202            |bytes, handles| {
1203                match this.inner.channel().read_etc(cx, bytes, handles) {
1204                    std::task::Poll::Ready(Ok(())) => {}
1205                    std::task::Poll::Pending => return std::task::Poll::Pending,
1206                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1207                        this.is_terminated = true;
1208                        return std::task::Poll::Ready(None);
1209                    }
1210                    std::task::Poll::Ready(Err(e)) => {
1211                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1212                            e.into(),
1213                        ))))
1214                    }
1215                }
1216
1217                // A message has been received from the channel
1218                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1219
1220                std::task::Poll::Ready(Some(match header.ordinal {
1221                    0x14fe60e927d7d487 => {
1222                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1223                        let mut req = fidl::new_empty!(
1224                            InputMethodEditorSetKeyboardTypeRequest,
1225                            fidl::encoding::DefaultFuchsiaResourceDialect
1226                        );
1227                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorSetKeyboardTypeRequest>(&header, _body_bytes, handles, &mut req)?;
1228                        let control_handle =
1229                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1230                        Ok(InputMethodEditorRequest::SetKeyboardType {
1231                            keyboard_type: req.keyboard_type,
1232
1233                            control_handle,
1234                        })
1235                    }
1236                    0x12b477b779818f45 => {
1237                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1238                        let mut req = fidl::new_empty!(
1239                            InputMethodEditorSetStateRequest,
1240                            fidl::encoding::DefaultFuchsiaResourceDialect
1241                        );
1242                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorSetStateRequest>(&header, _body_bytes, handles, &mut req)?;
1243                        let control_handle =
1244                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1245                        Ok(InputMethodEditorRequest::SetState { state: req.state, control_handle })
1246                    }
1247                    0x34af74618a4f82b => {
1248                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1249                        let mut req = fidl::new_empty!(
1250                            InputMethodEditorInjectInputRequest,
1251                            fidl::encoding::DefaultFuchsiaResourceDialect
1252                        );
1253                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorInjectInputRequest>(&header, _body_bytes, handles, &mut req)?;
1254                        let control_handle =
1255                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1256                        Ok(InputMethodEditorRequest::InjectInput {
1257                            event: req.event,
1258
1259                            control_handle,
1260                        })
1261                    }
1262                    0x2e13667c827209ac => {
1263                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1264                        let mut req = fidl::new_empty!(
1265                            InputMethodEditorDispatchKey3Request,
1266                            fidl::encoding::DefaultFuchsiaResourceDialect
1267                        );
1268                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorDispatchKey3Request>(&header, _body_bytes, handles, &mut req)?;
1269                        let control_handle =
1270                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1271                        Ok(InputMethodEditorRequest::DispatchKey3 {
1272                            event: req.event,
1273
1274                            responder: InputMethodEditorDispatchKey3Responder {
1275                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1276                                tx_id: header.tx_id,
1277                            },
1278                        })
1279                    }
1280                    0x19ba00ba1beb002e => {
1281                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1282                        let mut req = fidl::new_empty!(
1283                            fidl::encoding::EmptyPayload,
1284                            fidl::encoding::DefaultFuchsiaResourceDialect
1285                        );
1286                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1287                        let control_handle =
1288                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1289                        Ok(InputMethodEditorRequest::Show { control_handle })
1290                    }
1291                    0x283e0cd73f0d6d9e => {
1292                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1293                        let mut req = fidl::new_empty!(
1294                            fidl::encoding::EmptyPayload,
1295                            fidl::encoding::DefaultFuchsiaResourceDialect
1296                        );
1297                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1298                        let control_handle =
1299                            InputMethodEditorControlHandle { inner: this.inner.clone() };
1300                        Ok(InputMethodEditorRequest::Hide { control_handle })
1301                    }
1302                    _ => Err(fidl::Error::UnknownOrdinal {
1303                        ordinal: header.ordinal,
1304                        protocol_name:
1305                            <InputMethodEditorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1306                    }),
1307                }))
1308            },
1309        )
1310    }
1311}
1312
1313/// A interface for interacting with a text input control.
1314#[derive(Debug)]
1315pub enum InputMethodEditorRequest {
1316    SetKeyboardType {
1317        keyboard_type: KeyboardType,
1318        control_handle: InputMethodEditorControlHandle,
1319    },
1320    SetState {
1321        state: TextInputState,
1322        control_handle: InputMethodEditorControlHandle,
1323    },
1324    InjectInput {
1325        event: InputEvent,
1326        control_handle: InputMethodEditorControlHandle,
1327    },
1328    DispatchKey3 {
1329        event: fidl_fuchsia_ui_input3::KeyEvent,
1330        responder: InputMethodEditorDispatchKey3Responder,
1331    },
1332    Show {
1333        control_handle: InputMethodEditorControlHandle,
1334    },
1335    Hide {
1336        control_handle: InputMethodEditorControlHandle,
1337    },
1338}
1339
1340impl InputMethodEditorRequest {
1341    #[allow(irrefutable_let_patterns)]
1342    pub fn into_set_keyboard_type(self) -> Option<(KeyboardType, InputMethodEditorControlHandle)> {
1343        if let InputMethodEditorRequest::SetKeyboardType { keyboard_type, control_handle } = self {
1344            Some((keyboard_type, control_handle))
1345        } else {
1346            None
1347        }
1348    }
1349
1350    #[allow(irrefutable_let_patterns)]
1351    pub fn into_set_state(self) -> Option<(TextInputState, InputMethodEditorControlHandle)> {
1352        if let InputMethodEditorRequest::SetState { state, control_handle } = self {
1353            Some((state, control_handle))
1354        } else {
1355            None
1356        }
1357    }
1358
1359    #[allow(irrefutable_let_patterns)]
1360    pub fn into_inject_input(self) -> Option<(InputEvent, InputMethodEditorControlHandle)> {
1361        if let InputMethodEditorRequest::InjectInput { event, control_handle } = self {
1362            Some((event, control_handle))
1363        } else {
1364            None
1365        }
1366    }
1367
1368    #[allow(irrefutable_let_patterns)]
1369    pub fn into_dispatch_key3(
1370        self,
1371    ) -> Option<(fidl_fuchsia_ui_input3::KeyEvent, InputMethodEditorDispatchKey3Responder)> {
1372        if let InputMethodEditorRequest::DispatchKey3 { event, responder } = self {
1373            Some((event, responder))
1374        } else {
1375            None
1376        }
1377    }
1378
1379    #[allow(irrefutable_let_patterns)]
1380    pub fn into_show(self) -> Option<(InputMethodEditorControlHandle)> {
1381        if let InputMethodEditorRequest::Show { control_handle } = self {
1382            Some((control_handle))
1383        } else {
1384            None
1385        }
1386    }
1387
1388    #[allow(irrefutable_let_patterns)]
1389    pub fn into_hide(self) -> Option<(InputMethodEditorControlHandle)> {
1390        if let InputMethodEditorRequest::Hide { control_handle } = self {
1391            Some((control_handle))
1392        } else {
1393            None
1394        }
1395    }
1396
1397    /// Name of the method defined in FIDL
1398    pub fn method_name(&self) -> &'static str {
1399        match *self {
1400            InputMethodEditorRequest::SetKeyboardType { .. } => "set_keyboard_type",
1401            InputMethodEditorRequest::SetState { .. } => "set_state",
1402            InputMethodEditorRequest::InjectInput { .. } => "inject_input",
1403            InputMethodEditorRequest::DispatchKey3 { .. } => "dispatch_key3",
1404            InputMethodEditorRequest::Show { .. } => "show",
1405            InputMethodEditorRequest::Hide { .. } => "hide",
1406        }
1407    }
1408}
1409
1410#[derive(Debug, Clone)]
1411pub struct InputMethodEditorControlHandle {
1412    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1413}
1414
1415impl fidl::endpoints::ControlHandle for InputMethodEditorControlHandle {
1416    fn shutdown(&self) {
1417        self.inner.shutdown()
1418    }
1419    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1420        self.inner.shutdown_with_epitaph(status)
1421    }
1422
1423    fn is_closed(&self) -> bool {
1424        self.inner.channel().is_closed()
1425    }
1426    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1427        self.inner.channel().on_closed()
1428    }
1429
1430    #[cfg(target_os = "fuchsia")]
1431    fn signal_peer(
1432        &self,
1433        clear_mask: zx::Signals,
1434        set_mask: zx::Signals,
1435    ) -> Result<(), zx_status::Status> {
1436        use fidl::Peered;
1437        self.inner.channel().signal_peer(clear_mask, set_mask)
1438    }
1439}
1440
1441impl InputMethodEditorControlHandle {}
1442
1443#[must_use = "FIDL methods require a response to be sent"]
1444#[derive(Debug)]
1445pub struct InputMethodEditorDispatchKey3Responder {
1446    control_handle: std::mem::ManuallyDrop<InputMethodEditorControlHandle>,
1447    tx_id: u32,
1448}
1449
1450/// Set the the channel to be shutdown (see [`InputMethodEditorControlHandle::shutdown`])
1451/// if the responder is dropped without sending a response, so that the client
1452/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1453impl std::ops::Drop for InputMethodEditorDispatchKey3Responder {
1454    fn drop(&mut self) {
1455        self.control_handle.shutdown();
1456        // Safety: drops once, never accessed again
1457        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1458    }
1459}
1460
1461impl fidl::endpoints::Responder for InputMethodEditorDispatchKey3Responder {
1462    type ControlHandle = InputMethodEditorControlHandle;
1463
1464    fn control_handle(&self) -> &InputMethodEditorControlHandle {
1465        &self.control_handle
1466    }
1467
1468    fn drop_without_shutdown(mut self) {
1469        // Safety: drops once, never accessed again due to mem::forget
1470        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1471        // Prevent Drop from running (which would shut down the channel)
1472        std::mem::forget(self);
1473    }
1474}
1475
1476impl InputMethodEditorDispatchKey3Responder {
1477    /// Sends a response to the FIDL transaction.
1478    ///
1479    /// Sets the channel to shutdown if an error occurs.
1480    pub fn send(self, mut handled: bool) -> Result<(), fidl::Error> {
1481        let _result = self.send_raw(handled);
1482        if _result.is_err() {
1483            self.control_handle.shutdown();
1484        }
1485        self.drop_without_shutdown();
1486        _result
1487    }
1488
1489    /// Similar to "send" but does not shutdown the channel if an error occurs.
1490    pub fn send_no_shutdown_on_err(self, mut handled: bool) -> Result<(), fidl::Error> {
1491        let _result = self.send_raw(handled);
1492        self.drop_without_shutdown();
1493        _result
1494    }
1495
1496    fn send_raw(&self, mut handled: bool) -> Result<(), fidl::Error> {
1497        self.control_handle.inner.send::<InputMethodEditorDispatchKey3Response>(
1498            (handled,),
1499            self.tx_id,
1500            0x2e13667c827209ac,
1501            fidl::encoding::DynamicFlags::empty(),
1502        )
1503    }
1504}
1505
1506#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1507pub struct InputMethodEditorClientMarker;
1508
1509impl fidl::endpoints::ProtocolMarker for InputMethodEditorClientMarker {
1510    type Proxy = InputMethodEditorClientProxy;
1511    type RequestStream = InputMethodEditorClientRequestStream;
1512    #[cfg(target_os = "fuchsia")]
1513    type SynchronousProxy = InputMethodEditorClientSynchronousProxy;
1514
1515    const DEBUG_NAME: &'static str = "(anonymous) InputMethodEditorClient";
1516}
1517
1518pub trait InputMethodEditorClientProxyInterface: Send + Sync {
1519    fn r#did_update_state(
1520        &self,
1521        state: &TextInputState,
1522        event: Option<&InputEvent>,
1523    ) -> Result<(), fidl::Error>;
1524    fn r#on_action(&self, action: InputMethodAction) -> Result<(), fidl::Error>;
1525}
1526#[derive(Debug)]
1527#[cfg(target_os = "fuchsia")]
1528pub struct InputMethodEditorClientSynchronousProxy {
1529    client: fidl::client::sync::Client,
1530}
1531
1532#[cfg(target_os = "fuchsia")]
1533impl fidl::endpoints::SynchronousProxy for InputMethodEditorClientSynchronousProxy {
1534    type Proxy = InputMethodEditorClientProxy;
1535    type Protocol = InputMethodEditorClientMarker;
1536
1537    fn from_channel(inner: fidl::Channel) -> Self {
1538        Self::new(inner)
1539    }
1540
1541    fn into_channel(self) -> fidl::Channel {
1542        self.client.into_channel()
1543    }
1544
1545    fn as_channel(&self) -> &fidl::Channel {
1546        self.client.as_channel()
1547    }
1548}
1549
1550#[cfg(target_os = "fuchsia")]
1551impl InputMethodEditorClientSynchronousProxy {
1552    pub fn new(channel: fidl::Channel) -> Self {
1553        let protocol_name =
1554            <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1555        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1556    }
1557
1558    pub fn into_channel(self) -> fidl::Channel {
1559        self.client.into_channel()
1560    }
1561
1562    /// Waits until an event arrives and returns it. It is safe for other
1563    /// threads to make concurrent requests while waiting for an event.
1564    pub fn wait_for_event(
1565        &self,
1566        deadline: zx::MonotonicInstant,
1567    ) -> Result<InputMethodEditorClientEvent, fidl::Error> {
1568        InputMethodEditorClientEvent::decode(self.client.wait_for_event(deadline)?)
1569    }
1570
1571    pub fn r#did_update_state(
1572        &self,
1573        mut state: &TextInputState,
1574        mut event: Option<&InputEvent>,
1575    ) -> Result<(), fidl::Error> {
1576        self.client.send::<InputMethodEditorClientDidUpdateStateRequest>(
1577            (state, event),
1578            0x26681a6b204b679d,
1579            fidl::encoding::DynamicFlags::empty(),
1580        )
1581    }
1582
1583    pub fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
1584        self.client.send::<InputMethodEditorClientOnActionRequest>(
1585            (action,),
1586            0x19c420f173275398,
1587            fidl::encoding::DynamicFlags::empty(),
1588        )
1589    }
1590}
1591
1592#[derive(Debug, Clone)]
1593pub struct InputMethodEditorClientProxy {
1594    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1595}
1596
1597impl fidl::endpoints::Proxy for InputMethodEditorClientProxy {
1598    type Protocol = InputMethodEditorClientMarker;
1599
1600    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1601        Self::new(inner)
1602    }
1603
1604    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1605        self.client.into_channel().map_err(|client| Self { client })
1606    }
1607
1608    fn as_channel(&self) -> &::fidl::AsyncChannel {
1609        self.client.as_channel()
1610    }
1611}
1612
1613impl InputMethodEditorClientProxy {
1614    /// Create a new Proxy for fuchsia.ui.input/InputMethodEditorClient.
1615    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1616        let protocol_name =
1617            <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1618        Self { client: fidl::client::Client::new(channel, protocol_name) }
1619    }
1620
1621    /// Get a Stream of events from the remote end of the protocol.
1622    ///
1623    /// # Panics
1624    ///
1625    /// Panics if the event stream was already taken.
1626    pub fn take_event_stream(&self) -> InputMethodEditorClientEventStream {
1627        InputMethodEditorClientEventStream { event_receiver: self.client.take_event_receiver() }
1628    }
1629
1630    pub fn r#did_update_state(
1631        &self,
1632        mut state: &TextInputState,
1633        mut event: Option<&InputEvent>,
1634    ) -> Result<(), fidl::Error> {
1635        InputMethodEditorClientProxyInterface::r#did_update_state(self, state, event)
1636    }
1637
1638    pub fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
1639        InputMethodEditorClientProxyInterface::r#on_action(self, action)
1640    }
1641}
1642
1643impl InputMethodEditorClientProxyInterface for InputMethodEditorClientProxy {
1644    fn r#did_update_state(
1645        &self,
1646        mut state: &TextInputState,
1647        mut event: Option<&InputEvent>,
1648    ) -> Result<(), fidl::Error> {
1649        self.client.send::<InputMethodEditorClientDidUpdateStateRequest>(
1650            (state, event),
1651            0x26681a6b204b679d,
1652            fidl::encoding::DynamicFlags::empty(),
1653        )
1654    }
1655
1656    fn r#on_action(&self, mut action: InputMethodAction) -> Result<(), fidl::Error> {
1657        self.client.send::<InputMethodEditorClientOnActionRequest>(
1658            (action,),
1659            0x19c420f173275398,
1660            fidl::encoding::DynamicFlags::empty(),
1661        )
1662    }
1663}
1664
1665pub struct InputMethodEditorClientEventStream {
1666    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1667}
1668
1669impl std::marker::Unpin for InputMethodEditorClientEventStream {}
1670
1671impl futures::stream::FusedStream for InputMethodEditorClientEventStream {
1672    fn is_terminated(&self) -> bool {
1673        self.event_receiver.is_terminated()
1674    }
1675}
1676
1677impl futures::Stream for InputMethodEditorClientEventStream {
1678    type Item = Result<InputMethodEditorClientEvent, fidl::Error>;
1679
1680    fn poll_next(
1681        mut self: std::pin::Pin<&mut Self>,
1682        cx: &mut std::task::Context<'_>,
1683    ) -> std::task::Poll<Option<Self::Item>> {
1684        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1685            &mut self.event_receiver,
1686            cx
1687        )?) {
1688            Some(buf) => std::task::Poll::Ready(Some(InputMethodEditorClientEvent::decode(buf))),
1689            None => std::task::Poll::Ready(None),
1690        }
1691    }
1692}
1693
1694#[derive(Debug)]
1695pub enum InputMethodEditorClientEvent {}
1696
1697impl InputMethodEditorClientEvent {
1698    /// Decodes a message buffer as a [`InputMethodEditorClientEvent`].
1699    fn decode(
1700        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1701    ) -> Result<InputMethodEditorClientEvent, fidl::Error> {
1702        let (bytes, _handles) = buf.split_mut();
1703        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1704        debug_assert_eq!(tx_header.tx_id, 0);
1705        match tx_header.ordinal {
1706            _ => Err(fidl::Error::UnknownOrdinal {
1707                ordinal: tx_header.ordinal,
1708                protocol_name:
1709                    <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1710            }),
1711        }
1712    }
1713}
1714
1715/// A Stream of incoming requests for fuchsia.ui.input/InputMethodEditorClient.
1716pub struct InputMethodEditorClientRequestStream {
1717    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1718    is_terminated: bool,
1719}
1720
1721impl std::marker::Unpin for InputMethodEditorClientRequestStream {}
1722
1723impl futures::stream::FusedStream for InputMethodEditorClientRequestStream {
1724    fn is_terminated(&self) -> bool {
1725        self.is_terminated
1726    }
1727}
1728
1729impl fidl::endpoints::RequestStream for InputMethodEditorClientRequestStream {
1730    type Protocol = InputMethodEditorClientMarker;
1731    type ControlHandle = InputMethodEditorClientControlHandle;
1732
1733    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1734        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1735    }
1736
1737    fn control_handle(&self) -> Self::ControlHandle {
1738        InputMethodEditorClientControlHandle { inner: self.inner.clone() }
1739    }
1740
1741    fn into_inner(
1742        self,
1743    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1744    {
1745        (self.inner, self.is_terminated)
1746    }
1747
1748    fn from_inner(
1749        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1750        is_terminated: bool,
1751    ) -> Self {
1752        Self { inner, is_terminated }
1753    }
1754}
1755
1756impl futures::Stream for InputMethodEditorClientRequestStream {
1757    type Item = Result<InputMethodEditorClientRequest, fidl::Error>;
1758
1759    fn poll_next(
1760        mut self: std::pin::Pin<&mut Self>,
1761        cx: &mut std::task::Context<'_>,
1762    ) -> std::task::Poll<Option<Self::Item>> {
1763        let this = &mut *self;
1764        if this.inner.check_shutdown(cx) {
1765            this.is_terminated = true;
1766            return std::task::Poll::Ready(None);
1767        }
1768        if this.is_terminated {
1769            panic!("polled InputMethodEditorClientRequestStream after completion");
1770        }
1771        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1772            |bytes, handles| {
1773                match this.inner.channel().read_etc(cx, bytes, handles) {
1774                    std::task::Poll::Ready(Ok(())) => {}
1775                    std::task::Poll::Pending => return std::task::Poll::Pending,
1776                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1777                        this.is_terminated = true;
1778                        return std::task::Poll::Ready(None);
1779                    }
1780                    std::task::Poll::Ready(Err(e)) => {
1781                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1782                            e.into(),
1783                        ))))
1784                    }
1785                }
1786
1787                // A message has been received from the channel
1788                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1789
1790                std::task::Poll::Ready(Some(match header.ordinal {
1791                0x26681a6b204b679d => {
1792                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1793                    let mut req = fidl::new_empty!(InputMethodEditorClientDidUpdateStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1794                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorClientDidUpdateStateRequest>(&header, _body_bytes, handles, &mut req)?;
1795                    let control_handle = InputMethodEditorClientControlHandle {
1796                        inner: this.inner.clone(),
1797                    };
1798                    Ok(InputMethodEditorClientRequest::DidUpdateState {state: req.state,
1799event: req.event,
1800
1801                        control_handle,
1802                    })
1803                }
1804                0x19c420f173275398 => {
1805                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1806                    let mut req = fidl::new_empty!(InputMethodEditorClientOnActionRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1807                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputMethodEditorClientOnActionRequest>(&header, _body_bytes, handles, &mut req)?;
1808                    let control_handle = InputMethodEditorClientControlHandle {
1809                        inner: this.inner.clone(),
1810                    };
1811                    Ok(InputMethodEditorClientRequest::OnAction {action: req.action,
1812
1813                        control_handle,
1814                    })
1815                }
1816                _ => Err(fidl::Error::UnknownOrdinal {
1817                    ordinal: header.ordinal,
1818                    protocol_name: <InputMethodEditorClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1819                }),
1820            }))
1821            },
1822        )
1823    }
1824}
1825
1826/// An interface to receive information from `TextInputService`.
1827#[derive(Debug)]
1828pub enum InputMethodEditorClientRequest {
1829    DidUpdateState {
1830        state: TextInputState,
1831        event: Option<Box<InputEvent>>,
1832        control_handle: InputMethodEditorClientControlHandle,
1833    },
1834    OnAction {
1835        action: InputMethodAction,
1836        control_handle: InputMethodEditorClientControlHandle,
1837    },
1838}
1839
1840impl InputMethodEditorClientRequest {
1841    #[allow(irrefutable_let_patterns)]
1842    pub fn into_did_update_state(
1843        self,
1844    ) -> Option<(TextInputState, Option<Box<InputEvent>>, InputMethodEditorClientControlHandle)>
1845    {
1846        if let InputMethodEditorClientRequest::DidUpdateState { state, event, control_handle } =
1847            self
1848        {
1849            Some((state, event, control_handle))
1850        } else {
1851            None
1852        }
1853    }
1854
1855    #[allow(irrefutable_let_patterns)]
1856    pub fn into_on_action(
1857        self,
1858    ) -> Option<(InputMethodAction, InputMethodEditorClientControlHandle)> {
1859        if let InputMethodEditorClientRequest::OnAction { action, control_handle } = self {
1860            Some((action, control_handle))
1861        } else {
1862            None
1863        }
1864    }
1865
1866    /// Name of the method defined in FIDL
1867    pub fn method_name(&self) -> &'static str {
1868        match *self {
1869            InputMethodEditorClientRequest::DidUpdateState { .. } => "did_update_state",
1870            InputMethodEditorClientRequest::OnAction { .. } => "on_action",
1871        }
1872    }
1873}
1874
1875#[derive(Debug, Clone)]
1876pub struct InputMethodEditorClientControlHandle {
1877    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1878}
1879
1880impl fidl::endpoints::ControlHandle for InputMethodEditorClientControlHandle {
1881    fn shutdown(&self) {
1882        self.inner.shutdown()
1883    }
1884    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1885        self.inner.shutdown_with_epitaph(status)
1886    }
1887
1888    fn is_closed(&self) -> bool {
1889        self.inner.channel().is_closed()
1890    }
1891    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1892        self.inner.channel().on_closed()
1893    }
1894
1895    #[cfg(target_os = "fuchsia")]
1896    fn signal_peer(
1897        &self,
1898        clear_mask: zx::Signals,
1899        set_mask: zx::Signals,
1900    ) -> Result<(), zx_status::Status> {
1901        use fidl::Peered;
1902        self.inner.channel().signal_peer(clear_mask, set_mask)
1903    }
1904}
1905
1906impl InputMethodEditorClientControlHandle {}
1907
1908mod internal {
1909    use super::*;
1910
1911    impl fidl::encoding::ResourceTypeMarker for ImeServiceGetInputMethodEditorRequest {
1912        type Borrowed<'a> = &'a mut Self;
1913        fn take_or_borrow<'a>(
1914            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1915        ) -> Self::Borrowed<'a> {
1916            value
1917        }
1918    }
1919
1920    unsafe impl fidl::encoding::TypeMarker for ImeServiceGetInputMethodEditorRequest {
1921        type Owned = Self;
1922
1923        #[inline(always)]
1924        fn inline_align(_context: fidl::encoding::Context) -> usize {
1925            8
1926        }
1927
1928        #[inline(always)]
1929        fn inline_size(_context: fidl::encoding::Context) -> usize {
1930            80
1931        }
1932    }
1933
1934    unsafe impl
1935        fidl::encoding::Encode<
1936            ImeServiceGetInputMethodEditorRequest,
1937            fidl::encoding::DefaultFuchsiaResourceDialect,
1938        > for &mut ImeServiceGetInputMethodEditorRequest
1939    {
1940        #[inline]
1941        unsafe fn encode(
1942            self,
1943            encoder: &mut fidl::encoding::Encoder<
1944                '_,
1945                fidl::encoding::DefaultFuchsiaResourceDialect,
1946            >,
1947            offset: usize,
1948            _depth: fidl::encoding::Depth,
1949        ) -> fidl::Result<()> {
1950            encoder.debug_check_bounds::<ImeServiceGetInputMethodEditorRequest>(offset);
1951            // Delegate to tuple encoding.
1952            fidl::encoding::Encode::<ImeServiceGetInputMethodEditorRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1953                (
1954                    <KeyboardType as fidl::encoding::ValueTypeMarker>::borrow(&self.keyboard_type),
1955                    <InputMethodAction as fidl::encoding::ValueTypeMarker>::borrow(&self.action),
1956                    <TextInputState as fidl::encoding::ValueTypeMarker>::borrow(&self.initial_state),
1957                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.client),
1958                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.editor),
1959                ),
1960                encoder, offset, _depth
1961            )
1962        }
1963    }
1964    unsafe impl<
1965            T0: fidl::encoding::Encode<KeyboardType, fidl::encoding::DefaultFuchsiaResourceDialect>,
1966            T1: fidl::encoding::Encode<
1967                InputMethodAction,
1968                fidl::encoding::DefaultFuchsiaResourceDialect,
1969            >,
1970            T2: fidl::encoding::Encode<TextInputState, fidl::encoding::DefaultFuchsiaResourceDialect>,
1971            T3: fidl::encoding::Encode<
1972                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>>,
1973                fidl::encoding::DefaultFuchsiaResourceDialect,
1974            >,
1975            T4: fidl::encoding::Encode<
1976                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
1977                fidl::encoding::DefaultFuchsiaResourceDialect,
1978            >,
1979        >
1980        fidl::encoding::Encode<
1981            ImeServiceGetInputMethodEditorRequest,
1982            fidl::encoding::DefaultFuchsiaResourceDialect,
1983        > for (T0, T1, T2, T3, T4)
1984    {
1985        #[inline]
1986        unsafe fn encode(
1987            self,
1988            encoder: &mut fidl::encoding::Encoder<
1989                '_,
1990                fidl::encoding::DefaultFuchsiaResourceDialect,
1991            >,
1992            offset: usize,
1993            depth: fidl::encoding::Depth,
1994        ) -> fidl::Result<()> {
1995            encoder.debug_check_bounds::<ImeServiceGetInputMethodEditorRequest>(offset);
1996            // Zero out padding regions. There's no need to apply masks
1997            // because the unmasked parts will be overwritten by fields.
1998            // Write the fields.
1999            self.0.encode(encoder, offset + 0, depth)?;
2000            self.1.encode(encoder, offset + 4, depth)?;
2001            self.2.encode(encoder, offset + 8, depth)?;
2002            self.3.encode(encoder, offset + 72, depth)?;
2003            self.4.encode(encoder, offset + 76, depth)?;
2004            Ok(())
2005        }
2006    }
2007
2008    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2009        for ImeServiceGetInputMethodEditorRequest
2010    {
2011        #[inline(always)]
2012        fn new_empty() -> Self {
2013            Self {
2014                keyboard_type: fidl::new_empty!(
2015                    KeyboardType,
2016                    fidl::encoding::DefaultFuchsiaResourceDialect
2017                ),
2018                action: fidl::new_empty!(
2019                    InputMethodAction,
2020                    fidl::encoding::DefaultFuchsiaResourceDialect
2021                ),
2022                initial_state: fidl::new_empty!(
2023                    TextInputState,
2024                    fidl::encoding::DefaultFuchsiaResourceDialect
2025                ),
2026                client: fidl::new_empty!(
2027                    fidl::encoding::Endpoint<
2028                        fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>,
2029                    >,
2030                    fidl::encoding::DefaultFuchsiaResourceDialect
2031                ),
2032                editor: fidl::new_empty!(
2033                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
2034                    fidl::encoding::DefaultFuchsiaResourceDialect
2035                ),
2036            }
2037        }
2038
2039        #[inline]
2040        unsafe fn decode(
2041            &mut self,
2042            decoder: &mut fidl::encoding::Decoder<
2043                '_,
2044                fidl::encoding::DefaultFuchsiaResourceDialect,
2045            >,
2046            offset: usize,
2047            _depth: fidl::encoding::Depth,
2048        ) -> fidl::Result<()> {
2049            decoder.debug_check_bounds::<Self>(offset);
2050            // Verify that padding bytes are zero.
2051            fidl::decode!(
2052                KeyboardType,
2053                fidl::encoding::DefaultFuchsiaResourceDialect,
2054                &mut self.keyboard_type,
2055                decoder,
2056                offset + 0,
2057                _depth
2058            )?;
2059            fidl::decode!(
2060                InputMethodAction,
2061                fidl::encoding::DefaultFuchsiaResourceDialect,
2062                &mut self.action,
2063                decoder,
2064                offset + 4,
2065                _depth
2066            )?;
2067            fidl::decode!(
2068                TextInputState,
2069                fidl::encoding::DefaultFuchsiaResourceDialect,
2070                &mut self.initial_state,
2071                decoder,
2072                offset + 8,
2073                _depth
2074            )?;
2075            fidl::decode!(
2076                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<InputMethodEditorClientMarker>>,
2077                fidl::encoding::DefaultFuchsiaResourceDialect,
2078                &mut self.client,
2079                decoder,
2080                offset + 72,
2081                _depth
2082            )?;
2083            fidl::decode!(
2084                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InputMethodEditorMarker>>,
2085                fidl::encoding::DefaultFuchsiaResourceDialect,
2086                &mut self.editor,
2087                decoder,
2088                offset + 76,
2089                _depth
2090            )?;
2091            Ok(())
2092        }
2093    }
2094}