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