Skip to main content

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