fidl_fuchsia_memory_attribution_plugin/
fidl_fuchsia_memory_attribution_plugin.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_attribution_plugin__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct MemoryMonitorGetSnapshotRequest {
16    pub snapshot: fidl::Socket,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for MemoryMonitorGetSnapshotRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct MemoryMonitorMarker;
26
27impl fidl::endpoints::ProtocolMarker for MemoryMonitorMarker {
28    type Proxy = MemoryMonitorProxy;
29    type RequestStream = MemoryMonitorRequestStream;
30    #[cfg(target_os = "fuchsia")]
31    type SynchronousProxy = MemoryMonitorSynchronousProxy;
32
33    const DEBUG_NAME: &'static str = "fuchsia.memory.attribution.plugin.MemoryMonitor";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for MemoryMonitorMarker {}
36
37pub trait MemoryMonitorProxyInterface: Send + Sync {
38    fn r#get_snapshot(&self, snapshot: fidl::Socket) -> Result<(), fidl::Error>;
39    type GetSystemStatisticsResponseFut: std::future::Future<Output = Result<MemoryStatistics, fidl::Error>>
40        + Send;
41    fn r#get_system_statistics(&self) -> Self::GetSystemStatisticsResponseFut;
42}
43#[derive(Debug)]
44#[cfg(target_os = "fuchsia")]
45pub struct MemoryMonitorSynchronousProxy {
46    client: fidl::client::sync::Client,
47}
48
49#[cfg(target_os = "fuchsia")]
50impl fidl::endpoints::SynchronousProxy for MemoryMonitorSynchronousProxy {
51    type Proxy = MemoryMonitorProxy;
52    type Protocol = MemoryMonitorMarker;
53
54    fn from_channel(inner: fidl::Channel) -> Self {
55        Self::new(inner)
56    }
57
58    fn into_channel(self) -> fidl::Channel {
59        self.client.into_channel()
60    }
61
62    fn as_channel(&self) -> &fidl::Channel {
63        self.client.as_channel()
64    }
65}
66
67#[cfg(target_os = "fuchsia")]
68impl MemoryMonitorSynchronousProxy {
69    pub fn new(channel: fidl::Channel) -> Self {
70        let protocol_name = <MemoryMonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
71        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
72    }
73
74    pub fn into_channel(self) -> fidl::Channel {
75        self.client.into_channel()
76    }
77
78    /// Waits until an event arrives and returns it. It is safe for other
79    /// threads to make concurrent requests while waiting for an event.
80    pub fn wait_for_event(
81        &self,
82        deadline: zx::MonotonicInstant,
83    ) -> Result<MemoryMonitorEvent, fidl::Error> {
84        MemoryMonitorEvent::decode(self.client.wait_for_event(deadline)?)
85    }
86
87    pub fn r#get_snapshot(&self, mut snapshot: fidl::Socket) -> Result<(), fidl::Error> {
88        self.client.send::<MemoryMonitorGetSnapshotRequest>(
89            (snapshot,),
90            0x3af6caa4c6a6fdb7,
91            fidl::encoding::DynamicFlags::FLEXIBLE,
92        )
93    }
94
95    pub fn r#get_system_statistics(
96        &self,
97        ___deadline: zx::MonotonicInstant,
98    ) -> Result<MemoryStatistics, fidl::Error> {
99        let _response = self.client.send_query::<
100            fidl::encoding::EmptyPayload,
101            fidl::encoding::FlexibleType<MemoryMonitorGetSystemStatisticsResponse>,
102        >(
103            (),
104            0x33e3c58dc277f92d,
105            fidl::encoding::DynamicFlags::FLEXIBLE,
106            ___deadline,
107        )?
108        .into_result::<MemoryMonitorMarker>("get_system_statistics")?;
109        Ok(_response.statistics)
110    }
111}
112
113#[cfg(target_os = "fuchsia")]
114impl From<MemoryMonitorSynchronousProxy> for zx::Handle {
115    fn from(value: MemoryMonitorSynchronousProxy) -> Self {
116        value.into_channel().into()
117    }
118}
119
120#[cfg(target_os = "fuchsia")]
121impl From<fidl::Channel> for MemoryMonitorSynchronousProxy {
122    fn from(value: fidl::Channel) -> Self {
123        Self::new(value)
124    }
125}
126
127#[cfg(target_os = "fuchsia")]
128impl fidl::endpoints::FromClient for MemoryMonitorSynchronousProxy {
129    type Protocol = MemoryMonitorMarker;
130
131    fn from_client(value: fidl::endpoints::ClientEnd<MemoryMonitorMarker>) -> Self {
132        Self::new(value.into_channel())
133    }
134}
135
136#[derive(Debug, Clone)]
137pub struct MemoryMonitorProxy {
138    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
139}
140
141impl fidl::endpoints::Proxy for MemoryMonitorProxy {
142    type Protocol = MemoryMonitorMarker;
143
144    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
145        Self::new(inner)
146    }
147
148    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
149        self.client.into_channel().map_err(|client| Self { client })
150    }
151
152    fn as_channel(&self) -> &::fidl::AsyncChannel {
153        self.client.as_channel()
154    }
155}
156
157impl MemoryMonitorProxy {
158    /// Create a new Proxy for fuchsia.memory.attribution.plugin/MemoryMonitor.
159    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
160        let protocol_name = <MemoryMonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
161        Self { client: fidl::client::Client::new(channel, protocol_name) }
162    }
163
164    /// Get a Stream of events from the remote end of the protocol.
165    ///
166    /// # Panics
167    ///
168    /// Panics if the event stream was already taken.
169    pub fn take_event_stream(&self) -> MemoryMonitorEventStream {
170        MemoryMonitorEventStream { event_receiver: self.client.take_event_receiver() }
171    }
172
173    pub fn r#get_snapshot(&self, mut snapshot: fidl::Socket) -> Result<(), fidl::Error> {
174        MemoryMonitorProxyInterface::r#get_snapshot(self, snapshot)
175    }
176
177    pub fn r#get_system_statistics(
178        &self,
179    ) -> fidl::client::QueryResponseFut<
180        MemoryStatistics,
181        fidl::encoding::DefaultFuchsiaResourceDialect,
182    > {
183        MemoryMonitorProxyInterface::r#get_system_statistics(self)
184    }
185}
186
187impl MemoryMonitorProxyInterface for MemoryMonitorProxy {
188    fn r#get_snapshot(&self, mut snapshot: fidl::Socket) -> Result<(), fidl::Error> {
189        self.client.send::<MemoryMonitorGetSnapshotRequest>(
190            (snapshot,),
191            0x3af6caa4c6a6fdb7,
192            fidl::encoding::DynamicFlags::FLEXIBLE,
193        )
194    }
195
196    type GetSystemStatisticsResponseFut = fidl::client::QueryResponseFut<
197        MemoryStatistics,
198        fidl::encoding::DefaultFuchsiaResourceDialect,
199    >;
200    fn r#get_system_statistics(&self) -> Self::GetSystemStatisticsResponseFut {
201        fn _decode(
202            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
203        ) -> Result<MemoryStatistics, fidl::Error> {
204            let _response = fidl::client::decode_transaction_body::<
205                fidl::encoding::FlexibleType<MemoryMonitorGetSystemStatisticsResponse>,
206                fidl::encoding::DefaultFuchsiaResourceDialect,
207                0x33e3c58dc277f92d,
208            >(_buf?)?
209            .into_result::<MemoryMonitorMarker>("get_system_statistics")?;
210            Ok(_response.statistics)
211        }
212        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, MemoryStatistics>(
213            (),
214            0x33e3c58dc277f92d,
215            fidl::encoding::DynamicFlags::FLEXIBLE,
216            _decode,
217        )
218    }
219}
220
221pub struct MemoryMonitorEventStream {
222    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
223}
224
225impl std::marker::Unpin for MemoryMonitorEventStream {}
226
227impl futures::stream::FusedStream for MemoryMonitorEventStream {
228    fn is_terminated(&self) -> bool {
229        self.event_receiver.is_terminated()
230    }
231}
232
233impl futures::Stream for MemoryMonitorEventStream {
234    type Item = Result<MemoryMonitorEvent, fidl::Error>;
235
236    fn poll_next(
237        mut self: std::pin::Pin<&mut Self>,
238        cx: &mut std::task::Context<'_>,
239    ) -> std::task::Poll<Option<Self::Item>> {
240        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
241            &mut self.event_receiver,
242            cx
243        )?) {
244            Some(buf) => std::task::Poll::Ready(Some(MemoryMonitorEvent::decode(buf))),
245            None => std::task::Poll::Ready(None),
246        }
247    }
248}
249
250#[derive(Debug)]
251pub enum MemoryMonitorEvent {
252    #[non_exhaustive]
253    _UnknownEvent {
254        /// Ordinal of the event that was sent.
255        ordinal: u64,
256    },
257}
258
259impl MemoryMonitorEvent {
260    /// Decodes a message buffer as a [`MemoryMonitorEvent`].
261    fn decode(
262        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
263    ) -> Result<MemoryMonitorEvent, fidl::Error> {
264        let (bytes, _handles) = buf.split_mut();
265        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
266        debug_assert_eq!(tx_header.tx_id, 0);
267        match tx_header.ordinal {
268            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
269                Ok(MemoryMonitorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
270            }
271            _ => Err(fidl::Error::UnknownOrdinal {
272                ordinal: tx_header.ordinal,
273                protocol_name: <MemoryMonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
274            }),
275        }
276    }
277}
278
279/// A Stream of incoming requests for fuchsia.memory.attribution.plugin/MemoryMonitor.
280pub struct MemoryMonitorRequestStream {
281    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
282    is_terminated: bool,
283}
284
285impl std::marker::Unpin for MemoryMonitorRequestStream {}
286
287impl futures::stream::FusedStream for MemoryMonitorRequestStream {
288    fn is_terminated(&self) -> bool {
289        self.is_terminated
290    }
291}
292
293impl fidl::endpoints::RequestStream for MemoryMonitorRequestStream {
294    type Protocol = MemoryMonitorMarker;
295    type ControlHandle = MemoryMonitorControlHandle;
296
297    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
298        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
299    }
300
301    fn control_handle(&self) -> Self::ControlHandle {
302        MemoryMonitorControlHandle { inner: self.inner.clone() }
303    }
304
305    fn into_inner(
306        self,
307    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
308    {
309        (self.inner, self.is_terminated)
310    }
311
312    fn from_inner(
313        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
314        is_terminated: bool,
315    ) -> Self {
316        Self { inner, is_terminated }
317    }
318}
319
320impl futures::Stream for MemoryMonitorRequestStream {
321    type Item = Result<MemoryMonitorRequest, fidl::Error>;
322
323    fn poll_next(
324        mut self: std::pin::Pin<&mut Self>,
325        cx: &mut std::task::Context<'_>,
326    ) -> std::task::Poll<Option<Self::Item>> {
327        let this = &mut *self;
328        if this.inner.check_shutdown(cx) {
329            this.is_terminated = true;
330            return std::task::Poll::Ready(None);
331        }
332        if this.is_terminated {
333            panic!("polled MemoryMonitorRequestStream after completion");
334        }
335        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
336            |bytes, handles| {
337                match this.inner.channel().read_etc(cx, bytes, handles) {
338                    std::task::Poll::Ready(Ok(())) => {}
339                    std::task::Poll::Pending => return std::task::Poll::Pending,
340                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
341                        this.is_terminated = true;
342                        return std::task::Poll::Ready(None);
343                    }
344                    std::task::Poll::Ready(Err(e)) => {
345                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
346                            e.into(),
347                        ))));
348                    }
349                }
350
351                // A message has been received from the channel
352                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
353
354                std::task::Poll::Ready(Some(match header.ordinal {
355                    0x3af6caa4c6a6fdb7 => {
356                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
357                        let mut req = fidl::new_empty!(
358                            MemoryMonitorGetSnapshotRequest,
359                            fidl::encoding::DefaultFuchsiaResourceDialect
360                        );
361                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MemoryMonitorGetSnapshotRequest>(&header, _body_bytes, handles, &mut req)?;
362                        let control_handle =
363                            MemoryMonitorControlHandle { inner: this.inner.clone() };
364                        Ok(MemoryMonitorRequest::GetSnapshot {
365                            snapshot: req.snapshot,
366
367                            control_handle,
368                        })
369                    }
370                    0x33e3c58dc277f92d => {
371                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
372                        let mut req = fidl::new_empty!(
373                            fidl::encoding::EmptyPayload,
374                            fidl::encoding::DefaultFuchsiaResourceDialect
375                        );
376                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
377                        let control_handle =
378                            MemoryMonitorControlHandle { inner: this.inner.clone() };
379                        Ok(MemoryMonitorRequest::GetSystemStatistics {
380                            responder: MemoryMonitorGetSystemStatisticsResponder {
381                                control_handle: std::mem::ManuallyDrop::new(control_handle),
382                                tx_id: header.tx_id,
383                            },
384                        })
385                    }
386                    _ if header.tx_id == 0
387                        && header
388                            .dynamic_flags()
389                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
390                    {
391                        Ok(MemoryMonitorRequest::_UnknownMethod {
392                            ordinal: header.ordinal,
393                            control_handle: MemoryMonitorControlHandle {
394                                inner: this.inner.clone(),
395                            },
396                            method_type: fidl::MethodType::OneWay,
397                        })
398                    }
399                    _ if header
400                        .dynamic_flags()
401                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
402                    {
403                        this.inner.send_framework_err(
404                            fidl::encoding::FrameworkErr::UnknownMethod,
405                            header.tx_id,
406                            header.ordinal,
407                            header.dynamic_flags(),
408                            (bytes, handles),
409                        )?;
410                        Ok(MemoryMonitorRequest::_UnknownMethod {
411                            ordinal: header.ordinal,
412                            control_handle: MemoryMonitorControlHandle {
413                                inner: this.inner.clone(),
414                            },
415                            method_type: fidl::MethodType::TwoWay,
416                        })
417                    }
418                    _ => Err(fidl::Error::UnknownOrdinal {
419                        ordinal: header.ordinal,
420                        protocol_name:
421                            <MemoryMonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
422                    }),
423                }))
424            },
425        )
426    }
427}
428
429#[derive(Debug)]
430pub enum MemoryMonitorRequest {
431    GetSnapshot {
432        snapshot: fidl::Socket,
433        control_handle: MemoryMonitorControlHandle,
434    },
435    GetSystemStatistics {
436        responder: MemoryMonitorGetSystemStatisticsResponder,
437    },
438    /// An interaction was received which does not match any known method.
439    #[non_exhaustive]
440    _UnknownMethod {
441        /// Ordinal of the method that was called.
442        ordinal: u64,
443        control_handle: MemoryMonitorControlHandle,
444        method_type: fidl::MethodType,
445    },
446}
447
448impl MemoryMonitorRequest {
449    #[allow(irrefutable_let_patterns)]
450    pub fn into_get_snapshot(self) -> Option<(fidl::Socket, MemoryMonitorControlHandle)> {
451        if let MemoryMonitorRequest::GetSnapshot { snapshot, control_handle } = self {
452            Some((snapshot, control_handle))
453        } else {
454            None
455        }
456    }
457
458    #[allow(irrefutable_let_patterns)]
459    pub fn into_get_system_statistics(self) -> Option<(MemoryMonitorGetSystemStatisticsResponder)> {
460        if let MemoryMonitorRequest::GetSystemStatistics { responder } = self {
461            Some((responder))
462        } else {
463            None
464        }
465    }
466
467    /// Name of the method defined in FIDL
468    pub fn method_name(&self) -> &'static str {
469        match *self {
470            MemoryMonitorRequest::GetSnapshot { .. } => "get_snapshot",
471            MemoryMonitorRequest::GetSystemStatistics { .. } => "get_system_statistics",
472            MemoryMonitorRequest::_UnknownMethod {
473                method_type: fidl::MethodType::OneWay, ..
474            } => "unknown one-way method",
475            MemoryMonitorRequest::_UnknownMethod {
476                method_type: fidl::MethodType::TwoWay, ..
477            } => "unknown two-way method",
478        }
479    }
480}
481
482#[derive(Debug, Clone)]
483pub struct MemoryMonitorControlHandle {
484    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
485}
486
487impl fidl::endpoints::ControlHandle for MemoryMonitorControlHandle {
488    fn shutdown(&self) {
489        self.inner.shutdown()
490    }
491    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
492        self.inner.shutdown_with_epitaph(status)
493    }
494
495    fn is_closed(&self) -> bool {
496        self.inner.channel().is_closed()
497    }
498    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
499        self.inner.channel().on_closed()
500    }
501
502    #[cfg(target_os = "fuchsia")]
503    fn signal_peer(
504        &self,
505        clear_mask: zx::Signals,
506        set_mask: zx::Signals,
507    ) -> Result<(), zx_status::Status> {
508        use fidl::Peered;
509        self.inner.channel().signal_peer(clear_mask, set_mask)
510    }
511}
512
513impl MemoryMonitorControlHandle {}
514
515#[must_use = "FIDL methods require a response to be sent"]
516#[derive(Debug)]
517pub struct MemoryMonitorGetSystemStatisticsResponder {
518    control_handle: std::mem::ManuallyDrop<MemoryMonitorControlHandle>,
519    tx_id: u32,
520}
521
522/// Set the the channel to be shutdown (see [`MemoryMonitorControlHandle::shutdown`])
523/// if the responder is dropped without sending a response, so that the client
524/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
525impl std::ops::Drop for MemoryMonitorGetSystemStatisticsResponder {
526    fn drop(&mut self) {
527        self.control_handle.shutdown();
528        // Safety: drops once, never accessed again
529        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
530    }
531}
532
533impl fidl::endpoints::Responder for MemoryMonitorGetSystemStatisticsResponder {
534    type ControlHandle = MemoryMonitorControlHandle;
535
536    fn control_handle(&self) -> &MemoryMonitorControlHandle {
537        &self.control_handle
538    }
539
540    fn drop_without_shutdown(mut self) {
541        // Safety: drops once, never accessed again due to mem::forget
542        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
543        // Prevent Drop from running (which would shut down the channel)
544        std::mem::forget(self);
545    }
546}
547
548impl MemoryMonitorGetSystemStatisticsResponder {
549    /// Sends a response to the FIDL transaction.
550    ///
551    /// Sets the channel to shutdown if an error occurs.
552    pub fn send(self, mut statistics: &MemoryStatistics) -> Result<(), fidl::Error> {
553        let _result = self.send_raw(statistics);
554        if _result.is_err() {
555            self.control_handle.shutdown();
556        }
557        self.drop_without_shutdown();
558        _result
559    }
560
561    /// Similar to "send" but does not shutdown the channel if an error occurs.
562    pub fn send_no_shutdown_on_err(
563        self,
564        mut statistics: &MemoryStatistics,
565    ) -> Result<(), fidl::Error> {
566        let _result = self.send_raw(statistics);
567        self.drop_without_shutdown();
568        _result
569    }
570
571    fn send_raw(&self, mut statistics: &MemoryStatistics) -> Result<(), fidl::Error> {
572        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
573            MemoryMonitorGetSystemStatisticsResponse,
574        >>(
575            fidl::encoding::Flexible::new((statistics,)),
576            self.tx_id,
577            0x33e3c58dc277f92d,
578            fidl::encoding::DynamicFlags::FLEXIBLE,
579        )
580    }
581}
582
583mod internal {
584    use super::*;
585
586    impl fidl::encoding::ResourceTypeMarker for MemoryMonitorGetSnapshotRequest {
587        type Borrowed<'a> = &'a mut Self;
588        fn take_or_borrow<'a>(
589            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
590        ) -> Self::Borrowed<'a> {
591            value
592        }
593    }
594
595    unsafe impl fidl::encoding::TypeMarker for MemoryMonitorGetSnapshotRequest {
596        type Owned = Self;
597
598        #[inline(always)]
599        fn inline_align(_context: fidl::encoding::Context) -> usize {
600            4
601        }
602
603        #[inline(always)]
604        fn inline_size(_context: fidl::encoding::Context) -> usize {
605            4
606        }
607    }
608
609    unsafe impl
610        fidl::encoding::Encode<
611            MemoryMonitorGetSnapshotRequest,
612            fidl::encoding::DefaultFuchsiaResourceDialect,
613        > for &mut MemoryMonitorGetSnapshotRequest
614    {
615        #[inline]
616        unsafe fn encode(
617            self,
618            encoder: &mut fidl::encoding::Encoder<
619                '_,
620                fidl::encoding::DefaultFuchsiaResourceDialect,
621            >,
622            offset: usize,
623            _depth: fidl::encoding::Depth,
624        ) -> fidl::Result<()> {
625            encoder.debug_check_bounds::<MemoryMonitorGetSnapshotRequest>(offset);
626            // Delegate to tuple encoding.
627            fidl::encoding::Encode::<
628                MemoryMonitorGetSnapshotRequest,
629                fidl::encoding::DefaultFuchsiaResourceDialect,
630            >::encode(
631                (<fidl::encoding::HandleType<
632                    fidl::Socket,
633                    { fidl::ObjectType::SOCKET.into_raw() },
634                    2147483648,
635                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
636                    &mut self.snapshot
637                ),),
638                encoder,
639                offset,
640                _depth,
641            )
642        }
643    }
644    unsafe impl<
645        T0: fidl::encoding::Encode<
646                fidl::encoding::HandleType<
647                    fidl::Socket,
648                    { fidl::ObjectType::SOCKET.into_raw() },
649                    2147483648,
650                >,
651                fidl::encoding::DefaultFuchsiaResourceDialect,
652            >,
653    >
654        fidl::encoding::Encode<
655            MemoryMonitorGetSnapshotRequest,
656            fidl::encoding::DefaultFuchsiaResourceDialect,
657        > for (T0,)
658    {
659        #[inline]
660        unsafe fn encode(
661            self,
662            encoder: &mut fidl::encoding::Encoder<
663                '_,
664                fidl::encoding::DefaultFuchsiaResourceDialect,
665            >,
666            offset: usize,
667            depth: fidl::encoding::Depth,
668        ) -> fidl::Result<()> {
669            encoder.debug_check_bounds::<MemoryMonitorGetSnapshotRequest>(offset);
670            // Zero out padding regions. There's no need to apply masks
671            // because the unmasked parts will be overwritten by fields.
672            // Write the fields.
673            self.0.encode(encoder, offset + 0, depth)?;
674            Ok(())
675        }
676    }
677
678    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
679        for MemoryMonitorGetSnapshotRequest
680    {
681        #[inline(always)]
682        fn new_empty() -> Self {
683            Self {
684                snapshot: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
685            }
686        }
687
688        #[inline]
689        unsafe fn decode(
690            &mut self,
691            decoder: &mut fidl::encoding::Decoder<
692                '_,
693                fidl::encoding::DefaultFuchsiaResourceDialect,
694            >,
695            offset: usize,
696            _depth: fidl::encoding::Depth,
697        ) -> fidl::Result<()> {
698            decoder.debug_check_bounds::<Self>(offset);
699            // Verify that padding bytes are zero.
700            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.snapshot, decoder, offset + 0, _depth)?;
701            Ok(())
702        }
703    }
704}