Skip to main content

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