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