Skip to main content

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