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