fidl_fuchsia_io_test/
fidl_fuchsia_io_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_io_test_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// Directory entries should support opening with any combination of read/write/execute rights.
15#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16pub struct Directory {
17    pub name: String,
18    pub entries: Vec<Option<Box<DirectoryEntry>>>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Directory {}
22
23/// Remote directory which forwards FIDL requests from the server to the specified directory.
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct RemoteDirectory {
26    pub name: String,
27    pub remote_client: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RemoteDirectory {}
31
32#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33pub struct TestHarnessCreateDirectoryRequest {
34    pub contents: Vec<Option<Box<DirectoryEntry>>>,
35    pub flags: fidl_fuchsia_io::Flags,
36    pub object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for TestHarnessCreateDirectoryRequest
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct TestHarnessOpenServiceDirectoryResponse {
46    pub object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
47}
48
49impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
50    for TestHarnessOpenServiceDirectoryResponse
51{
52}
53
54#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
55pub enum DirectoryEntry {
56    Directory(Directory),
57    RemoteDirectory(RemoteDirectory),
58    File(File),
59    ExecutableFile(ExecutableFile),
60}
61
62impl DirectoryEntry {
63    #[inline]
64    pub fn ordinal(&self) -> u64 {
65        match *self {
66            Self::Directory(_) => 1,
67            Self::RemoteDirectory(_) => 2,
68            Self::File(_) => 3,
69            Self::ExecutableFile(_) => 5,
70        }
71    }
72
73    #[deprecated = "Strict unions should not use `is_unknown`"]
74    #[inline]
75    pub fn is_unknown(&self) -> bool {
76        false
77    }
78}
79
80impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DirectoryEntry {}
81
82#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
83pub struct TestHarnessMarker;
84
85impl fidl::endpoints::ProtocolMarker for TestHarnessMarker {
86    type Proxy = TestHarnessProxy;
87    type RequestStream = TestHarnessRequestStream;
88    #[cfg(target_os = "fuchsia")]
89    type SynchronousProxy = TestHarnessSynchronousProxy;
90
91    const DEBUG_NAME: &'static str = "fuchsia.io.test.TestHarness";
92}
93impl fidl::endpoints::DiscoverableProtocolMarker for TestHarnessMarker {}
94
95pub trait TestHarnessProxyInterface: Send + Sync {
96    type GetConfigResponseFut: std::future::Future<Output = Result<HarnessConfig, fidl::Error>>
97        + Send;
98    fn r#get_config(&self) -> Self::GetConfigResponseFut;
99    fn r#create_directory(
100        &self,
101        contents: Vec<Option<Box<DirectoryEntry>>>,
102        flags: fidl_fuchsia_io::Flags,
103        object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
104    ) -> Result<(), fidl::Error>;
105    type OpenServiceDirectoryResponseFut: std::future::Future<
106            Output = Result<
107                fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
108                fidl::Error,
109            >,
110        > + Send;
111    fn r#open_service_directory(&self) -> Self::OpenServiceDirectoryResponseFut;
112}
113#[derive(Debug)]
114#[cfg(target_os = "fuchsia")]
115pub struct TestHarnessSynchronousProxy {
116    client: fidl::client::sync::Client,
117}
118
119#[cfg(target_os = "fuchsia")]
120impl fidl::endpoints::SynchronousProxy for TestHarnessSynchronousProxy {
121    type Proxy = TestHarnessProxy;
122    type Protocol = TestHarnessMarker;
123
124    fn from_channel(inner: fidl::Channel) -> Self {
125        Self::new(inner)
126    }
127
128    fn into_channel(self) -> fidl::Channel {
129        self.client.into_channel()
130    }
131
132    fn as_channel(&self) -> &fidl::Channel {
133        self.client.as_channel()
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl TestHarnessSynchronousProxy {
139    pub fn new(channel: fidl::Channel) -> Self {
140        let protocol_name = <TestHarnessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
141        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
142    }
143
144    pub fn into_channel(self) -> fidl::Channel {
145        self.client.into_channel()
146    }
147
148    /// Waits until an event arrives and returns it. It is safe for other
149    /// threads to make concurrent requests while waiting for an event.
150    pub fn wait_for_event(
151        &self,
152        deadline: zx::MonotonicInstant,
153    ) -> Result<TestHarnessEvent, fidl::Error> {
154        TestHarnessEvent::decode(self.client.wait_for_event(deadline)?)
155    }
156
157    /// Returns the list of properties of the filesystem.
158    pub fn r#get_config(
159        &self,
160        ___deadline: zx::MonotonicInstant,
161    ) -> Result<HarnessConfig, fidl::Error> {
162        let _response =
163            self.client.send_query::<fidl::encoding::EmptyPayload, TestHarnessGetConfigResponse>(
164                (),
165                0x758882a165dbaa23,
166                fidl::encoding::DynamicFlags::empty(),
167                ___deadline,
168            )?;
169        Ok(_response.config)
170    }
171
172    /// Creates a directory with the given `contents` and opens it with the specified `flags`.
173    pub fn r#create_directory(
174        &self,
175        mut contents: Vec<Option<Box<DirectoryEntry>>>,
176        mut flags: fidl_fuchsia_io::Flags,
177        mut object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
178    ) -> Result<(), fidl::Error> {
179        self.client.send::<TestHarnessCreateDirectoryRequest>(
180            (contents.as_mut(), flags, object_request),
181            0x626b0ce412a0cb4c,
182            fidl::encoding::DynamicFlags::empty(),
183        )
184    }
185
186    /// Serves a service directory that contains a fuchsia.test.placeholders/Echo instance.
187    /// The test harness must have `supports_services` reported in it's config to use this method,
188    /// and the service instance should match the discoverable protocol name.
189    pub fn r#open_service_directory(
190        &self,
191        ___deadline: zx::MonotonicInstant,
192    ) -> Result<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>, fidl::Error> {
193        let _response = self
194            .client
195            .send_query::<fidl::encoding::EmptyPayload, TestHarnessOpenServiceDirectoryResponse>(
196                (),
197                0x42904fe08b12ef88,
198                fidl::encoding::DynamicFlags::empty(),
199                ___deadline,
200            )?;
201        Ok(_response.object_request)
202    }
203}
204
205#[derive(Debug, Clone)]
206pub struct TestHarnessProxy {
207    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
208}
209
210impl fidl::endpoints::Proxy for TestHarnessProxy {
211    type Protocol = TestHarnessMarker;
212
213    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
214        Self::new(inner)
215    }
216
217    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
218        self.client.into_channel().map_err(|client| Self { client })
219    }
220
221    fn as_channel(&self) -> &::fidl::AsyncChannel {
222        self.client.as_channel()
223    }
224}
225
226impl TestHarnessProxy {
227    /// Create a new Proxy for fuchsia.io.test/TestHarness.
228    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
229        let protocol_name = <TestHarnessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
230        Self { client: fidl::client::Client::new(channel, protocol_name) }
231    }
232
233    /// Get a Stream of events from the remote end of the protocol.
234    ///
235    /// # Panics
236    ///
237    /// Panics if the event stream was already taken.
238    pub fn take_event_stream(&self) -> TestHarnessEventStream {
239        TestHarnessEventStream { event_receiver: self.client.take_event_receiver() }
240    }
241
242    /// Returns the list of properties of the filesystem.
243    pub fn r#get_config(
244        &self,
245    ) -> fidl::client::QueryResponseFut<HarnessConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
246    {
247        TestHarnessProxyInterface::r#get_config(self)
248    }
249
250    /// Creates a directory with the given `contents` and opens it with the specified `flags`.
251    pub fn r#create_directory(
252        &self,
253        mut contents: Vec<Option<Box<DirectoryEntry>>>,
254        mut flags: fidl_fuchsia_io::Flags,
255        mut object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
256    ) -> Result<(), fidl::Error> {
257        TestHarnessProxyInterface::r#create_directory(self, contents, flags, object_request)
258    }
259
260    /// Serves a service directory that contains a fuchsia.test.placeholders/Echo instance.
261    /// The test harness must have `supports_services` reported in it's config to use this method,
262    /// and the service instance should match the discoverable protocol name.
263    pub fn r#open_service_directory(
264        &self,
265    ) -> fidl::client::QueryResponseFut<
266        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
267        fidl::encoding::DefaultFuchsiaResourceDialect,
268    > {
269        TestHarnessProxyInterface::r#open_service_directory(self)
270    }
271}
272
273impl TestHarnessProxyInterface for TestHarnessProxy {
274    type GetConfigResponseFut = fidl::client::QueryResponseFut<
275        HarnessConfig,
276        fidl::encoding::DefaultFuchsiaResourceDialect,
277    >;
278    fn r#get_config(&self) -> Self::GetConfigResponseFut {
279        fn _decode(
280            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
281        ) -> Result<HarnessConfig, fidl::Error> {
282            let _response = fidl::client::decode_transaction_body::<
283                TestHarnessGetConfigResponse,
284                fidl::encoding::DefaultFuchsiaResourceDialect,
285                0x758882a165dbaa23,
286            >(_buf?)?;
287            Ok(_response.config)
288        }
289        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HarnessConfig>(
290            (),
291            0x758882a165dbaa23,
292            fidl::encoding::DynamicFlags::empty(),
293            _decode,
294        )
295    }
296
297    fn r#create_directory(
298        &self,
299        mut contents: Vec<Option<Box<DirectoryEntry>>>,
300        mut flags: fidl_fuchsia_io::Flags,
301        mut object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
302    ) -> Result<(), fidl::Error> {
303        self.client.send::<TestHarnessCreateDirectoryRequest>(
304            (contents.as_mut(), flags, object_request),
305            0x626b0ce412a0cb4c,
306            fidl::encoding::DynamicFlags::empty(),
307        )
308    }
309
310    type OpenServiceDirectoryResponseFut = fidl::client::QueryResponseFut<
311        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
312        fidl::encoding::DefaultFuchsiaResourceDialect,
313    >;
314    fn r#open_service_directory(&self) -> Self::OpenServiceDirectoryResponseFut {
315        fn _decode(
316            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
317        ) -> Result<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>, fidl::Error>
318        {
319            let _response = fidl::client::decode_transaction_body::<
320                TestHarnessOpenServiceDirectoryResponse,
321                fidl::encoding::DefaultFuchsiaResourceDialect,
322                0x42904fe08b12ef88,
323            >(_buf?)?;
324            Ok(_response.object_request)
325        }
326        self.client.send_query_and_decode::<
327            fidl::encoding::EmptyPayload,
328            fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
329        >(
330            (),
331            0x42904fe08b12ef88,
332            fidl::encoding::DynamicFlags::empty(),
333            _decode,
334        )
335    }
336}
337
338pub struct TestHarnessEventStream {
339    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
340}
341
342impl std::marker::Unpin for TestHarnessEventStream {}
343
344impl futures::stream::FusedStream for TestHarnessEventStream {
345    fn is_terminated(&self) -> bool {
346        self.event_receiver.is_terminated()
347    }
348}
349
350impl futures::Stream for TestHarnessEventStream {
351    type Item = Result<TestHarnessEvent, fidl::Error>;
352
353    fn poll_next(
354        mut self: std::pin::Pin<&mut Self>,
355        cx: &mut std::task::Context<'_>,
356    ) -> std::task::Poll<Option<Self::Item>> {
357        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
358            &mut self.event_receiver,
359            cx
360        )?) {
361            Some(buf) => std::task::Poll::Ready(Some(TestHarnessEvent::decode(buf))),
362            None => std::task::Poll::Ready(None),
363        }
364    }
365}
366
367#[derive(Debug)]
368pub enum TestHarnessEvent {}
369
370impl TestHarnessEvent {
371    /// Decodes a message buffer as a [`TestHarnessEvent`].
372    fn decode(
373        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
374    ) -> Result<TestHarnessEvent, fidl::Error> {
375        let (bytes, _handles) = buf.split_mut();
376        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
377        debug_assert_eq!(tx_header.tx_id, 0);
378        match tx_header.ordinal {
379            _ => Err(fidl::Error::UnknownOrdinal {
380                ordinal: tx_header.ordinal,
381                protocol_name: <TestHarnessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
382            }),
383        }
384    }
385}
386
387/// A Stream of incoming requests for fuchsia.io.test/TestHarness.
388pub struct TestHarnessRequestStream {
389    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
390    is_terminated: bool,
391}
392
393impl std::marker::Unpin for TestHarnessRequestStream {}
394
395impl futures::stream::FusedStream for TestHarnessRequestStream {
396    fn is_terminated(&self) -> bool {
397        self.is_terminated
398    }
399}
400
401impl fidl::endpoints::RequestStream for TestHarnessRequestStream {
402    type Protocol = TestHarnessMarker;
403    type ControlHandle = TestHarnessControlHandle;
404
405    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
406        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
407    }
408
409    fn control_handle(&self) -> Self::ControlHandle {
410        TestHarnessControlHandle { inner: self.inner.clone() }
411    }
412
413    fn into_inner(
414        self,
415    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
416    {
417        (self.inner, self.is_terminated)
418    }
419
420    fn from_inner(
421        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
422        is_terminated: bool,
423    ) -> Self {
424        Self { inner, is_terminated }
425    }
426}
427
428impl futures::Stream for TestHarnessRequestStream {
429    type Item = Result<TestHarnessRequest, fidl::Error>;
430
431    fn poll_next(
432        mut self: std::pin::Pin<&mut Self>,
433        cx: &mut std::task::Context<'_>,
434    ) -> std::task::Poll<Option<Self::Item>> {
435        let this = &mut *self;
436        if this.inner.check_shutdown(cx) {
437            this.is_terminated = true;
438            return std::task::Poll::Ready(None);
439        }
440        if this.is_terminated {
441            panic!("polled TestHarnessRequestStream after completion");
442        }
443        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
444            |bytes, handles| {
445                match this.inner.channel().read_etc(cx, bytes, handles) {
446                    std::task::Poll::Ready(Ok(())) => {}
447                    std::task::Poll::Pending => return std::task::Poll::Pending,
448                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
449                        this.is_terminated = true;
450                        return std::task::Poll::Ready(None);
451                    }
452                    std::task::Poll::Ready(Err(e)) => {
453                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
454                            e.into(),
455                        ))))
456                    }
457                }
458
459                // A message has been received from the channel
460                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
461
462                std::task::Poll::Ready(Some(match header.ordinal {
463                    0x758882a165dbaa23 => {
464                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
465                        let mut req = fidl::new_empty!(
466                            fidl::encoding::EmptyPayload,
467                            fidl::encoding::DefaultFuchsiaResourceDialect
468                        );
469                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
470                        let control_handle = TestHarnessControlHandle { inner: this.inner.clone() };
471                        Ok(TestHarnessRequest::GetConfig {
472                            responder: TestHarnessGetConfigResponder {
473                                control_handle: std::mem::ManuallyDrop::new(control_handle),
474                                tx_id: header.tx_id,
475                            },
476                        })
477                    }
478                    0x626b0ce412a0cb4c => {
479                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
480                        let mut req = fidl::new_empty!(
481                            TestHarnessCreateDirectoryRequest,
482                            fidl::encoding::DefaultFuchsiaResourceDialect
483                        );
484                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TestHarnessCreateDirectoryRequest>(&header, _body_bytes, handles, &mut req)?;
485                        let control_handle = TestHarnessControlHandle { inner: this.inner.clone() };
486                        Ok(TestHarnessRequest::CreateDirectory {
487                            contents: req.contents,
488                            flags: req.flags,
489                            object_request: req.object_request,
490
491                            control_handle,
492                        })
493                    }
494                    0x42904fe08b12ef88 => {
495                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
496                        let mut req = fidl::new_empty!(
497                            fidl::encoding::EmptyPayload,
498                            fidl::encoding::DefaultFuchsiaResourceDialect
499                        );
500                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
501                        let control_handle = TestHarnessControlHandle { inner: this.inner.clone() };
502                        Ok(TestHarnessRequest::OpenServiceDirectory {
503                            responder: TestHarnessOpenServiceDirectoryResponder {
504                                control_handle: std::mem::ManuallyDrop::new(control_handle),
505                                tx_id: header.tx_id,
506                            },
507                        })
508                    }
509                    _ => Err(fidl::Error::UnknownOrdinal {
510                        ordinal: header.ordinal,
511                        protocol_name:
512                            <TestHarnessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
513                    }),
514                }))
515            },
516        )
517    }
518}
519
520#[derive(Debug)]
521pub enum TestHarnessRequest {
522    /// Returns the list of properties of the filesystem.
523    GetConfig { responder: TestHarnessGetConfigResponder },
524    /// Creates a directory with the given `contents` and opens it with the specified `flags`.
525    CreateDirectory {
526        contents: Vec<Option<Box<DirectoryEntry>>>,
527        flags: fidl_fuchsia_io::Flags,
528        object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
529        control_handle: TestHarnessControlHandle,
530    },
531    /// Serves a service directory that contains a fuchsia.test.placeholders/Echo instance.
532    /// The test harness must have `supports_services` reported in it's config to use this method,
533    /// and the service instance should match the discoverable protocol name.
534    OpenServiceDirectory { responder: TestHarnessOpenServiceDirectoryResponder },
535}
536
537impl TestHarnessRequest {
538    #[allow(irrefutable_let_patterns)]
539    pub fn into_get_config(self) -> Option<(TestHarnessGetConfigResponder)> {
540        if let TestHarnessRequest::GetConfig { responder } = self {
541            Some((responder))
542        } else {
543            None
544        }
545    }
546
547    #[allow(irrefutable_let_patterns)]
548    pub fn into_create_directory(
549        self,
550    ) -> Option<(
551        Vec<Option<Box<DirectoryEntry>>>,
552        fidl_fuchsia_io::Flags,
553        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
554        TestHarnessControlHandle,
555    )> {
556        if let TestHarnessRequest::CreateDirectory {
557            contents,
558            flags,
559            object_request,
560            control_handle,
561        } = self
562        {
563            Some((contents, flags, object_request, control_handle))
564        } else {
565            None
566        }
567    }
568
569    #[allow(irrefutable_let_patterns)]
570    pub fn into_open_service_directory(self) -> Option<(TestHarnessOpenServiceDirectoryResponder)> {
571        if let TestHarnessRequest::OpenServiceDirectory { responder } = self {
572            Some((responder))
573        } else {
574            None
575        }
576    }
577
578    /// Name of the method defined in FIDL
579    pub fn method_name(&self) -> &'static str {
580        match *self {
581            TestHarnessRequest::GetConfig { .. } => "get_config",
582            TestHarnessRequest::CreateDirectory { .. } => "create_directory",
583            TestHarnessRequest::OpenServiceDirectory { .. } => "open_service_directory",
584        }
585    }
586}
587
588#[derive(Debug, Clone)]
589pub struct TestHarnessControlHandle {
590    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
591}
592
593impl fidl::endpoints::ControlHandle for TestHarnessControlHandle {
594    fn shutdown(&self) {
595        self.inner.shutdown()
596    }
597    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
598        self.inner.shutdown_with_epitaph(status)
599    }
600
601    fn is_closed(&self) -> bool {
602        self.inner.channel().is_closed()
603    }
604    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
605        self.inner.channel().on_closed()
606    }
607
608    #[cfg(target_os = "fuchsia")]
609    fn signal_peer(
610        &self,
611        clear_mask: zx::Signals,
612        set_mask: zx::Signals,
613    ) -> Result<(), zx_status::Status> {
614        use fidl::Peered;
615        self.inner.channel().signal_peer(clear_mask, set_mask)
616    }
617}
618
619impl TestHarnessControlHandle {}
620
621#[must_use = "FIDL methods require a response to be sent"]
622#[derive(Debug)]
623pub struct TestHarnessGetConfigResponder {
624    control_handle: std::mem::ManuallyDrop<TestHarnessControlHandle>,
625    tx_id: u32,
626}
627
628/// Set the the channel to be shutdown (see [`TestHarnessControlHandle::shutdown`])
629/// if the responder is dropped without sending a response, so that the client
630/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
631impl std::ops::Drop for TestHarnessGetConfigResponder {
632    fn drop(&mut self) {
633        self.control_handle.shutdown();
634        // Safety: drops once, never accessed again
635        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
636    }
637}
638
639impl fidl::endpoints::Responder for TestHarnessGetConfigResponder {
640    type ControlHandle = TestHarnessControlHandle;
641
642    fn control_handle(&self) -> &TestHarnessControlHandle {
643        &self.control_handle
644    }
645
646    fn drop_without_shutdown(mut self) {
647        // Safety: drops once, never accessed again due to mem::forget
648        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
649        // Prevent Drop from running (which would shut down the channel)
650        std::mem::forget(self);
651    }
652}
653
654impl TestHarnessGetConfigResponder {
655    /// Sends a response to the FIDL transaction.
656    ///
657    /// Sets the channel to shutdown if an error occurs.
658    pub fn send(self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
659        let _result = self.send_raw(config);
660        if _result.is_err() {
661            self.control_handle.shutdown();
662        }
663        self.drop_without_shutdown();
664        _result
665    }
666
667    /// Similar to "send" but does not shutdown the channel if an error occurs.
668    pub fn send_no_shutdown_on_err(self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
669        let _result = self.send_raw(config);
670        self.drop_without_shutdown();
671        _result
672    }
673
674    fn send_raw(&self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
675        self.control_handle.inner.send::<TestHarnessGetConfigResponse>(
676            (config,),
677            self.tx_id,
678            0x758882a165dbaa23,
679            fidl::encoding::DynamicFlags::empty(),
680        )
681    }
682}
683
684#[must_use = "FIDL methods require a response to be sent"]
685#[derive(Debug)]
686pub struct TestHarnessOpenServiceDirectoryResponder {
687    control_handle: std::mem::ManuallyDrop<TestHarnessControlHandle>,
688    tx_id: u32,
689}
690
691/// Set the the channel to be shutdown (see [`TestHarnessControlHandle::shutdown`])
692/// if the responder is dropped without sending a response, so that the client
693/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
694impl std::ops::Drop for TestHarnessOpenServiceDirectoryResponder {
695    fn drop(&mut self) {
696        self.control_handle.shutdown();
697        // Safety: drops once, never accessed again
698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
699    }
700}
701
702impl fidl::endpoints::Responder for TestHarnessOpenServiceDirectoryResponder {
703    type ControlHandle = TestHarnessControlHandle;
704
705    fn control_handle(&self) -> &TestHarnessControlHandle {
706        &self.control_handle
707    }
708
709    fn drop_without_shutdown(mut self) {
710        // Safety: drops once, never accessed again due to mem::forget
711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
712        // Prevent Drop from running (which would shut down the channel)
713        std::mem::forget(self);
714    }
715}
716
717impl TestHarnessOpenServiceDirectoryResponder {
718    /// Sends a response to the FIDL transaction.
719    ///
720    /// Sets the channel to shutdown if an error occurs.
721    pub fn send(
722        self,
723        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
724    ) -> Result<(), fidl::Error> {
725        let _result = self.send_raw(object_request);
726        if _result.is_err() {
727            self.control_handle.shutdown();
728        }
729        self.drop_without_shutdown();
730        _result
731    }
732
733    /// Similar to "send" but does not shutdown the channel if an error occurs.
734    pub fn send_no_shutdown_on_err(
735        self,
736        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
737    ) -> Result<(), fidl::Error> {
738        let _result = self.send_raw(object_request);
739        self.drop_without_shutdown();
740        _result
741    }
742
743    fn send_raw(
744        &self,
745        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
746    ) -> Result<(), fidl::Error> {
747        self.control_handle.inner.send::<TestHarnessOpenServiceDirectoryResponse>(
748            (object_request,),
749            self.tx_id,
750            0x42904fe08b12ef88,
751            fidl::encoding::DynamicFlags::empty(),
752        )
753    }
754}
755
756mod internal {
757    use super::*;
758
759    impl fidl::encoding::ResourceTypeMarker for Directory {
760        type Borrowed<'a> = &'a mut Self;
761        fn take_or_borrow<'a>(
762            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
763        ) -> Self::Borrowed<'a> {
764            value
765        }
766    }
767
768    unsafe impl fidl::encoding::TypeMarker for Directory {
769        type Owned = Self;
770
771        #[inline(always)]
772        fn inline_align(_context: fidl::encoding::Context) -> usize {
773            8
774        }
775
776        #[inline(always)]
777        fn inline_size(_context: fidl::encoding::Context) -> usize {
778            32
779        }
780    }
781
782    unsafe impl fidl::encoding::Encode<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>
783        for &mut Directory
784    {
785        #[inline]
786        unsafe fn encode(
787            self,
788            encoder: &mut fidl::encoding::Encoder<
789                '_,
790                fidl::encoding::DefaultFuchsiaResourceDialect,
791            >,
792            offset: usize,
793            _depth: fidl::encoding::Depth,
794        ) -> fidl::Result<()> {
795            encoder.debug_check_bounds::<Directory>(offset);
796            // Delegate to tuple encoding.
797            fidl::encoding::Encode::<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
798                (
799                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
800                    <fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.entries),
801                ),
802                encoder, offset, _depth
803            )
804        }
805    }
806    unsafe impl<
807            T0: fidl::encoding::Encode<
808                fidl::encoding::BoundedString<255>,
809                fidl::encoding::DefaultFuchsiaResourceDialect,
810            >,
811            T1: fidl::encoding::Encode<
812                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
813                fidl::encoding::DefaultFuchsiaResourceDialect,
814            >,
815        > fidl::encoding::Encode<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>
816        for (T0, T1)
817    {
818        #[inline]
819        unsafe fn encode(
820            self,
821            encoder: &mut fidl::encoding::Encoder<
822                '_,
823                fidl::encoding::DefaultFuchsiaResourceDialect,
824            >,
825            offset: usize,
826            depth: fidl::encoding::Depth,
827        ) -> fidl::Result<()> {
828            encoder.debug_check_bounds::<Directory>(offset);
829            // Zero out padding regions. There's no need to apply masks
830            // because the unmasked parts will be overwritten by fields.
831            // Write the fields.
832            self.0.encode(encoder, offset + 0, depth)?;
833            self.1.encode(encoder, offset + 16, depth)?;
834            Ok(())
835        }
836    }
837
838    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Directory {
839        #[inline(always)]
840        fn new_empty() -> Self {
841            Self {
842                name: fidl::new_empty!(
843                    fidl::encoding::BoundedString<255>,
844                    fidl::encoding::DefaultFuchsiaResourceDialect
845                ),
846                entries: fidl::new_empty!(
847                    fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
848                    fidl::encoding::DefaultFuchsiaResourceDialect
849                ),
850            }
851        }
852
853        #[inline]
854        unsafe fn decode(
855            &mut self,
856            decoder: &mut fidl::encoding::Decoder<
857                '_,
858                fidl::encoding::DefaultFuchsiaResourceDialect,
859            >,
860            offset: usize,
861            _depth: fidl::encoding::Depth,
862        ) -> fidl::Result<()> {
863            decoder.debug_check_bounds::<Self>(offset);
864            // Verify that padding bytes are zero.
865            fidl::decode!(
866                fidl::encoding::BoundedString<255>,
867                fidl::encoding::DefaultFuchsiaResourceDialect,
868                &mut self.name,
869                decoder,
870                offset + 0,
871                _depth
872            )?;
873            fidl::decode!(
874                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
875                fidl::encoding::DefaultFuchsiaResourceDialect,
876                &mut self.entries,
877                decoder,
878                offset + 16,
879                _depth
880            )?;
881            Ok(())
882        }
883    }
884
885    impl fidl::encoding::ResourceTypeMarker for RemoteDirectory {
886        type Borrowed<'a> = &'a mut Self;
887        fn take_or_borrow<'a>(
888            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
889        ) -> Self::Borrowed<'a> {
890            value
891        }
892    }
893
894    unsafe impl fidl::encoding::TypeMarker for RemoteDirectory {
895        type Owned = Self;
896
897        #[inline(always)]
898        fn inline_align(_context: fidl::encoding::Context) -> usize {
899            8
900        }
901
902        #[inline(always)]
903        fn inline_size(_context: fidl::encoding::Context) -> usize {
904            24
905        }
906    }
907
908    unsafe impl
909        fidl::encoding::Encode<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>
910        for &mut RemoteDirectory
911    {
912        #[inline]
913        unsafe fn encode(
914            self,
915            encoder: &mut fidl::encoding::Encoder<
916                '_,
917                fidl::encoding::DefaultFuchsiaResourceDialect,
918            >,
919            offset: usize,
920            _depth: fidl::encoding::Depth,
921        ) -> fidl::Result<()> {
922            encoder.debug_check_bounds::<RemoteDirectory>(offset);
923            // Delegate to tuple encoding.
924            fidl::encoding::Encode::<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
925                (
926                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
927                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.remote_client),
928                ),
929                encoder, offset, _depth
930            )
931        }
932    }
933    unsafe impl<
934            T0: fidl::encoding::Encode<
935                fidl::encoding::BoundedString<255>,
936                fidl::encoding::DefaultFuchsiaResourceDialect,
937            >,
938            T1: fidl::encoding::Encode<
939                fidl::encoding::Endpoint<
940                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
941                >,
942                fidl::encoding::DefaultFuchsiaResourceDialect,
943            >,
944        > fidl::encoding::Encode<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>
945        for (T0, T1)
946    {
947        #[inline]
948        unsafe fn encode(
949            self,
950            encoder: &mut fidl::encoding::Encoder<
951                '_,
952                fidl::encoding::DefaultFuchsiaResourceDialect,
953            >,
954            offset: usize,
955            depth: fidl::encoding::Depth,
956        ) -> fidl::Result<()> {
957            encoder.debug_check_bounds::<RemoteDirectory>(offset);
958            // Zero out padding regions. There's no need to apply masks
959            // because the unmasked parts will be overwritten by fields.
960            unsafe {
961                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
962                (ptr as *mut u64).write_unaligned(0);
963            }
964            // Write the fields.
965            self.0.encode(encoder, offset + 0, depth)?;
966            self.1.encode(encoder, offset + 16, depth)?;
967            Ok(())
968        }
969    }
970
971    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
972        for RemoteDirectory
973    {
974        #[inline(always)]
975        fn new_empty() -> Self {
976            Self {
977                name: fidl::new_empty!(
978                    fidl::encoding::BoundedString<255>,
979                    fidl::encoding::DefaultFuchsiaResourceDialect
980                ),
981                remote_client: fidl::new_empty!(
982                    fidl::encoding::Endpoint<
983                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
984                    >,
985                    fidl::encoding::DefaultFuchsiaResourceDialect
986                ),
987            }
988        }
989
990        #[inline]
991        unsafe fn decode(
992            &mut self,
993            decoder: &mut fidl::encoding::Decoder<
994                '_,
995                fidl::encoding::DefaultFuchsiaResourceDialect,
996            >,
997            offset: usize,
998            _depth: fidl::encoding::Depth,
999        ) -> fidl::Result<()> {
1000            decoder.debug_check_bounds::<Self>(offset);
1001            // Verify that padding bytes are zero.
1002            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1003            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1004            let mask = 0xffffffff00000000u64;
1005            let maskedval = padval & mask;
1006            if maskedval != 0 {
1007                return Err(fidl::Error::NonZeroPadding {
1008                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1009                });
1010            }
1011            fidl::decode!(
1012                fidl::encoding::BoundedString<255>,
1013                fidl::encoding::DefaultFuchsiaResourceDialect,
1014                &mut self.name,
1015                decoder,
1016                offset + 0,
1017                _depth
1018            )?;
1019            fidl::decode!(
1020                fidl::encoding::Endpoint<
1021                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1022                >,
1023                fidl::encoding::DefaultFuchsiaResourceDialect,
1024                &mut self.remote_client,
1025                decoder,
1026                offset + 16,
1027                _depth
1028            )?;
1029            Ok(())
1030        }
1031    }
1032
1033    impl fidl::encoding::ResourceTypeMarker for TestHarnessCreateDirectoryRequest {
1034        type Borrowed<'a> = &'a mut Self;
1035        fn take_or_borrow<'a>(
1036            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1037        ) -> Self::Borrowed<'a> {
1038            value
1039        }
1040    }
1041
1042    unsafe impl fidl::encoding::TypeMarker for TestHarnessCreateDirectoryRequest {
1043        type Owned = Self;
1044
1045        #[inline(always)]
1046        fn inline_align(_context: fidl::encoding::Context) -> usize {
1047            8
1048        }
1049
1050        #[inline(always)]
1051        fn inline_size(_context: fidl::encoding::Context) -> usize {
1052            32
1053        }
1054    }
1055
1056    unsafe impl
1057        fidl::encoding::Encode<
1058            TestHarnessCreateDirectoryRequest,
1059            fidl::encoding::DefaultFuchsiaResourceDialect,
1060        > for &mut TestHarnessCreateDirectoryRequest
1061    {
1062        #[inline]
1063        unsafe fn encode(
1064            self,
1065            encoder: &mut fidl::encoding::Encoder<
1066                '_,
1067                fidl::encoding::DefaultFuchsiaResourceDialect,
1068            >,
1069            offset: usize,
1070            _depth: fidl::encoding::Depth,
1071        ) -> fidl::Result<()> {
1072            encoder.debug_check_bounds::<TestHarnessCreateDirectoryRequest>(offset);
1073            // Delegate to tuple encoding.
1074            fidl::encoding::Encode::<TestHarnessCreateDirectoryRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1075                (
1076                    <fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.contents),
1077                    <fidl_fuchsia_io::Flags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1078                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.object_request),
1079                ),
1080                encoder, offset, _depth
1081            )
1082        }
1083    }
1084    unsafe impl<
1085            T0: fidl::encoding::Encode<
1086                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1087                fidl::encoding::DefaultFuchsiaResourceDialect,
1088            >,
1089            T1: fidl::encoding::Encode<
1090                fidl_fuchsia_io::Flags,
1091                fidl::encoding::DefaultFuchsiaResourceDialect,
1092            >,
1093            T2: fidl::encoding::Encode<
1094                fidl::encoding::Endpoint<
1095                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1096                >,
1097                fidl::encoding::DefaultFuchsiaResourceDialect,
1098            >,
1099        >
1100        fidl::encoding::Encode<
1101            TestHarnessCreateDirectoryRequest,
1102            fidl::encoding::DefaultFuchsiaResourceDialect,
1103        > for (T0, T1, T2)
1104    {
1105        #[inline]
1106        unsafe fn encode(
1107            self,
1108            encoder: &mut fidl::encoding::Encoder<
1109                '_,
1110                fidl::encoding::DefaultFuchsiaResourceDialect,
1111            >,
1112            offset: usize,
1113            depth: fidl::encoding::Depth,
1114        ) -> fidl::Result<()> {
1115            encoder.debug_check_bounds::<TestHarnessCreateDirectoryRequest>(offset);
1116            // Zero out padding regions. There's no need to apply masks
1117            // because the unmasked parts will be overwritten by fields.
1118            unsafe {
1119                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1120                (ptr as *mut u64).write_unaligned(0);
1121            }
1122            // Write the fields.
1123            self.0.encode(encoder, offset + 0, depth)?;
1124            self.1.encode(encoder, offset + 16, depth)?;
1125            self.2.encode(encoder, offset + 24, depth)?;
1126            Ok(())
1127        }
1128    }
1129
1130    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1131        for TestHarnessCreateDirectoryRequest
1132    {
1133        #[inline(always)]
1134        fn new_empty() -> Self {
1135            Self {
1136                contents: fidl::new_empty!(
1137                    fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1138                    fidl::encoding::DefaultFuchsiaResourceDialect
1139                ),
1140                flags: fidl::new_empty!(
1141                    fidl_fuchsia_io::Flags,
1142                    fidl::encoding::DefaultFuchsiaResourceDialect
1143                ),
1144                object_request: fidl::new_empty!(
1145                    fidl::encoding::Endpoint<
1146                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1147                    >,
1148                    fidl::encoding::DefaultFuchsiaResourceDialect
1149                ),
1150            }
1151        }
1152
1153        #[inline]
1154        unsafe fn decode(
1155            &mut self,
1156            decoder: &mut fidl::encoding::Decoder<
1157                '_,
1158                fidl::encoding::DefaultFuchsiaResourceDialect,
1159            >,
1160            offset: usize,
1161            _depth: fidl::encoding::Depth,
1162        ) -> fidl::Result<()> {
1163            decoder.debug_check_bounds::<Self>(offset);
1164            // Verify that padding bytes are zero.
1165            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1166            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1167            let mask = 0xffffffff00000000u64;
1168            let maskedval = padval & mask;
1169            if maskedval != 0 {
1170                return Err(fidl::Error::NonZeroPadding {
1171                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1172                });
1173            }
1174            fidl::decode!(
1175                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1176                fidl::encoding::DefaultFuchsiaResourceDialect,
1177                &mut self.contents,
1178                decoder,
1179                offset + 0,
1180                _depth
1181            )?;
1182            fidl::decode!(
1183                fidl_fuchsia_io::Flags,
1184                fidl::encoding::DefaultFuchsiaResourceDialect,
1185                &mut self.flags,
1186                decoder,
1187                offset + 16,
1188                _depth
1189            )?;
1190            fidl::decode!(
1191                fidl::encoding::Endpoint<
1192                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1193                >,
1194                fidl::encoding::DefaultFuchsiaResourceDialect,
1195                &mut self.object_request,
1196                decoder,
1197                offset + 24,
1198                _depth
1199            )?;
1200            Ok(())
1201        }
1202    }
1203
1204    impl fidl::encoding::ResourceTypeMarker for TestHarnessOpenServiceDirectoryResponse {
1205        type Borrowed<'a> = &'a mut Self;
1206        fn take_or_borrow<'a>(
1207            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1208        ) -> Self::Borrowed<'a> {
1209            value
1210        }
1211    }
1212
1213    unsafe impl fidl::encoding::TypeMarker for TestHarnessOpenServiceDirectoryResponse {
1214        type Owned = Self;
1215
1216        #[inline(always)]
1217        fn inline_align(_context: fidl::encoding::Context) -> usize {
1218            4
1219        }
1220
1221        #[inline(always)]
1222        fn inline_size(_context: fidl::encoding::Context) -> usize {
1223            4
1224        }
1225    }
1226
1227    unsafe impl
1228        fidl::encoding::Encode<
1229            TestHarnessOpenServiceDirectoryResponse,
1230            fidl::encoding::DefaultFuchsiaResourceDialect,
1231        > for &mut TestHarnessOpenServiceDirectoryResponse
1232    {
1233        #[inline]
1234        unsafe fn encode(
1235            self,
1236            encoder: &mut fidl::encoding::Encoder<
1237                '_,
1238                fidl::encoding::DefaultFuchsiaResourceDialect,
1239            >,
1240            offset: usize,
1241            _depth: fidl::encoding::Depth,
1242        ) -> fidl::Result<()> {
1243            encoder.debug_check_bounds::<TestHarnessOpenServiceDirectoryResponse>(offset);
1244            // Delegate to tuple encoding.
1245            fidl::encoding::Encode::<
1246                TestHarnessOpenServiceDirectoryResponse,
1247                fidl::encoding::DefaultFuchsiaResourceDialect,
1248            >::encode(
1249                (<fidl::encoding::Endpoint<
1250                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1251                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1252                    &mut self.object_request
1253                ),),
1254                encoder,
1255                offset,
1256                _depth,
1257            )
1258        }
1259    }
1260    unsafe impl<
1261            T0: fidl::encoding::Encode<
1262                fidl::encoding::Endpoint<
1263                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1264                >,
1265                fidl::encoding::DefaultFuchsiaResourceDialect,
1266            >,
1267        >
1268        fidl::encoding::Encode<
1269            TestHarnessOpenServiceDirectoryResponse,
1270            fidl::encoding::DefaultFuchsiaResourceDialect,
1271        > for (T0,)
1272    {
1273        #[inline]
1274        unsafe fn encode(
1275            self,
1276            encoder: &mut fidl::encoding::Encoder<
1277                '_,
1278                fidl::encoding::DefaultFuchsiaResourceDialect,
1279            >,
1280            offset: usize,
1281            depth: fidl::encoding::Depth,
1282        ) -> fidl::Result<()> {
1283            encoder.debug_check_bounds::<TestHarnessOpenServiceDirectoryResponse>(offset);
1284            // Zero out padding regions. There's no need to apply masks
1285            // because the unmasked parts will be overwritten by fields.
1286            // Write the fields.
1287            self.0.encode(encoder, offset + 0, depth)?;
1288            Ok(())
1289        }
1290    }
1291
1292    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1293        for TestHarnessOpenServiceDirectoryResponse
1294    {
1295        #[inline(always)]
1296        fn new_empty() -> Self {
1297            Self {
1298                object_request: fidl::new_empty!(
1299                    fidl::encoding::Endpoint<
1300                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1301                    >,
1302                    fidl::encoding::DefaultFuchsiaResourceDialect
1303                ),
1304            }
1305        }
1306
1307        #[inline]
1308        unsafe fn decode(
1309            &mut self,
1310            decoder: &mut fidl::encoding::Decoder<
1311                '_,
1312                fidl::encoding::DefaultFuchsiaResourceDialect,
1313            >,
1314            offset: usize,
1315            _depth: fidl::encoding::Depth,
1316        ) -> fidl::Result<()> {
1317            decoder.debug_check_bounds::<Self>(offset);
1318            // Verify that padding bytes are zero.
1319            fidl::decode!(
1320                fidl::encoding::Endpoint<
1321                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1322                >,
1323                fidl::encoding::DefaultFuchsiaResourceDialect,
1324                &mut self.object_request,
1325                decoder,
1326                offset + 0,
1327                _depth
1328            )?;
1329            Ok(())
1330        }
1331    }
1332
1333    impl fidl::encoding::ResourceTypeMarker for DirectoryEntry {
1334        type Borrowed<'a> = &'a mut Self;
1335        fn take_or_borrow<'a>(
1336            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1337        ) -> Self::Borrowed<'a> {
1338            value
1339        }
1340    }
1341
1342    unsafe impl fidl::encoding::TypeMarker for DirectoryEntry {
1343        type Owned = Self;
1344
1345        #[inline(always)]
1346        fn inline_align(_context: fidl::encoding::Context) -> usize {
1347            8
1348        }
1349
1350        #[inline(always)]
1351        fn inline_size(_context: fidl::encoding::Context) -> usize {
1352            16
1353        }
1354    }
1355
1356    unsafe impl
1357        fidl::encoding::Encode<DirectoryEntry, fidl::encoding::DefaultFuchsiaResourceDialect>
1358        for &mut DirectoryEntry
1359    {
1360        #[inline]
1361        unsafe fn encode(
1362            self,
1363            encoder: &mut fidl::encoding::Encoder<
1364                '_,
1365                fidl::encoding::DefaultFuchsiaResourceDialect,
1366            >,
1367            offset: usize,
1368            _depth: fidl::encoding::Depth,
1369        ) -> fidl::Result<()> {
1370            encoder.debug_check_bounds::<DirectoryEntry>(offset);
1371            encoder.write_num::<u64>(self.ordinal(), offset);
1372            match self {
1373                DirectoryEntry::Directory(ref mut val) => fidl::encoding::encode_in_envelope::<
1374                    Directory,
1375                    fidl::encoding::DefaultFuchsiaResourceDialect,
1376                >(
1377                    <Directory as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1378                    encoder,
1379                    offset + 8,
1380                    _depth,
1381                ),
1382                DirectoryEntry::RemoteDirectory(ref mut val) => {
1383                    fidl::encoding::encode_in_envelope::<
1384                        RemoteDirectory,
1385                        fidl::encoding::DefaultFuchsiaResourceDialect,
1386                    >(
1387                        <RemoteDirectory as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1388                            val,
1389                        ),
1390                        encoder,
1391                        offset + 8,
1392                        _depth,
1393                    )
1394                }
1395                DirectoryEntry::File(ref val) => fidl::encoding::encode_in_envelope::<
1396                    File,
1397                    fidl::encoding::DefaultFuchsiaResourceDialect,
1398                >(
1399                    <File as fidl::encoding::ValueTypeMarker>::borrow(val),
1400                    encoder,
1401                    offset + 8,
1402                    _depth,
1403                ),
1404                DirectoryEntry::ExecutableFile(ref val) => fidl::encoding::encode_in_envelope::<
1405                    ExecutableFile,
1406                    fidl::encoding::DefaultFuchsiaResourceDialect,
1407                >(
1408                    <ExecutableFile as fidl::encoding::ValueTypeMarker>::borrow(val),
1409                    encoder,
1410                    offset + 8,
1411                    _depth,
1412                ),
1413            }
1414        }
1415    }
1416
1417    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1418        for DirectoryEntry
1419    {
1420        #[inline(always)]
1421        fn new_empty() -> Self {
1422            Self::Directory(fidl::new_empty!(
1423                Directory,
1424                fidl::encoding::DefaultFuchsiaResourceDialect
1425            ))
1426        }
1427
1428        #[inline]
1429        unsafe fn decode(
1430            &mut self,
1431            decoder: &mut fidl::encoding::Decoder<
1432                '_,
1433                fidl::encoding::DefaultFuchsiaResourceDialect,
1434            >,
1435            offset: usize,
1436            mut depth: fidl::encoding::Depth,
1437        ) -> fidl::Result<()> {
1438            decoder.debug_check_bounds::<Self>(offset);
1439            #[allow(unused_variables)]
1440            let next_out_of_line = decoder.next_out_of_line();
1441            let handles_before = decoder.remaining_handles();
1442            let (ordinal, inlined, num_bytes, num_handles) =
1443                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1444
1445            let member_inline_size = match ordinal {
1446                1 => <Directory as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1447                2 => <RemoteDirectory as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1448                3 => <File as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1449                5 => <ExecutableFile as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1450                _ => return Err(fidl::Error::UnknownUnionTag),
1451            };
1452
1453            if inlined != (member_inline_size <= 4) {
1454                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1455            }
1456            let _inner_offset;
1457            if inlined {
1458                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1459                _inner_offset = offset + 8;
1460            } else {
1461                depth.increment()?;
1462                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1463            }
1464            match ordinal {
1465                1 => {
1466                    #[allow(irrefutable_let_patterns)]
1467                    if let DirectoryEntry::Directory(_) = self {
1468                        // Do nothing, read the value into the object
1469                    } else {
1470                        // Initialize `self` to the right variant
1471                        *self = DirectoryEntry::Directory(fidl::new_empty!(
1472                            Directory,
1473                            fidl::encoding::DefaultFuchsiaResourceDialect
1474                        ));
1475                    }
1476                    #[allow(irrefutable_let_patterns)]
1477                    if let DirectoryEntry::Directory(ref mut val) = self {
1478                        fidl::decode!(
1479                            Directory,
1480                            fidl::encoding::DefaultFuchsiaResourceDialect,
1481                            val,
1482                            decoder,
1483                            _inner_offset,
1484                            depth
1485                        )?;
1486                    } else {
1487                        unreachable!()
1488                    }
1489                }
1490                2 => {
1491                    #[allow(irrefutable_let_patterns)]
1492                    if let DirectoryEntry::RemoteDirectory(_) = self {
1493                        // Do nothing, read the value into the object
1494                    } else {
1495                        // Initialize `self` to the right variant
1496                        *self = DirectoryEntry::RemoteDirectory(fidl::new_empty!(
1497                            RemoteDirectory,
1498                            fidl::encoding::DefaultFuchsiaResourceDialect
1499                        ));
1500                    }
1501                    #[allow(irrefutable_let_patterns)]
1502                    if let DirectoryEntry::RemoteDirectory(ref mut val) = self {
1503                        fidl::decode!(
1504                            RemoteDirectory,
1505                            fidl::encoding::DefaultFuchsiaResourceDialect,
1506                            val,
1507                            decoder,
1508                            _inner_offset,
1509                            depth
1510                        )?;
1511                    } else {
1512                        unreachable!()
1513                    }
1514                }
1515                3 => {
1516                    #[allow(irrefutable_let_patterns)]
1517                    if let DirectoryEntry::File(_) = self {
1518                        // Do nothing, read the value into the object
1519                    } else {
1520                        // Initialize `self` to the right variant
1521                        *self = DirectoryEntry::File(fidl::new_empty!(
1522                            File,
1523                            fidl::encoding::DefaultFuchsiaResourceDialect
1524                        ));
1525                    }
1526                    #[allow(irrefutable_let_patterns)]
1527                    if let DirectoryEntry::File(ref mut val) = self {
1528                        fidl::decode!(
1529                            File,
1530                            fidl::encoding::DefaultFuchsiaResourceDialect,
1531                            val,
1532                            decoder,
1533                            _inner_offset,
1534                            depth
1535                        )?;
1536                    } else {
1537                        unreachable!()
1538                    }
1539                }
1540                5 => {
1541                    #[allow(irrefutable_let_patterns)]
1542                    if let DirectoryEntry::ExecutableFile(_) = self {
1543                        // Do nothing, read the value into the object
1544                    } else {
1545                        // Initialize `self` to the right variant
1546                        *self = DirectoryEntry::ExecutableFile(fidl::new_empty!(
1547                            ExecutableFile,
1548                            fidl::encoding::DefaultFuchsiaResourceDialect
1549                        ));
1550                    }
1551                    #[allow(irrefutable_let_patterns)]
1552                    if let DirectoryEntry::ExecutableFile(ref mut val) = self {
1553                        fidl::decode!(
1554                            ExecutableFile,
1555                            fidl::encoding::DefaultFuchsiaResourceDialect,
1556                            val,
1557                            decoder,
1558                            _inner_offset,
1559                            depth
1560                        )?;
1561                    } else {
1562                        unreachable!()
1563                    }
1564                }
1565                ordinal => panic!("unexpected ordinal {:?}", ordinal),
1566            }
1567            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1568                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1569            }
1570            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1571                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1572            }
1573            Ok(())
1574        }
1575    }
1576}