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