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