Skip to main content

fidl_fuchsia_netemul_test/
fidl_fuchsia_netemul_test.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_netemul_test_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CounterConnectToProtocolRequest {
16    pub protocol_name: String,
17    pub request: fidl::Channel,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for CounterConnectToProtocolRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct CounterOpenInNamespaceRequest {
27    pub path: String,
28    pub flags: fidl_fuchsia_io::Flags,
29    pub request: fidl::Channel,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for CounterOpenInNamespaceRequest
34{
35}
36
37#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
38pub struct CounterMarker;
39
40impl fidl::endpoints::ProtocolMarker for CounterMarker {
41    type Proxy = CounterProxy;
42    type RequestStream = CounterRequestStream;
43    #[cfg(target_os = "fuchsia")]
44    type SynchronousProxy = CounterSynchronousProxy;
45
46    const DEBUG_NAME: &'static str = "fuchsia.netemul.test.Counter";
47}
48impl fidl::endpoints::DiscoverableProtocolMarker for CounterMarker {}
49pub type CounterTryOpenDirectoryResult = Result<(), i32>;
50
51pub trait CounterProxyInterface: Send + Sync {
52    type IncrementResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
53    fn r#increment(&self) -> Self::IncrementResponseFut;
54    fn r#connect_to_protocol(
55        &self,
56        protocol_name: &str,
57        request: fidl::Channel,
58    ) -> Result<(), fidl::Error>;
59    fn r#open_in_namespace(
60        &self,
61        path: &str,
62        flags: fidl_fuchsia_io::Flags,
63        request: fidl::Channel,
64    ) -> Result<(), fidl::Error>;
65    type TryOpenDirectoryResponseFut: std::future::Future<Output = Result<CounterTryOpenDirectoryResult, fidl::Error>>
66        + Send;
67    fn r#try_open_directory(&self, path: &str) -> Self::TryOpenDirectoryResponseFut;
68    type SetAbortOnShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
69    fn r#set_abort_on_shutdown(&self, abort: bool) -> Self::SetAbortOnShutdownResponseFut;
70}
71#[derive(Debug)]
72#[cfg(target_os = "fuchsia")]
73pub struct CounterSynchronousProxy {
74    client: fidl::client::sync::Client,
75}
76
77#[cfg(target_os = "fuchsia")]
78impl fidl::endpoints::SynchronousProxy for CounterSynchronousProxy {
79    type Proxy = CounterProxy;
80    type Protocol = CounterMarker;
81
82    fn from_channel(inner: fidl::Channel) -> Self {
83        Self::new(inner)
84    }
85
86    fn into_channel(self) -> fidl::Channel {
87        self.client.into_channel()
88    }
89
90    fn as_channel(&self) -> &fidl::Channel {
91        self.client.as_channel()
92    }
93}
94
95#[cfg(target_os = "fuchsia")]
96impl CounterSynchronousProxy {
97    pub fn new(channel: fidl::Channel) -> Self {
98        Self { client: fidl::client::sync::Client::new(channel) }
99    }
100
101    pub fn into_channel(self) -> fidl::Channel {
102        self.client.into_channel()
103    }
104
105    /// Waits until an event arrives and returns it. It is safe for other
106    /// threads to make concurrent requests while waiting for an event.
107    pub fn wait_for_event(
108        &self,
109        deadline: zx::MonotonicInstant,
110    ) -> Result<CounterEvent, fidl::Error> {
111        CounterEvent::decode(self.client.wait_for_event::<CounterMarker>(deadline)?)
112    }
113
114    /// Increments internal counter by one and returns new counter value.
115    pub fn r#increment(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
116        let _response = self
117            .client
118            .send_query::<fidl::encoding::EmptyPayload, CounterIncrementResponse, CounterMarker>(
119                (),
120                0x60cf610cd915d7a9,
121                fidl::encoding::DynamicFlags::empty(),
122                ___deadline,
123            )?;
124        Ok(_response.value)
125    }
126
127    /// Connects `request` to a protocol in the `/svc` directory named
128    /// `protocol_name`.
129    pub fn r#connect_to_protocol(
130        &self,
131        mut protocol_name: &str,
132        mut request: fidl::Channel,
133    ) -> Result<(), fidl::Error> {
134        self.client.send::<CounterConnectToProtocolRequest>(
135            (protocol_name, request),
136            0x75ea8d3a0e7a4f68,
137            fidl::encoding::DynamicFlags::empty(),
138        )
139    }
140
141    /// Opens the node found at `path` in the component's namespace with
142    /// `flags`, and connects `request`.
143    ///
144    /// This is essentially a wrapper around [`fuchsia.io/Directory.Open`],
145    /// which always opens in an implementation-defined mode.
146    ///
147    /// + request `path` the absolute path from the root of the server's
148    ///     namespace.
149    /// + request `flags` the rights with which to open the node.
150    /// + request `request` the server end channel to the node.
151    pub fn r#open_in_namespace(
152        &self,
153        mut path: &str,
154        mut flags: fidl_fuchsia_io::Flags,
155        mut request: fidl::Channel,
156    ) -> Result<(), fidl::Error> {
157        self.client.send::<CounterOpenInNamespaceRequest>(
158            (path, flags, request),
159            0x393b5808935aee83,
160            fidl::encoding::DynamicFlags::empty(),
161        )
162    }
163
164    /// Opens the directory found at `path`.
165    ///
166    /// + request `path` the absolute path from the server's namespace.
167    /// * error `ZX_ERR_NOT_FOUND` if the directory at `path` is not in the server's namespace.
168    /// * error `ZX_ERR_IO` if there is some other unspecified error during I/O.
169    pub fn r#try_open_directory(
170        &self,
171        mut path: &str,
172        ___deadline: zx::MonotonicInstant,
173    ) -> Result<CounterTryOpenDirectoryResult, fidl::Error> {
174        let _response = self.client.send_query::<
175            CounterTryOpenDirectoryRequest,
176            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
177            CounterMarker,
178        >(
179            (path,),
180            0x37310702b1c8b863,
181            fidl::encoding::DynamicFlags::empty(),
182            ___deadline,
183        )?;
184        Ok(_response.map(|x| x))
185    }
186
187    /// Controls whether this component crashes (via abort) after receiving a
188    /// shutdown signal.
189    ///
190    /// + request `abort` whether or not to abort on shutdown.
191    pub fn r#set_abort_on_shutdown(
192        &self,
193        mut abort: bool,
194        ___deadline: zx::MonotonicInstant,
195    ) -> Result<(), fidl::Error> {
196        let _response = self.client.send_query::<
197            CounterSetAbortOnShutdownRequest,
198            fidl::encoding::EmptyPayload,
199            CounterMarker,
200        >(
201            (abort,),
202            0x1d9c7aac19741829,
203            fidl::encoding::DynamicFlags::empty(),
204            ___deadline,
205        )?;
206        Ok(_response)
207    }
208}
209
210#[cfg(target_os = "fuchsia")]
211impl From<CounterSynchronousProxy> for zx::NullableHandle {
212    fn from(value: CounterSynchronousProxy) -> Self {
213        value.into_channel().into()
214    }
215}
216
217#[cfg(target_os = "fuchsia")]
218impl From<fidl::Channel> for CounterSynchronousProxy {
219    fn from(value: fidl::Channel) -> Self {
220        Self::new(value)
221    }
222}
223
224#[cfg(target_os = "fuchsia")]
225impl fidl::endpoints::FromClient for CounterSynchronousProxy {
226    type Protocol = CounterMarker;
227
228    fn from_client(value: fidl::endpoints::ClientEnd<CounterMarker>) -> Self {
229        Self::new(value.into_channel())
230    }
231}
232
233#[derive(Debug, Clone)]
234pub struct CounterProxy {
235    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
236}
237
238impl fidl::endpoints::Proxy for CounterProxy {
239    type Protocol = CounterMarker;
240
241    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
242        Self::new(inner)
243    }
244
245    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
246        self.client.into_channel().map_err(|client| Self { client })
247    }
248
249    fn as_channel(&self) -> &::fidl::AsyncChannel {
250        self.client.as_channel()
251    }
252}
253
254impl CounterProxy {
255    /// Create a new Proxy for fuchsia.netemul.test/Counter.
256    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
257        let protocol_name = <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
258        Self { client: fidl::client::Client::new(channel, protocol_name) }
259    }
260
261    /// Get a Stream of events from the remote end of the protocol.
262    ///
263    /// # Panics
264    ///
265    /// Panics if the event stream was already taken.
266    pub fn take_event_stream(&self) -> CounterEventStream {
267        CounterEventStream { event_receiver: self.client.take_event_receiver() }
268    }
269
270    /// Increments internal counter by one and returns new counter value.
271    pub fn r#increment(
272        &self,
273    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
274        CounterProxyInterface::r#increment(self)
275    }
276
277    /// Connects `request` to a protocol in the `/svc` directory named
278    /// `protocol_name`.
279    pub fn r#connect_to_protocol(
280        &self,
281        mut protocol_name: &str,
282        mut request: fidl::Channel,
283    ) -> Result<(), fidl::Error> {
284        CounterProxyInterface::r#connect_to_protocol(self, protocol_name, request)
285    }
286
287    /// Opens the node found at `path` in the component's namespace with
288    /// `flags`, and connects `request`.
289    ///
290    /// This is essentially a wrapper around [`fuchsia.io/Directory.Open`],
291    /// which always opens in an implementation-defined mode.
292    ///
293    /// + request `path` the absolute path from the root of the server's
294    ///     namespace.
295    /// + request `flags` the rights with which to open the node.
296    /// + request `request` the server end channel to the node.
297    pub fn r#open_in_namespace(
298        &self,
299        mut path: &str,
300        mut flags: fidl_fuchsia_io::Flags,
301        mut request: fidl::Channel,
302    ) -> Result<(), fidl::Error> {
303        CounterProxyInterface::r#open_in_namespace(self, path, flags, request)
304    }
305
306    /// Opens the directory found at `path`.
307    ///
308    /// + request `path` the absolute path from the server's namespace.
309    /// * error `ZX_ERR_NOT_FOUND` if the directory at `path` is not in the server's namespace.
310    /// * error `ZX_ERR_IO` if there is some other unspecified error during I/O.
311    pub fn r#try_open_directory(
312        &self,
313        mut path: &str,
314    ) -> fidl::client::QueryResponseFut<
315        CounterTryOpenDirectoryResult,
316        fidl::encoding::DefaultFuchsiaResourceDialect,
317    > {
318        CounterProxyInterface::r#try_open_directory(self, path)
319    }
320
321    /// Controls whether this component crashes (via abort) after receiving a
322    /// shutdown signal.
323    ///
324    /// + request `abort` whether or not to abort on shutdown.
325    pub fn r#set_abort_on_shutdown(
326        &self,
327        mut abort: bool,
328    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
329        CounterProxyInterface::r#set_abort_on_shutdown(self, abort)
330    }
331}
332
333impl CounterProxyInterface for CounterProxy {
334    type IncrementResponseFut =
335        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
336    fn r#increment(&self) -> Self::IncrementResponseFut {
337        fn _decode(
338            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
339        ) -> Result<u32, fidl::Error> {
340            let _response = fidl::client::decode_transaction_body::<
341                CounterIncrementResponse,
342                fidl::encoding::DefaultFuchsiaResourceDialect,
343                0x60cf610cd915d7a9,
344            >(_buf?)?;
345            Ok(_response.value)
346        }
347        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
348            (),
349            0x60cf610cd915d7a9,
350            fidl::encoding::DynamicFlags::empty(),
351            _decode,
352        )
353    }
354
355    fn r#connect_to_protocol(
356        &self,
357        mut protocol_name: &str,
358        mut request: fidl::Channel,
359    ) -> Result<(), fidl::Error> {
360        self.client.send::<CounterConnectToProtocolRequest>(
361            (protocol_name, request),
362            0x75ea8d3a0e7a4f68,
363            fidl::encoding::DynamicFlags::empty(),
364        )
365    }
366
367    fn r#open_in_namespace(
368        &self,
369        mut path: &str,
370        mut flags: fidl_fuchsia_io::Flags,
371        mut request: fidl::Channel,
372    ) -> Result<(), fidl::Error> {
373        self.client.send::<CounterOpenInNamespaceRequest>(
374            (path, flags, request),
375            0x393b5808935aee83,
376            fidl::encoding::DynamicFlags::empty(),
377        )
378    }
379
380    type TryOpenDirectoryResponseFut = fidl::client::QueryResponseFut<
381        CounterTryOpenDirectoryResult,
382        fidl::encoding::DefaultFuchsiaResourceDialect,
383    >;
384    fn r#try_open_directory(&self, mut path: &str) -> Self::TryOpenDirectoryResponseFut {
385        fn _decode(
386            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
387        ) -> Result<CounterTryOpenDirectoryResult, fidl::Error> {
388            let _response = fidl::client::decode_transaction_body::<
389                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
390                fidl::encoding::DefaultFuchsiaResourceDialect,
391                0x37310702b1c8b863,
392            >(_buf?)?;
393            Ok(_response.map(|x| x))
394        }
395        self.client
396            .send_query_and_decode::<CounterTryOpenDirectoryRequest, CounterTryOpenDirectoryResult>(
397                (path,),
398                0x37310702b1c8b863,
399                fidl::encoding::DynamicFlags::empty(),
400                _decode,
401            )
402    }
403
404    type SetAbortOnShutdownResponseFut =
405        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
406    fn r#set_abort_on_shutdown(&self, mut abort: bool) -> Self::SetAbortOnShutdownResponseFut {
407        fn _decode(
408            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
409        ) -> Result<(), fidl::Error> {
410            let _response = fidl::client::decode_transaction_body::<
411                fidl::encoding::EmptyPayload,
412                fidl::encoding::DefaultFuchsiaResourceDialect,
413                0x1d9c7aac19741829,
414            >(_buf?)?;
415            Ok(_response)
416        }
417        self.client.send_query_and_decode::<CounterSetAbortOnShutdownRequest, ()>(
418            (abort,),
419            0x1d9c7aac19741829,
420            fidl::encoding::DynamicFlags::empty(),
421            _decode,
422        )
423    }
424}
425
426pub struct CounterEventStream {
427    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
428}
429
430impl std::marker::Unpin for CounterEventStream {}
431
432impl futures::stream::FusedStream for CounterEventStream {
433    fn is_terminated(&self) -> bool {
434        self.event_receiver.is_terminated()
435    }
436}
437
438impl futures::Stream for CounterEventStream {
439    type Item = Result<CounterEvent, fidl::Error>;
440
441    fn poll_next(
442        mut self: std::pin::Pin<&mut Self>,
443        cx: &mut std::task::Context<'_>,
444    ) -> std::task::Poll<Option<Self::Item>> {
445        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
446            &mut self.event_receiver,
447            cx
448        )?) {
449            Some(buf) => std::task::Poll::Ready(Some(CounterEvent::decode(buf))),
450            None => std::task::Poll::Ready(None),
451        }
452    }
453}
454
455#[derive(Debug)]
456pub enum CounterEvent {}
457
458impl CounterEvent {
459    /// Decodes a message buffer as a [`CounterEvent`].
460    fn decode(
461        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
462    ) -> Result<CounterEvent, fidl::Error> {
463        let (bytes, _handles) = buf.split_mut();
464        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
465        debug_assert_eq!(tx_header.tx_id, 0);
466        match tx_header.ordinal {
467            _ => Err(fidl::Error::UnknownOrdinal {
468                ordinal: tx_header.ordinal,
469                protocol_name: <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
470            }),
471        }
472    }
473}
474
475/// A Stream of incoming requests for fuchsia.netemul.test/Counter.
476pub struct CounterRequestStream {
477    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
478    is_terminated: bool,
479}
480
481impl std::marker::Unpin for CounterRequestStream {}
482
483impl futures::stream::FusedStream for CounterRequestStream {
484    fn is_terminated(&self) -> bool {
485        self.is_terminated
486    }
487}
488
489impl fidl::endpoints::RequestStream for CounterRequestStream {
490    type Protocol = CounterMarker;
491    type ControlHandle = CounterControlHandle;
492
493    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
494        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
495    }
496
497    fn control_handle(&self) -> Self::ControlHandle {
498        CounterControlHandle { inner: self.inner.clone() }
499    }
500
501    fn into_inner(
502        self,
503    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
504    {
505        (self.inner, self.is_terminated)
506    }
507
508    fn from_inner(
509        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
510        is_terminated: bool,
511    ) -> Self {
512        Self { inner, is_terminated }
513    }
514}
515
516impl futures::Stream for CounterRequestStream {
517    type Item = Result<CounterRequest, fidl::Error>;
518
519    fn poll_next(
520        mut self: std::pin::Pin<&mut Self>,
521        cx: &mut std::task::Context<'_>,
522    ) -> std::task::Poll<Option<Self::Item>> {
523        let this = &mut *self;
524        if this.inner.check_shutdown(cx) {
525            this.is_terminated = true;
526            return std::task::Poll::Ready(None);
527        }
528        if this.is_terminated {
529            panic!("polled CounterRequestStream after completion");
530        }
531        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
532            |bytes, handles| {
533                match this.inner.channel().read_etc(cx, bytes, handles) {
534                    std::task::Poll::Ready(Ok(())) => {}
535                    std::task::Poll::Pending => return std::task::Poll::Pending,
536                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
537                        this.is_terminated = true;
538                        return std::task::Poll::Ready(None);
539                    }
540                    std::task::Poll::Ready(Err(e)) => {
541                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
542                            e.into(),
543                        ))));
544                    }
545                }
546
547                // A message has been received from the channel
548                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
549
550                std::task::Poll::Ready(Some(match header.ordinal {
551                    0x60cf610cd915d7a9 => {
552                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
553                        let mut req = fidl::new_empty!(
554                            fidl::encoding::EmptyPayload,
555                            fidl::encoding::DefaultFuchsiaResourceDialect
556                        );
557                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
558                        let control_handle = CounterControlHandle { inner: this.inner.clone() };
559                        Ok(CounterRequest::Increment {
560                            responder: CounterIncrementResponder {
561                                control_handle: std::mem::ManuallyDrop::new(control_handle),
562                                tx_id: header.tx_id,
563                            },
564                        })
565                    }
566                    0x75ea8d3a0e7a4f68 => {
567                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
568                        let mut req = fidl::new_empty!(
569                            CounterConnectToProtocolRequest,
570                            fidl::encoding::DefaultFuchsiaResourceDialect
571                        );
572                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CounterConnectToProtocolRequest>(&header, _body_bytes, handles, &mut req)?;
573                        let control_handle = CounterControlHandle { inner: this.inner.clone() };
574                        Ok(CounterRequest::ConnectToProtocol {
575                            protocol_name: req.protocol_name,
576                            request: req.request,
577
578                            control_handle,
579                        })
580                    }
581                    0x393b5808935aee83 => {
582                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
583                        let mut req = fidl::new_empty!(
584                            CounterOpenInNamespaceRequest,
585                            fidl::encoding::DefaultFuchsiaResourceDialect
586                        );
587                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CounterOpenInNamespaceRequest>(&header, _body_bytes, handles, &mut req)?;
588                        let control_handle = CounterControlHandle { inner: this.inner.clone() };
589                        Ok(CounterRequest::OpenInNamespace {
590                            path: req.path,
591                            flags: req.flags,
592                            request: req.request,
593
594                            control_handle,
595                        })
596                    }
597                    0x37310702b1c8b863 => {
598                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
599                        let mut req = fidl::new_empty!(
600                            CounterTryOpenDirectoryRequest,
601                            fidl::encoding::DefaultFuchsiaResourceDialect
602                        );
603                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CounterTryOpenDirectoryRequest>(&header, _body_bytes, handles, &mut req)?;
604                        let control_handle = CounterControlHandle { inner: this.inner.clone() };
605                        Ok(CounterRequest::TryOpenDirectory {
606                            path: req.path,
607
608                            responder: CounterTryOpenDirectoryResponder {
609                                control_handle: std::mem::ManuallyDrop::new(control_handle),
610                                tx_id: header.tx_id,
611                            },
612                        })
613                    }
614                    0x1d9c7aac19741829 => {
615                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
616                        let mut req = fidl::new_empty!(
617                            CounterSetAbortOnShutdownRequest,
618                            fidl::encoding::DefaultFuchsiaResourceDialect
619                        );
620                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CounterSetAbortOnShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
621                        let control_handle = CounterControlHandle { inner: this.inner.clone() };
622                        Ok(CounterRequest::SetAbortOnShutdown {
623                            abort: req.abort,
624
625                            responder: CounterSetAbortOnShutdownResponder {
626                                control_handle: std::mem::ManuallyDrop::new(control_handle),
627                                tx_id: header.tx_id,
628                            },
629                        })
630                    }
631                    _ => Err(fidl::Error::UnknownOrdinal {
632                        ordinal: header.ordinal,
633                        protocol_name:
634                            <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
635                    }),
636                }))
637            },
638        )
639    }
640}
641
642/// Sample interface that keeps a stateful integer counter starting at zero.
643#[derive(Debug)]
644pub enum CounterRequest {
645    /// Increments internal counter by one and returns new counter value.
646    Increment { responder: CounterIncrementResponder },
647    /// Connects `request` to a protocol in the `/svc` directory named
648    /// `protocol_name`.
649    ConnectToProtocol {
650        protocol_name: String,
651        request: fidl::Channel,
652        control_handle: CounterControlHandle,
653    },
654    /// Opens the node found at `path` in the component's namespace with
655    /// `flags`, and connects `request`.
656    ///
657    /// This is essentially a wrapper around [`fuchsia.io/Directory.Open`],
658    /// which always opens in an implementation-defined mode.
659    ///
660    /// + request `path` the absolute path from the root of the server's
661    ///     namespace.
662    /// + request `flags` the rights with which to open the node.
663    /// + request `request` the server end channel to the node.
664    OpenInNamespace {
665        path: String,
666        flags: fidl_fuchsia_io::Flags,
667        request: fidl::Channel,
668        control_handle: CounterControlHandle,
669    },
670    /// Opens the directory found at `path`.
671    ///
672    /// + request `path` the absolute path from the server's namespace.
673    /// * error `ZX_ERR_NOT_FOUND` if the directory at `path` is not in the server's namespace.
674    /// * error `ZX_ERR_IO` if there is some other unspecified error during I/O.
675    TryOpenDirectory { path: String, responder: CounterTryOpenDirectoryResponder },
676    /// Controls whether this component crashes (via abort) after receiving a
677    /// shutdown signal.
678    ///
679    /// + request `abort` whether or not to abort on shutdown.
680    SetAbortOnShutdown { abort: bool, responder: CounterSetAbortOnShutdownResponder },
681}
682
683impl CounterRequest {
684    #[allow(irrefutable_let_patterns)]
685    pub fn into_increment(self) -> Option<(CounterIncrementResponder)> {
686        if let CounterRequest::Increment { responder } = self { Some((responder)) } else { None }
687    }
688
689    #[allow(irrefutable_let_patterns)]
690    pub fn into_connect_to_protocol(self) -> Option<(String, fidl::Channel, CounterControlHandle)> {
691        if let CounterRequest::ConnectToProtocol { protocol_name, request, control_handle } = self {
692            Some((protocol_name, request, control_handle))
693        } else {
694            None
695        }
696    }
697
698    #[allow(irrefutable_let_patterns)]
699    pub fn into_open_in_namespace(
700        self,
701    ) -> Option<(String, fidl_fuchsia_io::Flags, fidl::Channel, CounterControlHandle)> {
702        if let CounterRequest::OpenInNamespace { path, flags, request, control_handle } = self {
703            Some((path, flags, request, control_handle))
704        } else {
705            None
706        }
707    }
708
709    #[allow(irrefutable_let_patterns)]
710    pub fn into_try_open_directory(self) -> Option<(String, CounterTryOpenDirectoryResponder)> {
711        if let CounterRequest::TryOpenDirectory { path, responder } = self {
712            Some((path, responder))
713        } else {
714            None
715        }
716    }
717
718    #[allow(irrefutable_let_patterns)]
719    pub fn into_set_abort_on_shutdown(self) -> Option<(bool, CounterSetAbortOnShutdownResponder)> {
720        if let CounterRequest::SetAbortOnShutdown { abort, responder } = self {
721            Some((abort, responder))
722        } else {
723            None
724        }
725    }
726
727    /// Name of the method defined in FIDL
728    pub fn method_name(&self) -> &'static str {
729        match *self {
730            CounterRequest::Increment { .. } => "increment",
731            CounterRequest::ConnectToProtocol { .. } => "connect_to_protocol",
732            CounterRequest::OpenInNamespace { .. } => "open_in_namespace",
733            CounterRequest::TryOpenDirectory { .. } => "try_open_directory",
734            CounterRequest::SetAbortOnShutdown { .. } => "set_abort_on_shutdown",
735        }
736    }
737}
738
739#[derive(Debug, Clone)]
740pub struct CounterControlHandle {
741    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
742}
743
744impl CounterControlHandle {
745    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
746        self.inner.shutdown_with_epitaph(status.into())
747    }
748}
749
750impl fidl::endpoints::ControlHandle for CounterControlHandle {
751    fn shutdown(&self) {
752        self.inner.shutdown()
753    }
754
755    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
756        self.inner.shutdown_with_epitaph(status)
757    }
758
759    fn is_closed(&self) -> bool {
760        self.inner.channel().is_closed()
761    }
762    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
763        self.inner.channel().on_closed()
764    }
765
766    #[cfg(target_os = "fuchsia")]
767    fn signal_peer(
768        &self,
769        clear_mask: zx::Signals,
770        set_mask: zx::Signals,
771    ) -> Result<(), zx_status::Status> {
772        use fidl::Peered;
773        self.inner.channel().signal_peer(clear_mask, set_mask)
774    }
775}
776
777impl CounterControlHandle {}
778
779#[must_use = "FIDL methods require a response to be sent"]
780#[derive(Debug)]
781pub struct CounterIncrementResponder {
782    control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
783    tx_id: u32,
784}
785
786/// Set the the channel to be shutdown (see [`CounterControlHandle::shutdown`])
787/// if the responder is dropped without sending a response, so that the client
788/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
789impl std::ops::Drop for CounterIncrementResponder {
790    fn drop(&mut self) {
791        self.control_handle.shutdown();
792        // Safety: drops once, never accessed again
793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
794    }
795}
796
797impl fidl::endpoints::Responder for CounterIncrementResponder {
798    type ControlHandle = CounterControlHandle;
799
800    fn control_handle(&self) -> &CounterControlHandle {
801        &self.control_handle
802    }
803
804    fn drop_without_shutdown(mut self) {
805        // Safety: drops once, never accessed again due to mem::forget
806        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
807        // Prevent Drop from running (which would shut down the channel)
808        std::mem::forget(self);
809    }
810}
811
812impl CounterIncrementResponder {
813    /// Sends a response to the FIDL transaction.
814    ///
815    /// Sets the channel to shutdown if an error occurs.
816    pub fn send(self, mut value: u32) -> Result<(), fidl::Error> {
817        let _result = self.send_raw(value);
818        if _result.is_err() {
819            self.control_handle.shutdown();
820        }
821        self.drop_without_shutdown();
822        _result
823    }
824
825    /// Similar to "send" but does not shutdown the channel if an error occurs.
826    pub fn send_no_shutdown_on_err(self, mut value: u32) -> Result<(), fidl::Error> {
827        let _result = self.send_raw(value);
828        self.drop_without_shutdown();
829        _result
830    }
831
832    fn send_raw(&self, mut value: u32) -> Result<(), fidl::Error> {
833        self.control_handle.inner.send::<CounterIncrementResponse>(
834            (value,),
835            self.tx_id,
836            0x60cf610cd915d7a9,
837            fidl::encoding::DynamicFlags::empty(),
838        )
839    }
840}
841
842#[must_use = "FIDL methods require a response to be sent"]
843#[derive(Debug)]
844pub struct CounterTryOpenDirectoryResponder {
845    control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
846    tx_id: u32,
847}
848
849/// Set the the channel to be shutdown (see [`CounterControlHandle::shutdown`])
850/// if the responder is dropped without sending a response, so that the client
851/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
852impl std::ops::Drop for CounterTryOpenDirectoryResponder {
853    fn drop(&mut self) {
854        self.control_handle.shutdown();
855        // Safety: drops once, never accessed again
856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
857    }
858}
859
860impl fidl::endpoints::Responder for CounterTryOpenDirectoryResponder {
861    type ControlHandle = CounterControlHandle;
862
863    fn control_handle(&self) -> &CounterControlHandle {
864        &self.control_handle
865    }
866
867    fn drop_without_shutdown(mut self) {
868        // Safety: drops once, never accessed again due to mem::forget
869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
870        // Prevent Drop from running (which would shut down the channel)
871        std::mem::forget(self);
872    }
873}
874
875impl CounterTryOpenDirectoryResponder {
876    /// Sends a response to the FIDL transaction.
877    ///
878    /// Sets the channel to shutdown if an error occurs.
879    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
880        let _result = self.send_raw(result);
881        if _result.is_err() {
882            self.control_handle.shutdown();
883        }
884        self.drop_without_shutdown();
885        _result
886    }
887
888    /// Similar to "send" but does not shutdown the channel if an error occurs.
889    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
890        let _result = self.send_raw(result);
891        self.drop_without_shutdown();
892        _result
893    }
894
895    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
896        self.control_handle
897            .inner
898            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
899                result,
900                self.tx_id,
901                0x37310702b1c8b863,
902                fidl::encoding::DynamicFlags::empty(),
903            )
904    }
905}
906
907#[must_use = "FIDL methods require a response to be sent"]
908#[derive(Debug)]
909pub struct CounterSetAbortOnShutdownResponder {
910    control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
911    tx_id: u32,
912}
913
914/// Set the the channel to be shutdown (see [`CounterControlHandle::shutdown`])
915/// if the responder is dropped without sending a response, so that the client
916/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
917impl std::ops::Drop for CounterSetAbortOnShutdownResponder {
918    fn drop(&mut self) {
919        self.control_handle.shutdown();
920        // Safety: drops once, never accessed again
921        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
922    }
923}
924
925impl fidl::endpoints::Responder for CounterSetAbortOnShutdownResponder {
926    type ControlHandle = CounterControlHandle;
927
928    fn control_handle(&self) -> &CounterControlHandle {
929        &self.control_handle
930    }
931
932    fn drop_without_shutdown(mut self) {
933        // Safety: drops once, never accessed again due to mem::forget
934        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
935        // Prevent Drop from running (which would shut down the channel)
936        std::mem::forget(self);
937    }
938}
939
940impl CounterSetAbortOnShutdownResponder {
941    /// Sends a response to the FIDL transaction.
942    ///
943    /// Sets the channel to shutdown if an error occurs.
944    pub fn send(self) -> Result<(), fidl::Error> {
945        let _result = self.send_raw();
946        if _result.is_err() {
947            self.control_handle.shutdown();
948        }
949        self.drop_without_shutdown();
950        _result
951    }
952
953    /// Similar to "send" but does not shutdown the channel if an error occurs.
954    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
955        let _result = self.send_raw();
956        self.drop_without_shutdown();
957        _result
958    }
959
960    fn send_raw(&self) -> Result<(), fidl::Error> {
961        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
962            (),
963            self.tx_id,
964            0x1d9c7aac19741829,
965            fidl::encoding::DynamicFlags::empty(),
966        )
967    }
968}
969
970mod internal {
971    use super::*;
972
973    impl fidl::encoding::ResourceTypeMarker for CounterConnectToProtocolRequest {
974        type Borrowed<'a> = &'a mut Self;
975        fn take_or_borrow<'a>(
976            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
977        ) -> Self::Borrowed<'a> {
978            value
979        }
980    }
981
982    unsafe impl fidl::encoding::TypeMarker for CounterConnectToProtocolRequest {
983        type Owned = Self;
984
985        #[inline(always)]
986        fn inline_align(_context: fidl::encoding::Context) -> usize {
987            8
988        }
989
990        #[inline(always)]
991        fn inline_size(_context: fidl::encoding::Context) -> usize {
992            24
993        }
994    }
995
996    unsafe impl
997        fidl::encoding::Encode<
998            CounterConnectToProtocolRequest,
999            fidl::encoding::DefaultFuchsiaResourceDialect,
1000        > for &mut CounterConnectToProtocolRequest
1001    {
1002        #[inline]
1003        unsafe fn encode(
1004            self,
1005            encoder: &mut fidl::encoding::Encoder<
1006                '_,
1007                fidl::encoding::DefaultFuchsiaResourceDialect,
1008            >,
1009            offset: usize,
1010            _depth: fidl::encoding::Depth,
1011        ) -> fidl::Result<()> {
1012            encoder.debug_check_bounds::<CounterConnectToProtocolRequest>(offset);
1013            // Delegate to tuple encoding.
1014            fidl::encoding::Encode::<
1015                CounterConnectToProtocolRequest,
1016                fidl::encoding::DefaultFuchsiaResourceDialect,
1017            >::encode(
1018                (
1019                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1020                        &self.protocol_name,
1021                    ),
1022                    <fidl::encoding::HandleType<
1023                        fidl::Channel,
1024                        { fidl::ObjectType::CHANNEL.into_raw() },
1025                        2147483648,
1026                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1027                        &mut self.request
1028                    ),
1029                ),
1030                encoder,
1031                offset,
1032                _depth,
1033            )
1034        }
1035    }
1036    unsafe impl<
1037        T0: fidl::encoding::Encode<
1038                fidl::encoding::BoundedString<255>,
1039                fidl::encoding::DefaultFuchsiaResourceDialect,
1040            >,
1041        T1: fidl::encoding::Encode<
1042                fidl::encoding::HandleType<
1043                    fidl::Channel,
1044                    { fidl::ObjectType::CHANNEL.into_raw() },
1045                    2147483648,
1046                >,
1047                fidl::encoding::DefaultFuchsiaResourceDialect,
1048            >,
1049    >
1050        fidl::encoding::Encode<
1051            CounterConnectToProtocolRequest,
1052            fidl::encoding::DefaultFuchsiaResourceDialect,
1053        > for (T0, T1)
1054    {
1055        #[inline]
1056        unsafe fn encode(
1057            self,
1058            encoder: &mut fidl::encoding::Encoder<
1059                '_,
1060                fidl::encoding::DefaultFuchsiaResourceDialect,
1061            >,
1062            offset: usize,
1063            depth: fidl::encoding::Depth,
1064        ) -> fidl::Result<()> {
1065            encoder.debug_check_bounds::<CounterConnectToProtocolRequest>(offset);
1066            // Zero out padding regions. There's no need to apply masks
1067            // because the unmasked parts will be overwritten by fields.
1068            unsafe {
1069                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1070                (ptr as *mut u64).write_unaligned(0);
1071            }
1072            // Write the fields.
1073            self.0.encode(encoder, offset + 0, depth)?;
1074            self.1.encode(encoder, offset + 16, depth)?;
1075            Ok(())
1076        }
1077    }
1078
1079    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1080        for CounterConnectToProtocolRequest
1081    {
1082        #[inline(always)]
1083        fn new_empty() -> Self {
1084            Self {
1085                protocol_name: fidl::new_empty!(
1086                    fidl::encoding::BoundedString<255>,
1087                    fidl::encoding::DefaultFuchsiaResourceDialect
1088                ),
1089                request: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1090            }
1091        }
1092
1093        #[inline]
1094        unsafe fn decode(
1095            &mut self,
1096            decoder: &mut fidl::encoding::Decoder<
1097                '_,
1098                fidl::encoding::DefaultFuchsiaResourceDialect,
1099            >,
1100            offset: usize,
1101            _depth: fidl::encoding::Depth,
1102        ) -> fidl::Result<()> {
1103            decoder.debug_check_bounds::<Self>(offset);
1104            // Verify that padding bytes are zero.
1105            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1106            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1107            let mask = 0xffffffff00000000u64;
1108            let maskedval = padval & mask;
1109            if maskedval != 0 {
1110                return Err(fidl::Error::NonZeroPadding {
1111                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1112                });
1113            }
1114            fidl::decode!(
1115                fidl::encoding::BoundedString<255>,
1116                fidl::encoding::DefaultFuchsiaResourceDialect,
1117                &mut self.protocol_name,
1118                decoder,
1119                offset + 0,
1120                _depth
1121            )?;
1122            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.request, decoder, offset + 16, _depth)?;
1123            Ok(())
1124        }
1125    }
1126
1127    impl fidl::encoding::ResourceTypeMarker for CounterOpenInNamespaceRequest {
1128        type Borrowed<'a> = &'a mut Self;
1129        fn take_or_borrow<'a>(
1130            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1131        ) -> Self::Borrowed<'a> {
1132            value
1133        }
1134    }
1135
1136    unsafe impl fidl::encoding::TypeMarker for CounterOpenInNamespaceRequest {
1137        type Owned = Self;
1138
1139        #[inline(always)]
1140        fn inline_align(_context: fidl::encoding::Context) -> usize {
1141            8
1142        }
1143
1144        #[inline(always)]
1145        fn inline_size(_context: fidl::encoding::Context) -> usize {
1146            32
1147        }
1148    }
1149
1150    unsafe impl
1151        fidl::encoding::Encode<
1152            CounterOpenInNamespaceRequest,
1153            fidl::encoding::DefaultFuchsiaResourceDialect,
1154        > for &mut CounterOpenInNamespaceRequest
1155    {
1156        #[inline]
1157        unsafe fn encode(
1158            self,
1159            encoder: &mut fidl::encoding::Encoder<
1160                '_,
1161                fidl::encoding::DefaultFuchsiaResourceDialect,
1162            >,
1163            offset: usize,
1164            _depth: fidl::encoding::Depth,
1165        ) -> fidl::Result<()> {
1166            encoder.debug_check_bounds::<CounterOpenInNamespaceRequest>(offset);
1167            // Delegate to tuple encoding.
1168            fidl::encoding::Encode::<CounterOpenInNamespaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1169                (
1170                    <fidl::encoding::BoundedString<4095> as fidl::encoding::ValueTypeMarker>::borrow(&self.path),
1171                    <fidl_fuchsia_io::Flags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1172                    <fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1173                ),
1174                encoder, offset, _depth
1175            )
1176        }
1177    }
1178    unsafe impl<
1179        T0: fidl::encoding::Encode<
1180                fidl::encoding::BoundedString<4095>,
1181                fidl::encoding::DefaultFuchsiaResourceDialect,
1182            >,
1183        T1: fidl::encoding::Encode<
1184                fidl_fuchsia_io::Flags,
1185                fidl::encoding::DefaultFuchsiaResourceDialect,
1186            >,
1187        T2: fidl::encoding::Encode<
1188                fidl::encoding::HandleType<
1189                    fidl::Channel,
1190                    { fidl::ObjectType::CHANNEL.into_raw() },
1191                    2147483648,
1192                >,
1193                fidl::encoding::DefaultFuchsiaResourceDialect,
1194            >,
1195    >
1196        fidl::encoding::Encode<
1197            CounterOpenInNamespaceRequest,
1198            fidl::encoding::DefaultFuchsiaResourceDialect,
1199        > for (T0, T1, T2)
1200    {
1201        #[inline]
1202        unsafe fn encode(
1203            self,
1204            encoder: &mut fidl::encoding::Encoder<
1205                '_,
1206                fidl::encoding::DefaultFuchsiaResourceDialect,
1207            >,
1208            offset: usize,
1209            depth: fidl::encoding::Depth,
1210        ) -> fidl::Result<()> {
1211            encoder.debug_check_bounds::<CounterOpenInNamespaceRequest>(offset);
1212            // Zero out padding regions. There's no need to apply masks
1213            // because the unmasked parts will be overwritten by fields.
1214            unsafe {
1215                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1216                (ptr as *mut u64).write_unaligned(0);
1217            }
1218            // Write the fields.
1219            self.0.encode(encoder, offset + 0, depth)?;
1220            self.1.encode(encoder, offset + 16, depth)?;
1221            self.2.encode(encoder, offset + 24, depth)?;
1222            Ok(())
1223        }
1224    }
1225
1226    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1227        for CounterOpenInNamespaceRequest
1228    {
1229        #[inline(always)]
1230        fn new_empty() -> Self {
1231            Self {
1232                path: fidl::new_empty!(
1233                    fidl::encoding::BoundedString<4095>,
1234                    fidl::encoding::DefaultFuchsiaResourceDialect
1235                ),
1236                flags: fidl::new_empty!(
1237                    fidl_fuchsia_io::Flags,
1238                    fidl::encoding::DefaultFuchsiaResourceDialect
1239                ),
1240                request: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1241            }
1242        }
1243
1244        #[inline]
1245        unsafe fn decode(
1246            &mut self,
1247            decoder: &mut fidl::encoding::Decoder<
1248                '_,
1249                fidl::encoding::DefaultFuchsiaResourceDialect,
1250            >,
1251            offset: usize,
1252            _depth: fidl::encoding::Depth,
1253        ) -> fidl::Result<()> {
1254            decoder.debug_check_bounds::<Self>(offset);
1255            // Verify that padding bytes are zero.
1256            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1257            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1258            let mask = 0xffffffff00000000u64;
1259            let maskedval = padval & mask;
1260            if maskedval != 0 {
1261                return Err(fidl::Error::NonZeroPadding {
1262                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1263                });
1264            }
1265            fidl::decode!(
1266                fidl::encoding::BoundedString<4095>,
1267                fidl::encoding::DefaultFuchsiaResourceDialect,
1268                &mut self.path,
1269                decoder,
1270                offset + 0,
1271                _depth
1272            )?;
1273            fidl::decode!(
1274                fidl_fuchsia_io::Flags,
1275                fidl::encoding::DefaultFuchsiaResourceDialect,
1276                &mut self.flags,
1277                decoder,
1278                offset + 16,
1279                _depth
1280            )?;
1281            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.request, decoder, offset + 24, _depth)?;
1282            Ok(())
1283        }
1284    }
1285}