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_test_mock_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct RealmFactoryCreateRealmRequest {
16 pub options: RealmOptions,
17 pub realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for RealmFactoryCreateRealmRequest
22{
23}
24
25#[derive(Debug, Default, PartialEq)]
27pub struct RealmOptions {
28 #[doc(hidden)]
29 pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub struct RealmFactoryMarker;
36
37impl fidl::endpoints::ProtocolMarker for RealmFactoryMarker {
38 type Proxy = RealmFactoryProxy;
39 type RequestStream = RealmFactoryRequestStream;
40 #[cfg(target_os = "fuchsia")]
41 type SynchronousProxy = RealmFactorySynchronousProxy;
42
43 const DEBUG_NAME: &'static str = "test.mock.RealmFactory";
44}
45impl fidl::endpoints::DiscoverableProtocolMarker for RealmFactoryMarker {}
46pub type RealmFactoryCreateRealmResult = Result<(), fidl_fuchsia_testing_harness::OperationError>;
47
48pub trait RealmFactoryProxyInterface: Send + Sync {
49 type CreateRealmResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealmResult, fidl::Error>>
50 + Send;
51 fn r#create_realm(
52 &self,
53 options: RealmOptions,
54 realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
55 ) -> Self::CreateRealmResponseFut;
56}
57#[derive(Debug)]
58#[cfg(target_os = "fuchsia")]
59pub struct RealmFactorySynchronousProxy {
60 client: fidl::client::sync::Client,
61}
62
63#[cfg(target_os = "fuchsia")]
64impl fidl::endpoints::SynchronousProxy for RealmFactorySynchronousProxy {
65 type Proxy = RealmFactoryProxy;
66 type Protocol = RealmFactoryMarker;
67
68 fn from_channel(inner: fidl::Channel) -> Self {
69 Self::new(inner)
70 }
71
72 fn into_channel(self) -> fidl::Channel {
73 self.client.into_channel()
74 }
75
76 fn as_channel(&self) -> &fidl::Channel {
77 self.client.as_channel()
78 }
79}
80
81#[cfg(target_os = "fuchsia")]
82impl RealmFactorySynchronousProxy {
83 pub fn new(channel: fidl::Channel) -> Self {
84 let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
85 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
86 }
87
88 pub fn into_channel(self) -> fidl::Channel {
89 self.client.into_channel()
90 }
91
92 pub fn wait_for_event(
95 &self,
96 deadline: zx::MonotonicInstant,
97 ) -> Result<RealmFactoryEvent, fidl::Error> {
98 RealmFactoryEvent::decode(self.client.wait_for_event(deadline)?)
99 }
100
101 pub fn r#create_realm(
105 &self,
106 mut options: RealmOptions,
107 mut realm_server: fidl::endpoints::ServerEnd<
108 fidl_fuchsia_testing_harness::RealmProxy_Marker,
109 >,
110 ___deadline: zx::MonotonicInstant,
111 ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
112 let _response = self
113 .client
114 .send_query::<RealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
115 fidl::encoding::EmptyStruct,
116 fidl_fuchsia_testing_harness::OperationError,
117 >>(
118 (&mut options, realm_server),
119 0x4fd194b2ad658fce,
120 fidl::encoding::DynamicFlags::FLEXIBLE,
121 ___deadline,
122 )?
123 .into_result::<RealmFactoryMarker>("create_realm")?;
124 Ok(_response.map(|x| x))
125 }
126}
127
128#[cfg(target_os = "fuchsia")]
129impl From<RealmFactorySynchronousProxy> for zx::Handle {
130 fn from(value: RealmFactorySynchronousProxy) -> Self {
131 value.into_channel().into()
132 }
133}
134
135#[cfg(target_os = "fuchsia")]
136impl From<fidl::Channel> for RealmFactorySynchronousProxy {
137 fn from(value: fidl::Channel) -> Self {
138 Self::new(value)
139 }
140}
141
142#[derive(Debug, Clone)]
143pub struct RealmFactoryProxy {
144 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
145}
146
147impl fidl::endpoints::Proxy for RealmFactoryProxy {
148 type Protocol = RealmFactoryMarker;
149
150 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
151 Self::new(inner)
152 }
153
154 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
155 self.client.into_channel().map_err(|client| Self { client })
156 }
157
158 fn as_channel(&self) -> &::fidl::AsyncChannel {
159 self.client.as_channel()
160 }
161}
162
163impl RealmFactoryProxy {
164 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
166 let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
167 Self { client: fidl::client::Client::new(channel, protocol_name) }
168 }
169
170 pub fn take_event_stream(&self) -> RealmFactoryEventStream {
176 RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
177 }
178
179 pub fn r#create_realm(
183 &self,
184 mut options: RealmOptions,
185 mut realm_server: fidl::endpoints::ServerEnd<
186 fidl_fuchsia_testing_harness::RealmProxy_Marker,
187 >,
188 ) -> fidl::client::QueryResponseFut<
189 RealmFactoryCreateRealmResult,
190 fidl::encoding::DefaultFuchsiaResourceDialect,
191 > {
192 RealmFactoryProxyInterface::r#create_realm(self, options, realm_server)
193 }
194}
195
196impl RealmFactoryProxyInterface for RealmFactoryProxy {
197 type CreateRealmResponseFut = fidl::client::QueryResponseFut<
198 RealmFactoryCreateRealmResult,
199 fidl::encoding::DefaultFuchsiaResourceDialect,
200 >;
201 fn r#create_realm(
202 &self,
203 mut options: RealmOptions,
204 mut realm_server: fidl::endpoints::ServerEnd<
205 fidl_fuchsia_testing_harness::RealmProxy_Marker,
206 >,
207 ) -> Self::CreateRealmResponseFut {
208 fn _decode(
209 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
210 ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
211 let _response = fidl::client::decode_transaction_body::<
212 fidl::encoding::FlexibleResultType<
213 fidl::encoding::EmptyStruct,
214 fidl_fuchsia_testing_harness::OperationError,
215 >,
216 fidl::encoding::DefaultFuchsiaResourceDialect,
217 0x4fd194b2ad658fce,
218 >(_buf?)?
219 .into_result::<RealmFactoryMarker>("create_realm")?;
220 Ok(_response.map(|x| x))
221 }
222 self.client
223 .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
224 (&mut options, realm_server),
225 0x4fd194b2ad658fce,
226 fidl::encoding::DynamicFlags::FLEXIBLE,
227 _decode,
228 )
229 }
230}
231
232pub struct RealmFactoryEventStream {
233 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
234}
235
236impl std::marker::Unpin for RealmFactoryEventStream {}
237
238impl futures::stream::FusedStream for RealmFactoryEventStream {
239 fn is_terminated(&self) -> bool {
240 self.event_receiver.is_terminated()
241 }
242}
243
244impl futures::Stream for RealmFactoryEventStream {
245 type Item = Result<RealmFactoryEvent, fidl::Error>;
246
247 fn poll_next(
248 mut self: std::pin::Pin<&mut Self>,
249 cx: &mut std::task::Context<'_>,
250 ) -> std::task::Poll<Option<Self::Item>> {
251 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
252 &mut self.event_receiver,
253 cx
254 )?) {
255 Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
256 None => std::task::Poll::Ready(None),
257 }
258 }
259}
260
261#[derive(Debug)]
262pub enum RealmFactoryEvent {
263 #[non_exhaustive]
264 _UnknownEvent {
265 ordinal: u64,
267 },
268}
269
270impl RealmFactoryEvent {
271 fn decode(
273 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
274 ) -> Result<RealmFactoryEvent, fidl::Error> {
275 let (bytes, _handles) = buf.split_mut();
276 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
277 debug_assert_eq!(tx_header.tx_id, 0);
278 match tx_header.ordinal {
279 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
280 Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
281 }
282 _ => Err(fidl::Error::UnknownOrdinal {
283 ordinal: tx_header.ordinal,
284 protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
285 }),
286 }
287 }
288}
289
290pub struct RealmFactoryRequestStream {
292 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
293 is_terminated: bool,
294}
295
296impl std::marker::Unpin for RealmFactoryRequestStream {}
297
298impl futures::stream::FusedStream for RealmFactoryRequestStream {
299 fn is_terminated(&self) -> bool {
300 self.is_terminated
301 }
302}
303
304impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
305 type Protocol = RealmFactoryMarker;
306 type ControlHandle = RealmFactoryControlHandle;
307
308 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
309 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
310 }
311
312 fn control_handle(&self) -> Self::ControlHandle {
313 RealmFactoryControlHandle { inner: self.inner.clone() }
314 }
315
316 fn into_inner(
317 self,
318 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
319 {
320 (self.inner, self.is_terminated)
321 }
322
323 fn from_inner(
324 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
325 is_terminated: bool,
326 ) -> Self {
327 Self { inner, is_terminated }
328 }
329}
330
331impl futures::Stream for RealmFactoryRequestStream {
332 type Item = Result<RealmFactoryRequest, fidl::Error>;
333
334 fn poll_next(
335 mut self: std::pin::Pin<&mut Self>,
336 cx: &mut std::task::Context<'_>,
337 ) -> std::task::Poll<Option<Self::Item>> {
338 let this = &mut *self;
339 if this.inner.check_shutdown(cx) {
340 this.is_terminated = true;
341 return std::task::Poll::Ready(None);
342 }
343 if this.is_terminated {
344 panic!("polled RealmFactoryRequestStream after completion");
345 }
346 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
347 |bytes, handles| {
348 match this.inner.channel().read_etc(cx, bytes, handles) {
349 std::task::Poll::Ready(Ok(())) => {}
350 std::task::Poll::Pending => return std::task::Poll::Pending,
351 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
352 this.is_terminated = true;
353 return std::task::Poll::Ready(None);
354 }
355 std::task::Poll::Ready(Err(e)) => {
356 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
357 e.into(),
358 ))))
359 }
360 }
361
362 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
364
365 std::task::Poll::Ready(Some(match header.ordinal {
366 0x4fd194b2ad658fce => {
367 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
368 let mut req = fidl::new_empty!(
369 RealmFactoryCreateRealmRequest,
370 fidl::encoding::DefaultFuchsiaResourceDialect
371 );
372 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
373 let control_handle =
374 RealmFactoryControlHandle { inner: this.inner.clone() };
375 Ok(RealmFactoryRequest::CreateRealm {
376 options: req.options,
377 realm_server: req.realm_server,
378
379 responder: RealmFactoryCreateRealmResponder {
380 control_handle: std::mem::ManuallyDrop::new(control_handle),
381 tx_id: header.tx_id,
382 },
383 })
384 }
385 _ if header.tx_id == 0
386 && header
387 .dynamic_flags()
388 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
389 {
390 Ok(RealmFactoryRequest::_UnknownMethod {
391 ordinal: header.ordinal,
392 control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
393 method_type: fidl::MethodType::OneWay,
394 })
395 }
396 _ if header
397 .dynamic_flags()
398 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
399 {
400 this.inner.send_framework_err(
401 fidl::encoding::FrameworkErr::UnknownMethod,
402 header.tx_id,
403 header.ordinal,
404 header.dynamic_flags(),
405 (bytes, handles),
406 )?;
407 Ok(RealmFactoryRequest::_UnknownMethod {
408 ordinal: header.ordinal,
409 control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
410 method_type: fidl::MethodType::TwoWay,
411 })
412 }
413 _ => Err(fidl::Error::UnknownOrdinal {
414 ordinal: header.ordinal,
415 protocol_name:
416 <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
417 }),
418 }))
419 },
420 )
421 }
422}
423
424#[derive(Debug)]
425pub enum RealmFactoryRequest {
426 CreateRealm {
430 options: RealmOptions,
431 realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
432 responder: RealmFactoryCreateRealmResponder,
433 },
434 #[non_exhaustive]
436 _UnknownMethod {
437 ordinal: u64,
439 control_handle: RealmFactoryControlHandle,
440 method_type: fidl::MethodType,
441 },
442}
443
444impl RealmFactoryRequest {
445 #[allow(irrefutable_let_patterns)]
446 pub fn into_create_realm(
447 self,
448 ) -> Option<(
449 RealmOptions,
450 fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
451 RealmFactoryCreateRealmResponder,
452 )> {
453 if let RealmFactoryRequest::CreateRealm { options, realm_server, responder } = self {
454 Some((options, realm_server, responder))
455 } else {
456 None
457 }
458 }
459
460 pub fn method_name(&self) -> &'static str {
462 match *self {
463 RealmFactoryRequest::CreateRealm { .. } => "create_realm",
464 RealmFactoryRequest::_UnknownMethod {
465 method_type: fidl::MethodType::OneWay, ..
466 } => "unknown one-way method",
467 RealmFactoryRequest::_UnknownMethod {
468 method_type: fidl::MethodType::TwoWay, ..
469 } => "unknown two-way method",
470 }
471 }
472}
473
474#[derive(Debug, Clone)]
475pub struct RealmFactoryControlHandle {
476 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
477}
478
479impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
480 fn shutdown(&self) {
481 self.inner.shutdown()
482 }
483 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
484 self.inner.shutdown_with_epitaph(status)
485 }
486
487 fn is_closed(&self) -> bool {
488 self.inner.channel().is_closed()
489 }
490 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
491 self.inner.channel().on_closed()
492 }
493
494 #[cfg(target_os = "fuchsia")]
495 fn signal_peer(
496 &self,
497 clear_mask: zx::Signals,
498 set_mask: zx::Signals,
499 ) -> Result<(), zx_status::Status> {
500 use fidl::Peered;
501 self.inner.channel().signal_peer(clear_mask, set_mask)
502 }
503}
504
505impl RealmFactoryControlHandle {}
506
507#[must_use = "FIDL methods require a response to be sent"]
508#[derive(Debug)]
509pub struct RealmFactoryCreateRealmResponder {
510 control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
511 tx_id: u32,
512}
513
514impl std::ops::Drop for RealmFactoryCreateRealmResponder {
518 fn drop(&mut self) {
519 self.control_handle.shutdown();
520 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
522 }
523}
524
525impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
526 type ControlHandle = RealmFactoryControlHandle;
527
528 fn control_handle(&self) -> &RealmFactoryControlHandle {
529 &self.control_handle
530 }
531
532 fn drop_without_shutdown(mut self) {
533 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
535 std::mem::forget(self);
537 }
538}
539
540impl RealmFactoryCreateRealmResponder {
541 pub fn send(
545 self,
546 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
547 ) -> Result<(), fidl::Error> {
548 let _result = self.send_raw(result);
549 if _result.is_err() {
550 self.control_handle.shutdown();
551 }
552 self.drop_without_shutdown();
553 _result
554 }
555
556 pub fn send_no_shutdown_on_err(
558 self,
559 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
560 ) -> Result<(), fidl::Error> {
561 let _result = self.send_raw(result);
562 self.drop_without_shutdown();
563 _result
564 }
565
566 fn send_raw(
567 &self,
568 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
569 ) -> Result<(), fidl::Error> {
570 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
571 fidl::encoding::EmptyStruct,
572 fidl_fuchsia_testing_harness::OperationError,
573 >>(
574 fidl::encoding::FlexibleResult::new(result),
575 self.tx_id,
576 0x4fd194b2ad658fce,
577 fidl::encoding::DynamicFlags::FLEXIBLE,
578 )
579 }
580}
581
582mod internal {
583 use super::*;
584
585 impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
586 type Borrowed<'a> = &'a mut Self;
587 fn take_or_borrow<'a>(
588 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
589 ) -> Self::Borrowed<'a> {
590 value
591 }
592 }
593
594 unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
595 type Owned = Self;
596
597 #[inline(always)]
598 fn inline_align(_context: fidl::encoding::Context) -> usize {
599 8
600 }
601
602 #[inline(always)]
603 fn inline_size(_context: fidl::encoding::Context) -> usize {
604 24
605 }
606 }
607
608 unsafe impl
609 fidl::encoding::Encode<
610 RealmFactoryCreateRealmRequest,
611 fidl::encoding::DefaultFuchsiaResourceDialect,
612 > for &mut RealmFactoryCreateRealmRequest
613 {
614 #[inline]
615 unsafe fn encode(
616 self,
617 encoder: &mut fidl::encoding::Encoder<
618 '_,
619 fidl::encoding::DefaultFuchsiaResourceDialect,
620 >,
621 offset: usize,
622 _depth: fidl::encoding::Depth,
623 ) -> fidl::Result<()> {
624 encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
625 fidl::encoding::Encode::<
627 RealmFactoryCreateRealmRequest,
628 fidl::encoding::DefaultFuchsiaResourceDialect,
629 >::encode(
630 (
631 <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
632 &mut self.options,
633 ),
634 <fidl::encoding::Endpoint<
635 fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
636 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
637 &mut self.realm_server,
638 ),
639 ),
640 encoder,
641 offset,
642 _depth,
643 )
644 }
645 }
646 unsafe impl<
647 T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
648 T1: fidl::encoding::Encode<
649 fidl::encoding::Endpoint<
650 fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
651 >,
652 fidl::encoding::DefaultFuchsiaResourceDialect,
653 >,
654 >
655 fidl::encoding::Encode<
656 RealmFactoryCreateRealmRequest,
657 fidl::encoding::DefaultFuchsiaResourceDialect,
658 > for (T0, T1)
659 {
660 #[inline]
661 unsafe fn encode(
662 self,
663 encoder: &mut fidl::encoding::Encoder<
664 '_,
665 fidl::encoding::DefaultFuchsiaResourceDialect,
666 >,
667 offset: usize,
668 depth: fidl::encoding::Depth,
669 ) -> fidl::Result<()> {
670 encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
671 unsafe {
674 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
675 (ptr as *mut u64).write_unaligned(0);
676 }
677 self.0.encode(encoder, offset + 0, depth)?;
679 self.1.encode(encoder, offset + 16, depth)?;
680 Ok(())
681 }
682 }
683
684 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
685 for RealmFactoryCreateRealmRequest
686 {
687 #[inline(always)]
688 fn new_empty() -> Self {
689 Self {
690 options: fidl::new_empty!(
691 RealmOptions,
692 fidl::encoding::DefaultFuchsiaResourceDialect
693 ),
694 realm_server: fidl::new_empty!(
695 fidl::encoding::Endpoint<
696 fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
697 >,
698 fidl::encoding::DefaultFuchsiaResourceDialect
699 ),
700 }
701 }
702
703 #[inline]
704 unsafe fn decode(
705 &mut self,
706 decoder: &mut fidl::encoding::Decoder<
707 '_,
708 fidl::encoding::DefaultFuchsiaResourceDialect,
709 >,
710 offset: usize,
711 _depth: fidl::encoding::Depth,
712 ) -> fidl::Result<()> {
713 decoder.debug_check_bounds::<Self>(offset);
714 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
716 let padval = unsafe { (ptr as *const u64).read_unaligned() };
717 let mask = 0xffffffff00000000u64;
718 let maskedval = padval & mask;
719 if maskedval != 0 {
720 return Err(fidl::Error::NonZeroPadding {
721 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
722 });
723 }
724 fidl::decode!(
725 RealmOptions,
726 fidl::encoding::DefaultFuchsiaResourceDialect,
727 &mut self.options,
728 decoder,
729 offset + 0,
730 _depth
731 )?;
732 fidl::decode!(
733 fidl::encoding::Endpoint<
734 fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
735 >,
736 fidl::encoding::DefaultFuchsiaResourceDialect,
737 &mut self.realm_server,
738 decoder,
739 offset + 16,
740 _depth
741 )?;
742 Ok(())
743 }
744 }
745
746 impl RealmOptions {
747 #[inline(always)]
748 fn max_ordinal_present(&self) -> u64 {
749 0
750 }
751 }
752
753 impl fidl::encoding::ResourceTypeMarker for RealmOptions {
754 type Borrowed<'a> = &'a mut Self;
755 fn take_or_borrow<'a>(
756 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
757 ) -> Self::Borrowed<'a> {
758 value
759 }
760 }
761
762 unsafe impl fidl::encoding::TypeMarker for RealmOptions {
763 type Owned = Self;
764
765 #[inline(always)]
766 fn inline_align(_context: fidl::encoding::Context) -> usize {
767 8
768 }
769
770 #[inline(always)]
771 fn inline_size(_context: fidl::encoding::Context) -> usize {
772 16
773 }
774 }
775
776 unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
777 for &mut RealmOptions
778 {
779 unsafe fn encode(
780 self,
781 encoder: &mut fidl::encoding::Encoder<
782 '_,
783 fidl::encoding::DefaultFuchsiaResourceDialect,
784 >,
785 offset: usize,
786 mut depth: fidl::encoding::Depth,
787 ) -> fidl::Result<()> {
788 encoder.debug_check_bounds::<RealmOptions>(offset);
789 let max_ordinal: u64 = self.max_ordinal_present();
791 encoder.write_num(max_ordinal, offset);
792 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
793 if max_ordinal == 0 {
795 return Ok(());
796 }
797 depth.increment()?;
798 let envelope_size = 8;
799 let bytes_len = max_ordinal as usize * envelope_size;
800 #[allow(unused_variables)]
801 let offset = encoder.out_of_line_offset(bytes_len);
802 let mut _prev_end_offset: usize = 0;
803
804 Ok(())
805 }
806 }
807
808 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
809 #[inline(always)]
810 fn new_empty() -> Self {
811 Self::default()
812 }
813
814 unsafe fn decode(
815 &mut self,
816 decoder: &mut fidl::encoding::Decoder<
817 '_,
818 fidl::encoding::DefaultFuchsiaResourceDialect,
819 >,
820 offset: usize,
821 mut depth: fidl::encoding::Depth,
822 ) -> fidl::Result<()> {
823 decoder.debug_check_bounds::<Self>(offset);
824 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
825 None => return Err(fidl::Error::NotNullable),
826 Some(len) => len,
827 };
828 if len == 0 {
830 return Ok(());
831 };
832 depth.increment()?;
833 let envelope_size = 8;
834 let bytes_len = len * envelope_size;
835 let offset = decoder.out_of_line_offset(bytes_len)?;
836 let mut _next_ordinal_to_read = 0;
838 let mut next_offset = offset;
839 let end_offset = offset + bytes_len;
840
841 while next_offset < end_offset {
843 _next_ordinal_to_read += 1;
844 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
845 next_offset += envelope_size;
846 }
847
848 Ok(())
849 }
850 }
851}