Skip to main content

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