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