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