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