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