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