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