fidl_fuchsia_process_lifecycle/
fidl_fuchsia_process_lifecycle.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_process_lifecycle__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct LifecycleOnEscrowRequest {
16    /// Escrow the outgoing directory server endpoint. Whenever the
17    /// component is started again, this will be returned as the
18    /// `PA_DIRECTORY_REQUEST` processargs entry.
19    pub outgoing_dir: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>>,
20    /// Escrow some user defined state. Whenever the component is started
21    /// again, this will be returned as the `PA_ESCROWED_DICTIONARY`
22    /// processargs entry.
23    ///
24    /// The framework will not wait for any signals on these objects.
25    ///
26    /// ## Example
27    ///
28    /// Let's say a component needs to escrow an event pair that represents
29    /// the result of some expensive calculation. It can create a
30    /// dictionary, put the event pair inside with an appropriate key
31    /// (e.g. `"my_event_pair"`), then check for that entry on startup.
32    pub escrowed_dictionary: Option<fidl_fuchsia_component_sandbox::DictionaryRef>,
33    #[doc(hidden)]
34    pub __source_breaking: fidl::marker::SourceBreaking,
35}
36
37impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LifecycleOnEscrowRequest {}
38
39#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
40pub struct LifecycleMarker;
41
42impl fidl::endpoints::ProtocolMarker for LifecycleMarker {
43    type Proxy = LifecycleProxy;
44    type RequestStream = LifecycleRequestStream;
45    #[cfg(target_os = "fuchsia")]
46    type SynchronousProxy = LifecycleSynchronousProxy;
47
48    const DEBUG_NAME: &'static str = "(anonymous) Lifecycle";
49}
50
51pub trait LifecycleProxyInterface: Send + Sync {
52    fn r#stop(&self) -> Result<(), fidl::Error>;
53}
54#[derive(Debug)]
55#[cfg(target_os = "fuchsia")]
56pub struct LifecycleSynchronousProxy {
57    client: fidl::client::sync::Client,
58}
59
60#[cfg(target_os = "fuchsia")]
61impl fidl::endpoints::SynchronousProxy for LifecycleSynchronousProxy {
62    type Proxy = LifecycleProxy;
63    type Protocol = LifecycleMarker;
64
65    fn from_channel(inner: fidl::Channel) -> Self {
66        Self::new(inner)
67    }
68
69    fn into_channel(self) -> fidl::Channel {
70        self.client.into_channel()
71    }
72
73    fn as_channel(&self) -> &fidl::Channel {
74        self.client.as_channel()
75    }
76}
77
78#[cfg(target_os = "fuchsia")]
79impl LifecycleSynchronousProxy {
80    pub fn new(channel: fidl::Channel) -> Self {
81        let protocol_name = <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
82        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
83    }
84
85    pub fn into_channel(self) -> fidl::Channel {
86        self.client.into_channel()
87    }
88
89    /// Waits until an event arrives and returns it. It is safe for other
90    /// threads to make concurrent requests while waiting for an event.
91    pub fn wait_for_event(
92        &self,
93        deadline: zx::MonotonicInstant,
94    ) -> Result<LifecycleEvent, fidl::Error> {
95        LifecycleEvent::decode(self.client.wait_for_event(deadline)?)
96    }
97
98    /// The process must clean up its state in preparation for termination, and
99    /// must close the channel hosting the `Lifecycle` protocol when it is
100    /// ready to be terminated. The process should exit after it completes its
101    /// cleanup. At the discretion of the system the process may be terminated
102    /// before it closes the `Lifecycle` channel.
103    pub fn r#stop(&self) -> Result<(), fidl::Error> {
104        self.client.send::<fidl::encoding::EmptyPayload>(
105            (),
106            0x64b176f1744c6f15,
107            fidl::encoding::DynamicFlags::empty(),
108        )
109    }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<LifecycleSynchronousProxy> for zx::NullableHandle {
114    fn from(value: LifecycleSynchronousProxy) -> Self {
115        value.into_channel().into()
116    }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<fidl::Channel> for LifecycleSynchronousProxy {
121    fn from(value: fidl::Channel) -> Self {
122        Self::new(value)
123    }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl fidl::endpoints::FromClient for LifecycleSynchronousProxy {
128    type Protocol = LifecycleMarker;
129
130    fn from_client(value: fidl::endpoints::ClientEnd<LifecycleMarker>) -> Self {
131        Self::new(value.into_channel())
132    }
133}
134
135#[derive(Debug, Clone)]
136pub struct LifecycleProxy {
137    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
138}
139
140impl fidl::endpoints::Proxy for LifecycleProxy {
141    type Protocol = LifecycleMarker;
142
143    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
144        Self::new(inner)
145    }
146
147    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
148        self.client.into_channel().map_err(|client| Self { client })
149    }
150
151    fn as_channel(&self) -> &::fidl::AsyncChannel {
152        self.client.as_channel()
153    }
154}
155
156impl LifecycleProxy {
157    /// Create a new Proxy for fuchsia.process.lifecycle/Lifecycle.
158    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
159        let protocol_name = <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
160        Self { client: fidl::client::Client::new(channel, protocol_name) }
161    }
162
163    /// Get a Stream of events from the remote end of the protocol.
164    ///
165    /// # Panics
166    ///
167    /// Panics if the event stream was already taken.
168    pub fn take_event_stream(&self) -> LifecycleEventStream {
169        LifecycleEventStream { event_receiver: self.client.take_event_receiver() }
170    }
171
172    /// The process must clean up its state in preparation for termination, and
173    /// must close the channel hosting the `Lifecycle` protocol when it is
174    /// ready to be terminated. The process should exit after it completes its
175    /// cleanup. At the discretion of the system the process may be terminated
176    /// before it closes the `Lifecycle` channel.
177    pub fn r#stop(&self) -> Result<(), fidl::Error> {
178        LifecycleProxyInterface::r#stop(self)
179    }
180}
181
182impl LifecycleProxyInterface for LifecycleProxy {
183    fn r#stop(&self) -> Result<(), fidl::Error> {
184        self.client.send::<fidl::encoding::EmptyPayload>(
185            (),
186            0x64b176f1744c6f15,
187            fidl::encoding::DynamicFlags::empty(),
188        )
189    }
190}
191
192pub struct LifecycleEventStream {
193    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
194}
195
196impl std::marker::Unpin for LifecycleEventStream {}
197
198impl futures::stream::FusedStream for LifecycleEventStream {
199    fn is_terminated(&self) -> bool {
200        self.event_receiver.is_terminated()
201    }
202}
203
204impl futures::Stream for LifecycleEventStream {
205    type Item = Result<LifecycleEvent, fidl::Error>;
206
207    fn poll_next(
208        mut self: std::pin::Pin<&mut Self>,
209        cx: &mut std::task::Context<'_>,
210    ) -> std::task::Poll<Option<Self::Item>> {
211        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
212            &mut self.event_receiver,
213            cx
214        )?) {
215            Some(buf) => std::task::Poll::Ready(Some(LifecycleEvent::decode(buf))),
216            None => std::task::Poll::Ready(None),
217        }
218    }
219}
220
221#[derive(Debug)]
222pub enum LifecycleEvent {
223    OnEscrow { payload: LifecycleOnEscrowRequest },
224}
225
226impl LifecycleEvent {
227    #[allow(irrefutable_let_patterns)]
228    pub fn into_on_escrow(self) -> Option<LifecycleOnEscrowRequest> {
229        if let LifecycleEvent::OnEscrow { payload } = self { Some((payload)) } else { None }
230    }
231
232    /// Decodes a message buffer as a [`LifecycleEvent`].
233    fn decode(
234        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
235    ) -> Result<LifecycleEvent, fidl::Error> {
236        let (bytes, _handles) = buf.split_mut();
237        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
238        debug_assert_eq!(tx_header.tx_id, 0);
239        match tx_header.ordinal {
240            0x3de9c2fcb734ed48 => {
241                let mut out = fidl::new_empty!(
242                    LifecycleOnEscrowRequest,
243                    fidl::encoding::DefaultFuchsiaResourceDialect
244                );
245                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LifecycleOnEscrowRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
246                Ok((LifecycleEvent::OnEscrow { payload: out }))
247            }
248            _ => Err(fidl::Error::UnknownOrdinal {
249                ordinal: tx_header.ordinal,
250                protocol_name: <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
251            }),
252        }
253    }
254}
255
256/// A Stream of incoming requests for fuchsia.process.lifecycle/Lifecycle.
257pub struct LifecycleRequestStream {
258    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
259    is_terminated: bool,
260}
261
262impl std::marker::Unpin for LifecycleRequestStream {}
263
264impl futures::stream::FusedStream for LifecycleRequestStream {
265    fn is_terminated(&self) -> bool {
266        self.is_terminated
267    }
268}
269
270impl fidl::endpoints::RequestStream for LifecycleRequestStream {
271    type Protocol = LifecycleMarker;
272    type ControlHandle = LifecycleControlHandle;
273
274    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
275        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
276    }
277
278    fn control_handle(&self) -> Self::ControlHandle {
279        LifecycleControlHandle { inner: self.inner.clone() }
280    }
281
282    fn into_inner(
283        self,
284    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
285    {
286        (self.inner, self.is_terminated)
287    }
288
289    fn from_inner(
290        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
291        is_terminated: bool,
292    ) -> Self {
293        Self { inner, is_terminated }
294    }
295}
296
297impl futures::Stream for LifecycleRequestStream {
298    type Item = Result<LifecycleRequest, fidl::Error>;
299
300    fn poll_next(
301        mut self: std::pin::Pin<&mut Self>,
302        cx: &mut std::task::Context<'_>,
303    ) -> std::task::Poll<Option<Self::Item>> {
304        let this = &mut *self;
305        if this.inner.check_shutdown(cx) {
306            this.is_terminated = true;
307            return std::task::Poll::Ready(None);
308        }
309        if this.is_terminated {
310            panic!("polled LifecycleRequestStream after completion");
311        }
312        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
313            |bytes, handles| {
314                match this.inner.channel().read_etc(cx, bytes, handles) {
315                    std::task::Poll::Ready(Ok(())) => {}
316                    std::task::Poll::Pending => return std::task::Poll::Pending,
317                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
318                        this.is_terminated = true;
319                        return std::task::Poll::Ready(None);
320                    }
321                    std::task::Poll::Ready(Err(e)) => {
322                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
323                            e.into(),
324                        ))));
325                    }
326                }
327
328                // A message has been received from the channel
329                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
330
331                std::task::Poll::Ready(Some(match header.ordinal {
332                    0x64b176f1744c6f15 => {
333                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
334                        let mut req = fidl::new_empty!(
335                            fidl::encoding::EmptyPayload,
336                            fidl::encoding::DefaultFuchsiaResourceDialect
337                        );
338                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
339                        let control_handle = LifecycleControlHandle { inner: this.inner.clone() };
340                        Ok(LifecycleRequest::Stop { control_handle })
341                    }
342                    _ => Err(fidl::Error::UnknownOrdinal {
343                        ordinal: header.ordinal,
344                        protocol_name:
345                            <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
346                    }),
347                }))
348            },
349        )
350    }
351}
352
353/// A component can implement the Lifecycle protocol to be notified of lifecycle
354/// events. It can also store some state in the framework, to be redelivered to
355/// the component the next time it is started (a practice called "escrowing").
356///
357/// The ELF Runner uses this protocol to communicate lifecycle changes
358/// to the component, for more details on how it uses this protocol see:
359/// https://fuchsia.dev/fuchsia-src/concepts/components/v2/elf_runner#lifecycle
360#[derive(Debug)]
361pub enum LifecycleRequest {
362    /// The process must clean up its state in preparation for termination, and
363    /// must close the channel hosting the `Lifecycle` protocol when it is
364    /// ready to be terminated. The process should exit after it completes its
365    /// cleanup. At the discretion of the system the process may be terminated
366    /// before it closes the `Lifecycle` channel.
367    Stop { control_handle: LifecycleControlHandle },
368}
369
370impl LifecycleRequest {
371    #[allow(irrefutable_let_patterns)]
372    pub fn into_stop(self) -> Option<(LifecycleControlHandle)> {
373        if let LifecycleRequest::Stop { control_handle } = self {
374            Some((control_handle))
375        } else {
376            None
377        }
378    }
379
380    /// Name of the method defined in FIDL
381    pub fn method_name(&self) -> &'static str {
382        match *self {
383            LifecycleRequest::Stop { .. } => "stop",
384        }
385    }
386}
387
388#[derive(Debug, Clone)]
389pub struct LifecycleControlHandle {
390    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
391}
392
393impl fidl::endpoints::ControlHandle for LifecycleControlHandle {
394    fn shutdown(&self) {
395        self.inner.shutdown()
396    }
397
398    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
399        self.inner.shutdown_with_epitaph(status)
400    }
401
402    fn is_closed(&self) -> bool {
403        self.inner.channel().is_closed()
404    }
405    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
406        self.inner.channel().on_closed()
407    }
408
409    #[cfg(target_os = "fuchsia")]
410    fn signal_peer(
411        &self,
412        clear_mask: zx::Signals,
413        set_mask: zx::Signals,
414    ) -> Result<(), zx_status::Status> {
415        use fidl::Peered;
416        self.inner.channel().signal_peer(clear_mask, set_mask)
417    }
418}
419
420impl LifecycleControlHandle {
421    pub fn send_on_escrow(&self, mut payload: LifecycleOnEscrowRequest) -> Result<(), fidl::Error> {
422        self.inner.send::<LifecycleOnEscrowRequest>(
423            &mut payload,
424            0,
425            0x3de9c2fcb734ed48,
426            fidl::encoding::DynamicFlags::empty(),
427        )
428    }
429}
430
431mod internal {
432    use super::*;
433
434    impl LifecycleOnEscrowRequest {
435        #[inline(always)]
436        fn max_ordinal_present(&self) -> u64 {
437            if let Some(_) = self.escrowed_dictionary {
438                return 2;
439            }
440            if let Some(_) = self.outgoing_dir {
441                return 1;
442            }
443            0
444        }
445    }
446
447    impl fidl::encoding::ResourceTypeMarker for LifecycleOnEscrowRequest {
448        type Borrowed<'a> = &'a mut Self;
449        fn take_or_borrow<'a>(
450            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
451        ) -> Self::Borrowed<'a> {
452            value
453        }
454    }
455
456    unsafe impl fidl::encoding::TypeMarker for LifecycleOnEscrowRequest {
457        type Owned = Self;
458
459        #[inline(always)]
460        fn inline_align(_context: fidl::encoding::Context) -> usize {
461            8
462        }
463
464        #[inline(always)]
465        fn inline_size(_context: fidl::encoding::Context) -> usize {
466            16
467        }
468    }
469
470    unsafe impl
471        fidl::encoding::Encode<
472            LifecycleOnEscrowRequest,
473            fidl::encoding::DefaultFuchsiaResourceDialect,
474        > for &mut LifecycleOnEscrowRequest
475    {
476        unsafe fn encode(
477            self,
478            encoder: &mut fidl::encoding::Encoder<
479                '_,
480                fidl::encoding::DefaultFuchsiaResourceDialect,
481            >,
482            offset: usize,
483            mut depth: fidl::encoding::Depth,
484        ) -> fidl::Result<()> {
485            encoder.debug_check_bounds::<LifecycleOnEscrowRequest>(offset);
486            // Vector header
487            let max_ordinal: u64 = self.max_ordinal_present();
488            encoder.write_num(max_ordinal, offset);
489            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
490            // Calling encoder.out_of_line_offset(0) is not allowed.
491            if max_ordinal == 0 {
492                return Ok(());
493            }
494            depth.increment()?;
495            let envelope_size = 8;
496            let bytes_len = max_ordinal as usize * envelope_size;
497            #[allow(unused_variables)]
498            let offset = encoder.out_of_line_offset(bytes_len);
499            let mut _prev_end_offset: usize = 0;
500            if 1 > max_ordinal {
501                return Ok(());
502            }
503
504            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
505            // are envelope_size bytes.
506            let cur_offset: usize = (1 - 1) * envelope_size;
507
508            // Zero reserved fields.
509            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
510
511            // Safety:
512            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
513            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
514            //   envelope_size bytes, there is always sufficient room.
515            fidl::encoding::encode_in_envelope_optional::<
516                fidl::encoding::Endpoint<
517                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
518                >,
519                fidl::encoding::DefaultFuchsiaResourceDialect,
520            >(
521                self.outgoing_dir.as_mut().map(
522                    <fidl::encoding::Endpoint<
523                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
524                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
525                ),
526                encoder,
527                offset + cur_offset,
528                depth,
529            )?;
530
531            _prev_end_offset = cur_offset + envelope_size;
532            if 2 > max_ordinal {
533                return Ok(());
534            }
535
536            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
537            // are envelope_size bytes.
538            let cur_offset: usize = (2 - 1) * envelope_size;
539
540            // Zero reserved fields.
541            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
542
543            // Safety:
544            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
545            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
546            //   envelope_size bytes, there is always sufficient room.
547            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_component_sandbox::DictionaryRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
548            self.escrowed_dictionary.as_mut().map(<fidl_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
549            encoder, offset + cur_offset, depth
550        )?;
551
552            _prev_end_offset = cur_offset + envelope_size;
553
554            Ok(())
555        }
556    }
557
558    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
559        for LifecycleOnEscrowRequest
560    {
561        #[inline(always)]
562        fn new_empty() -> Self {
563            Self::default()
564        }
565
566        unsafe fn decode(
567            &mut self,
568            decoder: &mut fidl::encoding::Decoder<
569                '_,
570                fidl::encoding::DefaultFuchsiaResourceDialect,
571            >,
572            offset: usize,
573            mut depth: fidl::encoding::Depth,
574        ) -> fidl::Result<()> {
575            decoder.debug_check_bounds::<Self>(offset);
576            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
577                None => return Err(fidl::Error::NotNullable),
578                Some(len) => len,
579            };
580            // Calling decoder.out_of_line_offset(0) is not allowed.
581            if len == 0 {
582                return Ok(());
583            };
584            depth.increment()?;
585            let envelope_size = 8;
586            let bytes_len = len * envelope_size;
587            let offset = decoder.out_of_line_offset(bytes_len)?;
588            // Decode the envelope for each type.
589            let mut _next_ordinal_to_read = 0;
590            let mut next_offset = offset;
591            let end_offset = offset + bytes_len;
592            _next_ordinal_to_read += 1;
593            if next_offset >= end_offset {
594                return Ok(());
595            }
596
597            // Decode unknown envelopes for gaps in ordinals.
598            while _next_ordinal_to_read < 1 {
599                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
600                _next_ordinal_to_read += 1;
601                next_offset += envelope_size;
602            }
603
604            let next_out_of_line = decoder.next_out_of_line();
605            let handles_before = decoder.remaining_handles();
606            if let Some((inlined, num_bytes, num_handles)) =
607                fidl::encoding::decode_envelope_header(decoder, next_offset)?
608            {
609                let member_inline_size = <fidl::encoding::Endpoint<
610                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
611                > as fidl::encoding::TypeMarker>::inline_size(
612                    decoder.context
613                );
614                if inlined != (member_inline_size <= 4) {
615                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
616                }
617                let inner_offset;
618                let mut inner_depth = depth.clone();
619                if inlined {
620                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
621                    inner_offset = next_offset;
622                } else {
623                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
624                    inner_depth.increment()?;
625                }
626                let val_ref = self.outgoing_dir.get_or_insert_with(|| {
627                    fidl::new_empty!(
628                        fidl::encoding::Endpoint<
629                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
630                        >,
631                        fidl::encoding::DefaultFuchsiaResourceDialect
632                    )
633                });
634                fidl::decode!(
635                    fidl::encoding::Endpoint<
636                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
637                    >,
638                    fidl::encoding::DefaultFuchsiaResourceDialect,
639                    val_ref,
640                    decoder,
641                    inner_offset,
642                    inner_depth
643                )?;
644                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
645                {
646                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
647                }
648                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
649                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
650                }
651            }
652
653            next_offset += envelope_size;
654            _next_ordinal_to_read += 1;
655            if next_offset >= end_offset {
656                return Ok(());
657            }
658
659            // Decode unknown envelopes for gaps in ordinals.
660            while _next_ordinal_to_read < 2 {
661                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
662                _next_ordinal_to_read += 1;
663                next_offset += envelope_size;
664            }
665
666            let next_out_of_line = decoder.next_out_of_line();
667            let handles_before = decoder.remaining_handles();
668            if let Some((inlined, num_bytes, num_handles)) =
669                fidl::encoding::decode_envelope_header(decoder, next_offset)?
670            {
671                let member_inline_size = <fidl_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
672                if inlined != (member_inline_size <= 4) {
673                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
674                }
675                let inner_offset;
676                let mut inner_depth = depth.clone();
677                if inlined {
678                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
679                    inner_offset = next_offset;
680                } else {
681                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
682                    inner_depth.increment()?;
683                }
684                let val_ref = self.escrowed_dictionary.get_or_insert_with(|| {
685                    fidl::new_empty!(
686                        fidl_fuchsia_component_sandbox::DictionaryRef,
687                        fidl::encoding::DefaultFuchsiaResourceDialect
688                    )
689                });
690                fidl::decode!(
691                    fidl_fuchsia_component_sandbox::DictionaryRef,
692                    fidl::encoding::DefaultFuchsiaResourceDialect,
693                    val_ref,
694                    decoder,
695                    inner_offset,
696                    inner_depth
697                )?;
698                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
699                {
700                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
701                }
702                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
703                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
704                }
705            }
706
707            next_offset += envelope_size;
708
709            // Decode the remaining unknown envelopes.
710            while next_offset < end_offset {
711                _next_ordinal_to_read += 1;
712                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
713                next_offset += envelope_size;
714            }
715
716            Ok(())
717        }
718    }
719}