fidl_fidl_test_imported/
fidl_fidl_test_imported.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_fidl_test_imported__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ComposedMarker;
16
17impl fidl::endpoints::ProtocolMarker for ComposedMarker {
18    type Proxy = ComposedProxy;
19    type RequestStream = ComposedRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ComposedSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) Composed";
24}
25pub type ComposedEchoUnionResponseWithErrorComposedResult =
26    Result<ComposedEchoUnionResponseWithErrorComposedResponse, u32>;
27
28pub trait ComposedProxyInterface: Send + Sync {
29    type EchoTableRequestComposedResponseFut: std::future::Future<Output = Result<SimpleStruct, fidl::Error>>
30        + Send;
31    fn r#echo_table_request_composed(
32        &self,
33        payload: &ComposedEchoTableRequestComposedRequest,
34    ) -> Self::EchoTableRequestComposedResponseFut;
35    type EchoUnionResponseWithErrorComposedResponseFut: std::future::Future<
36            Output = Result<ComposedEchoUnionResponseWithErrorComposedResult, fidl::Error>,
37        > + Send;
38    fn r#echo_union_response_with_error_composed(
39        &self,
40        value: i64,
41        want_absolute_value: bool,
42        forward_to_server: &str,
43        result_err: u32,
44        result_variant: WantResponse,
45    ) -> Self::EchoUnionResponseWithErrorComposedResponseFut;
46}
47#[derive(Debug)]
48#[cfg(target_os = "fuchsia")]
49pub struct ComposedSynchronousProxy {
50    client: fidl::client::sync::Client,
51}
52
53#[cfg(target_os = "fuchsia")]
54impl fidl::endpoints::SynchronousProxy for ComposedSynchronousProxy {
55    type Proxy = ComposedProxy;
56    type Protocol = ComposedMarker;
57
58    fn from_channel(inner: fidl::Channel) -> Self {
59        Self::new(inner)
60    }
61
62    fn into_channel(self) -> fidl::Channel {
63        self.client.into_channel()
64    }
65
66    fn as_channel(&self) -> &fidl::Channel {
67        self.client.as_channel()
68    }
69}
70
71#[cfg(target_os = "fuchsia")]
72impl ComposedSynchronousProxy {
73    pub fn new(channel: fidl::Channel) -> Self {
74        let protocol_name = <ComposedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
75        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
76    }
77
78    pub fn into_channel(self) -> fidl::Channel {
79        self.client.into_channel()
80    }
81
82    /// Waits until an event arrives and returns it. It is safe for other
83    /// threads to make concurrent requests while waiting for an event.
84    pub fn wait_for_event(
85        &self,
86        deadline: zx::MonotonicInstant,
87    ) -> Result<ComposedEvent, fidl::Error> {
88        ComposedEvent::decode(self.client.wait_for_event(deadline)?)
89    }
90
91    pub fn r#echo_table_request_composed(
92        &self,
93        mut payload: &ComposedEchoTableRequestComposedRequest,
94        ___deadline: zx::MonotonicInstant,
95    ) -> Result<SimpleStruct, fidl::Error> {
96        let _response =
97            self.client.send_query::<ComposedEchoTableRequestComposedRequest, ResponseStruct>(
98                payload,
99                0x1d545c738c7a8ee,
100                fidl::encoding::DynamicFlags::empty(),
101                ___deadline,
102            )?;
103        Ok(_response.value)
104    }
105
106    pub fn r#echo_union_response_with_error_composed(
107        &self,
108        mut value: i64,
109        mut want_absolute_value: bool,
110        mut forward_to_server: &str,
111        mut result_err: u32,
112        mut result_variant: WantResponse,
113        ___deadline: zx::MonotonicInstant,
114    ) -> Result<ComposedEchoUnionResponseWithErrorComposedResult, fidl::Error> {
115        let _response = self.client.send_query::<
116            ComposedEchoUnionResponseWithErrorComposedRequest,
117            fidl::encoding::ResultType<ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
118        >(
119            (value, want_absolute_value, forward_to_server, result_err, result_variant,),
120            0x38a67e88d6106443,
121            fidl::encoding::DynamicFlags::empty(),
122            ___deadline,
123        )?;
124        Ok(_response.map(|x| x))
125    }
126}
127
128#[cfg(target_os = "fuchsia")]
129impl From<ComposedSynchronousProxy> for zx::Handle {
130    fn from(value: ComposedSynchronousProxy) -> Self {
131        value.into_channel().into()
132    }
133}
134
135#[cfg(target_os = "fuchsia")]
136impl From<fidl::Channel> for ComposedSynchronousProxy {
137    fn from(value: fidl::Channel) -> Self {
138        Self::new(value)
139    }
140}
141
142#[cfg(target_os = "fuchsia")]
143impl fidl::endpoints::FromClient for ComposedSynchronousProxy {
144    type Protocol = ComposedMarker;
145
146    fn from_client(value: fidl::endpoints::ClientEnd<ComposedMarker>) -> Self {
147        Self::new(value.into_channel())
148    }
149}
150
151#[derive(Debug, Clone)]
152pub struct ComposedProxy {
153    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
154}
155
156impl fidl::endpoints::Proxy for ComposedProxy {
157    type Protocol = ComposedMarker;
158
159    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
160        Self::new(inner)
161    }
162
163    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
164        self.client.into_channel().map_err(|client| Self { client })
165    }
166
167    fn as_channel(&self) -> &::fidl::AsyncChannel {
168        self.client.as_channel()
169    }
170}
171
172impl ComposedProxy {
173    /// Create a new Proxy for fidl.test.imported/Composed.
174    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
175        let protocol_name = <ComposedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
176        Self { client: fidl::client::Client::new(channel, protocol_name) }
177    }
178
179    /// Get a Stream of events from the remote end of the protocol.
180    ///
181    /// # Panics
182    ///
183    /// Panics if the event stream was already taken.
184    pub fn take_event_stream(&self) -> ComposedEventStream {
185        ComposedEventStream { event_receiver: self.client.take_event_receiver() }
186    }
187
188    pub fn r#echo_table_request_composed(
189        &self,
190        mut payload: &ComposedEchoTableRequestComposedRequest,
191    ) -> fidl::client::QueryResponseFut<SimpleStruct, fidl::encoding::DefaultFuchsiaResourceDialect>
192    {
193        ComposedProxyInterface::r#echo_table_request_composed(self, payload)
194    }
195
196    pub fn r#echo_union_response_with_error_composed(
197        &self,
198        mut value: i64,
199        mut want_absolute_value: bool,
200        mut forward_to_server: &str,
201        mut result_err: u32,
202        mut result_variant: WantResponse,
203    ) -> fidl::client::QueryResponseFut<
204        ComposedEchoUnionResponseWithErrorComposedResult,
205        fidl::encoding::DefaultFuchsiaResourceDialect,
206    > {
207        ComposedProxyInterface::r#echo_union_response_with_error_composed(
208            self,
209            value,
210            want_absolute_value,
211            forward_to_server,
212            result_err,
213            result_variant,
214        )
215    }
216}
217
218impl ComposedProxyInterface for ComposedProxy {
219    type EchoTableRequestComposedResponseFut =
220        fidl::client::QueryResponseFut<SimpleStruct, fidl::encoding::DefaultFuchsiaResourceDialect>;
221    fn r#echo_table_request_composed(
222        &self,
223        mut payload: &ComposedEchoTableRequestComposedRequest,
224    ) -> Self::EchoTableRequestComposedResponseFut {
225        fn _decode(
226            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
227        ) -> Result<SimpleStruct, fidl::Error> {
228            let _response = fidl::client::decode_transaction_body::<
229                ResponseStruct,
230                fidl::encoding::DefaultFuchsiaResourceDialect,
231                0x1d545c738c7a8ee,
232            >(_buf?)?;
233            Ok(_response.value)
234        }
235        self.client.send_query_and_decode::<ComposedEchoTableRequestComposedRequest, SimpleStruct>(
236            payload,
237            0x1d545c738c7a8ee,
238            fidl::encoding::DynamicFlags::empty(),
239            _decode,
240        )
241    }
242
243    type EchoUnionResponseWithErrorComposedResponseFut = fidl::client::QueryResponseFut<
244        ComposedEchoUnionResponseWithErrorComposedResult,
245        fidl::encoding::DefaultFuchsiaResourceDialect,
246    >;
247    fn r#echo_union_response_with_error_composed(
248        &self,
249        mut value: i64,
250        mut want_absolute_value: bool,
251        mut forward_to_server: &str,
252        mut result_err: u32,
253        mut result_variant: WantResponse,
254    ) -> Self::EchoUnionResponseWithErrorComposedResponseFut {
255        fn _decode(
256            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
257        ) -> Result<ComposedEchoUnionResponseWithErrorComposedResult, fidl::Error> {
258            let _response = fidl::client::decode_transaction_body::<
259                fidl::encoding::ResultType<ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
260                fidl::encoding::DefaultFuchsiaResourceDialect,
261                0x38a67e88d6106443,
262            >(_buf?)?;
263            Ok(_response.map(|x| x))
264        }
265        self.client.send_query_and_decode::<
266            ComposedEchoUnionResponseWithErrorComposedRequest,
267            ComposedEchoUnionResponseWithErrorComposedResult,
268        >(
269            (value, want_absolute_value, forward_to_server, result_err, result_variant,),
270            0x38a67e88d6106443,
271            fidl::encoding::DynamicFlags::empty(),
272            _decode,
273        )
274    }
275}
276
277pub struct ComposedEventStream {
278    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
279}
280
281impl std::marker::Unpin for ComposedEventStream {}
282
283impl futures::stream::FusedStream for ComposedEventStream {
284    fn is_terminated(&self) -> bool {
285        self.event_receiver.is_terminated()
286    }
287}
288
289impl futures::Stream for ComposedEventStream {
290    type Item = Result<ComposedEvent, fidl::Error>;
291
292    fn poll_next(
293        mut self: std::pin::Pin<&mut Self>,
294        cx: &mut std::task::Context<'_>,
295    ) -> std::task::Poll<Option<Self::Item>> {
296        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
297            &mut self.event_receiver,
298            cx
299        )?) {
300            Some(buf) => std::task::Poll::Ready(Some(ComposedEvent::decode(buf))),
301            None => std::task::Poll::Ready(None),
302        }
303    }
304}
305
306#[derive(Debug)]
307pub enum ComposedEvent {}
308
309impl ComposedEvent {
310    /// Decodes a message buffer as a [`ComposedEvent`].
311    fn decode(
312        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
313    ) -> Result<ComposedEvent, fidl::Error> {
314        let (bytes, _handles) = buf.split_mut();
315        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
316        debug_assert_eq!(tx_header.tx_id, 0);
317        match tx_header.ordinal {
318            _ => Err(fidl::Error::UnknownOrdinal {
319                ordinal: tx_header.ordinal,
320                protocol_name: <ComposedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
321            }),
322        }
323    }
324}
325
326/// A Stream of incoming requests for fidl.test.imported/Composed.
327pub struct ComposedRequestStream {
328    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
329    is_terminated: bool,
330}
331
332impl std::marker::Unpin for ComposedRequestStream {}
333
334impl futures::stream::FusedStream for ComposedRequestStream {
335    fn is_terminated(&self) -> bool {
336        self.is_terminated
337    }
338}
339
340impl fidl::endpoints::RequestStream for ComposedRequestStream {
341    type Protocol = ComposedMarker;
342    type ControlHandle = ComposedControlHandle;
343
344    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
345        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
346    }
347
348    fn control_handle(&self) -> Self::ControlHandle {
349        ComposedControlHandle { inner: self.inner.clone() }
350    }
351
352    fn into_inner(
353        self,
354    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
355    {
356        (self.inner, self.is_terminated)
357    }
358
359    fn from_inner(
360        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
361        is_terminated: bool,
362    ) -> Self {
363        Self { inner, is_terminated }
364    }
365}
366
367impl futures::Stream for ComposedRequestStream {
368    type Item = Result<ComposedRequest, fidl::Error>;
369
370    fn poll_next(
371        mut self: std::pin::Pin<&mut Self>,
372        cx: &mut std::task::Context<'_>,
373    ) -> std::task::Poll<Option<Self::Item>> {
374        let this = &mut *self;
375        if this.inner.check_shutdown(cx) {
376            this.is_terminated = true;
377            return std::task::Poll::Ready(None);
378        }
379        if this.is_terminated {
380            panic!("polled ComposedRequestStream after completion");
381        }
382        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
383            |bytes, handles| {
384                match this.inner.channel().read_etc(cx, bytes, handles) {
385                    std::task::Poll::Ready(Ok(())) => {}
386                    std::task::Poll::Pending => return std::task::Poll::Pending,
387                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
388                        this.is_terminated = true;
389                        return std::task::Poll::Ready(None);
390                    }
391                    std::task::Poll::Ready(Err(e)) => {
392                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
393                            e.into(),
394                        ))))
395                    }
396                }
397
398                // A message has been received from the channel
399                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
400
401                std::task::Poll::Ready(Some(match header.ordinal {
402                    0x1d545c738c7a8ee => {
403                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
404                        let mut req = fidl::new_empty!(
405                            ComposedEchoTableRequestComposedRequest,
406                            fidl::encoding::DefaultFuchsiaResourceDialect
407                        );
408                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ComposedEchoTableRequestComposedRequest>(&header, _body_bytes, handles, &mut req)?;
409                        let control_handle = ComposedControlHandle { inner: this.inner.clone() };
410                        Ok(ComposedRequest::EchoTableRequestComposed {
411                            payload: req,
412                            responder: ComposedEchoTableRequestComposedResponder {
413                                control_handle: std::mem::ManuallyDrop::new(control_handle),
414                                tx_id: header.tx_id,
415                            },
416                        })
417                    }
418                    0x38a67e88d6106443 => {
419                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
420                        let mut req = fidl::new_empty!(
421                            ComposedEchoUnionResponseWithErrorComposedRequest,
422                            fidl::encoding::DefaultFuchsiaResourceDialect
423                        );
424                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ComposedEchoUnionResponseWithErrorComposedRequest>(&header, _body_bytes, handles, &mut req)?;
425                        let control_handle = ComposedControlHandle { inner: this.inner.clone() };
426                        Ok(ComposedRequest::EchoUnionResponseWithErrorComposed {
427                            value: req.value,
428                            want_absolute_value: req.want_absolute_value,
429                            forward_to_server: req.forward_to_server,
430                            result_err: req.result_err,
431                            result_variant: req.result_variant,
432
433                            responder: ComposedEchoUnionResponseWithErrorComposedResponder {
434                                control_handle: std::mem::ManuallyDrop::new(control_handle),
435                                tx_id: header.tx_id,
436                            },
437                        })
438                    }
439                    _ => Err(fidl::Error::UnknownOrdinal {
440                        ordinal: header.ordinal,
441                        protocol_name:
442                            <ComposedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
443                    }),
444                }))
445            },
446        )
447    }
448}
449
450#[derive(Debug)]
451pub enum ComposedRequest {
452    EchoTableRequestComposed {
453        payload: ComposedEchoTableRequestComposedRequest,
454        responder: ComposedEchoTableRequestComposedResponder,
455    },
456    EchoUnionResponseWithErrorComposed {
457        value: i64,
458        want_absolute_value: bool,
459        forward_to_server: String,
460        result_err: u32,
461        result_variant: WantResponse,
462        responder: ComposedEchoUnionResponseWithErrorComposedResponder,
463    },
464}
465
466impl ComposedRequest {
467    #[allow(irrefutable_let_patterns)]
468    pub fn into_echo_table_request_composed(
469        self,
470    ) -> Option<(ComposedEchoTableRequestComposedRequest, ComposedEchoTableRequestComposedResponder)>
471    {
472        if let ComposedRequest::EchoTableRequestComposed { payload, responder } = self {
473            Some((payload, responder))
474        } else {
475            None
476        }
477    }
478
479    #[allow(irrefutable_let_patterns)]
480    pub fn into_echo_union_response_with_error_composed(
481        self,
482    ) -> Option<(
483        i64,
484        bool,
485        String,
486        u32,
487        WantResponse,
488        ComposedEchoUnionResponseWithErrorComposedResponder,
489    )> {
490        if let ComposedRequest::EchoUnionResponseWithErrorComposed {
491            value,
492            want_absolute_value,
493            forward_to_server,
494            result_err,
495            result_variant,
496            responder,
497        } = self
498        {
499            Some((
500                value,
501                want_absolute_value,
502                forward_to_server,
503                result_err,
504                result_variant,
505                responder,
506            ))
507        } else {
508            None
509        }
510    }
511
512    /// Name of the method defined in FIDL
513    pub fn method_name(&self) -> &'static str {
514        match *self {
515            ComposedRequest::EchoTableRequestComposed { .. } => "echo_table_request_composed",
516            ComposedRequest::EchoUnionResponseWithErrorComposed { .. } => {
517                "echo_union_response_with_error_composed"
518            }
519        }
520    }
521}
522
523#[derive(Debug, Clone)]
524pub struct ComposedControlHandle {
525    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
526}
527
528impl fidl::endpoints::ControlHandle for ComposedControlHandle {
529    fn shutdown(&self) {
530        self.inner.shutdown()
531    }
532    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
533        self.inner.shutdown_with_epitaph(status)
534    }
535
536    fn is_closed(&self) -> bool {
537        self.inner.channel().is_closed()
538    }
539    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
540        self.inner.channel().on_closed()
541    }
542
543    #[cfg(target_os = "fuchsia")]
544    fn signal_peer(
545        &self,
546        clear_mask: zx::Signals,
547        set_mask: zx::Signals,
548    ) -> Result<(), zx_status::Status> {
549        use fidl::Peered;
550        self.inner.channel().signal_peer(clear_mask, set_mask)
551    }
552}
553
554impl ComposedControlHandle {}
555
556#[must_use = "FIDL methods require a response to be sent"]
557#[derive(Debug)]
558pub struct ComposedEchoTableRequestComposedResponder {
559    control_handle: std::mem::ManuallyDrop<ComposedControlHandle>,
560    tx_id: u32,
561}
562
563/// Set the the channel to be shutdown (see [`ComposedControlHandle::shutdown`])
564/// if the responder is dropped without sending a response, so that the client
565/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
566impl std::ops::Drop for ComposedEchoTableRequestComposedResponder {
567    fn drop(&mut self) {
568        self.control_handle.shutdown();
569        // Safety: drops once, never accessed again
570        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
571    }
572}
573
574impl fidl::endpoints::Responder for ComposedEchoTableRequestComposedResponder {
575    type ControlHandle = ComposedControlHandle;
576
577    fn control_handle(&self) -> &ComposedControlHandle {
578        &self.control_handle
579    }
580
581    fn drop_without_shutdown(mut self) {
582        // Safety: drops once, never accessed again due to mem::forget
583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
584        // Prevent Drop from running (which would shut down the channel)
585        std::mem::forget(self);
586    }
587}
588
589impl ComposedEchoTableRequestComposedResponder {
590    /// Sends a response to the FIDL transaction.
591    ///
592    /// Sets the channel to shutdown if an error occurs.
593    pub fn send(self, mut value: &SimpleStruct) -> Result<(), fidl::Error> {
594        let _result = self.send_raw(value);
595        if _result.is_err() {
596            self.control_handle.shutdown();
597        }
598        self.drop_without_shutdown();
599        _result
600    }
601
602    /// Similar to "send" but does not shutdown the channel if an error occurs.
603    pub fn send_no_shutdown_on_err(self, mut value: &SimpleStruct) -> Result<(), fidl::Error> {
604        let _result = self.send_raw(value);
605        self.drop_without_shutdown();
606        _result
607    }
608
609    fn send_raw(&self, mut value: &SimpleStruct) -> Result<(), fidl::Error> {
610        self.control_handle.inner.send::<ResponseStruct>(
611            (value,),
612            self.tx_id,
613            0x1d545c738c7a8ee,
614            fidl::encoding::DynamicFlags::empty(),
615        )
616    }
617}
618
619#[must_use = "FIDL methods require a response to be sent"]
620#[derive(Debug)]
621pub struct ComposedEchoUnionResponseWithErrorComposedResponder {
622    control_handle: std::mem::ManuallyDrop<ComposedControlHandle>,
623    tx_id: u32,
624}
625
626/// Set the the channel to be shutdown (see [`ComposedControlHandle::shutdown`])
627/// if the responder is dropped without sending a response, so that the client
628/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
629impl std::ops::Drop for ComposedEchoUnionResponseWithErrorComposedResponder {
630    fn drop(&mut self) {
631        self.control_handle.shutdown();
632        // Safety: drops once, never accessed again
633        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
634    }
635}
636
637impl fidl::endpoints::Responder for ComposedEchoUnionResponseWithErrorComposedResponder {
638    type ControlHandle = ComposedControlHandle;
639
640    fn control_handle(&self) -> &ComposedControlHandle {
641        &self.control_handle
642    }
643
644    fn drop_without_shutdown(mut self) {
645        // Safety: drops once, never accessed again due to mem::forget
646        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
647        // Prevent Drop from running (which would shut down the channel)
648        std::mem::forget(self);
649    }
650}
651
652impl ComposedEchoUnionResponseWithErrorComposedResponder {
653    /// Sends a response to the FIDL transaction.
654    ///
655    /// Sets the channel to shutdown if an error occurs.
656    pub fn send(
657        self,
658        mut result: Result<&ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
659    ) -> Result<(), fidl::Error> {
660        let _result = self.send_raw(result);
661        if _result.is_err() {
662            self.control_handle.shutdown();
663        }
664        self.drop_without_shutdown();
665        _result
666    }
667
668    /// Similar to "send" but does not shutdown the channel if an error occurs.
669    pub fn send_no_shutdown_on_err(
670        self,
671        mut result: Result<&ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
672    ) -> Result<(), fidl::Error> {
673        let _result = self.send_raw(result);
674        self.drop_without_shutdown();
675        _result
676    }
677
678    fn send_raw(
679        &self,
680        mut result: Result<&ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
681    ) -> Result<(), fidl::Error> {
682        self.control_handle.inner.send::<fidl::encoding::ResultType<
683            ComposedEchoUnionResponseWithErrorComposedResponse,
684            u32,
685        >>(
686            result,
687            self.tx_id,
688            0x38a67e88d6106443,
689            fidl::encoding::DynamicFlags::empty(),
690        )
691    }
692}
693
694mod internal {
695    use super::*;
696}