Skip to main content

fidl_fuchsia_inspect/
fidl_fuchsia_inspect.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__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14pub type EscrowedVmo = fidl::Vmo;
15
16#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub struct EscrowToken {
18    pub token: fidl::EventPair,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for EscrowToken {}
22
23#[derive(Debug, PartialEq)]
24pub struct TreeGetContentResponse {
25    pub content: TreeContent,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TreeGetContentResponse {}
29
30#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
31pub struct TreeListChildNamesRequest {
32    pub tree_iterator: fidl::endpoints::ServerEnd<TreeNameIteratorMarker>,
33}
34
35impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TreeListChildNamesRequest {}
36
37#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
38pub struct TreeOpenChildRequest {
39    pub child_name: String,
40    pub tree: fidl::endpoints::ServerEnd<TreeMarker>,
41}
42
43impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TreeOpenChildRequest {}
44
45#[derive(Debug, Default, PartialEq)]
46pub struct InspectSinkEscrowRequest {
47    /// The VMO containing Inspect data that the server will store.
48    /// Required
49    pub vmo: Option<fidl::Vmo>,
50    /// The token identifying this VMO and also serving as a controller to
51    /// stop storing this VMO in the server.
52    /// Required
53    pub token: Option<EscrowToken>,
54    /// An optional name to identify this VMO, that can be human readable.
55    ///
56    /// Optional
57    pub name: Option<String>,
58    /// An optional reference to the Tree that was previously provided to
59    /// the server using `Publish`. The server will drop the handle
60    /// associated with that tree connection, triggering a peer closed on
61    /// the tree server. This enables the client to ensure the following:
62    ///
63    /// - Tree data and escrowed data won't be present twice in snapshots.
64    /// - The caller can know when to stop serving the tree, preventing data
65    ///   missing from snapshots.
66    ///
67    /// If `name` isn't provided, the `name` of this Inspect will be the one
68    /// associated with this tree.
69    ///
70    /// If the server isn't tracking any handle associated with the source
71    /// component with this koid, this will be ignored and treated as if
72    /// nothing had been provided.
73    ///
74    /// Optional
75    pub tree: Option<u64>,
76    #[doc(hidden)]
77    pub __source_breaking: fidl::marker::SourceBreaking,
78}
79
80impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InspectSinkEscrowRequest {}
81
82#[derive(Debug, Default, PartialEq)]
83pub struct InspectSinkFetchEscrowRequest {
84    /// The token associated with the VMO taht we want to fetch. If this
85    /// token isn't associated with any VMO the response will be empty.
86    ///
87    /// Required
88    pub token: Option<EscrowToken>,
89    /// A handle that the server can use to continue reading data associated
90    /// with this VMO. The previous name that the component had given to
91    /// this VMO will be maintained. This would be equivalent to calling
92    /// `Publish` with the return VMO, except that it removes the race that
93    /// can happen if Inspect data is read, between the time that the
94    /// component fetches the VMO and publishes a tree for it.
95    ///
96    /// Optional
97    pub tree: Option<fidl::endpoints::ClientEnd<TreeMarker>>,
98    #[doc(hidden)]
99    pub __source_breaking: fidl::marker::SourceBreaking,
100}
101
102impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
103    for InspectSinkFetchEscrowRequest
104{
105}
106
107#[derive(Debug, Default, PartialEq)]
108pub struct InspectSinkPublishRequest {
109    /// The Tree that the server will use to fetch Inspect data.
110    ///
111    /// The connection will be closed if this isn't provided.
112    ///
113    /// Required
114    pub tree: Option<fidl::endpoints::ClientEnd<TreeMarker>>,
115    /// A name to identify this tree from the client perspective. This name
116    /// isn't required to be unique across multiple trees. Multiple trees
117    /// published under the same name are accepted and will not overwrite
118    /// previously published trees.
119    ///
120    /// Optional
121    pub name: Option<String>,
122    #[doc(hidden)]
123    pub __source_breaking: fidl::marker::SourceBreaking,
124}
125
126impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InspectSinkPublishRequest {}
127
128#[derive(Debug, Default, PartialEq)]
129pub struct InspectSinkFetchEscrowResponse {
130    pub vmo: Option<fidl::Vmo>,
131    #[doc(hidden)]
132    pub __source_breaking: fidl::marker::SourceBreaking,
133}
134
135impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
136    for InspectSinkFetchEscrowResponse
137{
138}
139
140/// The content of a specific Inspect Tree.
141#[derive(Debug, Default, PartialEq)]
142pub struct TreeContent {
143    /// Buffer containing the bytes of a tree in Inspect format.
144    pub buffer: Option<fidl_fuchsia_mem::Buffer>,
145    #[doc(hidden)]
146    pub __source_breaking: fidl::marker::SourceBreaking,
147}
148
149impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TreeContent {}
150
151#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
152pub struct InspectSinkMarker;
153
154impl fidl::endpoints::ProtocolMarker for InspectSinkMarker {
155    type Proxy = InspectSinkProxy;
156    type RequestStream = InspectSinkRequestStream;
157    #[cfg(target_os = "fuchsia")]
158    type SynchronousProxy = InspectSinkSynchronousProxy;
159
160    const DEBUG_NAME: &'static str = "fuchsia.inspect.InspectSink";
161}
162impl fidl::endpoints::DiscoverableProtocolMarker for InspectSinkMarker {}
163
164pub trait InspectSinkProxyInterface: Send + Sync {
165    fn r#publish(&self, payload: InspectSinkPublishRequest) -> Result<(), fidl::Error>;
166    fn r#escrow(&self, payload: InspectSinkEscrowRequest) -> Result<(), fidl::Error>;
167    type FetchEscrowResponseFut: std::future::Future<Output = Result<InspectSinkFetchEscrowResponse, fidl::Error>>
168        + Send;
169    fn r#fetch_escrow(
170        &self,
171        payload: InspectSinkFetchEscrowRequest,
172    ) -> Self::FetchEscrowResponseFut;
173}
174#[derive(Debug)]
175#[cfg(target_os = "fuchsia")]
176pub struct InspectSinkSynchronousProxy {
177    client: fidl::client::sync::Client,
178}
179
180#[cfg(target_os = "fuchsia")]
181impl fidl::endpoints::SynchronousProxy for InspectSinkSynchronousProxy {
182    type Proxy = InspectSinkProxy;
183    type Protocol = InspectSinkMarker;
184
185    fn from_channel(inner: fidl::Channel) -> Self {
186        Self::new(inner)
187    }
188
189    fn into_channel(self) -> fidl::Channel {
190        self.client.into_channel()
191    }
192
193    fn as_channel(&self) -> &fidl::Channel {
194        self.client.as_channel()
195    }
196}
197
198#[cfg(target_os = "fuchsia")]
199impl InspectSinkSynchronousProxy {
200    pub fn new(channel: fidl::Channel) -> Self {
201        Self { client: fidl::client::sync::Client::new(channel) }
202    }
203
204    pub fn into_channel(self) -> fidl::Channel {
205        self.client.into_channel()
206    }
207
208    /// Waits until an event arrives and returns it. It is safe for other
209    /// threads to make concurrent requests while waiting for an event.
210    pub fn wait_for_event(
211        &self,
212        deadline: zx::MonotonicInstant,
213    ) -> Result<InspectSinkEvent, fidl::Error> {
214        InspectSinkEvent::decode(self.client.wait_for_event::<InspectSinkMarker>(deadline)?)
215    }
216
217    /// Publishes a handle to the `fuchsia.inspect.Tree` protocol that the
218    /// server can use to read Inspect data, including lazy nodes.
219    pub fn r#publish(&self, mut payload: InspectSinkPublishRequest) -> Result<(), fidl::Error> {
220        self.client.send::<InspectSinkPublishRequest>(
221            &mut payload,
222            0xf9ceb1ab8ec6b4b,
223            fidl::encoding::DynamicFlags::FLEXIBLE,
224        )
225    }
226
227    /// Instructs the server to store the VMO provided to make its data
228    /// available to Inspect readers, even when the component that published
229    /// this VMO isn't running.
230    ///
231    /// This is meant to be used when integrating with Component Framework's
232    /// Escrow APIs to enable stopping when IDLE but still ensure that some
233    /// useful diagnostics information is available.
234    ///
235    /// The client must provide a `token` that will be used as a unique
236    /// identifier to this VMO by the the server. This token is an event pair, a
237    /// client must provide one end of this event pair and hold to the other end
238    /// (or escrow the handle it using Component APIs). If the server sees a
239    /// PEER_CLOSED on the handle it received, it will drop the VMO associated
240    /// with this token.
241    ///
242    /// If any of the required arguments isn't passed the connection will be
243    /// closed.
244    ///
245    /// To learn more about stopping IDLE components, please refer to:
246    /// https://fuchsia.dev/fuchsia-src/development/components/stop_idle
247    pub fn r#escrow(&self, mut payload: InspectSinkEscrowRequest) -> Result<(), fidl::Error> {
248        self.client.send::<InspectSinkEscrowRequest>(
249            &mut payload,
250            0x4b683186a65d2d16,
251            fidl::encoding::DynamicFlags::FLEXIBLE,
252        )
253    }
254
255    /// Instructs the server to return (and stop tracking) the VMO associated
256    /// with the given token.
257    ///
258    /// This is meant to be used when a component restarts and wants to fetch
259    /// Inspect data that it escrowed.
260    ///
261    /// To learn more about stopping IDLE components, please refer to:
262    /// https://fuchsia.dev/fuchsia-src/development/components/stop_idle
263    pub fn r#fetch_escrow(
264        &self,
265        mut payload: InspectSinkFetchEscrowRequest,
266        ___deadline: zx::MonotonicInstant,
267    ) -> Result<InspectSinkFetchEscrowResponse, fidl::Error> {
268        let _response = self.client.send_query::<
269            InspectSinkFetchEscrowRequest,
270            fidl::encoding::FlexibleType<InspectSinkFetchEscrowResponse>,
271            InspectSinkMarker,
272        >(
273            &mut payload,
274            0x7b9faa1a6f8e666a,
275            fidl::encoding::DynamicFlags::FLEXIBLE,
276            ___deadline,
277        )?
278        .into_result::<InspectSinkMarker>("fetch_escrow")?;
279        Ok(_response)
280    }
281}
282
283#[cfg(target_os = "fuchsia")]
284impl From<InspectSinkSynchronousProxy> for zx::NullableHandle {
285    fn from(value: InspectSinkSynchronousProxy) -> Self {
286        value.into_channel().into()
287    }
288}
289
290#[cfg(target_os = "fuchsia")]
291impl From<fidl::Channel> for InspectSinkSynchronousProxy {
292    fn from(value: fidl::Channel) -> Self {
293        Self::new(value)
294    }
295}
296
297#[cfg(target_os = "fuchsia")]
298impl fidl::endpoints::FromClient for InspectSinkSynchronousProxy {
299    type Protocol = InspectSinkMarker;
300
301    fn from_client(value: fidl::endpoints::ClientEnd<InspectSinkMarker>) -> Self {
302        Self::new(value.into_channel())
303    }
304}
305
306#[derive(Debug, Clone)]
307pub struct InspectSinkProxy {
308    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
309}
310
311impl fidl::endpoints::Proxy for InspectSinkProxy {
312    type Protocol = InspectSinkMarker;
313
314    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
315        Self::new(inner)
316    }
317
318    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
319        self.client.into_channel().map_err(|client| Self { client })
320    }
321
322    fn as_channel(&self) -> &::fidl::AsyncChannel {
323        self.client.as_channel()
324    }
325}
326
327impl InspectSinkProxy {
328    /// Create a new Proxy for fuchsia.inspect/InspectSink.
329    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
330        let protocol_name = <InspectSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
331        Self { client: fidl::client::Client::new(channel, protocol_name) }
332    }
333
334    /// Get a Stream of events from the remote end of the protocol.
335    ///
336    /// # Panics
337    ///
338    /// Panics if the event stream was already taken.
339    pub fn take_event_stream(&self) -> InspectSinkEventStream {
340        InspectSinkEventStream { event_receiver: self.client.take_event_receiver() }
341    }
342
343    /// Publishes a handle to the `fuchsia.inspect.Tree` protocol that the
344    /// server can use to read Inspect data, including lazy nodes.
345    pub fn r#publish(&self, mut payload: InspectSinkPublishRequest) -> Result<(), fidl::Error> {
346        InspectSinkProxyInterface::r#publish(self, payload)
347    }
348
349    /// Instructs the server to store the VMO provided to make its data
350    /// available to Inspect readers, even when the component that published
351    /// this VMO isn't running.
352    ///
353    /// This is meant to be used when integrating with Component Framework's
354    /// Escrow APIs to enable stopping when IDLE but still ensure that some
355    /// useful diagnostics information is available.
356    ///
357    /// The client must provide a `token` that will be used as a unique
358    /// identifier to this VMO by the the server. This token is an event pair, a
359    /// client must provide one end of this event pair and hold to the other end
360    /// (or escrow the handle it using Component APIs). If the server sees a
361    /// PEER_CLOSED on the handle it received, it will drop the VMO associated
362    /// with this token.
363    ///
364    /// If any of the required arguments isn't passed the connection will be
365    /// closed.
366    ///
367    /// To learn more about stopping IDLE components, please refer to:
368    /// https://fuchsia.dev/fuchsia-src/development/components/stop_idle
369    pub fn r#escrow(&self, mut payload: InspectSinkEscrowRequest) -> Result<(), fidl::Error> {
370        InspectSinkProxyInterface::r#escrow(self, payload)
371    }
372
373    /// Instructs the server to return (and stop tracking) the VMO associated
374    /// with the given token.
375    ///
376    /// This is meant to be used when a component restarts and wants to fetch
377    /// Inspect data that it escrowed.
378    ///
379    /// To learn more about stopping IDLE components, please refer to:
380    /// https://fuchsia.dev/fuchsia-src/development/components/stop_idle
381    pub fn r#fetch_escrow(
382        &self,
383        mut payload: InspectSinkFetchEscrowRequest,
384    ) -> fidl::client::QueryResponseFut<
385        InspectSinkFetchEscrowResponse,
386        fidl::encoding::DefaultFuchsiaResourceDialect,
387    > {
388        InspectSinkProxyInterface::r#fetch_escrow(self, payload)
389    }
390}
391
392impl InspectSinkProxyInterface for InspectSinkProxy {
393    fn r#publish(&self, mut payload: InspectSinkPublishRequest) -> Result<(), fidl::Error> {
394        self.client.send::<InspectSinkPublishRequest>(
395            &mut payload,
396            0xf9ceb1ab8ec6b4b,
397            fidl::encoding::DynamicFlags::FLEXIBLE,
398        )
399    }
400
401    fn r#escrow(&self, mut payload: InspectSinkEscrowRequest) -> Result<(), fidl::Error> {
402        self.client.send::<InspectSinkEscrowRequest>(
403            &mut payload,
404            0x4b683186a65d2d16,
405            fidl::encoding::DynamicFlags::FLEXIBLE,
406        )
407    }
408
409    type FetchEscrowResponseFut = fidl::client::QueryResponseFut<
410        InspectSinkFetchEscrowResponse,
411        fidl::encoding::DefaultFuchsiaResourceDialect,
412    >;
413    fn r#fetch_escrow(
414        &self,
415        mut payload: InspectSinkFetchEscrowRequest,
416    ) -> Self::FetchEscrowResponseFut {
417        fn _decode(
418            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
419        ) -> Result<InspectSinkFetchEscrowResponse, fidl::Error> {
420            let _response = fidl::client::decode_transaction_body::<
421                fidl::encoding::FlexibleType<InspectSinkFetchEscrowResponse>,
422                fidl::encoding::DefaultFuchsiaResourceDialect,
423                0x7b9faa1a6f8e666a,
424            >(_buf?)?
425            .into_result::<InspectSinkMarker>("fetch_escrow")?;
426            Ok(_response)
427        }
428        self.client
429            .send_query_and_decode::<InspectSinkFetchEscrowRequest, InspectSinkFetchEscrowResponse>(
430                &mut payload,
431                0x7b9faa1a6f8e666a,
432                fidl::encoding::DynamicFlags::FLEXIBLE,
433                _decode,
434            )
435    }
436}
437
438pub struct InspectSinkEventStream {
439    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
440}
441
442impl std::marker::Unpin for InspectSinkEventStream {}
443
444impl futures::stream::FusedStream for InspectSinkEventStream {
445    fn is_terminated(&self) -> bool {
446        self.event_receiver.is_terminated()
447    }
448}
449
450impl futures::Stream for InspectSinkEventStream {
451    type Item = Result<InspectSinkEvent, fidl::Error>;
452
453    fn poll_next(
454        mut self: std::pin::Pin<&mut Self>,
455        cx: &mut std::task::Context<'_>,
456    ) -> std::task::Poll<Option<Self::Item>> {
457        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
458            &mut self.event_receiver,
459            cx
460        )?) {
461            Some(buf) => std::task::Poll::Ready(Some(InspectSinkEvent::decode(buf))),
462            None => std::task::Poll::Ready(None),
463        }
464    }
465}
466
467#[derive(Debug)]
468pub enum InspectSinkEvent {
469    #[non_exhaustive]
470    _UnknownEvent {
471        /// Ordinal of the event that was sent.
472        ordinal: u64,
473    },
474}
475
476impl InspectSinkEvent {
477    /// Decodes a message buffer as a [`InspectSinkEvent`].
478    fn decode(
479        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
480    ) -> Result<InspectSinkEvent, fidl::Error> {
481        let (bytes, _handles) = buf.split_mut();
482        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
483        debug_assert_eq!(tx_header.tx_id, 0);
484        match tx_header.ordinal {
485            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
486                Ok(InspectSinkEvent::_UnknownEvent { ordinal: tx_header.ordinal })
487            }
488            _ => Err(fidl::Error::UnknownOrdinal {
489                ordinal: tx_header.ordinal,
490                protocol_name: <InspectSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
491            }),
492        }
493    }
494}
495
496/// A Stream of incoming requests for fuchsia.inspect/InspectSink.
497pub struct InspectSinkRequestStream {
498    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
499    is_terminated: bool,
500}
501
502impl std::marker::Unpin for InspectSinkRequestStream {}
503
504impl futures::stream::FusedStream for InspectSinkRequestStream {
505    fn is_terminated(&self) -> bool {
506        self.is_terminated
507    }
508}
509
510impl fidl::endpoints::RequestStream for InspectSinkRequestStream {
511    type Protocol = InspectSinkMarker;
512    type ControlHandle = InspectSinkControlHandle;
513
514    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
515        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
516    }
517
518    fn control_handle(&self) -> Self::ControlHandle {
519        InspectSinkControlHandle { inner: self.inner.clone() }
520    }
521
522    fn into_inner(
523        self,
524    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
525    {
526        (self.inner, self.is_terminated)
527    }
528
529    fn from_inner(
530        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
531        is_terminated: bool,
532    ) -> Self {
533        Self { inner, is_terminated }
534    }
535}
536
537impl futures::Stream for InspectSinkRequestStream {
538    type Item = Result<InspectSinkRequest, fidl::Error>;
539
540    fn poll_next(
541        mut self: std::pin::Pin<&mut Self>,
542        cx: &mut std::task::Context<'_>,
543    ) -> std::task::Poll<Option<Self::Item>> {
544        let this = &mut *self;
545        if this.inner.check_shutdown(cx) {
546            this.is_terminated = true;
547            return std::task::Poll::Ready(None);
548        }
549        if this.is_terminated {
550            panic!("polled InspectSinkRequestStream after completion");
551        }
552        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
553            |bytes, handles| {
554                match this.inner.channel().read_etc(cx, bytes, handles) {
555                    std::task::Poll::Ready(Ok(())) => {}
556                    std::task::Poll::Pending => return std::task::Poll::Pending,
557                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
558                        this.is_terminated = true;
559                        return std::task::Poll::Ready(None);
560                    }
561                    std::task::Poll::Ready(Err(e)) => {
562                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
563                            e.into(),
564                        ))));
565                    }
566                }
567
568                // A message has been received from the channel
569                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
570
571                std::task::Poll::Ready(Some(match header.ordinal {
572                    0xf9ceb1ab8ec6b4b => {
573                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
574                        let mut req = fidl::new_empty!(
575                            InspectSinkPublishRequest,
576                            fidl::encoding::DefaultFuchsiaResourceDialect
577                        );
578                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InspectSinkPublishRequest>(&header, _body_bytes, handles, &mut req)?;
579                        let control_handle = InspectSinkControlHandle { inner: this.inner.clone() };
580                        Ok(InspectSinkRequest::Publish { payload: req, control_handle })
581                    }
582                    0x4b683186a65d2d16 => {
583                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
584                        let mut req = fidl::new_empty!(
585                            InspectSinkEscrowRequest,
586                            fidl::encoding::DefaultFuchsiaResourceDialect
587                        );
588                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InspectSinkEscrowRequest>(&header, _body_bytes, handles, &mut req)?;
589                        let control_handle = InspectSinkControlHandle { inner: this.inner.clone() };
590                        Ok(InspectSinkRequest::Escrow { payload: req, control_handle })
591                    }
592                    0x7b9faa1a6f8e666a => {
593                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
594                        let mut req = fidl::new_empty!(
595                            InspectSinkFetchEscrowRequest,
596                            fidl::encoding::DefaultFuchsiaResourceDialect
597                        );
598                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InspectSinkFetchEscrowRequest>(&header, _body_bytes, handles, &mut req)?;
599                        let control_handle = InspectSinkControlHandle { inner: this.inner.clone() };
600                        Ok(InspectSinkRequest::FetchEscrow {
601                            payload: req,
602                            responder: InspectSinkFetchEscrowResponder {
603                                control_handle: std::mem::ManuallyDrop::new(control_handle),
604                                tx_id: header.tx_id,
605                            },
606                        })
607                    }
608                    _ if header.tx_id == 0
609                        && header
610                            .dynamic_flags()
611                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
612                    {
613                        Ok(InspectSinkRequest::_UnknownMethod {
614                            ordinal: header.ordinal,
615                            control_handle: InspectSinkControlHandle { inner: this.inner.clone() },
616                            method_type: fidl::MethodType::OneWay,
617                        })
618                    }
619                    _ if header
620                        .dynamic_flags()
621                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
622                    {
623                        this.inner.send_framework_err(
624                            fidl::encoding::FrameworkErr::UnknownMethod,
625                            header.tx_id,
626                            header.ordinal,
627                            header.dynamic_flags(),
628                            (bytes, handles),
629                        )?;
630                        Ok(InspectSinkRequest::_UnknownMethod {
631                            ordinal: header.ordinal,
632                            control_handle: InspectSinkControlHandle { inner: this.inner.clone() },
633                            method_type: fidl::MethodType::TwoWay,
634                        })
635                    }
636                    _ => Err(fidl::Error::UnknownOrdinal {
637                        ordinal: header.ordinal,
638                        protocol_name:
639                            <InspectSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
640                    }),
641                }))
642            },
643        )
644    }
645}
646
647#[derive(Debug)]
648pub enum InspectSinkRequest {
649    /// Publishes a handle to the `fuchsia.inspect.Tree` protocol that the
650    /// server can use to read Inspect data, including lazy nodes.
651    Publish { payload: InspectSinkPublishRequest, control_handle: InspectSinkControlHandle },
652    /// Instructs the server to store the VMO provided to make its data
653    /// available to Inspect readers, even when the component that published
654    /// this VMO isn't running.
655    ///
656    /// This is meant to be used when integrating with Component Framework's
657    /// Escrow APIs to enable stopping when IDLE but still ensure that some
658    /// useful diagnostics information is available.
659    ///
660    /// The client must provide a `token` that will be used as a unique
661    /// identifier to this VMO by the the server. This token is an event pair, a
662    /// client must provide one end of this event pair and hold to the other end
663    /// (or escrow the handle it using Component APIs). If the server sees a
664    /// PEER_CLOSED on the handle it received, it will drop the VMO associated
665    /// with this token.
666    ///
667    /// If any of the required arguments isn't passed the connection will be
668    /// closed.
669    ///
670    /// To learn more about stopping IDLE components, please refer to:
671    /// https://fuchsia.dev/fuchsia-src/development/components/stop_idle
672    Escrow { payload: InspectSinkEscrowRequest, control_handle: InspectSinkControlHandle },
673    /// Instructs the server to return (and stop tracking) the VMO associated
674    /// with the given token.
675    ///
676    /// This is meant to be used when a component restarts and wants to fetch
677    /// Inspect data that it escrowed.
678    ///
679    /// To learn more about stopping IDLE components, please refer to:
680    /// https://fuchsia.dev/fuchsia-src/development/components/stop_idle
681    FetchEscrow {
682        payload: InspectSinkFetchEscrowRequest,
683        responder: InspectSinkFetchEscrowResponder,
684    },
685    /// An interaction was received which does not match any known method.
686    #[non_exhaustive]
687    _UnknownMethod {
688        /// Ordinal of the method that was called.
689        ordinal: u64,
690        control_handle: InspectSinkControlHandle,
691        method_type: fidl::MethodType,
692    },
693}
694
695impl InspectSinkRequest {
696    #[allow(irrefutable_let_patterns)]
697    pub fn into_publish(self) -> Option<(InspectSinkPublishRequest, InspectSinkControlHandle)> {
698        if let InspectSinkRequest::Publish { payload, control_handle } = self {
699            Some((payload, control_handle))
700        } else {
701            None
702        }
703    }
704
705    #[allow(irrefutable_let_patterns)]
706    pub fn into_escrow(self) -> Option<(InspectSinkEscrowRequest, InspectSinkControlHandle)> {
707        if let InspectSinkRequest::Escrow { payload, control_handle } = self {
708            Some((payload, control_handle))
709        } else {
710            None
711        }
712    }
713
714    #[allow(irrefutable_let_patterns)]
715    pub fn into_fetch_escrow(
716        self,
717    ) -> Option<(InspectSinkFetchEscrowRequest, InspectSinkFetchEscrowResponder)> {
718        if let InspectSinkRequest::FetchEscrow { payload, responder } = self {
719            Some((payload, responder))
720        } else {
721            None
722        }
723    }
724
725    /// Name of the method defined in FIDL
726    pub fn method_name(&self) -> &'static str {
727        match *self {
728            InspectSinkRequest::Publish { .. } => "publish",
729            InspectSinkRequest::Escrow { .. } => "escrow",
730            InspectSinkRequest::FetchEscrow { .. } => "fetch_escrow",
731            InspectSinkRequest::_UnknownMethod {
732                method_type: fidl::MethodType::OneWay, ..
733            } => "unknown one-way method",
734            InspectSinkRequest::_UnknownMethod {
735                method_type: fidl::MethodType::TwoWay, ..
736            } => "unknown two-way method",
737        }
738    }
739}
740
741#[derive(Debug, Clone)]
742pub struct InspectSinkControlHandle {
743    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
744}
745
746impl fidl::endpoints::ControlHandle for InspectSinkControlHandle {
747    fn shutdown(&self) {
748        self.inner.shutdown()
749    }
750
751    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
752        self.inner.shutdown_with_epitaph(status)
753    }
754
755    fn is_closed(&self) -> bool {
756        self.inner.channel().is_closed()
757    }
758    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
759        self.inner.channel().on_closed()
760    }
761
762    #[cfg(target_os = "fuchsia")]
763    fn signal_peer(
764        &self,
765        clear_mask: zx::Signals,
766        set_mask: zx::Signals,
767    ) -> Result<(), zx_status::Status> {
768        use fidl::Peered;
769        self.inner.channel().signal_peer(clear_mask, set_mask)
770    }
771}
772
773impl InspectSinkControlHandle {}
774
775#[must_use = "FIDL methods require a response to be sent"]
776#[derive(Debug)]
777pub struct InspectSinkFetchEscrowResponder {
778    control_handle: std::mem::ManuallyDrop<InspectSinkControlHandle>,
779    tx_id: u32,
780}
781
782/// Set the the channel to be shutdown (see [`InspectSinkControlHandle::shutdown`])
783/// if the responder is dropped without sending a response, so that the client
784/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
785impl std::ops::Drop for InspectSinkFetchEscrowResponder {
786    fn drop(&mut self) {
787        self.control_handle.shutdown();
788        // Safety: drops once, never accessed again
789        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
790    }
791}
792
793impl fidl::endpoints::Responder for InspectSinkFetchEscrowResponder {
794    type ControlHandle = InspectSinkControlHandle;
795
796    fn control_handle(&self) -> &InspectSinkControlHandle {
797        &self.control_handle
798    }
799
800    fn drop_without_shutdown(mut self) {
801        // Safety: drops once, never accessed again due to mem::forget
802        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
803        // Prevent Drop from running (which would shut down the channel)
804        std::mem::forget(self);
805    }
806}
807
808impl InspectSinkFetchEscrowResponder {
809    /// Sends a response to the FIDL transaction.
810    ///
811    /// Sets the channel to shutdown if an error occurs.
812    pub fn send(self, mut payload: InspectSinkFetchEscrowResponse) -> Result<(), fidl::Error> {
813        let _result = self.send_raw(payload);
814        if _result.is_err() {
815            self.control_handle.shutdown();
816        }
817        self.drop_without_shutdown();
818        _result
819    }
820
821    /// Similar to "send" but does not shutdown the channel if an error occurs.
822    pub fn send_no_shutdown_on_err(
823        self,
824        mut payload: InspectSinkFetchEscrowResponse,
825    ) -> Result<(), fidl::Error> {
826        let _result = self.send_raw(payload);
827        self.drop_without_shutdown();
828        _result
829    }
830
831    fn send_raw(&self, mut payload: InspectSinkFetchEscrowResponse) -> Result<(), fidl::Error> {
832        self.control_handle
833            .inner
834            .send::<fidl::encoding::FlexibleType<InspectSinkFetchEscrowResponse>>(
835                fidl::encoding::Flexible::new(&mut payload),
836                self.tx_id,
837                0x7b9faa1a6f8e666a,
838                fidl::encoding::DynamicFlags::FLEXIBLE,
839            )
840    }
841}
842
843#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
844pub struct TreeMarker;
845
846impl fidl::endpoints::ProtocolMarker for TreeMarker {
847    type Proxy = TreeProxy;
848    type RequestStream = TreeRequestStream;
849    #[cfg(target_os = "fuchsia")]
850    type SynchronousProxy = TreeSynchronousProxy;
851
852    const DEBUG_NAME: &'static str = "fuchsia.inspect.Tree";
853}
854impl fidl::endpoints::DiscoverableProtocolMarker for TreeMarker {}
855
856pub trait TreeProxyInterface: Send + Sync {
857    type GetContentResponseFut: std::future::Future<Output = Result<TreeContent, fidl::Error>>
858        + Send;
859    fn r#get_content(&self) -> Self::GetContentResponseFut;
860    fn r#list_child_names(
861        &self,
862        tree_iterator: fidl::endpoints::ServerEnd<TreeNameIteratorMarker>,
863    ) -> Result<(), fidl::Error>;
864    fn r#open_child(
865        &self,
866        child_name: &str,
867        tree: fidl::endpoints::ServerEnd<TreeMarker>,
868    ) -> Result<(), fidl::Error>;
869}
870#[derive(Debug)]
871#[cfg(target_os = "fuchsia")]
872pub struct TreeSynchronousProxy {
873    client: fidl::client::sync::Client,
874}
875
876#[cfg(target_os = "fuchsia")]
877impl fidl::endpoints::SynchronousProxy for TreeSynchronousProxy {
878    type Proxy = TreeProxy;
879    type Protocol = TreeMarker;
880
881    fn from_channel(inner: fidl::Channel) -> Self {
882        Self::new(inner)
883    }
884
885    fn into_channel(self) -> fidl::Channel {
886        self.client.into_channel()
887    }
888
889    fn as_channel(&self) -> &fidl::Channel {
890        self.client.as_channel()
891    }
892}
893
894#[cfg(target_os = "fuchsia")]
895impl TreeSynchronousProxy {
896    pub fn new(channel: fidl::Channel) -> Self {
897        Self { client: fidl::client::sync::Client::new(channel) }
898    }
899
900    pub fn into_channel(self) -> fidl::Channel {
901        self.client.into_channel()
902    }
903
904    /// Waits until an event arrives and returns it. It is safe for other
905    /// threads to make concurrent requests while waiting for an event.
906    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<TreeEvent, fidl::Error> {
907        TreeEvent::decode(self.client.wait_for_event::<TreeMarker>(deadline)?)
908    }
909
910    /// Get the content for the Inspect VMO backing this tree.
911    ///
912    /// So long as the Tree connection is still maintained, the contents
913    /// of the tree are guaranteed to still be live. Once the connection is
914    /// lost, the serving component is free to clear the contents of returned
915    /// shared buffers.
916    ///
917    /// Serving components may return different buffers to GetContent
918    /// requests for the same Tree.
919    pub fn r#get_content(
920        &self,
921        ___deadline: zx::MonotonicInstant,
922    ) -> Result<TreeContent, fidl::Error> {
923        let _response = self
924            .client
925            .send_query::<fidl::encoding::EmptyPayload, TreeGetContentResponse, TreeMarker>(
926                (),
927                0x6ce0c1e42f903b47,
928                fidl::encoding::DynamicFlags::empty(),
929                ___deadline,
930            )?;
931        Ok(_response.content)
932    }
933
934    /// Iterate over the names of Trees that are children of this Tree.
935    ///
936    /// The underlying list of children may change in between calls to
937    /// ListChildNames and OpenChild.
938    pub fn r#list_child_names(
939        &self,
940        mut tree_iterator: fidl::endpoints::ServerEnd<TreeNameIteratorMarker>,
941    ) -> Result<(), fidl::Error> {
942        self.client.send::<TreeListChildNamesRequest>(
943            (tree_iterator,),
944            0x577c988a830784a3,
945            fidl::encoding::DynamicFlags::empty(),
946        )
947    }
948
949    /// Open a child Tree by name.
950    ///
951    /// If the child cannot be opened, the given request is closed.
952    pub fn r#open_child(
953        &self,
954        mut child_name: &str,
955        mut tree: fidl::endpoints::ServerEnd<TreeMarker>,
956    ) -> Result<(), fidl::Error> {
957        self.client.send::<TreeOpenChildRequest>(
958            (child_name, tree),
959            0x526e35326e80a1b3,
960            fidl::encoding::DynamicFlags::empty(),
961        )
962    }
963}
964
965#[cfg(target_os = "fuchsia")]
966impl From<TreeSynchronousProxy> for zx::NullableHandle {
967    fn from(value: TreeSynchronousProxy) -> Self {
968        value.into_channel().into()
969    }
970}
971
972#[cfg(target_os = "fuchsia")]
973impl From<fidl::Channel> for TreeSynchronousProxy {
974    fn from(value: fidl::Channel) -> Self {
975        Self::new(value)
976    }
977}
978
979#[cfg(target_os = "fuchsia")]
980impl fidl::endpoints::FromClient for TreeSynchronousProxy {
981    type Protocol = TreeMarker;
982
983    fn from_client(value: fidl::endpoints::ClientEnd<TreeMarker>) -> Self {
984        Self::new(value.into_channel())
985    }
986}
987
988#[derive(Debug, Clone)]
989pub struct TreeProxy {
990    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
991}
992
993impl fidl::endpoints::Proxy for TreeProxy {
994    type Protocol = TreeMarker;
995
996    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
997        Self::new(inner)
998    }
999
1000    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1001        self.client.into_channel().map_err(|client| Self { client })
1002    }
1003
1004    fn as_channel(&self) -> &::fidl::AsyncChannel {
1005        self.client.as_channel()
1006    }
1007}
1008
1009impl TreeProxy {
1010    /// Create a new Proxy for fuchsia.inspect/Tree.
1011    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1012        let protocol_name = <TreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1013        Self { client: fidl::client::Client::new(channel, protocol_name) }
1014    }
1015
1016    /// Get a Stream of events from the remote end of the protocol.
1017    ///
1018    /// # Panics
1019    ///
1020    /// Panics if the event stream was already taken.
1021    pub fn take_event_stream(&self) -> TreeEventStream {
1022        TreeEventStream { event_receiver: self.client.take_event_receiver() }
1023    }
1024
1025    /// Get the content for the Inspect VMO backing this tree.
1026    ///
1027    /// So long as the Tree connection is still maintained, the contents
1028    /// of the tree are guaranteed to still be live. Once the connection is
1029    /// lost, the serving component is free to clear the contents of returned
1030    /// shared buffers.
1031    ///
1032    /// Serving components may return different buffers to GetContent
1033    /// requests for the same Tree.
1034    pub fn r#get_content(
1035        &self,
1036    ) -> fidl::client::QueryResponseFut<TreeContent, fidl::encoding::DefaultFuchsiaResourceDialect>
1037    {
1038        TreeProxyInterface::r#get_content(self)
1039    }
1040
1041    /// Iterate over the names of Trees that are children of this Tree.
1042    ///
1043    /// The underlying list of children may change in between calls to
1044    /// ListChildNames and OpenChild.
1045    pub fn r#list_child_names(
1046        &self,
1047        mut tree_iterator: fidl::endpoints::ServerEnd<TreeNameIteratorMarker>,
1048    ) -> Result<(), fidl::Error> {
1049        TreeProxyInterface::r#list_child_names(self, tree_iterator)
1050    }
1051
1052    /// Open a child Tree by name.
1053    ///
1054    /// If the child cannot be opened, the given request is closed.
1055    pub fn r#open_child(
1056        &self,
1057        mut child_name: &str,
1058        mut tree: fidl::endpoints::ServerEnd<TreeMarker>,
1059    ) -> Result<(), fidl::Error> {
1060        TreeProxyInterface::r#open_child(self, child_name, tree)
1061    }
1062}
1063
1064impl TreeProxyInterface for TreeProxy {
1065    type GetContentResponseFut =
1066        fidl::client::QueryResponseFut<TreeContent, fidl::encoding::DefaultFuchsiaResourceDialect>;
1067    fn r#get_content(&self) -> Self::GetContentResponseFut {
1068        fn _decode(
1069            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1070        ) -> Result<TreeContent, fidl::Error> {
1071            let _response = fidl::client::decode_transaction_body::<
1072                TreeGetContentResponse,
1073                fidl::encoding::DefaultFuchsiaResourceDialect,
1074                0x6ce0c1e42f903b47,
1075            >(_buf?)?;
1076            Ok(_response.content)
1077        }
1078        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, TreeContent>(
1079            (),
1080            0x6ce0c1e42f903b47,
1081            fidl::encoding::DynamicFlags::empty(),
1082            _decode,
1083        )
1084    }
1085
1086    fn r#list_child_names(
1087        &self,
1088        mut tree_iterator: fidl::endpoints::ServerEnd<TreeNameIteratorMarker>,
1089    ) -> Result<(), fidl::Error> {
1090        self.client.send::<TreeListChildNamesRequest>(
1091            (tree_iterator,),
1092            0x577c988a830784a3,
1093            fidl::encoding::DynamicFlags::empty(),
1094        )
1095    }
1096
1097    fn r#open_child(
1098        &self,
1099        mut child_name: &str,
1100        mut tree: fidl::endpoints::ServerEnd<TreeMarker>,
1101    ) -> Result<(), fidl::Error> {
1102        self.client.send::<TreeOpenChildRequest>(
1103            (child_name, tree),
1104            0x526e35326e80a1b3,
1105            fidl::encoding::DynamicFlags::empty(),
1106        )
1107    }
1108}
1109
1110pub struct TreeEventStream {
1111    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1112}
1113
1114impl std::marker::Unpin for TreeEventStream {}
1115
1116impl futures::stream::FusedStream for TreeEventStream {
1117    fn is_terminated(&self) -> bool {
1118        self.event_receiver.is_terminated()
1119    }
1120}
1121
1122impl futures::Stream for TreeEventStream {
1123    type Item = Result<TreeEvent, fidl::Error>;
1124
1125    fn poll_next(
1126        mut self: std::pin::Pin<&mut Self>,
1127        cx: &mut std::task::Context<'_>,
1128    ) -> std::task::Poll<Option<Self::Item>> {
1129        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1130            &mut self.event_receiver,
1131            cx
1132        )?) {
1133            Some(buf) => std::task::Poll::Ready(Some(TreeEvent::decode(buf))),
1134            None => std::task::Poll::Ready(None),
1135        }
1136    }
1137}
1138
1139#[derive(Debug)]
1140pub enum TreeEvent {
1141    #[non_exhaustive]
1142    _UnknownEvent {
1143        /// Ordinal of the event that was sent.
1144        ordinal: u64,
1145    },
1146}
1147
1148impl TreeEvent {
1149    /// Decodes a message buffer as a [`TreeEvent`].
1150    fn decode(
1151        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1152    ) -> Result<TreeEvent, fidl::Error> {
1153        let (bytes, _handles) = buf.split_mut();
1154        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1155        debug_assert_eq!(tx_header.tx_id, 0);
1156        match tx_header.ordinal {
1157            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1158                Ok(TreeEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1159            }
1160            _ => Err(fidl::Error::UnknownOrdinal {
1161                ordinal: tx_header.ordinal,
1162                protocol_name: <TreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1163            }),
1164        }
1165    }
1166}
1167
1168/// A Stream of incoming requests for fuchsia.inspect/Tree.
1169pub struct TreeRequestStream {
1170    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1171    is_terminated: bool,
1172}
1173
1174impl std::marker::Unpin for TreeRequestStream {}
1175
1176impl futures::stream::FusedStream for TreeRequestStream {
1177    fn is_terminated(&self) -> bool {
1178        self.is_terminated
1179    }
1180}
1181
1182impl fidl::endpoints::RequestStream for TreeRequestStream {
1183    type Protocol = TreeMarker;
1184    type ControlHandle = TreeControlHandle;
1185
1186    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1187        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1188    }
1189
1190    fn control_handle(&self) -> Self::ControlHandle {
1191        TreeControlHandle { inner: self.inner.clone() }
1192    }
1193
1194    fn into_inner(
1195        self,
1196    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1197    {
1198        (self.inner, self.is_terminated)
1199    }
1200
1201    fn from_inner(
1202        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1203        is_terminated: bool,
1204    ) -> Self {
1205        Self { inner, is_terminated }
1206    }
1207}
1208
1209impl futures::Stream for TreeRequestStream {
1210    type Item = Result<TreeRequest, fidl::Error>;
1211
1212    fn poll_next(
1213        mut self: std::pin::Pin<&mut Self>,
1214        cx: &mut std::task::Context<'_>,
1215    ) -> std::task::Poll<Option<Self::Item>> {
1216        let this = &mut *self;
1217        if this.inner.check_shutdown(cx) {
1218            this.is_terminated = true;
1219            return std::task::Poll::Ready(None);
1220        }
1221        if this.is_terminated {
1222            panic!("polled TreeRequestStream after completion");
1223        }
1224        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1225            |bytes, handles| {
1226                match this.inner.channel().read_etc(cx, bytes, handles) {
1227                    std::task::Poll::Ready(Ok(())) => {}
1228                    std::task::Poll::Pending => return std::task::Poll::Pending,
1229                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1230                        this.is_terminated = true;
1231                        return std::task::Poll::Ready(None);
1232                    }
1233                    std::task::Poll::Ready(Err(e)) => {
1234                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1235                            e.into(),
1236                        ))));
1237                    }
1238                }
1239
1240                // A message has been received from the channel
1241                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1242
1243                std::task::Poll::Ready(Some(match header.ordinal {
1244                    0x6ce0c1e42f903b47 => {
1245                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1246                        let mut req = fidl::new_empty!(
1247                            fidl::encoding::EmptyPayload,
1248                            fidl::encoding::DefaultFuchsiaResourceDialect
1249                        );
1250                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1251                        let control_handle = TreeControlHandle { inner: this.inner.clone() };
1252                        Ok(TreeRequest::GetContent {
1253                            responder: TreeGetContentResponder {
1254                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1255                                tx_id: header.tx_id,
1256                            },
1257                        })
1258                    }
1259                    0x577c988a830784a3 => {
1260                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1261                        let mut req = fidl::new_empty!(
1262                            TreeListChildNamesRequest,
1263                            fidl::encoding::DefaultFuchsiaResourceDialect
1264                        );
1265                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TreeListChildNamesRequest>(&header, _body_bytes, handles, &mut req)?;
1266                        let control_handle = TreeControlHandle { inner: this.inner.clone() };
1267                        Ok(TreeRequest::ListChildNames {
1268                            tree_iterator: req.tree_iterator,
1269
1270                            control_handle,
1271                        })
1272                    }
1273                    0x526e35326e80a1b3 => {
1274                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1275                        let mut req = fidl::new_empty!(
1276                            TreeOpenChildRequest,
1277                            fidl::encoding::DefaultFuchsiaResourceDialect
1278                        );
1279                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TreeOpenChildRequest>(&header, _body_bytes, handles, &mut req)?;
1280                        let control_handle = TreeControlHandle { inner: this.inner.clone() };
1281                        Ok(TreeRequest::OpenChild {
1282                            child_name: req.child_name,
1283                            tree: req.tree,
1284
1285                            control_handle,
1286                        })
1287                    }
1288                    _ if header.tx_id == 0
1289                        && header
1290                            .dynamic_flags()
1291                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1292                    {
1293                        Ok(TreeRequest::_UnknownMethod {
1294                            ordinal: header.ordinal,
1295                            control_handle: TreeControlHandle { inner: this.inner.clone() },
1296                            method_type: fidl::MethodType::OneWay,
1297                        })
1298                    }
1299                    _ if header
1300                        .dynamic_flags()
1301                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1302                    {
1303                        this.inner.send_framework_err(
1304                            fidl::encoding::FrameworkErr::UnknownMethod,
1305                            header.tx_id,
1306                            header.ordinal,
1307                            header.dynamic_flags(),
1308                            (bytes, handles),
1309                        )?;
1310                        Ok(TreeRequest::_UnknownMethod {
1311                            ordinal: header.ordinal,
1312                            control_handle: TreeControlHandle { inner: this.inner.clone() },
1313                            method_type: fidl::MethodType::TwoWay,
1314                        })
1315                    }
1316                    _ => Err(fidl::Error::UnknownOrdinal {
1317                        ordinal: header.ordinal,
1318                        protocol_name: <TreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1319                    }),
1320                }))
1321            },
1322        )
1323    }
1324}
1325
1326/// The Tree protocol represents a hierarchy of Inspect VMOs.
1327///
1328/// Link values stored in an Inspect file contain references to new
1329/// named files that contain a continuation of the data for the overall
1330/// hierarchy. Protocol Tree allows clients to request these named files so
1331/// long as the hosting component is still alive.
1332///
1333/// Connecting to a particular tree keeps the content for that Tree resident
1334/// in memory. Clients are recommended to traverse the trees in depth-first
1335/// order to reduce memory usage. Serving components are free to deny
1336/// connections to avoid unbounded memory usage.
1337#[derive(Debug)]
1338pub enum TreeRequest {
1339    /// Get the content for the Inspect VMO backing this tree.
1340    ///
1341    /// So long as the Tree connection is still maintained, the contents
1342    /// of the tree are guaranteed to still be live. Once the connection is
1343    /// lost, the serving component is free to clear the contents of returned
1344    /// shared buffers.
1345    ///
1346    /// Serving components may return different buffers to GetContent
1347    /// requests for the same Tree.
1348    GetContent { responder: TreeGetContentResponder },
1349    /// Iterate over the names of Trees that are children of this Tree.
1350    ///
1351    /// The underlying list of children may change in between calls to
1352    /// ListChildNames and OpenChild.
1353    ListChildNames {
1354        tree_iterator: fidl::endpoints::ServerEnd<TreeNameIteratorMarker>,
1355        control_handle: TreeControlHandle,
1356    },
1357    /// Open a child Tree by name.
1358    ///
1359    /// If the child cannot be opened, the given request is closed.
1360    OpenChild {
1361        child_name: String,
1362        tree: fidl::endpoints::ServerEnd<TreeMarker>,
1363        control_handle: TreeControlHandle,
1364    },
1365    /// An interaction was received which does not match any known method.
1366    #[non_exhaustive]
1367    _UnknownMethod {
1368        /// Ordinal of the method that was called.
1369        ordinal: u64,
1370        control_handle: TreeControlHandle,
1371        method_type: fidl::MethodType,
1372    },
1373}
1374
1375impl TreeRequest {
1376    #[allow(irrefutable_let_patterns)]
1377    pub fn into_get_content(self) -> Option<(TreeGetContentResponder)> {
1378        if let TreeRequest::GetContent { responder } = self { Some((responder)) } else { None }
1379    }
1380
1381    #[allow(irrefutable_let_patterns)]
1382    pub fn into_list_child_names(
1383        self,
1384    ) -> Option<(fidl::endpoints::ServerEnd<TreeNameIteratorMarker>, TreeControlHandle)> {
1385        if let TreeRequest::ListChildNames { tree_iterator, control_handle } = self {
1386            Some((tree_iterator, control_handle))
1387        } else {
1388            None
1389        }
1390    }
1391
1392    #[allow(irrefutable_let_patterns)]
1393    pub fn into_open_child(
1394        self,
1395    ) -> Option<(String, fidl::endpoints::ServerEnd<TreeMarker>, TreeControlHandle)> {
1396        if let TreeRequest::OpenChild { child_name, tree, control_handle } = self {
1397            Some((child_name, tree, control_handle))
1398        } else {
1399            None
1400        }
1401    }
1402
1403    /// Name of the method defined in FIDL
1404    pub fn method_name(&self) -> &'static str {
1405        match *self {
1406            TreeRequest::GetContent { .. } => "get_content",
1407            TreeRequest::ListChildNames { .. } => "list_child_names",
1408            TreeRequest::OpenChild { .. } => "open_child",
1409            TreeRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1410                "unknown one-way method"
1411            }
1412            TreeRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1413                "unknown two-way method"
1414            }
1415        }
1416    }
1417}
1418
1419#[derive(Debug, Clone)]
1420pub struct TreeControlHandle {
1421    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1422}
1423
1424impl fidl::endpoints::ControlHandle for TreeControlHandle {
1425    fn shutdown(&self) {
1426        self.inner.shutdown()
1427    }
1428
1429    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1430        self.inner.shutdown_with_epitaph(status)
1431    }
1432
1433    fn is_closed(&self) -> bool {
1434        self.inner.channel().is_closed()
1435    }
1436    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1437        self.inner.channel().on_closed()
1438    }
1439
1440    #[cfg(target_os = "fuchsia")]
1441    fn signal_peer(
1442        &self,
1443        clear_mask: zx::Signals,
1444        set_mask: zx::Signals,
1445    ) -> Result<(), zx_status::Status> {
1446        use fidl::Peered;
1447        self.inner.channel().signal_peer(clear_mask, set_mask)
1448    }
1449}
1450
1451impl TreeControlHandle {}
1452
1453#[must_use = "FIDL methods require a response to be sent"]
1454#[derive(Debug)]
1455pub struct TreeGetContentResponder {
1456    control_handle: std::mem::ManuallyDrop<TreeControlHandle>,
1457    tx_id: u32,
1458}
1459
1460/// Set the the channel to be shutdown (see [`TreeControlHandle::shutdown`])
1461/// if the responder is dropped without sending a response, so that the client
1462/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1463impl std::ops::Drop for TreeGetContentResponder {
1464    fn drop(&mut self) {
1465        self.control_handle.shutdown();
1466        // Safety: drops once, never accessed again
1467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1468    }
1469}
1470
1471impl fidl::endpoints::Responder for TreeGetContentResponder {
1472    type ControlHandle = TreeControlHandle;
1473
1474    fn control_handle(&self) -> &TreeControlHandle {
1475        &self.control_handle
1476    }
1477
1478    fn drop_without_shutdown(mut self) {
1479        // Safety: drops once, never accessed again due to mem::forget
1480        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1481        // Prevent Drop from running (which would shut down the channel)
1482        std::mem::forget(self);
1483    }
1484}
1485
1486impl TreeGetContentResponder {
1487    /// Sends a response to the FIDL transaction.
1488    ///
1489    /// Sets the channel to shutdown if an error occurs.
1490    pub fn send(self, mut content: TreeContent) -> Result<(), fidl::Error> {
1491        let _result = self.send_raw(content);
1492        if _result.is_err() {
1493            self.control_handle.shutdown();
1494        }
1495        self.drop_without_shutdown();
1496        _result
1497    }
1498
1499    /// Similar to "send" but does not shutdown the channel if an error occurs.
1500    pub fn send_no_shutdown_on_err(self, mut content: TreeContent) -> Result<(), fidl::Error> {
1501        let _result = self.send_raw(content);
1502        self.drop_without_shutdown();
1503        _result
1504    }
1505
1506    fn send_raw(&self, mut content: TreeContent) -> Result<(), fidl::Error> {
1507        self.control_handle.inner.send::<TreeGetContentResponse>(
1508            (&mut content,),
1509            self.tx_id,
1510            0x6ce0c1e42f903b47,
1511            fidl::encoding::DynamicFlags::empty(),
1512        )
1513    }
1514}
1515
1516#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1517pub struct TreeNameIteratorMarker;
1518
1519impl fidl::endpoints::ProtocolMarker for TreeNameIteratorMarker {
1520    type Proxy = TreeNameIteratorProxy;
1521    type RequestStream = TreeNameIteratorRequestStream;
1522    #[cfg(target_os = "fuchsia")]
1523    type SynchronousProxy = TreeNameIteratorSynchronousProxy;
1524
1525    const DEBUG_NAME: &'static str = "(anonymous) TreeNameIterator";
1526}
1527
1528pub trait TreeNameIteratorProxyInterface: Send + Sync {
1529    type GetNextResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>> + Send;
1530    fn r#get_next(&self) -> Self::GetNextResponseFut;
1531}
1532#[derive(Debug)]
1533#[cfg(target_os = "fuchsia")]
1534pub struct TreeNameIteratorSynchronousProxy {
1535    client: fidl::client::sync::Client,
1536}
1537
1538#[cfg(target_os = "fuchsia")]
1539impl fidl::endpoints::SynchronousProxy for TreeNameIteratorSynchronousProxy {
1540    type Proxy = TreeNameIteratorProxy;
1541    type Protocol = TreeNameIteratorMarker;
1542
1543    fn from_channel(inner: fidl::Channel) -> Self {
1544        Self::new(inner)
1545    }
1546
1547    fn into_channel(self) -> fidl::Channel {
1548        self.client.into_channel()
1549    }
1550
1551    fn as_channel(&self) -> &fidl::Channel {
1552        self.client.as_channel()
1553    }
1554}
1555
1556#[cfg(target_os = "fuchsia")]
1557impl TreeNameIteratorSynchronousProxy {
1558    pub fn new(channel: fidl::Channel) -> Self {
1559        Self { client: fidl::client::sync::Client::new(channel) }
1560    }
1561
1562    pub fn into_channel(self) -> fidl::Channel {
1563        self.client.into_channel()
1564    }
1565
1566    /// Waits until an event arrives and returns it. It is safe for other
1567    /// threads to make concurrent requests while waiting for an event.
1568    pub fn wait_for_event(
1569        &self,
1570        deadline: zx::MonotonicInstant,
1571    ) -> Result<TreeNameIteratorEvent, fidl::Error> {
1572        TreeNameIteratorEvent::decode(
1573            self.client.wait_for_event::<TreeNameIteratorMarker>(deadline)?,
1574        )
1575    }
1576
1577    /// Get the next batch of names.
1578    ///
1579    /// Returns an empty vector and closes the channel when no more names are present.
1580    /// Implementors may eagerly close the channel after sending the last batch.
1581    pub fn r#get_next(
1582        &self,
1583        ___deadline: zx::MonotonicInstant,
1584    ) -> Result<Vec<String>, fidl::Error> {
1585        let _response = self.client.send_query::<
1586            fidl::encoding::EmptyPayload,
1587            TreeNameIteratorGetNextResponse,
1588            TreeNameIteratorMarker,
1589        >(
1590            (),
1591            0x6a7d7af5a325c8ac,
1592            fidl::encoding::DynamicFlags::empty(),
1593            ___deadline,
1594        )?;
1595        Ok(_response.name)
1596    }
1597}
1598
1599#[cfg(target_os = "fuchsia")]
1600impl From<TreeNameIteratorSynchronousProxy> for zx::NullableHandle {
1601    fn from(value: TreeNameIteratorSynchronousProxy) -> Self {
1602        value.into_channel().into()
1603    }
1604}
1605
1606#[cfg(target_os = "fuchsia")]
1607impl From<fidl::Channel> for TreeNameIteratorSynchronousProxy {
1608    fn from(value: fidl::Channel) -> Self {
1609        Self::new(value)
1610    }
1611}
1612
1613#[cfg(target_os = "fuchsia")]
1614impl fidl::endpoints::FromClient for TreeNameIteratorSynchronousProxy {
1615    type Protocol = TreeNameIteratorMarker;
1616
1617    fn from_client(value: fidl::endpoints::ClientEnd<TreeNameIteratorMarker>) -> Self {
1618        Self::new(value.into_channel())
1619    }
1620}
1621
1622#[derive(Debug, Clone)]
1623pub struct TreeNameIteratorProxy {
1624    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1625}
1626
1627impl fidl::endpoints::Proxy for TreeNameIteratorProxy {
1628    type Protocol = TreeNameIteratorMarker;
1629
1630    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1631        Self::new(inner)
1632    }
1633
1634    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1635        self.client.into_channel().map_err(|client| Self { client })
1636    }
1637
1638    fn as_channel(&self) -> &::fidl::AsyncChannel {
1639        self.client.as_channel()
1640    }
1641}
1642
1643impl TreeNameIteratorProxy {
1644    /// Create a new Proxy for fuchsia.inspect/TreeNameIterator.
1645    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1646        let protocol_name = <TreeNameIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1647        Self { client: fidl::client::Client::new(channel, protocol_name) }
1648    }
1649
1650    /// Get a Stream of events from the remote end of the protocol.
1651    ///
1652    /// # Panics
1653    ///
1654    /// Panics if the event stream was already taken.
1655    pub fn take_event_stream(&self) -> TreeNameIteratorEventStream {
1656        TreeNameIteratorEventStream { event_receiver: self.client.take_event_receiver() }
1657    }
1658
1659    /// Get the next batch of names.
1660    ///
1661    /// Returns an empty vector and closes the channel when no more names are present.
1662    /// Implementors may eagerly close the channel after sending the last batch.
1663    pub fn r#get_next(
1664        &self,
1665    ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
1666    {
1667        TreeNameIteratorProxyInterface::r#get_next(self)
1668    }
1669}
1670
1671impl TreeNameIteratorProxyInterface for TreeNameIteratorProxy {
1672    type GetNextResponseFut =
1673        fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
1674    fn r#get_next(&self) -> Self::GetNextResponseFut {
1675        fn _decode(
1676            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1677        ) -> Result<Vec<String>, fidl::Error> {
1678            let _response = fidl::client::decode_transaction_body::<
1679                TreeNameIteratorGetNextResponse,
1680                fidl::encoding::DefaultFuchsiaResourceDialect,
1681                0x6a7d7af5a325c8ac,
1682            >(_buf?)?;
1683            Ok(_response.name)
1684        }
1685        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
1686            (),
1687            0x6a7d7af5a325c8ac,
1688            fidl::encoding::DynamicFlags::empty(),
1689            _decode,
1690        )
1691    }
1692}
1693
1694pub struct TreeNameIteratorEventStream {
1695    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1696}
1697
1698impl std::marker::Unpin for TreeNameIteratorEventStream {}
1699
1700impl futures::stream::FusedStream for TreeNameIteratorEventStream {
1701    fn is_terminated(&self) -> bool {
1702        self.event_receiver.is_terminated()
1703    }
1704}
1705
1706impl futures::Stream for TreeNameIteratorEventStream {
1707    type Item = Result<TreeNameIteratorEvent, fidl::Error>;
1708
1709    fn poll_next(
1710        mut self: std::pin::Pin<&mut Self>,
1711        cx: &mut std::task::Context<'_>,
1712    ) -> std::task::Poll<Option<Self::Item>> {
1713        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1714            &mut self.event_receiver,
1715            cx
1716        )?) {
1717            Some(buf) => std::task::Poll::Ready(Some(TreeNameIteratorEvent::decode(buf))),
1718            None => std::task::Poll::Ready(None),
1719        }
1720    }
1721}
1722
1723#[derive(Debug)]
1724pub enum TreeNameIteratorEvent {
1725    #[non_exhaustive]
1726    _UnknownEvent {
1727        /// Ordinal of the event that was sent.
1728        ordinal: u64,
1729    },
1730}
1731
1732impl TreeNameIteratorEvent {
1733    /// Decodes a message buffer as a [`TreeNameIteratorEvent`].
1734    fn decode(
1735        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1736    ) -> Result<TreeNameIteratorEvent, fidl::Error> {
1737        let (bytes, _handles) = buf.split_mut();
1738        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1739        debug_assert_eq!(tx_header.tx_id, 0);
1740        match tx_header.ordinal {
1741            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1742                Ok(TreeNameIteratorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1743            }
1744            _ => Err(fidl::Error::UnknownOrdinal {
1745                ordinal: tx_header.ordinal,
1746                protocol_name:
1747                    <TreeNameIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1748            }),
1749        }
1750    }
1751}
1752
1753/// A Stream of incoming requests for fuchsia.inspect/TreeNameIterator.
1754pub struct TreeNameIteratorRequestStream {
1755    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1756    is_terminated: bool,
1757}
1758
1759impl std::marker::Unpin for TreeNameIteratorRequestStream {}
1760
1761impl futures::stream::FusedStream for TreeNameIteratorRequestStream {
1762    fn is_terminated(&self) -> bool {
1763        self.is_terminated
1764    }
1765}
1766
1767impl fidl::endpoints::RequestStream for TreeNameIteratorRequestStream {
1768    type Protocol = TreeNameIteratorMarker;
1769    type ControlHandle = TreeNameIteratorControlHandle;
1770
1771    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1772        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1773    }
1774
1775    fn control_handle(&self) -> Self::ControlHandle {
1776        TreeNameIteratorControlHandle { inner: self.inner.clone() }
1777    }
1778
1779    fn into_inner(
1780        self,
1781    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1782    {
1783        (self.inner, self.is_terminated)
1784    }
1785
1786    fn from_inner(
1787        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1788        is_terminated: bool,
1789    ) -> Self {
1790        Self { inner, is_terminated }
1791    }
1792}
1793
1794impl futures::Stream for TreeNameIteratorRequestStream {
1795    type Item = Result<TreeNameIteratorRequest, fidl::Error>;
1796
1797    fn poll_next(
1798        mut self: std::pin::Pin<&mut Self>,
1799        cx: &mut std::task::Context<'_>,
1800    ) -> std::task::Poll<Option<Self::Item>> {
1801        let this = &mut *self;
1802        if this.inner.check_shutdown(cx) {
1803            this.is_terminated = true;
1804            return std::task::Poll::Ready(None);
1805        }
1806        if this.is_terminated {
1807            panic!("polled TreeNameIteratorRequestStream after completion");
1808        }
1809        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1810            |bytes, handles| {
1811                match this.inner.channel().read_etc(cx, bytes, handles) {
1812                    std::task::Poll::Ready(Ok(())) => {}
1813                    std::task::Poll::Pending => return std::task::Poll::Pending,
1814                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1815                        this.is_terminated = true;
1816                        return std::task::Poll::Ready(None);
1817                    }
1818                    std::task::Poll::Ready(Err(e)) => {
1819                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1820                            e.into(),
1821                        ))));
1822                    }
1823                }
1824
1825                // A message has been received from the channel
1826                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1827
1828                std::task::Poll::Ready(Some(match header.ordinal {
1829                    0x6a7d7af5a325c8ac => {
1830                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1831                        let mut req = fidl::new_empty!(
1832                            fidl::encoding::EmptyPayload,
1833                            fidl::encoding::DefaultFuchsiaResourceDialect
1834                        );
1835                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1836                        let control_handle =
1837                            TreeNameIteratorControlHandle { inner: this.inner.clone() };
1838                        Ok(TreeNameIteratorRequest::GetNext {
1839                            responder: TreeNameIteratorGetNextResponder {
1840                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1841                                tx_id: header.tx_id,
1842                            },
1843                        })
1844                    }
1845                    _ if header.tx_id == 0
1846                        && header
1847                            .dynamic_flags()
1848                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1849                    {
1850                        Ok(TreeNameIteratorRequest::_UnknownMethod {
1851                            ordinal: header.ordinal,
1852                            control_handle: TreeNameIteratorControlHandle {
1853                                inner: this.inner.clone(),
1854                            },
1855                            method_type: fidl::MethodType::OneWay,
1856                        })
1857                    }
1858                    _ if header
1859                        .dynamic_flags()
1860                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1861                    {
1862                        this.inner.send_framework_err(
1863                            fidl::encoding::FrameworkErr::UnknownMethod,
1864                            header.tx_id,
1865                            header.ordinal,
1866                            header.dynamic_flags(),
1867                            (bytes, handles),
1868                        )?;
1869                        Ok(TreeNameIteratorRequest::_UnknownMethod {
1870                            ordinal: header.ordinal,
1871                            control_handle: TreeNameIteratorControlHandle {
1872                                inner: this.inner.clone(),
1873                            },
1874                            method_type: fidl::MethodType::TwoWay,
1875                        })
1876                    }
1877                    _ => Err(fidl::Error::UnknownOrdinal {
1878                        ordinal: header.ordinal,
1879                        protocol_name:
1880                            <TreeNameIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1881                    }),
1882                }))
1883            },
1884        )
1885    }
1886}
1887
1888/// Iterator protocol for listing the names of children of a particular Tree.
1889#[derive(Debug)]
1890pub enum TreeNameIteratorRequest {
1891    /// Get the next batch of names.
1892    ///
1893    /// Returns an empty vector and closes the channel when no more names are present.
1894    /// Implementors may eagerly close the channel after sending the last batch.
1895    GetNext { responder: TreeNameIteratorGetNextResponder },
1896    /// An interaction was received which does not match any known method.
1897    #[non_exhaustive]
1898    _UnknownMethod {
1899        /// Ordinal of the method that was called.
1900        ordinal: u64,
1901        control_handle: TreeNameIteratorControlHandle,
1902        method_type: fidl::MethodType,
1903    },
1904}
1905
1906impl TreeNameIteratorRequest {
1907    #[allow(irrefutable_let_patterns)]
1908    pub fn into_get_next(self) -> Option<(TreeNameIteratorGetNextResponder)> {
1909        if let TreeNameIteratorRequest::GetNext { responder } = self {
1910            Some((responder))
1911        } else {
1912            None
1913        }
1914    }
1915
1916    /// Name of the method defined in FIDL
1917    pub fn method_name(&self) -> &'static str {
1918        match *self {
1919            TreeNameIteratorRequest::GetNext { .. } => "get_next",
1920            TreeNameIteratorRequest::_UnknownMethod {
1921                method_type: fidl::MethodType::OneWay,
1922                ..
1923            } => "unknown one-way method",
1924            TreeNameIteratorRequest::_UnknownMethod {
1925                method_type: fidl::MethodType::TwoWay,
1926                ..
1927            } => "unknown two-way method",
1928        }
1929    }
1930}
1931
1932#[derive(Debug, Clone)]
1933pub struct TreeNameIteratorControlHandle {
1934    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1935}
1936
1937impl fidl::endpoints::ControlHandle for TreeNameIteratorControlHandle {
1938    fn shutdown(&self) {
1939        self.inner.shutdown()
1940    }
1941
1942    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1943        self.inner.shutdown_with_epitaph(status)
1944    }
1945
1946    fn is_closed(&self) -> bool {
1947        self.inner.channel().is_closed()
1948    }
1949    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1950        self.inner.channel().on_closed()
1951    }
1952
1953    #[cfg(target_os = "fuchsia")]
1954    fn signal_peer(
1955        &self,
1956        clear_mask: zx::Signals,
1957        set_mask: zx::Signals,
1958    ) -> Result<(), zx_status::Status> {
1959        use fidl::Peered;
1960        self.inner.channel().signal_peer(clear_mask, set_mask)
1961    }
1962}
1963
1964impl TreeNameIteratorControlHandle {}
1965
1966#[must_use = "FIDL methods require a response to be sent"]
1967#[derive(Debug)]
1968pub struct TreeNameIteratorGetNextResponder {
1969    control_handle: std::mem::ManuallyDrop<TreeNameIteratorControlHandle>,
1970    tx_id: u32,
1971}
1972
1973/// Set the the channel to be shutdown (see [`TreeNameIteratorControlHandle::shutdown`])
1974/// if the responder is dropped without sending a response, so that the client
1975/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1976impl std::ops::Drop for TreeNameIteratorGetNextResponder {
1977    fn drop(&mut self) {
1978        self.control_handle.shutdown();
1979        // Safety: drops once, never accessed again
1980        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1981    }
1982}
1983
1984impl fidl::endpoints::Responder for TreeNameIteratorGetNextResponder {
1985    type ControlHandle = TreeNameIteratorControlHandle;
1986
1987    fn control_handle(&self) -> &TreeNameIteratorControlHandle {
1988        &self.control_handle
1989    }
1990
1991    fn drop_without_shutdown(mut self) {
1992        // Safety: drops once, never accessed again due to mem::forget
1993        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1994        // Prevent Drop from running (which would shut down the channel)
1995        std::mem::forget(self);
1996    }
1997}
1998
1999impl TreeNameIteratorGetNextResponder {
2000    /// Sends a response to the FIDL transaction.
2001    ///
2002    /// Sets the channel to shutdown if an error occurs.
2003    pub fn send(self, mut name: &[String]) -> Result<(), fidl::Error> {
2004        let _result = self.send_raw(name);
2005        if _result.is_err() {
2006            self.control_handle.shutdown();
2007        }
2008        self.drop_without_shutdown();
2009        _result
2010    }
2011
2012    /// Similar to "send" but does not shutdown the channel if an error occurs.
2013    pub fn send_no_shutdown_on_err(self, mut name: &[String]) -> Result<(), fidl::Error> {
2014        let _result = self.send_raw(name);
2015        self.drop_without_shutdown();
2016        _result
2017    }
2018
2019    fn send_raw(&self, mut name: &[String]) -> Result<(), fidl::Error> {
2020        self.control_handle.inner.send::<TreeNameIteratorGetNextResponse>(
2021            (name,),
2022            self.tx_id,
2023            0x6a7d7af5a325c8ac,
2024            fidl::encoding::DynamicFlags::empty(),
2025        )
2026    }
2027}
2028
2029mod internal {
2030    use super::*;
2031
2032    impl fidl::encoding::ResourceTypeMarker for EscrowToken {
2033        type Borrowed<'a> = &'a mut Self;
2034        fn take_or_borrow<'a>(
2035            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2036        ) -> Self::Borrowed<'a> {
2037            value
2038        }
2039    }
2040
2041    unsafe impl fidl::encoding::TypeMarker for EscrowToken {
2042        type Owned = Self;
2043
2044        #[inline(always)]
2045        fn inline_align(_context: fidl::encoding::Context) -> usize {
2046            4
2047        }
2048
2049        #[inline(always)]
2050        fn inline_size(_context: fidl::encoding::Context) -> usize {
2051            4
2052        }
2053    }
2054
2055    unsafe impl fidl::encoding::Encode<EscrowToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2056        for &mut EscrowToken
2057    {
2058        #[inline]
2059        unsafe fn encode(
2060            self,
2061            encoder: &mut fidl::encoding::Encoder<
2062                '_,
2063                fidl::encoding::DefaultFuchsiaResourceDialect,
2064            >,
2065            offset: usize,
2066            _depth: fidl::encoding::Depth,
2067        ) -> fidl::Result<()> {
2068            encoder.debug_check_bounds::<EscrowToken>(offset);
2069            // Delegate to tuple encoding.
2070            fidl::encoding::Encode::<EscrowToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2071                (
2072                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 49154> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
2073                ),
2074                encoder, offset, _depth
2075            )
2076        }
2077    }
2078    unsafe impl<
2079        T0: fidl::encoding::Encode<
2080                fidl::encoding::HandleType<
2081                    fidl::EventPair,
2082                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2083                    49154,
2084                >,
2085                fidl::encoding::DefaultFuchsiaResourceDialect,
2086            >,
2087    > fidl::encoding::Encode<EscrowToken, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
2088    {
2089        #[inline]
2090        unsafe fn encode(
2091            self,
2092            encoder: &mut fidl::encoding::Encoder<
2093                '_,
2094                fidl::encoding::DefaultFuchsiaResourceDialect,
2095            >,
2096            offset: usize,
2097            depth: fidl::encoding::Depth,
2098        ) -> fidl::Result<()> {
2099            encoder.debug_check_bounds::<EscrowToken>(offset);
2100            // Zero out padding regions. There's no need to apply masks
2101            // because the unmasked parts will be overwritten by fields.
2102            // Write the fields.
2103            self.0.encode(encoder, offset + 0, depth)?;
2104            Ok(())
2105        }
2106    }
2107
2108    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for EscrowToken {
2109        #[inline(always)]
2110        fn new_empty() -> Self {
2111            Self {
2112                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 49154>, fidl::encoding::DefaultFuchsiaResourceDialect),
2113            }
2114        }
2115
2116        #[inline]
2117        unsafe fn decode(
2118            &mut self,
2119            decoder: &mut fidl::encoding::Decoder<
2120                '_,
2121                fidl::encoding::DefaultFuchsiaResourceDialect,
2122            >,
2123            offset: usize,
2124            _depth: fidl::encoding::Depth,
2125        ) -> fidl::Result<()> {
2126            decoder.debug_check_bounds::<Self>(offset);
2127            // Verify that padding bytes are zero.
2128            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 49154>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
2129            Ok(())
2130        }
2131    }
2132
2133    impl fidl::encoding::ResourceTypeMarker for TreeGetContentResponse {
2134        type Borrowed<'a> = &'a mut Self;
2135        fn take_or_borrow<'a>(
2136            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2137        ) -> Self::Borrowed<'a> {
2138            value
2139        }
2140    }
2141
2142    unsafe impl fidl::encoding::TypeMarker for TreeGetContentResponse {
2143        type Owned = Self;
2144
2145        #[inline(always)]
2146        fn inline_align(_context: fidl::encoding::Context) -> usize {
2147            8
2148        }
2149
2150        #[inline(always)]
2151        fn inline_size(_context: fidl::encoding::Context) -> usize {
2152            16
2153        }
2154    }
2155
2156    unsafe impl
2157        fidl::encoding::Encode<
2158            TreeGetContentResponse,
2159            fidl::encoding::DefaultFuchsiaResourceDialect,
2160        > for &mut TreeGetContentResponse
2161    {
2162        #[inline]
2163        unsafe fn encode(
2164            self,
2165            encoder: &mut fidl::encoding::Encoder<
2166                '_,
2167                fidl::encoding::DefaultFuchsiaResourceDialect,
2168            >,
2169            offset: usize,
2170            _depth: fidl::encoding::Depth,
2171        ) -> fidl::Result<()> {
2172            encoder.debug_check_bounds::<TreeGetContentResponse>(offset);
2173            // Delegate to tuple encoding.
2174            fidl::encoding::Encode::<
2175                TreeGetContentResponse,
2176                fidl::encoding::DefaultFuchsiaResourceDialect,
2177            >::encode(
2178                (<TreeContent as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2179                    &mut self.content,
2180                ),),
2181                encoder,
2182                offset,
2183                _depth,
2184            )
2185        }
2186    }
2187    unsafe impl<
2188        T0: fidl::encoding::Encode<TreeContent, fidl::encoding::DefaultFuchsiaResourceDialect>,
2189    >
2190        fidl::encoding::Encode<
2191            TreeGetContentResponse,
2192            fidl::encoding::DefaultFuchsiaResourceDialect,
2193        > for (T0,)
2194    {
2195        #[inline]
2196        unsafe fn encode(
2197            self,
2198            encoder: &mut fidl::encoding::Encoder<
2199                '_,
2200                fidl::encoding::DefaultFuchsiaResourceDialect,
2201            >,
2202            offset: usize,
2203            depth: fidl::encoding::Depth,
2204        ) -> fidl::Result<()> {
2205            encoder.debug_check_bounds::<TreeGetContentResponse>(offset);
2206            // Zero out padding regions. There's no need to apply masks
2207            // because the unmasked parts will be overwritten by fields.
2208            // Write the fields.
2209            self.0.encode(encoder, offset + 0, depth)?;
2210            Ok(())
2211        }
2212    }
2213
2214    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2215        for TreeGetContentResponse
2216    {
2217        #[inline(always)]
2218        fn new_empty() -> Self {
2219            Self {
2220                content: fidl::new_empty!(
2221                    TreeContent,
2222                    fidl::encoding::DefaultFuchsiaResourceDialect
2223                ),
2224            }
2225        }
2226
2227        #[inline]
2228        unsafe fn decode(
2229            &mut self,
2230            decoder: &mut fidl::encoding::Decoder<
2231                '_,
2232                fidl::encoding::DefaultFuchsiaResourceDialect,
2233            >,
2234            offset: usize,
2235            _depth: fidl::encoding::Depth,
2236        ) -> fidl::Result<()> {
2237            decoder.debug_check_bounds::<Self>(offset);
2238            // Verify that padding bytes are zero.
2239            fidl::decode!(
2240                TreeContent,
2241                fidl::encoding::DefaultFuchsiaResourceDialect,
2242                &mut self.content,
2243                decoder,
2244                offset + 0,
2245                _depth
2246            )?;
2247            Ok(())
2248        }
2249    }
2250
2251    impl fidl::encoding::ResourceTypeMarker for TreeListChildNamesRequest {
2252        type Borrowed<'a> = &'a mut Self;
2253        fn take_or_borrow<'a>(
2254            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2255        ) -> Self::Borrowed<'a> {
2256            value
2257        }
2258    }
2259
2260    unsafe impl fidl::encoding::TypeMarker for TreeListChildNamesRequest {
2261        type Owned = Self;
2262
2263        #[inline(always)]
2264        fn inline_align(_context: fidl::encoding::Context) -> usize {
2265            4
2266        }
2267
2268        #[inline(always)]
2269        fn inline_size(_context: fidl::encoding::Context) -> usize {
2270            4
2271        }
2272    }
2273
2274    unsafe impl
2275        fidl::encoding::Encode<
2276            TreeListChildNamesRequest,
2277            fidl::encoding::DefaultFuchsiaResourceDialect,
2278        > for &mut TreeListChildNamesRequest
2279    {
2280        #[inline]
2281        unsafe fn encode(
2282            self,
2283            encoder: &mut fidl::encoding::Encoder<
2284                '_,
2285                fidl::encoding::DefaultFuchsiaResourceDialect,
2286            >,
2287            offset: usize,
2288            _depth: fidl::encoding::Depth,
2289        ) -> fidl::Result<()> {
2290            encoder.debug_check_bounds::<TreeListChildNamesRequest>(offset);
2291            // Delegate to tuple encoding.
2292            fidl::encoding::Encode::<TreeListChildNamesRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2293                (
2294                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TreeNameIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.tree_iterator),
2295                ),
2296                encoder, offset, _depth
2297            )
2298        }
2299    }
2300    unsafe impl<
2301        T0: fidl::encoding::Encode<
2302                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TreeNameIteratorMarker>>,
2303                fidl::encoding::DefaultFuchsiaResourceDialect,
2304            >,
2305    >
2306        fidl::encoding::Encode<
2307            TreeListChildNamesRequest,
2308            fidl::encoding::DefaultFuchsiaResourceDialect,
2309        > for (T0,)
2310    {
2311        #[inline]
2312        unsafe fn encode(
2313            self,
2314            encoder: &mut fidl::encoding::Encoder<
2315                '_,
2316                fidl::encoding::DefaultFuchsiaResourceDialect,
2317            >,
2318            offset: usize,
2319            depth: fidl::encoding::Depth,
2320        ) -> fidl::Result<()> {
2321            encoder.debug_check_bounds::<TreeListChildNamesRequest>(offset);
2322            // Zero out padding regions. There's no need to apply masks
2323            // because the unmasked parts will be overwritten by fields.
2324            // Write the fields.
2325            self.0.encode(encoder, offset + 0, depth)?;
2326            Ok(())
2327        }
2328    }
2329
2330    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2331        for TreeListChildNamesRequest
2332    {
2333        #[inline(always)]
2334        fn new_empty() -> Self {
2335            Self {
2336                tree_iterator: fidl::new_empty!(
2337                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TreeNameIteratorMarker>>,
2338                    fidl::encoding::DefaultFuchsiaResourceDialect
2339                ),
2340            }
2341        }
2342
2343        #[inline]
2344        unsafe fn decode(
2345            &mut self,
2346            decoder: &mut fidl::encoding::Decoder<
2347                '_,
2348                fidl::encoding::DefaultFuchsiaResourceDialect,
2349            >,
2350            offset: usize,
2351            _depth: fidl::encoding::Depth,
2352        ) -> fidl::Result<()> {
2353            decoder.debug_check_bounds::<Self>(offset);
2354            // Verify that padding bytes are zero.
2355            fidl::decode!(
2356                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TreeNameIteratorMarker>>,
2357                fidl::encoding::DefaultFuchsiaResourceDialect,
2358                &mut self.tree_iterator,
2359                decoder,
2360                offset + 0,
2361                _depth
2362            )?;
2363            Ok(())
2364        }
2365    }
2366
2367    impl fidl::encoding::ResourceTypeMarker for TreeOpenChildRequest {
2368        type Borrowed<'a> = &'a mut Self;
2369        fn take_or_borrow<'a>(
2370            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2371        ) -> Self::Borrowed<'a> {
2372            value
2373        }
2374    }
2375
2376    unsafe impl fidl::encoding::TypeMarker for TreeOpenChildRequest {
2377        type Owned = Self;
2378
2379        #[inline(always)]
2380        fn inline_align(_context: fidl::encoding::Context) -> usize {
2381            8
2382        }
2383
2384        #[inline(always)]
2385        fn inline_size(_context: fidl::encoding::Context) -> usize {
2386            24
2387        }
2388    }
2389
2390    unsafe impl
2391        fidl::encoding::Encode<TreeOpenChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2392        for &mut TreeOpenChildRequest
2393    {
2394        #[inline]
2395        unsafe fn encode(
2396            self,
2397            encoder: &mut fidl::encoding::Encoder<
2398                '_,
2399                fidl::encoding::DefaultFuchsiaResourceDialect,
2400            >,
2401            offset: usize,
2402            _depth: fidl::encoding::Depth,
2403        ) -> fidl::Result<()> {
2404            encoder.debug_check_bounds::<TreeOpenChildRequest>(offset);
2405            // Delegate to tuple encoding.
2406            fidl::encoding::Encode::<TreeOpenChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2407                (
2408                    <fidl::encoding::BoundedString<2040> as fidl::encoding::ValueTypeMarker>::borrow(&self.child_name),
2409                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TreeMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.tree),
2410                ),
2411                encoder, offset, _depth
2412            )
2413        }
2414    }
2415    unsafe impl<
2416        T0: fidl::encoding::Encode<
2417                fidl::encoding::BoundedString<2040>,
2418                fidl::encoding::DefaultFuchsiaResourceDialect,
2419            >,
2420        T1: fidl::encoding::Encode<
2421                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TreeMarker>>,
2422                fidl::encoding::DefaultFuchsiaResourceDialect,
2423            >,
2424    >
2425        fidl::encoding::Encode<TreeOpenChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2426        for (T0, T1)
2427    {
2428        #[inline]
2429        unsafe fn encode(
2430            self,
2431            encoder: &mut fidl::encoding::Encoder<
2432                '_,
2433                fidl::encoding::DefaultFuchsiaResourceDialect,
2434            >,
2435            offset: usize,
2436            depth: fidl::encoding::Depth,
2437        ) -> fidl::Result<()> {
2438            encoder.debug_check_bounds::<TreeOpenChildRequest>(offset);
2439            // Zero out padding regions. There's no need to apply masks
2440            // because the unmasked parts will be overwritten by fields.
2441            unsafe {
2442                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2443                (ptr as *mut u64).write_unaligned(0);
2444            }
2445            // Write the fields.
2446            self.0.encode(encoder, offset + 0, depth)?;
2447            self.1.encode(encoder, offset + 16, depth)?;
2448            Ok(())
2449        }
2450    }
2451
2452    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2453        for TreeOpenChildRequest
2454    {
2455        #[inline(always)]
2456        fn new_empty() -> Self {
2457            Self {
2458                child_name: fidl::new_empty!(
2459                    fidl::encoding::BoundedString<2040>,
2460                    fidl::encoding::DefaultFuchsiaResourceDialect
2461                ),
2462                tree: fidl::new_empty!(
2463                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TreeMarker>>,
2464                    fidl::encoding::DefaultFuchsiaResourceDialect
2465                ),
2466            }
2467        }
2468
2469        #[inline]
2470        unsafe fn decode(
2471            &mut self,
2472            decoder: &mut fidl::encoding::Decoder<
2473                '_,
2474                fidl::encoding::DefaultFuchsiaResourceDialect,
2475            >,
2476            offset: usize,
2477            _depth: fidl::encoding::Depth,
2478        ) -> fidl::Result<()> {
2479            decoder.debug_check_bounds::<Self>(offset);
2480            // Verify that padding bytes are zero.
2481            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2482            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2483            let mask = 0xffffffff00000000u64;
2484            let maskedval = padval & mask;
2485            if maskedval != 0 {
2486                return Err(fidl::Error::NonZeroPadding {
2487                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2488                });
2489            }
2490            fidl::decode!(
2491                fidl::encoding::BoundedString<2040>,
2492                fidl::encoding::DefaultFuchsiaResourceDialect,
2493                &mut self.child_name,
2494                decoder,
2495                offset + 0,
2496                _depth
2497            )?;
2498            fidl::decode!(
2499                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TreeMarker>>,
2500                fidl::encoding::DefaultFuchsiaResourceDialect,
2501                &mut self.tree,
2502                decoder,
2503                offset + 16,
2504                _depth
2505            )?;
2506            Ok(())
2507        }
2508    }
2509
2510    impl InspectSinkEscrowRequest {
2511        #[inline(always)]
2512        fn max_ordinal_present(&self) -> u64 {
2513            if let Some(_) = self.tree {
2514                return 4;
2515            }
2516            if let Some(_) = self.name {
2517                return 3;
2518            }
2519            if let Some(_) = self.token {
2520                return 2;
2521            }
2522            if let Some(_) = self.vmo {
2523                return 1;
2524            }
2525            0
2526        }
2527    }
2528
2529    impl fidl::encoding::ResourceTypeMarker for InspectSinkEscrowRequest {
2530        type Borrowed<'a> = &'a mut Self;
2531        fn take_or_borrow<'a>(
2532            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2533        ) -> Self::Borrowed<'a> {
2534            value
2535        }
2536    }
2537
2538    unsafe impl fidl::encoding::TypeMarker for InspectSinkEscrowRequest {
2539        type Owned = Self;
2540
2541        #[inline(always)]
2542        fn inline_align(_context: fidl::encoding::Context) -> usize {
2543            8
2544        }
2545
2546        #[inline(always)]
2547        fn inline_size(_context: fidl::encoding::Context) -> usize {
2548            16
2549        }
2550    }
2551
2552    unsafe impl
2553        fidl::encoding::Encode<
2554            InspectSinkEscrowRequest,
2555            fidl::encoding::DefaultFuchsiaResourceDialect,
2556        > for &mut InspectSinkEscrowRequest
2557    {
2558        unsafe fn encode(
2559            self,
2560            encoder: &mut fidl::encoding::Encoder<
2561                '_,
2562                fidl::encoding::DefaultFuchsiaResourceDialect,
2563            >,
2564            offset: usize,
2565            mut depth: fidl::encoding::Depth,
2566        ) -> fidl::Result<()> {
2567            encoder.debug_check_bounds::<InspectSinkEscrowRequest>(offset);
2568            // Vector header
2569            let max_ordinal: u64 = self.max_ordinal_present();
2570            encoder.write_num(max_ordinal, offset);
2571            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2572            // Calling encoder.out_of_line_offset(0) is not allowed.
2573            if max_ordinal == 0 {
2574                return Ok(());
2575            }
2576            depth.increment()?;
2577            let envelope_size = 8;
2578            let bytes_len = max_ordinal as usize * envelope_size;
2579            #[allow(unused_variables)]
2580            let offset = encoder.out_of_line_offset(bytes_len);
2581            let mut _prev_end_offset: usize = 0;
2582            if 1 > max_ordinal {
2583                return Ok(());
2584            }
2585
2586            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2587            // are envelope_size bytes.
2588            let cur_offset: usize = (1 - 1) * envelope_size;
2589
2590            // Zero reserved fields.
2591            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2592
2593            // Safety:
2594            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2595            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2596            //   envelope_size bytes, there is always sufficient room.
2597            fidl::encoding::encode_in_envelope_optional::<
2598                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49383>,
2599                fidl::encoding::DefaultFuchsiaResourceDialect,
2600            >(
2601                self.vmo.as_mut().map(
2602                    <fidl::encoding::HandleType<
2603                        fidl::Vmo,
2604                        { fidl::ObjectType::VMO.into_raw() },
2605                        49383,
2606                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2607                ),
2608                encoder,
2609                offset + cur_offset,
2610                depth,
2611            )?;
2612
2613            _prev_end_offset = cur_offset + envelope_size;
2614            if 2 > max_ordinal {
2615                return Ok(());
2616            }
2617
2618            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2619            // are envelope_size bytes.
2620            let cur_offset: usize = (2 - 1) * envelope_size;
2621
2622            // Zero reserved fields.
2623            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2624
2625            // Safety:
2626            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2627            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2628            //   envelope_size bytes, there is always sufficient room.
2629            fidl::encoding::encode_in_envelope_optional::<
2630                EscrowToken,
2631                fidl::encoding::DefaultFuchsiaResourceDialect,
2632            >(
2633                self.token
2634                    .as_mut()
2635                    .map(<EscrowToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2636                encoder,
2637                offset + cur_offset,
2638                depth,
2639            )?;
2640
2641            _prev_end_offset = cur_offset + envelope_size;
2642            if 3 > max_ordinal {
2643                return Ok(());
2644            }
2645
2646            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2647            // are envelope_size bytes.
2648            let cur_offset: usize = (3 - 1) * envelope_size;
2649
2650            // Zero reserved fields.
2651            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2652
2653            // Safety:
2654            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2655            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2656            //   envelope_size bytes, there is always sufficient room.
2657            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2658            self.name.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
2659            encoder, offset + cur_offset, depth
2660        )?;
2661
2662            _prev_end_offset = cur_offset + envelope_size;
2663            if 4 > max_ordinal {
2664                return Ok(());
2665            }
2666
2667            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2668            // are envelope_size bytes.
2669            let cur_offset: usize = (4 - 1) * envelope_size;
2670
2671            // Zero reserved fields.
2672            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2673
2674            // Safety:
2675            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2676            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2677            //   envelope_size bytes, there is always sufficient room.
2678            fidl::encoding::encode_in_envelope_optional::<
2679                u64,
2680                fidl::encoding::DefaultFuchsiaResourceDialect,
2681            >(
2682                self.tree.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2683                encoder,
2684                offset + cur_offset,
2685                depth,
2686            )?;
2687
2688            _prev_end_offset = cur_offset + envelope_size;
2689
2690            Ok(())
2691        }
2692    }
2693
2694    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2695        for InspectSinkEscrowRequest
2696    {
2697        #[inline(always)]
2698        fn new_empty() -> Self {
2699            Self::default()
2700        }
2701
2702        unsafe fn decode(
2703            &mut self,
2704            decoder: &mut fidl::encoding::Decoder<
2705                '_,
2706                fidl::encoding::DefaultFuchsiaResourceDialect,
2707            >,
2708            offset: usize,
2709            mut depth: fidl::encoding::Depth,
2710        ) -> fidl::Result<()> {
2711            decoder.debug_check_bounds::<Self>(offset);
2712            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2713                None => return Err(fidl::Error::NotNullable),
2714                Some(len) => len,
2715            };
2716            // Calling decoder.out_of_line_offset(0) is not allowed.
2717            if len == 0 {
2718                return Ok(());
2719            };
2720            depth.increment()?;
2721            let envelope_size = 8;
2722            let bytes_len = len * envelope_size;
2723            let offset = decoder.out_of_line_offset(bytes_len)?;
2724            // Decode the envelope for each type.
2725            let mut _next_ordinal_to_read = 0;
2726            let mut next_offset = offset;
2727            let end_offset = offset + bytes_len;
2728            _next_ordinal_to_read += 1;
2729            if next_offset >= end_offset {
2730                return Ok(());
2731            }
2732
2733            // Decode unknown envelopes for gaps in ordinals.
2734            while _next_ordinal_to_read < 1 {
2735                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2736                _next_ordinal_to_read += 1;
2737                next_offset += envelope_size;
2738            }
2739
2740            let next_out_of_line = decoder.next_out_of_line();
2741            let handles_before = decoder.remaining_handles();
2742            if let Some((inlined, num_bytes, num_handles)) =
2743                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2744            {
2745                let member_inline_size = <fidl::encoding::HandleType<
2746                    fidl::Vmo,
2747                    { fidl::ObjectType::VMO.into_raw() },
2748                    49383,
2749                > as fidl::encoding::TypeMarker>::inline_size(
2750                    decoder.context
2751                );
2752                if inlined != (member_inline_size <= 4) {
2753                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2754                }
2755                let inner_offset;
2756                let mut inner_depth = depth.clone();
2757                if inlined {
2758                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2759                    inner_offset = next_offset;
2760                } else {
2761                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2762                    inner_depth.increment()?;
2763                }
2764                let val_ref =
2765                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49383>, fidl::encoding::DefaultFuchsiaResourceDialect));
2766                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49383>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2767                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2768                {
2769                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2770                }
2771                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2772                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2773                }
2774            }
2775
2776            next_offset += envelope_size;
2777            _next_ordinal_to_read += 1;
2778            if next_offset >= end_offset {
2779                return Ok(());
2780            }
2781
2782            // Decode unknown envelopes for gaps in ordinals.
2783            while _next_ordinal_to_read < 2 {
2784                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2785                _next_ordinal_to_read += 1;
2786                next_offset += envelope_size;
2787            }
2788
2789            let next_out_of_line = decoder.next_out_of_line();
2790            let handles_before = decoder.remaining_handles();
2791            if let Some((inlined, num_bytes, num_handles)) =
2792                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2793            {
2794                let member_inline_size =
2795                    <EscrowToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2796                if inlined != (member_inline_size <= 4) {
2797                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2798                }
2799                let inner_offset;
2800                let mut inner_depth = depth.clone();
2801                if inlined {
2802                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2803                    inner_offset = next_offset;
2804                } else {
2805                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2806                    inner_depth.increment()?;
2807                }
2808                let val_ref = self.token.get_or_insert_with(|| {
2809                    fidl::new_empty!(EscrowToken, fidl::encoding::DefaultFuchsiaResourceDialect)
2810                });
2811                fidl::decode!(
2812                    EscrowToken,
2813                    fidl::encoding::DefaultFuchsiaResourceDialect,
2814                    val_ref,
2815                    decoder,
2816                    inner_offset,
2817                    inner_depth
2818                )?;
2819                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2820                {
2821                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2822                }
2823                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2824                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2825                }
2826            }
2827
2828            next_offset += envelope_size;
2829            _next_ordinal_to_read += 1;
2830            if next_offset >= end_offset {
2831                return Ok(());
2832            }
2833
2834            // Decode unknown envelopes for gaps in ordinals.
2835            while _next_ordinal_to_read < 3 {
2836                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2837                _next_ordinal_to_read += 1;
2838                next_offset += envelope_size;
2839            }
2840
2841            let next_out_of_line = decoder.next_out_of_line();
2842            let handles_before = decoder.remaining_handles();
2843            if let Some((inlined, num_bytes, num_handles)) =
2844                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2845            {
2846                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2847                if inlined != (member_inline_size <= 4) {
2848                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2849                }
2850                let inner_offset;
2851                let mut inner_depth = depth.clone();
2852                if inlined {
2853                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2854                    inner_offset = next_offset;
2855                } else {
2856                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2857                    inner_depth.increment()?;
2858                }
2859                let val_ref = self.name.get_or_insert_with(|| {
2860                    fidl::new_empty!(
2861                        fidl::encoding::BoundedString<4096>,
2862                        fidl::encoding::DefaultFuchsiaResourceDialect
2863                    )
2864                });
2865                fidl::decode!(
2866                    fidl::encoding::BoundedString<4096>,
2867                    fidl::encoding::DefaultFuchsiaResourceDialect,
2868                    val_ref,
2869                    decoder,
2870                    inner_offset,
2871                    inner_depth
2872                )?;
2873                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2874                {
2875                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2876                }
2877                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2878                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2879                }
2880            }
2881
2882            next_offset += envelope_size;
2883            _next_ordinal_to_read += 1;
2884            if next_offset >= end_offset {
2885                return Ok(());
2886            }
2887
2888            // Decode unknown envelopes for gaps in ordinals.
2889            while _next_ordinal_to_read < 4 {
2890                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2891                _next_ordinal_to_read += 1;
2892                next_offset += envelope_size;
2893            }
2894
2895            let next_out_of_line = decoder.next_out_of_line();
2896            let handles_before = decoder.remaining_handles();
2897            if let Some((inlined, num_bytes, num_handles)) =
2898                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2899            {
2900                let member_inline_size =
2901                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2902                if inlined != (member_inline_size <= 4) {
2903                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2904                }
2905                let inner_offset;
2906                let mut inner_depth = depth.clone();
2907                if inlined {
2908                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2909                    inner_offset = next_offset;
2910                } else {
2911                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2912                    inner_depth.increment()?;
2913                }
2914                let val_ref = self.tree.get_or_insert_with(|| {
2915                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2916                });
2917                fidl::decode!(
2918                    u64,
2919                    fidl::encoding::DefaultFuchsiaResourceDialect,
2920                    val_ref,
2921                    decoder,
2922                    inner_offset,
2923                    inner_depth
2924                )?;
2925                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2926                {
2927                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2928                }
2929                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2930                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2931                }
2932            }
2933
2934            next_offset += envelope_size;
2935
2936            // Decode the remaining unknown envelopes.
2937            while next_offset < end_offset {
2938                _next_ordinal_to_read += 1;
2939                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2940                next_offset += envelope_size;
2941            }
2942
2943            Ok(())
2944        }
2945    }
2946
2947    impl InspectSinkFetchEscrowRequest {
2948        #[inline(always)]
2949        fn max_ordinal_present(&self) -> u64 {
2950            if let Some(_) = self.tree {
2951                return 2;
2952            }
2953            if let Some(_) = self.token {
2954                return 1;
2955            }
2956            0
2957        }
2958    }
2959
2960    impl fidl::encoding::ResourceTypeMarker for InspectSinkFetchEscrowRequest {
2961        type Borrowed<'a> = &'a mut Self;
2962        fn take_or_borrow<'a>(
2963            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2964        ) -> Self::Borrowed<'a> {
2965            value
2966        }
2967    }
2968
2969    unsafe impl fidl::encoding::TypeMarker for InspectSinkFetchEscrowRequest {
2970        type Owned = Self;
2971
2972        #[inline(always)]
2973        fn inline_align(_context: fidl::encoding::Context) -> usize {
2974            8
2975        }
2976
2977        #[inline(always)]
2978        fn inline_size(_context: fidl::encoding::Context) -> usize {
2979            16
2980        }
2981    }
2982
2983    unsafe impl
2984        fidl::encoding::Encode<
2985            InspectSinkFetchEscrowRequest,
2986            fidl::encoding::DefaultFuchsiaResourceDialect,
2987        > for &mut InspectSinkFetchEscrowRequest
2988    {
2989        unsafe fn encode(
2990            self,
2991            encoder: &mut fidl::encoding::Encoder<
2992                '_,
2993                fidl::encoding::DefaultFuchsiaResourceDialect,
2994            >,
2995            offset: usize,
2996            mut depth: fidl::encoding::Depth,
2997        ) -> fidl::Result<()> {
2998            encoder.debug_check_bounds::<InspectSinkFetchEscrowRequest>(offset);
2999            // Vector header
3000            let max_ordinal: u64 = self.max_ordinal_present();
3001            encoder.write_num(max_ordinal, offset);
3002            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3003            // Calling encoder.out_of_line_offset(0) is not allowed.
3004            if max_ordinal == 0 {
3005                return Ok(());
3006            }
3007            depth.increment()?;
3008            let envelope_size = 8;
3009            let bytes_len = max_ordinal as usize * envelope_size;
3010            #[allow(unused_variables)]
3011            let offset = encoder.out_of_line_offset(bytes_len);
3012            let mut _prev_end_offset: usize = 0;
3013            if 1 > max_ordinal {
3014                return Ok(());
3015            }
3016
3017            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3018            // are envelope_size bytes.
3019            let cur_offset: usize = (1 - 1) * envelope_size;
3020
3021            // Zero reserved fields.
3022            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3023
3024            // Safety:
3025            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3026            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3027            //   envelope_size bytes, there is always sufficient room.
3028            fidl::encoding::encode_in_envelope_optional::<
3029                EscrowToken,
3030                fidl::encoding::DefaultFuchsiaResourceDialect,
3031            >(
3032                self.token
3033                    .as_mut()
3034                    .map(<EscrowToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3035                encoder,
3036                offset + cur_offset,
3037                depth,
3038            )?;
3039
3040            _prev_end_offset = cur_offset + envelope_size;
3041            if 2 > max_ordinal {
3042                return Ok(());
3043            }
3044
3045            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3046            // are envelope_size bytes.
3047            let cur_offset: usize = (2 - 1) * envelope_size;
3048
3049            // Zero reserved fields.
3050            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3051
3052            // Safety:
3053            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3054            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3055            //   envelope_size bytes, there is always sufficient room.
3056            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TreeMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3057            self.tree.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TreeMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3058            encoder, offset + cur_offset, depth
3059        )?;
3060
3061            _prev_end_offset = cur_offset + envelope_size;
3062
3063            Ok(())
3064        }
3065    }
3066
3067    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3068        for InspectSinkFetchEscrowRequest
3069    {
3070        #[inline(always)]
3071        fn new_empty() -> Self {
3072            Self::default()
3073        }
3074
3075        unsafe fn decode(
3076            &mut self,
3077            decoder: &mut fidl::encoding::Decoder<
3078                '_,
3079                fidl::encoding::DefaultFuchsiaResourceDialect,
3080            >,
3081            offset: usize,
3082            mut depth: fidl::encoding::Depth,
3083        ) -> fidl::Result<()> {
3084            decoder.debug_check_bounds::<Self>(offset);
3085            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3086                None => return Err(fidl::Error::NotNullable),
3087                Some(len) => len,
3088            };
3089            // Calling decoder.out_of_line_offset(0) is not allowed.
3090            if len == 0 {
3091                return Ok(());
3092            };
3093            depth.increment()?;
3094            let envelope_size = 8;
3095            let bytes_len = len * envelope_size;
3096            let offset = decoder.out_of_line_offset(bytes_len)?;
3097            // Decode the envelope for each type.
3098            let mut _next_ordinal_to_read = 0;
3099            let mut next_offset = offset;
3100            let end_offset = offset + bytes_len;
3101            _next_ordinal_to_read += 1;
3102            if next_offset >= end_offset {
3103                return Ok(());
3104            }
3105
3106            // Decode unknown envelopes for gaps in ordinals.
3107            while _next_ordinal_to_read < 1 {
3108                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3109                _next_ordinal_to_read += 1;
3110                next_offset += envelope_size;
3111            }
3112
3113            let next_out_of_line = decoder.next_out_of_line();
3114            let handles_before = decoder.remaining_handles();
3115            if let Some((inlined, num_bytes, num_handles)) =
3116                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3117            {
3118                let member_inline_size =
3119                    <EscrowToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3120                if inlined != (member_inline_size <= 4) {
3121                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3122                }
3123                let inner_offset;
3124                let mut inner_depth = depth.clone();
3125                if inlined {
3126                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3127                    inner_offset = next_offset;
3128                } else {
3129                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3130                    inner_depth.increment()?;
3131                }
3132                let val_ref = self.token.get_or_insert_with(|| {
3133                    fidl::new_empty!(EscrowToken, fidl::encoding::DefaultFuchsiaResourceDialect)
3134                });
3135                fidl::decode!(
3136                    EscrowToken,
3137                    fidl::encoding::DefaultFuchsiaResourceDialect,
3138                    val_ref,
3139                    decoder,
3140                    inner_offset,
3141                    inner_depth
3142                )?;
3143                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3144                {
3145                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3146                }
3147                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3148                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3149                }
3150            }
3151
3152            next_offset += envelope_size;
3153            _next_ordinal_to_read += 1;
3154            if next_offset >= end_offset {
3155                return Ok(());
3156            }
3157
3158            // Decode unknown envelopes for gaps in ordinals.
3159            while _next_ordinal_to_read < 2 {
3160                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3161                _next_ordinal_to_read += 1;
3162                next_offset += envelope_size;
3163            }
3164
3165            let next_out_of_line = decoder.next_out_of_line();
3166            let handles_before = decoder.remaining_handles();
3167            if let Some((inlined, num_bytes, num_handles)) =
3168                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3169            {
3170                let member_inline_size = <fidl::encoding::Endpoint<
3171                    fidl::endpoints::ClientEnd<TreeMarker>,
3172                > as fidl::encoding::TypeMarker>::inline_size(
3173                    decoder.context
3174                );
3175                if inlined != (member_inline_size <= 4) {
3176                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3177                }
3178                let inner_offset;
3179                let mut inner_depth = depth.clone();
3180                if inlined {
3181                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3182                    inner_offset = next_offset;
3183                } else {
3184                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3185                    inner_depth.increment()?;
3186                }
3187                let val_ref = self.tree.get_or_insert_with(|| {
3188                    fidl::new_empty!(
3189                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TreeMarker>>,
3190                        fidl::encoding::DefaultFuchsiaResourceDialect
3191                    )
3192                });
3193                fidl::decode!(
3194                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TreeMarker>>,
3195                    fidl::encoding::DefaultFuchsiaResourceDialect,
3196                    val_ref,
3197                    decoder,
3198                    inner_offset,
3199                    inner_depth
3200                )?;
3201                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3202                {
3203                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3204                }
3205                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3206                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3207                }
3208            }
3209
3210            next_offset += envelope_size;
3211
3212            // Decode the remaining unknown envelopes.
3213            while next_offset < end_offset {
3214                _next_ordinal_to_read += 1;
3215                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3216                next_offset += envelope_size;
3217            }
3218
3219            Ok(())
3220        }
3221    }
3222
3223    impl InspectSinkPublishRequest {
3224        #[inline(always)]
3225        fn max_ordinal_present(&self) -> u64 {
3226            if let Some(_) = self.name {
3227                return 2;
3228            }
3229            if let Some(_) = self.tree {
3230                return 1;
3231            }
3232            0
3233        }
3234    }
3235
3236    impl fidl::encoding::ResourceTypeMarker for InspectSinkPublishRequest {
3237        type Borrowed<'a> = &'a mut Self;
3238        fn take_or_borrow<'a>(
3239            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3240        ) -> Self::Borrowed<'a> {
3241            value
3242        }
3243    }
3244
3245    unsafe impl fidl::encoding::TypeMarker for InspectSinkPublishRequest {
3246        type Owned = Self;
3247
3248        #[inline(always)]
3249        fn inline_align(_context: fidl::encoding::Context) -> usize {
3250            8
3251        }
3252
3253        #[inline(always)]
3254        fn inline_size(_context: fidl::encoding::Context) -> usize {
3255            16
3256        }
3257    }
3258
3259    unsafe impl
3260        fidl::encoding::Encode<
3261            InspectSinkPublishRequest,
3262            fidl::encoding::DefaultFuchsiaResourceDialect,
3263        > for &mut InspectSinkPublishRequest
3264    {
3265        unsafe fn encode(
3266            self,
3267            encoder: &mut fidl::encoding::Encoder<
3268                '_,
3269                fidl::encoding::DefaultFuchsiaResourceDialect,
3270            >,
3271            offset: usize,
3272            mut depth: fidl::encoding::Depth,
3273        ) -> fidl::Result<()> {
3274            encoder.debug_check_bounds::<InspectSinkPublishRequest>(offset);
3275            // Vector header
3276            let max_ordinal: u64 = self.max_ordinal_present();
3277            encoder.write_num(max_ordinal, offset);
3278            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3279            // Calling encoder.out_of_line_offset(0) is not allowed.
3280            if max_ordinal == 0 {
3281                return Ok(());
3282            }
3283            depth.increment()?;
3284            let envelope_size = 8;
3285            let bytes_len = max_ordinal as usize * envelope_size;
3286            #[allow(unused_variables)]
3287            let offset = encoder.out_of_line_offset(bytes_len);
3288            let mut _prev_end_offset: usize = 0;
3289            if 1 > max_ordinal {
3290                return Ok(());
3291            }
3292
3293            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3294            // are envelope_size bytes.
3295            let cur_offset: usize = (1 - 1) * envelope_size;
3296
3297            // Zero reserved fields.
3298            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3299
3300            // Safety:
3301            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3302            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3303            //   envelope_size bytes, there is always sufficient room.
3304            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TreeMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3305            self.tree.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TreeMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3306            encoder, offset + cur_offset, depth
3307        )?;
3308
3309            _prev_end_offset = cur_offset + envelope_size;
3310            if 2 > max_ordinal {
3311                return Ok(());
3312            }
3313
3314            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3315            // are envelope_size bytes.
3316            let cur_offset: usize = (2 - 1) * envelope_size;
3317
3318            // Zero reserved fields.
3319            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3320
3321            // Safety:
3322            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3323            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3324            //   envelope_size bytes, there is always sufficient room.
3325            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3326            self.name.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
3327            encoder, offset + cur_offset, depth
3328        )?;
3329
3330            _prev_end_offset = cur_offset + envelope_size;
3331
3332            Ok(())
3333        }
3334    }
3335
3336    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3337        for InspectSinkPublishRequest
3338    {
3339        #[inline(always)]
3340        fn new_empty() -> Self {
3341            Self::default()
3342        }
3343
3344        unsafe fn decode(
3345            &mut self,
3346            decoder: &mut fidl::encoding::Decoder<
3347                '_,
3348                fidl::encoding::DefaultFuchsiaResourceDialect,
3349            >,
3350            offset: usize,
3351            mut depth: fidl::encoding::Depth,
3352        ) -> fidl::Result<()> {
3353            decoder.debug_check_bounds::<Self>(offset);
3354            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3355                None => return Err(fidl::Error::NotNullable),
3356                Some(len) => len,
3357            };
3358            // Calling decoder.out_of_line_offset(0) is not allowed.
3359            if len == 0 {
3360                return Ok(());
3361            };
3362            depth.increment()?;
3363            let envelope_size = 8;
3364            let bytes_len = len * envelope_size;
3365            let offset = decoder.out_of_line_offset(bytes_len)?;
3366            // Decode the envelope for each type.
3367            let mut _next_ordinal_to_read = 0;
3368            let mut next_offset = offset;
3369            let end_offset = offset + bytes_len;
3370            _next_ordinal_to_read += 1;
3371            if next_offset >= end_offset {
3372                return Ok(());
3373            }
3374
3375            // Decode unknown envelopes for gaps in ordinals.
3376            while _next_ordinal_to_read < 1 {
3377                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3378                _next_ordinal_to_read += 1;
3379                next_offset += envelope_size;
3380            }
3381
3382            let next_out_of_line = decoder.next_out_of_line();
3383            let handles_before = decoder.remaining_handles();
3384            if let Some((inlined, num_bytes, num_handles)) =
3385                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3386            {
3387                let member_inline_size = <fidl::encoding::Endpoint<
3388                    fidl::endpoints::ClientEnd<TreeMarker>,
3389                > as fidl::encoding::TypeMarker>::inline_size(
3390                    decoder.context
3391                );
3392                if inlined != (member_inline_size <= 4) {
3393                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3394                }
3395                let inner_offset;
3396                let mut inner_depth = depth.clone();
3397                if inlined {
3398                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3399                    inner_offset = next_offset;
3400                } else {
3401                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3402                    inner_depth.increment()?;
3403                }
3404                let val_ref = self.tree.get_or_insert_with(|| {
3405                    fidl::new_empty!(
3406                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TreeMarker>>,
3407                        fidl::encoding::DefaultFuchsiaResourceDialect
3408                    )
3409                });
3410                fidl::decode!(
3411                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<TreeMarker>>,
3412                    fidl::encoding::DefaultFuchsiaResourceDialect,
3413                    val_ref,
3414                    decoder,
3415                    inner_offset,
3416                    inner_depth
3417                )?;
3418                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3419                {
3420                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3421                }
3422                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3423                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3424                }
3425            }
3426
3427            next_offset += envelope_size;
3428            _next_ordinal_to_read += 1;
3429            if next_offset >= end_offset {
3430                return Ok(());
3431            }
3432
3433            // Decode unknown envelopes for gaps in ordinals.
3434            while _next_ordinal_to_read < 2 {
3435                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3436                _next_ordinal_to_read += 1;
3437                next_offset += envelope_size;
3438            }
3439
3440            let next_out_of_line = decoder.next_out_of_line();
3441            let handles_before = decoder.remaining_handles();
3442            if let Some((inlined, num_bytes, num_handles)) =
3443                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3444            {
3445                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3446                if inlined != (member_inline_size <= 4) {
3447                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3448                }
3449                let inner_offset;
3450                let mut inner_depth = depth.clone();
3451                if inlined {
3452                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3453                    inner_offset = next_offset;
3454                } else {
3455                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3456                    inner_depth.increment()?;
3457                }
3458                let val_ref = self.name.get_or_insert_with(|| {
3459                    fidl::new_empty!(
3460                        fidl::encoding::BoundedString<4096>,
3461                        fidl::encoding::DefaultFuchsiaResourceDialect
3462                    )
3463                });
3464                fidl::decode!(
3465                    fidl::encoding::BoundedString<4096>,
3466                    fidl::encoding::DefaultFuchsiaResourceDialect,
3467                    val_ref,
3468                    decoder,
3469                    inner_offset,
3470                    inner_depth
3471                )?;
3472                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3473                {
3474                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3475                }
3476                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3477                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3478                }
3479            }
3480
3481            next_offset += envelope_size;
3482
3483            // Decode the remaining unknown envelopes.
3484            while next_offset < end_offset {
3485                _next_ordinal_to_read += 1;
3486                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3487                next_offset += envelope_size;
3488            }
3489
3490            Ok(())
3491        }
3492    }
3493
3494    impl InspectSinkFetchEscrowResponse {
3495        #[inline(always)]
3496        fn max_ordinal_present(&self) -> u64 {
3497            if let Some(_) = self.vmo {
3498                return 1;
3499            }
3500            0
3501        }
3502    }
3503
3504    impl fidl::encoding::ResourceTypeMarker for InspectSinkFetchEscrowResponse {
3505        type Borrowed<'a> = &'a mut Self;
3506        fn take_or_borrow<'a>(
3507            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3508        ) -> Self::Borrowed<'a> {
3509            value
3510        }
3511    }
3512
3513    unsafe impl fidl::encoding::TypeMarker for InspectSinkFetchEscrowResponse {
3514        type Owned = Self;
3515
3516        #[inline(always)]
3517        fn inline_align(_context: fidl::encoding::Context) -> usize {
3518            8
3519        }
3520
3521        #[inline(always)]
3522        fn inline_size(_context: fidl::encoding::Context) -> usize {
3523            16
3524        }
3525    }
3526
3527    unsafe impl
3528        fidl::encoding::Encode<
3529            InspectSinkFetchEscrowResponse,
3530            fidl::encoding::DefaultFuchsiaResourceDialect,
3531        > for &mut InspectSinkFetchEscrowResponse
3532    {
3533        unsafe fn encode(
3534            self,
3535            encoder: &mut fidl::encoding::Encoder<
3536                '_,
3537                fidl::encoding::DefaultFuchsiaResourceDialect,
3538            >,
3539            offset: usize,
3540            mut depth: fidl::encoding::Depth,
3541        ) -> fidl::Result<()> {
3542            encoder.debug_check_bounds::<InspectSinkFetchEscrowResponse>(offset);
3543            // Vector header
3544            let max_ordinal: u64 = self.max_ordinal_present();
3545            encoder.write_num(max_ordinal, offset);
3546            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3547            // Calling encoder.out_of_line_offset(0) is not allowed.
3548            if max_ordinal == 0 {
3549                return Ok(());
3550            }
3551            depth.increment()?;
3552            let envelope_size = 8;
3553            let bytes_len = max_ordinal as usize * envelope_size;
3554            #[allow(unused_variables)]
3555            let offset = encoder.out_of_line_offset(bytes_len);
3556            let mut _prev_end_offset: usize = 0;
3557            if 1 > max_ordinal {
3558                return Ok(());
3559            }
3560
3561            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3562            // are envelope_size bytes.
3563            let cur_offset: usize = (1 - 1) * envelope_size;
3564
3565            // Zero reserved fields.
3566            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3567
3568            // Safety:
3569            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3570            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3571            //   envelope_size bytes, there is always sufficient room.
3572            fidl::encoding::encode_in_envelope_optional::<
3573                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49383>,
3574                fidl::encoding::DefaultFuchsiaResourceDialect,
3575            >(
3576                self.vmo.as_mut().map(
3577                    <fidl::encoding::HandleType<
3578                        fidl::Vmo,
3579                        { fidl::ObjectType::VMO.into_raw() },
3580                        49383,
3581                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3582                ),
3583                encoder,
3584                offset + cur_offset,
3585                depth,
3586            )?;
3587
3588            _prev_end_offset = cur_offset + envelope_size;
3589
3590            Ok(())
3591        }
3592    }
3593
3594    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3595        for InspectSinkFetchEscrowResponse
3596    {
3597        #[inline(always)]
3598        fn new_empty() -> Self {
3599            Self::default()
3600        }
3601
3602        unsafe fn decode(
3603            &mut self,
3604            decoder: &mut fidl::encoding::Decoder<
3605                '_,
3606                fidl::encoding::DefaultFuchsiaResourceDialect,
3607            >,
3608            offset: usize,
3609            mut depth: fidl::encoding::Depth,
3610        ) -> fidl::Result<()> {
3611            decoder.debug_check_bounds::<Self>(offset);
3612            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3613                None => return Err(fidl::Error::NotNullable),
3614                Some(len) => len,
3615            };
3616            // Calling decoder.out_of_line_offset(0) is not allowed.
3617            if len == 0 {
3618                return Ok(());
3619            };
3620            depth.increment()?;
3621            let envelope_size = 8;
3622            let bytes_len = len * envelope_size;
3623            let offset = decoder.out_of_line_offset(bytes_len)?;
3624            // Decode the envelope for each type.
3625            let mut _next_ordinal_to_read = 0;
3626            let mut next_offset = offset;
3627            let end_offset = offset + bytes_len;
3628            _next_ordinal_to_read += 1;
3629            if next_offset >= end_offset {
3630                return Ok(());
3631            }
3632
3633            // Decode unknown envelopes for gaps in ordinals.
3634            while _next_ordinal_to_read < 1 {
3635                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3636                _next_ordinal_to_read += 1;
3637                next_offset += envelope_size;
3638            }
3639
3640            let next_out_of_line = decoder.next_out_of_line();
3641            let handles_before = decoder.remaining_handles();
3642            if let Some((inlined, num_bytes, num_handles)) =
3643                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3644            {
3645                let member_inline_size = <fidl::encoding::HandleType<
3646                    fidl::Vmo,
3647                    { fidl::ObjectType::VMO.into_raw() },
3648                    49383,
3649                > as fidl::encoding::TypeMarker>::inline_size(
3650                    decoder.context
3651                );
3652                if inlined != (member_inline_size <= 4) {
3653                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3654                }
3655                let inner_offset;
3656                let mut inner_depth = depth.clone();
3657                if inlined {
3658                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3659                    inner_offset = next_offset;
3660                } else {
3661                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3662                    inner_depth.increment()?;
3663                }
3664                let val_ref =
3665                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49383>, fidl::encoding::DefaultFuchsiaResourceDialect));
3666                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49383>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3667                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3668                {
3669                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3670                }
3671                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3672                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3673                }
3674            }
3675
3676            next_offset += envelope_size;
3677
3678            // Decode the remaining unknown envelopes.
3679            while next_offset < end_offset {
3680                _next_ordinal_to_read += 1;
3681                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3682                next_offset += envelope_size;
3683            }
3684
3685            Ok(())
3686        }
3687    }
3688
3689    impl TreeContent {
3690        #[inline(always)]
3691        fn max_ordinal_present(&self) -> u64 {
3692            if let Some(_) = self.buffer {
3693                return 1;
3694            }
3695            0
3696        }
3697    }
3698
3699    impl fidl::encoding::ResourceTypeMarker for TreeContent {
3700        type Borrowed<'a> = &'a mut Self;
3701        fn take_or_borrow<'a>(
3702            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3703        ) -> Self::Borrowed<'a> {
3704            value
3705        }
3706    }
3707
3708    unsafe impl fidl::encoding::TypeMarker for TreeContent {
3709        type Owned = Self;
3710
3711        #[inline(always)]
3712        fn inline_align(_context: fidl::encoding::Context) -> usize {
3713            8
3714        }
3715
3716        #[inline(always)]
3717        fn inline_size(_context: fidl::encoding::Context) -> usize {
3718            16
3719        }
3720    }
3721
3722    unsafe impl fidl::encoding::Encode<TreeContent, fidl::encoding::DefaultFuchsiaResourceDialect>
3723        for &mut TreeContent
3724    {
3725        unsafe fn encode(
3726            self,
3727            encoder: &mut fidl::encoding::Encoder<
3728                '_,
3729                fidl::encoding::DefaultFuchsiaResourceDialect,
3730            >,
3731            offset: usize,
3732            mut depth: fidl::encoding::Depth,
3733        ) -> fidl::Result<()> {
3734            encoder.debug_check_bounds::<TreeContent>(offset);
3735            // Vector header
3736            let max_ordinal: u64 = self.max_ordinal_present();
3737            encoder.write_num(max_ordinal, offset);
3738            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3739            // Calling encoder.out_of_line_offset(0) is not allowed.
3740            if max_ordinal == 0 {
3741                return Ok(());
3742            }
3743            depth.increment()?;
3744            let envelope_size = 8;
3745            let bytes_len = max_ordinal as usize * envelope_size;
3746            #[allow(unused_variables)]
3747            let offset = encoder.out_of_line_offset(bytes_len);
3748            let mut _prev_end_offset: usize = 0;
3749            if 1 > max_ordinal {
3750                return Ok(());
3751            }
3752
3753            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3754            // are envelope_size bytes.
3755            let cur_offset: usize = (1 - 1) * envelope_size;
3756
3757            // Zero reserved fields.
3758            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3759
3760            // Safety:
3761            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3762            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3763            //   envelope_size bytes, there is always sufficient room.
3764            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_mem::Buffer, fidl::encoding::DefaultFuchsiaResourceDialect>(
3765            self.buffer.as_mut().map(<fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3766            encoder, offset + cur_offset, depth
3767        )?;
3768
3769            _prev_end_offset = cur_offset + envelope_size;
3770
3771            Ok(())
3772        }
3773    }
3774
3775    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for TreeContent {
3776        #[inline(always)]
3777        fn new_empty() -> Self {
3778            Self::default()
3779        }
3780
3781        unsafe fn decode(
3782            &mut self,
3783            decoder: &mut fidl::encoding::Decoder<
3784                '_,
3785                fidl::encoding::DefaultFuchsiaResourceDialect,
3786            >,
3787            offset: usize,
3788            mut depth: fidl::encoding::Depth,
3789        ) -> fidl::Result<()> {
3790            decoder.debug_check_bounds::<Self>(offset);
3791            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3792                None => return Err(fidl::Error::NotNullable),
3793                Some(len) => len,
3794            };
3795            // Calling decoder.out_of_line_offset(0) is not allowed.
3796            if len == 0 {
3797                return Ok(());
3798            };
3799            depth.increment()?;
3800            let envelope_size = 8;
3801            let bytes_len = len * envelope_size;
3802            let offset = decoder.out_of_line_offset(bytes_len)?;
3803            // Decode the envelope for each type.
3804            let mut _next_ordinal_to_read = 0;
3805            let mut next_offset = offset;
3806            let end_offset = offset + bytes_len;
3807            _next_ordinal_to_read += 1;
3808            if next_offset >= end_offset {
3809                return Ok(());
3810            }
3811
3812            // Decode unknown envelopes for gaps in ordinals.
3813            while _next_ordinal_to_read < 1 {
3814                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3815                _next_ordinal_to_read += 1;
3816                next_offset += envelope_size;
3817            }
3818
3819            let next_out_of_line = decoder.next_out_of_line();
3820            let handles_before = decoder.remaining_handles();
3821            if let Some((inlined, num_bytes, num_handles)) =
3822                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3823            {
3824                let member_inline_size =
3825                    <fidl_fuchsia_mem::Buffer as fidl::encoding::TypeMarker>::inline_size(
3826                        decoder.context,
3827                    );
3828                if inlined != (member_inline_size <= 4) {
3829                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3830                }
3831                let inner_offset;
3832                let mut inner_depth = depth.clone();
3833                if inlined {
3834                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3835                    inner_offset = next_offset;
3836                } else {
3837                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3838                    inner_depth.increment()?;
3839                }
3840                let val_ref = self.buffer.get_or_insert_with(|| {
3841                    fidl::new_empty!(
3842                        fidl_fuchsia_mem::Buffer,
3843                        fidl::encoding::DefaultFuchsiaResourceDialect
3844                    )
3845                });
3846                fidl::decode!(
3847                    fidl_fuchsia_mem::Buffer,
3848                    fidl::encoding::DefaultFuchsiaResourceDialect,
3849                    val_ref,
3850                    decoder,
3851                    inner_offset,
3852                    inner_depth
3853                )?;
3854                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3855                {
3856                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3857                }
3858                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3859                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3860                }
3861            }
3862
3863            next_offset += envelope_size;
3864
3865            // Decode the remaining unknown envelopes.
3866            while next_offset < end_offset {
3867                _next_ordinal_to_read += 1;
3868                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3869                next_offset += envelope_size;
3870            }
3871
3872            Ok(())
3873        }
3874    }
3875}