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