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_sampler__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct RealmFactoryCreateRealmRequest {
16 pub options: RealmOptions,
17 pub dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for RealmFactoryCreateRealmRequest
22{
23}
24
25#[derive(Debug, Default, PartialEq)]
27pub struct RealmOptions {
28 pub sampler_component_name: Option<String>,
31 pub single_counter_name: Option<String>,
34 pub fake_cobalt_name: Option<String>,
37 pub test_archivist_name: Option<String>,
40 #[doc(hidden)]
41 pub __source_breaking: fidl::marker::SourceBreaking,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {}
45
46#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
47pub struct RealmFactoryMarker;
48
49impl fidl::endpoints::ProtocolMarker for RealmFactoryMarker {
50 type Proxy = RealmFactoryProxy;
51 type RequestStream = RealmFactoryRequestStream;
52 #[cfg(target_os = "fuchsia")]
53 type SynchronousProxy = RealmFactorySynchronousProxy;
54
55 const DEBUG_NAME: &'static str = "test.sampler.RealmFactory";
56}
57impl fidl::endpoints::DiscoverableProtocolMarker for RealmFactoryMarker {}
58pub type RealmFactoryCreateRealmResult = Result<(), fidl_fuchsia_testing_harness::OperationError>;
59
60pub trait RealmFactoryProxyInterface: Send + Sync {
61 type CreateRealmResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealmResult, fidl::Error>>
62 + Send;
63 fn r#create_realm(
64 &self,
65 options: RealmOptions,
66 dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
67 ) -> Self::CreateRealmResponseFut;
68}
69#[derive(Debug)]
70#[cfg(target_os = "fuchsia")]
71pub struct RealmFactorySynchronousProxy {
72 client: fidl::client::sync::Client,
73}
74
75#[cfg(target_os = "fuchsia")]
76impl fidl::endpoints::SynchronousProxy for RealmFactorySynchronousProxy {
77 type Proxy = RealmFactoryProxy;
78 type Protocol = RealmFactoryMarker;
79
80 fn from_channel(inner: fidl::Channel) -> Self {
81 Self::new(inner)
82 }
83
84 fn into_channel(self) -> fidl::Channel {
85 self.client.into_channel()
86 }
87
88 fn as_channel(&self) -> &fidl::Channel {
89 self.client.as_channel()
90 }
91}
92
93#[cfg(target_os = "fuchsia")]
94impl RealmFactorySynchronousProxy {
95 pub fn new(channel: fidl::Channel) -> Self {
96 let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
97 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
98 }
99
100 pub fn into_channel(self) -> fidl::Channel {
101 self.client.into_channel()
102 }
103
104 pub fn wait_for_event(
107 &self,
108 deadline: zx::MonotonicInstant,
109 ) -> Result<RealmFactoryEvent, fidl::Error> {
110 RealmFactoryEvent::decode(self.client.wait_for_event(deadline)?)
111 }
112
113 pub fn r#create_realm(
117 &self,
118 mut options: RealmOptions,
119 mut dictionary: fidl::endpoints::ServerEnd<
120 fidl_fuchsia_component_sandbox::DictionaryMarker,
121 >,
122 ___deadline: zx::MonotonicInstant,
123 ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
124 let _response = self
125 .client
126 .send_query::<RealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
127 fidl::encoding::EmptyStruct,
128 fidl_fuchsia_testing_harness::OperationError,
129 >>(
130 (&mut options, dictionary),
131 0x3c060dc24a5d0788,
132 fidl::encoding::DynamicFlags::FLEXIBLE,
133 ___deadline,
134 )?
135 .into_result::<RealmFactoryMarker>("create_realm")?;
136 Ok(_response.map(|x| x))
137 }
138}
139
140#[cfg(target_os = "fuchsia")]
141impl From<RealmFactorySynchronousProxy> for zx::NullableHandle {
142 fn from(value: RealmFactorySynchronousProxy) -> Self {
143 value.into_channel().into()
144 }
145}
146
147#[cfg(target_os = "fuchsia")]
148impl From<fidl::Channel> for RealmFactorySynchronousProxy {
149 fn from(value: fidl::Channel) -> Self {
150 Self::new(value)
151 }
152}
153
154#[cfg(target_os = "fuchsia")]
155impl fidl::endpoints::FromClient for RealmFactorySynchronousProxy {
156 type Protocol = RealmFactoryMarker;
157
158 fn from_client(value: fidl::endpoints::ClientEnd<RealmFactoryMarker>) -> Self {
159 Self::new(value.into_channel())
160 }
161}
162
163#[derive(Debug, Clone)]
164pub struct RealmFactoryProxy {
165 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
166}
167
168impl fidl::endpoints::Proxy for RealmFactoryProxy {
169 type Protocol = RealmFactoryMarker;
170
171 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
172 Self::new(inner)
173 }
174
175 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
176 self.client.into_channel().map_err(|client| Self { client })
177 }
178
179 fn as_channel(&self) -> &::fidl::AsyncChannel {
180 self.client.as_channel()
181 }
182}
183
184impl RealmFactoryProxy {
185 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
187 let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
188 Self { client: fidl::client::Client::new(channel, protocol_name) }
189 }
190
191 pub fn take_event_stream(&self) -> RealmFactoryEventStream {
197 RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
198 }
199
200 pub fn r#create_realm(
204 &self,
205 mut options: RealmOptions,
206 mut dictionary: fidl::endpoints::ServerEnd<
207 fidl_fuchsia_component_sandbox::DictionaryMarker,
208 >,
209 ) -> fidl::client::QueryResponseFut<
210 RealmFactoryCreateRealmResult,
211 fidl::encoding::DefaultFuchsiaResourceDialect,
212 > {
213 RealmFactoryProxyInterface::r#create_realm(self, options, dictionary)
214 }
215}
216
217impl RealmFactoryProxyInterface for RealmFactoryProxy {
218 type CreateRealmResponseFut = fidl::client::QueryResponseFut<
219 RealmFactoryCreateRealmResult,
220 fidl::encoding::DefaultFuchsiaResourceDialect,
221 >;
222 fn r#create_realm(
223 &self,
224 mut options: RealmOptions,
225 mut dictionary: fidl::endpoints::ServerEnd<
226 fidl_fuchsia_component_sandbox::DictionaryMarker,
227 >,
228 ) -> Self::CreateRealmResponseFut {
229 fn _decode(
230 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
231 ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
232 let _response = fidl::client::decode_transaction_body::<
233 fidl::encoding::FlexibleResultType<
234 fidl::encoding::EmptyStruct,
235 fidl_fuchsia_testing_harness::OperationError,
236 >,
237 fidl::encoding::DefaultFuchsiaResourceDialect,
238 0x3c060dc24a5d0788,
239 >(_buf?)?
240 .into_result::<RealmFactoryMarker>("create_realm")?;
241 Ok(_response.map(|x| x))
242 }
243 self.client
244 .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
245 (&mut options, dictionary),
246 0x3c060dc24a5d0788,
247 fidl::encoding::DynamicFlags::FLEXIBLE,
248 _decode,
249 )
250 }
251}
252
253pub struct RealmFactoryEventStream {
254 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
255}
256
257impl std::marker::Unpin for RealmFactoryEventStream {}
258
259impl futures::stream::FusedStream for RealmFactoryEventStream {
260 fn is_terminated(&self) -> bool {
261 self.event_receiver.is_terminated()
262 }
263}
264
265impl futures::Stream for RealmFactoryEventStream {
266 type Item = Result<RealmFactoryEvent, fidl::Error>;
267
268 fn poll_next(
269 mut self: std::pin::Pin<&mut Self>,
270 cx: &mut std::task::Context<'_>,
271 ) -> std::task::Poll<Option<Self::Item>> {
272 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
273 &mut self.event_receiver,
274 cx
275 )?) {
276 Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
277 None => std::task::Poll::Ready(None),
278 }
279 }
280}
281
282#[derive(Debug)]
283pub enum RealmFactoryEvent {
284 #[non_exhaustive]
285 _UnknownEvent {
286 ordinal: u64,
288 },
289}
290
291impl RealmFactoryEvent {
292 fn decode(
294 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
295 ) -> Result<RealmFactoryEvent, fidl::Error> {
296 let (bytes, _handles) = buf.split_mut();
297 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
298 debug_assert_eq!(tx_header.tx_id, 0);
299 match tx_header.ordinal {
300 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
301 Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
302 }
303 _ => Err(fidl::Error::UnknownOrdinal {
304 ordinal: tx_header.ordinal,
305 protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
306 }),
307 }
308 }
309}
310
311pub struct RealmFactoryRequestStream {
313 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
314 is_terminated: bool,
315}
316
317impl std::marker::Unpin for RealmFactoryRequestStream {}
318
319impl futures::stream::FusedStream for RealmFactoryRequestStream {
320 fn is_terminated(&self) -> bool {
321 self.is_terminated
322 }
323}
324
325impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
326 type Protocol = RealmFactoryMarker;
327 type ControlHandle = RealmFactoryControlHandle;
328
329 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
330 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
331 }
332
333 fn control_handle(&self) -> Self::ControlHandle {
334 RealmFactoryControlHandle { inner: self.inner.clone() }
335 }
336
337 fn into_inner(
338 self,
339 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
340 {
341 (self.inner, self.is_terminated)
342 }
343
344 fn from_inner(
345 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
346 is_terminated: bool,
347 ) -> Self {
348 Self { inner, is_terminated }
349 }
350}
351
352impl futures::Stream for RealmFactoryRequestStream {
353 type Item = Result<RealmFactoryRequest, fidl::Error>;
354
355 fn poll_next(
356 mut self: std::pin::Pin<&mut Self>,
357 cx: &mut std::task::Context<'_>,
358 ) -> std::task::Poll<Option<Self::Item>> {
359 let this = &mut *self;
360 if this.inner.check_shutdown(cx) {
361 this.is_terminated = true;
362 return std::task::Poll::Ready(None);
363 }
364 if this.is_terminated {
365 panic!("polled RealmFactoryRequestStream after completion");
366 }
367 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
368 |bytes, handles| {
369 match this.inner.channel().read_etc(cx, bytes, handles) {
370 std::task::Poll::Ready(Ok(())) => {}
371 std::task::Poll::Pending => return std::task::Poll::Pending,
372 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
373 this.is_terminated = true;
374 return std::task::Poll::Ready(None);
375 }
376 std::task::Poll::Ready(Err(e)) => {
377 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
378 e.into(),
379 ))));
380 }
381 }
382
383 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
385
386 std::task::Poll::Ready(Some(match header.ordinal {
387 0x3c060dc24a5d0788 => {
388 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
389 let mut req = fidl::new_empty!(
390 RealmFactoryCreateRealmRequest,
391 fidl::encoding::DefaultFuchsiaResourceDialect
392 );
393 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
394 let control_handle =
395 RealmFactoryControlHandle { inner: this.inner.clone() };
396 Ok(RealmFactoryRequest::CreateRealm {
397 options: req.options,
398 dictionary: req.dictionary,
399
400 responder: RealmFactoryCreateRealmResponder {
401 control_handle: std::mem::ManuallyDrop::new(control_handle),
402 tx_id: header.tx_id,
403 },
404 })
405 }
406 _ if header.tx_id == 0
407 && header
408 .dynamic_flags()
409 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
410 {
411 Ok(RealmFactoryRequest::_UnknownMethod {
412 ordinal: header.ordinal,
413 control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
414 method_type: fidl::MethodType::OneWay,
415 })
416 }
417 _ if header
418 .dynamic_flags()
419 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
420 {
421 this.inner.send_framework_err(
422 fidl::encoding::FrameworkErr::UnknownMethod,
423 header.tx_id,
424 header.ordinal,
425 header.dynamic_flags(),
426 (bytes, handles),
427 )?;
428 Ok(RealmFactoryRequest::_UnknownMethod {
429 ordinal: header.ordinal,
430 control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
431 method_type: fidl::MethodType::TwoWay,
432 })
433 }
434 _ => Err(fidl::Error::UnknownOrdinal {
435 ordinal: header.ordinal,
436 protocol_name:
437 <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
438 }),
439 }))
440 },
441 )
442 }
443}
444
445#[derive(Debug)]
446pub enum RealmFactoryRequest {
447 CreateRealm {
451 options: RealmOptions,
452 dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
453 responder: RealmFactoryCreateRealmResponder,
454 },
455 #[non_exhaustive]
457 _UnknownMethod {
458 ordinal: u64,
460 control_handle: RealmFactoryControlHandle,
461 method_type: fidl::MethodType,
462 },
463}
464
465impl RealmFactoryRequest {
466 #[allow(irrefutable_let_patterns)]
467 pub fn into_create_realm(
468 self,
469 ) -> Option<(
470 RealmOptions,
471 fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
472 RealmFactoryCreateRealmResponder,
473 )> {
474 if let RealmFactoryRequest::CreateRealm { options, dictionary, responder } = self {
475 Some((options, dictionary, responder))
476 } else {
477 None
478 }
479 }
480
481 pub fn method_name(&self) -> &'static str {
483 match *self {
484 RealmFactoryRequest::CreateRealm { .. } => "create_realm",
485 RealmFactoryRequest::_UnknownMethod {
486 method_type: fidl::MethodType::OneWay, ..
487 } => "unknown one-way method",
488 RealmFactoryRequest::_UnknownMethod {
489 method_type: fidl::MethodType::TwoWay, ..
490 } => "unknown two-way method",
491 }
492 }
493}
494
495#[derive(Debug, Clone)]
496pub struct RealmFactoryControlHandle {
497 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
498}
499
500impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
501 fn shutdown(&self) {
502 self.inner.shutdown()
503 }
504
505 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
506 self.inner.shutdown_with_epitaph(status)
507 }
508
509 fn is_closed(&self) -> bool {
510 self.inner.channel().is_closed()
511 }
512 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
513 self.inner.channel().on_closed()
514 }
515
516 #[cfg(target_os = "fuchsia")]
517 fn signal_peer(
518 &self,
519 clear_mask: zx::Signals,
520 set_mask: zx::Signals,
521 ) -> Result<(), zx_status::Status> {
522 use fidl::Peered;
523 self.inner.channel().signal_peer(clear_mask, set_mask)
524 }
525}
526
527impl RealmFactoryControlHandle {}
528
529#[must_use = "FIDL methods require a response to be sent"]
530#[derive(Debug)]
531pub struct RealmFactoryCreateRealmResponder {
532 control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
533 tx_id: u32,
534}
535
536impl std::ops::Drop for RealmFactoryCreateRealmResponder {
540 fn drop(&mut self) {
541 self.control_handle.shutdown();
542 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
544 }
545}
546
547impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
548 type ControlHandle = RealmFactoryControlHandle;
549
550 fn control_handle(&self) -> &RealmFactoryControlHandle {
551 &self.control_handle
552 }
553
554 fn drop_without_shutdown(mut self) {
555 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
557 std::mem::forget(self);
559 }
560}
561
562impl RealmFactoryCreateRealmResponder {
563 pub fn send(
567 self,
568 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
569 ) -> Result<(), fidl::Error> {
570 let _result = self.send_raw(result);
571 if _result.is_err() {
572 self.control_handle.shutdown();
573 }
574 self.drop_without_shutdown();
575 _result
576 }
577
578 pub fn send_no_shutdown_on_err(
580 self,
581 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
582 ) -> Result<(), fidl::Error> {
583 let _result = self.send_raw(result);
584 self.drop_without_shutdown();
585 _result
586 }
587
588 fn send_raw(
589 &self,
590 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
591 ) -> Result<(), fidl::Error> {
592 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
593 fidl::encoding::EmptyStruct,
594 fidl_fuchsia_testing_harness::OperationError,
595 >>(
596 fidl::encoding::FlexibleResult::new(result),
597 self.tx_id,
598 0x3c060dc24a5d0788,
599 fidl::encoding::DynamicFlags::FLEXIBLE,
600 )
601 }
602}
603
604mod internal {
605 use super::*;
606
607 impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
608 type Borrowed<'a> = &'a mut Self;
609 fn take_or_borrow<'a>(
610 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
611 ) -> Self::Borrowed<'a> {
612 value
613 }
614 }
615
616 unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
617 type Owned = Self;
618
619 #[inline(always)]
620 fn inline_align(_context: fidl::encoding::Context) -> usize {
621 8
622 }
623
624 #[inline(always)]
625 fn inline_size(_context: fidl::encoding::Context) -> usize {
626 24
627 }
628 }
629
630 unsafe impl
631 fidl::encoding::Encode<
632 RealmFactoryCreateRealmRequest,
633 fidl::encoding::DefaultFuchsiaResourceDialect,
634 > for &mut RealmFactoryCreateRealmRequest
635 {
636 #[inline]
637 unsafe fn encode(
638 self,
639 encoder: &mut fidl::encoding::Encoder<
640 '_,
641 fidl::encoding::DefaultFuchsiaResourceDialect,
642 >,
643 offset: usize,
644 _depth: fidl::encoding::Depth,
645 ) -> fidl::Result<()> {
646 encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
647 fidl::encoding::Encode::<
649 RealmFactoryCreateRealmRequest,
650 fidl::encoding::DefaultFuchsiaResourceDialect,
651 >::encode(
652 (
653 <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
654 &mut self.options,
655 ),
656 <fidl::encoding::Endpoint<
657 fidl::endpoints::ServerEnd<
658 fidl_fuchsia_component_sandbox::DictionaryMarker,
659 >,
660 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
661 &mut self.dictionary
662 ),
663 ),
664 encoder,
665 offset,
666 _depth,
667 )
668 }
669 }
670 unsafe impl<
671 T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
672 T1: fidl::encoding::Encode<
673 fidl::encoding::Endpoint<
674 fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
675 >,
676 fidl::encoding::DefaultFuchsiaResourceDialect,
677 >,
678 >
679 fidl::encoding::Encode<
680 RealmFactoryCreateRealmRequest,
681 fidl::encoding::DefaultFuchsiaResourceDialect,
682 > for (T0, T1)
683 {
684 #[inline]
685 unsafe fn encode(
686 self,
687 encoder: &mut fidl::encoding::Encoder<
688 '_,
689 fidl::encoding::DefaultFuchsiaResourceDialect,
690 >,
691 offset: usize,
692 depth: fidl::encoding::Depth,
693 ) -> fidl::Result<()> {
694 encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
695 unsafe {
698 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
699 (ptr as *mut u64).write_unaligned(0);
700 }
701 self.0.encode(encoder, offset + 0, depth)?;
703 self.1.encode(encoder, offset + 16, depth)?;
704 Ok(())
705 }
706 }
707
708 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
709 for RealmFactoryCreateRealmRequest
710 {
711 #[inline(always)]
712 fn new_empty() -> Self {
713 Self {
714 options: fidl::new_empty!(
715 RealmOptions,
716 fidl::encoding::DefaultFuchsiaResourceDialect
717 ),
718 dictionary: fidl::new_empty!(
719 fidl::encoding::Endpoint<
720 fidl::endpoints::ServerEnd<
721 fidl_fuchsia_component_sandbox::DictionaryMarker,
722 >,
723 >,
724 fidl::encoding::DefaultFuchsiaResourceDialect
725 ),
726 }
727 }
728
729 #[inline]
730 unsafe fn decode(
731 &mut self,
732 decoder: &mut fidl::encoding::Decoder<
733 '_,
734 fidl::encoding::DefaultFuchsiaResourceDialect,
735 >,
736 offset: usize,
737 _depth: fidl::encoding::Depth,
738 ) -> fidl::Result<()> {
739 decoder.debug_check_bounds::<Self>(offset);
740 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
742 let padval = unsafe { (ptr as *const u64).read_unaligned() };
743 let mask = 0xffffffff00000000u64;
744 let maskedval = padval & mask;
745 if maskedval != 0 {
746 return Err(fidl::Error::NonZeroPadding {
747 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
748 });
749 }
750 fidl::decode!(
751 RealmOptions,
752 fidl::encoding::DefaultFuchsiaResourceDialect,
753 &mut self.options,
754 decoder,
755 offset + 0,
756 _depth
757 )?;
758 fidl::decode!(
759 fidl::encoding::Endpoint<
760 fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
761 >,
762 fidl::encoding::DefaultFuchsiaResourceDialect,
763 &mut self.dictionary,
764 decoder,
765 offset + 16,
766 _depth
767 )?;
768 Ok(())
769 }
770 }
771
772 impl RealmOptions {
773 #[inline(always)]
774 fn max_ordinal_present(&self) -> u64 {
775 if let Some(_) = self.test_archivist_name {
776 return 4;
777 }
778 if let Some(_) = self.fake_cobalt_name {
779 return 3;
780 }
781 if let Some(_) = self.single_counter_name {
782 return 2;
783 }
784 if let Some(_) = self.sampler_component_name {
785 return 1;
786 }
787 0
788 }
789 }
790
791 impl fidl::encoding::ResourceTypeMarker for RealmOptions {
792 type Borrowed<'a> = &'a mut Self;
793 fn take_or_borrow<'a>(
794 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
795 ) -> Self::Borrowed<'a> {
796 value
797 }
798 }
799
800 unsafe impl fidl::encoding::TypeMarker for RealmOptions {
801 type Owned = Self;
802
803 #[inline(always)]
804 fn inline_align(_context: fidl::encoding::Context) -> usize {
805 8
806 }
807
808 #[inline(always)]
809 fn inline_size(_context: fidl::encoding::Context) -> usize {
810 16
811 }
812 }
813
814 unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
815 for &mut RealmOptions
816 {
817 unsafe fn encode(
818 self,
819 encoder: &mut fidl::encoding::Encoder<
820 '_,
821 fidl::encoding::DefaultFuchsiaResourceDialect,
822 >,
823 offset: usize,
824 mut depth: fidl::encoding::Depth,
825 ) -> fidl::Result<()> {
826 encoder.debug_check_bounds::<RealmOptions>(offset);
827 let max_ordinal: u64 = self.max_ordinal_present();
829 encoder.write_num(max_ordinal, offset);
830 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
831 if max_ordinal == 0 {
833 return Ok(());
834 }
835 depth.increment()?;
836 let envelope_size = 8;
837 let bytes_len = max_ordinal as usize * envelope_size;
838 #[allow(unused_variables)]
839 let offset = encoder.out_of_line_offset(bytes_len);
840 let mut _prev_end_offset: usize = 0;
841 if 1 > max_ordinal {
842 return Ok(());
843 }
844
845 let cur_offset: usize = (1 - 1) * envelope_size;
848
849 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
851
852 fidl::encoding::encode_in_envelope_optional::<
857 fidl::encoding::UnboundedString,
858 fidl::encoding::DefaultFuchsiaResourceDialect,
859 >(
860 self.sampler_component_name.as_ref().map(
861 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
862 ),
863 encoder,
864 offset + cur_offset,
865 depth,
866 )?;
867
868 _prev_end_offset = cur_offset + envelope_size;
869 if 2 > max_ordinal {
870 return Ok(());
871 }
872
873 let cur_offset: usize = (2 - 1) * envelope_size;
876
877 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
879
880 fidl::encoding::encode_in_envelope_optional::<
885 fidl::encoding::UnboundedString,
886 fidl::encoding::DefaultFuchsiaResourceDialect,
887 >(
888 self.single_counter_name.as_ref().map(
889 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
890 ),
891 encoder,
892 offset + cur_offset,
893 depth,
894 )?;
895
896 _prev_end_offset = cur_offset + envelope_size;
897 if 3 > max_ordinal {
898 return Ok(());
899 }
900
901 let cur_offset: usize = (3 - 1) * envelope_size;
904
905 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
907
908 fidl::encoding::encode_in_envelope_optional::<
913 fidl::encoding::UnboundedString,
914 fidl::encoding::DefaultFuchsiaResourceDialect,
915 >(
916 self.fake_cobalt_name.as_ref().map(
917 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
918 ),
919 encoder,
920 offset + cur_offset,
921 depth,
922 )?;
923
924 _prev_end_offset = cur_offset + envelope_size;
925 if 4 > max_ordinal {
926 return Ok(());
927 }
928
929 let cur_offset: usize = (4 - 1) * envelope_size;
932
933 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
935
936 fidl::encoding::encode_in_envelope_optional::<
941 fidl::encoding::UnboundedString,
942 fidl::encoding::DefaultFuchsiaResourceDialect,
943 >(
944 self.test_archivist_name.as_ref().map(
945 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
946 ),
947 encoder,
948 offset + cur_offset,
949 depth,
950 )?;
951
952 _prev_end_offset = cur_offset + envelope_size;
953
954 Ok(())
955 }
956 }
957
958 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
959 #[inline(always)]
960 fn new_empty() -> Self {
961 Self::default()
962 }
963
964 unsafe fn decode(
965 &mut self,
966 decoder: &mut fidl::encoding::Decoder<
967 '_,
968 fidl::encoding::DefaultFuchsiaResourceDialect,
969 >,
970 offset: usize,
971 mut depth: fidl::encoding::Depth,
972 ) -> fidl::Result<()> {
973 decoder.debug_check_bounds::<Self>(offset);
974 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
975 None => return Err(fidl::Error::NotNullable),
976 Some(len) => len,
977 };
978 if len == 0 {
980 return Ok(());
981 };
982 depth.increment()?;
983 let envelope_size = 8;
984 let bytes_len = len * envelope_size;
985 let offset = decoder.out_of_line_offset(bytes_len)?;
986 let mut _next_ordinal_to_read = 0;
988 let mut next_offset = offset;
989 let end_offset = offset + bytes_len;
990 _next_ordinal_to_read += 1;
991 if next_offset >= end_offset {
992 return Ok(());
993 }
994
995 while _next_ordinal_to_read < 1 {
997 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
998 _next_ordinal_to_read += 1;
999 next_offset += envelope_size;
1000 }
1001
1002 let next_out_of_line = decoder.next_out_of_line();
1003 let handles_before = decoder.remaining_handles();
1004 if let Some((inlined, num_bytes, num_handles)) =
1005 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1006 {
1007 let member_inline_size =
1008 <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1009 decoder.context,
1010 );
1011 if inlined != (member_inline_size <= 4) {
1012 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1013 }
1014 let inner_offset;
1015 let mut inner_depth = depth.clone();
1016 if inlined {
1017 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1018 inner_offset = next_offset;
1019 } else {
1020 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1021 inner_depth.increment()?;
1022 }
1023 let val_ref = self.sampler_component_name.get_or_insert_with(|| {
1024 fidl::new_empty!(
1025 fidl::encoding::UnboundedString,
1026 fidl::encoding::DefaultFuchsiaResourceDialect
1027 )
1028 });
1029 fidl::decode!(
1030 fidl::encoding::UnboundedString,
1031 fidl::encoding::DefaultFuchsiaResourceDialect,
1032 val_ref,
1033 decoder,
1034 inner_offset,
1035 inner_depth
1036 )?;
1037 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1038 {
1039 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1040 }
1041 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1042 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1043 }
1044 }
1045
1046 next_offset += envelope_size;
1047 _next_ordinal_to_read += 1;
1048 if next_offset >= end_offset {
1049 return Ok(());
1050 }
1051
1052 while _next_ordinal_to_read < 2 {
1054 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1055 _next_ordinal_to_read += 1;
1056 next_offset += envelope_size;
1057 }
1058
1059 let next_out_of_line = decoder.next_out_of_line();
1060 let handles_before = decoder.remaining_handles();
1061 if let Some((inlined, num_bytes, num_handles)) =
1062 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1063 {
1064 let member_inline_size =
1065 <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1066 decoder.context,
1067 );
1068 if inlined != (member_inline_size <= 4) {
1069 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1070 }
1071 let inner_offset;
1072 let mut inner_depth = depth.clone();
1073 if inlined {
1074 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1075 inner_offset = next_offset;
1076 } else {
1077 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1078 inner_depth.increment()?;
1079 }
1080 let val_ref = self.single_counter_name.get_or_insert_with(|| {
1081 fidl::new_empty!(
1082 fidl::encoding::UnboundedString,
1083 fidl::encoding::DefaultFuchsiaResourceDialect
1084 )
1085 });
1086 fidl::decode!(
1087 fidl::encoding::UnboundedString,
1088 fidl::encoding::DefaultFuchsiaResourceDialect,
1089 val_ref,
1090 decoder,
1091 inner_offset,
1092 inner_depth
1093 )?;
1094 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1095 {
1096 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1097 }
1098 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1099 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1100 }
1101 }
1102
1103 next_offset += envelope_size;
1104 _next_ordinal_to_read += 1;
1105 if next_offset >= end_offset {
1106 return Ok(());
1107 }
1108
1109 while _next_ordinal_to_read < 3 {
1111 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1112 _next_ordinal_to_read += 1;
1113 next_offset += envelope_size;
1114 }
1115
1116 let next_out_of_line = decoder.next_out_of_line();
1117 let handles_before = decoder.remaining_handles();
1118 if let Some((inlined, num_bytes, num_handles)) =
1119 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1120 {
1121 let member_inline_size =
1122 <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1123 decoder.context,
1124 );
1125 if inlined != (member_inline_size <= 4) {
1126 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1127 }
1128 let inner_offset;
1129 let mut inner_depth = depth.clone();
1130 if inlined {
1131 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1132 inner_offset = next_offset;
1133 } else {
1134 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1135 inner_depth.increment()?;
1136 }
1137 let val_ref = self.fake_cobalt_name.get_or_insert_with(|| {
1138 fidl::new_empty!(
1139 fidl::encoding::UnboundedString,
1140 fidl::encoding::DefaultFuchsiaResourceDialect
1141 )
1142 });
1143 fidl::decode!(
1144 fidl::encoding::UnboundedString,
1145 fidl::encoding::DefaultFuchsiaResourceDialect,
1146 val_ref,
1147 decoder,
1148 inner_offset,
1149 inner_depth
1150 )?;
1151 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1152 {
1153 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1154 }
1155 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1156 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1157 }
1158 }
1159
1160 next_offset += envelope_size;
1161 _next_ordinal_to_read += 1;
1162 if next_offset >= end_offset {
1163 return Ok(());
1164 }
1165
1166 while _next_ordinal_to_read < 4 {
1168 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1169 _next_ordinal_to_read += 1;
1170 next_offset += envelope_size;
1171 }
1172
1173 let next_out_of_line = decoder.next_out_of_line();
1174 let handles_before = decoder.remaining_handles();
1175 if let Some((inlined, num_bytes, num_handles)) =
1176 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1177 {
1178 let member_inline_size =
1179 <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1180 decoder.context,
1181 );
1182 if inlined != (member_inline_size <= 4) {
1183 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1184 }
1185 let inner_offset;
1186 let mut inner_depth = depth.clone();
1187 if inlined {
1188 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1189 inner_offset = next_offset;
1190 } else {
1191 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1192 inner_depth.increment()?;
1193 }
1194 let val_ref = self.test_archivist_name.get_or_insert_with(|| {
1195 fidl::new_empty!(
1196 fidl::encoding::UnboundedString,
1197 fidl::encoding::DefaultFuchsiaResourceDialect
1198 )
1199 });
1200 fidl::decode!(
1201 fidl::encoding::UnboundedString,
1202 fidl::encoding::DefaultFuchsiaResourceDialect,
1203 val_ref,
1204 decoder,
1205 inner_offset,
1206 inner_depth
1207 )?;
1208 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1209 {
1210 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1211 }
1212 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1213 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1214 }
1215 }
1216
1217 next_offset += envelope_size;
1218
1219 while next_offset < end_offset {
1221 _next_ordinal_to_read += 1;
1222 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1223 next_offset += envelope_size;
1224 }
1225
1226 Ok(())
1227 }
1228 }
1229}