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