Skip to main content

fidl_fuchsia_memory_stacktrack_client/
fidl_fuchsia_memory_stacktrack_client.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_memory_stacktrack_client_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct CollectorGetStackTracesRequest {
16    /// The process to gather data about.
17    ///
18    /// If not set, any process will be considered a match.
19    pub process_selector: Option<ProcessSelector>,
20    /// The receiver that will accept the stack traces.
21    ///
22    /// Required.
23    pub receiver: Option<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>,
24    #[doc(hidden)]
25    pub __source_breaking: fidl::marker::SourceBreaking,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
29    for CollectorGetStackTracesRequest
30{
31}
32
33#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
34pub struct CollectorMarker;
35
36impl fidl::endpoints::ProtocolMarker for CollectorMarker {
37    type Proxy = CollectorProxy;
38    type RequestStream = CollectorRequestStream;
39    #[cfg(target_os = "fuchsia")]
40    type SynchronousProxy = CollectorSynchronousProxy;
41
42    const DEBUG_NAME: &'static str = "fuchsia.memory.stacktrack.client.Collector";
43}
44impl fidl::endpoints::DiscoverableProtocolMarker for CollectorMarker {}
45
46pub trait CollectorProxyInterface: Send + Sync {
47    fn r#get_stack_traces(
48        &self,
49        payload: CollectorGetStackTracesRequest,
50    ) -> Result<(), fidl::Error>;
51}
52#[derive(Debug)]
53#[cfg(target_os = "fuchsia")]
54pub struct CollectorSynchronousProxy {
55    client: fidl::client::sync::Client,
56}
57
58#[cfg(target_os = "fuchsia")]
59impl fidl::endpoints::SynchronousProxy for CollectorSynchronousProxy {
60    type Proxy = CollectorProxy;
61    type Protocol = CollectorMarker;
62
63    fn from_channel(inner: fidl::Channel) -> Self {
64        Self::new(inner)
65    }
66
67    fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    fn as_channel(&self) -> &fidl::Channel {
72        self.client.as_channel()
73    }
74}
75
76#[cfg(target_os = "fuchsia")]
77impl CollectorSynchronousProxy {
78    pub fn new(channel: fidl::Channel) -> Self {
79        Self { client: fidl::client::sync::Client::new(channel) }
80    }
81
82    pub fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    /// Waits until an event arrives and returns it. It is safe for other
87    /// threads to make concurrent requests while waiting for an event.
88    pub fn wait_for_event(
89        &self,
90        deadline: zx::MonotonicInstant,
91    ) -> Result<CollectorEvent, fidl::Error> {
92        CollectorEvent::decode(self.client.wait_for_event::<CollectorMarker>(deadline)?)
93    }
94
95    /// Returns stack traces for the specified process.
96    pub fn r#get_stack_traces(
97        &self,
98        mut payload: CollectorGetStackTracesRequest,
99    ) -> Result<(), fidl::Error> {
100        self.client.send::<CollectorGetStackTracesRequest>(
101            &mut payload,
102            0x1f23d82090761a91,
103            fidl::encoding::DynamicFlags::FLEXIBLE,
104        )
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl From<CollectorSynchronousProxy> for zx::NullableHandle {
110    fn from(value: CollectorSynchronousProxy) -> Self {
111        value.into_channel().into()
112    }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl From<fidl::Channel> for CollectorSynchronousProxy {
117    fn from(value: fidl::Channel) -> Self {
118        Self::new(value)
119    }
120}
121
122#[cfg(target_os = "fuchsia")]
123impl fidl::endpoints::FromClient for CollectorSynchronousProxy {
124    type Protocol = CollectorMarker;
125
126    fn from_client(value: fidl::endpoints::ClientEnd<CollectorMarker>) -> Self {
127        Self::new(value.into_channel())
128    }
129}
130
131#[derive(Debug, Clone)]
132pub struct CollectorProxy {
133    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
134}
135
136impl fidl::endpoints::Proxy for CollectorProxy {
137    type Protocol = CollectorMarker;
138
139    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
140        Self::new(inner)
141    }
142
143    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
144        self.client.into_channel().map_err(|client| Self { client })
145    }
146
147    fn as_channel(&self) -> &::fidl::AsyncChannel {
148        self.client.as_channel()
149    }
150}
151
152impl CollectorProxy {
153    /// Create a new Proxy for fuchsia.memory.stacktrack.client/Collector.
154    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
155        let protocol_name = <CollectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156        Self { client: fidl::client::Client::new(channel, protocol_name) }
157    }
158
159    /// Get a Stream of events from the remote end of the protocol.
160    ///
161    /// # Panics
162    ///
163    /// Panics if the event stream was already taken.
164    pub fn take_event_stream(&self) -> CollectorEventStream {
165        CollectorEventStream { event_receiver: self.client.take_event_receiver() }
166    }
167
168    /// Returns stack traces for the specified process.
169    pub fn r#get_stack_traces(
170        &self,
171        mut payload: CollectorGetStackTracesRequest,
172    ) -> Result<(), fidl::Error> {
173        CollectorProxyInterface::r#get_stack_traces(self, payload)
174    }
175}
176
177impl CollectorProxyInterface for CollectorProxy {
178    fn r#get_stack_traces(
179        &self,
180        mut payload: CollectorGetStackTracesRequest,
181    ) -> Result<(), fidl::Error> {
182        self.client.send::<CollectorGetStackTracesRequest>(
183            &mut payload,
184            0x1f23d82090761a91,
185            fidl::encoding::DynamicFlags::FLEXIBLE,
186        )
187    }
188}
189
190pub struct CollectorEventStream {
191    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
192}
193
194impl std::marker::Unpin for CollectorEventStream {}
195
196impl futures::stream::FusedStream for CollectorEventStream {
197    fn is_terminated(&self) -> bool {
198        self.event_receiver.is_terminated()
199    }
200}
201
202impl futures::Stream for CollectorEventStream {
203    type Item = Result<CollectorEvent, fidl::Error>;
204
205    fn poll_next(
206        mut self: std::pin::Pin<&mut Self>,
207        cx: &mut std::task::Context<'_>,
208    ) -> std::task::Poll<Option<Self::Item>> {
209        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
210            &mut self.event_receiver,
211            cx
212        )?) {
213            Some(buf) => std::task::Poll::Ready(Some(CollectorEvent::decode(buf))),
214            None => std::task::Poll::Ready(None),
215        }
216    }
217}
218
219#[derive(Debug)]
220pub enum CollectorEvent {
221    #[non_exhaustive]
222    _UnknownEvent {
223        /// Ordinal of the event that was sent.
224        ordinal: u64,
225    },
226}
227
228impl CollectorEvent {
229    /// Decodes a message buffer as a [`CollectorEvent`].
230    fn decode(
231        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
232    ) -> Result<CollectorEvent, fidl::Error> {
233        let (bytes, _handles) = buf.split_mut();
234        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
235        debug_assert_eq!(tx_header.tx_id, 0);
236        match tx_header.ordinal {
237            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
238                Ok(CollectorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
239            }
240            _ => Err(fidl::Error::UnknownOrdinal {
241                ordinal: tx_header.ordinal,
242                protocol_name: <CollectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
243            }),
244        }
245    }
246}
247
248/// A Stream of incoming requests for fuchsia.memory.stacktrack.client/Collector.
249pub struct CollectorRequestStream {
250    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
251    is_terminated: bool,
252}
253
254impl std::marker::Unpin for CollectorRequestStream {}
255
256impl futures::stream::FusedStream for CollectorRequestStream {
257    fn is_terminated(&self) -> bool {
258        self.is_terminated
259    }
260}
261
262impl fidl::endpoints::RequestStream for CollectorRequestStream {
263    type Protocol = CollectorMarker;
264    type ControlHandle = CollectorControlHandle;
265
266    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
267        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
268    }
269
270    fn control_handle(&self) -> Self::ControlHandle {
271        CollectorControlHandle { inner: self.inner.clone() }
272    }
273
274    fn into_inner(
275        self,
276    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
277    {
278        (self.inner, self.is_terminated)
279    }
280
281    fn from_inner(
282        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
283        is_terminated: bool,
284    ) -> Self {
285        Self { inner, is_terminated }
286    }
287}
288
289impl futures::Stream for CollectorRequestStream {
290    type Item = Result<CollectorRequest, fidl::Error>;
291
292    fn poll_next(
293        mut self: std::pin::Pin<&mut Self>,
294        cx: &mut std::task::Context<'_>,
295    ) -> std::task::Poll<Option<Self::Item>> {
296        let this = &mut *self;
297        if this.inner.check_shutdown(cx) {
298            this.is_terminated = true;
299            return std::task::Poll::Ready(None);
300        }
301        if this.is_terminated {
302            panic!("polled CollectorRequestStream after completion");
303        }
304        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
305            |bytes, handles| {
306                match this.inner.channel().read_etc(cx, bytes, handles) {
307                    std::task::Poll::Ready(Ok(())) => {}
308                    std::task::Poll::Pending => return std::task::Poll::Pending,
309                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
310                        this.is_terminated = true;
311                        return std::task::Poll::Ready(None);
312                    }
313                    std::task::Poll::Ready(Err(e)) => {
314                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
315                            e.into(),
316                        ))));
317                    }
318                }
319
320                // A message has been received from the channel
321                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
322
323                std::task::Poll::Ready(Some(match header.ordinal {
324                    0x1f23d82090761a91 => {
325                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
326                        let mut req = fidl::new_empty!(
327                            CollectorGetStackTracesRequest,
328                            fidl::encoding::DefaultFuchsiaResourceDialect
329                        );
330                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CollectorGetStackTracesRequest>(&header, _body_bytes, handles, &mut req)?;
331                        let control_handle = CollectorControlHandle { inner: this.inner.clone() };
332                        Ok(CollectorRequest::GetStackTraces { payload: req, control_handle })
333                    }
334                    _ if header.tx_id == 0
335                        && header
336                            .dynamic_flags()
337                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
338                    {
339                        Ok(CollectorRequest::_UnknownMethod {
340                            ordinal: header.ordinal,
341                            control_handle: CollectorControlHandle { inner: this.inner.clone() },
342                            method_type: fidl::MethodType::OneWay,
343                        })
344                    }
345                    _ if header
346                        .dynamic_flags()
347                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
348                    {
349                        this.inner.send_framework_err(
350                            fidl::encoding::FrameworkErr::UnknownMethod,
351                            header.tx_id,
352                            header.ordinal,
353                            header.dynamic_flags(),
354                            (bytes, handles),
355                        )?;
356                        Ok(CollectorRequest::_UnknownMethod {
357                            ordinal: header.ordinal,
358                            control_handle: CollectorControlHandle { inner: this.inner.clone() },
359                            method_type: fidl::MethodType::TwoWay,
360                        })
361                    }
362                    _ => Err(fidl::Error::UnknownOrdinal {
363                        ordinal: header.ordinal,
364                        protocol_name:
365                            <CollectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
366                    }),
367                }))
368            },
369        )
370    }
371}
372
373#[derive(Debug)]
374pub enum CollectorRequest {
375    /// Returns stack traces for the specified process.
376    GetStackTraces {
377        payload: CollectorGetStackTracesRequest,
378        control_handle: CollectorControlHandle,
379    },
380    /// An interaction was received which does not match any known method.
381    #[non_exhaustive]
382    _UnknownMethod {
383        /// Ordinal of the method that was called.
384        ordinal: u64,
385        control_handle: CollectorControlHandle,
386        method_type: fidl::MethodType,
387    },
388}
389
390impl CollectorRequest {
391    #[allow(irrefutable_let_patterns)]
392    pub fn into_get_stack_traces(
393        self,
394    ) -> Option<(CollectorGetStackTracesRequest, CollectorControlHandle)> {
395        if let CollectorRequest::GetStackTraces { payload, control_handle } = self {
396            Some((payload, control_handle))
397        } else {
398            None
399        }
400    }
401
402    /// Name of the method defined in FIDL
403    pub fn method_name(&self) -> &'static str {
404        match *self {
405            CollectorRequest::GetStackTraces { .. } => "get_stack_traces",
406            CollectorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
407                "unknown one-way method"
408            }
409            CollectorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
410                "unknown two-way method"
411            }
412        }
413    }
414}
415
416#[derive(Debug, Clone)]
417pub struct CollectorControlHandle {
418    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
419}
420
421impl CollectorControlHandle {
422    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
423        self.inner.shutdown_with_epitaph(status.into())
424    }
425}
426
427impl fidl::endpoints::ControlHandle for CollectorControlHandle {
428    fn shutdown(&self) {
429        self.inner.shutdown()
430    }
431
432    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
433        self.inner.shutdown_with_epitaph(status)
434    }
435
436    fn is_closed(&self) -> bool {
437        self.inner.channel().is_closed()
438    }
439    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
440        self.inner.channel().on_closed()
441    }
442
443    #[cfg(target_os = "fuchsia")]
444    fn signal_peer(
445        &self,
446        clear_mask: zx::Signals,
447        set_mask: zx::Signals,
448    ) -> Result<(), zx_status::Status> {
449        use fidl::Peered;
450        self.inner.channel().signal_peer(clear_mask, set_mask)
451    }
452}
453
454impl CollectorControlHandle {}
455
456#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
457pub struct SnapshotReceiverMarker;
458
459impl fidl::endpoints::ProtocolMarker for SnapshotReceiverMarker {
460    type Proxy = SnapshotReceiverProxy;
461    type RequestStream = SnapshotReceiverRequestStream;
462    #[cfg(target_os = "fuchsia")]
463    type SynchronousProxy = SnapshotReceiverSynchronousProxy;
464
465    const DEBUG_NAME: &'static str = "(anonymous) SnapshotReceiver";
466}
467
468pub trait SnapshotReceiverProxyInterface: Send + Sync {
469    type BatchResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
470    fn r#batch(&self, batch: &[SnapshotElement]) -> Self::BatchResponseFut;
471    type ReportErrorResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
472    fn r#report_error(&self, error: CollectorError) -> Self::ReportErrorResponseFut;
473}
474#[derive(Debug)]
475#[cfg(target_os = "fuchsia")]
476pub struct SnapshotReceiverSynchronousProxy {
477    client: fidl::client::sync::Client,
478}
479
480#[cfg(target_os = "fuchsia")]
481impl fidl::endpoints::SynchronousProxy for SnapshotReceiverSynchronousProxy {
482    type Proxy = SnapshotReceiverProxy;
483    type Protocol = SnapshotReceiverMarker;
484
485    fn from_channel(inner: fidl::Channel) -> Self {
486        Self::new(inner)
487    }
488
489    fn into_channel(self) -> fidl::Channel {
490        self.client.into_channel()
491    }
492
493    fn as_channel(&self) -> &fidl::Channel {
494        self.client.as_channel()
495    }
496}
497
498#[cfg(target_os = "fuchsia")]
499impl SnapshotReceiverSynchronousProxy {
500    pub fn new(channel: fidl::Channel) -> Self {
501        Self { client: fidl::client::sync::Client::new(channel) }
502    }
503
504    pub fn into_channel(self) -> fidl::Channel {
505        self.client.into_channel()
506    }
507
508    /// Waits until an event arrives and returns it. It is safe for other
509    /// threads to make concurrent requests while waiting for an event.
510    pub fn wait_for_event(
511        &self,
512        deadline: zx::MonotonicInstant,
513    ) -> Result<SnapshotReceiverEvent, fidl::Error> {
514        SnapshotReceiverEvent::decode(
515            self.client.wait_for_event::<SnapshotReceiverMarker>(deadline)?,
516        )
517    }
518
519    /// Delivers a batch of snapshot elements.
520    pub fn r#batch(
521        &self,
522        mut batch: &[SnapshotElement],
523        ___deadline: zx::MonotonicInstant,
524    ) -> Result<(), fidl::Error> {
525        let _response = self.client.send_query::<
526            SnapshotReceiverBatchRequest,
527            fidl::encoding::EmptyPayload,
528            SnapshotReceiverMarker,
529        >(
530            (batch,),
531            0x4251379bcb445d20,
532            fidl::encoding::DynamicFlags::empty(),
533            ___deadline,
534        )?;
535        Ok(_response)
536    }
537
538    /// Reports an error. No other batches or errors will follow.
539    pub fn r#report_error(
540        &self,
541        mut error: CollectorError,
542        ___deadline: zx::MonotonicInstant,
543    ) -> Result<(), fidl::Error> {
544        let _response = self.client.send_query::<
545            SnapshotReceiverReportErrorRequest,
546            fidl::encoding::EmptyPayload,
547            SnapshotReceiverMarker,
548        >(
549            (error,),
550            0x28423f6f135756ad,
551            fidl::encoding::DynamicFlags::empty(),
552            ___deadline,
553        )?;
554        Ok(_response)
555    }
556}
557
558#[cfg(target_os = "fuchsia")]
559impl From<SnapshotReceiverSynchronousProxy> for zx::NullableHandle {
560    fn from(value: SnapshotReceiverSynchronousProxy) -> Self {
561        value.into_channel().into()
562    }
563}
564
565#[cfg(target_os = "fuchsia")]
566impl From<fidl::Channel> for SnapshotReceiverSynchronousProxy {
567    fn from(value: fidl::Channel) -> Self {
568        Self::new(value)
569    }
570}
571
572#[cfg(target_os = "fuchsia")]
573impl fidl::endpoints::FromClient for SnapshotReceiverSynchronousProxy {
574    type Protocol = SnapshotReceiverMarker;
575
576    fn from_client(value: fidl::endpoints::ClientEnd<SnapshotReceiverMarker>) -> Self {
577        Self::new(value.into_channel())
578    }
579}
580
581#[derive(Debug, Clone)]
582pub struct SnapshotReceiverProxy {
583    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
584}
585
586impl fidl::endpoints::Proxy for SnapshotReceiverProxy {
587    type Protocol = SnapshotReceiverMarker;
588
589    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
590        Self::new(inner)
591    }
592
593    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
594        self.client.into_channel().map_err(|client| Self { client })
595    }
596
597    fn as_channel(&self) -> &::fidl::AsyncChannel {
598        self.client.as_channel()
599    }
600}
601
602impl SnapshotReceiverProxy {
603    /// Create a new Proxy for fuchsia.memory.stacktrack.client/SnapshotReceiver.
604    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
605        let protocol_name = <SnapshotReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
606        Self { client: fidl::client::Client::new(channel, protocol_name) }
607    }
608
609    /// Get a Stream of events from the remote end of the protocol.
610    ///
611    /// # Panics
612    ///
613    /// Panics if the event stream was already taken.
614    pub fn take_event_stream(&self) -> SnapshotReceiverEventStream {
615        SnapshotReceiverEventStream { event_receiver: self.client.take_event_receiver() }
616    }
617
618    /// Delivers a batch of snapshot elements.
619    pub fn r#batch(
620        &self,
621        mut batch: &[SnapshotElement],
622    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
623        SnapshotReceiverProxyInterface::r#batch(self, batch)
624    }
625
626    /// Reports an error. No other batches or errors will follow.
627    pub fn r#report_error(
628        &self,
629        mut error: CollectorError,
630    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
631        SnapshotReceiverProxyInterface::r#report_error(self, error)
632    }
633}
634
635impl SnapshotReceiverProxyInterface for SnapshotReceiverProxy {
636    type BatchResponseFut =
637        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
638    fn r#batch(&self, mut batch: &[SnapshotElement]) -> Self::BatchResponseFut {
639        fn _decode(
640            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
641        ) -> Result<(), fidl::Error> {
642            let _response = fidl::client::decode_transaction_body::<
643                fidl::encoding::EmptyPayload,
644                fidl::encoding::DefaultFuchsiaResourceDialect,
645                0x4251379bcb445d20,
646            >(_buf?)?;
647            Ok(_response)
648        }
649        self.client.send_query_and_decode::<SnapshotReceiverBatchRequest, ()>(
650            (batch,),
651            0x4251379bcb445d20,
652            fidl::encoding::DynamicFlags::empty(),
653            _decode,
654        )
655    }
656
657    type ReportErrorResponseFut =
658        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
659    fn r#report_error(&self, mut error: CollectorError) -> Self::ReportErrorResponseFut {
660        fn _decode(
661            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
662        ) -> Result<(), fidl::Error> {
663            let _response = fidl::client::decode_transaction_body::<
664                fidl::encoding::EmptyPayload,
665                fidl::encoding::DefaultFuchsiaResourceDialect,
666                0x28423f6f135756ad,
667            >(_buf?)?;
668            Ok(_response)
669        }
670        self.client.send_query_and_decode::<SnapshotReceiverReportErrorRequest, ()>(
671            (error,),
672            0x28423f6f135756ad,
673            fidl::encoding::DynamicFlags::empty(),
674            _decode,
675        )
676    }
677}
678
679pub struct SnapshotReceiverEventStream {
680    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
681}
682
683impl std::marker::Unpin for SnapshotReceiverEventStream {}
684
685impl futures::stream::FusedStream for SnapshotReceiverEventStream {
686    fn is_terminated(&self) -> bool {
687        self.event_receiver.is_terminated()
688    }
689}
690
691impl futures::Stream for SnapshotReceiverEventStream {
692    type Item = Result<SnapshotReceiverEvent, fidl::Error>;
693
694    fn poll_next(
695        mut self: std::pin::Pin<&mut Self>,
696        cx: &mut std::task::Context<'_>,
697    ) -> std::task::Poll<Option<Self::Item>> {
698        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
699            &mut self.event_receiver,
700            cx
701        )?) {
702            Some(buf) => std::task::Poll::Ready(Some(SnapshotReceiverEvent::decode(buf))),
703            None => std::task::Poll::Ready(None),
704        }
705    }
706}
707
708#[derive(Debug)]
709pub enum SnapshotReceiverEvent {}
710
711impl SnapshotReceiverEvent {
712    /// Decodes a message buffer as a [`SnapshotReceiverEvent`].
713    fn decode(
714        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
715    ) -> Result<SnapshotReceiverEvent, fidl::Error> {
716        let (bytes, _handles) = buf.split_mut();
717        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
718        debug_assert_eq!(tx_header.tx_id, 0);
719        match tx_header.ordinal {
720            _ => Err(fidl::Error::UnknownOrdinal {
721                ordinal: tx_header.ordinal,
722                protocol_name:
723                    <SnapshotReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
724            }),
725        }
726    }
727}
728
729/// A Stream of incoming requests for fuchsia.memory.stacktrack.client/SnapshotReceiver.
730pub struct SnapshotReceiverRequestStream {
731    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
732    is_terminated: bool,
733}
734
735impl std::marker::Unpin for SnapshotReceiverRequestStream {}
736
737impl futures::stream::FusedStream for SnapshotReceiverRequestStream {
738    fn is_terminated(&self) -> bool {
739        self.is_terminated
740    }
741}
742
743impl fidl::endpoints::RequestStream for SnapshotReceiverRequestStream {
744    type Protocol = SnapshotReceiverMarker;
745    type ControlHandle = SnapshotReceiverControlHandle;
746
747    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
748        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
749    }
750
751    fn control_handle(&self) -> Self::ControlHandle {
752        SnapshotReceiverControlHandle { inner: self.inner.clone() }
753    }
754
755    fn into_inner(
756        self,
757    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
758    {
759        (self.inner, self.is_terminated)
760    }
761
762    fn from_inner(
763        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
764        is_terminated: bool,
765    ) -> Self {
766        Self { inner, is_terminated }
767    }
768}
769
770impl futures::Stream for SnapshotReceiverRequestStream {
771    type Item = Result<SnapshotReceiverRequest, fidl::Error>;
772
773    fn poll_next(
774        mut self: std::pin::Pin<&mut Self>,
775        cx: &mut std::task::Context<'_>,
776    ) -> std::task::Poll<Option<Self::Item>> {
777        let this = &mut *self;
778        if this.inner.check_shutdown(cx) {
779            this.is_terminated = true;
780            return std::task::Poll::Ready(None);
781        }
782        if this.is_terminated {
783            panic!("polled SnapshotReceiverRequestStream after completion");
784        }
785        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
786            |bytes, handles| {
787                match this.inner.channel().read_etc(cx, bytes, handles) {
788                    std::task::Poll::Ready(Ok(())) => {}
789                    std::task::Poll::Pending => return std::task::Poll::Pending,
790                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
791                        this.is_terminated = true;
792                        return std::task::Poll::Ready(None);
793                    }
794                    std::task::Poll::Ready(Err(e)) => {
795                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
796                            e.into(),
797                        ))));
798                    }
799                }
800
801                // A message has been received from the channel
802                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
803
804                std::task::Poll::Ready(Some(match header.ordinal {
805                    0x4251379bcb445d20 => {
806                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
807                        let mut req = fidl::new_empty!(
808                            SnapshotReceiverBatchRequest,
809                            fidl::encoding::DefaultFuchsiaResourceDialect
810                        );
811                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnapshotReceiverBatchRequest>(&header, _body_bytes, handles, &mut req)?;
812                        let control_handle =
813                            SnapshotReceiverControlHandle { inner: this.inner.clone() };
814                        Ok(SnapshotReceiverRequest::Batch {
815                            batch: req.batch,
816
817                            responder: SnapshotReceiverBatchResponder {
818                                control_handle: std::mem::ManuallyDrop::new(control_handle),
819                                tx_id: header.tx_id,
820                            },
821                        })
822                    }
823                    0x28423f6f135756ad => {
824                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
825                        let mut req = fidl::new_empty!(
826                            SnapshotReceiverReportErrorRequest,
827                            fidl::encoding::DefaultFuchsiaResourceDialect
828                        );
829                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnapshotReceiverReportErrorRequest>(&header, _body_bytes, handles, &mut req)?;
830                        let control_handle =
831                            SnapshotReceiverControlHandle { inner: this.inner.clone() };
832                        Ok(SnapshotReceiverRequest::ReportError {
833                            error: req.error,
834
835                            responder: SnapshotReceiverReportErrorResponder {
836                                control_handle: std::mem::ManuallyDrop::new(control_handle),
837                                tx_id: header.tx_id,
838                            },
839                        })
840                    }
841                    _ => Err(fidl::Error::UnknownOrdinal {
842                        ordinal: header.ordinal,
843                        protocol_name:
844                            <SnapshotReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
845                    }),
846                }))
847            },
848        )
849    }
850}
851
852/// Protocol to transmit snapshot(s) as a stream of elements.
853#[derive(Debug)]
854pub enum SnapshotReceiverRequest {
855    /// Delivers a batch of snapshot elements.
856    Batch { batch: Vec<SnapshotElement>, responder: SnapshotReceiverBatchResponder },
857    /// Reports an error. No other batches or errors will follow.
858    ReportError { error: CollectorError, responder: SnapshotReceiverReportErrorResponder },
859}
860
861impl SnapshotReceiverRequest {
862    #[allow(irrefutable_let_patterns)]
863    pub fn into_batch(self) -> Option<(Vec<SnapshotElement>, SnapshotReceiverBatchResponder)> {
864        if let SnapshotReceiverRequest::Batch { batch, responder } = self {
865            Some((batch, responder))
866        } else {
867            None
868        }
869    }
870
871    #[allow(irrefutable_let_patterns)]
872    pub fn into_report_error(
873        self,
874    ) -> Option<(CollectorError, SnapshotReceiverReportErrorResponder)> {
875        if let SnapshotReceiverRequest::ReportError { error, responder } = self {
876            Some((error, responder))
877        } else {
878            None
879        }
880    }
881
882    /// Name of the method defined in FIDL
883    pub fn method_name(&self) -> &'static str {
884        match *self {
885            SnapshotReceiverRequest::Batch { .. } => "batch",
886            SnapshotReceiverRequest::ReportError { .. } => "report_error",
887        }
888    }
889}
890
891#[derive(Debug, Clone)]
892pub struct SnapshotReceiverControlHandle {
893    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
894}
895
896impl SnapshotReceiverControlHandle {
897    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
898        self.inner.shutdown_with_epitaph(status.into())
899    }
900}
901
902impl fidl::endpoints::ControlHandle for SnapshotReceiverControlHandle {
903    fn shutdown(&self) {
904        self.inner.shutdown()
905    }
906
907    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
908        self.inner.shutdown_with_epitaph(status)
909    }
910
911    fn is_closed(&self) -> bool {
912        self.inner.channel().is_closed()
913    }
914    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
915        self.inner.channel().on_closed()
916    }
917
918    #[cfg(target_os = "fuchsia")]
919    fn signal_peer(
920        &self,
921        clear_mask: zx::Signals,
922        set_mask: zx::Signals,
923    ) -> Result<(), zx_status::Status> {
924        use fidl::Peered;
925        self.inner.channel().signal_peer(clear_mask, set_mask)
926    }
927}
928
929impl SnapshotReceiverControlHandle {}
930
931#[must_use = "FIDL methods require a response to be sent"]
932#[derive(Debug)]
933pub struct SnapshotReceiverBatchResponder {
934    control_handle: std::mem::ManuallyDrop<SnapshotReceiverControlHandle>,
935    tx_id: u32,
936}
937
938/// Set the the channel to be shutdown (see [`SnapshotReceiverControlHandle::shutdown`])
939/// if the responder is dropped without sending a response, so that the client
940/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
941impl std::ops::Drop for SnapshotReceiverBatchResponder {
942    fn drop(&mut self) {
943        self.control_handle.shutdown();
944        // Safety: drops once, never accessed again
945        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
946    }
947}
948
949impl fidl::endpoints::Responder for SnapshotReceiverBatchResponder {
950    type ControlHandle = SnapshotReceiverControlHandle;
951
952    fn control_handle(&self) -> &SnapshotReceiverControlHandle {
953        &self.control_handle
954    }
955
956    fn drop_without_shutdown(mut self) {
957        // Safety: drops once, never accessed again due to mem::forget
958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
959        // Prevent Drop from running (which would shut down the channel)
960        std::mem::forget(self);
961    }
962}
963
964impl SnapshotReceiverBatchResponder {
965    /// Sends a response to the FIDL transaction.
966    ///
967    /// Sets the channel to shutdown if an error occurs.
968    pub fn send(self) -> Result<(), fidl::Error> {
969        let _result = self.send_raw();
970        if _result.is_err() {
971            self.control_handle.shutdown();
972        }
973        self.drop_without_shutdown();
974        _result
975    }
976
977    /// Similar to "send" but does not shutdown the channel if an error occurs.
978    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
979        let _result = self.send_raw();
980        self.drop_without_shutdown();
981        _result
982    }
983
984    fn send_raw(&self) -> Result<(), fidl::Error> {
985        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
986            (),
987            self.tx_id,
988            0x4251379bcb445d20,
989            fidl::encoding::DynamicFlags::empty(),
990        )
991    }
992}
993
994#[must_use = "FIDL methods require a response to be sent"]
995#[derive(Debug)]
996pub struct SnapshotReceiverReportErrorResponder {
997    control_handle: std::mem::ManuallyDrop<SnapshotReceiverControlHandle>,
998    tx_id: u32,
999}
1000
1001/// Set the the channel to be shutdown (see [`SnapshotReceiverControlHandle::shutdown`])
1002/// if the responder is dropped without sending a response, so that the client
1003/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1004impl std::ops::Drop for SnapshotReceiverReportErrorResponder {
1005    fn drop(&mut self) {
1006        self.control_handle.shutdown();
1007        // Safety: drops once, never accessed again
1008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1009    }
1010}
1011
1012impl fidl::endpoints::Responder for SnapshotReceiverReportErrorResponder {
1013    type ControlHandle = SnapshotReceiverControlHandle;
1014
1015    fn control_handle(&self) -> &SnapshotReceiverControlHandle {
1016        &self.control_handle
1017    }
1018
1019    fn drop_without_shutdown(mut self) {
1020        // Safety: drops once, never accessed again due to mem::forget
1021        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1022        // Prevent Drop from running (which would shut down the channel)
1023        std::mem::forget(self);
1024    }
1025}
1026
1027impl SnapshotReceiverReportErrorResponder {
1028    /// Sends a response to the FIDL transaction.
1029    ///
1030    /// Sets the channel to shutdown if an error occurs.
1031    pub fn send(self) -> Result<(), fidl::Error> {
1032        let _result = self.send_raw();
1033        if _result.is_err() {
1034            self.control_handle.shutdown();
1035        }
1036        self.drop_without_shutdown();
1037        _result
1038    }
1039
1040    /// Similar to "send" but does not shutdown the channel if an error occurs.
1041    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1042        let _result = self.send_raw();
1043        self.drop_without_shutdown();
1044        _result
1045    }
1046
1047    fn send_raw(&self) -> Result<(), fidl::Error> {
1048        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1049            (),
1050            self.tx_id,
1051            0x28423f6f135756ad,
1052            fidl::encoding::DynamicFlags::empty(),
1053        )
1054    }
1055}
1056
1057mod internal {
1058    use super::*;
1059
1060    impl CollectorGetStackTracesRequest {
1061        #[inline(always)]
1062        fn max_ordinal_present(&self) -> u64 {
1063            if let Some(_) = self.receiver {
1064                return 2;
1065            }
1066            if let Some(_) = self.process_selector {
1067                return 1;
1068            }
1069            0
1070        }
1071    }
1072
1073    impl fidl::encoding::ResourceTypeMarker for CollectorGetStackTracesRequest {
1074        type Borrowed<'a> = &'a mut Self;
1075        fn take_or_borrow<'a>(
1076            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1077        ) -> Self::Borrowed<'a> {
1078            value
1079        }
1080    }
1081
1082    unsafe impl fidl::encoding::TypeMarker for CollectorGetStackTracesRequest {
1083        type Owned = Self;
1084
1085        #[inline(always)]
1086        fn inline_align(_context: fidl::encoding::Context) -> usize {
1087            8
1088        }
1089
1090        #[inline(always)]
1091        fn inline_size(_context: fidl::encoding::Context) -> usize {
1092            16
1093        }
1094    }
1095
1096    unsafe impl
1097        fidl::encoding::Encode<
1098            CollectorGetStackTracesRequest,
1099            fidl::encoding::DefaultFuchsiaResourceDialect,
1100        > for &mut CollectorGetStackTracesRequest
1101    {
1102        unsafe fn encode(
1103            self,
1104            encoder: &mut fidl::encoding::Encoder<
1105                '_,
1106                fidl::encoding::DefaultFuchsiaResourceDialect,
1107            >,
1108            offset: usize,
1109            mut depth: fidl::encoding::Depth,
1110        ) -> fidl::Result<()> {
1111            encoder.debug_check_bounds::<CollectorGetStackTracesRequest>(offset);
1112            // Vector header
1113            let max_ordinal: u64 = self.max_ordinal_present();
1114            encoder.write_num(max_ordinal, offset);
1115            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1116            // Calling encoder.out_of_line_offset(0) is not allowed.
1117            if max_ordinal == 0 {
1118                return Ok(());
1119            }
1120            depth.increment()?;
1121            let envelope_size = 8;
1122            let bytes_len = max_ordinal as usize * envelope_size;
1123            #[allow(unused_variables)]
1124            let offset = encoder.out_of_line_offset(bytes_len);
1125            let mut _prev_end_offset: usize = 0;
1126            if 1 > max_ordinal {
1127                return Ok(());
1128            }
1129
1130            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1131            // are envelope_size bytes.
1132            let cur_offset: usize = (1 - 1) * envelope_size;
1133
1134            // Zero reserved fields.
1135            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1136
1137            // Safety:
1138            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1139            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1140            //   envelope_size bytes, there is always sufficient room.
1141            fidl::encoding::encode_in_envelope_optional::<
1142                ProcessSelector,
1143                fidl::encoding::DefaultFuchsiaResourceDialect,
1144            >(
1145                self.process_selector
1146                    .as_ref()
1147                    .map(<ProcessSelector as fidl::encoding::ValueTypeMarker>::borrow),
1148                encoder,
1149                offset + cur_offset,
1150                depth,
1151            )?;
1152
1153            _prev_end_offset = cur_offset + envelope_size;
1154            if 2 > max_ordinal {
1155                return Ok(());
1156            }
1157
1158            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1159            // are envelope_size bytes.
1160            let cur_offset: usize = (2 - 1) * envelope_size;
1161
1162            // Zero reserved fields.
1163            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1164
1165            // Safety:
1166            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1167            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1168            //   envelope_size bytes, there is always sufficient room.
1169            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1170            self.receiver.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1171            encoder, offset + cur_offset, depth
1172        )?;
1173
1174            _prev_end_offset = cur_offset + envelope_size;
1175
1176            Ok(())
1177        }
1178    }
1179
1180    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1181        for CollectorGetStackTracesRequest
1182    {
1183        #[inline(always)]
1184        fn new_empty() -> Self {
1185            Self::default()
1186        }
1187
1188        unsafe fn decode(
1189            &mut self,
1190            decoder: &mut fidl::encoding::Decoder<
1191                '_,
1192                fidl::encoding::DefaultFuchsiaResourceDialect,
1193            >,
1194            offset: usize,
1195            mut depth: fidl::encoding::Depth,
1196        ) -> fidl::Result<()> {
1197            decoder.debug_check_bounds::<Self>(offset);
1198            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1199                None => return Err(fidl::Error::NotNullable),
1200                Some(len) => len,
1201            };
1202            // Calling decoder.out_of_line_offset(0) is not allowed.
1203            if len == 0 {
1204                return Ok(());
1205            };
1206            depth.increment()?;
1207            let envelope_size = 8;
1208            let bytes_len = len * envelope_size;
1209            let offset = decoder.out_of_line_offset(bytes_len)?;
1210            // Decode the envelope for each type.
1211            let mut _next_ordinal_to_read = 0;
1212            let mut next_offset = offset;
1213            let end_offset = offset + bytes_len;
1214            _next_ordinal_to_read += 1;
1215            if next_offset >= end_offset {
1216                return Ok(());
1217            }
1218
1219            // Decode unknown envelopes for gaps in ordinals.
1220            while _next_ordinal_to_read < 1 {
1221                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1222                _next_ordinal_to_read += 1;
1223                next_offset += envelope_size;
1224            }
1225
1226            let next_out_of_line = decoder.next_out_of_line();
1227            let handles_before = decoder.remaining_handles();
1228            if let Some((inlined, num_bytes, num_handles)) =
1229                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1230            {
1231                let member_inline_size =
1232                    <ProcessSelector as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1233                if inlined != (member_inline_size <= 4) {
1234                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1235                }
1236                let inner_offset;
1237                let mut inner_depth = depth.clone();
1238                if inlined {
1239                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1240                    inner_offset = next_offset;
1241                } else {
1242                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1243                    inner_depth.increment()?;
1244                }
1245                let val_ref = self.process_selector.get_or_insert_with(|| {
1246                    fidl::new_empty!(ProcessSelector, fidl::encoding::DefaultFuchsiaResourceDialect)
1247                });
1248                fidl::decode!(
1249                    ProcessSelector,
1250                    fidl::encoding::DefaultFuchsiaResourceDialect,
1251                    val_ref,
1252                    decoder,
1253                    inner_offset,
1254                    inner_depth
1255                )?;
1256                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1257                {
1258                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1259                }
1260                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1261                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1262                }
1263            }
1264
1265            next_offset += envelope_size;
1266            _next_ordinal_to_read += 1;
1267            if next_offset >= end_offset {
1268                return Ok(());
1269            }
1270
1271            // Decode unknown envelopes for gaps in ordinals.
1272            while _next_ordinal_to_read < 2 {
1273                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1274                _next_ordinal_to_read += 1;
1275                next_offset += envelope_size;
1276            }
1277
1278            let next_out_of_line = decoder.next_out_of_line();
1279            let handles_before = decoder.remaining_handles();
1280            if let Some((inlined, num_bytes, num_handles)) =
1281                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1282            {
1283                let member_inline_size = <fidl::encoding::Endpoint<
1284                    fidl::endpoints::ClientEnd<SnapshotReceiverMarker>,
1285                > as fidl::encoding::TypeMarker>::inline_size(
1286                    decoder.context
1287                );
1288                if inlined != (member_inline_size <= 4) {
1289                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1290                }
1291                let inner_offset;
1292                let mut inner_depth = depth.clone();
1293                if inlined {
1294                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1295                    inner_offset = next_offset;
1296                } else {
1297                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1298                    inner_depth.increment()?;
1299                }
1300                let val_ref = self.receiver.get_or_insert_with(|| {
1301                    fidl::new_empty!(
1302                        fidl::encoding::Endpoint<
1303                            fidl::endpoints::ClientEnd<SnapshotReceiverMarker>,
1304                        >,
1305                        fidl::encoding::DefaultFuchsiaResourceDialect
1306                    )
1307                });
1308                fidl::decode!(
1309                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>,
1310                    fidl::encoding::DefaultFuchsiaResourceDialect,
1311                    val_ref,
1312                    decoder,
1313                    inner_offset,
1314                    inner_depth
1315                )?;
1316                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1317                {
1318                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1319                }
1320                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1321                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1322                }
1323            }
1324
1325            next_offset += envelope_size;
1326
1327            // Decode the remaining unknown envelopes.
1328            while next_offset < end_offset {
1329                _next_ordinal_to_read += 1;
1330                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1331                next_offset += envelope_size;
1332            }
1333
1334            Ok(())
1335        }
1336    }
1337}