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