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::Handle {
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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
615        self.inner.shutdown_with_epitaph(status)
616    }
617
618    fn is_closed(&self) -> bool {
619        self.inner.channel().is_closed()
620    }
621    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
622        self.inner.channel().on_closed()
623    }
624
625    #[cfg(target_os = "fuchsia")]
626    fn signal_peer(
627        &self,
628        clear_mask: zx::Signals,
629        set_mask: zx::Signals,
630    ) -> Result<(), zx_status::Status> {
631        use fidl::Peered;
632        self.inner.channel().signal_peer(clear_mask, set_mask)
633    }
634}
635
636impl TestHarnessControlHandle {}
637
638#[must_use = "FIDL methods require a response to be sent"]
639#[derive(Debug)]
640pub struct TestHarnessGetConfigResponder {
641    control_handle: std::mem::ManuallyDrop<TestHarnessControlHandle>,
642    tx_id: u32,
643}
644
645/// Set the the channel to be shutdown (see [`TestHarnessControlHandle::shutdown`])
646/// if the responder is dropped without sending a response, so that the client
647/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
648impl std::ops::Drop for TestHarnessGetConfigResponder {
649    fn drop(&mut self) {
650        self.control_handle.shutdown();
651        // Safety: drops once, never accessed again
652        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
653    }
654}
655
656impl fidl::endpoints::Responder for TestHarnessGetConfigResponder {
657    type ControlHandle = TestHarnessControlHandle;
658
659    fn control_handle(&self) -> &TestHarnessControlHandle {
660        &self.control_handle
661    }
662
663    fn drop_without_shutdown(mut self) {
664        // Safety: drops once, never accessed again due to mem::forget
665        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
666        // Prevent Drop from running (which would shut down the channel)
667        std::mem::forget(self);
668    }
669}
670
671impl TestHarnessGetConfigResponder {
672    /// Sends a response to the FIDL transaction.
673    ///
674    /// Sets the channel to shutdown if an error occurs.
675    pub fn send(self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
676        let _result = self.send_raw(config);
677        if _result.is_err() {
678            self.control_handle.shutdown();
679        }
680        self.drop_without_shutdown();
681        _result
682    }
683
684    /// Similar to "send" but does not shutdown the channel if an error occurs.
685    pub fn send_no_shutdown_on_err(self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
686        let _result = self.send_raw(config);
687        self.drop_without_shutdown();
688        _result
689    }
690
691    fn send_raw(&self, mut config: &HarnessConfig) -> Result<(), fidl::Error> {
692        self.control_handle.inner.send::<TestHarnessGetConfigResponse>(
693            (config,),
694            self.tx_id,
695            0x758882a165dbaa23,
696            fidl::encoding::DynamicFlags::empty(),
697        )
698    }
699}
700
701#[must_use = "FIDL methods require a response to be sent"]
702#[derive(Debug)]
703pub struct TestHarnessOpenServiceDirectoryResponder {
704    control_handle: std::mem::ManuallyDrop<TestHarnessControlHandle>,
705    tx_id: u32,
706}
707
708/// Set the the channel to be shutdown (see [`TestHarnessControlHandle::shutdown`])
709/// if the responder is dropped without sending a response, so that the client
710/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
711impl std::ops::Drop for TestHarnessOpenServiceDirectoryResponder {
712    fn drop(&mut self) {
713        self.control_handle.shutdown();
714        // Safety: drops once, never accessed again
715        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
716    }
717}
718
719impl fidl::endpoints::Responder for TestHarnessOpenServiceDirectoryResponder {
720    type ControlHandle = TestHarnessControlHandle;
721
722    fn control_handle(&self) -> &TestHarnessControlHandle {
723        &self.control_handle
724    }
725
726    fn drop_without_shutdown(mut self) {
727        // Safety: drops once, never accessed again due to mem::forget
728        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
729        // Prevent Drop from running (which would shut down the channel)
730        std::mem::forget(self);
731    }
732}
733
734impl TestHarnessOpenServiceDirectoryResponder {
735    /// Sends a response to the FIDL transaction.
736    ///
737    /// Sets the channel to shutdown if an error occurs.
738    pub fn send(
739        self,
740        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
741    ) -> Result<(), fidl::Error> {
742        let _result = self.send_raw(object_request);
743        if _result.is_err() {
744            self.control_handle.shutdown();
745        }
746        self.drop_without_shutdown();
747        _result
748    }
749
750    /// Similar to "send" but does not shutdown the channel if an error occurs.
751    pub fn send_no_shutdown_on_err(
752        self,
753        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
754    ) -> Result<(), fidl::Error> {
755        let _result = self.send_raw(object_request);
756        self.drop_without_shutdown();
757        _result
758    }
759
760    fn send_raw(
761        &self,
762        mut object_request: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
763    ) -> Result<(), fidl::Error> {
764        self.control_handle.inner.send::<TestHarnessOpenServiceDirectoryResponse>(
765            (object_request,),
766            self.tx_id,
767            0x42904fe08b12ef88,
768            fidl::encoding::DynamicFlags::empty(),
769        )
770    }
771}
772
773mod internal {
774    use super::*;
775
776    impl fidl::encoding::ResourceTypeMarker for Directory {
777        type Borrowed<'a> = &'a mut Self;
778        fn take_or_borrow<'a>(
779            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
780        ) -> Self::Borrowed<'a> {
781            value
782        }
783    }
784
785    unsafe impl fidl::encoding::TypeMarker for Directory {
786        type Owned = Self;
787
788        #[inline(always)]
789        fn inline_align(_context: fidl::encoding::Context) -> usize {
790            8
791        }
792
793        #[inline(always)]
794        fn inline_size(_context: fidl::encoding::Context) -> usize {
795            32
796        }
797    }
798
799    unsafe impl fidl::encoding::Encode<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>
800        for &mut Directory
801    {
802        #[inline]
803        unsafe fn encode(
804            self,
805            encoder: &mut fidl::encoding::Encoder<
806                '_,
807                fidl::encoding::DefaultFuchsiaResourceDialect,
808            >,
809            offset: usize,
810            _depth: fidl::encoding::Depth,
811        ) -> fidl::Result<()> {
812            encoder.debug_check_bounds::<Directory>(offset);
813            // Delegate to tuple encoding.
814            fidl::encoding::Encode::<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
815                (
816                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
817                    <fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.entries),
818                ),
819                encoder, offset, _depth
820            )
821        }
822    }
823    unsafe impl<
824            T0: fidl::encoding::Encode<
825                fidl::encoding::BoundedString<255>,
826                fidl::encoding::DefaultFuchsiaResourceDialect,
827            >,
828            T1: fidl::encoding::Encode<
829                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
830                fidl::encoding::DefaultFuchsiaResourceDialect,
831            >,
832        > fidl::encoding::Encode<Directory, fidl::encoding::DefaultFuchsiaResourceDialect>
833        for (T0, T1)
834    {
835        #[inline]
836        unsafe fn encode(
837            self,
838            encoder: &mut fidl::encoding::Encoder<
839                '_,
840                fidl::encoding::DefaultFuchsiaResourceDialect,
841            >,
842            offset: usize,
843            depth: fidl::encoding::Depth,
844        ) -> fidl::Result<()> {
845            encoder.debug_check_bounds::<Directory>(offset);
846            // Zero out padding regions. There's no need to apply masks
847            // because the unmasked parts will be overwritten by fields.
848            // Write the fields.
849            self.0.encode(encoder, offset + 0, depth)?;
850            self.1.encode(encoder, offset + 16, depth)?;
851            Ok(())
852        }
853    }
854
855    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Directory {
856        #[inline(always)]
857        fn new_empty() -> Self {
858            Self {
859                name: fidl::new_empty!(
860                    fidl::encoding::BoundedString<255>,
861                    fidl::encoding::DefaultFuchsiaResourceDialect
862                ),
863                entries: fidl::new_empty!(
864                    fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
865                    fidl::encoding::DefaultFuchsiaResourceDialect
866                ),
867            }
868        }
869
870        #[inline]
871        unsafe fn decode(
872            &mut self,
873            decoder: &mut fidl::encoding::Decoder<
874                '_,
875                fidl::encoding::DefaultFuchsiaResourceDialect,
876            >,
877            offset: usize,
878            _depth: fidl::encoding::Depth,
879        ) -> fidl::Result<()> {
880            decoder.debug_check_bounds::<Self>(offset);
881            // Verify that padding bytes are zero.
882            fidl::decode!(
883                fidl::encoding::BoundedString<255>,
884                fidl::encoding::DefaultFuchsiaResourceDialect,
885                &mut self.name,
886                decoder,
887                offset + 0,
888                _depth
889            )?;
890            fidl::decode!(
891                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
892                fidl::encoding::DefaultFuchsiaResourceDialect,
893                &mut self.entries,
894                decoder,
895                offset + 16,
896                _depth
897            )?;
898            Ok(())
899        }
900    }
901
902    impl fidl::encoding::ResourceTypeMarker for RemoteDirectory {
903        type Borrowed<'a> = &'a mut Self;
904        fn take_or_borrow<'a>(
905            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
906        ) -> Self::Borrowed<'a> {
907            value
908        }
909    }
910
911    unsafe impl fidl::encoding::TypeMarker for RemoteDirectory {
912        type Owned = Self;
913
914        #[inline(always)]
915        fn inline_align(_context: fidl::encoding::Context) -> usize {
916            8
917        }
918
919        #[inline(always)]
920        fn inline_size(_context: fidl::encoding::Context) -> usize {
921            24
922        }
923    }
924
925    unsafe impl
926        fidl::encoding::Encode<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>
927        for &mut RemoteDirectory
928    {
929        #[inline]
930        unsafe fn encode(
931            self,
932            encoder: &mut fidl::encoding::Encoder<
933                '_,
934                fidl::encoding::DefaultFuchsiaResourceDialect,
935            >,
936            offset: usize,
937            _depth: fidl::encoding::Depth,
938        ) -> fidl::Result<()> {
939            encoder.debug_check_bounds::<RemoteDirectory>(offset);
940            // Delegate to tuple encoding.
941            fidl::encoding::Encode::<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
942                (
943                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
944                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.remote_client),
945                ),
946                encoder, offset, _depth
947            )
948        }
949    }
950    unsafe impl<
951            T0: fidl::encoding::Encode<
952                fidl::encoding::BoundedString<255>,
953                fidl::encoding::DefaultFuchsiaResourceDialect,
954            >,
955            T1: fidl::encoding::Encode<
956                fidl::encoding::Endpoint<
957                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
958                >,
959                fidl::encoding::DefaultFuchsiaResourceDialect,
960            >,
961        > fidl::encoding::Encode<RemoteDirectory, fidl::encoding::DefaultFuchsiaResourceDialect>
962        for (T0, T1)
963    {
964        #[inline]
965        unsafe fn encode(
966            self,
967            encoder: &mut fidl::encoding::Encoder<
968                '_,
969                fidl::encoding::DefaultFuchsiaResourceDialect,
970            >,
971            offset: usize,
972            depth: fidl::encoding::Depth,
973        ) -> fidl::Result<()> {
974            encoder.debug_check_bounds::<RemoteDirectory>(offset);
975            // Zero out padding regions. There's no need to apply masks
976            // because the unmasked parts will be overwritten by fields.
977            unsafe {
978                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
979                (ptr as *mut u64).write_unaligned(0);
980            }
981            // Write the fields.
982            self.0.encode(encoder, offset + 0, depth)?;
983            self.1.encode(encoder, offset + 16, depth)?;
984            Ok(())
985        }
986    }
987
988    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
989        for RemoteDirectory
990    {
991        #[inline(always)]
992        fn new_empty() -> Self {
993            Self {
994                name: fidl::new_empty!(
995                    fidl::encoding::BoundedString<255>,
996                    fidl::encoding::DefaultFuchsiaResourceDialect
997                ),
998                remote_client: fidl::new_empty!(
999                    fidl::encoding::Endpoint<
1000                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1001                    >,
1002                    fidl::encoding::DefaultFuchsiaResourceDialect
1003                ),
1004            }
1005        }
1006
1007        #[inline]
1008        unsafe fn decode(
1009            &mut self,
1010            decoder: &mut fidl::encoding::Decoder<
1011                '_,
1012                fidl::encoding::DefaultFuchsiaResourceDialect,
1013            >,
1014            offset: usize,
1015            _depth: fidl::encoding::Depth,
1016        ) -> fidl::Result<()> {
1017            decoder.debug_check_bounds::<Self>(offset);
1018            // Verify that padding bytes are zero.
1019            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1020            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1021            let mask = 0xffffffff00000000u64;
1022            let maskedval = padval & mask;
1023            if maskedval != 0 {
1024                return Err(fidl::Error::NonZeroPadding {
1025                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1026                });
1027            }
1028            fidl::decode!(
1029                fidl::encoding::BoundedString<255>,
1030                fidl::encoding::DefaultFuchsiaResourceDialect,
1031                &mut self.name,
1032                decoder,
1033                offset + 0,
1034                _depth
1035            )?;
1036            fidl::decode!(
1037                fidl::encoding::Endpoint<
1038                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1039                >,
1040                fidl::encoding::DefaultFuchsiaResourceDialect,
1041                &mut self.remote_client,
1042                decoder,
1043                offset + 16,
1044                _depth
1045            )?;
1046            Ok(())
1047        }
1048    }
1049
1050    impl fidl::encoding::ResourceTypeMarker for TestHarnessCreateDirectoryRequest {
1051        type Borrowed<'a> = &'a mut Self;
1052        fn take_or_borrow<'a>(
1053            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1054        ) -> Self::Borrowed<'a> {
1055            value
1056        }
1057    }
1058
1059    unsafe impl fidl::encoding::TypeMarker for TestHarnessCreateDirectoryRequest {
1060        type Owned = Self;
1061
1062        #[inline(always)]
1063        fn inline_align(_context: fidl::encoding::Context) -> usize {
1064            8
1065        }
1066
1067        #[inline(always)]
1068        fn inline_size(_context: fidl::encoding::Context) -> usize {
1069            32
1070        }
1071    }
1072
1073    unsafe impl
1074        fidl::encoding::Encode<
1075            TestHarnessCreateDirectoryRequest,
1076            fidl::encoding::DefaultFuchsiaResourceDialect,
1077        > for &mut TestHarnessCreateDirectoryRequest
1078    {
1079        #[inline]
1080        unsafe fn encode(
1081            self,
1082            encoder: &mut fidl::encoding::Encoder<
1083                '_,
1084                fidl::encoding::DefaultFuchsiaResourceDialect,
1085            >,
1086            offset: usize,
1087            _depth: fidl::encoding::Depth,
1088        ) -> fidl::Result<()> {
1089            encoder.debug_check_bounds::<TestHarnessCreateDirectoryRequest>(offset);
1090            // Delegate to tuple encoding.
1091            fidl::encoding::Encode::<TestHarnessCreateDirectoryRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1092                (
1093                    <fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.contents),
1094                    <fidl_fuchsia_io::Flags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1095                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.object_request),
1096                ),
1097                encoder, offset, _depth
1098            )
1099        }
1100    }
1101    unsafe impl<
1102            T0: fidl::encoding::Encode<
1103                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1104                fidl::encoding::DefaultFuchsiaResourceDialect,
1105            >,
1106            T1: fidl::encoding::Encode<
1107                fidl_fuchsia_io::Flags,
1108                fidl::encoding::DefaultFuchsiaResourceDialect,
1109            >,
1110            T2: fidl::encoding::Encode<
1111                fidl::encoding::Endpoint<
1112                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1113                >,
1114                fidl::encoding::DefaultFuchsiaResourceDialect,
1115            >,
1116        >
1117        fidl::encoding::Encode<
1118            TestHarnessCreateDirectoryRequest,
1119            fidl::encoding::DefaultFuchsiaResourceDialect,
1120        > for (T0, T1, T2)
1121    {
1122        #[inline]
1123        unsafe fn encode(
1124            self,
1125            encoder: &mut fidl::encoding::Encoder<
1126                '_,
1127                fidl::encoding::DefaultFuchsiaResourceDialect,
1128            >,
1129            offset: usize,
1130            depth: fidl::encoding::Depth,
1131        ) -> fidl::Result<()> {
1132            encoder.debug_check_bounds::<TestHarnessCreateDirectoryRequest>(offset);
1133            // Zero out padding regions. There's no need to apply masks
1134            // because the unmasked parts will be overwritten by fields.
1135            unsafe {
1136                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1137                (ptr as *mut u64).write_unaligned(0);
1138            }
1139            // Write the fields.
1140            self.0.encode(encoder, offset + 0, depth)?;
1141            self.1.encode(encoder, offset + 16, depth)?;
1142            self.2.encode(encoder, offset + 24, depth)?;
1143            Ok(())
1144        }
1145    }
1146
1147    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1148        for TestHarnessCreateDirectoryRequest
1149    {
1150        #[inline(always)]
1151        fn new_empty() -> Self {
1152            Self {
1153                contents: fidl::new_empty!(
1154                    fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1155                    fidl::encoding::DefaultFuchsiaResourceDialect
1156                ),
1157                flags: fidl::new_empty!(
1158                    fidl_fuchsia_io::Flags,
1159                    fidl::encoding::DefaultFuchsiaResourceDialect
1160                ),
1161                object_request: fidl::new_empty!(
1162                    fidl::encoding::Endpoint<
1163                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1164                    >,
1165                    fidl::encoding::DefaultFuchsiaResourceDialect
1166                ),
1167            }
1168        }
1169
1170        #[inline]
1171        unsafe fn decode(
1172            &mut self,
1173            decoder: &mut fidl::encoding::Decoder<
1174                '_,
1175                fidl::encoding::DefaultFuchsiaResourceDialect,
1176            >,
1177            offset: usize,
1178            _depth: fidl::encoding::Depth,
1179        ) -> fidl::Result<()> {
1180            decoder.debug_check_bounds::<Self>(offset);
1181            // Verify that padding bytes are zero.
1182            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1183            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1184            let mask = 0xffffffff00000000u64;
1185            let maskedval = padval & mask;
1186            if maskedval != 0 {
1187                return Err(fidl::Error::NonZeroPadding {
1188                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1189                });
1190            }
1191            fidl::decode!(
1192                fidl::encoding::UnboundedVector<fidl::encoding::OptionalUnion<DirectoryEntry>>,
1193                fidl::encoding::DefaultFuchsiaResourceDialect,
1194                &mut self.contents,
1195                decoder,
1196                offset + 0,
1197                _depth
1198            )?;
1199            fidl::decode!(
1200                fidl_fuchsia_io::Flags,
1201                fidl::encoding::DefaultFuchsiaResourceDialect,
1202                &mut self.flags,
1203                decoder,
1204                offset + 16,
1205                _depth
1206            )?;
1207            fidl::decode!(
1208                fidl::encoding::Endpoint<
1209                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1210                >,
1211                fidl::encoding::DefaultFuchsiaResourceDialect,
1212                &mut self.object_request,
1213                decoder,
1214                offset + 24,
1215                _depth
1216            )?;
1217            Ok(())
1218        }
1219    }
1220
1221    impl fidl::encoding::ResourceTypeMarker for TestHarnessOpenServiceDirectoryResponse {
1222        type Borrowed<'a> = &'a mut Self;
1223        fn take_or_borrow<'a>(
1224            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1225        ) -> Self::Borrowed<'a> {
1226            value
1227        }
1228    }
1229
1230    unsafe impl fidl::encoding::TypeMarker for TestHarnessOpenServiceDirectoryResponse {
1231        type Owned = Self;
1232
1233        #[inline(always)]
1234        fn inline_align(_context: fidl::encoding::Context) -> usize {
1235            4
1236        }
1237
1238        #[inline(always)]
1239        fn inline_size(_context: fidl::encoding::Context) -> usize {
1240            4
1241        }
1242    }
1243
1244    unsafe impl
1245        fidl::encoding::Encode<
1246            TestHarnessOpenServiceDirectoryResponse,
1247            fidl::encoding::DefaultFuchsiaResourceDialect,
1248        > for &mut TestHarnessOpenServiceDirectoryResponse
1249    {
1250        #[inline]
1251        unsafe fn encode(
1252            self,
1253            encoder: &mut fidl::encoding::Encoder<
1254                '_,
1255                fidl::encoding::DefaultFuchsiaResourceDialect,
1256            >,
1257            offset: usize,
1258            _depth: fidl::encoding::Depth,
1259        ) -> fidl::Result<()> {
1260            encoder.debug_check_bounds::<TestHarnessOpenServiceDirectoryResponse>(offset);
1261            // Delegate to tuple encoding.
1262            fidl::encoding::Encode::<
1263                TestHarnessOpenServiceDirectoryResponse,
1264                fidl::encoding::DefaultFuchsiaResourceDialect,
1265            >::encode(
1266                (<fidl::encoding::Endpoint<
1267                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1268                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1269                    &mut self.object_request
1270                ),),
1271                encoder,
1272                offset,
1273                _depth,
1274            )
1275        }
1276    }
1277    unsafe impl<
1278            T0: fidl::encoding::Encode<
1279                fidl::encoding::Endpoint<
1280                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1281                >,
1282                fidl::encoding::DefaultFuchsiaResourceDialect,
1283            >,
1284        >
1285        fidl::encoding::Encode<
1286            TestHarnessOpenServiceDirectoryResponse,
1287            fidl::encoding::DefaultFuchsiaResourceDialect,
1288        > for (T0,)
1289    {
1290        #[inline]
1291        unsafe fn encode(
1292            self,
1293            encoder: &mut fidl::encoding::Encoder<
1294                '_,
1295                fidl::encoding::DefaultFuchsiaResourceDialect,
1296            >,
1297            offset: usize,
1298            depth: fidl::encoding::Depth,
1299        ) -> fidl::Result<()> {
1300            encoder.debug_check_bounds::<TestHarnessOpenServiceDirectoryResponse>(offset);
1301            // Zero out padding regions. There's no need to apply masks
1302            // because the unmasked parts will be overwritten by fields.
1303            // Write the fields.
1304            self.0.encode(encoder, offset + 0, depth)?;
1305            Ok(())
1306        }
1307    }
1308
1309    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1310        for TestHarnessOpenServiceDirectoryResponse
1311    {
1312        #[inline(always)]
1313        fn new_empty() -> Self {
1314            Self {
1315                object_request: fidl::new_empty!(
1316                    fidl::encoding::Endpoint<
1317                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1318                    >,
1319                    fidl::encoding::DefaultFuchsiaResourceDialect
1320                ),
1321            }
1322        }
1323
1324        #[inline]
1325        unsafe fn decode(
1326            &mut self,
1327            decoder: &mut fidl::encoding::Decoder<
1328                '_,
1329                fidl::encoding::DefaultFuchsiaResourceDialect,
1330            >,
1331            offset: usize,
1332            _depth: fidl::encoding::Depth,
1333        ) -> fidl::Result<()> {
1334            decoder.debug_check_bounds::<Self>(offset);
1335            // Verify that padding bytes are zero.
1336            fidl::decode!(
1337                fidl::encoding::Endpoint<
1338                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1339                >,
1340                fidl::encoding::DefaultFuchsiaResourceDialect,
1341                &mut self.object_request,
1342                decoder,
1343                offset + 0,
1344                _depth
1345            )?;
1346            Ok(())
1347        }
1348    }
1349
1350    impl fidl::encoding::ResourceTypeMarker for DirectoryEntry {
1351        type Borrowed<'a> = &'a mut Self;
1352        fn take_or_borrow<'a>(
1353            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1354        ) -> Self::Borrowed<'a> {
1355            value
1356        }
1357    }
1358
1359    unsafe impl fidl::encoding::TypeMarker for DirectoryEntry {
1360        type Owned = Self;
1361
1362        #[inline(always)]
1363        fn inline_align(_context: fidl::encoding::Context) -> usize {
1364            8
1365        }
1366
1367        #[inline(always)]
1368        fn inline_size(_context: fidl::encoding::Context) -> usize {
1369            16
1370        }
1371    }
1372
1373    unsafe impl
1374        fidl::encoding::Encode<DirectoryEntry, fidl::encoding::DefaultFuchsiaResourceDialect>
1375        for &mut DirectoryEntry
1376    {
1377        #[inline]
1378        unsafe fn encode(
1379            self,
1380            encoder: &mut fidl::encoding::Encoder<
1381                '_,
1382                fidl::encoding::DefaultFuchsiaResourceDialect,
1383            >,
1384            offset: usize,
1385            _depth: fidl::encoding::Depth,
1386        ) -> fidl::Result<()> {
1387            encoder.debug_check_bounds::<DirectoryEntry>(offset);
1388            encoder.write_num::<u64>(self.ordinal(), offset);
1389            match self {
1390                DirectoryEntry::Directory(ref mut val) => fidl::encoding::encode_in_envelope::<
1391                    Directory,
1392                    fidl::encoding::DefaultFuchsiaResourceDialect,
1393                >(
1394                    <Directory as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1395                    encoder,
1396                    offset + 8,
1397                    _depth,
1398                ),
1399                DirectoryEntry::RemoteDirectory(ref mut val) => {
1400                    fidl::encoding::encode_in_envelope::<
1401                        RemoteDirectory,
1402                        fidl::encoding::DefaultFuchsiaResourceDialect,
1403                    >(
1404                        <RemoteDirectory as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1405                            val,
1406                        ),
1407                        encoder,
1408                        offset + 8,
1409                        _depth,
1410                    )
1411                }
1412                DirectoryEntry::File(ref val) => fidl::encoding::encode_in_envelope::<
1413                    File,
1414                    fidl::encoding::DefaultFuchsiaResourceDialect,
1415                >(
1416                    <File as fidl::encoding::ValueTypeMarker>::borrow(val),
1417                    encoder,
1418                    offset + 8,
1419                    _depth,
1420                ),
1421                DirectoryEntry::ExecutableFile(ref val) => fidl::encoding::encode_in_envelope::<
1422                    ExecutableFile,
1423                    fidl::encoding::DefaultFuchsiaResourceDialect,
1424                >(
1425                    <ExecutableFile as fidl::encoding::ValueTypeMarker>::borrow(val),
1426                    encoder,
1427                    offset + 8,
1428                    _depth,
1429                ),
1430            }
1431        }
1432    }
1433
1434    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1435        for DirectoryEntry
1436    {
1437        #[inline(always)]
1438        fn new_empty() -> Self {
1439            Self::Directory(fidl::new_empty!(
1440                Directory,
1441                fidl::encoding::DefaultFuchsiaResourceDialect
1442            ))
1443        }
1444
1445        #[inline]
1446        unsafe fn decode(
1447            &mut self,
1448            decoder: &mut fidl::encoding::Decoder<
1449                '_,
1450                fidl::encoding::DefaultFuchsiaResourceDialect,
1451            >,
1452            offset: usize,
1453            mut depth: fidl::encoding::Depth,
1454        ) -> fidl::Result<()> {
1455            decoder.debug_check_bounds::<Self>(offset);
1456            #[allow(unused_variables)]
1457            let next_out_of_line = decoder.next_out_of_line();
1458            let handles_before = decoder.remaining_handles();
1459            let (ordinal, inlined, num_bytes, num_handles) =
1460                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1461
1462            let member_inline_size = match ordinal {
1463                1 => <Directory as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1464                2 => <RemoteDirectory as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1465                3 => <File as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1466                5 => <ExecutableFile as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1467                _ => return Err(fidl::Error::UnknownUnionTag),
1468            };
1469
1470            if inlined != (member_inline_size <= 4) {
1471                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1472            }
1473            let _inner_offset;
1474            if inlined {
1475                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1476                _inner_offset = offset + 8;
1477            } else {
1478                depth.increment()?;
1479                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1480            }
1481            match ordinal {
1482                1 => {
1483                    #[allow(irrefutable_let_patterns)]
1484                    if let DirectoryEntry::Directory(_) = self {
1485                        // Do nothing, read the value into the object
1486                    } else {
1487                        // Initialize `self` to the right variant
1488                        *self = DirectoryEntry::Directory(fidl::new_empty!(
1489                            Directory,
1490                            fidl::encoding::DefaultFuchsiaResourceDialect
1491                        ));
1492                    }
1493                    #[allow(irrefutable_let_patterns)]
1494                    if let DirectoryEntry::Directory(ref mut val) = self {
1495                        fidl::decode!(
1496                            Directory,
1497                            fidl::encoding::DefaultFuchsiaResourceDialect,
1498                            val,
1499                            decoder,
1500                            _inner_offset,
1501                            depth
1502                        )?;
1503                    } else {
1504                        unreachable!()
1505                    }
1506                }
1507                2 => {
1508                    #[allow(irrefutable_let_patterns)]
1509                    if let DirectoryEntry::RemoteDirectory(_) = self {
1510                        // Do nothing, read the value into the object
1511                    } else {
1512                        // Initialize `self` to the right variant
1513                        *self = DirectoryEntry::RemoteDirectory(fidl::new_empty!(
1514                            RemoteDirectory,
1515                            fidl::encoding::DefaultFuchsiaResourceDialect
1516                        ));
1517                    }
1518                    #[allow(irrefutable_let_patterns)]
1519                    if let DirectoryEntry::RemoteDirectory(ref mut val) = self {
1520                        fidl::decode!(
1521                            RemoteDirectory,
1522                            fidl::encoding::DefaultFuchsiaResourceDialect,
1523                            val,
1524                            decoder,
1525                            _inner_offset,
1526                            depth
1527                        )?;
1528                    } else {
1529                        unreachable!()
1530                    }
1531                }
1532                3 => {
1533                    #[allow(irrefutable_let_patterns)]
1534                    if let DirectoryEntry::File(_) = self {
1535                        // Do nothing, read the value into the object
1536                    } else {
1537                        // Initialize `self` to the right variant
1538                        *self = DirectoryEntry::File(fidl::new_empty!(
1539                            File,
1540                            fidl::encoding::DefaultFuchsiaResourceDialect
1541                        ));
1542                    }
1543                    #[allow(irrefutable_let_patterns)]
1544                    if let DirectoryEntry::File(ref mut val) = self {
1545                        fidl::decode!(
1546                            File,
1547                            fidl::encoding::DefaultFuchsiaResourceDialect,
1548                            val,
1549                            decoder,
1550                            _inner_offset,
1551                            depth
1552                        )?;
1553                    } else {
1554                        unreachable!()
1555                    }
1556                }
1557                5 => {
1558                    #[allow(irrefutable_let_patterns)]
1559                    if let DirectoryEntry::ExecutableFile(_) = self {
1560                        // Do nothing, read the value into the object
1561                    } else {
1562                        // Initialize `self` to the right variant
1563                        *self = DirectoryEntry::ExecutableFile(fidl::new_empty!(
1564                            ExecutableFile,
1565                            fidl::encoding::DefaultFuchsiaResourceDialect
1566                        ));
1567                    }
1568                    #[allow(irrefutable_let_patterns)]
1569                    if let DirectoryEntry::ExecutableFile(ref mut val) = self {
1570                        fidl::decode!(
1571                            ExecutableFile,
1572                            fidl::encoding::DefaultFuchsiaResourceDialect,
1573                            val,
1574                            decoder,
1575                            _inner_offset,
1576                            depth
1577                        )?;
1578                    } else {
1579                        unreachable!()
1580                    }
1581                }
1582                ordinal => panic!("unexpected ordinal {:?}", ordinal),
1583            }
1584            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1585                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1586            }
1587            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1588                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1589            }
1590            Ok(())
1591        }
1592    }
1593}