Skip to main content

fidl_fuchsia_inspect/
fidl_fuchsia_inspect.rs

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