fidl_fuchsia_inspect_deprecated/
fidl_fuchsia_inspect_deprecated.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_inspect_deprecated__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct InspectOpenChildRequest {
16    pub child_name: String,
17    pub child_channel: fidl::endpoints::ServerEnd<InspectMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InspectOpenChildRequest {}
21
22#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
23pub struct InspectMarker;
24
25impl fidl::endpoints::ProtocolMarker for InspectMarker {
26    type Proxy = InspectProxy;
27    type RequestStream = InspectRequestStream;
28    #[cfg(target_os = "fuchsia")]
29    type SynchronousProxy = InspectSynchronousProxy;
30
31    const DEBUG_NAME: &'static str = "fuchsia.inspect.deprecated.Inspect";
32}
33impl fidl::endpoints::DiscoverableProtocolMarker for InspectMarker {}
34
35pub trait InspectProxyInterface: Send + Sync {
36    type ReadDataResponseFut: std::future::Future<Output = Result<Object, fidl::Error>> + Send;
37    fn r#read_data(&self) -> Self::ReadDataResponseFut;
38    type ListChildrenResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>>
39        + Send;
40    fn r#list_children(&self) -> Self::ListChildrenResponseFut;
41    type OpenChildResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
42    fn r#open_child(
43        &self,
44        child_name: &str,
45        child_channel: fidl::endpoints::ServerEnd<InspectMarker>,
46    ) -> Self::OpenChildResponseFut;
47}
48#[derive(Debug)]
49#[cfg(target_os = "fuchsia")]
50pub struct InspectSynchronousProxy {
51    client: fidl::client::sync::Client,
52}
53
54#[cfg(target_os = "fuchsia")]
55impl fidl::endpoints::SynchronousProxy for InspectSynchronousProxy {
56    type Proxy = InspectProxy;
57    type Protocol = InspectMarker;
58
59    fn from_channel(inner: fidl::Channel) -> Self {
60        Self::new(inner)
61    }
62
63    fn into_channel(self) -> fidl::Channel {
64        self.client.into_channel()
65    }
66
67    fn as_channel(&self) -> &fidl::Channel {
68        self.client.as_channel()
69    }
70}
71
72#[cfg(target_os = "fuchsia")]
73impl InspectSynchronousProxy {
74    pub fn new(channel: fidl::Channel) -> Self {
75        let protocol_name = <InspectMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
76        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
77    }
78
79    pub fn into_channel(self) -> fidl::Channel {
80        self.client.into_channel()
81    }
82
83    /// Waits until an event arrives and returns it. It is safe for other
84    /// threads to make concurrent requests while waiting for an event.
85    pub fn wait_for_event(
86        &self,
87        deadline: zx::MonotonicInstant,
88    ) -> Result<InspectEvent, fidl::Error> {
89        InspectEvent::decode(self.client.wait_for_event(deadline)?)
90    }
91
92    pub fn r#read_data(&self, ___deadline: zx::MonotonicInstant) -> Result<Object, fidl::Error> {
93        let _response =
94            self.client.send_query::<fidl::encoding::EmptyPayload, InspectReadDataResponse>(
95                (),
96                0x1c6778e57fcfa9e1,
97                fidl::encoding::DynamicFlags::empty(),
98                ___deadline,
99            )?;
100        Ok(_response.object)
101    }
102
103    pub fn r#list_children(
104        &self,
105        ___deadline: zx::MonotonicInstant,
106    ) -> Result<Vec<String>, fidl::Error> {
107        let _response =
108            self.client.send_query::<fidl::encoding::EmptyPayload, InspectListChildrenResponse>(
109                (),
110                0x463fdc024dc40611,
111                fidl::encoding::DynamicFlags::empty(),
112                ___deadline,
113            )?;
114        Ok(_response.children_names)
115    }
116
117    pub fn r#open_child(
118        &self,
119        mut child_name: &str,
120        mut child_channel: fidl::endpoints::ServerEnd<InspectMarker>,
121        ___deadline: zx::MonotonicInstant,
122    ) -> Result<bool, fidl::Error> {
123        let _response =
124            self.client.send_query::<InspectOpenChildRequest, InspectOpenChildResponse>(
125                (child_name, child_channel),
126                0x30513125b65c866a,
127                fidl::encoding::DynamicFlags::empty(),
128                ___deadline,
129            )?;
130        Ok(_response.success)
131    }
132}
133
134#[cfg(target_os = "fuchsia")]
135impl From<InspectSynchronousProxy> for zx::Handle {
136    fn from(value: InspectSynchronousProxy) -> Self {
137        value.into_channel().into()
138    }
139}
140
141#[cfg(target_os = "fuchsia")]
142impl From<fidl::Channel> for InspectSynchronousProxy {
143    fn from(value: fidl::Channel) -> Self {
144        Self::new(value)
145    }
146}
147
148#[cfg(target_os = "fuchsia")]
149impl fidl::endpoints::FromClient for InspectSynchronousProxy {
150    type Protocol = InspectMarker;
151
152    fn from_client(value: fidl::endpoints::ClientEnd<InspectMarker>) -> Self {
153        Self::new(value.into_channel())
154    }
155}
156
157#[derive(Debug, Clone)]
158pub struct InspectProxy {
159    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
160}
161
162impl fidl::endpoints::Proxy for InspectProxy {
163    type Protocol = InspectMarker;
164
165    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
166        Self::new(inner)
167    }
168
169    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
170        self.client.into_channel().map_err(|client| Self { client })
171    }
172
173    fn as_channel(&self) -> &::fidl::AsyncChannel {
174        self.client.as_channel()
175    }
176}
177
178impl InspectProxy {
179    /// Create a new Proxy for fuchsia.inspect.deprecated/Inspect.
180    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
181        let protocol_name = <InspectMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
182        Self { client: fidl::client::Client::new(channel, protocol_name) }
183    }
184
185    /// Get a Stream of events from the remote end of the protocol.
186    ///
187    /// # Panics
188    ///
189    /// Panics if the event stream was already taken.
190    pub fn take_event_stream(&self) -> InspectEventStream {
191        InspectEventStream { event_receiver: self.client.take_event_receiver() }
192    }
193
194    pub fn r#read_data(
195        &self,
196    ) -> fidl::client::QueryResponseFut<Object, fidl::encoding::DefaultFuchsiaResourceDialect> {
197        InspectProxyInterface::r#read_data(self)
198    }
199
200    pub fn r#list_children(
201        &self,
202    ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
203    {
204        InspectProxyInterface::r#list_children(self)
205    }
206
207    pub fn r#open_child(
208        &self,
209        mut child_name: &str,
210        mut child_channel: fidl::endpoints::ServerEnd<InspectMarker>,
211    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
212        InspectProxyInterface::r#open_child(self, child_name, child_channel)
213    }
214}
215
216impl InspectProxyInterface for InspectProxy {
217    type ReadDataResponseFut =
218        fidl::client::QueryResponseFut<Object, fidl::encoding::DefaultFuchsiaResourceDialect>;
219    fn r#read_data(&self) -> Self::ReadDataResponseFut {
220        fn _decode(
221            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
222        ) -> Result<Object, fidl::Error> {
223            let _response = fidl::client::decode_transaction_body::<
224                InspectReadDataResponse,
225                fidl::encoding::DefaultFuchsiaResourceDialect,
226                0x1c6778e57fcfa9e1,
227            >(_buf?)?;
228            Ok(_response.object)
229        }
230        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Object>(
231            (),
232            0x1c6778e57fcfa9e1,
233            fidl::encoding::DynamicFlags::empty(),
234            _decode,
235        )
236    }
237
238    type ListChildrenResponseFut =
239        fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
240    fn r#list_children(&self) -> Self::ListChildrenResponseFut {
241        fn _decode(
242            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
243        ) -> Result<Vec<String>, fidl::Error> {
244            let _response = fidl::client::decode_transaction_body::<
245                InspectListChildrenResponse,
246                fidl::encoding::DefaultFuchsiaResourceDialect,
247                0x463fdc024dc40611,
248            >(_buf?)?;
249            Ok(_response.children_names)
250        }
251        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
252            (),
253            0x463fdc024dc40611,
254            fidl::encoding::DynamicFlags::empty(),
255            _decode,
256        )
257    }
258
259    type OpenChildResponseFut =
260        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
261    fn r#open_child(
262        &self,
263        mut child_name: &str,
264        mut child_channel: fidl::endpoints::ServerEnd<InspectMarker>,
265    ) -> Self::OpenChildResponseFut {
266        fn _decode(
267            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
268        ) -> Result<bool, fidl::Error> {
269            let _response = fidl::client::decode_transaction_body::<
270                InspectOpenChildResponse,
271                fidl::encoding::DefaultFuchsiaResourceDialect,
272                0x30513125b65c866a,
273            >(_buf?)?;
274            Ok(_response.success)
275        }
276        self.client.send_query_and_decode::<InspectOpenChildRequest, bool>(
277            (child_name, child_channel),
278            0x30513125b65c866a,
279            fidl::encoding::DynamicFlags::empty(),
280            _decode,
281        )
282    }
283}
284
285pub struct InspectEventStream {
286    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
287}
288
289impl std::marker::Unpin for InspectEventStream {}
290
291impl futures::stream::FusedStream for InspectEventStream {
292    fn is_terminated(&self) -> bool {
293        self.event_receiver.is_terminated()
294    }
295}
296
297impl futures::Stream for InspectEventStream {
298    type Item = Result<InspectEvent, fidl::Error>;
299
300    fn poll_next(
301        mut self: std::pin::Pin<&mut Self>,
302        cx: &mut std::task::Context<'_>,
303    ) -> std::task::Poll<Option<Self::Item>> {
304        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
305            &mut self.event_receiver,
306            cx
307        )?) {
308            Some(buf) => std::task::Poll::Ready(Some(InspectEvent::decode(buf))),
309            None => std::task::Poll::Ready(None),
310        }
311    }
312}
313
314#[derive(Debug)]
315pub enum InspectEvent {}
316
317impl InspectEvent {
318    /// Decodes a message buffer as a [`InspectEvent`].
319    fn decode(
320        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
321    ) -> Result<InspectEvent, fidl::Error> {
322        let (bytes, _handles) = buf.split_mut();
323        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
324        debug_assert_eq!(tx_header.tx_id, 0);
325        match tx_header.ordinal {
326            _ => Err(fidl::Error::UnknownOrdinal {
327                ordinal: tx_header.ordinal,
328                protocol_name: <InspectMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
329            }),
330        }
331    }
332}
333
334/// A Stream of incoming requests for fuchsia.inspect.deprecated/Inspect.
335pub struct InspectRequestStream {
336    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
337    is_terminated: bool,
338}
339
340impl std::marker::Unpin for InspectRequestStream {}
341
342impl futures::stream::FusedStream for InspectRequestStream {
343    fn is_terminated(&self) -> bool {
344        self.is_terminated
345    }
346}
347
348impl fidl::endpoints::RequestStream for InspectRequestStream {
349    type Protocol = InspectMarker;
350    type ControlHandle = InspectControlHandle;
351
352    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
353        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
354    }
355
356    fn control_handle(&self) -> Self::ControlHandle {
357        InspectControlHandle { inner: self.inner.clone() }
358    }
359
360    fn into_inner(
361        self,
362    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
363    {
364        (self.inner, self.is_terminated)
365    }
366
367    fn from_inner(
368        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
369        is_terminated: bool,
370    ) -> Self {
371        Self { inner, is_terminated }
372    }
373}
374
375impl futures::Stream for InspectRequestStream {
376    type Item = Result<InspectRequest, fidl::Error>;
377
378    fn poll_next(
379        mut self: std::pin::Pin<&mut Self>,
380        cx: &mut std::task::Context<'_>,
381    ) -> std::task::Poll<Option<Self::Item>> {
382        let this = &mut *self;
383        if this.inner.check_shutdown(cx) {
384            this.is_terminated = true;
385            return std::task::Poll::Ready(None);
386        }
387        if this.is_terminated {
388            panic!("polled InspectRequestStream after completion");
389        }
390        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
391            |bytes, handles| {
392                match this.inner.channel().read_etc(cx, bytes, handles) {
393                    std::task::Poll::Ready(Ok(())) => {}
394                    std::task::Poll::Pending => return std::task::Poll::Pending,
395                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
396                        this.is_terminated = true;
397                        return std::task::Poll::Ready(None);
398                    }
399                    std::task::Poll::Ready(Err(e)) => {
400                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
401                            e.into(),
402                        ))));
403                    }
404                }
405
406                // A message has been received from the channel
407                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
408
409                std::task::Poll::Ready(Some(match header.ordinal {
410                    0x1c6778e57fcfa9e1 => {
411                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
412                        let mut req = fidl::new_empty!(
413                            fidl::encoding::EmptyPayload,
414                            fidl::encoding::DefaultFuchsiaResourceDialect
415                        );
416                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
417                        let control_handle = InspectControlHandle { inner: this.inner.clone() };
418                        Ok(InspectRequest::ReadData {
419                            responder: InspectReadDataResponder {
420                                control_handle: std::mem::ManuallyDrop::new(control_handle),
421                                tx_id: header.tx_id,
422                            },
423                        })
424                    }
425                    0x463fdc024dc40611 => {
426                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
427                        let mut req = fidl::new_empty!(
428                            fidl::encoding::EmptyPayload,
429                            fidl::encoding::DefaultFuchsiaResourceDialect
430                        );
431                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
432                        let control_handle = InspectControlHandle { inner: this.inner.clone() };
433                        Ok(InspectRequest::ListChildren {
434                            responder: InspectListChildrenResponder {
435                                control_handle: std::mem::ManuallyDrop::new(control_handle),
436                                tx_id: header.tx_id,
437                            },
438                        })
439                    }
440                    0x30513125b65c866a => {
441                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
442                        let mut req = fidl::new_empty!(
443                            InspectOpenChildRequest,
444                            fidl::encoding::DefaultFuchsiaResourceDialect
445                        );
446                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InspectOpenChildRequest>(&header, _body_bytes, handles, &mut req)?;
447                        let control_handle = InspectControlHandle { inner: this.inner.clone() };
448                        Ok(InspectRequest::OpenChild {
449                            child_name: req.child_name,
450                            child_channel: req.child_channel,
451
452                            responder: InspectOpenChildResponder {
453                                control_handle: std::mem::ManuallyDrop::new(control_handle),
454                                tx_id: header.tx_id,
455                            },
456                        })
457                    }
458                    _ => Err(fidl::Error::UnknownOrdinal {
459                        ordinal: header.ordinal,
460                        protocol_name:
461                            <InspectMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
462                    }),
463                }))
464            },
465        )
466    }
467}
468
469#[derive(Debug)]
470pub enum InspectRequest {
471    ReadData {
472        responder: InspectReadDataResponder,
473    },
474    ListChildren {
475        responder: InspectListChildrenResponder,
476    },
477    OpenChild {
478        child_name: String,
479        child_channel: fidl::endpoints::ServerEnd<InspectMarker>,
480        responder: InspectOpenChildResponder,
481    },
482}
483
484impl InspectRequest {
485    #[allow(irrefutable_let_patterns)]
486    pub fn into_read_data(self) -> Option<(InspectReadDataResponder)> {
487        if let InspectRequest::ReadData { responder } = self { Some((responder)) } else { None }
488    }
489
490    #[allow(irrefutable_let_patterns)]
491    pub fn into_list_children(self) -> Option<(InspectListChildrenResponder)> {
492        if let InspectRequest::ListChildren { responder } = self { Some((responder)) } else { None }
493    }
494
495    #[allow(irrefutable_let_patterns)]
496    pub fn into_open_child(
497        self,
498    ) -> Option<(String, fidl::endpoints::ServerEnd<InspectMarker>, InspectOpenChildResponder)>
499    {
500        if let InspectRequest::OpenChild { child_name, child_channel, responder } = self {
501            Some((child_name, child_channel, responder))
502        } else {
503            None
504        }
505    }
506
507    /// Name of the method defined in FIDL
508    pub fn method_name(&self) -> &'static str {
509        match *self {
510            InspectRequest::ReadData { .. } => "read_data",
511            InspectRequest::ListChildren { .. } => "list_children",
512            InspectRequest::OpenChild { .. } => "open_child",
513        }
514    }
515}
516
517#[derive(Debug, Clone)]
518pub struct InspectControlHandle {
519    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
520}
521
522impl fidl::endpoints::ControlHandle for InspectControlHandle {
523    fn shutdown(&self) {
524        self.inner.shutdown()
525    }
526    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
527        self.inner.shutdown_with_epitaph(status)
528    }
529
530    fn is_closed(&self) -> bool {
531        self.inner.channel().is_closed()
532    }
533    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
534        self.inner.channel().on_closed()
535    }
536
537    #[cfg(target_os = "fuchsia")]
538    fn signal_peer(
539        &self,
540        clear_mask: zx::Signals,
541        set_mask: zx::Signals,
542    ) -> Result<(), zx_status::Status> {
543        use fidl::Peered;
544        self.inner.channel().signal_peer(clear_mask, set_mask)
545    }
546}
547
548impl InspectControlHandle {}
549
550#[must_use = "FIDL methods require a response to be sent"]
551#[derive(Debug)]
552pub struct InspectReadDataResponder {
553    control_handle: std::mem::ManuallyDrop<InspectControlHandle>,
554    tx_id: u32,
555}
556
557/// Set the the channel to be shutdown (see [`InspectControlHandle::shutdown`])
558/// if the responder is dropped without sending a response, so that the client
559/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
560impl std::ops::Drop for InspectReadDataResponder {
561    fn drop(&mut self) {
562        self.control_handle.shutdown();
563        // Safety: drops once, never accessed again
564        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
565    }
566}
567
568impl fidl::endpoints::Responder for InspectReadDataResponder {
569    type ControlHandle = InspectControlHandle;
570
571    fn control_handle(&self) -> &InspectControlHandle {
572        &self.control_handle
573    }
574
575    fn drop_without_shutdown(mut self) {
576        // Safety: drops once, never accessed again due to mem::forget
577        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
578        // Prevent Drop from running (which would shut down the channel)
579        std::mem::forget(self);
580    }
581}
582
583impl InspectReadDataResponder {
584    /// Sends a response to the FIDL transaction.
585    ///
586    /// Sets the channel to shutdown if an error occurs.
587    pub fn send(self, mut object: &Object) -> Result<(), fidl::Error> {
588        let _result = self.send_raw(object);
589        if _result.is_err() {
590            self.control_handle.shutdown();
591        }
592        self.drop_without_shutdown();
593        _result
594    }
595
596    /// Similar to "send" but does not shutdown the channel if an error occurs.
597    pub fn send_no_shutdown_on_err(self, mut object: &Object) -> Result<(), fidl::Error> {
598        let _result = self.send_raw(object);
599        self.drop_without_shutdown();
600        _result
601    }
602
603    fn send_raw(&self, mut object: &Object) -> Result<(), fidl::Error> {
604        self.control_handle.inner.send::<InspectReadDataResponse>(
605            (object,),
606            self.tx_id,
607            0x1c6778e57fcfa9e1,
608            fidl::encoding::DynamicFlags::empty(),
609        )
610    }
611}
612
613#[must_use = "FIDL methods require a response to be sent"]
614#[derive(Debug)]
615pub struct InspectListChildrenResponder {
616    control_handle: std::mem::ManuallyDrop<InspectControlHandle>,
617    tx_id: u32,
618}
619
620/// Set the the channel to be shutdown (see [`InspectControlHandle::shutdown`])
621/// if the responder is dropped without sending a response, so that the client
622/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
623impl std::ops::Drop for InspectListChildrenResponder {
624    fn drop(&mut self) {
625        self.control_handle.shutdown();
626        // Safety: drops once, never accessed again
627        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
628    }
629}
630
631impl fidl::endpoints::Responder for InspectListChildrenResponder {
632    type ControlHandle = InspectControlHandle;
633
634    fn control_handle(&self) -> &InspectControlHandle {
635        &self.control_handle
636    }
637
638    fn drop_without_shutdown(mut self) {
639        // Safety: drops once, never accessed again due to mem::forget
640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
641        // Prevent Drop from running (which would shut down the channel)
642        std::mem::forget(self);
643    }
644}
645
646impl InspectListChildrenResponder {
647    /// Sends a response to the FIDL transaction.
648    ///
649    /// Sets the channel to shutdown if an error occurs.
650    pub fn send(self, mut children_names: &[String]) -> Result<(), fidl::Error> {
651        let _result = self.send_raw(children_names);
652        if _result.is_err() {
653            self.control_handle.shutdown();
654        }
655        self.drop_without_shutdown();
656        _result
657    }
658
659    /// Similar to "send" but does not shutdown the channel if an error occurs.
660    pub fn send_no_shutdown_on_err(self, mut children_names: &[String]) -> Result<(), fidl::Error> {
661        let _result = self.send_raw(children_names);
662        self.drop_without_shutdown();
663        _result
664    }
665
666    fn send_raw(&self, mut children_names: &[String]) -> Result<(), fidl::Error> {
667        self.control_handle.inner.send::<InspectListChildrenResponse>(
668            (children_names,),
669            self.tx_id,
670            0x463fdc024dc40611,
671            fidl::encoding::DynamicFlags::empty(),
672        )
673    }
674}
675
676#[must_use = "FIDL methods require a response to be sent"]
677#[derive(Debug)]
678pub struct InspectOpenChildResponder {
679    control_handle: std::mem::ManuallyDrop<InspectControlHandle>,
680    tx_id: u32,
681}
682
683/// Set the the channel to be shutdown (see [`InspectControlHandle::shutdown`])
684/// if the responder is dropped without sending a response, so that the client
685/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
686impl std::ops::Drop for InspectOpenChildResponder {
687    fn drop(&mut self) {
688        self.control_handle.shutdown();
689        // Safety: drops once, never accessed again
690        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
691    }
692}
693
694impl fidl::endpoints::Responder for InspectOpenChildResponder {
695    type ControlHandle = InspectControlHandle;
696
697    fn control_handle(&self) -> &InspectControlHandle {
698        &self.control_handle
699    }
700
701    fn drop_without_shutdown(mut self) {
702        // Safety: drops once, never accessed again due to mem::forget
703        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
704        // Prevent Drop from running (which would shut down the channel)
705        std::mem::forget(self);
706    }
707}
708
709impl InspectOpenChildResponder {
710    /// Sends a response to the FIDL transaction.
711    ///
712    /// Sets the channel to shutdown if an error occurs.
713    pub fn send(self, mut success: bool) -> Result<(), fidl::Error> {
714        let _result = self.send_raw(success);
715        if _result.is_err() {
716            self.control_handle.shutdown();
717        }
718        self.drop_without_shutdown();
719        _result
720    }
721
722    /// Similar to "send" but does not shutdown the channel if an error occurs.
723    pub fn send_no_shutdown_on_err(self, mut success: bool) -> Result<(), fidl::Error> {
724        let _result = self.send_raw(success);
725        self.drop_without_shutdown();
726        _result
727    }
728
729    fn send_raw(&self, mut success: bool) -> Result<(), fidl::Error> {
730        self.control_handle.inner.send::<InspectOpenChildResponse>(
731            (success,),
732            self.tx_id,
733            0x30513125b65c866a,
734            fidl::encoding::DynamicFlags::empty(),
735        )
736    }
737}
738
739mod internal {
740    use super::*;
741
742    impl fidl::encoding::ResourceTypeMarker for InspectOpenChildRequest {
743        type Borrowed<'a> = &'a mut Self;
744        fn take_or_borrow<'a>(
745            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
746        ) -> Self::Borrowed<'a> {
747            value
748        }
749    }
750
751    unsafe impl fidl::encoding::TypeMarker for InspectOpenChildRequest {
752        type Owned = Self;
753
754        #[inline(always)]
755        fn inline_align(_context: fidl::encoding::Context) -> usize {
756            8
757        }
758
759        #[inline(always)]
760        fn inline_size(_context: fidl::encoding::Context) -> usize {
761            24
762        }
763    }
764
765    unsafe impl
766        fidl::encoding::Encode<
767            InspectOpenChildRequest,
768            fidl::encoding::DefaultFuchsiaResourceDialect,
769        > for &mut InspectOpenChildRequest
770    {
771        #[inline]
772        unsafe fn encode(
773            self,
774            encoder: &mut fidl::encoding::Encoder<
775                '_,
776                fidl::encoding::DefaultFuchsiaResourceDialect,
777            >,
778            offset: usize,
779            _depth: fidl::encoding::Depth,
780        ) -> fidl::Result<()> {
781            encoder.debug_check_bounds::<InspectOpenChildRequest>(offset);
782            // Delegate to tuple encoding.
783            fidl::encoding::Encode::<InspectOpenChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
784                (
785                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.child_name),
786                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InspectMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.child_channel),
787                ),
788                encoder, offset, _depth
789            )
790        }
791    }
792    unsafe impl<
793        T0: fidl::encoding::Encode<
794                fidl::encoding::UnboundedString,
795                fidl::encoding::DefaultFuchsiaResourceDialect,
796            >,
797        T1: fidl::encoding::Encode<
798                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InspectMarker>>,
799                fidl::encoding::DefaultFuchsiaResourceDialect,
800            >,
801    >
802        fidl::encoding::Encode<
803            InspectOpenChildRequest,
804            fidl::encoding::DefaultFuchsiaResourceDialect,
805        > for (T0, T1)
806    {
807        #[inline]
808        unsafe fn encode(
809            self,
810            encoder: &mut fidl::encoding::Encoder<
811                '_,
812                fidl::encoding::DefaultFuchsiaResourceDialect,
813            >,
814            offset: usize,
815            depth: fidl::encoding::Depth,
816        ) -> fidl::Result<()> {
817            encoder.debug_check_bounds::<InspectOpenChildRequest>(offset);
818            // Zero out padding regions. There's no need to apply masks
819            // because the unmasked parts will be overwritten by fields.
820            unsafe {
821                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
822                (ptr as *mut u64).write_unaligned(0);
823            }
824            // Write the fields.
825            self.0.encode(encoder, offset + 0, depth)?;
826            self.1.encode(encoder, offset + 16, depth)?;
827            Ok(())
828        }
829    }
830
831    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
832        for InspectOpenChildRequest
833    {
834        #[inline(always)]
835        fn new_empty() -> Self {
836            Self {
837                child_name: fidl::new_empty!(
838                    fidl::encoding::UnboundedString,
839                    fidl::encoding::DefaultFuchsiaResourceDialect
840                ),
841                child_channel: fidl::new_empty!(
842                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InspectMarker>>,
843                    fidl::encoding::DefaultFuchsiaResourceDialect
844                ),
845            }
846        }
847
848        #[inline]
849        unsafe fn decode(
850            &mut self,
851            decoder: &mut fidl::encoding::Decoder<
852                '_,
853                fidl::encoding::DefaultFuchsiaResourceDialect,
854            >,
855            offset: usize,
856            _depth: fidl::encoding::Depth,
857        ) -> fidl::Result<()> {
858            decoder.debug_check_bounds::<Self>(offset);
859            // Verify that padding bytes are zero.
860            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
861            let padval = unsafe { (ptr as *const u64).read_unaligned() };
862            let mask = 0xffffffff00000000u64;
863            let maskedval = padval & mask;
864            if maskedval != 0 {
865                return Err(fidl::Error::NonZeroPadding {
866                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
867                });
868            }
869            fidl::decode!(
870                fidl::encoding::UnboundedString,
871                fidl::encoding::DefaultFuchsiaResourceDialect,
872                &mut self.child_name,
873                decoder,
874                offset + 0,
875                _depth
876            )?;
877            fidl::decode!(
878                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InspectMarker>>,
879                fidl::encoding::DefaultFuchsiaResourceDialect,
880                &mut self.child_channel,
881                decoder,
882                offset + 16,
883                _depth
884            )?;
885            Ok(())
886        }
887    }
888}