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