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