Skip to main content

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