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