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 fidl::endpoints::ControlHandle for CounterControlHandle {
745    fn shutdown(&self) {
746        self.inner.shutdown()
747    }
748
749    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
750        self.inner.shutdown_with_epitaph(status)
751    }
752
753    fn is_closed(&self) -> bool {
754        self.inner.channel().is_closed()
755    }
756    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
757        self.inner.channel().on_closed()
758    }
759
760    #[cfg(target_os = "fuchsia")]
761    fn signal_peer(
762        &self,
763        clear_mask: zx::Signals,
764        set_mask: zx::Signals,
765    ) -> Result<(), zx_status::Status> {
766        use fidl::Peered;
767        self.inner.channel().signal_peer(clear_mask, set_mask)
768    }
769}
770
771impl CounterControlHandle {}
772
773#[must_use = "FIDL methods require a response to be sent"]
774#[derive(Debug)]
775pub struct CounterIncrementResponder {
776    control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
777    tx_id: u32,
778}
779
780/// Set the the channel to be shutdown (see [`CounterControlHandle::shutdown`])
781/// if the responder is dropped without sending a response, so that the client
782/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
783impl std::ops::Drop for CounterIncrementResponder {
784    fn drop(&mut self) {
785        self.control_handle.shutdown();
786        // Safety: drops once, never accessed again
787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
788    }
789}
790
791impl fidl::endpoints::Responder for CounterIncrementResponder {
792    type ControlHandle = CounterControlHandle;
793
794    fn control_handle(&self) -> &CounterControlHandle {
795        &self.control_handle
796    }
797
798    fn drop_without_shutdown(mut self) {
799        // Safety: drops once, never accessed again due to mem::forget
800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
801        // Prevent Drop from running (which would shut down the channel)
802        std::mem::forget(self);
803    }
804}
805
806impl CounterIncrementResponder {
807    /// Sends a response to the FIDL transaction.
808    ///
809    /// Sets the channel to shutdown if an error occurs.
810    pub fn send(self, mut value: u32) -> Result<(), fidl::Error> {
811        let _result = self.send_raw(value);
812        if _result.is_err() {
813            self.control_handle.shutdown();
814        }
815        self.drop_without_shutdown();
816        _result
817    }
818
819    /// Similar to "send" but does not shutdown the channel if an error occurs.
820    pub fn send_no_shutdown_on_err(self, mut value: u32) -> Result<(), fidl::Error> {
821        let _result = self.send_raw(value);
822        self.drop_without_shutdown();
823        _result
824    }
825
826    fn send_raw(&self, mut value: u32) -> Result<(), fidl::Error> {
827        self.control_handle.inner.send::<CounterIncrementResponse>(
828            (value,),
829            self.tx_id,
830            0x60cf610cd915d7a9,
831            fidl::encoding::DynamicFlags::empty(),
832        )
833    }
834}
835
836#[must_use = "FIDL methods require a response to be sent"]
837#[derive(Debug)]
838pub struct CounterTryOpenDirectoryResponder {
839    control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
840    tx_id: u32,
841}
842
843/// Set the the channel to be shutdown (see [`CounterControlHandle::shutdown`])
844/// if the responder is dropped without sending a response, so that the client
845/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
846impl std::ops::Drop for CounterTryOpenDirectoryResponder {
847    fn drop(&mut self) {
848        self.control_handle.shutdown();
849        // Safety: drops once, never accessed again
850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
851    }
852}
853
854impl fidl::endpoints::Responder for CounterTryOpenDirectoryResponder {
855    type ControlHandle = CounterControlHandle;
856
857    fn control_handle(&self) -> &CounterControlHandle {
858        &self.control_handle
859    }
860
861    fn drop_without_shutdown(mut self) {
862        // Safety: drops once, never accessed again due to mem::forget
863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
864        // Prevent Drop from running (which would shut down the channel)
865        std::mem::forget(self);
866    }
867}
868
869impl CounterTryOpenDirectoryResponder {
870    /// Sends a response to the FIDL transaction.
871    ///
872    /// Sets the channel to shutdown if an error occurs.
873    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
874        let _result = self.send_raw(result);
875        if _result.is_err() {
876            self.control_handle.shutdown();
877        }
878        self.drop_without_shutdown();
879        _result
880    }
881
882    /// Similar to "send" but does not shutdown the channel if an error occurs.
883    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
884        let _result = self.send_raw(result);
885        self.drop_without_shutdown();
886        _result
887    }
888
889    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
890        self.control_handle
891            .inner
892            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
893                result,
894                self.tx_id,
895                0x37310702b1c8b863,
896                fidl::encoding::DynamicFlags::empty(),
897            )
898    }
899}
900
901#[must_use = "FIDL methods require a response to be sent"]
902#[derive(Debug)]
903pub struct CounterSetAbortOnShutdownResponder {
904    control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
905    tx_id: u32,
906}
907
908/// Set the the channel to be shutdown (see [`CounterControlHandle::shutdown`])
909/// if the responder is dropped without sending a response, so that the client
910/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
911impl std::ops::Drop for CounterSetAbortOnShutdownResponder {
912    fn drop(&mut self) {
913        self.control_handle.shutdown();
914        // Safety: drops once, never accessed again
915        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
916    }
917}
918
919impl fidl::endpoints::Responder for CounterSetAbortOnShutdownResponder {
920    type ControlHandle = CounterControlHandle;
921
922    fn control_handle(&self) -> &CounterControlHandle {
923        &self.control_handle
924    }
925
926    fn drop_without_shutdown(mut self) {
927        // Safety: drops once, never accessed again due to mem::forget
928        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
929        // Prevent Drop from running (which would shut down the channel)
930        std::mem::forget(self);
931    }
932}
933
934impl CounterSetAbortOnShutdownResponder {
935    /// Sends a response to the FIDL transaction.
936    ///
937    /// Sets the channel to shutdown if an error occurs.
938    pub fn send(self) -> Result<(), fidl::Error> {
939        let _result = self.send_raw();
940        if _result.is_err() {
941            self.control_handle.shutdown();
942        }
943        self.drop_without_shutdown();
944        _result
945    }
946
947    /// Similar to "send" but does not shutdown the channel if an error occurs.
948    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
949        let _result = self.send_raw();
950        self.drop_without_shutdown();
951        _result
952    }
953
954    fn send_raw(&self) -> Result<(), fidl::Error> {
955        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
956            (),
957            self.tx_id,
958            0x1d9c7aac19741829,
959            fidl::encoding::DynamicFlags::empty(),
960        )
961    }
962}
963
964mod internal {
965    use super::*;
966
967    impl fidl::encoding::ResourceTypeMarker for CounterConnectToProtocolRequest {
968        type Borrowed<'a> = &'a mut Self;
969        fn take_or_borrow<'a>(
970            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
971        ) -> Self::Borrowed<'a> {
972            value
973        }
974    }
975
976    unsafe impl fidl::encoding::TypeMarker for CounterConnectToProtocolRequest {
977        type Owned = Self;
978
979        #[inline(always)]
980        fn inline_align(_context: fidl::encoding::Context) -> usize {
981            8
982        }
983
984        #[inline(always)]
985        fn inline_size(_context: fidl::encoding::Context) -> usize {
986            24
987        }
988    }
989
990    unsafe impl
991        fidl::encoding::Encode<
992            CounterConnectToProtocolRequest,
993            fidl::encoding::DefaultFuchsiaResourceDialect,
994        > for &mut CounterConnectToProtocolRequest
995    {
996        #[inline]
997        unsafe fn encode(
998            self,
999            encoder: &mut fidl::encoding::Encoder<
1000                '_,
1001                fidl::encoding::DefaultFuchsiaResourceDialect,
1002            >,
1003            offset: usize,
1004            _depth: fidl::encoding::Depth,
1005        ) -> fidl::Result<()> {
1006            encoder.debug_check_bounds::<CounterConnectToProtocolRequest>(offset);
1007            // Delegate to tuple encoding.
1008            fidl::encoding::Encode::<
1009                CounterConnectToProtocolRequest,
1010                fidl::encoding::DefaultFuchsiaResourceDialect,
1011            >::encode(
1012                (
1013                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1014                        &self.protocol_name,
1015                    ),
1016                    <fidl::encoding::HandleType<
1017                        fidl::Channel,
1018                        { fidl::ObjectType::CHANNEL.into_raw() },
1019                        2147483648,
1020                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1021                        &mut self.request
1022                    ),
1023                ),
1024                encoder,
1025                offset,
1026                _depth,
1027            )
1028        }
1029    }
1030    unsafe impl<
1031        T0: fidl::encoding::Encode<
1032                fidl::encoding::BoundedString<255>,
1033                fidl::encoding::DefaultFuchsiaResourceDialect,
1034            >,
1035        T1: fidl::encoding::Encode<
1036                fidl::encoding::HandleType<
1037                    fidl::Channel,
1038                    { fidl::ObjectType::CHANNEL.into_raw() },
1039                    2147483648,
1040                >,
1041                fidl::encoding::DefaultFuchsiaResourceDialect,
1042            >,
1043    >
1044        fidl::encoding::Encode<
1045            CounterConnectToProtocolRequest,
1046            fidl::encoding::DefaultFuchsiaResourceDialect,
1047        > for (T0, T1)
1048    {
1049        #[inline]
1050        unsafe fn encode(
1051            self,
1052            encoder: &mut fidl::encoding::Encoder<
1053                '_,
1054                fidl::encoding::DefaultFuchsiaResourceDialect,
1055            >,
1056            offset: usize,
1057            depth: fidl::encoding::Depth,
1058        ) -> fidl::Result<()> {
1059            encoder.debug_check_bounds::<CounterConnectToProtocolRequest>(offset);
1060            // Zero out padding regions. There's no need to apply masks
1061            // because the unmasked parts will be overwritten by fields.
1062            unsafe {
1063                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1064                (ptr as *mut u64).write_unaligned(0);
1065            }
1066            // Write the fields.
1067            self.0.encode(encoder, offset + 0, depth)?;
1068            self.1.encode(encoder, offset + 16, depth)?;
1069            Ok(())
1070        }
1071    }
1072
1073    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1074        for CounterConnectToProtocolRequest
1075    {
1076        #[inline(always)]
1077        fn new_empty() -> Self {
1078            Self {
1079                protocol_name: fidl::new_empty!(
1080                    fidl::encoding::BoundedString<255>,
1081                    fidl::encoding::DefaultFuchsiaResourceDialect
1082                ),
1083                request: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1084            }
1085        }
1086
1087        #[inline]
1088        unsafe fn decode(
1089            &mut self,
1090            decoder: &mut fidl::encoding::Decoder<
1091                '_,
1092                fidl::encoding::DefaultFuchsiaResourceDialect,
1093            >,
1094            offset: usize,
1095            _depth: fidl::encoding::Depth,
1096        ) -> fidl::Result<()> {
1097            decoder.debug_check_bounds::<Self>(offset);
1098            // Verify that padding bytes are zero.
1099            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1100            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1101            let mask = 0xffffffff00000000u64;
1102            let maskedval = padval & mask;
1103            if maskedval != 0 {
1104                return Err(fidl::Error::NonZeroPadding {
1105                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1106                });
1107            }
1108            fidl::decode!(
1109                fidl::encoding::BoundedString<255>,
1110                fidl::encoding::DefaultFuchsiaResourceDialect,
1111                &mut self.protocol_name,
1112                decoder,
1113                offset + 0,
1114                _depth
1115            )?;
1116            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.request, decoder, offset + 16, _depth)?;
1117            Ok(())
1118        }
1119    }
1120
1121    impl fidl::encoding::ResourceTypeMarker for CounterOpenInNamespaceRequest {
1122        type Borrowed<'a> = &'a mut Self;
1123        fn take_or_borrow<'a>(
1124            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1125        ) -> Self::Borrowed<'a> {
1126            value
1127        }
1128    }
1129
1130    unsafe impl fidl::encoding::TypeMarker for CounterOpenInNamespaceRequest {
1131        type Owned = Self;
1132
1133        #[inline(always)]
1134        fn inline_align(_context: fidl::encoding::Context) -> usize {
1135            8
1136        }
1137
1138        #[inline(always)]
1139        fn inline_size(_context: fidl::encoding::Context) -> usize {
1140            32
1141        }
1142    }
1143
1144    unsafe impl
1145        fidl::encoding::Encode<
1146            CounterOpenInNamespaceRequest,
1147            fidl::encoding::DefaultFuchsiaResourceDialect,
1148        > for &mut CounterOpenInNamespaceRequest
1149    {
1150        #[inline]
1151        unsafe fn encode(
1152            self,
1153            encoder: &mut fidl::encoding::Encoder<
1154                '_,
1155                fidl::encoding::DefaultFuchsiaResourceDialect,
1156            >,
1157            offset: usize,
1158            _depth: fidl::encoding::Depth,
1159        ) -> fidl::Result<()> {
1160            encoder.debug_check_bounds::<CounterOpenInNamespaceRequest>(offset);
1161            // Delegate to tuple encoding.
1162            fidl::encoding::Encode::<CounterOpenInNamespaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1163                (
1164                    <fidl::encoding::BoundedString<4095> as fidl::encoding::ValueTypeMarker>::borrow(&self.path),
1165                    <fidl_fuchsia_io::Flags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1166                    <fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1167                ),
1168                encoder, offset, _depth
1169            )
1170        }
1171    }
1172    unsafe impl<
1173        T0: fidl::encoding::Encode<
1174                fidl::encoding::BoundedString<4095>,
1175                fidl::encoding::DefaultFuchsiaResourceDialect,
1176            >,
1177        T1: fidl::encoding::Encode<
1178                fidl_fuchsia_io::Flags,
1179                fidl::encoding::DefaultFuchsiaResourceDialect,
1180            >,
1181        T2: fidl::encoding::Encode<
1182                fidl::encoding::HandleType<
1183                    fidl::Channel,
1184                    { fidl::ObjectType::CHANNEL.into_raw() },
1185                    2147483648,
1186                >,
1187                fidl::encoding::DefaultFuchsiaResourceDialect,
1188            >,
1189    >
1190        fidl::encoding::Encode<
1191            CounterOpenInNamespaceRequest,
1192            fidl::encoding::DefaultFuchsiaResourceDialect,
1193        > for (T0, T1, T2)
1194    {
1195        #[inline]
1196        unsafe fn encode(
1197            self,
1198            encoder: &mut fidl::encoding::Encoder<
1199                '_,
1200                fidl::encoding::DefaultFuchsiaResourceDialect,
1201            >,
1202            offset: usize,
1203            depth: fidl::encoding::Depth,
1204        ) -> fidl::Result<()> {
1205            encoder.debug_check_bounds::<CounterOpenInNamespaceRequest>(offset);
1206            // Zero out padding regions. There's no need to apply masks
1207            // because the unmasked parts will be overwritten by fields.
1208            unsafe {
1209                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1210                (ptr as *mut u64).write_unaligned(0);
1211            }
1212            // Write the fields.
1213            self.0.encode(encoder, offset + 0, depth)?;
1214            self.1.encode(encoder, offset + 16, depth)?;
1215            self.2.encode(encoder, offset + 24, depth)?;
1216            Ok(())
1217        }
1218    }
1219
1220    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1221        for CounterOpenInNamespaceRequest
1222    {
1223        #[inline(always)]
1224        fn new_empty() -> Self {
1225            Self {
1226                path: fidl::new_empty!(
1227                    fidl::encoding::BoundedString<4095>,
1228                    fidl::encoding::DefaultFuchsiaResourceDialect
1229                ),
1230                flags: fidl::new_empty!(
1231                    fidl_fuchsia_io::Flags,
1232                    fidl::encoding::DefaultFuchsiaResourceDialect
1233                ),
1234                request: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1235            }
1236        }
1237
1238        #[inline]
1239        unsafe fn decode(
1240            &mut self,
1241            decoder: &mut fidl::encoding::Decoder<
1242                '_,
1243                fidl::encoding::DefaultFuchsiaResourceDialect,
1244            >,
1245            offset: usize,
1246            _depth: fidl::encoding::Depth,
1247        ) -> fidl::Result<()> {
1248            decoder.debug_check_bounds::<Self>(offset);
1249            // Verify that padding bytes are zero.
1250            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1251            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1252            let mask = 0xffffffff00000000u64;
1253            let maskedval = padval & mask;
1254            if maskedval != 0 {
1255                return Err(fidl::Error::NonZeroPadding {
1256                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1257                });
1258            }
1259            fidl::decode!(
1260                fidl::encoding::BoundedString<4095>,
1261                fidl::encoding::DefaultFuchsiaResourceDialect,
1262                &mut self.path,
1263                decoder,
1264                offset + 0,
1265                _depth
1266            )?;
1267            fidl::decode!(
1268                fidl_fuchsia_io::Flags,
1269                fidl::encoding::DefaultFuchsiaResourceDialect,
1270                &mut self.flags,
1271                decoder,
1272                offset + 16,
1273                _depth
1274            )?;
1275            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.request, decoder, offset + 24, _depth)?;
1276            Ok(())
1277        }
1278    }
1279}