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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// Directory entries should support opening with any combination of read/write/execute rights.
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct Directory {
16    pub name: String,
17    pub entries: Vec<Option<Box<DirectoryEntry>>>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Directory {}
21
22/// Adds an executable file that supports opening as readable + executable. The file has a non-zero
23/// size, but the contents are otherwise unspecified.
24///
25/// Enabled via the `supports_executable_file` configuration option. `ExecutableFile` objects should
26/// support fuchsia.io/File.GetBackingMemory.
27#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
28pub struct ExecutableFile {
29    pub name: String,
30}
31
32impl fidl::Persistable for ExecutableFile {}
33
34/// File object which supports reading and writing. Use [`ExecutableFile`] if execute rights are
35/// required.
36#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct File {
38    pub name: String,
39    pub contents: Vec<u8>,
40}
41
42impl fidl::Persistable for File {}
43
44/// Conformance test harnesses will implement this protocol to setup its
45/// associated filesystem servers with the described directory layout,
46/// allowing their implementation of `fuchsia.io` and `fuchsia.io2` protocols
47/// to be verified by a common test suite.
48///
49/// Different test cases will not interact with one another during the
50/// conformance test, and only one test case will be active at a time per
51/// tested filesystem. So it is possible to host all cases as different
52/// sub-directories under a common filesystem instance, to simplify the
53/// lifecycle and implementation.
54///
55/// If a test case has mutable bits, each method call should be implemented
56/// to obtain the directory in its original state. In other words, repeated
57/// test case set up should "as-if" yield new directories.
58///
59/// See `src/storage/conformance/README.md` for an overview of io conformance
60/// testing.
61///
62/// `HarnessConfig` lets the test harness modulate the set of expected outcomes and
63/// behaviors validated by the test suite, by declaring specific properties
64/// about the filesystem implementation. For example, setting [`ImmutableFile`]
65/// to true informs the test suites that files hosted by this harness do not
66/// support mutation.
67#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
68pub struct HarnessConfig {
69    /// ExecutableFile objects are supported.
70    pub supports_executable_file: bool,
71    /// Supports writing to files and updating file attributes.
72    pub supports_mutable_file: bool,
73    /// GetBackingMemory is supported.
74    pub supports_get_backing_memory: bool,
75    /// Remote directories are supported.
76    pub supports_remote_dir: bool,
77    /// GetToken is supported.
78    pub supports_get_token: bool,
79    /// Supports fuchsia.io's LinkInto method.
80    pub supports_link_into: bool,
81    /// Files can be opened in append mode.
82    pub supports_append: bool,
83    /// Files can be truncated (resized).
84    pub supports_truncate: bool,
85    /// The set of attributes the filesystem supports. If mutable attributes are reported, the
86    /// harness must support [`fuchsia.io/Node.SetAttr`] and [`fuchsia.io/Node.UpdateAttributes`].
87    pub supported_attributes: fidl_fuchsia_io::NodeAttributesQuery,
88    /// Directories support creating files, Rename, Link, and Unlink.
89    pub supports_modify_directory: bool,
90    /// Supports services.
91    pub supports_services: bool,
92    /// Supports unnamed temporary files.
93    pub supports_unnamed_temporary_file: bool,
94}
95
96impl fidl::Persistable for HarnessConfig {}
97
98/// Remote directory which forwards FIDL requests from the server to the specified directory.
99#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
100pub struct RemoteDirectory {
101    pub name: String,
102    pub remote_client: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
103}
104
105impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RemoteDirectory {}
106
107#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
108pub struct TestHarnessCreateDirectoryRequest {
109    pub contents: Vec<Option<Box<DirectoryEntry>>>,
110    pub flags: fidl_fuchsia_io::Flags,
111    pub object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
112}
113
114impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
115    for TestHarnessCreateDirectoryRequest
116{
117}
118
119#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
120pub struct TestHarnessGetConfigResponse {
121    pub config: HarnessConfig,
122}
123
124impl fidl::Persistable for TestHarnessGetConfigResponse {}
125
126#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
127pub struct TestHarnessOpenServiceDirectoryResponse {
128    pub object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
129}
130
131impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
132    for TestHarnessOpenServiceDirectoryResponse
133{
134}
135
136#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
137pub enum DirectoryEntry {
138    Directory(Directory),
139    RemoteDirectory(RemoteDirectory),
140    File(File),
141    ExecutableFile(ExecutableFile),
142}
143
144impl DirectoryEntry {
145    #[inline]
146    pub fn ordinal(&self) -> u64 {
147        match *self {
148            Self::Directory(_) => 1,
149            Self::RemoteDirectory(_) => 2,
150            Self::File(_) => 3,
151            Self::ExecutableFile(_) => 5,
152        }
153    }
154
155    #[deprecated = "Strict unions should not use `is_unknown`"]
156    #[inline]
157    pub fn is_unknown(&self) -> bool {
158        false
159    }
160}
161
162impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DirectoryEntry {}
163
164#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
165pub struct TestHarnessMarker;
166
167impl fidl::endpoints::ProtocolMarker for TestHarnessMarker {
168    type Proxy = TestHarnessProxy;
169    type RequestStream = TestHarnessRequestStream;
170    #[cfg(target_os = "fuchsia")]
171    type SynchronousProxy = TestHarnessSynchronousProxy;
172
173    const DEBUG_NAME: &'static str = "fuchsia.io.test.TestHarness";
174}
175impl fidl::endpoints::DiscoverableProtocolMarker for TestHarnessMarker {}
176
177pub trait TestHarnessProxyInterface: Send + Sync {
178    type GetConfigResponseFut: std::future::Future<Output = Result<HarnessConfig, fidl::Error>>
179        + Send;
180    fn r#get_config(&self) -> Self::GetConfigResponseFut;
181    fn r#create_directory(
182        &self,
183        contents: Vec<Option<Box<DirectoryEntry>>>,
184        flags: fidl_fuchsia_io::Flags,
185        object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
186    ) -> Result<(), fidl::Error>;
187    type OpenServiceDirectoryResponseFut: std::future::Future<
188            Output = Result<
189                fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
190                fidl::Error,
191            >,
192        > + Send;
193    fn r#open_service_directory(&self) -> Self::OpenServiceDirectoryResponseFut;
194}
195#[derive(Debug)]
196#[cfg(target_os = "fuchsia")]
197pub struct TestHarnessSynchronousProxy {
198    client: fidl::client::sync::Client,
199}
200
201#[cfg(target_os = "fuchsia")]
202impl fidl::endpoints::SynchronousProxy for TestHarnessSynchronousProxy {
203    type Proxy = TestHarnessProxy;
204    type Protocol = TestHarnessMarker;
205
206    fn from_channel(inner: fidl::Channel) -> Self {
207        Self::new(inner)
208    }
209
210    fn into_channel(self) -> fidl::Channel {
211        self.client.into_channel()
212    }
213
214    fn as_channel(&self) -> &fidl::Channel {
215        self.client.as_channel()
216    }
217}
218
219#[cfg(target_os = "fuchsia")]
220impl TestHarnessSynchronousProxy {
221    pub fn new(channel: fidl::Channel) -> Self {
222        let protocol_name = <TestHarnessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
223        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
224    }
225
226    pub fn into_channel(self) -> fidl::Channel {
227        self.client.into_channel()
228    }
229
230    /// Waits until an event arrives and returns it. It is safe for other
231    /// threads to make concurrent requests while waiting for an event.
232    pub fn wait_for_event(
233        &self,
234        deadline: zx::MonotonicInstant,
235    ) -> Result<TestHarnessEvent, fidl::Error> {
236        TestHarnessEvent::decode(self.client.wait_for_event(deadline)?)
237    }
238
239    /// Returns the list of properties of the filesystem.
240    pub fn r#get_config(
241        &self,
242        ___deadline: zx::MonotonicInstant,
243    ) -> Result<HarnessConfig, fidl::Error> {
244        let _response =
245            self.client.send_query::<fidl::encoding::EmptyPayload, TestHarnessGetConfigResponse>(
246                (),
247                0x758882a165dbaa23,
248                fidl::encoding::DynamicFlags::empty(),
249                ___deadline,
250            )?;
251        Ok(_response.config)
252    }
253
254    /// Creates a directory with the given `contents` and opens it with the specified `flags`.
255    pub fn r#create_directory(
256        &self,
257        mut contents: Vec<Option<Box<DirectoryEntry>>>,
258        mut flags: fidl_fuchsia_io::Flags,
259        mut object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
260    ) -> Result<(), fidl::Error> {
261        self.client.send::<TestHarnessCreateDirectoryRequest>(
262            (contents.as_mut(), flags, object_request),
263            0x626b0ce412a0cb4c,
264            fidl::encoding::DynamicFlags::empty(),
265        )
266    }
267
268    /// Serves a service directory that contains a fuchsia.test.placeholders/Echo instance.
269    /// The test harness must have `supports_services` reported in it's config to use this method,
270    /// and the service instance should match the discoverable protocol name.
271    pub fn r#open_service_directory(
272        &self,
273        ___deadline: zx::MonotonicInstant,
274    ) -> Result<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>, fidl::Error> {
275        let _response = self
276            .client
277            .send_query::<fidl::encoding::EmptyPayload, TestHarnessOpenServiceDirectoryResponse>(
278                (),
279                0x42904fe08b12ef88,
280                fidl::encoding::DynamicFlags::empty(),
281                ___deadline,
282            )?;
283        Ok(_response.object_request)
284    }
285}
286
287#[derive(Debug, Clone)]
288pub struct TestHarnessProxy {
289    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
290}
291
292impl fidl::endpoints::Proxy for TestHarnessProxy {
293    type Protocol = TestHarnessMarker;
294
295    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
296        Self::new(inner)
297    }
298
299    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
300        self.client.into_channel().map_err(|client| Self { client })
301    }
302
303    fn as_channel(&self) -> &::fidl::AsyncChannel {
304        self.client.as_channel()
305    }
306}
307
308impl TestHarnessProxy {
309    /// Create a new Proxy for fuchsia.io.test/TestHarness.
310    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
311        let protocol_name = <TestHarnessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
312        Self { client: fidl::client::Client::new(channel, protocol_name) }
313    }
314
315    /// Get a Stream of events from the remote end of the protocol.
316    ///
317    /// # Panics
318    ///
319    /// Panics if the event stream was already taken.
320    pub fn take_event_stream(&self) -> TestHarnessEventStream {
321        TestHarnessEventStream { event_receiver: self.client.take_event_receiver() }
322    }
323
324    /// Returns the list of properties of the filesystem.
325    pub fn r#get_config(
326        &self,
327    ) -> fidl::client::QueryResponseFut<HarnessConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
328    {
329        TestHarnessProxyInterface::r#get_config(self)
330    }
331
332    /// Creates a directory with the given `contents` and opens it with the specified `flags`.
333    pub fn r#create_directory(
334        &self,
335        mut contents: Vec<Option<Box<DirectoryEntry>>>,
336        mut flags: fidl_fuchsia_io::Flags,
337        mut object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
338    ) -> Result<(), fidl::Error> {
339        TestHarnessProxyInterface::r#create_directory(self, contents, flags, object_request)
340    }
341
342    /// Serves a service directory that contains a fuchsia.test.placeholders/Echo instance.
343    /// The test harness must have `supports_services` reported in it's config to use this method,
344    /// and the service instance should match the discoverable protocol name.
345    pub fn r#open_service_directory(
346        &self,
347    ) -> fidl::client::QueryResponseFut<
348        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
349        fidl::encoding::DefaultFuchsiaResourceDialect,
350    > {
351        TestHarnessProxyInterface::r#open_service_directory(self)
352    }
353}
354
355impl TestHarnessProxyInterface for TestHarnessProxy {
356    type GetConfigResponseFut = fidl::client::QueryResponseFut<
357        HarnessConfig,
358        fidl::encoding::DefaultFuchsiaResourceDialect,
359    >;
360    fn r#get_config(&self) -> Self::GetConfigResponseFut {
361        fn _decode(
362            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
363        ) -> Result<HarnessConfig, fidl::Error> {
364            let _response = fidl::client::decode_transaction_body::<
365                TestHarnessGetConfigResponse,
366                fidl::encoding::DefaultFuchsiaResourceDialect,
367                0x758882a165dbaa23,
368            >(_buf?)?;
369            Ok(_response.config)
370        }
371        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HarnessConfig>(
372            (),
373            0x758882a165dbaa23,
374            fidl::encoding::DynamicFlags::empty(),
375            _decode,
376        )
377    }
378
379    fn r#create_directory(
380        &self,
381        mut contents: Vec<Option<Box<DirectoryEntry>>>,
382        mut flags: fidl_fuchsia_io::Flags,
383        mut object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
384    ) -> Result<(), fidl::Error> {
385        self.client.send::<TestHarnessCreateDirectoryRequest>(
386            (contents.as_mut(), flags, object_request),
387            0x626b0ce412a0cb4c,
388            fidl::encoding::DynamicFlags::empty(),
389        )
390    }
391
392    type OpenServiceDirectoryResponseFut = fidl::client::QueryResponseFut<
393        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
394        fidl::encoding::DefaultFuchsiaResourceDialect,
395    >;
396    fn r#open_service_directory(&self) -> Self::OpenServiceDirectoryResponseFut {
397        fn _decode(
398            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
399        ) -> Result<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>, fidl::Error>
400        {
401            let _response = fidl::client::decode_transaction_body::<
402                TestHarnessOpenServiceDirectoryResponse,
403                fidl::encoding::DefaultFuchsiaResourceDialect,
404                0x42904fe08b12ef88,
405            >(_buf?)?;
406            Ok(_response.object_request)
407        }
408        self.client.send_query_and_decode::<
409            fidl::encoding::EmptyPayload,
410            fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
411        >(
412            (),
413            0x42904fe08b12ef88,
414            fidl::encoding::DynamicFlags::empty(),
415            _decode,
416        )
417    }
418}
419
420pub struct TestHarnessEventStream {
421    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
422}
423
424impl std::marker::Unpin for TestHarnessEventStream {}
425
426impl futures::stream::FusedStream for TestHarnessEventStream {
427    fn is_terminated(&self) -> bool {
428        self.event_receiver.is_terminated()
429    }
430}
431
432impl futures::Stream for TestHarnessEventStream {
433    type Item = Result<TestHarnessEvent, fidl::Error>;
434
435    fn poll_next(
436        mut self: std::pin::Pin<&mut Self>,
437        cx: &mut std::task::Context<'_>,
438    ) -> std::task::Poll<Option<Self::Item>> {
439        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
440            &mut self.event_receiver,
441            cx
442        )?) {
443            Some(buf) => std::task::Poll::Ready(Some(TestHarnessEvent::decode(buf))),
444            None => std::task::Poll::Ready(None),
445        }
446    }
447}
448
449#[derive(Debug)]
450pub enum TestHarnessEvent {}
451
452impl TestHarnessEvent {
453    /// Decodes a message buffer as a [`TestHarnessEvent`].
454    fn decode(
455        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
456    ) -> Result<TestHarnessEvent, fidl::Error> {
457        let (bytes, _handles) = buf.split_mut();
458        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
459        debug_assert_eq!(tx_header.tx_id, 0);
460        match tx_header.ordinal {
461            _ => Err(fidl::Error::UnknownOrdinal {
462                ordinal: tx_header.ordinal,
463                protocol_name: <TestHarnessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
464            }),
465        }
466    }
467}
468
469/// A Stream of incoming requests for fuchsia.io.test/TestHarness.
470pub struct TestHarnessRequestStream {
471    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
472    is_terminated: bool,
473}
474
475impl std::marker::Unpin for TestHarnessRequestStream {}
476
477impl futures::stream::FusedStream for TestHarnessRequestStream {
478    fn is_terminated(&self) -> bool {
479        self.is_terminated
480    }
481}
482
483impl fidl::endpoints::RequestStream for TestHarnessRequestStream {
484    type Protocol = TestHarnessMarker;
485    type ControlHandle = TestHarnessControlHandle;
486
487    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
488        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
489    }
490
491    fn control_handle(&self) -> Self::ControlHandle {
492        TestHarnessControlHandle { inner: self.inner.clone() }
493    }
494
495    fn into_inner(
496        self,
497    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
498    {
499        (self.inner, self.is_terminated)
500    }
501
502    fn from_inner(
503        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
504        is_terminated: bool,
505    ) -> Self {
506        Self { inner, is_terminated }
507    }
508}
509
510impl futures::Stream for TestHarnessRequestStream {
511    type Item = Result<TestHarnessRequest, fidl::Error>;
512
513    fn poll_next(
514        mut self: std::pin::Pin<&mut Self>,
515        cx: &mut std::task::Context<'_>,
516    ) -> std::task::Poll<Option<Self::Item>> {
517        let this = &mut *self;
518        if this.inner.check_shutdown(cx) {
519            this.is_terminated = true;
520            return std::task::Poll::Ready(None);
521        }
522        if this.is_terminated {
523            panic!("polled TestHarnessRequestStream after completion");
524        }
525        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
526            |bytes, handles| {
527                match this.inner.channel().read_etc(cx, bytes, handles) {
528                    std::task::Poll::Ready(Ok(())) => {}
529                    std::task::Poll::Pending => return std::task::Poll::Pending,
530                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
531                        this.is_terminated = true;
532                        return std::task::Poll::Ready(None);
533                    }
534                    std::task::Poll::Ready(Err(e)) => {
535                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
536                            e.into(),
537                        ))))
538                    }
539                }
540
541                // A message has been received from the channel
542                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
543
544                std::task::Poll::Ready(Some(match header.ordinal {
545                    0x758882a165dbaa23 => {
546                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
547                        let mut req = fidl::new_empty!(
548                            fidl::encoding::EmptyPayload,
549                            fidl::encoding::DefaultFuchsiaResourceDialect
550                        );
551                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
552                        let control_handle = TestHarnessControlHandle { inner: this.inner.clone() };
553                        Ok(TestHarnessRequest::GetConfig {
554                            responder: TestHarnessGetConfigResponder {
555                                control_handle: std::mem::ManuallyDrop::new(control_handle),
556                                tx_id: header.tx_id,
557                            },
558                        })
559                    }
560                    0x626b0ce412a0cb4c => {
561                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
562                        let mut req = fidl::new_empty!(
563                            TestHarnessCreateDirectoryRequest,
564                            fidl::encoding::DefaultFuchsiaResourceDialect
565                        );
566                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TestHarnessCreateDirectoryRequest>(&header, _body_bytes, handles, &mut req)?;
567                        let control_handle = TestHarnessControlHandle { inner: this.inner.clone() };
568                        Ok(TestHarnessRequest::CreateDirectory {
569                            contents: req.contents,
570                            flags: req.flags,
571                            object_request: req.object_request,
572
573                            control_handle,
574                        })
575                    }
576                    0x42904fe08b12ef88 => {
577                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
578                        let mut req = fidl::new_empty!(
579                            fidl::encoding::EmptyPayload,
580                            fidl::encoding::DefaultFuchsiaResourceDialect
581                        );
582                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
583                        let control_handle = TestHarnessControlHandle { inner: this.inner.clone() };
584                        Ok(TestHarnessRequest::OpenServiceDirectory {
585                            responder: TestHarnessOpenServiceDirectoryResponder {
586                                control_handle: std::mem::ManuallyDrop::new(control_handle),
587                                tx_id: header.tx_id,
588                            },
589                        })
590                    }
591                    _ => Err(fidl::Error::UnknownOrdinal {
592                        ordinal: header.ordinal,
593                        protocol_name:
594                            <TestHarnessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
595                    }),
596                }))
597            },
598        )
599    }
600}
601
602#[derive(Debug)]
603pub enum TestHarnessRequest {
604    /// Returns the list of properties of the filesystem.
605    GetConfig { responder: TestHarnessGetConfigResponder },
606    /// Creates a directory with the given `contents` and opens it with the specified `flags`.
607    CreateDirectory {
608        contents: Vec<Option<Box<DirectoryEntry>>>,
609        flags: fidl_fuchsia_io::Flags,
610        object_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
611        control_handle: TestHarnessControlHandle,
612    },
613    /// Serves a service directory that contains a fuchsia.test.placeholders/Echo instance.
614    /// The test harness must have `supports_services` reported in it's config to use this method,
615    /// and the service instance should match the discoverable protocol name.
616    OpenServiceDirectory { responder: TestHarnessOpenServiceDirectoryResponder },
617}
618
619impl TestHarnessRequest {
620    #[allow(irrefutable_let_patterns)]
621    pub fn into_get_config(self) -> Option<(TestHarnessGetConfigResponder)> {
622        if let TestHarnessRequest::GetConfig { responder } = self {
623            Some((responder))
624        } else {
625            None
626        }
627    }
628
629    #[allow(irrefutable_let_patterns)]
630    pub fn into_create_directory(
631        self,
632    ) -> Option<(
633        Vec<Option<Box<DirectoryEntry>>>,
634        fidl_fuchsia_io::Flags,
635        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
636        TestHarnessControlHandle,
637    )> {
638        if let TestHarnessRequest::CreateDirectory {
639            contents,
640            flags,
641            object_request,
642            control_handle,
643        } = self
644        {
645            Some((contents, flags, object_request, control_handle))
646        } else {
647            None
648        }
649    }
650
651    #[allow(irrefutable_let_patterns)]
652    pub fn into_open_service_directory(self) -> Option<(TestHarnessOpenServiceDirectoryResponder)> {
653        if let TestHarnessRequest::OpenServiceDirectory { responder } = self {
654            Some((responder))
655        } else {
656            None
657        }
658    }
659
660    /// Name of the method defined in FIDL
661    pub fn method_name(&self) -> &'static str {
662        match *self {
663            TestHarnessRequest::GetConfig { .. } => "get_config",
664            TestHarnessRequest::CreateDirectory { .. } => "create_directory",
665            TestHarnessRequest::OpenServiceDirectory { .. } => "open_service_directory",
666        }
667    }
668}
669
670#[derive(Debug, Clone)]
671pub struct TestHarnessControlHandle {
672    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
673}
674
675impl fidl::endpoints::ControlHandle for TestHarnessControlHandle {
676    fn shutdown(&self) {
677        self.inner.shutdown()
678    }
679    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
680        self.inner.shutdown_with_epitaph(status)
681    }
682
683    fn is_closed(&self) -> bool {
684        self.inner.channel().is_closed()
685    }
686    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
687        self.inner.channel().on_closed()
688    }
689
690    #[cfg(target_os = "fuchsia")]
691    fn signal_peer(
692        &self,
693        clear_mask: zx::Signals,
694        set_mask: zx::Signals,
695    ) -> Result<(), zx_status::Status> {
696        use fidl::Peered;
697        self.inner.channel().signal_peer(clear_mask, set_mask)
698    }
699}
700
701impl TestHarnessControlHandle {}
702
703#[must_use = "FIDL methods require a response to be sent"]
704#[derive(Debug)]
705pub struct TestHarnessGetConfigResponder {
706    control_handle: std::mem::ManuallyDrop<TestHarnessControlHandle>,
707    tx_id: u32,
708}
709
710/// Set the the channel to be shutdown (see [`TestHarnessControlHandle::shutdown`])
711/// if the responder is dropped without sending a response, so that the client
712/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
713impl std::ops::Drop for TestHarnessGetConfigResponder {
714    fn drop(&mut self) {
715        self.control_handle.shutdown();
716        // Safety: drops once, never accessed again
717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
718    }
719}
720
721impl fidl::endpoints::Responder for TestHarnessGetConfigResponder {
722    type ControlHandle = TestHarnessControlHandle;
723
724    fn control_handle(&self) -> &TestHarnessControlHandle {
725        &self.control_handle
726    }
727
728    fn drop_without_shutdown(mut self) {
729        // Safety: drops once, never accessed again due to mem::forget
730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
731        // Prevent Drop from running (which would shut down the channel)
732        std::mem::forget(self);
733    }
734}
735
736impl TestHarnessGetConfigResponder {
737    /// Sends a response to the FIDL transaction.
738    ///
739    /// Sets the channel to shutdown if an error occurs.
740    pub fn send(self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
741        let _result = self.send_raw(config);
742        if _result.is_err() {
743            self.control_handle.shutdown();
744        }
745        self.drop_without_shutdown();
746        _result
747    }
748
749    /// Similar to "send" but does not shutdown the channel if an error occurs.
750    pub fn send_no_shutdown_on_err(self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
751        let _result = self.send_raw(config);
752        self.drop_without_shutdown();
753        _result
754    }
755
756    fn send_raw(&self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
757        self.control_handle.inner.send::<TestHarnessGetConfigResponse>(
758            (config,),
759            self.tx_id,
760            0x758882a165dbaa23,
761            fidl::encoding::DynamicFlags::empty(),
762        )
763    }
764}
765
766#[must_use = "FIDL methods require a response to be sent"]
767#[derive(Debug)]
768pub struct TestHarnessOpenServiceDirectoryResponder {
769    control_handle: std::mem::ManuallyDrop<TestHarnessControlHandle>,
770    tx_id: u32,
771}
772
773/// Set the the channel to be shutdown (see [`TestHarnessControlHandle::shutdown`])
774/// if the responder is dropped without sending a response, so that the client
775/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
776impl std::ops::Drop for TestHarnessOpenServiceDirectoryResponder {
777    fn drop(&mut self) {
778        self.control_handle.shutdown();
779        // Safety: drops once, never accessed again
780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
781    }
782}
783
784impl fidl::endpoints::Responder for TestHarnessOpenServiceDirectoryResponder {
785    type ControlHandle = TestHarnessControlHandle;
786
787    fn control_handle(&self) -> &TestHarnessControlHandle {
788        &self.control_handle
789    }
790
791    fn drop_without_shutdown(mut self) {
792        // Safety: drops once, never accessed again due to mem::forget
793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
794        // Prevent Drop from running (which would shut down the channel)
795        std::mem::forget(self);
796    }
797}
798
799impl TestHarnessOpenServiceDirectoryResponder {
800    /// Sends a response to the FIDL transaction.
801    ///
802    /// Sets the channel to shutdown if an error occurs.
803    pub fn send(
804        self,
805        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
806    ) -> Result<(), fidl::Error> {
807        let _result = self.send_raw(object_request);
808        if _result.is_err() {
809            self.control_handle.shutdown();
810        }
811        self.drop_without_shutdown();
812        _result
813    }
814
815    /// Similar to "send" but does not shutdown the channel if an error occurs.
816    pub fn send_no_shutdown_on_err(
817        self,
818        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
819    ) -> Result<(), fidl::Error> {
820        let _result = self.send_raw(object_request);
821        self.drop_without_shutdown();
822        _result
823    }
824
825    fn send_raw(
826        &self,
827        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
828    ) -> Result<(), fidl::Error> {
829        self.control_handle.inner.send::<TestHarnessOpenServiceDirectoryResponse>(
830            (object_request,),
831            self.tx_id,
832            0x42904fe08b12ef88,
833            fidl::encoding::DynamicFlags::empty(),
834        )
835    }
836}
837
838mod internal {
839    use super::*;
840
841    impl fidl::encoding::ResourceTypeMarker for Directory {
842        type Borrowed<'a> = &'a mut Self;
843        fn take_or_borrow<'a>(
844            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
845        ) -> Self::Borrowed<'a> {
846            value
847        }
848    }
849
850    unsafe impl fidl::encoding::TypeMarker for Directory {
851        type Owned = Self;
852
853        #[inline(always)]
854        fn inline_align(_context: fidl::encoding::Context) -> usize {
855            8
856        }
857
858        #[inline(always)]
859        fn inline_size(_context: fidl::encoding::Context) -> usize {
860            32
861        }
862    }
863
864    unsafe impl fidl::encoding::Encode<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>
865        for &mut Directory
866    {
867        #[inline]
868        unsafe fn encode(
869            self,
870            encoder: &mut fidl::encoding::Encoder<
871                '_,
872                fidl::encoding::DefaultFuchsiaResourceDialect,
873            >,
874            offset: usize,
875            _depth: fidl::encoding::Depth,
876        ) -> fidl::Result<()> {
877            encoder.debug_check_bounds::<Directory>(offset);
878            // Delegate to tuple encoding.
879            fidl::encoding::Encode::<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
880                (
881                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
882                    <fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.entries),
883                ),
884                encoder, offset, _depth
885            )
886        }
887    }
888    unsafe impl<
889            T0: fidl::encoding::Encode<
890                fidl::encoding::BoundedString<255>,
891                fidl::encoding::DefaultFuchsiaResourceDialect,
892            >,
893            T1: fidl::encoding::Encode<
894                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
895                fidl::encoding::DefaultFuchsiaResourceDialect,
896            >,
897        > fidl::encoding::Encode<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>
898        for (T0, T1)
899    {
900        #[inline]
901        unsafe fn encode(
902            self,
903            encoder: &mut fidl::encoding::Encoder<
904                '_,
905                fidl::encoding::DefaultFuchsiaResourceDialect,
906            >,
907            offset: usize,
908            depth: fidl::encoding::Depth,
909        ) -> fidl::Result<()> {
910            encoder.debug_check_bounds::<Directory>(offset);
911            // Zero out padding regions. There's no need to apply masks
912            // because the unmasked parts will be overwritten by fields.
913            // Write the fields.
914            self.0.encode(encoder, offset + 0, depth)?;
915            self.1.encode(encoder, offset + 16, depth)?;
916            Ok(())
917        }
918    }
919
920    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Directory {
921        #[inline(always)]
922        fn new_empty() -> Self {
923            Self {
924                name: fidl::new_empty!(
925                    fidl::encoding::BoundedString<255>,
926                    fidl::encoding::DefaultFuchsiaResourceDialect
927                ),
928                entries: fidl::new_empty!(
929                    fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
930                    fidl::encoding::DefaultFuchsiaResourceDialect
931                ),
932            }
933        }
934
935        #[inline]
936        unsafe fn decode(
937            &mut self,
938            decoder: &mut fidl::encoding::Decoder<
939                '_,
940                fidl::encoding::DefaultFuchsiaResourceDialect,
941            >,
942            offset: usize,
943            _depth: fidl::encoding::Depth,
944        ) -> fidl::Result<()> {
945            decoder.debug_check_bounds::<Self>(offset);
946            // Verify that padding bytes are zero.
947            fidl::decode!(
948                fidl::encoding::BoundedString<255>,
949                fidl::encoding::DefaultFuchsiaResourceDialect,
950                &mut self.name,
951                decoder,
952                offset + 0,
953                _depth
954            )?;
955            fidl::decode!(
956                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
957                fidl::encoding::DefaultFuchsiaResourceDialect,
958                &mut self.entries,
959                decoder,
960                offset + 16,
961                _depth
962            )?;
963            Ok(())
964        }
965    }
966
967    impl fidl::encoding::ValueTypeMarker for ExecutableFile {
968        type Borrowed<'a> = &'a Self;
969        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
970            value
971        }
972    }
973
974    unsafe impl fidl::encoding::TypeMarker for ExecutableFile {
975        type Owned = Self;
976
977        #[inline(always)]
978        fn inline_align(_context: fidl::encoding::Context) -> usize {
979            8
980        }
981
982        #[inline(always)]
983        fn inline_size(_context: fidl::encoding::Context) -> usize {
984            16
985        }
986    }
987
988    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ExecutableFile, D>
989        for &ExecutableFile
990    {
991        #[inline]
992        unsafe fn encode(
993            self,
994            encoder: &mut fidl::encoding::Encoder<'_, D>,
995            offset: usize,
996            _depth: fidl::encoding::Depth,
997        ) -> fidl::Result<()> {
998            encoder.debug_check_bounds::<ExecutableFile>(offset);
999            // Delegate to tuple encoding.
1000            fidl::encoding::Encode::<ExecutableFile, D>::encode(
1001                (<fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1002                    &self.name,
1003                ),),
1004                encoder,
1005                offset,
1006                _depth,
1007            )
1008        }
1009    }
1010    unsafe impl<
1011            D: fidl::encoding::ResourceDialect,
1012            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<255>, D>,
1013        > fidl::encoding::Encode<ExecutableFile, D> for (T0,)
1014    {
1015        #[inline]
1016        unsafe fn encode(
1017            self,
1018            encoder: &mut fidl::encoding::Encoder<'_, D>,
1019            offset: usize,
1020            depth: fidl::encoding::Depth,
1021        ) -> fidl::Result<()> {
1022            encoder.debug_check_bounds::<ExecutableFile>(offset);
1023            // Zero out padding regions. There's no need to apply masks
1024            // because the unmasked parts will be overwritten by fields.
1025            // Write the fields.
1026            self.0.encode(encoder, offset + 0, depth)?;
1027            Ok(())
1028        }
1029    }
1030
1031    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ExecutableFile {
1032        #[inline(always)]
1033        fn new_empty() -> Self {
1034            Self { name: fidl::new_empty!(fidl::encoding::BoundedString<255>, D) }
1035        }
1036
1037        #[inline]
1038        unsafe fn decode(
1039            &mut self,
1040            decoder: &mut fidl::encoding::Decoder<'_, D>,
1041            offset: usize,
1042            _depth: fidl::encoding::Depth,
1043        ) -> fidl::Result<()> {
1044            decoder.debug_check_bounds::<Self>(offset);
1045            // Verify that padding bytes are zero.
1046            fidl::decode!(
1047                fidl::encoding::BoundedString<255>,
1048                D,
1049                &mut self.name,
1050                decoder,
1051                offset + 0,
1052                _depth
1053            )?;
1054            Ok(())
1055        }
1056    }
1057
1058    impl fidl::encoding::ValueTypeMarker for File {
1059        type Borrowed<'a> = &'a Self;
1060        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1061            value
1062        }
1063    }
1064
1065    unsafe impl fidl::encoding::TypeMarker for File {
1066        type Owned = Self;
1067
1068        #[inline(always)]
1069        fn inline_align(_context: fidl::encoding::Context) -> usize {
1070            8
1071        }
1072
1073        #[inline(always)]
1074        fn inline_size(_context: fidl::encoding::Context) -> usize {
1075            32
1076        }
1077    }
1078
1079    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<File, D> for &File {
1080        #[inline]
1081        unsafe fn encode(
1082            self,
1083            encoder: &mut fidl::encoding::Encoder<'_, D>,
1084            offset: usize,
1085            _depth: fidl::encoding::Depth,
1086        ) -> fidl::Result<()> {
1087            encoder.debug_check_bounds::<File>(offset);
1088            // Delegate to tuple encoding.
1089            fidl::encoding::Encode::<File, D>::encode(
1090                (
1091                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
1092                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.contents),
1093                ),
1094                encoder, offset, _depth
1095            )
1096        }
1097    }
1098    unsafe impl<
1099            D: fidl::encoding::ResourceDialect,
1100            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<255>, D>,
1101            T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
1102        > fidl::encoding::Encode<File, D> for (T0, T1)
1103    {
1104        #[inline]
1105        unsafe fn encode(
1106            self,
1107            encoder: &mut fidl::encoding::Encoder<'_, D>,
1108            offset: usize,
1109            depth: fidl::encoding::Depth,
1110        ) -> fidl::Result<()> {
1111            encoder.debug_check_bounds::<File>(offset);
1112            // Zero out padding regions. There's no need to apply masks
1113            // because the unmasked parts will be overwritten by fields.
1114            // Write the fields.
1115            self.0.encode(encoder, offset + 0, depth)?;
1116            self.1.encode(encoder, offset + 16, depth)?;
1117            Ok(())
1118        }
1119    }
1120
1121    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for File {
1122        #[inline(always)]
1123        fn new_empty() -> Self {
1124            Self {
1125                name: fidl::new_empty!(fidl::encoding::BoundedString<255>, D),
1126                contents: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
1127            }
1128        }
1129
1130        #[inline]
1131        unsafe fn decode(
1132            &mut self,
1133            decoder: &mut fidl::encoding::Decoder<'_, D>,
1134            offset: usize,
1135            _depth: fidl::encoding::Depth,
1136        ) -> fidl::Result<()> {
1137            decoder.debug_check_bounds::<Self>(offset);
1138            // Verify that padding bytes are zero.
1139            fidl::decode!(
1140                fidl::encoding::BoundedString<255>,
1141                D,
1142                &mut self.name,
1143                decoder,
1144                offset + 0,
1145                _depth
1146            )?;
1147            fidl::decode!(
1148                fidl::encoding::UnboundedVector<u8>,
1149                D,
1150                &mut self.contents,
1151                decoder,
1152                offset + 16,
1153                _depth
1154            )?;
1155            Ok(())
1156        }
1157    }
1158
1159    impl fidl::encoding::ValueTypeMarker for HarnessConfig {
1160        type Borrowed<'a> = &'a Self;
1161        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1162            value
1163        }
1164    }
1165
1166    unsafe impl fidl::encoding::TypeMarker for HarnessConfig {
1167        type Owned = Self;
1168
1169        #[inline(always)]
1170        fn inline_align(_context: fidl::encoding::Context) -> usize {
1171            8
1172        }
1173
1174        #[inline(always)]
1175        fn inline_size(_context: fidl::encoding::Context) -> usize {
1176            24
1177        }
1178    }
1179
1180    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<HarnessConfig, D>
1181        for &HarnessConfig
1182    {
1183        #[inline]
1184        unsafe fn encode(
1185            self,
1186            encoder: &mut fidl::encoding::Encoder<'_, D>,
1187            offset: usize,
1188            _depth: fidl::encoding::Depth,
1189        ) -> fidl::Result<()> {
1190            encoder.debug_check_bounds::<HarnessConfig>(offset);
1191            // Delegate to tuple encoding.
1192            fidl::encoding::Encode::<HarnessConfig, D>::encode(
1193                (
1194                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_executable_file),
1195                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_mutable_file),
1196                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_get_backing_memory),
1197                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_remote_dir),
1198                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_get_token),
1199                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_link_into),
1200                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_append),
1201                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_truncate),
1202                    <fidl_fuchsia_io::NodeAttributesQuery as fidl::encoding::ValueTypeMarker>::borrow(&self.supported_attributes),
1203                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_modify_directory),
1204                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_services),
1205                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.supports_unnamed_temporary_file),
1206                ),
1207                encoder, offset, _depth
1208            )
1209        }
1210    }
1211    unsafe impl<
1212            D: fidl::encoding::ResourceDialect,
1213            T0: fidl::encoding::Encode<bool, D>,
1214            T1: fidl::encoding::Encode<bool, D>,
1215            T2: fidl::encoding::Encode<bool, D>,
1216            T3: fidl::encoding::Encode<bool, D>,
1217            T4: fidl::encoding::Encode<bool, D>,
1218            T5: fidl::encoding::Encode<bool, D>,
1219            T6: fidl::encoding::Encode<bool, D>,
1220            T7: fidl::encoding::Encode<bool, D>,
1221            T8: fidl::encoding::Encode<fidl_fuchsia_io::NodeAttributesQuery, D>,
1222            T9: fidl::encoding::Encode<bool, D>,
1223            T10: fidl::encoding::Encode<bool, D>,
1224            T11: fidl::encoding::Encode<bool, D>,
1225        > fidl::encoding::Encode<HarnessConfig, D>
1226        for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
1227    {
1228        #[inline]
1229        unsafe fn encode(
1230            self,
1231            encoder: &mut fidl::encoding::Encoder<'_, D>,
1232            offset: usize,
1233            depth: fidl::encoding::Depth,
1234        ) -> fidl::Result<()> {
1235            encoder.debug_check_bounds::<HarnessConfig>(offset);
1236            // Zero out padding regions. There's no need to apply masks
1237            // because the unmasked parts will be overwritten by fields.
1238            unsafe {
1239                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1240                (ptr as *mut u64).write_unaligned(0);
1241            }
1242            // Write the fields.
1243            self.0.encode(encoder, offset + 0, depth)?;
1244            self.1.encode(encoder, offset + 1, depth)?;
1245            self.2.encode(encoder, offset + 2, depth)?;
1246            self.3.encode(encoder, offset + 3, depth)?;
1247            self.4.encode(encoder, offset + 4, depth)?;
1248            self.5.encode(encoder, offset + 5, depth)?;
1249            self.6.encode(encoder, offset + 6, depth)?;
1250            self.7.encode(encoder, offset + 7, depth)?;
1251            self.8.encode(encoder, offset + 8, depth)?;
1252            self.9.encode(encoder, offset + 16, depth)?;
1253            self.10.encode(encoder, offset + 17, depth)?;
1254            self.11.encode(encoder, offset + 18, depth)?;
1255            Ok(())
1256        }
1257    }
1258
1259    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HarnessConfig {
1260        #[inline(always)]
1261        fn new_empty() -> Self {
1262            Self {
1263                supports_executable_file: fidl::new_empty!(bool, D),
1264                supports_mutable_file: fidl::new_empty!(bool, D),
1265                supports_get_backing_memory: fidl::new_empty!(bool, D),
1266                supports_remote_dir: fidl::new_empty!(bool, D),
1267                supports_get_token: fidl::new_empty!(bool, D),
1268                supports_link_into: fidl::new_empty!(bool, D),
1269                supports_append: fidl::new_empty!(bool, D),
1270                supports_truncate: fidl::new_empty!(bool, D),
1271                supported_attributes: fidl::new_empty!(fidl_fuchsia_io::NodeAttributesQuery, D),
1272                supports_modify_directory: fidl::new_empty!(bool, D),
1273                supports_services: fidl::new_empty!(bool, D),
1274                supports_unnamed_temporary_file: fidl::new_empty!(bool, D),
1275            }
1276        }
1277
1278        #[inline]
1279        unsafe fn decode(
1280            &mut self,
1281            decoder: &mut fidl::encoding::Decoder<'_, D>,
1282            offset: usize,
1283            _depth: fidl::encoding::Depth,
1284        ) -> fidl::Result<()> {
1285            decoder.debug_check_bounds::<Self>(offset);
1286            // Verify that padding bytes are zero.
1287            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1288            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1289            let mask = 0xffffffffff000000u64;
1290            let maskedval = padval & mask;
1291            if maskedval != 0 {
1292                return Err(fidl::Error::NonZeroPadding {
1293                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1294                });
1295            }
1296            fidl::decode!(
1297                bool,
1298                D,
1299                &mut self.supports_executable_file,
1300                decoder,
1301                offset + 0,
1302                _depth
1303            )?;
1304            fidl::decode!(bool, D, &mut self.supports_mutable_file, decoder, offset + 1, _depth)?;
1305            fidl::decode!(
1306                bool,
1307                D,
1308                &mut self.supports_get_backing_memory,
1309                decoder,
1310                offset + 2,
1311                _depth
1312            )?;
1313            fidl::decode!(bool, D, &mut self.supports_remote_dir, decoder, offset + 3, _depth)?;
1314            fidl::decode!(bool, D, &mut self.supports_get_token, decoder, offset + 4, _depth)?;
1315            fidl::decode!(bool, D, &mut self.supports_link_into, decoder, offset + 5, _depth)?;
1316            fidl::decode!(bool, D, &mut self.supports_append, decoder, offset + 6, _depth)?;
1317            fidl::decode!(bool, D, &mut self.supports_truncate, decoder, offset + 7, _depth)?;
1318            fidl::decode!(
1319                fidl_fuchsia_io::NodeAttributesQuery,
1320                D,
1321                &mut self.supported_attributes,
1322                decoder,
1323                offset + 8,
1324                _depth
1325            )?;
1326            fidl::decode!(
1327                bool,
1328                D,
1329                &mut self.supports_modify_directory,
1330                decoder,
1331                offset + 16,
1332                _depth
1333            )?;
1334            fidl::decode!(bool, D, &mut self.supports_services, decoder, offset + 17, _depth)?;
1335            fidl::decode!(
1336                bool,
1337                D,
1338                &mut self.supports_unnamed_temporary_file,
1339                decoder,
1340                offset + 18,
1341                _depth
1342            )?;
1343            Ok(())
1344        }
1345    }
1346
1347    impl fidl::encoding::ResourceTypeMarker for RemoteDirectory {
1348        type Borrowed<'a> = &'a mut Self;
1349        fn take_or_borrow<'a>(
1350            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1351        ) -> Self::Borrowed<'a> {
1352            value
1353        }
1354    }
1355
1356    unsafe impl fidl::encoding::TypeMarker for RemoteDirectory {
1357        type Owned = Self;
1358
1359        #[inline(always)]
1360        fn inline_align(_context: fidl::encoding::Context) -> usize {
1361            8
1362        }
1363
1364        #[inline(always)]
1365        fn inline_size(_context: fidl::encoding::Context) -> usize {
1366            24
1367        }
1368    }
1369
1370    unsafe impl
1371        fidl::encoding::Encode<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>
1372        for &mut RemoteDirectory
1373    {
1374        #[inline]
1375        unsafe fn encode(
1376            self,
1377            encoder: &mut fidl::encoding::Encoder<
1378                '_,
1379                fidl::encoding::DefaultFuchsiaResourceDialect,
1380            >,
1381            offset: usize,
1382            _depth: fidl::encoding::Depth,
1383        ) -> fidl::Result<()> {
1384            encoder.debug_check_bounds::<RemoteDirectory>(offset);
1385            // Delegate to tuple encoding.
1386            fidl::encoding::Encode::<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1387                (
1388                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
1389                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.remote_client),
1390                ),
1391                encoder, offset, _depth
1392            )
1393        }
1394    }
1395    unsafe impl<
1396            T0: fidl::encoding::Encode<
1397                fidl::encoding::BoundedString<255>,
1398                fidl::encoding::DefaultFuchsiaResourceDialect,
1399            >,
1400            T1: fidl::encoding::Encode<
1401                fidl::encoding::Endpoint<
1402                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1403                >,
1404                fidl::encoding::DefaultFuchsiaResourceDialect,
1405            >,
1406        > fidl::encoding::Encode<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>
1407        for (T0, T1)
1408    {
1409        #[inline]
1410        unsafe fn encode(
1411            self,
1412            encoder: &mut fidl::encoding::Encoder<
1413                '_,
1414                fidl::encoding::DefaultFuchsiaResourceDialect,
1415            >,
1416            offset: usize,
1417            depth: fidl::encoding::Depth,
1418        ) -> fidl::Result<()> {
1419            encoder.debug_check_bounds::<RemoteDirectory>(offset);
1420            // Zero out padding regions. There's no need to apply masks
1421            // because the unmasked parts will be overwritten by fields.
1422            unsafe {
1423                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1424                (ptr as *mut u64).write_unaligned(0);
1425            }
1426            // Write the fields.
1427            self.0.encode(encoder, offset + 0, depth)?;
1428            self.1.encode(encoder, offset + 16, depth)?;
1429            Ok(())
1430        }
1431    }
1432
1433    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1434        for RemoteDirectory
1435    {
1436        #[inline(always)]
1437        fn new_empty() -> Self {
1438            Self {
1439                name: fidl::new_empty!(
1440                    fidl::encoding::BoundedString<255>,
1441                    fidl::encoding::DefaultFuchsiaResourceDialect
1442                ),
1443                remote_client: fidl::new_empty!(
1444                    fidl::encoding::Endpoint<
1445                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1446                    >,
1447                    fidl::encoding::DefaultFuchsiaResourceDialect
1448                ),
1449            }
1450        }
1451
1452        #[inline]
1453        unsafe fn decode(
1454            &mut self,
1455            decoder: &mut fidl::encoding::Decoder<
1456                '_,
1457                fidl::encoding::DefaultFuchsiaResourceDialect,
1458            >,
1459            offset: usize,
1460            _depth: fidl::encoding::Depth,
1461        ) -> fidl::Result<()> {
1462            decoder.debug_check_bounds::<Self>(offset);
1463            // Verify that padding bytes are zero.
1464            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1465            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1466            let mask = 0xffffffff00000000u64;
1467            let maskedval = padval & mask;
1468            if maskedval != 0 {
1469                return Err(fidl::Error::NonZeroPadding {
1470                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1471                });
1472            }
1473            fidl::decode!(
1474                fidl::encoding::BoundedString<255>,
1475                fidl::encoding::DefaultFuchsiaResourceDialect,
1476                &mut self.name,
1477                decoder,
1478                offset + 0,
1479                _depth
1480            )?;
1481            fidl::decode!(
1482                fidl::encoding::Endpoint<
1483                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1484                >,
1485                fidl::encoding::DefaultFuchsiaResourceDialect,
1486                &mut self.remote_client,
1487                decoder,
1488                offset + 16,
1489                _depth
1490            )?;
1491            Ok(())
1492        }
1493    }
1494
1495    impl fidl::encoding::ResourceTypeMarker for TestHarnessCreateDirectoryRequest {
1496        type Borrowed<'a> = &'a mut Self;
1497        fn take_or_borrow<'a>(
1498            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1499        ) -> Self::Borrowed<'a> {
1500            value
1501        }
1502    }
1503
1504    unsafe impl fidl::encoding::TypeMarker for TestHarnessCreateDirectoryRequest {
1505        type Owned = Self;
1506
1507        #[inline(always)]
1508        fn inline_align(_context: fidl::encoding::Context) -> usize {
1509            8
1510        }
1511
1512        #[inline(always)]
1513        fn inline_size(_context: fidl::encoding::Context) -> usize {
1514            32
1515        }
1516    }
1517
1518    unsafe impl
1519        fidl::encoding::Encode<
1520            TestHarnessCreateDirectoryRequest,
1521            fidl::encoding::DefaultFuchsiaResourceDialect,
1522        > for &mut TestHarnessCreateDirectoryRequest
1523    {
1524        #[inline]
1525        unsafe fn encode(
1526            self,
1527            encoder: &mut fidl::encoding::Encoder<
1528                '_,
1529                fidl::encoding::DefaultFuchsiaResourceDialect,
1530            >,
1531            offset: usize,
1532            _depth: fidl::encoding::Depth,
1533        ) -> fidl::Result<()> {
1534            encoder.debug_check_bounds::<TestHarnessCreateDirectoryRequest>(offset);
1535            // Delegate to tuple encoding.
1536            fidl::encoding::Encode::<TestHarnessCreateDirectoryRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1537                (
1538                    <fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.contents),
1539                    <fidl_fuchsia_io::Flags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1540                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.object_request),
1541                ),
1542                encoder, offset, _depth
1543            )
1544        }
1545    }
1546    unsafe impl<
1547            T0: fidl::encoding::Encode<
1548                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1549                fidl::encoding::DefaultFuchsiaResourceDialect,
1550            >,
1551            T1: fidl::encoding::Encode<
1552                fidl_fuchsia_io::Flags,
1553                fidl::encoding::DefaultFuchsiaResourceDialect,
1554            >,
1555            T2: fidl::encoding::Encode<
1556                fidl::encoding::Endpoint<
1557                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1558                >,
1559                fidl::encoding::DefaultFuchsiaResourceDialect,
1560            >,
1561        >
1562        fidl::encoding::Encode<
1563            TestHarnessCreateDirectoryRequest,
1564            fidl::encoding::DefaultFuchsiaResourceDialect,
1565        > for (T0, T1, T2)
1566    {
1567        #[inline]
1568        unsafe fn encode(
1569            self,
1570            encoder: &mut fidl::encoding::Encoder<
1571                '_,
1572                fidl::encoding::DefaultFuchsiaResourceDialect,
1573            >,
1574            offset: usize,
1575            depth: fidl::encoding::Depth,
1576        ) -> fidl::Result<()> {
1577            encoder.debug_check_bounds::<TestHarnessCreateDirectoryRequest>(offset);
1578            // Zero out padding regions. There's no need to apply masks
1579            // because the unmasked parts will be overwritten by fields.
1580            unsafe {
1581                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1582                (ptr as *mut u64).write_unaligned(0);
1583            }
1584            // Write the fields.
1585            self.0.encode(encoder, offset + 0, depth)?;
1586            self.1.encode(encoder, offset + 16, depth)?;
1587            self.2.encode(encoder, offset + 24, depth)?;
1588            Ok(())
1589        }
1590    }
1591
1592    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1593        for TestHarnessCreateDirectoryRequest
1594    {
1595        #[inline(always)]
1596        fn new_empty() -> Self {
1597            Self {
1598                contents: fidl::new_empty!(
1599                    fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1600                    fidl::encoding::DefaultFuchsiaResourceDialect
1601                ),
1602                flags: fidl::new_empty!(
1603                    fidl_fuchsia_io::Flags,
1604                    fidl::encoding::DefaultFuchsiaResourceDialect
1605                ),
1606                object_request: fidl::new_empty!(
1607                    fidl::encoding::Endpoint<
1608                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1609                    >,
1610                    fidl::encoding::DefaultFuchsiaResourceDialect
1611                ),
1612            }
1613        }
1614
1615        #[inline]
1616        unsafe fn decode(
1617            &mut self,
1618            decoder: &mut fidl::encoding::Decoder<
1619                '_,
1620                fidl::encoding::DefaultFuchsiaResourceDialect,
1621            >,
1622            offset: usize,
1623            _depth: fidl::encoding::Depth,
1624        ) -> fidl::Result<()> {
1625            decoder.debug_check_bounds::<Self>(offset);
1626            // Verify that padding bytes are zero.
1627            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1628            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1629            let mask = 0xffffffff00000000u64;
1630            let maskedval = padval & mask;
1631            if maskedval != 0 {
1632                return Err(fidl::Error::NonZeroPadding {
1633                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1634                });
1635            }
1636            fidl::decode!(
1637                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1638                fidl::encoding::DefaultFuchsiaResourceDialect,
1639                &mut self.contents,
1640                decoder,
1641                offset + 0,
1642                _depth
1643            )?;
1644            fidl::decode!(
1645                fidl_fuchsia_io::Flags,
1646                fidl::encoding::DefaultFuchsiaResourceDialect,
1647                &mut self.flags,
1648                decoder,
1649                offset + 16,
1650                _depth
1651            )?;
1652            fidl::decode!(
1653                fidl::encoding::Endpoint<
1654                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1655                >,
1656                fidl::encoding::DefaultFuchsiaResourceDialect,
1657                &mut self.object_request,
1658                decoder,
1659                offset + 24,
1660                _depth
1661            )?;
1662            Ok(())
1663        }
1664    }
1665
1666    impl fidl::encoding::ValueTypeMarker for TestHarnessGetConfigResponse {
1667        type Borrowed<'a> = &'a Self;
1668        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1669            value
1670        }
1671    }
1672
1673    unsafe impl fidl::encoding::TypeMarker for TestHarnessGetConfigResponse {
1674        type Owned = Self;
1675
1676        #[inline(always)]
1677        fn inline_align(_context: fidl::encoding::Context) -> usize {
1678            8
1679        }
1680
1681        #[inline(always)]
1682        fn inline_size(_context: fidl::encoding::Context) -> usize {
1683            24
1684        }
1685    }
1686
1687    unsafe impl<D: fidl::encoding::ResourceDialect>
1688        fidl::encoding::Encode<TestHarnessGetConfigResponse, D> for &TestHarnessGetConfigResponse
1689    {
1690        #[inline]
1691        unsafe fn encode(
1692            self,
1693            encoder: &mut fidl::encoding::Encoder<'_, D>,
1694            offset: usize,
1695            _depth: fidl::encoding::Depth,
1696        ) -> fidl::Result<()> {
1697            encoder.debug_check_bounds::<TestHarnessGetConfigResponse>(offset);
1698            // Delegate to tuple encoding.
1699            fidl::encoding::Encode::<TestHarnessGetConfigResponse, D>::encode(
1700                (<HarnessConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),),
1701                encoder,
1702                offset,
1703                _depth,
1704            )
1705        }
1706    }
1707    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<HarnessConfig, D>>
1708        fidl::encoding::Encode<TestHarnessGetConfigResponse, D> for (T0,)
1709    {
1710        #[inline]
1711        unsafe fn encode(
1712            self,
1713            encoder: &mut fidl::encoding::Encoder<'_, D>,
1714            offset: usize,
1715            depth: fidl::encoding::Depth,
1716        ) -> fidl::Result<()> {
1717            encoder.debug_check_bounds::<TestHarnessGetConfigResponse>(offset);
1718            // Zero out padding regions. There's no need to apply masks
1719            // because the unmasked parts will be overwritten by fields.
1720            // Write the fields.
1721            self.0.encode(encoder, offset + 0, depth)?;
1722            Ok(())
1723        }
1724    }
1725
1726    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1727        for TestHarnessGetConfigResponse
1728    {
1729        #[inline(always)]
1730        fn new_empty() -> Self {
1731            Self { config: fidl::new_empty!(HarnessConfig, D) }
1732        }
1733
1734        #[inline]
1735        unsafe fn decode(
1736            &mut self,
1737            decoder: &mut fidl::encoding::Decoder<'_, D>,
1738            offset: usize,
1739            _depth: fidl::encoding::Depth,
1740        ) -> fidl::Result<()> {
1741            decoder.debug_check_bounds::<Self>(offset);
1742            // Verify that padding bytes are zero.
1743            fidl::decode!(HarnessConfig, D, &mut self.config, decoder, offset + 0, _depth)?;
1744            Ok(())
1745        }
1746    }
1747
1748    impl fidl::encoding::ResourceTypeMarker for TestHarnessOpenServiceDirectoryResponse {
1749        type Borrowed<'a> = &'a mut Self;
1750        fn take_or_borrow<'a>(
1751            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1752        ) -> Self::Borrowed<'a> {
1753            value
1754        }
1755    }
1756
1757    unsafe impl fidl::encoding::TypeMarker for TestHarnessOpenServiceDirectoryResponse {
1758        type Owned = Self;
1759
1760        #[inline(always)]
1761        fn inline_align(_context: fidl::encoding::Context) -> usize {
1762            4
1763        }
1764
1765        #[inline(always)]
1766        fn inline_size(_context: fidl::encoding::Context) -> usize {
1767            4
1768        }
1769    }
1770
1771    unsafe impl
1772        fidl::encoding::Encode<
1773            TestHarnessOpenServiceDirectoryResponse,
1774            fidl::encoding::DefaultFuchsiaResourceDialect,
1775        > for &mut TestHarnessOpenServiceDirectoryResponse
1776    {
1777        #[inline]
1778        unsafe fn encode(
1779            self,
1780            encoder: &mut fidl::encoding::Encoder<
1781                '_,
1782                fidl::encoding::DefaultFuchsiaResourceDialect,
1783            >,
1784            offset: usize,
1785            _depth: fidl::encoding::Depth,
1786        ) -> fidl::Result<()> {
1787            encoder.debug_check_bounds::<TestHarnessOpenServiceDirectoryResponse>(offset);
1788            // Delegate to tuple encoding.
1789            fidl::encoding::Encode::<
1790                TestHarnessOpenServiceDirectoryResponse,
1791                fidl::encoding::DefaultFuchsiaResourceDialect,
1792            >::encode(
1793                (<fidl::encoding::Endpoint<
1794                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1795                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1796                    &mut self.object_request
1797                ),),
1798                encoder,
1799                offset,
1800                _depth,
1801            )
1802        }
1803    }
1804    unsafe impl<
1805            T0: fidl::encoding::Encode<
1806                fidl::encoding::Endpoint<
1807                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1808                >,
1809                fidl::encoding::DefaultFuchsiaResourceDialect,
1810            >,
1811        >
1812        fidl::encoding::Encode<
1813            TestHarnessOpenServiceDirectoryResponse,
1814            fidl::encoding::DefaultFuchsiaResourceDialect,
1815        > for (T0,)
1816    {
1817        #[inline]
1818        unsafe fn encode(
1819            self,
1820            encoder: &mut fidl::encoding::Encoder<
1821                '_,
1822                fidl::encoding::DefaultFuchsiaResourceDialect,
1823            >,
1824            offset: usize,
1825            depth: fidl::encoding::Depth,
1826        ) -> fidl::Result<()> {
1827            encoder.debug_check_bounds::<TestHarnessOpenServiceDirectoryResponse>(offset);
1828            // Zero out padding regions. There's no need to apply masks
1829            // because the unmasked parts will be overwritten by fields.
1830            // Write the fields.
1831            self.0.encode(encoder, offset + 0, depth)?;
1832            Ok(())
1833        }
1834    }
1835
1836    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1837        for TestHarnessOpenServiceDirectoryResponse
1838    {
1839        #[inline(always)]
1840        fn new_empty() -> Self {
1841            Self {
1842                object_request: fidl::new_empty!(
1843                    fidl::encoding::Endpoint<
1844                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1845                    >,
1846                    fidl::encoding::DefaultFuchsiaResourceDialect
1847                ),
1848            }
1849        }
1850
1851        #[inline]
1852        unsafe fn decode(
1853            &mut self,
1854            decoder: &mut fidl::encoding::Decoder<
1855                '_,
1856                fidl::encoding::DefaultFuchsiaResourceDialect,
1857            >,
1858            offset: usize,
1859            _depth: fidl::encoding::Depth,
1860        ) -> fidl::Result<()> {
1861            decoder.debug_check_bounds::<Self>(offset);
1862            // Verify that padding bytes are zero.
1863            fidl::decode!(
1864                fidl::encoding::Endpoint<
1865                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1866                >,
1867                fidl::encoding::DefaultFuchsiaResourceDialect,
1868                &mut self.object_request,
1869                decoder,
1870                offset + 0,
1871                _depth
1872            )?;
1873            Ok(())
1874        }
1875    }
1876
1877    impl fidl::encoding::ResourceTypeMarker for DirectoryEntry {
1878        type Borrowed<'a> = &'a mut Self;
1879        fn take_or_borrow<'a>(
1880            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1881        ) -> Self::Borrowed<'a> {
1882            value
1883        }
1884    }
1885
1886    unsafe impl fidl::encoding::TypeMarker for DirectoryEntry {
1887        type Owned = Self;
1888
1889        #[inline(always)]
1890        fn inline_align(_context: fidl::encoding::Context) -> usize {
1891            8
1892        }
1893
1894        #[inline(always)]
1895        fn inline_size(_context: fidl::encoding::Context) -> usize {
1896            16
1897        }
1898    }
1899
1900    unsafe impl
1901        fidl::encoding::Encode<DirectoryEntry, fidl::encoding::DefaultFuchsiaResourceDialect>
1902        for &mut DirectoryEntry
1903    {
1904        #[inline]
1905        unsafe fn encode(
1906            self,
1907            encoder: &mut fidl::encoding::Encoder<
1908                '_,
1909                fidl::encoding::DefaultFuchsiaResourceDialect,
1910            >,
1911            offset: usize,
1912            _depth: fidl::encoding::Depth,
1913        ) -> fidl::Result<()> {
1914            encoder.debug_check_bounds::<DirectoryEntry>(offset);
1915            encoder.write_num::<u64>(self.ordinal(), offset);
1916            match self {
1917                DirectoryEntry::Directory(ref mut val) => fidl::encoding::encode_in_envelope::<
1918                    Directory,
1919                    fidl::encoding::DefaultFuchsiaResourceDialect,
1920                >(
1921                    <Directory as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1922                    encoder,
1923                    offset + 8,
1924                    _depth,
1925                ),
1926                DirectoryEntry::RemoteDirectory(ref mut val) => {
1927                    fidl::encoding::encode_in_envelope::<
1928                        RemoteDirectory,
1929                        fidl::encoding::DefaultFuchsiaResourceDialect,
1930                    >(
1931                        <RemoteDirectory as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1932                            val,
1933                        ),
1934                        encoder,
1935                        offset + 8,
1936                        _depth,
1937                    )
1938                }
1939                DirectoryEntry::File(ref val) => fidl::encoding::encode_in_envelope::<
1940                    File,
1941                    fidl::encoding::DefaultFuchsiaResourceDialect,
1942                >(
1943                    <File as fidl::encoding::ValueTypeMarker>::borrow(val),
1944                    encoder,
1945                    offset + 8,
1946                    _depth,
1947                ),
1948                DirectoryEntry::ExecutableFile(ref val) => fidl::encoding::encode_in_envelope::<
1949                    ExecutableFile,
1950                    fidl::encoding::DefaultFuchsiaResourceDialect,
1951                >(
1952                    <ExecutableFile as fidl::encoding::ValueTypeMarker>::borrow(val),
1953                    encoder,
1954                    offset + 8,
1955                    _depth,
1956                ),
1957            }
1958        }
1959    }
1960
1961    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1962        for DirectoryEntry
1963    {
1964        #[inline(always)]
1965        fn new_empty() -> Self {
1966            Self::Directory(fidl::new_empty!(
1967                Directory,
1968                fidl::encoding::DefaultFuchsiaResourceDialect
1969            ))
1970        }
1971
1972        #[inline]
1973        unsafe fn decode(
1974            &mut self,
1975            decoder: &mut fidl::encoding::Decoder<
1976                '_,
1977                fidl::encoding::DefaultFuchsiaResourceDialect,
1978            >,
1979            offset: usize,
1980            mut depth: fidl::encoding::Depth,
1981        ) -> fidl::Result<()> {
1982            decoder.debug_check_bounds::<Self>(offset);
1983            #[allow(unused_variables)]
1984            let next_out_of_line = decoder.next_out_of_line();
1985            let handles_before = decoder.remaining_handles();
1986            let (ordinal, inlined, num_bytes, num_handles) =
1987                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1988
1989            let member_inline_size = match ordinal {
1990                1 => <Directory as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1991                2 => <RemoteDirectory as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1992                3 => <File as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1993                5 => <ExecutableFile as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1994                _ => return Err(fidl::Error::UnknownUnionTag),
1995            };
1996
1997            if inlined != (member_inline_size <= 4) {
1998                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1999            }
2000            let _inner_offset;
2001            if inlined {
2002                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2003                _inner_offset = offset + 8;
2004            } else {
2005                depth.increment()?;
2006                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2007            }
2008            match ordinal {
2009                1 => {
2010                    #[allow(irrefutable_let_patterns)]
2011                    if let DirectoryEntry::Directory(_) = self {
2012                        // Do nothing, read the value into the object
2013                    } else {
2014                        // Initialize `self` to the right variant
2015                        *self = DirectoryEntry::Directory(fidl::new_empty!(
2016                            Directory,
2017                            fidl::encoding::DefaultFuchsiaResourceDialect
2018                        ));
2019                    }
2020                    #[allow(irrefutable_let_patterns)]
2021                    if let DirectoryEntry::Directory(ref mut val) = self {
2022                        fidl::decode!(
2023                            Directory,
2024                            fidl::encoding::DefaultFuchsiaResourceDialect,
2025                            val,
2026                            decoder,
2027                            _inner_offset,
2028                            depth
2029                        )?;
2030                    } else {
2031                        unreachable!()
2032                    }
2033                }
2034                2 => {
2035                    #[allow(irrefutable_let_patterns)]
2036                    if let DirectoryEntry::RemoteDirectory(_) = self {
2037                        // Do nothing, read the value into the object
2038                    } else {
2039                        // Initialize `self` to the right variant
2040                        *self = DirectoryEntry::RemoteDirectory(fidl::new_empty!(
2041                            RemoteDirectory,
2042                            fidl::encoding::DefaultFuchsiaResourceDialect
2043                        ));
2044                    }
2045                    #[allow(irrefutable_let_patterns)]
2046                    if let DirectoryEntry::RemoteDirectory(ref mut val) = self {
2047                        fidl::decode!(
2048                            RemoteDirectory,
2049                            fidl::encoding::DefaultFuchsiaResourceDialect,
2050                            val,
2051                            decoder,
2052                            _inner_offset,
2053                            depth
2054                        )?;
2055                    } else {
2056                        unreachable!()
2057                    }
2058                }
2059                3 => {
2060                    #[allow(irrefutable_let_patterns)]
2061                    if let DirectoryEntry::File(_) = self {
2062                        // Do nothing, read the value into the object
2063                    } else {
2064                        // Initialize `self` to the right variant
2065                        *self = DirectoryEntry::File(fidl::new_empty!(
2066                            File,
2067                            fidl::encoding::DefaultFuchsiaResourceDialect
2068                        ));
2069                    }
2070                    #[allow(irrefutable_let_patterns)]
2071                    if let DirectoryEntry::File(ref mut val) = self {
2072                        fidl::decode!(
2073                            File,
2074                            fidl::encoding::DefaultFuchsiaResourceDialect,
2075                            val,
2076                            decoder,
2077                            _inner_offset,
2078                            depth
2079                        )?;
2080                    } else {
2081                        unreachable!()
2082                    }
2083                }
2084                5 => {
2085                    #[allow(irrefutable_let_patterns)]
2086                    if let DirectoryEntry::ExecutableFile(_) = self {
2087                        // Do nothing, read the value into the object
2088                    } else {
2089                        // Initialize `self` to the right variant
2090                        *self = DirectoryEntry::ExecutableFile(fidl::new_empty!(
2091                            ExecutableFile,
2092                            fidl::encoding::DefaultFuchsiaResourceDialect
2093                        ));
2094                    }
2095                    #[allow(irrefutable_let_patterns)]
2096                    if let DirectoryEntry::ExecutableFile(ref mut val) = self {
2097                        fidl::decode!(
2098                            ExecutableFile,
2099                            fidl::encoding::DefaultFuchsiaResourceDialect,
2100                            val,
2101                            decoder,
2102                            _inner_offset,
2103                            depth
2104                        )?;
2105                    } else {
2106                        unreachable!()
2107                    }
2108                }
2109                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2110            }
2111            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2112                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2113            }
2114            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2115                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2116            }
2117            Ok(())
2118        }
2119    }
2120}