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::NullableHandle {
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
527    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
528        self.inner.shutdown_with_epitaph(status)
529    }
530
531    fn is_closed(&self) -> bool {
532        self.inner.channel().is_closed()
533    }
534    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
535        self.inner.channel().on_closed()
536    }
537
538    #[cfg(target_os = "fuchsia")]
539    fn signal_peer(
540        &self,
541        clear_mask: zx::Signals,
542        set_mask: zx::Signals,
543    ) -> Result<(), zx_status::Status> {
544        use fidl::Peered;
545        self.inner.channel().signal_peer(clear_mask, set_mask)
546    }
547}
548
549impl InspectControlHandle {}
550
551#[must_use = "FIDL methods require a response to be sent"]
552#[derive(Debug)]
553pub struct InspectReadDataResponder {
554    control_handle: std::mem::ManuallyDrop<InspectControlHandle>,
555    tx_id: u32,
556}
557
558/// Set the the channel to be shutdown (see [`InspectControlHandle::shutdown`])
559/// if the responder is dropped without sending a response, so that the client
560/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
561impl std::ops::Drop for InspectReadDataResponder {
562    fn drop(&mut self) {
563        self.control_handle.shutdown();
564        // Safety: drops once, never accessed again
565        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
566    }
567}
568
569impl fidl::endpoints::Responder for InspectReadDataResponder {
570    type ControlHandle = InspectControlHandle;
571
572    fn control_handle(&self) -> &InspectControlHandle {
573        &self.control_handle
574    }
575
576    fn drop_without_shutdown(mut self) {
577        // Safety: drops once, never accessed again due to mem::forget
578        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
579        // Prevent Drop from running (which would shut down the channel)
580        std::mem::forget(self);
581    }
582}
583
584impl InspectReadDataResponder {
585    /// Sends a response to the FIDL transaction.
586    ///
587    /// Sets the channel to shutdown if an error occurs.
588    pub fn send(self, mut object: &Object) -> Result<(), fidl::Error> {
589        let _result = self.send_raw(object);
590        if _result.is_err() {
591            self.control_handle.shutdown();
592        }
593        self.drop_without_shutdown();
594        _result
595    }
596
597    /// Similar to "send" but does not shutdown the channel if an error occurs.
598    pub fn send_no_shutdown_on_err(self, mut object: &Object) -> Result<(), fidl::Error> {
599        let _result = self.send_raw(object);
600        self.drop_without_shutdown();
601        _result
602    }
603
604    fn send_raw(&self, mut object: &Object) -> Result<(), fidl::Error> {
605        self.control_handle.inner.send::<InspectReadDataResponse>(
606            (object,),
607            self.tx_id,
608            0x1c6778e57fcfa9e1,
609            fidl::encoding::DynamicFlags::empty(),
610        )
611    }
612}
613
614#[must_use = "FIDL methods require a response to be sent"]
615#[derive(Debug)]
616pub struct InspectListChildrenResponder {
617    control_handle: std::mem::ManuallyDrop<InspectControlHandle>,
618    tx_id: u32,
619}
620
621/// Set the the channel to be shutdown (see [`InspectControlHandle::shutdown`])
622/// if the responder is dropped without sending a response, so that the client
623/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
624impl std::ops::Drop for InspectListChildrenResponder {
625    fn drop(&mut self) {
626        self.control_handle.shutdown();
627        // Safety: drops once, never accessed again
628        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
629    }
630}
631
632impl fidl::endpoints::Responder for InspectListChildrenResponder {
633    type ControlHandle = InspectControlHandle;
634
635    fn control_handle(&self) -> &InspectControlHandle {
636        &self.control_handle
637    }
638
639    fn drop_without_shutdown(mut self) {
640        // Safety: drops once, never accessed again due to mem::forget
641        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
642        // Prevent Drop from running (which would shut down the channel)
643        std::mem::forget(self);
644    }
645}
646
647impl InspectListChildrenResponder {
648    /// Sends a response to the FIDL transaction.
649    ///
650    /// Sets the channel to shutdown if an error occurs.
651    pub fn send(self, mut children_names: &[String]) -> Result<(), fidl::Error> {
652        let _result = self.send_raw(children_names);
653        if _result.is_err() {
654            self.control_handle.shutdown();
655        }
656        self.drop_without_shutdown();
657        _result
658    }
659
660    /// Similar to "send" but does not shutdown the channel if an error occurs.
661    pub fn send_no_shutdown_on_err(self, mut children_names: &[String]) -> Result<(), fidl::Error> {
662        let _result = self.send_raw(children_names);
663        self.drop_without_shutdown();
664        _result
665    }
666
667    fn send_raw(&self, mut children_names: &[String]) -> Result<(), fidl::Error> {
668        self.control_handle.inner.send::<InspectListChildrenResponse>(
669            (children_names,),
670            self.tx_id,
671            0x463fdc024dc40611,
672            fidl::encoding::DynamicFlags::empty(),
673        )
674    }
675}
676
677#[must_use = "FIDL methods require a response to be sent"]
678#[derive(Debug)]
679pub struct InspectOpenChildResponder {
680    control_handle: std::mem::ManuallyDrop<InspectControlHandle>,
681    tx_id: u32,
682}
683
684/// Set the the channel to be shutdown (see [`InspectControlHandle::shutdown`])
685/// if the responder is dropped without sending a response, so that the client
686/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
687impl std::ops::Drop for InspectOpenChildResponder {
688    fn drop(&mut self) {
689        self.control_handle.shutdown();
690        // Safety: drops once, never accessed again
691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
692    }
693}
694
695impl fidl::endpoints::Responder for InspectOpenChildResponder {
696    type ControlHandle = InspectControlHandle;
697
698    fn control_handle(&self) -> &InspectControlHandle {
699        &self.control_handle
700    }
701
702    fn drop_without_shutdown(mut self) {
703        // Safety: drops once, never accessed again due to mem::forget
704        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
705        // Prevent Drop from running (which would shut down the channel)
706        std::mem::forget(self);
707    }
708}
709
710impl InspectOpenChildResponder {
711    /// Sends a response to the FIDL transaction.
712    ///
713    /// Sets the channel to shutdown if an error occurs.
714    pub fn send(self, mut success: bool) -> Result<(), fidl::Error> {
715        let _result = self.send_raw(success);
716        if _result.is_err() {
717            self.control_handle.shutdown();
718        }
719        self.drop_without_shutdown();
720        _result
721    }
722
723    /// Similar to "send" but does not shutdown the channel if an error occurs.
724    pub fn send_no_shutdown_on_err(self, mut success: bool) -> Result<(), fidl::Error> {
725        let _result = self.send_raw(success);
726        self.drop_without_shutdown();
727        _result
728    }
729
730    fn send_raw(&self, mut success: bool) -> Result<(), fidl::Error> {
731        self.control_handle.inner.send::<InspectOpenChildResponse>(
732            (success,),
733            self.tx_id,
734            0x30513125b65c866a,
735            fidl::encoding::DynamicFlags::empty(),
736        )
737    }
738}
739
740mod internal {
741    use super::*;
742
743    impl fidl::encoding::ResourceTypeMarker for InspectOpenChildRequest {
744        type Borrowed<'a> = &'a mut Self;
745        fn take_or_borrow<'a>(
746            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
747        ) -> Self::Borrowed<'a> {
748            value
749        }
750    }
751
752    unsafe impl fidl::encoding::TypeMarker for InspectOpenChildRequest {
753        type Owned = Self;
754
755        #[inline(always)]
756        fn inline_align(_context: fidl::encoding::Context) -> usize {
757            8
758        }
759
760        #[inline(always)]
761        fn inline_size(_context: fidl::encoding::Context) -> usize {
762            24
763        }
764    }
765
766    unsafe impl
767        fidl::encoding::Encode<
768            InspectOpenChildRequest,
769            fidl::encoding::DefaultFuchsiaResourceDialect,
770        > for &mut InspectOpenChildRequest
771    {
772        #[inline]
773        unsafe fn encode(
774            self,
775            encoder: &mut fidl::encoding::Encoder<
776                '_,
777                fidl::encoding::DefaultFuchsiaResourceDialect,
778            >,
779            offset: usize,
780            _depth: fidl::encoding::Depth,
781        ) -> fidl::Result<()> {
782            encoder.debug_check_bounds::<InspectOpenChildRequest>(offset);
783            // Delegate to tuple encoding.
784            fidl::encoding::Encode::<InspectOpenChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
785                (
786                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.child_name),
787                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InspectMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.child_channel),
788                ),
789                encoder, offset, _depth
790            )
791        }
792    }
793    unsafe impl<
794        T0: fidl::encoding::Encode<
795                fidl::encoding::UnboundedString,
796                fidl::encoding::DefaultFuchsiaResourceDialect,
797            >,
798        T1: fidl::encoding::Encode<
799                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InspectMarker>>,
800                fidl::encoding::DefaultFuchsiaResourceDialect,
801            >,
802    >
803        fidl::encoding::Encode<
804            InspectOpenChildRequest,
805            fidl::encoding::DefaultFuchsiaResourceDialect,
806        > for (T0, T1)
807    {
808        #[inline]
809        unsafe fn encode(
810            self,
811            encoder: &mut fidl::encoding::Encoder<
812                '_,
813                fidl::encoding::DefaultFuchsiaResourceDialect,
814            >,
815            offset: usize,
816            depth: fidl::encoding::Depth,
817        ) -> fidl::Result<()> {
818            encoder.debug_check_bounds::<InspectOpenChildRequest>(offset);
819            // Zero out padding regions. There's no need to apply masks
820            // because the unmasked parts will be overwritten by fields.
821            unsafe {
822                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
823                (ptr as *mut u64).write_unaligned(0);
824            }
825            // Write the fields.
826            self.0.encode(encoder, offset + 0, depth)?;
827            self.1.encode(encoder, offset + 16, depth)?;
828            Ok(())
829        }
830    }
831
832    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
833        for InspectOpenChildRequest
834    {
835        #[inline(always)]
836        fn new_empty() -> Self {
837            Self {
838                child_name: fidl::new_empty!(
839                    fidl::encoding::UnboundedString,
840                    fidl::encoding::DefaultFuchsiaResourceDialect
841                ),
842                child_channel: fidl::new_empty!(
843                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InspectMarker>>,
844                    fidl::encoding::DefaultFuchsiaResourceDialect
845                ),
846            }
847        }
848
849        #[inline]
850        unsafe fn decode(
851            &mut self,
852            decoder: &mut fidl::encoding::Decoder<
853                '_,
854                fidl::encoding::DefaultFuchsiaResourceDialect,
855            >,
856            offset: usize,
857            _depth: fidl::encoding::Depth,
858        ) -> fidl::Result<()> {
859            decoder.debug_check_bounds::<Self>(offset);
860            // Verify that padding bytes are zero.
861            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
862            let padval = unsafe { (ptr as *const u64).read_unaligned() };
863            let mask = 0xffffffff00000000u64;
864            let maskedval = padval & mask;
865            if maskedval != 0 {
866                return Err(fidl::Error::NonZeroPadding {
867                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
868                });
869            }
870            fidl::decode!(
871                fidl::encoding::UnboundedString,
872                fidl::encoding::DefaultFuchsiaResourceDialect,
873                &mut self.child_name,
874                decoder,
875                offset + 0,
876                _depth
877            )?;
878            fidl::decode!(
879                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InspectMarker>>,
880                fidl::encoding::DefaultFuchsiaResourceDialect,
881                &mut self.child_channel,
882                decoder,
883                offset + 16,
884                _depth
885            )?;
886            Ok(())
887        }
888    }
889}