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