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