fidl_fuchsia_ui_pointer_augment/
fidl_fuchsia_ui_pointer_augment.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_pointer_augment__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ErrorForLocalHit {
16    /// Abnormal reason for return.
17    pub error_reason: ErrorReason,
18    /// Original protocol endpoint for client use.
19    pub original: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
20}
21
22impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ErrorForLocalHit {}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct LocalHitUpgradeRequest {
26    pub original: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LocalHitUpgradeRequest {}
30
31#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
32pub struct LocalHitUpgradeResponse {
33    pub augmented: Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
34    pub error: Option<Box<ErrorForLocalHit>>,
35}
36
37impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LocalHitUpgradeResponse {}
38
39#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
40pub struct LocalHitMarker;
41
42impl fidl::endpoints::ProtocolMarker for LocalHitMarker {
43    type Proxy = LocalHitProxy;
44    type RequestStream = LocalHitRequestStream;
45    #[cfg(target_os = "fuchsia")]
46    type SynchronousProxy = LocalHitSynchronousProxy;
47
48    const DEBUG_NAME: &'static str = "fuchsia.ui.pointer.augment.LocalHit";
49}
50impl fidl::endpoints::DiscoverableProtocolMarker for LocalHitMarker {}
51
52pub trait LocalHitProxyInterface: Send + Sync {
53    type UpgradeResponseFut: std::future::Future<
54            Output = Result<
55                (
56                    Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
57                    Option<Box<ErrorForLocalHit>>,
58                ),
59                fidl::Error,
60            >,
61        > + Send;
62    fn r#upgrade(
63        &self,
64        original: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
65    ) -> Self::UpgradeResponseFut;
66}
67#[derive(Debug)]
68#[cfg(target_os = "fuchsia")]
69pub struct LocalHitSynchronousProxy {
70    client: fidl::client::sync::Client,
71}
72
73#[cfg(target_os = "fuchsia")]
74impl fidl::endpoints::SynchronousProxy for LocalHitSynchronousProxy {
75    type Proxy = LocalHitProxy;
76    type Protocol = LocalHitMarker;
77
78    fn from_channel(inner: fidl::Channel) -> Self {
79        Self::new(inner)
80    }
81
82    fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    fn as_channel(&self) -> &fidl::Channel {
87        self.client.as_channel()
88    }
89}
90
91#[cfg(target_os = "fuchsia")]
92impl LocalHitSynchronousProxy {
93    pub fn new(channel: fidl::Channel) -> Self {
94        let protocol_name = <LocalHitMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
95        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
96    }
97
98    pub fn into_channel(self) -> fidl::Channel {
99        self.client.into_channel()
100    }
101
102    /// Waits until an event arrives and returns it. It is safe for other
103    /// threads to make concurrent requests while waiting for an event.
104    pub fn wait_for_event(
105        &self,
106        deadline: zx::MonotonicInstant,
107    ) -> Result<LocalHitEvent, fidl::Error> {
108        LocalHitEvent::decode(self.client.wait_for_event(deadline)?)
109    }
110
111    /// An exchange from an `original` touch protocol endpoint to an `augmented`
112    /// touch protocol endpoint. If successful, `error` is empty, `original` is
113    /// consumed, and `augmented` is returned for the client's use. Otherwise,
114    /// the `error` carries back `original` for the client's use, and
115    /// `augmented` is null.
116    pub fn r#upgrade(
117        &self,
118        mut original: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
119        ___deadline: zx::MonotonicInstant,
120    ) -> Result<
121        (
122            Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
123            Option<Box<ErrorForLocalHit>>,
124        ),
125        fidl::Error,
126    > {
127        let _response = self.client.send_query::<LocalHitUpgradeRequest, LocalHitUpgradeResponse>(
128            (original,),
129            0x1ec0c985bbfe4e8c,
130            fidl::encoding::DynamicFlags::empty(),
131            ___deadline,
132        )?;
133        Ok((_response.augmented, _response.error))
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl From<LocalHitSynchronousProxy> for zx::Handle {
139    fn from(value: LocalHitSynchronousProxy) -> Self {
140        value.into_channel().into()
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl From<fidl::Channel> for LocalHitSynchronousProxy {
146    fn from(value: fidl::Channel) -> Self {
147        Self::new(value)
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl fidl::endpoints::FromClient for LocalHitSynchronousProxy {
153    type Protocol = LocalHitMarker;
154
155    fn from_client(value: fidl::endpoints::ClientEnd<LocalHitMarker>) -> Self {
156        Self::new(value.into_channel())
157    }
158}
159
160#[derive(Debug, Clone)]
161pub struct LocalHitProxy {
162    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
163}
164
165impl fidl::endpoints::Proxy for LocalHitProxy {
166    type Protocol = LocalHitMarker;
167
168    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
169        Self::new(inner)
170    }
171
172    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
173        self.client.into_channel().map_err(|client| Self { client })
174    }
175
176    fn as_channel(&self) -> &::fidl::AsyncChannel {
177        self.client.as_channel()
178    }
179}
180
181impl LocalHitProxy {
182    /// Create a new Proxy for fuchsia.ui.pointer.augment/LocalHit.
183    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
184        let protocol_name = <LocalHitMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
185        Self { client: fidl::client::Client::new(channel, protocol_name) }
186    }
187
188    /// Get a Stream of events from the remote end of the protocol.
189    ///
190    /// # Panics
191    ///
192    /// Panics if the event stream was already taken.
193    pub fn take_event_stream(&self) -> LocalHitEventStream {
194        LocalHitEventStream { event_receiver: self.client.take_event_receiver() }
195    }
196
197    /// An exchange from an `original` touch protocol endpoint to an `augmented`
198    /// touch protocol endpoint. If successful, `error` is empty, `original` is
199    /// consumed, and `augmented` is returned for the client's use. Otherwise,
200    /// the `error` carries back `original` for the client's use, and
201    /// `augmented` is null.
202    pub fn r#upgrade(
203        &self,
204        mut original: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
205    ) -> fidl::client::QueryResponseFut<
206        (
207            Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
208            Option<Box<ErrorForLocalHit>>,
209        ),
210        fidl::encoding::DefaultFuchsiaResourceDialect,
211    > {
212        LocalHitProxyInterface::r#upgrade(self, original)
213    }
214}
215
216impl LocalHitProxyInterface for LocalHitProxy {
217    type UpgradeResponseFut = fidl::client::QueryResponseFut<
218        (
219            Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
220            Option<Box<ErrorForLocalHit>>,
221        ),
222        fidl::encoding::DefaultFuchsiaResourceDialect,
223    >;
224    fn r#upgrade(
225        &self,
226        mut original: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
227    ) -> Self::UpgradeResponseFut {
228        fn _decode(
229            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
230        ) -> Result<
231            (
232                Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
233                Option<Box<ErrorForLocalHit>>,
234            ),
235            fidl::Error,
236        > {
237            let _response = fidl::client::decode_transaction_body::<
238                LocalHitUpgradeResponse,
239                fidl::encoding::DefaultFuchsiaResourceDialect,
240                0x1ec0c985bbfe4e8c,
241            >(_buf?)?;
242            Ok((_response.augmented, _response.error))
243        }
244        self.client.send_query_and_decode::<LocalHitUpgradeRequest, (
245            Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
246            Option<Box<ErrorForLocalHit>>,
247        )>(
248            (original,), 0x1ec0c985bbfe4e8c, fidl::encoding::DynamicFlags::empty(), _decode
249        )
250    }
251}
252
253pub struct LocalHitEventStream {
254    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
255}
256
257impl std::marker::Unpin for LocalHitEventStream {}
258
259impl futures::stream::FusedStream for LocalHitEventStream {
260    fn is_terminated(&self) -> bool {
261        self.event_receiver.is_terminated()
262    }
263}
264
265impl futures::Stream for LocalHitEventStream {
266    type Item = Result<LocalHitEvent, fidl::Error>;
267
268    fn poll_next(
269        mut self: std::pin::Pin<&mut Self>,
270        cx: &mut std::task::Context<'_>,
271    ) -> std::task::Poll<Option<Self::Item>> {
272        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
273            &mut self.event_receiver,
274            cx
275        )?) {
276            Some(buf) => std::task::Poll::Ready(Some(LocalHitEvent::decode(buf))),
277            None => std::task::Poll::Ready(None),
278        }
279    }
280}
281
282#[derive(Debug)]
283pub enum LocalHitEvent {}
284
285impl LocalHitEvent {
286    /// Decodes a message buffer as a [`LocalHitEvent`].
287    fn decode(
288        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
289    ) -> Result<LocalHitEvent, fidl::Error> {
290        let (bytes, _handles) = buf.split_mut();
291        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
292        debug_assert_eq!(tx_header.tx_id, 0);
293        match tx_header.ordinal {
294            _ => Err(fidl::Error::UnknownOrdinal {
295                ordinal: tx_header.ordinal,
296                protocol_name: <LocalHitMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
297            }),
298        }
299    }
300}
301
302/// A Stream of incoming requests for fuchsia.ui.pointer.augment/LocalHit.
303pub struct LocalHitRequestStream {
304    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
305    is_terminated: bool,
306}
307
308impl std::marker::Unpin for LocalHitRequestStream {}
309
310impl futures::stream::FusedStream for LocalHitRequestStream {
311    fn is_terminated(&self) -> bool {
312        self.is_terminated
313    }
314}
315
316impl fidl::endpoints::RequestStream for LocalHitRequestStream {
317    type Protocol = LocalHitMarker;
318    type ControlHandle = LocalHitControlHandle;
319
320    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
321        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
322    }
323
324    fn control_handle(&self) -> Self::ControlHandle {
325        LocalHitControlHandle { inner: self.inner.clone() }
326    }
327
328    fn into_inner(
329        self,
330    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
331    {
332        (self.inner, self.is_terminated)
333    }
334
335    fn from_inner(
336        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
337        is_terminated: bool,
338    ) -> Self {
339        Self { inner, is_terminated }
340    }
341}
342
343impl futures::Stream for LocalHitRequestStream {
344    type Item = Result<LocalHitRequest, fidl::Error>;
345
346    fn poll_next(
347        mut self: std::pin::Pin<&mut Self>,
348        cx: &mut std::task::Context<'_>,
349    ) -> std::task::Poll<Option<Self::Item>> {
350        let this = &mut *self;
351        if this.inner.check_shutdown(cx) {
352            this.is_terminated = true;
353            return std::task::Poll::Ready(None);
354        }
355        if this.is_terminated {
356            panic!("polled LocalHitRequestStream after completion");
357        }
358        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
359            |bytes, handles| {
360                match this.inner.channel().read_etc(cx, bytes, handles) {
361                    std::task::Poll::Ready(Ok(())) => {}
362                    std::task::Poll::Pending => return std::task::Poll::Pending,
363                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
364                        this.is_terminated = true;
365                        return std::task::Poll::Ready(None);
366                    }
367                    std::task::Poll::Ready(Err(e)) => {
368                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
369                            e.into(),
370                        ))));
371                    }
372                }
373
374                // A message has been received from the channel
375                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
376
377                std::task::Poll::Ready(Some(match header.ordinal {
378                    0x1ec0c985bbfe4e8c => {
379                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
380                        let mut req = fidl::new_empty!(
381                            LocalHitUpgradeRequest,
382                            fidl::encoding::DefaultFuchsiaResourceDialect
383                        );
384                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalHitUpgradeRequest>(&header, _body_bytes, handles, &mut req)?;
385                        let control_handle = LocalHitControlHandle { inner: this.inner.clone() };
386                        Ok(LocalHitRequest::Upgrade {
387                            original: req.original,
388
389                            responder: LocalHitUpgradeResponder {
390                                control_handle: std::mem::ManuallyDrop::new(control_handle),
391                                tx_id: header.tx_id,
392                            },
393                        })
394                    }
395                    _ => Err(fidl::Error::UnknownOrdinal {
396                        ordinal: header.ordinal,
397                        protocol_name:
398                            <LocalHitMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
399                    }),
400                }))
401            },
402        )
403    }
404}
405
406/// A method for a client to upgrade its touch event protocol to additionally
407/// receive local-hit data for touch events.
408#[derive(Debug)]
409pub enum LocalHitRequest {
410    /// An exchange from an `original` touch protocol endpoint to an `augmented`
411    /// touch protocol endpoint. If successful, `error` is empty, `original` is
412    /// consumed, and `augmented` is returned for the client's use. Otherwise,
413    /// the `error` carries back `original` for the client's use, and
414    /// `augmented` is null.
415    Upgrade {
416        original: fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
417        responder: LocalHitUpgradeResponder,
418    },
419}
420
421impl LocalHitRequest {
422    #[allow(irrefutable_let_patterns)]
423    pub fn into_upgrade(
424        self,
425    ) -> Option<(
426        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
427        LocalHitUpgradeResponder,
428    )> {
429        if let LocalHitRequest::Upgrade { original, responder } = self {
430            Some((original, responder))
431        } else {
432            None
433        }
434    }
435
436    /// Name of the method defined in FIDL
437    pub fn method_name(&self) -> &'static str {
438        match *self {
439            LocalHitRequest::Upgrade { .. } => "upgrade",
440        }
441    }
442}
443
444#[derive(Debug, Clone)]
445pub struct LocalHitControlHandle {
446    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
447}
448
449impl fidl::endpoints::ControlHandle for LocalHitControlHandle {
450    fn shutdown(&self) {
451        self.inner.shutdown()
452    }
453    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
454        self.inner.shutdown_with_epitaph(status)
455    }
456
457    fn is_closed(&self) -> bool {
458        self.inner.channel().is_closed()
459    }
460    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
461        self.inner.channel().on_closed()
462    }
463
464    #[cfg(target_os = "fuchsia")]
465    fn signal_peer(
466        &self,
467        clear_mask: zx::Signals,
468        set_mask: zx::Signals,
469    ) -> Result<(), zx_status::Status> {
470        use fidl::Peered;
471        self.inner.channel().signal_peer(clear_mask, set_mask)
472    }
473}
474
475impl LocalHitControlHandle {}
476
477#[must_use = "FIDL methods require a response to be sent"]
478#[derive(Debug)]
479pub struct LocalHitUpgradeResponder {
480    control_handle: std::mem::ManuallyDrop<LocalHitControlHandle>,
481    tx_id: u32,
482}
483
484/// Set the the channel to be shutdown (see [`LocalHitControlHandle::shutdown`])
485/// if the responder is dropped without sending a response, so that the client
486/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
487impl std::ops::Drop for LocalHitUpgradeResponder {
488    fn drop(&mut self) {
489        self.control_handle.shutdown();
490        // Safety: drops once, never accessed again
491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
492    }
493}
494
495impl fidl::endpoints::Responder for LocalHitUpgradeResponder {
496    type ControlHandle = LocalHitControlHandle;
497
498    fn control_handle(&self) -> &LocalHitControlHandle {
499        &self.control_handle
500    }
501
502    fn drop_without_shutdown(mut self) {
503        // Safety: drops once, never accessed again due to mem::forget
504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
505        // Prevent Drop from running (which would shut down the channel)
506        std::mem::forget(self);
507    }
508}
509
510impl LocalHitUpgradeResponder {
511    /// Sends a response to the FIDL transaction.
512    ///
513    /// Sets the channel to shutdown if an error occurs.
514    pub fn send(
515        self,
516        mut augmented: Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
517        mut error: Option<ErrorForLocalHit>,
518    ) -> Result<(), fidl::Error> {
519        let _result = self.send_raw(augmented, error);
520        if _result.is_err() {
521            self.control_handle.shutdown();
522        }
523        self.drop_without_shutdown();
524        _result
525    }
526
527    /// Similar to "send" but does not shutdown the channel if an error occurs.
528    pub fn send_no_shutdown_on_err(
529        self,
530        mut augmented: Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
531        mut error: Option<ErrorForLocalHit>,
532    ) -> Result<(), fidl::Error> {
533        let _result = self.send_raw(augmented, error);
534        self.drop_without_shutdown();
535        _result
536    }
537
538    fn send_raw(
539        &self,
540        mut augmented: Option<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>,
541        mut error: Option<ErrorForLocalHit>,
542    ) -> Result<(), fidl::Error> {
543        self.control_handle.inner.send::<LocalHitUpgradeResponse>(
544            (augmented, error.as_mut()),
545            self.tx_id,
546            0x1ec0c985bbfe4e8c,
547            fidl::encoding::DynamicFlags::empty(),
548        )
549    }
550}
551
552#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
553pub struct TouchSourceWithLocalHitMarker;
554
555impl fidl::endpoints::ProtocolMarker for TouchSourceWithLocalHitMarker {
556    type Proxy = TouchSourceWithLocalHitProxy;
557    type RequestStream = TouchSourceWithLocalHitRequestStream;
558    #[cfg(target_os = "fuchsia")]
559    type SynchronousProxy = TouchSourceWithLocalHitSynchronousProxy;
560
561    const DEBUG_NAME: &'static str = "(anonymous) TouchSourceWithLocalHit";
562}
563
564pub trait TouchSourceWithLocalHitProxyInterface: Send + Sync {
565    type WatchResponseFut: std::future::Future<Output = Result<Vec<TouchEventWithLocalHit>, fidl::Error>>
566        + Send;
567    fn r#watch(
568        &self,
569        responses: &[fidl_fuchsia_ui_pointer::TouchResponse],
570    ) -> Self::WatchResponseFut;
571    type UpdateResponseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
572    fn r#update_response(
573        &self,
574        interaction: &fidl_fuchsia_ui_pointer::TouchInteractionId,
575        response: &fidl_fuchsia_ui_pointer::TouchResponse,
576    ) -> Self::UpdateResponseResponseFut;
577}
578#[derive(Debug)]
579#[cfg(target_os = "fuchsia")]
580pub struct TouchSourceWithLocalHitSynchronousProxy {
581    client: fidl::client::sync::Client,
582}
583
584#[cfg(target_os = "fuchsia")]
585impl fidl::endpoints::SynchronousProxy for TouchSourceWithLocalHitSynchronousProxy {
586    type Proxy = TouchSourceWithLocalHitProxy;
587    type Protocol = TouchSourceWithLocalHitMarker;
588
589    fn from_channel(inner: fidl::Channel) -> Self {
590        Self::new(inner)
591    }
592
593    fn into_channel(self) -> fidl::Channel {
594        self.client.into_channel()
595    }
596
597    fn as_channel(&self) -> &fidl::Channel {
598        self.client.as_channel()
599    }
600}
601
602#[cfg(target_os = "fuchsia")]
603impl TouchSourceWithLocalHitSynchronousProxy {
604    pub fn new(channel: fidl::Channel) -> Self {
605        let protocol_name =
606            <TouchSourceWithLocalHitMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
607        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
608    }
609
610    pub fn into_channel(self) -> fidl::Channel {
611        self.client.into_channel()
612    }
613
614    /// Waits until an event arrives and returns it. It is safe for other
615    /// threads to make concurrent requests while waiting for an event.
616    pub fn wait_for_event(
617        &self,
618        deadline: zx::MonotonicInstant,
619    ) -> Result<TouchSourceWithLocalHitEvent, fidl::Error> {
620        TouchSourceWithLocalHitEvent::decode(self.client.wait_for_event(deadline)?)
621    }
622
623    /// Identical usage to [`fuchsia.ui.pointer.TouchSource.Watch`], but with
624    /// augmented data.
625    pub fn r#watch(
626        &self,
627        mut responses: &[fidl_fuchsia_ui_pointer::TouchResponse],
628        ___deadline: zx::MonotonicInstant,
629    ) -> Result<Vec<TouchEventWithLocalHit>, fidl::Error> {
630        let _response = self.client.send_query::<
631            TouchSourceWithLocalHitWatchRequest,
632            TouchSourceWithLocalHitWatchResponse,
633        >(
634            (responses,),
635            0x4eb5acc052ada449,
636            fidl::encoding::DynamicFlags::empty(),
637            ___deadline,
638        )?;
639        Ok(_response.events)
640    }
641
642    /// Identical usage to [`fuchsia.ui.pointer.TouchSource.UpdateResponse`].
643    pub fn r#update_response(
644        &self,
645        mut interaction: &fidl_fuchsia_ui_pointer::TouchInteractionId,
646        mut response: &fidl_fuchsia_ui_pointer::TouchResponse,
647        ___deadline: zx::MonotonicInstant,
648    ) -> Result<(), fidl::Error> {
649        let _response = self.client.send_query::<
650            TouchSourceWithLocalHitUpdateResponseRequest,
651            fidl::encoding::EmptyPayload,
652        >(
653            (interaction, response,),
654            0x1f2fde6734e7da1,
655            fidl::encoding::DynamicFlags::empty(),
656            ___deadline,
657        )?;
658        Ok(_response)
659    }
660}
661
662#[cfg(target_os = "fuchsia")]
663impl From<TouchSourceWithLocalHitSynchronousProxy> for zx::Handle {
664    fn from(value: TouchSourceWithLocalHitSynchronousProxy) -> Self {
665        value.into_channel().into()
666    }
667}
668
669#[cfg(target_os = "fuchsia")]
670impl From<fidl::Channel> for TouchSourceWithLocalHitSynchronousProxy {
671    fn from(value: fidl::Channel) -> Self {
672        Self::new(value)
673    }
674}
675
676#[cfg(target_os = "fuchsia")]
677impl fidl::endpoints::FromClient for TouchSourceWithLocalHitSynchronousProxy {
678    type Protocol = TouchSourceWithLocalHitMarker;
679
680    fn from_client(value: fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>) -> Self {
681        Self::new(value.into_channel())
682    }
683}
684
685#[derive(Debug, Clone)]
686pub struct TouchSourceWithLocalHitProxy {
687    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
688}
689
690impl fidl::endpoints::Proxy for TouchSourceWithLocalHitProxy {
691    type Protocol = TouchSourceWithLocalHitMarker;
692
693    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
694        Self::new(inner)
695    }
696
697    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
698        self.client.into_channel().map_err(|client| Self { client })
699    }
700
701    fn as_channel(&self) -> &::fidl::AsyncChannel {
702        self.client.as_channel()
703    }
704}
705
706impl TouchSourceWithLocalHitProxy {
707    /// Create a new Proxy for fuchsia.ui.pointer.augment/TouchSourceWithLocalHit.
708    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
709        let protocol_name =
710            <TouchSourceWithLocalHitMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
711        Self { client: fidl::client::Client::new(channel, protocol_name) }
712    }
713
714    /// Get a Stream of events from the remote end of the protocol.
715    ///
716    /// # Panics
717    ///
718    /// Panics if the event stream was already taken.
719    pub fn take_event_stream(&self) -> TouchSourceWithLocalHitEventStream {
720        TouchSourceWithLocalHitEventStream { event_receiver: self.client.take_event_receiver() }
721    }
722
723    /// Identical usage to [`fuchsia.ui.pointer.TouchSource.Watch`], but with
724    /// augmented data.
725    pub fn r#watch(
726        &self,
727        mut responses: &[fidl_fuchsia_ui_pointer::TouchResponse],
728    ) -> fidl::client::QueryResponseFut<
729        Vec<TouchEventWithLocalHit>,
730        fidl::encoding::DefaultFuchsiaResourceDialect,
731    > {
732        TouchSourceWithLocalHitProxyInterface::r#watch(self, responses)
733    }
734
735    /// Identical usage to [`fuchsia.ui.pointer.TouchSource.UpdateResponse`].
736    pub fn r#update_response(
737        &self,
738        mut interaction: &fidl_fuchsia_ui_pointer::TouchInteractionId,
739        mut response: &fidl_fuchsia_ui_pointer::TouchResponse,
740    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
741        TouchSourceWithLocalHitProxyInterface::r#update_response(self, interaction, response)
742    }
743}
744
745impl TouchSourceWithLocalHitProxyInterface for TouchSourceWithLocalHitProxy {
746    type WatchResponseFut = fidl::client::QueryResponseFut<
747        Vec<TouchEventWithLocalHit>,
748        fidl::encoding::DefaultFuchsiaResourceDialect,
749    >;
750    fn r#watch(
751        &self,
752        mut responses: &[fidl_fuchsia_ui_pointer::TouchResponse],
753    ) -> Self::WatchResponseFut {
754        fn _decode(
755            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
756        ) -> Result<Vec<TouchEventWithLocalHit>, fidl::Error> {
757            let _response = fidl::client::decode_transaction_body::<
758                TouchSourceWithLocalHitWatchResponse,
759                fidl::encoding::DefaultFuchsiaResourceDialect,
760                0x4eb5acc052ada449,
761            >(_buf?)?;
762            Ok(_response.events)
763        }
764        self.client.send_query_and_decode::<
765            TouchSourceWithLocalHitWatchRequest,
766            Vec<TouchEventWithLocalHit>,
767        >(
768            (responses,),
769            0x4eb5acc052ada449,
770            fidl::encoding::DynamicFlags::empty(),
771            _decode,
772        )
773    }
774
775    type UpdateResponseResponseFut =
776        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
777    fn r#update_response(
778        &self,
779        mut interaction: &fidl_fuchsia_ui_pointer::TouchInteractionId,
780        mut response: &fidl_fuchsia_ui_pointer::TouchResponse,
781    ) -> Self::UpdateResponseResponseFut {
782        fn _decode(
783            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
784        ) -> Result<(), fidl::Error> {
785            let _response = fidl::client::decode_transaction_body::<
786                fidl::encoding::EmptyPayload,
787                fidl::encoding::DefaultFuchsiaResourceDialect,
788                0x1f2fde6734e7da1,
789            >(_buf?)?;
790            Ok(_response)
791        }
792        self.client.send_query_and_decode::<TouchSourceWithLocalHitUpdateResponseRequest, ()>(
793            (interaction, response),
794            0x1f2fde6734e7da1,
795            fidl::encoding::DynamicFlags::empty(),
796            _decode,
797        )
798    }
799}
800
801pub struct TouchSourceWithLocalHitEventStream {
802    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
803}
804
805impl std::marker::Unpin for TouchSourceWithLocalHitEventStream {}
806
807impl futures::stream::FusedStream for TouchSourceWithLocalHitEventStream {
808    fn is_terminated(&self) -> bool {
809        self.event_receiver.is_terminated()
810    }
811}
812
813impl futures::Stream for TouchSourceWithLocalHitEventStream {
814    type Item = Result<TouchSourceWithLocalHitEvent, fidl::Error>;
815
816    fn poll_next(
817        mut self: std::pin::Pin<&mut Self>,
818        cx: &mut std::task::Context<'_>,
819    ) -> std::task::Poll<Option<Self::Item>> {
820        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
821            &mut self.event_receiver,
822            cx
823        )?) {
824            Some(buf) => std::task::Poll::Ready(Some(TouchSourceWithLocalHitEvent::decode(buf))),
825            None => std::task::Poll::Ready(None),
826        }
827    }
828}
829
830#[derive(Debug)]
831pub enum TouchSourceWithLocalHitEvent {}
832
833impl TouchSourceWithLocalHitEvent {
834    /// Decodes a message buffer as a [`TouchSourceWithLocalHitEvent`].
835    fn decode(
836        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
837    ) -> Result<TouchSourceWithLocalHitEvent, fidl::Error> {
838        let (bytes, _handles) = buf.split_mut();
839        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
840        debug_assert_eq!(tx_header.tx_id, 0);
841        match tx_header.ordinal {
842            _ => Err(fidl::Error::UnknownOrdinal {
843                ordinal: tx_header.ordinal,
844                protocol_name:
845                    <TouchSourceWithLocalHitMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
846            }),
847        }
848    }
849}
850
851/// A Stream of incoming requests for fuchsia.ui.pointer.augment/TouchSourceWithLocalHit.
852pub struct TouchSourceWithLocalHitRequestStream {
853    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
854    is_terminated: bool,
855}
856
857impl std::marker::Unpin for TouchSourceWithLocalHitRequestStream {}
858
859impl futures::stream::FusedStream for TouchSourceWithLocalHitRequestStream {
860    fn is_terminated(&self) -> bool {
861        self.is_terminated
862    }
863}
864
865impl fidl::endpoints::RequestStream for TouchSourceWithLocalHitRequestStream {
866    type Protocol = TouchSourceWithLocalHitMarker;
867    type ControlHandle = TouchSourceWithLocalHitControlHandle;
868
869    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
870        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
871    }
872
873    fn control_handle(&self) -> Self::ControlHandle {
874        TouchSourceWithLocalHitControlHandle { inner: self.inner.clone() }
875    }
876
877    fn into_inner(
878        self,
879    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
880    {
881        (self.inner, self.is_terminated)
882    }
883
884    fn from_inner(
885        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
886        is_terminated: bool,
887    ) -> Self {
888        Self { inner, is_terminated }
889    }
890}
891
892impl futures::Stream for TouchSourceWithLocalHitRequestStream {
893    type Item = Result<TouchSourceWithLocalHitRequest, fidl::Error>;
894
895    fn poll_next(
896        mut self: std::pin::Pin<&mut Self>,
897        cx: &mut std::task::Context<'_>,
898    ) -> std::task::Poll<Option<Self::Item>> {
899        let this = &mut *self;
900        if this.inner.check_shutdown(cx) {
901            this.is_terminated = true;
902            return std::task::Poll::Ready(None);
903        }
904        if this.is_terminated {
905            panic!("polled TouchSourceWithLocalHitRequestStream after completion");
906        }
907        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
908            |bytes, handles| {
909                match this.inner.channel().read_etc(cx, bytes, handles) {
910                    std::task::Poll::Ready(Ok(())) => {}
911                    std::task::Poll::Pending => return std::task::Poll::Pending,
912                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
913                        this.is_terminated = true;
914                        return std::task::Poll::Ready(None);
915                    }
916                    std::task::Poll::Ready(Err(e)) => {
917                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
918                            e.into(),
919                        ))));
920                    }
921                }
922
923                // A message has been received from the channel
924                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
925
926                std::task::Poll::Ready(Some(match header.ordinal {
927                0x4eb5acc052ada449 => {
928                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
929                    let mut req = fidl::new_empty!(TouchSourceWithLocalHitWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
930                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceWithLocalHitWatchRequest>(&header, _body_bytes, handles, &mut req)?;
931                    let control_handle = TouchSourceWithLocalHitControlHandle {
932                        inner: this.inner.clone(),
933                    };
934                    Ok(TouchSourceWithLocalHitRequest::Watch {responses: req.responses,
935
936                        responder: TouchSourceWithLocalHitWatchResponder {
937                            control_handle: std::mem::ManuallyDrop::new(control_handle),
938                            tx_id: header.tx_id,
939                        },
940                    })
941                }
942                0x1f2fde6734e7da1 => {
943                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
944                    let mut req = fidl::new_empty!(TouchSourceWithLocalHitUpdateResponseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
945                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceWithLocalHitUpdateResponseRequest>(&header, _body_bytes, handles, &mut req)?;
946                    let control_handle = TouchSourceWithLocalHitControlHandle {
947                        inner: this.inner.clone(),
948                    };
949                    Ok(TouchSourceWithLocalHitRequest::UpdateResponse {interaction: req.interaction,
950response: req.response,
951
952                        responder: TouchSourceWithLocalHitUpdateResponseResponder {
953                            control_handle: std::mem::ManuallyDrop::new(control_handle),
954                            tx_id: header.tx_id,
955                        },
956                    })
957                }
958                _ => Err(fidl::Error::UnknownOrdinal {
959                    ordinal: header.ordinal,
960                    protocol_name: <TouchSourceWithLocalHitMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
961                }),
962            }))
963            },
964        )
965    }
966}
967
968/// Like [`fuchsia.ui.pointer.TouchSource`], but with additional information
969/// about the local-hit position of touch events, and otherwise identical in
970/// operation. See [`fuchsia.ui.pointer.TouchSource`] for regular usage
971/// information.
972#[derive(Debug)]
973pub enum TouchSourceWithLocalHitRequest {
974    /// Identical usage to [`fuchsia.ui.pointer.TouchSource.Watch`], but with
975    /// augmented data.
976    Watch {
977        responses: Vec<fidl_fuchsia_ui_pointer::TouchResponse>,
978        responder: TouchSourceWithLocalHitWatchResponder,
979    },
980    /// Identical usage to [`fuchsia.ui.pointer.TouchSource.UpdateResponse`].
981    UpdateResponse {
982        interaction: fidl_fuchsia_ui_pointer::TouchInteractionId,
983        response: fidl_fuchsia_ui_pointer::TouchResponse,
984        responder: TouchSourceWithLocalHitUpdateResponseResponder,
985    },
986}
987
988impl TouchSourceWithLocalHitRequest {
989    #[allow(irrefutable_let_patterns)]
990    pub fn into_watch(
991        self,
992    ) -> Option<(Vec<fidl_fuchsia_ui_pointer::TouchResponse>, TouchSourceWithLocalHitWatchResponder)>
993    {
994        if let TouchSourceWithLocalHitRequest::Watch { responses, responder } = self {
995            Some((responses, responder))
996        } else {
997            None
998        }
999    }
1000
1001    #[allow(irrefutable_let_patterns)]
1002    pub fn into_update_response(
1003        self,
1004    ) -> Option<(
1005        fidl_fuchsia_ui_pointer::TouchInteractionId,
1006        fidl_fuchsia_ui_pointer::TouchResponse,
1007        TouchSourceWithLocalHitUpdateResponseResponder,
1008    )> {
1009        if let TouchSourceWithLocalHitRequest::UpdateResponse { interaction, response, responder } =
1010            self
1011        {
1012            Some((interaction, response, responder))
1013        } else {
1014            None
1015        }
1016    }
1017
1018    /// Name of the method defined in FIDL
1019    pub fn method_name(&self) -> &'static str {
1020        match *self {
1021            TouchSourceWithLocalHitRequest::Watch { .. } => "watch",
1022            TouchSourceWithLocalHitRequest::UpdateResponse { .. } => "update_response",
1023        }
1024    }
1025}
1026
1027#[derive(Debug, Clone)]
1028pub struct TouchSourceWithLocalHitControlHandle {
1029    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1030}
1031
1032impl fidl::endpoints::ControlHandle for TouchSourceWithLocalHitControlHandle {
1033    fn shutdown(&self) {
1034        self.inner.shutdown()
1035    }
1036    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1037        self.inner.shutdown_with_epitaph(status)
1038    }
1039
1040    fn is_closed(&self) -> bool {
1041        self.inner.channel().is_closed()
1042    }
1043    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1044        self.inner.channel().on_closed()
1045    }
1046
1047    #[cfg(target_os = "fuchsia")]
1048    fn signal_peer(
1049        &self,
1050        clear_mask: zx::Signals,
1051        set_mask: zx::Signals,
1052    ) -> Result<(), zx_status::Status> {
1053        use fidl::Peered;
1054        self.inner.channel().signal_peer(clear_mask, set_mask)
1055    }
1056}
1057
1058impl TouchSourceWithLocalHitControlHandle {}
1059
1060#[must_use = "FIDL methods require a response to be sent"]
1061#[derive(Debug)]
1062pub struct TouchSourceWithLocalHitWatchResponder {
1063    control_handle: std::mem::ManuallyDrop<TouchSourceWithLocalHitControlHandle>,
1064    tx_id: u32,
1065}
1066
1067/// Set the the channel to be shutdown (see [`TouchSourceWithLocalHitControlHandle::shutdown`])
1068/// if the responder is dropped without sending a response, so that the client
1069/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1070impl std::ops::Drop for TouchSourceWithLocalHitWatchResponder {
1071    fn drop(&mut self) {
1072        self.control_handle.shutdown();
1073        // Safety: drops once, never accessed again
1074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1075    }
1076}
1077
1078impl fidl::endpoints::Responder for TouchSourceWithLocalHitWatchResponder {
1079    type ControlHandle = TouchSourceWithLocalHitControlHandle;
1080
1081    fn control_handle(&self) -> &TouchSourceWithLocalHitControlHandle {
1082        &self.control_handle
1083    }
1084
1085    fn drop_without_shutdown(mut self) {
1086        // Safety: drops once, never accessed again due to mem::forget
1087        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1088        // Prevent Drop from running (which would shut down the channel)
1089        std::mem::forget(self);
1090    }
1091}
1092
1093impl TouchSourceWithLocalHitWatchResponder {
1094    /// Sends a response to the FIDL transaction.
1095    ///
1096    /// Sets the channel to shutdown if an error occurs.
1097    pub fn send(self, mut events: &[TouchEventWithLocalHit]) -> Result<(), fidl::Error> {
1098        let _result = self.send_raw(events);
1099        if _result.is_err() {
1100            self.control_handle.shutdown();
1101        }
1102        self.drop_without_shutdown();
1103        _result
1104    }
1105
1106    /// Similar to "send" but does not shutdown the channel if an error occurs.
1107    pub fn send_no_shutdown_on_err(
1108        self,
1109        mut events: &[TouchEventWithLocalHit],
1110    ) -> Result<(), fidl::Error> {
1111        let _result = self.send_raw(events);
1112        self.drop_without_shutdown();
1113        _result
1114    }
1115
1116    fn send_raw(&self, mut events: &[TouchEventWithLocalHit]) -> Result<(), fidl::Error> {
1117        self.control_handle.inner.send::<TouchSourceWithLocalHitWatchResponse>(
1118            (events,),
1119            self.tx_id,
1120            0x4eb5acc052ada449,
1121            fidl::encoding::DynamicFlags::empty(),
1122        )
1123    }
1124}
1125
1126#[must_use = "FIDL methods require a response to be sent"]
1127#[derive(Debug)]
1128pub struct TouchSourceWithLocalHitUpdateResponseResponder {
1129    control_handle: std::mem::ManuallyDrop<TouchSourceWithLocalHitControlHandle>,
1130    tx_id: u32,
1131}
1132
1133/// Set the the channel to be shutdown (see [`TouchSourceWithLocalHitControlHandle::shutdown`])
1134/// if the responder is dropped without sending a response, so that the client
1135/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1136impl std::ops::Drop for TouchSourceWithLocalHitUpdateResponseResponder {
1137    fn drop(&mut self) {
1138        self.control_handle.shutdown();
1139        // Safety: drops once, never accessed again
1140        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1141    }
1142}
1143
1144impl fidl::endpoints::Responder for TouchSourceWithLocalHitUpdateResponseResponder {
1145    type ControlHandle = TouchSourceWithLocalHitControlHandle;
1146
1147    fn control_handle(&self) -> &TouchSourceWithLocalHitControlHandle {
1148        &self.control_handle
1149    }
1150
1151    fn drop_without_shutdown(mut self) {
1152        // Safety: drops once, never accessed again due to mem::forget
1153        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1154        // Prevent Drop from running (which would shut down the channel)
1155        std::mem::forget(self);
1156    }
1157}
1158
1159impl TouchSourceWithLocalHitUpdateResponseResponder {
1160    /// Sends a response to the FIDL transaction.
1161    ///
1162    /// Sets the channel to shutdown if an error occurs.
1163    pub fn send(self) -> Result<(), fidl::Error> {
1164        let _result = self.send_raw();
1165        if _result.is_err() {
1166            self.control_handle.shutdown();
1167        }
1168        self.drop_without_shutdown();
1169        _result
1170    }
1171
1172    /// Similar to "send" but does not shutdown the channel if an error occurs.
1173    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1174        let _result = self.send_raw();
1175        self.drop_without_shutdown();
1176        _result
1177    }
1178
1179    fn send_raw(&self) -> Result<(), fidl::Error> {
1180        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1181            (),
1182            self.tx_id,
1183            0x1f2fde6734e7da1,
1184            fidl::encoding::DynamicFlags::empty(),
1185        )
1186    }
1187}
1188
1189mod internal {
1190    use super::*;
1191
1192    impl fidl::encoding::ResourceTypeMarker for ErrorForLocalHit {
1193        type Borrowed<'a> = &'a mut Self;
1194        fn take_or_borrow<'a>(
1195            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1196        ) -> Self::Borrowed<'a> {
1197            value
1198        }
1199    }
1200
1201    unsafe impl fidl::encoding::TypeMarker for ErrorForLocalHit {
1202        type Owned = Self;
1203
1204        #[inline(always)]
1205        fn inline_align(_context: fidl::encoding::Context) -> usize {
1206            4
1207        }
1208
1209        #[inline(always)]
1210        fn inline_size(_context: fidl::encoding::Context) -> usize {
1211            8
1212        }
1213    }
1214
1215    unsafe impl
1216        fidl::encoding::Encode<ErrorForLocalHit, fidl::encoding::DefaultFuchsiaResourceDialect>
1217        for &mut ErrorForLocalHit
1218    {
1219        #[inline]
1220        unsafe fn encode(
1221            self,
1222            encoder: &mut fidl::encoding::Encoder<
1223                '_,
1224                fidl::encoding::DefaultFuchsiaResourceDialect,
1225            >,
1226            offset: usize,
1227            _depth: fidl::encoding::Depth,
1228        ) -> fidl::Result<()> {
1229            encoder.debug_check_bounds::<ErrorForLocalHit>(offset);
1230            // Delegate to tuple encoding.
1231            fidl::encoding::Encode::<ErrorForLocalHit, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1232                (
1233                    <ErrorReason as fidl::encoding::ValueTypeMarker>::borrow(&self.error_reason),
1234                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.original),
1235                ),
1236                encoder, offset, _depth
1237            )
1238        }
1239    }
1240    unsafe impl<
1241        T0: fidl::encoding::Encode<ErrorReason, fidl::encoding::DefaultFuchsiaResourceDialect>,
1242        T1: fidl::encoding::Encode<
1243                fidl::encoding::Endpoint<
1244                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
1245                >,
1246                fidl::encoding::DefaultFuchsiaResourceDialect,
1247            >,
1248    > fidl::encoding::Encode<ErrorForLocalHit, fidl::encoding::DefaultFuchsiaResourceDialect>
1249        for (T0, T1)
1250    {
1251        #[inline]
1252        unsafe fn encode(
1253            self,
1254            encoder: &mut fidl::encoding::Encoder<
1255                '_,
1256                fidl::encoding::DefaultFuchsiaResourceDialect,
1257            >,
1258            offset: usize,
1259            depth: fidl::encoding::Depth,
1260        ) -> fidl::Result<()> {
1261            encoder.debug_check_bounds::<ErrorForLocalHit>(offset);
1262            // Zero out padding regions. There's no need to apply masks
1263            // because the unmasked parts will be overwritten by fields.
1264            // Write the fields.
1265            self.0.encode(encoder, offset + 0, depth)?;
1266            self.1.encode(encoder, offset + 4, depth)?;
1267            Ok(())
1268        }
1269    }
1270
1271    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1272        for ErrorForLocalHit
1273    {
1274        #[inline(always)]
1275        fn new_empty() -> Self {
1276            Self {
1277                error_reason: fidl::new_empty!(
1278                    ErrorReason,
1279                    fidl::encoding::DefaultFuchsiaResourceDialect
1280                ),
1281                original: fidl::new_empty!(
1282                    fidl::encoding::Endpoint<
1283                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
1284                    >,
1285                    fidl::encoding::DefaultFuchsiaResourceDialect
1286                ),
1287            }
1288        }
1289
1290        #[inline]
1291        unsafe fn decode(
1292            &mut self,
1293            decoder: &mut fidl::encoding::Decoder<
1294                '_,
1295                fidl::encoding::DefaultFuchsiaResourceDialect,
1296            >,
1297            offset: usize,
1298            _depth: fidl::encoding::Depth,
1299        ) -> fidl::Result<()> {
1300            decoder.debug_check_bounds::<Self>(offset);
1301            // Verify that padding bytes are zero.
1302            fidl::decode!(
1303                ErrorReason,
1304                fidl::encoding::DefaultFuchsiaResourceDialect,
1305                &mut self.error_reason,
1306                decoder,
1307                offset + 0,
1308                _depth
1309            )?;
1310            fidl::decode!(
1311                fidl::encoding::Endpoint<
1312                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
1313                >,
1314                fidl::encoding::DefaultFuchsiaResourceDialect,
1315                &mut self.original,
1316                decoder,
1317                offset + 4,
1318                _depth
1319            )?;
1320            Ok(())
1321        }
1322    }
1323
1324    impl fidl::encoding::ResourceTypeMarker for LocalHitUpgradeRequest {
1325        type Borrowed<'a> = &'a mut Self;
1326        fn take_or_borrow<'a>(
1327            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1328        ) -> Self::Borrowed<'a> {
1329            value
1330        }
1331    }
1332
1333    unsafe impl fidl::encoding::TypeMarker for LocalHitUpgradeRequest {
1334        type Owned = Self;
1335
1336        #[inline(always)]
1337        fn inline_align(_context: fidl::encoding::Context) -> usize {
1338            4
1339        }
1340
1341        #[inline(always)]
1342        fn inline_size(_context: fidl::encoding::Context) -> usize {
1343            4
1344        }
1345    }
1346
1347    unsafe impl
1348        fidl::encoding::Encode<
1349            LocalHitUpgradeRequest,
1350            fidl::encoding::DefaultFuchsiaResourceDialect,
1351        > for &mut LocalHitUpgradeRequest
1352    {
1353        #[inline]
1354        unsafe fn encode(
1355            self,
1356            encoder: &mut fidl::encoding::Encoder<
1357                '_,
1358                fidl::encoding::DefaultFuchsiaResourceDialect,
1359            >,
1360            offset: usize,
1361            _depth: fidl::encoding::Depth,
1362        ) -> fidl::Result<()> {
1363            encoder.debug_check_bounds::<LocalHitUpgradeRequest>(offset);
1364            // Delegate to tuple encoding.
1365            fidl::encoding::Encode::<
1366                LocalHitUpgradeRequest,
1367                fidl::encoding::DefaultFuchsiaResourceDialect,
1368            >::encode(
1369                (<fidl::encoding::Endpoint<
1370                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
1371                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1372                    &mut self.original
1373                ),),
1374                encoder,
1375                offset,
1376                _depth,
1377            )
1378        }
1379    }
1380    unsafe impl<
1381        T0: fidl::encoding::Encode<
1382                fidl::encoding::Endpoint<
1383                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
1384                >,
1385                fidl::encoding::DefaultFuchsiaResourceDialect,
1386            >,
1387    >
1388        fidl::encoding::Encode<
1389            LocalHitUpgradeRequest,
1390            fidl::encoding::DefaultFuchsiaResourceDialect,
1391        > for (T0,)
1392    {
1393        #[inline]
1394        unsafe fn encode(
1395            self,
1396            encoder: &mut fidl::encoding::Encoder<
1397                '_,
1398                fidl::encoding::DefaultFuchsiaResourceDialect,
1399            >,
1400            offset: usize,
1401            depth: fidl::encoding::Depth,
1402        ) -> fidl::Result<()> {
1403            encoder.debug_check_bounds::<LocalHitUpgradeRequest>(offset);
1404            // Zero out padding regions. There's no need to apply masks
1405            // because the unmasked parts will be overwritten by fields.
1406            // Write the fields.
1407            self.0.encode(encoder, offset + 0, depth)?;
1408            Ok(())
1409        }
1410    }
1411
1412    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1413        for LocalHitUpgradeRequest
1414    {
1415        #[inline(always)]
1416        fn new_empty() -> Self {
1417            Self {
1418                original: fidl::new_empty!(
1419                    fidl::encoding::Endpoint<
1420                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
1421                    >,
1422                    fidl::encoding::DefaultFuchsiaResourceDialect
1423                ),
1424            }
1425        }
1426
1427        #[inline]
1428        unsafe fn decode(
1429            &mut self,
1430            decoder: &mut fidl::encoding::Decoder<
1431                '_,
1432                fidl::encoding::DefaultFuchsiaResourceDialect,
1433            >,
1434            offset: usize,
1435            _depth: fidl::encoding::Depth,
1436        ) -> fidl::Result<()> {
1437            decoder.debug_check_bounds::<Self>(offset);
1438            // Verify that padding bytes are zero.
1439            fidl::decode!(
1440                fidl::encoding::Endpoint<
1441                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
1442                >,
1443                fidl::encoding::DefaultFuchsiaResourceDialect,
1444                &mut self.original,
1445                decoder,
1446                offset + 0,
1447                _depth
1448            )?;
1449            Ok(())
1450        }
1451    }
1452
1453    impl fidl::encoding::ResourceTypeMarker for LocalHitUpgradeResponse {
1454        type Borrowed<'a> = &'a mut Self;
1455        fn take_or_borrow<'a>(
1456            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1457        ) -> Self::Borrowed<'a> {
1458            value
1459        }
1460    }
1461
1462    unsafe impl fidl::encoding::TypeMarker for LocalHitUpgradeResponse {
1463        type Owned = Self;
1464
1465        #[inline(always)]
1466        fn inline_align(_context: fidl::encoding::Context) -> usize {
1467            8
1468        }
1469
1470        #[inline(always)]
1471        fn inline_size(_context: fidl::encoding::Context) -> usize {
1472            16
1473        }
1474    }
1475
1476    unsafe impl
1477        fidl::encoding::Encode<
1478            LocalHitUpgradeResponse,
1479            fidl::encoding::DefaultFuchsiaResourceDialect,
1480        > for &mut LocalHitUpgradeResponse
1481    {
1482        #[inline]
1483        unsafe fn encode(
1484            self,
1485            encoder: &mut fidl::encoding::Encoder<
1486                '_,
1487                fidl::encoding::DefaultFuchsiaResourceDialect,
1488            >,
1489            offset: usize,
1490            _depth: fidl::encoding::Depth,
1491        ) -> fidl::Result<()> {
1492            encoder.debug_check_bounds::<LocalHitUpgradeResponse>(offset);
1493            // Delegate to tuple encoding.
1494            fidl::encoding::Encode::<LocalHitUpgradeResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1495                (
1496                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.augmented),
1497                    <fidl::encoding::Boxed<ErrorForLocalHit> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.error),
1498                ),
1499                encoder, offset, _depth
1500            )
1501        }
1502    }
1503    unsafe impl<
1504        T0: fidl::encoding::Encode<
1505                fidl::encoding::Optional<
1506                    fidl::encoding::Endpoint<
1507                        fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>,
1508                    >,
1509                >,
1510                fidl::encoding::DefaultFuchsiaResourceDialect,
1511            >,
1512        T1: fidl::encoding::Encode<
1513                fidl::encoding::Boxed<ErrorForLocalHit>,
1514                fidl::encoding::DefaultFuchsiaResourceDialect,
1515            >,
1516    >
1517        fidl::encoding::Encode<
1518            LocalHitUpgradeResponse,
1519            fidl::encoding::DefaultFuchsiaResourceDialect,
1520        > for (T0, T1)
1521    {
1522        #[inline]
1523        unsafe fn encode(
1524            self,
1525            encoder: &mut fidl::encoding::Encoder<
1526                '_,
1527                fidl::encoding::DefaultFuchsiaResourceDialect,
1528            >,
1529            offset: usize,
1530            depth: fidl::encoding::Depth,
1531        ) -> fidl::Result<()> {
1532            encoder.debug_check_bounds::<LocalHitUpgradeResponse>(offset);
1533            // Zero out padding regions. There's no need to apply masks
1534            // because the unmasked parts will be overwritten by fields.
1535            unsafe {
1536                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1537                (ptr as *mut u64).write_unaligned(0);
1538            }
1539            // Write the fields.
1540            self.0.encode(encoder, offset + 0, depth)?;
1541            self.1.encode(encoder, offset + 8, depth)?;
1542            Ok(())
1543        }
1544    }
1545
1546    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1547        for LocalHitUpgradeResponse
1548    {
1549        #[inline(always)]
1550        fn new_empty() -> Self {
1551            Self {
1552                augmented: fidl::new_empty!(
1553                    fidl::encoding::Optional<
1554                        fidl::encoding::Endpoint<
1555                            fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>,
1556                        >,
1557                    >,
1558                    fidl::encoding::DefaultFuchsiaResourceDialect
1559                ),
1560                error: fidl::new_empty!(
1561                    fidl::encoding::Boxed<ErrorForLocalHit>,
1562                    fidl::encoding::DefaultFuchsiaResourceDialect
1563                ),
1564            }
1565        }
1566
1567        #[inline]
1568        unsafe fn decode(
1569            &mut self,
1570            decoder: &mut fidl::encoding::Decoder<
1571                '_,
1572                fidl::encoding::DefaultFuchsiaResourceDialect,
1573            >,
1574            offset: usize,
1575            _depth: fidl::encoding::Depth,
1576        ) -> fidl::Result<()> {
1577            decoder.debug_check_bounds::<Self>(offset);
1578            // Verify that padding bytes are zero.
1579            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1580            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1581            let mask = 0xffffffff00000000u64;
1582            let maskedval = padval & mask;
1583            if maskedval != 0 {
1584                return Err(fidl::Error::NonZeroPadding {
1585                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1586                });
1587            }
1588            fidl::decode!(
1589                fidl::encoding::Optional<
1590                    fidl::encoding::Endpoint<
1591                        fidl::endpoints::ClientEnd<TouchSourceWithLocalHitMarker>,
1592                    >,
1593                >,
1594                fidl::encoding::DefaultFuchsiaResourceDialect,
1595                &mut self.augmented,
1596                decoder,
1597                offset + 0,
1598                _depth
1599            )?;
1600            fidl::decode!(
1601                fidl::encoding::Boxed<ErrorForLocalHit>,
1602                fidl::encoding::DefaultFuchsiaResourceDialect,
1603                &mut self.error,
1604                decoder,
1605                offset + 8,
1606                _depth
1607            )?;
1608            Ok(())
1609        }
1610    }
1611}