fidl_fuchsia_memory_heapdump_client/
fidl_fuchsia_memory_heapdump_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_heapdump_client_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct CollectorDownloadStoredSnapshotRequest {
16    /// The identifier of the snapshot to be downloaded.
17    ///
18    /// The list of the available snapshots can be retrieved with ListStoredSnapshots.
19    ///
20    /// Required.
21    pub snapshot_id: Option<u32>,
22    /// Where the elements of the requested snapshot will be sent to.
23    ///
24    /// Required.
25    pub receiver: Option<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>,
26    #[doc(hidden)]
27    pub __source_breaking: fidl::marker::SourceBreaking,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for CollectorDownloadStoredSnapshotRequest
32{
33}
34
35#[derive(Debug, Default, PartialEq)]
36pub struct CollectorListStoredSnapshotsRequest {
37    /// The server_end of the StoredSnapshotIterator that will be used to retrieve the results.
38    ///
39    /// Required.
40    pub iterator: Option<fidl::endpoints::ServerEnd<StoredSnapshotIteratorMarker>>,
41    /// If present, only retrieve snapshots that refer to matching processes.
42    pub process_selector: Option<ProcessSelector>,
43    #[doc(hidden)]
44    pub __source_breaking: fidl::marker::SourceBreaking,
45}
46
47impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
48    for CollectorListStoredSnapshotsRequest
49{
50}
51
52#[derive(Debug, Default, PartialEq)]
53pub struct CollectorTakeLiveSnapshotRequest {
54    /// The instrumented process to operate on.
55    ///
56    /// Required.
57    pub process_selector: Option<ProcessSelector>,
58    /// Where the elements of the requested snapshot will be sent to.
59    ///
60    /// Required.
61    pub receiver: Option<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>,
62    /// Whether the snapshot should include the contents of each memory block.
63    ///
64    /// If not set, false is assumed.
65    pub with_contents: Option<bool>,
66    #[doc(hidden)]
67    pub __source_breaking: fidl::marker::SourceBreaking,
68}
69
70impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
71    for CollectorTakeLiveSnapshotRequest
72{
73}
74
75#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
76pub struct CollectorMarker;
77
78impl fidl::endpoints::ProtocolMarker for CollectorMarker {
79    type Proxy = CollectorProxy;
80    type RequestStream = CollectorRequestStream;
81    #[cfg(target_os = "fuchsia")]
82    type SynchronousProxy = CollectorSynchronousProxy;
83
84    const DEBUG_NAME: &'static str = "fuchsia.memory.heapdump.client.Collector";
85}
86impl fidl::endpoints::DiscoverableProtocolMarker for CollectorMarker {}
87
88pub trait CollectorProxyInterface: Send + Sync {
89    fn r#take_live_snapshot(
90        &self,
91        payload: CollectorTakeLiveSnapshotRequest,
92    ) -> Result<(), fidl::Error>;
93    fn r#list_stored_snapshots(
94        &self,
95        payload: CollectorListStoredSnapshotsRequest,
96    ) -> Result<(), fidl::Error>;
97    fn r#download_stored_snapshot(
98        &self,
99        payload: CollectorDownloadStoredSnapshotRequest,
100    ) -> Result<(), fidl::Error>;
101}
102#[derive(Debug)]
103#[cfg(target_os = "fuchsia")]
104pub struct CollectorSynchronousProxy {
105    client: fidl::client::sync::Client,
106}
107
108#[cfg(target_os = "fuchsia")]
109impl fidl::endpoints::SynchronousProxy for CollectorSynchronousProxy {
110    type Proxy = CollectorProxy;
111    type Protocol = CollectorMarker;
112
113    fn from_channel(inner: fidl::Channel) -> Self {
114        Self::new(inner)
115    }
116
117    fn into_channel(self) -> fidl::Channel {
118        self.client.into_channel()
119    }
120
121    fn as_channel(&self) -> &fidl::Channel {
122        self.client.as_channel()
123    }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl CollectorSynchronousProxy {
128    pub fn new(channel: fidl::Channel) -> Self {
129        let protocol_name = <CollectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
130        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
131    }
132
133    pub fn into_channel(self) -> fidl::Channel {
134        self.client.into_channel()
135    }
136
137    /// Waits until an event arrives and returns it. It is safe for other
138    /// threads to make concurrent requests while waiting for an event.
139    pub fn wait_for_event(
140        &self,
141        deadline: zx::MonotonicInstant,
142    ) -> Result<CollectorEvent, fidl::Error> {
143        CollectorEvent::decode(self.client.wait_for_event(deadline)?)
144    }
145
146    /// Obtains a snapshot of the current live allocations in an instrumented process.
147    pub fn r#take_live_snapshot(
148        &self,
149        mut payload: CollectorTakeLiveSnapshotRequest,
150    ) -> Result<(), fidl::Error> {
151        self.client.send::<CollectorTakeLiveSnapshotRequest>(
152            &mut payload,
153            0xa581ff8b75eaea3,
154            fidl::encoding::DynamicFlags::FLEXIBLE,
155        )
156    }
157
158    /// Retrieves the list of all the available stored snapshots.
159    pub fn r#list_stored_snapshots(
160        &self,
161        mut payload: CollectorListStoredSnapshotsRequest,
162    ) -> Result<(), fidl::Error> {
163        self.client.send::<CollectorListStoredSnapshotsRequest>(
164            &mut payload,
165            0x13fd9211708b42e6,
166            fidl::encoding::DynamicFlags::FLEXIBLE,
167        )
168    }
169
170    /// Retrieves a stored snapshot.
171    pub fn r#download_stored_snapshot(
172        &self,
173        mut payload: CollectorDownloadStoredSnapshotRequest,
174    ) -> Result<(), fidl::Error> {
175        self.client.send::<CollectorDownloadStoredSnapshotRequest>(
176            &mut payload,
177            0x48e9792c6f7f1c2e,
178            fidl::encoding::DynamicFlags::FLEXIBLE,
179        )
180    }
181}
182
183#[derive(Debug, Clone)]
184pub struct CollectorProxy {
185    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
186}
187
188impl fidl::endpoints::Proxy for CollectorProxy {
189    type Protocol = CollectorMarker;
190
191    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
192        Self::new(inner)
193    }
194
195    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
196        self.client.into_channel().map_err(|client| Self { client })
197    }
198
199    fn as_channel(&self) -> &::fidl::AsyncChannel {
200        self.client.as_channel()
201    }
202}
203
204impl CollectorProxy {
205    /// Create a new Proxy for fuchsia.memory.heapdump.client/Collector.
206    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
207        let protocol_name = <CollectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
208        Self { client: fidl::client::Client::new(channel, protocol_name) }
209    }
210
211    /// Get a Stream of events from the remote end of the protocol.
212    ///
213    /// # Panics
214    ///
215    /// Panics if the event stream was already taken.
216    pub fn take_event_stream(&self) -> CollectorEventStream {
217        CollectorEventStream { event_receiver: self.client.take_event_receiver() }
218    }
219
220    /// Obtains a snapshot of the current live allocations in an instrumented process.
221    pub fn r#take_live_snapshot(
222        &self,
223        mut payload: CollectorTakeLiveSnapshotRequest,
224    ) -> Result<(), fidl::Error> {
225        CollectorProxyInterface::r#take_live_snapshot(self, payload)
226    }
227
228    /// Retrieves the list of all the available stored snapshots.
229    pub fn r#list_stored_snapshots(
230        &self,
231        mut payload: CollectorListStoredSnapshotsRequest,
232    ) -> Result<(), fidl::Error> {
233        CollectorProxyInterface::r#list_stored_snapshots(self, payload)
234    }
235
236    /// Retrieves a stored snapshot.
237    pub fn r#download_stored_snapshot(
238        &self,
239        mut payload: CollectorDownloadStoredSnapshotRequest,
240    ) -> Result<(), fidl::Error> {
241        CollectorProxyInterface::r#download_stored_snapshot(self, payload)
242    }
243}
244
245impl CollectorProxyInterface for CollectorProxy {
246    fn r#take_live_snapshot(
247        &self,
248        mut payload: CollectorTakeLiveSnapshotRequest,
249    ) -> Result<(), fidl::Error> {
250        self.client.send::<CollectorTakeLiveSnapshotRequest>(
251            &mut payload,
252            0xa581ff8b75eaea3,
253            fidl::encoding::DynamicFlags::FLEXIBLE,
254        )
255    }
256
257    fn r#list_stored_snapshots(
258        &self,
259        mut payload: CollectorListStoredSnapshotsRequest,
260    ) -> Result<(), fidl::Error> {
261        self.client.send::<CollectorListStoredSnapshotsRequest>(
262            &mut payload,
263            0x13fd9211708b42e6,
264            fidl::encoding::DynamicFlags::FLEXIBLE,
265        )
266    }
267
268    fn r#download_stored_snapshot(
269        &self,
270        mut payload: CollectorDownloadStoredSnapshotRequest,
271    ) -> Result<(), fidl::Error> {
272        self.client.send::<CollectorDownloadStoredSnapshotRequest>(
273            &mut payload,
274            0x48e9792c6f7f1c2e,
275            fidl::encoding::DynamicFlags::FLEXIBLE,
276        )
277    }
278}
279
280pub struct CollectorEventStream {
281    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
282}
283
284impl std::marker::Unpin for CollectorEventStream {}
285
286impl futures::stream::FusedStream for CollectorEventStream {
287    fn is_terminated(&self) -> bool {
288        self.event_receiver.is_terminated()
289    }
290}
291
292impl futures::Stream for CollectorEventStream {
293    type Item = Result<CollectorEvent, fidl::Error>;
294
295    fn poll_next(
296        mut self: std::pin::Pin<&mut Self>,
297        cx: &mut std::task::Context<'_>,
298    ) -> std::task::Poll<Option<Self::Item>> {
299        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
300            &mut self.event_receiver,
301            cx
302        )?) {
303            Some(buf) => std::task::Poll::Ready(Some(CollectorEvent::decode(buf))),
304            None => std::task::Poll::Ready(None),
305        }
306    }
307}
308
309#[derive(Debug)]
310pub enum CollectorEvent {
311    #[non_exhaustive]
312    _UnknownEvent {
313        /// Ordinal of the event that was sent.
314        ordinal: u64,
315    },
316}
317
318impl CollectorEvent {
319    /// Decodes a message buffer as a [`CollectorEvent`].
320    fn decode(
321        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
322    ) -> Result<CollectorEvent, fidl::Error> {
323        let (bytes, _handles) = buf.split_mut();
324        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
325        debug_assert_eq!(tx_header.tx_id, 0);
326        match tx_header.ordinal {
327            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
328                Ok(CollectorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
329            }
330            _ => Err(fidl::Error::UnknownOrdinal {
331                ordinal: tx_header.ordinal,
332                protocol_name: <CollectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
333            }),
334        }
335    }
336}
337
338/// A Stream of incoming requests for fuchsia.memory.heapdump.client/Collector.
339pub struct CollectorRequestStream {
340    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
341    is_terminated: bool,
342}
343
344impl std::marker::Unpin for CollectorRequestStream {}
345
346impl futures::stream::FusedStream for CollectorRequestStream {
347    fn is_terminated(&self) -> bool {
348        self.is_terminated
349    }
350}
351
352impl fidl::endpoints::RequestStream for CollectorRequestStream {
353    type Protocol = CollectorMarker;
354    type ControlHandle = CollectorControlHandle;
355
356    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
357        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
358    }
359
360    fn control_handle(&self) -> Self::ControlHandle {
361        CollectorControlHandle { inner: self.inner.clone() }
362    }
363
364    fn into_inner(
365        self,
366    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
367    {
368        (self.inner, self.is_terminated)
369    }
370
371    fn from_inner(
372        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
373        is_terminated: bool,
374    ) -> Self {
375        Self { inner, is_terminated }
376    }
377}
378
379impl futures::Stream for CollectorRequestStream {
380    type Item = Result<CollectorRequest, fidl::Error>;
381
382    fn poll_next(
383        mut self: std::pin::Pin<&mut Self>,
384        cx: &mut std::task::Context<'_>,
385    ) -> std::task::Poll<Option<Self::Item>> {
386        let this = &mut *self;
387        if this.inner.check_shutdown(cx) {
388            this.is_terminated = true;
389            return std::task::Poll::Ready(None);
390        }
391        if this.is_terminated {
392            panic!("polled CollectorRequestStream after completion");
393        }
394        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
395            |bytes, handles| {
396                match this.inner.channel().read_etc(cx, bytes, handles) {
397                    std::task::Poll::Ready(Ok(())) => {}
398                    std::task::Poll::Pending => return std::task::Poll::Pending,
399                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
400                        this.is_terminated = true;
401                        return std::task::Poll::Ready(None);
402                    }
403                    std::task::Poll::Ready(Err(e)) => {
404                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
405                            e.into(),
406                        ))))
407                    }
408                }
409
410                // A message has been received from the channel
411                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
412
413                std::task::Poll::Ready(Some(match header.ordinal {
414                    0xa581ff8b75eaea3 => {
415                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
416                        let mut req = fidl::new_empty!(
417                            CollectorTakeLiveSnapshotRequest,
418                            fidl::encoding::DefaultFuchsiaResourceDialect
419                        );
420                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CollectorTakeLiveSnapshotRequest>(&header, _body_bytes, handles, &mut req)?;
421                        let control_handle = CollectorControlHandle { inner: this.inner.clone() };
422                        Ok(CollectorRequest::TakeLiveSnapshot { payload: req, control_handle })
423                    }
424                    0x13fd9211708b42e6 => {
425                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
426                        let mut req = fidl::new_empty!(
427                            CollectorListStoredSnapshotsRequest,
428                            fidl::encoding::DefaultFuchsiaResourceDialect
429                        );
430                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CollectorListStoredSnapshotsRequest>(&header, _body_bytes, handles, &mut req)?;
431                        let control_handle = CollectorControlHandle { inner: this.inner.clone() };
432                        Ok(CollectorRequest::ListStoredSnapshots { payload: req, control_handle })
433                    }
434                    0x48e9792c6f7f1c2e => {
435                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
436                        let mut req = fidl::new_empty!(
437                            CollectorDownloadStoredSnapshotRequest,
438                            fidl::encoding::DefaultFuchsiaResourceDialect
439                        );
440                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CollectorDownloadStoredSnapshotRequest>(&header, _body_bytes, handles, &mut req)?;
441                        let control_handle = CollectorControlHandle { inner: this.inner.clone() };
442                        Ok(CollectorRequest::DownloadStoredSnapshot {
443                            payload: req,
444                            control_handle,
445                        })
446                    }
447                    _ if header.tx_id == 0
448                        && header
449                            .dynamic_flags()
450                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
451                    {
452                        Ok(CollectorRequest::_UnknownMethod {
453                            ordinal: header.ordinal,
454                            control_handle: CollectorControlHandle { inner: this.inner.clone() },
455                            method_type: fidl::MethodType::OneWay,
456                        })
457                    }
458                    _ if header
459                        .dynamic_flags()
460                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
461                    {
462                        this.inner.send_framework_err(
463                            fidl::encoding::FrameworkErr::UnknownMethod,
464                            header.tx_id,
465                            header.ordinal,
466                            header.dynamic_flags(),
467                            (bytes, handles),
468                        )?;
469                        Ok(CollectorRequest::_UnknownMethod {
470                            ordinal: header.ordinal,
471                            control_handle: CollectorControlHandle { inner: this.inner.clone() },
472                            method_type: fidl::MethodType::TwoWay,
473                        })
474                    }
475                    _ => Err(fidl::Error::UnknownOrdinal {
476                        ordinal: header.ordinal,
477                        protocol_name:
478                            <CollectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
479                    }),
480                }))
481            },
482        )
483    }
484}
485
486/// Protocol to request and retrieve memory profiles.
487#[derive(Debug)]
488pub enum CollectorRequest {
489    /// Obtains a snapshot of the current live allocations in an instrumented process.
490    TakeLiveSnapshot {
491        payload: CollectorTakeLiveSnapshotRequest,
492        control_handle: CollectorControlHandle,
493    },
494    /// Retrieves the list of all the available stored snapshots.
495    ListStoredSnapshots {
496        payload: CollectorListStoredSnapshotsRequest,
497        control_handle: CollectorControlHandle,
498    },
499    /// Retrieves a stored snapshot.
500    DownloadStoredSnapshot {
501        payload: CollectorDownloadStoredSnapshotRequest,
502        control_handle: CollectorControlHandle,
503    },
504    /// An interaction was received which does not match any known method.
505    #[non_exhaustive]
506    _UnknownMethod {
507        /// Ordinal of the method that was called.
508        ordinal: u64,
509        control_handle: CollectorControlHandle,
510        method_type: fidl::MethodType,
511    },
512}
513
514impl CollectorRequest {
515    #[allow(irrefutable_let_patterns)]
516    pub fn into_take_live_snapshot(
517        self,
518    ) -> Option<(CollectorTakeLiveSnapshotRequest, CollectorControlHandle)> {
519        if let CollectorRequest::TakeLiveSnapshot { payload, control_handle } = self {
520            Some((payload, control_handle))
521        } else {
522            None
523        }
524    }
525
526    #[allow(irrefutable_let_patterns)]
527    pub fn into_list_stored_snapshots(
528        self,
529    ) -> Option<(CollectorListStoredSnapshotsRequest, CollectorControlHandle)> {
530        if let CollectorRequest::ListStoredSnapshots { payload, control_handle } = self {
531            Some((payload, control_handle))
532        } else {
533            None
534        }
535    }
536
537    #[allow(irrefutable_let_patterns)]
538    pub fn into_download_stored_snapshot(
539        self,
540    ) -> Option<(CollectorDownloadStoredSnapshotRequest, CollectorControlHandle)> {
541        if let CollectorRequest::DownloadStoredSnapshot { payload, control_handle } = self {
542            Some((payload, control_handle))
543        } else {
544            None
545        }
546    }
547
548    /// Name of the method defined in FIDL
549    pub fn method_name(&self) -> &'static str {
550        match *self {
551            CollectorRequest::TakeLiveSnapshot { .. } => "take_live_snapshot",
552            CollectorRequest::ListStoredSnapshots { .. } => "list_stored_snapshots",
553            CollectorRequest::DownloadStoredSnapshot { .. } => "download_stored_snapshot",
554            CollectorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
555                "unknown one-way method"
556            }
557            CollectorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
558                "unknown two-way method"
559            }
560        }
561    }
562}
563
564#[derive(Debug, Clone)]
565pub struct CollectorControlHandle {
566    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
567}
568
569impl fidl::endpoints::ControlHandle for CollectorControlHandle {
570    fn shutdown(&self) {
571        self.inner.shutdown()
572    }
573    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
574        self.inner.shutdown_with_epitaph(status)
575    }
576
577    fn is_closed(&self) -> bool {
578        self.inner.channel().is_closed()
579    }
580    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
581        self.inner.channel().on_closed()
582    }
583
584    #[cfg(target_os = "fuchsia")]
585    fn signal_peer(
586        &self,
587        clear_mask: zx::Signals,
588        set_mask: zx::Signals,
589    ) -> Result<(), zx_status::Status> {
590        use fidl::Peered;
591        self.inner.channel().signal_peer(clear_mask, set_mask)
592    }
593}
594
595impl CollectorControlHandle {}
596
597#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
598pub struct SnapshotReceiverMarker;
599
600impl fidl::endpoints::ProtocolMarker for SnapshotReceiverMarker {
601    type Proxy = SnapshotReceiverProxy;
602    type RequestStream = SnapshotReceiverRequestStream;
603    #[cfg(target_os = "fuchsia")]
604    type SynchronousProxy = SnapshotReceiverSynchronousProxy;
605
606    const DEBUG_NAME: &'static str = "(anonymous) SnapshotReceiver";
607}
608
609pub trait SnapshotReceiverProxyInterface: Send + Sync {
610    type BatchResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
611    fn r#batch(&self, batch: &[SnapshotElement]) -> Self::BatchResponseFut;
612    type ReportErrorResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
613    fn r#report_error(&self, error: CollectorError) -> Self::ReportErrorResponseFut;
614}
615#[derive(Debug)]
616#[cfg(target_os = "fuchsia")]
617pub struct SnapshotReceiverSynchronousProxy {
618    client: fidl::client::sync::Client,
619}
620
621#[cfg(target_os = "fuchsia")]
622impl fidl::endpoints::SynchronousProxy for SnapshotReceiverSynchronousProxy {
623    type Proxy = SnapshotReceiverProxy;
624    type Protocol = SnapshotReceiverMarker;
625
626    fn from_channel(inner: fidl::Channel) -> Self {
627        Self::new(inner)
628    }
629
630    fn into_channel(self) -> fidl::Channel {
631        self.client.into_channel()
632    }
633
634    fn as_channel(&self) -> &fidl::Channel {
635        self.client.as_channel()
636    }
637}
638
639#[cfg(target_os = "fuchsia")]
640impl SnapshotReceiverSynchronousProxy {
641    pub fn new(channel: fidl::Channel) -> Self {
642        let protocol_name = <SnapshotReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
643        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
644    }
645
646    pub fn into_channel(self) -> fidl::Channel {
647        self.client.into_channel()
648    }
649
650    /// Waits until an event arrives and returns it. It is safe for other
651    /// threads to make concurrent requests while waiting for an event.
652    pub fn wait_for_event(
653        &self,
654        deadline: zx::MonotonicInstant,
655    ) -> Result<SnapshotReceiverEvent, fidl::Error> {
656        SnapshotReceiverEvent::decode(self.client.wait_for_event(deadline)?)
657    }
658
659    /// Delivers a batch of snapshot elements.
660    ///
661    /// It will be called repeatedly until no elements are left, and then one final time with an
662    /// empty vector to signal the end of the stream.
663    pub fn r#batch(
664        &self,
665        mut batch: &[SnapshotElement],
666        ___deadline: zx::MonotonicInstant,
667    ) -> Result<(), fidl::Error> {
668        let _response =
669            self.client.send_query::<SnapshotReceiverBatchRequest, fidl::encoding::EmptyPayload>(
670                (batch,),
671                0x4e2a7b07ec4bf37e,
672                fidl::encoding::DynamicFlags::empty(),
673                ___deadline,
674            )?;
675        Ok(_response)
676    }
677
678    /// Reports an error. No other batches or errors will follow.
679    pub fn r#report_error(
680        &self,
681        mut error: CollectorError,
682        ___deadline: zx::MonotonicInstant,
683    ) -> Result<(), fidl::Error> {
684        let _response = self
685            .client
686            .send_query::<SnapshotReceiverReportErrorRequest, fidl::encoding::EmptyPayload>(
687                (error,),
688                0x7bc3329e0ec250c4,
689                fidl::encoding::DynamicFlags::empty(),
690                ___deadline,
691            )?;
692        Ok(_response)
693    }
694}
695
696#[derive(Debug, Clone)]
697pub struct SnapshotReceiverProxy {
698    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
699}
700
701impl fidl::endpoints::Proxy for SnapshotReceiverProxy {
702    type Protocol = SnapshotReceiverMarker;
703
704    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
705        Self::new(inner)
706    }
707
708    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
709        self.client.into_channel().map_err(|client| Self { client })
710    }
711
712    fn as_channel(&self) -> &::fidl::AsyncChannel {
713        self.client.as_channel()
714    }
715}
716
717impl SnapshotReceiverProxy {
718    /// Create a new Proxy for fuchsia.memory.heapdump.client/SnapshotReceiver.
719    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
720        let protocol_name = <SnapshotReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
721        Self { client: fidl::client::Client::new(channel, protocol_name) }
722    }
723
724    /// Get a Stream of events from the remote end of the protocol.
725    ///
726    /// # Panics
727    ///
728    /// Panics if the event stream was already taken.
729    pub fn take_event_stream(&self) -> SnapshotReceiverEventStream {
730        SnapshotReceiverEventStream { event_receiver: self.client.take_event_receiver() }
731    }
732
733    /// Delivers a batch of snapshot elements.
734    ///
735    /// It will be called repeatedly until no elements are left, and then one final time with an
736    /// empty vector to signal the end of the stream.
737    pub fn r#batch(
738        &self,
739        mut batch: &[SnapshotElement],
740    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
741        SnapshotReceiverProxyInterface::r#batch(self, batch)
742    }
743
744    /// Reports an error. No other batches or errors will follow.
745    pub fn r#report_error(
746        &self,
747        mut error: CollectorError,
748    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
749        SnapshotReceiverProxyInterface::r#report_error(self, error)
750    }
751}
752
753impl SnapshotReceiverProxyInterface for SnapshotReceiverProxy {
754    type BatchResponseFut =
755        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
756    fn r#batch(&self, mut batch: &[SnapshotElement]) -> Self::BatchResponseFut {
757        fn _decode(
758            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
759        ) -> Result<(), fidl::Error> {
760            let _response = fidl::client::decode_transaction_body::<
761                fidl::encoding::EmptyPayload,
762                fidl::encoding::DefaultFuchsiaResourceDialect,
763                0x4e2a7b07ec4bf37e,
764            >(_buf?)?;
765            Ok(_response)
766        }
767        self.client.send_query_and_decode::<SnapshotReceiverBatchRequest, ()>(
768            (batch,),
769            0x4e2a7b07ec4bf37e,
770            fidl::encoding::DynamicFlags::empty(),
771            _decode,
772        )
773    }
774
775    type ReportErrorResponseFut =
776        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
777    fn r#report_error(&self, mut error: CollectorError) -> Self::ReportErrorResponseFut {
778        fn _decode(
779            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
780        ) -> Result<(), fidl::Error> {
781            let _response = fidl::client::decode_transaction_body::<
782                fidl::encoding::EmptyPayload,
783                fidl::encoding::DefaultFuchsiaResourceDialect,
784                0x7bc3329e0ec250c4,
785            >(_buf?)?;
786            Ok(_response)
787        }
788        self.client.send_query_and_decode::<SnapshotReceiverReportErrorRequest, ()>(
789            (error,),
790            0x7bc3329e0ec250c4,
791            fidl::encoding::DynamicFlags::empty(),
792            _decode,
793        )
794    }
795}
796
797pub struct SnapshotReceiverEventStream {
798    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
799}
800
801impl std::marker::Unpin for SnapshotReceiverEventStream {}
802
803impl futures::stream::FusedStream for SnapshotReceiverEventStream {
804    fn is_terminated(&self) -> bool {
805        self.event_receiver.is_terminated()
806    }
807}
808
809impl futures::Stream for SnapshotReceiverEventStream {
810    type Item = Result<SnapshotReceiverEvent, fidl::Error>;
811
812    fn poll_next(
813        mut self: std::pin::Pin<&mut Self>,
814        cx: &mut std::task::Context<'_>,
815    ) -> std::task::Poll<Option<Self::Item>> {
816        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
817            &mut self.event_receiver,
818            cx
819        )?) {
820            Some(buf) => std::task::Poll::Ready(Some(SnapshotReceiverEvent::decode(buf))),
821            None => std::task::Poll::Ready(None),
822        }
823    }
824}
825
826#[derive(Debug)]
827pub enum SnapshotReceiverEvent {}
828
829impl SnapshotReceiverEvent {
830    /// Decodes a message buffer as a [`SnapshotReceiverEvent`].
831    fn decode(
832        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
833    ) -> Result<SnapshotReceiverEvent, fidl::Error> {
834        let (bytes, _handles) = buf.split_mut();
835        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
836        debug_assert_eq!(tx_header.tx_id, 0);
837        match tx_header.ordinal {
838            _ => Err(fidl::Error::UnknownOrdinal {
839                ordinal: tx_header.ordinal,
840                protocol_name:
841                    <SnapshotReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
842            }),
843        }
844    }
845}
846
847/// A Stream of incoming requests for fuchsia.memory.heapdump.client/SnapshotReceiver.
848pub struct SnapshotReceiverRequestStream {
849    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
850    is_terminated: bool,
851}
852
853impl std::marker::Unpin for SnapshotReceiverRequestStream {}
854
855impl futures::stream::FusedStream for SnapshotReceiverRequestStream {
856    fn is_terminated(&self) -> bool {
857        self.is_terminated
858    }
859}
860
861impl fidl::endpoints::RequestStream for SnapshotReceiverRequestStream {
862    type Protocol = SnapshotReceiverMarker;
863    type ControlHandle = SnapshotReceiverControlHandle;
864
865    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
866        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
867    }
868
869    fn control_handle(&self) -> Self::ControlHandle {
870        SnapshotReceiverControlHandle { inner: self.inner.clone() }
871    }
872
873    fn into_inner(
874        self,
875    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
876    {
877        (self.inner, self.is_terminated)
878    }
879
880    fn from_inner(
881        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
882        is_terminated: bool,
883    ) -> Self {
884        Self { inner, is_terminated }
885    }
886}
887
888impl futures::Stream for SnapshotReceiverRequestStream {
889    type Item = Result<SnapshotReceiverRequest, fidl::Error>;
890
891    fn poll_next(
892        mut self: std::pin::Pin<&mut Self>,
893        cx: &mut std::task::Context<'_>,
894    ) -> std::task::Poll<Option<Self::Item>> {
895        let this = &mut *self;
896        if this.inner.check_shutdown(cx) {
897            this.is_terminated = true;
898            return std::task::Poll::Ready(None);
899        }
900        if this.is_terminated {
901            panic!("polled SnapshotReceiverRequestStream after completion");
902        }
903        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
904            |bytes, handles| {
905                match this.inner.channel().read_etc(cx, bytes, handles) {
906                    std::task::Poll::Ready(Ok(())) => {}
907                    std::task::Poll::Pending => return std::task::Poll::Pending,
908                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
909                        this.is_terminated = true;
910                        return std::task::Poll::Ready(None);
911                    }
912                    std::task::Poll::Ready(Err(e)) => {
913                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
914                            e.into(),
915                        ))))
916                    }
917                }
918
919                // A message has been received from the channel
920                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
921
922                std::task::Poll::Ready(Some(match header.ordinal {
923                    0x4e2a7b07ec4bf37e => {
924                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
925                        let mut req = fidl::new_empty!(
926                            SnapshotReceiverBatchRequest,
927                            fidl::encoding::DefaultFuchsiaResourceDialect
928                        );
929                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnapshotReceiverBatchRequest>(&header, _body_bytes, handles, &mut req)?;
930                        let control_handle =
931                            SnapshotReceiverControlHandle { inner: this.inner.clone() };
932                        Ok(SnapshotReceiverRequest::Batch {
933                            batch: req.batch,
934
935                            responder: SnapshotReceiverBatchResponder {
936                                control_handle: std::mem::ManuallyDrop::new(control_handle),
937                                tx_id: header.tx_id,
938                            },
939                        })
940                    }
941                    0x7bc3329e0ec250c4 => {
942                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
943                        let mut req = fidl::new_empty!(
944                            SnapshotReceiverReportErrorRequest,
945                            fidl::encoding::DefaultFuchsiaResourceDialect
946                        );
947                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnapshotReceiverReportErrorRequest>(&header, _body_bytes, handles, &mut req)?;
948                        let control_handle =
949                            SnapshotReceiverControlHandle { inner: this.inner.clone() };
950                        Ok(SnapshotReceiverRequest::ReportError {
951                            error: req.error,
952
953                            responder: SnapshotReceiverReportErrorResponder {
954                                control_handle: std::mem::ManuallyDrop::new(control_handle),
955                                tx_id: header.tx_id,
956                            },
957                        })
958                    }
959                    _ => Err(fidl::Error::UnknownOrdinal {
960                        ordinal: header.ordinal,
961                        protocol_name:
962                            <SnapshotReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
963                    }),
964                }))
965            },
966        )
967    }
968}
969
970/// Protocol to transmit a snapshot as a stream of elements.
971#[derive(Debug)]
972pub enum SnapshotReceiverRequest {
973    /// Delivers a batch of snapshot elements.
974    ///
975    /// It will be called repeatedly until no elements are left, and then one final time with an
976    /// empty vector to signal the end of the stream.
977    Batch { batch: Vec<SnapshotElement>, responder: SnapshotReceiverBatchResponder },
978    /// Reports an error. No other batches or errors will follow.
979    ReportError { error: CollectorError, responder: SnapshotReceiverReportErrorResponder },
980}
981
982impl SnapshotReceiverRequest {
983    #[allow(irrefutable_let_patterns)]
984    pub fn into_batch(self) -> Option<(Vec<SnapshotElement>, SnapshotReceiverBatchResponder)> {
985        if let SnapshotReceiverRequest::Batch { batch, responder } = self {
986            Some((batch, responder))
987        } else {
988            None
989        }
990    }
991
992    #[allow(irrefutable_let_patterns)]
993    pub fn into_report_error(
994        self,
995    ) -> Option<(CollectorError, SnapshotReceiverReportErrorResponder)> {
996        if let SnapshotReceiverRequest::ReportError { error, responder } = self {
997            Some((error, responder))
998        } else {
999            None
1000        }
1001    }
1002
1003    /// Name of the method defined in FIDL
1004    pub fn method_name(&self) -> &'static str {
1005        match *self {
1006            SnapshotReceiverRequest::Batch { .. } => "batch",
1007            SnapshotReceiverRequest::ReportError { .. } => "report_error",
1008        }
1009    }
1010}
1011
1012#[derive(Debug, Clone)]
1013pub struct SnapshotReceiverControlHandle {
1014    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1015}
1016
1017impl fidl::endpoints::ControlHandle for SnapshotReceiverControlHandle {
1018    fn shutdown(&self) {
1019        self.inner.shutdown()
1020    }
1021    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1022        self.inner.shutdown_with_epitaph(status)
1023    }
1024
1025    fn is_closed(&self) -> bool {
1026        self.inner.channel().is_closed()
1027    }
1028    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1029        self.inner.channel().on_closed()
1030    }
1031
1032    #[cfg(target_os = "fuchsia")]
1033    fn signal_peer(
1034        &self,
1035        clear_mask: zx::Signals,
1036        set_mask: zx::Signals,
1037    ) -> Result<(), zx_status::Status> {
1038        use fidl::Peered;
1039        self.inner.channel().signal_peer(clear_mask, set_mask)
1040    }
1041}
1042
1043impl SnapshotReceiverControlHandle {}
1044
1045#[must_use = "FIDL methods require a response to be sent"]
1046#[derive(Debug)]
1047pub struct SnapshotReceiverBatchResponder {
1048    control_handle: std::mem::ManuallyDrop<SnapshotReceiverControlHandle>,
1049    tx_id: u32,
1050}
1051
1052/// Set the the channel to be shutdown (see [`SnapshotReceiverControlHandle::shutdown`])
1053/// if the responder is dropped without sending a response, so that the client
1054/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1055impl std::ops::Drop for SnapshotReceiverBatchResponder {
1056    fn drop(&mut self) {
1057        self.control_handle.shutdown();
1058        // Safety: drops once, never accessed again
1059        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1060    }
1061}
1062
1063impl fidl::endpoints::Responder for SnapshotReceiverBatchResponder {
1064    type ControlHandle = SnapshotReceiverControlHandle;
1065
1066    fn control_handle(&self) -> &SnapshotReceiverControlHandle {
1067        &self.control_handle
1068    }
1069
1070    fn drop_without_shutdown(mut self) {
1071        // Safety: drops once, never accessed again due to mem::forget
1072        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1073        // Prevent Drop from running (which would shut down the channel)
1074        std::mem::forget(self);
1075    }
1076}
1077
1078impl SnapshotReceiverBatchResponder {
1079    /// Sends a response to the FIDL transaction.
1080    ///
1081    /// Sets the channel to shutdown if an error occurs.
1082    pub fn send(self) -> Result<(), fidl::Error> {
1083        let _result = self.send_raw();
1084        if _result.is_err() {
1085            self.control_handle.shutdown();
1086        }
1087        self.drop_without_shutdown();
1088        _result
1089    }
1090
1091    /// Similar to "send" but does not shutdown the channel if an error occurs.
1092    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1093        let _result = self.send_raw();
1094        self.drop_without_shutdown();
1095        _result
1096    }
1097
1098    fn send_raw(&self) -> Result<(), fidl::Error> {
1099        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1100            (),
1101            self.tx_id,
1102            0x4e2a7b07ec4bf37e,
1103            fidl::encoding::DynamicFlags::empty(),
1104        )
1105    }
1106}
1107
1108#[must_use = "FIDL methods require a response to be sent"]
1109#[derive(Debug)]
1110pub struct SnapshotReceiverReportErrorResponder {
1111    control_handle: std::mem::ManuallyDrop<SnapshotReceiverControlHandle>,
1112    tx_id: u32,
1113}
1114
1115/// Set the the channel to be shutdown (see [`SnapshotReceiverControlHandle::shutdown`])
1116/// if the responder is dropped without sending a response, so that the client
1117/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1118impl std::ops::Drop for SnapshotReceiverReportErrorResponder {
1119    fn drop(&mut self) {
1120        self.control_handle.shutdown();
1121        // Safety: drops once, never accessed again
1122        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1123    }
1124}
1125
1126impl fidl::endpoints::Responder for SnapshotReceiverReportErrorResponder {
1127    type ControlHandle = SnapshotReceiverControlHandle;
1128
1129    fn control_handle(&self) -> &SnapshotReceiverControlHandle {
1130        &self.control_handle
1131    }
1132
1133    fn drop_without_shutdown(mut self) {
1134        // Safety: drops once, never accessed again due to mem::forget
1135        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1136        // Prevent Drop from running (which would shut down the channel)
1137        std::mem::forget(self);
1138    }
1139}
1140
1141impl SnapshotReceiverReportErrorResponder {
1142    /// Sends a response to the FIDL transaction.
1143    ///
1144    /// Sets the channel to shutdown if an error occurs.
1145    pub fn send(self) -> Result<(), fidl::Error> {
1146        let _result = self.send_raw();
1147        if _result.is_err() {
1148            self.control_handle.shutdown();
1149        }
1150        self.drop_without_shutdown();
1151        _result
1152    }
1153
1154    /// Similar to "send" but does not shutdown the channel if an error occurs.
1155    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1156        let _result = self.send_raw();
1157        self.drop_without_shutdown();
1158        _result
1159    }
1160
1161    fn send_raw(&self) -> Result<(), fidl::Error> {
1162        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1163            (),
1164            self.tx_id,
1165            0x7bc3329e0ec250c4,
1166            fidl::encoding::DynamicFlags::empty(),
1167        )
1168    }
1169}
1170
1171#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1172pub struct StoredSnapshotIteratorMarker;
1173
1174impl fidl::endpoints::ProtocolMarker for StoredSnapshotIteratorMarker {
1175    type Proxy = StoredSnapshotIteratorProxy;
1176    type RequestStream = StoredSnapshotIteratorRequestStream;
1177    #[cfg(target_os = "fuchsia")]
1178    type SynchronousProxy = StoredSnapshotIteratorSynchronousProxy;
1179
1180    const DEBUG_NAME: &'static str = "(anonymous) StoredSnapshotIterator";
1181}
1182pub type StoredSnapshotIteratorGetNextResult = Result<Vec<StoredSnapshot>, CollectorError>;
1183
1184pub trait StoredSnapshotIteratorProxyInterface: Send + Sync {
1185    type GetNextResponseFut: std::future::Future<Output = Result<StoredSnapshotIteratorGetNextResult, fidl::Error>>
1186        + Send;
1187    fn r#get_next(&self) -> Self::GetNextResponseFut;
1188}
1189#[derive(Debug)]
1190#[cfg(target_os = "fuchsia")]
1191pub struct StoredSnapshotIteratorSynchronousProxy {
1192    client: fidl::client::sync::Client,
1193}
1194
1195#[cfg(target_os = "fuchsia")]
1196impl fidl::endpoints::SynchronousProxy for StoredSnapshotIteratorSynchronousProxy {
1197    type Proxy = StoredSnapshotIteratorProxy;
1198    type Protocol = StoredSnapshotIteratorMarker;
1199
1200    fn from_channel(inner: fidl::Channel) -> Self {
1201        Self::new(inner)
1202    }
1203
1204    fn into_channel(self) -> fidl::Channel {
1205        self.client.into_channel()
1206    }
1207
1208    fn as_channel(&self) -> &fidl::Channel {
1209        self.client.as_channel()
1210    }
1211}
1212
1213#[cfg(target_os = "fuchsia")]
1214impl StoredSnapshotIteratorSynchronousProxy {
1215    pub fn new(channel: fidl::Channel) -> Self {
1216        let protocol_name =
1217            <StoredSnapshotIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1218        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1219    }
1220
1221    pub fn into_channel(self) -> fidl::Channel {
1222        self.client.into_channel()
1223    }
1224
1225    /// Waits until an event arrives and returns it. It is safe for other
1226    /// threads to make concurrent requests while waiting for an event.
1227    pub fn wait_for_event(
1228        &self,
1229        deadline: zx::MonotonicInstant,
1230    ) -> Result<StoredSnapshotIteratorEvent, fidl::Error> {
1231        StoredSnapshotIteratorEvent::decode(self.client.wait_for_event(deadline)?)
1232    }
1233
1234    /// Retrieves the next batch of StoredSnapshots elements.
1235    ///
1236    /// An empty response signals the end of the list.
1237    pub fn r#get_next(
1238        &self,
1239        ___deadline: zx::MonotonicInstant,
1240    ) -> Result<StoredSnapshotIteratorGetNextResult, fidl::Error> {
1241        let _response =
1242            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
1243                StoredSnapshotIteratorGetNextResponse,
1244                CollectorError,
1245            >>(
1246                (),
1247                0x486d0c7d309d2474,
1248                fidl::encoding::DynamicFlags::empty(),
1249                ___deadline,
1250            )?;
1251        Ok(_response.map(|x| x.batch))
1252    }
1253}
1254
1255#[derive(Debug, Clone)]
1256pub struct StoredSnapshotIteratorProxy {
1257    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1258}
1259
1260impl fidl::endpoints::Proxy for StoredSnapshotIteratorProxy {
1261    type Protocol = StoredSnapshotIteratorMarker;
1262
1263    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1264        Self::new(inner)
1265    }
1266
1267    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1268        self.client.into_channel().map_err(|client| Self { client })
1269    }
1270
1271    fn as_channel(&self) -> &::fidl::AsyncChannel {
1272        self.client.as_channel()
1273    }
1274}
1275
1276impl StoredSnapshotIteratorProxy {
1277    /// Create a new Proxy for fuchsia.memory.heapdump.client/StoredSnapshotIterator.
1278    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1279        let protocol_name =
1280            <StoredSnapshotIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1281        Self { client: fidl::client::Client::new(channel, protocol_name) }
1282    }
1283
1284    /// Get a Stream of events from the remote end of the protocol.
1285    ///
1286    /// # Panics
1287    ///
1288    /// Panics if the event stream was already taken.
1289    pub fn take_event_stream(&self) -> StoredSnapshotIteratorEventStream {
1290        StoredSnapshotIteratorEventStream { event_receiver: self.client.take_event_receiver() }
1291    }
1292
1293    /// Retrieves the next batch of StoredSnapshots elements.
1294    ///
1295    /// An empty response signals the end of the list.
1296    pub fn r#get_next(
1297        &self,
1298    ) -> fidl::client::QueryResponseFut<
1299        StoredSnapshotIteratorGetNextResult,
1300        fidl::encoding::DefaultFuchsiaResourceDialect,
1301    > {
1302        StoredSnapshotIteratorProxyInterface::r#get_next(self)
1303    }
1304}
1305
1306impl StoredSnapshotIteratorProxyInterface for StoredSnapshotIteratorProxy {
1307    type GetNextResponseFut = fidl::client::QueryResponseFut<
1308        StoredSnapshotIteratorGetNextResult,
1309        fidl::encoding::DefaultFuchsiaResourceDialect,
1310    >;
1311    fn r#get_next(&self) -> Self::GetNextResponseFut {
1312        fn _decode(
1313            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1314        ) -> Result<StoredSnapshotIteratorGetNextResult, fidl::Error> {
1315            let _response = fidl::client::decode_transaction_body::<
1316                fidl::encoding::ResultType<StoredSnapshotIteratorGetNextResponse, CollectorError>,
1317                fidl::encoding::DefaultFuchsiaResourceDialect,
1318                0x486d0c7d309d2474,
1319            >(_buf?)?;
1320            Ok(_response.map(|x| x.batch))
1321        }
1322        self.client.send_query_and_decode::<
1323            fidl::encoding::EmptyPayload,
1324            StoredSnapshotIteratorGetNextResult,
1325        >(
1326            (),
1327            0x486d0c7d309d2474,
1328            fidl::encoding::DynamicFlags::empty(),
1329            _decode,
1330        )
1331    }
1332}
1333
1334pub struct StoredSnapshotIteratorEventStream {
1335    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1336}
1337
1338impl std::marker::Unpin for StoredSnapshotIteratorEventStream {}
1339
1340impl futures::stream::FusedStream for StoredSnapshotIteratorEventStream {
1341    fn is_terminated(&self) -> bool {
1342        self.event_receiver.is_terminated()
1343    }
1344}
1345
1346impl futures::Stream for StoredSnapshotIteratorEventStream {
1347    type Item = Result<StoredSnapshotIteratorEvent, fidl::Error>;
1348
1349    fn poll_next(
1350        mut self: std::pin::Pin<&mut Self>,
1351        cx: &mut std::task::Context<'_>,
1352    ) -> std::task::Poll<Option<Self::Item>> {
1353        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1354            &mut self.event_receiver,
1355            cx
1356        )?) {
1357            Some(buf) => std::task::Poll::Ready(Some(StoredSnapshotIteratorEvent::decode(buf))),
1358            None => std::task::Poll::Ready(None),
1359        }
1360    }
1361}
1362
1363#[derive(Debug)]
1364pub enum StoredSnapshotIteratorEvent {}
1365
1366impl StoredSnapshotIteratorEvent {
1367    /// Decodes a message buffer as a [`StoredSnapshotIteratorEvent`].
1368    fn decode(
1369        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1370    ) -> Result<StoredSnapshotIteratorEvent, fidl::Error> {
1371        let (bytes, _handles) = buf.split_mut();
1372        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1373        debug_assert_eq!(tx_header.tx_id, 0);
1374        match tx_header.ordinal {
1375            _ => Err(fidl::Error::UnknownOrdinal {
1376                ordinal: tx_header.ordinal,
1377                protocol_name:
1378                    <StoredSnapshotIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1379            }),
1380        }
1381    }
1382}
1383
1384/// A Stream of incoming requests for fuchsia.memory.heapdump.client/StoredSnapshotIterator.
1385pub struct StoredSnapshotIteratorRequestStream {
1386    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1387    is_terminated: bool,
1388}
1389
1390impl std::marker::Unpin for StoredSnapshotIteratorRequestStream {}
1391
1392impl futures::stream::FusedStream for StoredSnapshotIteratorRequestStream {
1393    fn is_terminated(&self) -> bool {
1394        self.is_terminated
1395    }
1396}
1397
1398impl fidl::endpoints::RequestStream for StoredSnapshotIteratorRequestStream {
1399    type Protocol = StoredSnapshotIteratorMarker;
1400    type ControlHandle = StoredSnapshotIteratorControlHandle;
1401
1402    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1403        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1404    }
1405
1406    fn control_handle(&self) -> Self::ControlHandle {
1407        StoredSnapshotIteratorControlHandle { inner: self.inner.clone() }
1408    }
1409
1410    fn into_inner(
1411        self,
1412    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1413    {
1414        (self.inner, self.is_terminated)
1415    }
1416
1417    fn from_inner(
1418        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1419        is_terminated: bool,
1420    ) -> Self {
1421        Self { inner, is_terminated }
1422    }
1423}
1424
1425impl futures::Stream for StoredSnapshotIteratorRequestStream {
1426    type Item = Result<StoredSnapshotIteratorRequest, fidl::Error>;
1427
1428    fn poll_next(
1429        mut self: std::pin::Pin<&mut Self>,
1430        cx: &mut std::task::Context<'_>,
1431    ) -> std::task::Poll<Option<Self::Item>> {
1432        let this = &mut *self;
1433        if this.inner.check_shutdown(cx) {
1434            this.is_terminated = true;
1435            return std::task::Poll::Ready(None);
1436        }
1437        if this.is_terminated {
1438            panic!("polled StoredSnapshotIteratorRequestStream after completion");
1439        }
1440        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1441            |bytes, handles| {
1442                match this.inner.channel().read_etc(cx, bytes, handles) {
1443                    std::task::Poll::Ready(Ok(())) => {}
1444                    std::task::Poll::Pending => return std::task::Poll::Pending,
1445                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1446                        this.is_terminated = true;
1447                        return std::task::Poll::Ready(None);
1448                    }
1449                    std::task::Poll::Ready(Err(e)) => {
1450                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1451                            e.into(),
1452                        ))))
1453                    }
1454                }
1455
1456                // A message has been received from the channel
1457                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1458
1459                std::task::Poll::Ready(Some(match header.ordinal {
1460                0x486d0c7d309d2474 => {
1461                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1462                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1463                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1464                    let control_handle = StoredSnapshotIteratorControlHandle {
1465                        inner: this.inner.clone(),
1466                    };
1467                    Ok(StoredSnapshotIteratorRequest::GetNext {
1468                        responder: StoredSnapshotIteratorGetNextResponder {
1469                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1470                            tx_id: header.tx_id,
1471                        },
1472                    })
1473                }
1474                _ => Err(fidl::Error::UnknownOrdinal {
1475                    ordinal: header.ordinal,
1476                    protocol_name: <StoredSnapshotIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1477                }),
1478            }))
1479            },
1480        )
1481    }
1482}
1483
1484/// Protocol to retrieve a list of StoredSnapshots.
1485#[derive(Debug)]
1486pub enum StoredSnapshotIteratorRequest {
1487    /// Retrieves the next batch of StoredSnapshots elements.
1488    ///
1489    /// An empty response signals the end of the list.
1490    GetNext { responder: StoredSnapshotIteratorGetNextResponder },
1491}
1492
1493impl StoredSnapshotIteratorRequest {
1494    #[allow(irrefutable_let_patterns)]
1495    pub fn into_get_next(self) -> Option<(StoredSnapshotIteratorGetNextResponder)> {
1496        if let StoredSnapshotIteratorRequest::GetNext { responder } = self {
1497            Some((responder))
1498        } else {
1499            None
1500        }
1501    }
1502
1503    /// Name of the method defined in FIDL
1504    pub fn method_name(&self) -> &'static str {
1505        match *self {
1506            StoredSnapshotIteratorRequest::GetNext { .. } => "get_next",
1507        }
1508    }
1509}
1510
1511#[derive(Debug, Clone)]
1512pub struct StoredSnapshotIteratorControlHandle {
1513    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1514}
1515
1516impl fidl::endpoints::ControlHandle for StoredSnapshotIteratorControlHandle {
1517    fn shutdown(&self) {
1518        self.inner.shutdown()
1519    }
1520    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1521        self.inner.shutdown_with_epitaph(status)
1522    }
1523
1524    fn is_closed(&self) -> bool {
1525        self.inner.channel().is_closed()
1526    }
1527    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1528        self.inner.channel().on_closed()
1529    }
1530
1531    #[cfg(target_os = "fuchsia")]
1532    fn signal_peer(
1533        &self,
1534        clear_mask: zx::Signals,
1535        set_mask: zx::Signals,
1536    ) -> Result<(), zx_status::Status> {
1537        use fidl::Peered;
1538        self.inner.channel().signal_peer(clear_mask, set_mask)
1539    }
1540}
1541
1542impl StoredSnapshotIteratorControlHandle {}
1543
1544#[must_use = "FIDL methods require a response to be sent"]
1545#[derive(Debug)]
1546pub struct StoredSnapshotIteratorGetNextResponder {
1547    control_handle: std::mem::ManuallyDrop<StoredSnapshotIteratorControlHandle>,
1548    tx_id: u32,
1549}
1550
1551/// Set the the channel to be shutdown (see [`StoredSnapshotIteratorControlHandle::shutdown`])
1552/// if the responder is dropped without sending a response, so that the client
1553/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1554impl std::ops::Drop for StoredSnapshotIteratorGetNextResponder {
1555    fn drop(&mut self) {
1556        self.control_handle.shutdown();
1557        // Safety: drops once, never accessed again
1558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1559    }
1560}
1561
1562impl fidl::endpoints::Responder for StoredSnapshotIteratorGetNextResponder {
1563    type ControlHandle = StoredSnapshotIteratorControlHandle;
1564
1565    fn control_handle(&self) -> &StoredSnapshotIteratorControlHandle {
1566        &self.control_handle
1567    }
1568
1569    fn drop_without_shutdown(mut self) {
1570        // Safety: drops once, never accessed again due to mem::forget
1571        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1572        // Prevent Drop from running (which would shut down the channel)
1573        std::mem::forget(self);
1574    }
1575}
1576
1577impl StoredSnapshotIteratorGetNextResponder {
1578    /// Sends a response to the FIDL transaction.
1579    ///
1580    /// Sets the channel to shutdown if an error occurs.
1581    pub fn send(
1582        self,
1583        mut result: Result<&[StoredSnapshot], CollectorError>,
1584    ) -> Result<(), fidl::Error> {
1585        let _result = self.send_raw(result);
1586        if _result.is_err() {
1587            self.control_handle.shutdown();
1588        }
1589        self.drop_without_shutdown();
1590        _result
1591    }
1592
1593    /// Similar to "send" but does not shutdown the channel if an error occurs.
1594    pub fn send_no_shutdown_on_err(
1595        self,
1596        mut result: Result<&[StoredSnapshot], CollectorError>,
1597    ) -> Result<(), fidl::Error> {
1598        let _result = self.send_raw(result);
1599        self.drop_without_shutdown();
1600        _result
1601    }
1602
1603    fn send_raw(
1604        &self,
1605        mut result: Result<&[StoredSnapshot], CollectorError>,
1606    ) -> Result<(), fidl::Error> {
1607        self.control_handle.inner.send::<fidl::encoding::ResultType<
1608            StoredSnapshotIteratorGetNextResponse,
1609            CollectorError,
1610        >>(
1611            result.map(|batch| (batch,)),
1612            self.tx_id,
1613            0x486d0c7d309d2474,
1614            fidl::encoding::DynamicFlags::empty(),
1615        )
1616    }
1617}
1618
1619mod internal {
1620    use super::*;
1621
1622    impl CollectorDownloadStoredSnapshotRequest {
1623        #[inline(always)]
1624        fn max_ordinal_present(&self) -> u64 {
1625            if let Some(_) = self.receiver {
1626                return 2;
1627            }
1628            if let Some(_) = self.snapshot_id {
1629                return 1;
1630            }
1631            0
1632        }
1633    }
1634
1635    impl fidl::encoding::ResourceTypeMarker for CollectorDownloadStoredSnapshotRequest {
1636        type Borrowed<'a> = &'a mut Self;
1637        fn take_or_borrow<'a>(
1638            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1639        ) -> Self::Borrowed<'a> {
1640            value
1641        }
1642    }
1643
1644    unsafe impl fidl::encoding::TypeMarker for CollectorDownloadStoredSnapshotRequest {
1645        type Owned = Self;
1646
1647        #[inline(always)]
1648        fn inline_align(_context: fidl::encoding::Context) -> usize {
1649            8
1650        }
1651
1652        #[inline(always)]
1653        fn inline_size(_context: fidl::encoding::Context) -> usize {
1654            16
1655        }
1656    }
1657
1658    unsafe impl
1659        fidl::encoding::Encode<
1660            CollectorDownloadStoredSnapshotRequest,
1661            fidl::encoding::DefaultFuchsiaResourceDialect,
1662        > for &mut CollectorDownloadStoredSnapshotRequest
1663    {
1664        unsafe fn encode(
1665            self,
1666            encoder: &mut fidl::encoding::Encoder<
1667                '_,
1668                fidl::encoding::DefaultFuchsiaResourceDialect,
1669            >,
1670            offset: usize,
1671            mut depth: fidl::encoding::Depth,
1672        ) -> fidl::Result<()> {
1673            encoder.debug_check_bounds::<CollectorDownloadStoredSnapshotRequest>(offset);
1674            // Vector header
1675            let max_ordinal: u64 = self.max_ordinal_present();
1676            encoder.write_num(max_ordinal, offset);
1677            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1678            // Calling encoder.out_of_line_offset(0) is not allowed.
1679            if max_ordinal == 0 {
1680                return Ok(());
1681            }
1682            depth.increment()?;
1683            let envelope_size = 8;
1684            let bytes_len = max_ordinal as usize * envelope_size;
1685            #[allow(unused_variables)]
1686            let offset = encoder.out_of_line_offset(bytes_len);
1687            let mut _prev_end_offset: usize = 0;
1688            if 1 > max_ordinal {
1689                return Ok(());
1690            }
1691
1692            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1693            // are envelope_size bytes.
1694            let cur_offset: usize = (1 - 1) * envelope_size;
1695
1696            // Zero reserved fields.
1697            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1698
1699            // Safety:
1700            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1701            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1702            //   envelope_size bytes, there is always sufficient room.
1703            fidl::encoding::encode_in_envelope_optional::<
1704                u32,
1705                fidl::encoding::DefaultFuchsiaResourceDialect,
1706            >(
1707                self.snapshot_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1708                encoder,
1709                offset + cur_offset,
1710                depth,
1711            )?;
1712
1713            _prev_end_offset = cur_offset + envelope_size;
1714            if 2 > max_ordinal {
1715                return Ok(());
1716            }
1717
1718            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1719            // are envelope_size bytes.
1720            let cur_offset: usize = (2 - 1) * envelope_size;
1721
1722            // Zero reserved fields.
1723            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1724
1725            // Safety:
1726            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1727            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1728            //   envelope_size bytes, there is always sufficient room.
1729            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1730            self.receiver.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1731            encoder, offset + cur_offset, depth
1732        )?;
1733
1734            _prev_end_offset = cur_offset + envelope_size;
1735
1736            Ok(())
1737        }
1738    }
1739
1740    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1741        for CollectorDownloadStoredSnapshotRequest
1742    {
1743        #[inline(always)]
1744        fn new_empty() -> Self {
1745            Self::default()
1746        }
1747
1748        unsafe fn decode(
1749            &mut self,
1750            decoder: &mut fidl::encoding::Decoder<
1751                '_,
1752                fidl::encoding::DefaultFuchsiaResourceDialect,
1753            >,
1754            offset: usize,
1755            mut depth: fidl::encoding::Depth,
1756        ) -> fidl::Result<()> {
1757            decoder.debug_check_bounds::<Self>(offset);
1758            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1759                None => return Err(fidl::Error::NotNullable),
1760                Some(len) => len,
1761            };
1762            // Calling decoder.out_of_line_offset(0) is not allowed.
1763            if len == 0 {
1764                return Ok(());
1765            };
1766            depth.increment()?;
1767            let envelope_size = 8;
1768            let bytes_len = len * envelope_size;
1769            let offset = decoder.out_of_line_offset(bytes_len)?;
1770            // Decode the envelope for each type.
1771            let mut _next_ordinal_to_read = 0;
1772            let mut next_offset = offset;
1773            let end_offset = offset + bytes_len;
1774            _next_ordinal_to_read += 1;
1775            if next_offset >= end_offset {
1776                return Ok(());
1777            }
1778
1779            // Decode unknown envelopes for gaps in ordinals.
1780            while _next_ordinal_to_read < 1 {
1781                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1782                _next_ordinal_to_read += 1;
1783                next_offset += envelope_size;
1784            }
1785
1786            let next_out_of_line = decoder.next_out_of_line();
1787            let handles_before = decoder.remaining_handles();
1788            if let Some((inlined, num_bytes, num_handles)) =
1789                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1790            {
1791                let member_inline_size =
1792                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1793                if inlined != (member_inline_size <= 4) {
1794                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1795                }
1796                let inner_offset;
1797                let mut inner_depth = depth.clone();
1798                if inlined {
1799                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1800                    inner_offset = next_offset;
1801                } else {
1802                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1803                    inner_depth.increment()?;
1804                }
1805                let val_ref = self.snapshot_id.get_or_insert_with(|| {
1806                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1807                });
1808                fidl::decode!(
1809                    u32,
1810                    fidl::encoding::DefaultFuchsiaResourceDialect,
1811                    val_ref,
1812                    decoder,
1813                    inner_offset,
1814                    inner_depth
1815                )?;
1816                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1817                {
1818                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1819                }
1820                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1821                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1822                }
1823            }
1824
1825            next_offset += envelope_size;
1826            _next_ordinal_to_read += 1;
1827            if next_offset >= end_offset {
1828                return Ok(());
1829            }
1830
1831            // Decode unknown envelopes for gaps in ordinals.
1832            while _next_ordinal_to_read < 2 {
1833                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1834                _next_ordinal_to_read += 1;
1835                next_offset += envelope_size;
1836            }
1837
1838            let next_out_of_line = decoder.next_out_of_line();
1839            let handles_before = decoder.remaining_handles();
1840            if let Some((inlined, num_bytes, num_handles)) =
1841                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1842            {
1843                let member_inline_size = <fidl::encoding::Endpoint<
1844                    fidl::endpoints::ClientEnd<SnapshotReceiverMarker>,
1845                > as fidl::encoding::TypeMarker>::inline_size(
1846                    decoder.context
1847                );
1848                if inlined != (member_inline_size <= 4) {
1849                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1850                }
1851                let inner_offset;
1852                let mut inner_depth = depth.clone();
1853                if inlined {
1854                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1855                    inner_offset = next_offset;
1856                } else {
1857                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1858                    inner_depth.increment()?;
1859                }
1860                let val_ref = self.receiver.get_or_insert_with(|| {
1861                    fidl::new_empty!(
1862                        fidl::encoding::Endpoint<
1863                            fidl::endpoints::ClientEnd<SnapshotReceiverMarker>,
1864                        >,
1865                        fidl::encoding::DefaultFuchsiaResourceDialect
1866                    )
1867                });
1868                fidl::decode!(
1869                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>,
1870                    fidl::encoding::DefaultFuchsiaResourceDialect,
1871                    val_ref,
1872                    decoder,
1873                    inner_offset,
1874                    inner_depth
1875                )?;
1876                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1877                {
1878                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1879                }
1880                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1881                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1882                }
1883            }
1884
1885            next_offset += envelope_size;
1886
1887            // Decode the remaining unknown envelopes.
1888            while next_offset < end_offset {
1889                _next_ordinal_to_read += 1;
1890                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1891                next_offset += envelope_size;
1892            }
1893
1894            Ok(())
1895        }
1896    }
1897
1898    impl CollectorListStoredSnapshotsRequest {
1899        #[inline(always)]
1900        fn max_ordinal_present(&self) -> u64 {
1901            if let Some(_) = self.process_selector {
1902                return 2;
1903            }
1904            if let Some(_) = self.iterator {
1905                return 1;
1906            }
1907            0
1908        }
1909    }
1910
1911    impl fidl::encoding::ResourceTypeMarker for CollectorListStoredSnapshotsRequest {
1912        type Borrowed<'a> = &'a mut Self;
1913        fn take_or_borrow<'a>(
1914            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1915        ) -> Self::Borrowed<'a> {
1916            value
1917        }
1918    }
1919
1920    unsafe impl fidl::encoding::TypeMarker for CollectorListStoredSnapshotsRequest {
1921        type Owned = Self;
1922
1923        #[inline(always)]
1924        fn inline_align(_context: fidl::encoding::Context) -> usize {
1925            8
1926        }
1927
1928        #[inline(always)]
1929        fn inline_size(_context: fidl::encoding::Context) -> usize {
1930            16
1931        }
1932    }
1933
1934    unsafe impl
1935        fidl::encoding::Encode<
1936            CollectorListStoredSnapshotsRequest,
1937            fidl::encoding::DefaultFuchsiaResourceDialect,
1938        > for &mut CollectorListStoredSnapshotsRequest
1939    {
1940        unsafe fn encode(
1941            self,
1942            encoder: &mut fidl::encoding::Encoder<
1943                '_,
1944                fidl::encoding::DefaultFuchsiaResourceDialect,
1945            >,
1946            offset: usize,
1947            mut depth: fidl::encoding::Depth,
1948        ) -> fidl::Result<()> {
1949            encoder.debug_check_bounds::<CollectorListStoredSnapshotsRequest>(offset);
1950            // Vector header
1951            let max_ordinal: u64 = self.max_ordinal_present();
1952            encoder.write_num(max_ordinal, offset);
1953            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1954            // Calling encoder.out_of_line_offset(0) is not allowed.
1955            if max_ordinal == 0 {
1956                return Ok(());
1957            }
1958            depth.increment()?;
1959            let envelope_size = 8;
1960            let bytes_len = max_ordinal as usize * envelope_size;
1961            #[allow(unused_variables)]
1962            let offset = encoder.out_of_line_offset(bytes_len);
1963            let mut _prev_end_offset: usize = 0;
1964            if 1 > max_ordinal {
1965                return Ok(());
1966            }
1967
1968            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1969            // are envelope_size bytes.
1970            let cur_offset: usize = (1 - 1) * envelope_size;
1971
1972            // Zero reserved fields.
1973            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1974
1975            // Safety:
1976            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1977            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1978            //   envelope_size bytes, there is always sufficient room.
1979            fidl::encoding::encode_in_envelope_optional::<
1980                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StoredSnapshotIteratorMarker>>,
1981                fidl::encoding::DefaultFuchsiaResourceDialect,
1982            >(
1983                self.iterator.as_mut().map(
1984                    <fidl::encoding::Endpoint<
1985                        fidl::endpoints::ServerEnd<StoredSnapshotIteratorMarker>,
1986                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1987                ),
1988                encoder,
1989                offset + cur_offset,
1990                depth,
1991            )?;
1992
1993            _prev_end_offset = cur_offset + envelope_size;
1994            if 2 > max_ordinal {
1995                return Ok(());
1996            }
1997
1998            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1999            // are envelope_size bytes.
2000            let cur_offset: usize = (2 - 1) * envelope_size;
2001
2002            // Zero reserved fields.
2003            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2004
2005            // Safety:
2006            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2007            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2008            //   envelope_size bytes, there is always sufficient room.
2009            fidl::encoding::encode_in_envelope_optional::<
2010                ProcessSelector,
2011                fidl::encoding::DefaultFuchsiaResourceDialect,
2012            >(
2013                self.process_selector
2014                    .as_ref()
2015                    .map(<ProcessSelector as fidl::encoding::ValueTypeMarker>::borrow),
2016                encoder,
2017                offset + cur_offset,
2018                depth,
2019            )?;
2020
2021            _prev_end_offset = cur_offset + envelope_size;
2022
2023            Ok(())
2024        }
2025    }
2026
2027    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2028        for CollectorListStoredSnapshotsRequest
2029    {
2030        #[inline(always)]
2031        fn new_empty() -> Self {
2032            Self::default()
2033        }
2034
2035        unsafe fn decode(
2036            &mut self,
2037            decoder: &mut fidl::encoding::Decoder<
2038                '_,
2039                fidl::encoding::DefaultFuchsiaResourceDialect,
2040            >,
2041            offset: usize,
2042            mut depth: fidl::encoding::Depth,
2043        ) -> fidl::Result<()> {
2044            decoder.debug_check_bounds::<Self>(offset);
2045            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2046                None => return Err(fidl::Error::NotNullable),
2047                Some(len) => len,
2048            };
2049            // Calling decoder.out_of_line_offset(0) is not allowed.
2050            if len == 0 {
2051                return Ok(());
2052            };
2053            depth.increment()?;
2054            let envelope_size = 8;
2055            let bytes_len = len * envelope_size;
2056            let offset = decoder.out_of_line_offset(bytes_len)?;
2057            // Decode the envelope for each type.
2058            let mut _next_ordinal_to_read = 0;
2059            let mut next_offset = offset;
2060            let end_offset = offset + bytes_len;
2061            _next_ordinal_to_read += 1;
2062            if next_offset >= end_offset {
2063                return Ok(());
2064            }
2065
2066            // Decode unknown envelopes for gaps in ordinals.
2067            while _next_ordinal_to_read < 1 {
2068                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2069                _next_ordinal_to_read += 1;
2070                next_offset += envelope_size;
2071            }
2072
2073            let next_out_of_line = decoder.next_out_of_line();
2074            let handles_before = decoder.remaining_handles();
2075            if let Some((inlined, num_bytes, num_handles)) =
2076                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2077            {
2078                let member_inline_size = <fidl::encoding::Endpoint<
2079                    fidl::endpoints::ServerEnd<StoredSnapshotIteratorMarker>,
2080                > as fidl::encoding::TypeMarker>::inline_size(
2081                    decoder.context
2082                );
2083                if inlined != (member_inline_size <= 4) {
2084                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2085                }
2086                let inner_offset;
2087                let mut inner_depth = depth.clone();
2088                if inlined {
2089                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2090                    inner_offset = next_offset;
2091                } else {
2092                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2093                    inner_depth.increment()?;
2094                }
2095                let val_ref = self.iterator.get_or_insert_with(|| {
2096                    fidl::new_empty!(
2097                        fidl::encoding::Endpoint<
2098                            fidl::endpoints::ServerEnd<StoredSnapshotIteratorMarker>,
2099                        >,
2100                        fidl::encoding::DefaultFuchsiaResourceDialect
2101                    )
2102                });
2103                fidl::decode!(
2104                    fidl::encoding::Endpoint<
2105                        fidl::endpoints::ServerEnd<StoredSnapshotIteratorMarker>,
2106                    >,
2107                    fidl::encoding::DefaultFuchsiaResourceDialect,
2108                    val_ref,
2109                    decoder,
2110                    inner_offset,
2111                    inner_depth
2112                )?;
2113                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2114                {
2115                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2116                }
2117                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2118                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2119                }
2120            }
2121
2122            next_offset += envelope_size;
2123            _next_ordinal_to_read += 1;
2124            if next_offset >= end_offset {
2125                return Ok(());
2126            }
2127
2128            // Decode unknown envelopes for gaps in ordinals.
2129            while _next_ordinal_to_read < 2 {
2130                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2131                _next_ordinal_to_read += 1;
2132                next_offset += envelope_size;
2133            }
2134
2135            let next_out_of_line = decoder.next_out_of_line();
2136            let handles_before = decoder.remaining_handles();
2137            if let Some((inlined, num_bytes, num_handles)) =
2138                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2139            {
2140                let member_inline_size =
2141                    <ProcessSelector as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2142                if inlined != (member_inline_size <= 4) {
2143                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2144                }
2145                let inner_offset;
2146                let mut inner_depth = depth.clone();
2147                if inlined {
2148                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2149                    inner_offset = next_offset;
2150                } else {
2151                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2152                    inner_depth.increment()?;
2153                }
2154                let val_ref = self.process_selector.get_or_insert_with(|| {
2155                    fidl::new_empty!(ProcessSelector, fidl::encoding::DefaultFuchsiaResourceDialect)
2156                });
2157                fidl::decode!(
2158                    ProcessSelector,
2159                    fidl::encoding::DefaultFuchsiaResourceDialect,
2160                    val_ref,
2161                    decoder,
2162                    inner_offset,
2163                    inner_depth
2164                )?;
2165                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2166                {
2167                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2168                }
2169                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2170                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2171                }
2172            }
2173
2174            next_offset += envelope_size;
2175
2176            // Decode the remaining unknown envelopes.
2177            while next_offset < end_offset {
2178                _next_ordinal_to_read += 1;
2179                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2180                next_offset += envelope_size;
2181            }
2182
2183            Ok(())
2184        }
2185    }
2186
2187    impl CollectorTakeLiveSnapshotRequest {
2188        #[inline(always)]
2189        fn max_ordinal_present(&self) -> u64 {
2190            if let Some(_) = self.with_contents {
2191                return 3;
2192            }
2193            if let Some(_) = self.receiver {
2194                return 2;
2195            }
2196            if let Some(_) = self.process_selector {
2197                return 1;
2198            }
2199            0
2200        }
2201    }
2202
2203    impl fidl::encoding::ResourceTypeMarker for CollectorTakeLiveSnapshotRequest {
2204        type Borrowed<'a> = &'a mut Self;
2205        fn take_or_borrow<'a>(
2206            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2207        ) -> Self::Borrowed<'a> {
2208            value
2209        }
2210    }
2211
2212    unsafe impl fidl::encoding::TypeMarker for CollectorTakeLiveSnapshotRequest {
2213        type Owned = Self;
2214
2215        #[inline(always)]
2216        fn inline_align(_context: fidl::encoding::Context) -> usize {
2217            8
2218        }
2219
2220        #[inline(always)]
2221        fn inline_size(_context: fidl::encoding::Context) -> usize {
2222            16
2223        }
2224    }
2225
2226    unsafe impl
2227        fidl::encoding::Encode<
2228            CollectorTakeLiveSnapshotRequest,
2229            fidl::encoding::DefaultFuchsiaResourceDialect,
2230        > for &mut CollectorTakeLiveSnapshotRequest
2231    {
2232        unsafe fn encode(
2233            self,
2234            encoder: &mut fidl::encoding::Encoder<
2235                '_,
2236                fidl::encoding::DefaultFuchsiaResourceDialect,
2237            >,
2238            offset: usize,
2239            mut depth: fidl::encoding::Depth,
2240        ) -> fidl::Result<()> {
2241            encoder.debug_check_bounds::<CollectorTakeLiveSnapshotRequest>(offset);
2242            // Vector header
2243            let max_ordinal: u64 = self.max_ordinal_present();
2244            encoder.write_num(max_ordinal, offset);
2245            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2246            // Calling encoder.out_of_line_offset(0) is not allowed.
2247            if max_ordinal == 0 {
2248                return Ok(());
2249            }
2250            depth.increment()?;
2251            let envelope_size = 8;
2252            let bytes_len = max_ordinal as usize * envelope_size;
2253            #[allow(unused_variables)]
2254            let offset = encoder.out_of_line_offset(bytes_len);
2255            let mut _prev_end_offset: usize = 0;
2256            if 1 > max_ordinal {
2257                return Ok(());
2258            }
2259
2260            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2261            // are envelope_size bytes.
2262            let cur_offset: usize = (1 - 1) * envelope_size;
2263
2264            // Zero reserved fields.
2265            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2266
2267            // Safety:
2268            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2269            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2270            //   envelope_size bytes, there is always sufficient room.
2271            fidl::encoding::encode_in_envelope_optional::<
2272                ProcessSelector,
2273                fidl::encoding::DefaultFuchsiaResourceDialect,
2274            >(
2275                self.process_selector
2276                    .as_ref()
2277                    .map(<ProcessSelector as fidl::encoding::ValueTypeMarker>::borrow),
2278                encoder,
2279                offset + cur_offset,
2280                depth,
2281            )?;
2282
2283            _prev_end_offset = cur_offset + envelope_size;
2284            if 2 > max_ordinal {
2285                return Ok(());
2286            }
2287
2288            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2289            // are envelope_size bytes.
2290            let cur_offset: usize = (2 - 1) * envelope_size;
2291
2292            // Zero reserved fields.
2293            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2294
2295            // Safety:
2296            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2297            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2298            //   envelope_size bytes, there is always sufficient room.
2299            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2300            self.receiver.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2301            encoder, offset + cur_offset, depth
2302        )?;
2303
2304            _prev_end_offset = cur_offset + envelope_size;
2305            if 3 > max_ordinal {
2306                return Ok(());
2307            }
2308
2309            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2310            // are envelope_size bytes.
2311            let cur_offset: usize = (3 - 1) * envelope_size;
2312
2313            // Zero reserved fields.
2314            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2315
2316            // Safety:
2317            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2318            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2319            //   envelope_size bytes, there is always sufficient room.
2320            fidl::encoding::encode_in_envelope_optional::<
2321                bool,
2322                fidl::encoding::DefaultFuchsiaResourceDialect,
2323            >(
2324                self.with_contents.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2325                encoder,
2326                offset + cur_offset,
2327                depth,
2328            )?;
2329
2330            _prev_end_offset = cur_offset + envelope_size;
2331
2332            Ok(())
2333        }
2334    }
2335
2336    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2337        for CollectorTakeLiveSnapshotRequest
2338    {
2339        #[inline(always)]
2340        fn new_empty() -> Self {
2341            Self::default()
2342        }
2343
2344        unsafe fn decode(
2345            &mut self,
2346            decoder: &mut fidl::encoding::Decoder<
2347                '_,
2348                fidl::encoding::DefaultFuchsiaResourceDialect,
2349            >,
2350            offset: usize,
2351            mut depth: fidl::encoding::Depth,
2352        ) -> fidl::Result<()> {
2353            decoder.debug_check_bounds::<Self>(offset);
2354            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2355                None => return Err(fidl::Error::NotNullable),
2356                Some(len) => len,
2357            };
2358            // Calling decoder.out_of_line_offset(0) is not allowed.
2359            if len == 0 {
2360                return Ok(());
2361            };
2362            depth.increment()?;
2363            let envelope_size = 8;
2364            let bytes_len = len * envelope_size;
2365            let offset = decoder.out_of_line_offset(bytes_len)?;
2366            // Decode the envelope for each type.
2367            let mut _next_ordinal_to_read = 0;
2368            let mut next_offset = offset;
2369            let end_offset = offset + bytes_len;
2370            _next_ordinal_to_read += 1;
2371            if next_offset >= end_offset {
2372                return Ok(());
2373            }
2374
2375            // Decode unknown envelopes for gaps in ordinals.
2376            while _next_ordinal_to_read < 1 {
2377                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2378                _next_ordinal_to_read += 1;
2379                next_offset += envelope_size;
2380            }
2381
2382            let next_out_of_line = decoder.next_out_of_line();
2383            let handles_before = decoder.remaining_handles();
2384            if let Some((inlined, num_bytes, num_handles)) =
2385                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2386            {
2387                let member_inline_size =
2388                    <ProcessSelector as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2389                if inlined != (member_inline_size <= 4) {
2390                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2391                }
2392                let inner_offset;
2393                let mut inner_depth = depth.clone();
2394                if inlined {
2395                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2396                    inner_offset = next_offset;
2397                } else {
2398                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2399                    inner_depth.increment()?;
2400                }
2401                let val_ref = self.process_selector.get_or_insert_with(|| {
2402                    fidl::new_empty!(ProcessSelector, fidl::encoding::DefaultFuchsiaResourceDialect)
2403                });
2404                fidl::decode!(
2405                    ProcessSelector,
2406                    fidl::encoding::DefaultFuchsiaResourceDialect,
2407                    val_ref,
2408                    decoder,
2409                    inner_offset,
2410                    inner_depth
2411                )?;
2412                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2413                {
2414                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2415                }
2416                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2417                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2418                }
2419            }
2420
2421            next_offset += envelope_size;
2422            _next_ordinal_to_read += 1;
2423            if next_offset >= end_offset {
2424                return Ok(());
2425            }
2426
2427            // Decode unknown envelopes for gaps in ordinals.
2428            while _next_ordinal_to_read < 2 {
2429                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2430                _next_ordinal_to_read += 1;
2431                next_offset += envelope_size;
2432            }
2433
2434            let next_out_of_line = decoder.next_out_of_line();
2435            let handles_before = decoder.remaining_handles();
2436            if let Some((inlined, num_bytes, num_handles)) =
2437                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2438            {
2439                let member_inline_size = <fidl::encoding::Endpoint<
2440                    fidl::endpoints::ClientEnd<SnapshotReceiverMarker>,
2441                > as fidl::encoding::TypeMarker>::inline_size(
2442                    decoder.context
2443                );
2444                if inlined != (member_inline_size <= 4) {
2445                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2446                }
2447                let inner_offset;
2448                let mut inner_depth = depth.clone();
2449                if inlined {
2450                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2451                    inner_offset = next_offset;
2452                } else {
2453                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2454                    inner_depth.increment()?;
2455                }
2456                let val_ref = self.receiver.get_or_insert_with(|| {
2457                    fidl::new_empty!(
2458                        fidl::encoding::Endpoint<
2459                            fidl::endpoints::ClientEnd<SnapshotReceiverMarker>,
2460                        >,
2461                        fidl::encoding::DefaultFuchsiaResourceDialect
2462                    )
2463                });
2464                fidl::decode!(
2465                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnapshotReceiverMarker>>,
2466                    fidl::encoding::DefaultFuchsiaResourceDialect,
2467                    val_ref,
2468                    decoder,
2469                    inner_offset,
2470                    inner_depth
2471                )?;
2472                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2473                {
2474                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2475                }
2476                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2477                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2478                }
2479            }
2480
2481            next_offset += envelope_size;
2482            _next_ordinal_to_read += 1;
2483            if next_offset >= end_offset {
2484                return Ok(());
2485            }
2486
2487            // Decode unknown envelopes for gaps in ordinals.
2488            while _next_ordinal_to_read < 3 {
2489                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2490                _next_ordinal_to_read += 1;
2491                next_offset += envelope_size;
2492            }
2493
2494            let next_out_of_line = decoder.next_out_of_line();
2495            let handles_before = decoder.remaining_handles();
2496            if let Some((inlined, num_bytes, num_handles)) =
2497                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2498            {
2499                let member_inline_size =
2500                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2501                if inlined != (member_inline_size <= 4) {
2502                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2503                }
2504                let inner_offset;
2505                let mut inner_depth = depth.clone();
2506                if inlined {
2507                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2508                    inner_offset = next_offset;
2509                } else {
2510                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2511                    inner_depth.increment()?;
2512                }
2513                let val_ref = self.with_contents.get_or_insert_with(|| {
2514                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2515                });
2516                fidl::decode!(
2517                    bool,
2518                    fidl::encoding::DefaultFuchsiaResourceDialect,
2519                    val_ref,
2520                    decoder,
2521                    inner_offset,
2522                    inner_depth
2523                )?;
2524                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2525                {
2526                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2527                }
2528                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2529                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2530                }
2531            }
2532
2533            next_offset += envelope_size;
2534
2535            // Decode the remaining unknown envelopes.
2536            while next_offset < end_offset {
2537                _next_ordinal_to_read += 1;
2538                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2539                next_offset += envelope_size;
2540            }
2541
2542            Ok(())
2543        }
2544    }
2545}