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