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_fuchsia_trf_factory_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FactoryCreateRealmResponse {
16 pub realm: fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for FactoryCreateRealmResponse
22{
23}
24
25#[derive(Debug, Default, PartialEq)]
27pub struct CreateRealmRequest {
28 pub overrides: Option<Vec<ConfigOverride>>,
30 #[doc(hidden)]
31 pub __source_breaking: fidl::marker::SourceBreaking,
32}
33
34impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CreateRealmRequest {}
35
36#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
37pub struct FactoryMarker;
38
39impl fidl::endpoints::ProtocolMarker for FactoryMarker {
40 type Proxy = FactoryProxy;
41 type RequestStream = FactoryRequestStream;
42 #[cfg(target_os = "fuchsia")]
43 type SynchronousProxy = FactorySynchronousProxy;
44
45 const DEBUG_NAME: &'static str = "fuchsia.trf.factory.Factory";
46}
47impl fidl::endpoints::DiscoverableProtocolMarker for FactoryMarker {}
48pub type FactoryCreateRealmResult = Result<
49 fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
50 fidl_fuchsia_testing_harness::OperationError,
51>;
52
53pub trait FactoryProxyInterface: Send + Sync {
54 type CreateRealmResponseFut: std::future::Future<Output = Result<FactoryCreateRealmResult, fidl::Error>>
55 + Send;
56 fn r#create_realm(&self, payload: CreateRealmRequest) -> Self::CreateRealmResponseFut;
57}
58#[derive(Debug)]
59#[cfg(target_os = "fuchsia")]
60pub struct FactorySynchronousProxy {
61 client: fidl::client::sync::Client,
62}
63
64#[cfg(target_os = "fuchsia")]
65impl fidl::endpoints::SynchronousProxy for FactorySynchronousProxy {
66 type Proxy = FactoryProxy;
67 type Protocol = FactoryMarker;
68
69 fn from_channel(inner: fidl::Channel) -> Self {
70 Self::new(inner)
71 }
72
73 fn into_channel(self) -> fidl::Channel {
74 self.client.into_channel()
75 }
76
77 fn as_channel(&self) -> &fidl::Channel {
78 self.client.as_channel()
79 }
80}
81
82#[cfg(target_os = "fuchsia")]
83impl FactorySynchronousProxy {
84 pub fn new(channel: fidl::Channel) -> Self {
85 Self { client: fidl::client::sync::Client::new(channel) }
86 }
87
88 pub fn into_channel(self) -> fidl::Channel {
89 self.client.into_channel()
90 }
91
92 pub fn wait_for_event(
95 &self,
96 deadline: zx::MonotonicInstant,
97 ) -> Result<FactoryEvent, fidl::Error> {
98 FactoryEvent::decode(self.client.wait_for_event::<FactoryMarker>(deadline)?)
99 }
100
101 pub fn r#create_realm(
104 &self,
105 mut payload: CreateRealmRequest,
106 ___deadline: zx::MonotonicInstant,
107 ) -> Result<FactoryCreateRealmResult, fidl::Error> {
108 let _response = self
109 .client
110 .send_query::<CreateRealmRequest, fidl::encoding::FlexibleResultType<
111 FactoryCreateRealmResponse,
112 fidl_fuchsia_testing_harness::OperationError,
113 >, FactoryMarker>(
114 &mut payload,
115 0x6fc9625bf736d437,
116 fidl::encoding::DynamicFlags::FLEXIBLE,
117 ___deadline,
118 )?
119 .into_result::<FactoryMarker>("create_realm")?;
120 Ok(_response.map(|x| x.realm))
121 }
122}
123
124#[cfg(target_os = "fuchsia")]
125impl From<FactorySynchronousProxy> for zx::NullableHandle {
126 fn from(value: FactorySynchronousProxy) -> Self {
127 value.into_channel().into()
128 }
129}
130
131#[cfg(target_os = "fuchsia")]
132impl From<fidl::Channel> for FactorySynchronousProxy {
133 fn from(value: fidl::Channel) -> Self {
134 Self::new(value)
135 }
136}
137
138#[cfg(target_os = "fuchsia")]
139impl fidl::endpoints::FromClient for FactorySynchronousProxy {
140 type Protocol = FactoryMarker;
141
142 fn from_client(value: fidl::endpoints::ClientEnd<FactoryMarker>) -> Self {
143 Self::new(value.into_channel())
144 }
145}
146
147#[derive(Debug, Clone)]
148pub struct FactoryProxy {
149 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
150}
151
152impl fidl::endpoints::Proxy for FactoryProxy {
153 type Protocol = FactoryMarker;
154
155 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
156 Self::new(inner)
157 }
158
159 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
160 self.client.into_channel().map_err(|client| Self { client })
161 }
162
163 fn as_channel(&self) -> &::fidl::AsyncChannel {
164 self.client.as_channel()
165 }
166}
167
168impl FactoryProxy {
169 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
171 let protocol_name = <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
172 Self { client: fidl::client::Client::new(channel, protocol_name) }
173 }
174
175 pub fn take_event_stream(&self) -> FactoryEventStream {
181 FactoryEventStream { event_receiver: self.client.take_event_receiver() }
182 }
183
184 pub fn r#create_realm(
187 &self,
188 mut payload: CreateRealmRequest,
189 ) -> fidl::client::QueryResponseFut<
190 FactoryCreateRealmResult,
191 fidl::encoding::DefaultFuchsiaResourceDialect,
192 > {
193 FactoryProxyInterface::r#create_realm(self, payload)
194 }
195}
196
197impl FactoryProxyInterface for FactoryProxy {
198 type CreateRealmResponseFut = fidl::client::QueryResponseFut<
199 FactoryCreateRealmResult,
200 fidl::encoding::DefaultFuchsiaResourceDialect,
201 >;
202 fn r#create_realm(&self, mut payload: CreateRealmRequest) -> Self::CreateRealmResponseFut {
203 fn _decode(
204 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
205 ) -> Result<FactoryCreateRealmResult, fidl::Error> {
206 let _response = fidl::client::decode_transaction_body::<
207 fidl::encoding::FlexibleResultType<
208 FactoryCreateRealmResponse,
209 fidl_fuchsia_testing_harness::OperationError,
210 >,
211 fidl::encoding::DefaultFuchsiaResourceDialect,
212 0x6fc9625bf736d437,
213 >(_buf?)?
214 .into_result::<FactoryMarker>("create_realm")?;
215 Ok(_response.map(|x| x.realm))
216 }
217 self.client.send_query_and_decode::<CreateRealmRequest, FactoryCreateRealmResult>(
218 &mut payload,
219 0x6fc9625bf736d437,
220 fidl::encoding::DynamicFlags::FLEXIBLE,
221 _decode,
222 )
223 }
224}
225
226pub struct FactoryEventStream {
227 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
228}
229
230impl std::marker::Unpin for FactoryEventStream {}
231
232impl futures::stream::FusedStream for FactoryEventStream {
233 fn is_terminated(&self) -> bool {
234 self.event_receiver.is_terminated()
235 }
236}
237
238impl futures::Stream for FactoryEventStream {
239 type Item = Result<FactoryEvent, fidl::Error>;
240
241 fn poll_next(
242 mut self: std::pin::Pin<&mut Self>,
243 cx: &mut std::task::Context<'_>,
244 ) -> std::task::Poll<Option<Self::Item>> {
245 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
246 &mut self.event_receiver,
247 cx
248 )?) {
249 Some(buf) => std::task::Poll::Ready(Some(FactoryEvent::decode(buf))),
250 None => std::task::Poll::Ready(None),
251 }
252 }
253}
254
255#[derive(Debug)]
256pub enum FactoryEvent {
257 #[non_exhaustive]
258 _UnknownEvent {
259 ordinal: u64,
261 },
262}
263
264impl FactoryEvent {
265 fn decode(
267 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
268 ) -> Result<FactoryEvent, fidl::Error> {
269 let (bytes, _handles) = buf.split_mut();
270 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
271 debug_assert_eq!(tx_header.tx_id, 0);
272 match tx_header.ordinal {
273 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
274 Ok(FactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
275 }
276 _ => Err(fidl::Error::UnknownOrdinal {
277 ordinal: tx_header.ordinal,
278 protocol_name: <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
279 }),
280 }
281 }
282}
283
284pub struct FactoryRequestStream {
286 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
287 is_terminated: bool,
288}
289
290impl std::marker::Unpin for FactoryRequestStream {}
291
292impl futures::stream::FusedStream for FactoryRequestStream {
293 fn is_terminated(&self) -> bool {
294 self.is_terminated
295 }
296}
297
298impl fidl::endpoints::RequestStream for FactoryRequestStream {
299 type Protocol = FactoryMarker;
300 type ControlHandle = FactoryControlHandle;
301
302 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
303 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
304 }
305
306 fn control_handle(&self) -> Self::ControlHandle {
307 FactoryControlHandle { inner: self.inner.clone() }
308 }
309
310 fn into_inner(
311 self,
312 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
313 {
314 (self.inner, self.is_terminated)
315 }
316
317 fn from_inner(
318 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
319 is_terminated: bool,
320 ) -> Self {
321 Self { inner, is_terminated }
322 }
323}
324
325impl futures::Stream for FactoryRequestStream {
326 type Item = Result<FactoryRequest, fidl::Error>;
327
328 fn poll_next(
329 mut self: std::pin::Pin<&mut Self>,
330 cx: &mut std::task::Context<'_>,
331 ) -> std::task::Poll<Option<Self::Item>> {
332 let this = &mut *self;
333 if this.inner.check_shutdown(cx) {
334 this.is_terminated = true;
335 return std::task::Poll::Ready(None);
336 }
337 if this.is_terminated {
338 panic!("polled FactoryRequestStream after completion");
339 }
340 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
341 |bytes, handles| {
342 match this.inner.channel().read_etc(cx, bytes, handles) {
343 std::task::Poll::Ready(Ok(())) => {}
344 std::task::Poll::Pending => return std::task::Poll::Pending,
345 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
346 this.is_terminated = true;
347 return std::task::Poll::Ready(None);
348 }
349 std::task::Poll::Ready(Err(e)) => {
350 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
351 e.into(),
352 ))));
353 }
354 }
355
356 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
358
359 std::task::Poll::Ready(Some(match header.ordinal {
360 0x6fc9625bf736d437 => {
361 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
362 let mut req = fidl::new_empty!(
363 CreateRealmRequest,
364 fidl::encoding::DefaultFuchsiaResourceDialect
365 );
366 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
367 let control_handle = FactoryControlHandle { inner: this.inner.clone() };
368 Ok(FactoryRequest::CreateRealm {
369 payload: req,
370 responder: FactoryCreateRealmResponder {
371 control_handle: std::mem::ManuallyDrop::new(control_handle),
372 tx_id: header.tx_id,
373 },
374 })
375 }
376 _ if header.tx_id == 0
377 && header
378 .dynamic_flags()
379 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
380 {
381 Ok(FactoryRequest::_UnknownMethod {
382 ordinal: header.ordinal,
383 control_handle: FactoryControlHandle { inner: this.inner.clone() },
384 method_type: fidl::MethodType::OneWay,
385 })
386 }
387 _ if header
388 .dynamic_flags()
389 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
390 {
391 this.inner.send_framework_err(
392 fidl::encoding::FrameworkErr::UnknownMethod,
393 header.tx_id,
394 header.ordinal,
395 header.dynamic_flags(),
396 (bytes, handles),
397 )?;
398 Ok(FactoryRequest::_UnknownMethod {
399 ordinal: header.ordinal,
400 control_handle: FactoryControlHandle { inner: this.inner.clone() },
401 method_type: fidl::MethodType::TwoWay,
402 })
403 }
404 _ => Err(fidl::Error::UnknownOrdinal {
405 ordinal: header.ordinal,
406 protocol_name:
407 <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
408 }),
409 }))
410 },
411 )
412 }
413}
414
415#[derive(Debug)]
418pub enum FactoryRequest {
419 CreateRealm { payload: CreateRealmRequest, responder: FactoryCreateRealmResponder },
422 #[non_exhaustive]
424 _UnknownMethod {
425 ordinal: u64,
427 control_handle: FactoryControlHandle,
428 method_type: fidl::MethodType,
429 },
430}
431
432impl FactoryRequest {
433 #[allow(irrefutable_let_patterns)]
434 pub fn into_create_realm(self) -> Option<(CreateRealmRequest, FactoryCreateRealmResponder)> {
435 if let FactoryRequest::CreateRealm { payload, responder } = self {
436 Some((payload, responder))
437 } else {
438 None
439 }
440 }
441
442 pub fn method_name(&self) -> &'static str {
444 match *self {
445 FactoryRequest::CreateRealm { .. } => "create_realm",
446 FactoryRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
447 "unknown one-way method"
448 }
449 FactoryRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
450 "unknown two-way method"
451 }
452 }
453 }
454}
455
456#[derive(Debug, Clone)]
457pub struct FactoryControlHandle {
458 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
459}
460
461impl FactoryControlHandle {
462 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
463 self.inner.shutdown_with_epitaph(status.into())
464 }
465}
466
467impl fidl::endpoints::ControlHandle for FactoryControlHandle {
468 fn shutdown(&self) {
469 self.inner.shutdown()
470 }
471
472 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
473 self.inner.shutdown_with_epitaph(status)
474 }
475
476 fn is_closed(&self) -> bool {
477 self.inner.channel().is_closed()
478 }
479 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
480 self.inner.channel().on_closed()
481 }
482
483 #[cfg(target_os = "fuchsia")]
484 fn signal_peer(
485 &self,
486 clear_mask: zx::Signals,
487 set_mask: zx::Signals,
488 ) -> Result<(), zx_status::Status> {
489 use fidl::Peered;
490 self.inner.channel().signal_peer(clear_mask, set_mask)
491 }
492}
493
494impl FactoryControlHandle {}
495
496#[must_use = "FIDL methods require a response to be sent"]
497#[derive(Debug)]
498pub struct FactoryCreateRealmResponder {
499 control_handle: std::mem::ManuallyDrop<FactoryControlHandle>,
500 tx_id: u32,
501}
502
503impl std::ops::Drop for FactoryCreateRealmResponder {
507 fn drop(&mut self) {
508 self.control_handle.shutdown();
509 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
511 }
512}
513
514impl fidl::endpoints::Responder for FactoryCreateRealmResponder {
515 type ControlHandle = FactoryControlHandle;
516
517 fn control_handle(&self) -> &FactoryControlHandle {
518 &self.control_handle
519 }
520
521 fn drop_without_shutdown(mut self) {
522 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
524 std::mem::forget(self);
526 }
527}
528
529impl FactoryCreateRealmResponder {
530 pub fn send(
534 self,
535 mut result: Result<
536 fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
537 fidl_fuchsia_testing_harness::OperationError,
538 >,
539 ) -> Result<(), fidl::Error> {
540 let _result = self.send_raw(result);
541 if _result.is_err() {
542 self.control_handle.shutdown();
543 }
544 self.drop_without_shutdown();
545 _result
546 }
547
548 pub fn send_no_shutdown_on_err(
550 self,
551 mut result: Result<
552 fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
553 fidl_fuchsia_testing_harness::OperationError,
554 >,
555 ) -> Result<(), fidl::Error> {
556 let _result = self.send_raw(result);
557 self.drop_without_shutdown();
558 _result
559 }
560
561 fn send_raw(
562 &self,
563 mut result: Result<
564 fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
565 fidl_fuchsia_testing_harness::OperationError,
566 >,
567 ) -> Result<(), fidl::Error> {
568 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
569 FactoryCreateRealmResponse,
570 fidl_fuchsia_testing_harness::OperationError,
571 >>(
572 fidl::encoding::FlexibleResult::new(result.map(|realm| (realm,))),
573 self.tx_id,
574 0x6fc9625bf736d437,
575 fidl::encoding::DynamicFlags::FLEXIBLE,
576 )
577 }
578}
579
580mod internal {
581 use super::*;
582
583 impl fidl::encoding::ResourceTypeMarker for FactoryCreateRealmResponse {
584 type Borrowed<'a> = &'a mut Self;
585 fn take_or_borrow<'a>(
586 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
587 ) -> Self::Borrowed<'a> {
588 value
589 }
590 }
591
592 unsafe impl fidl::encoding::TypeMarker for FactoryCreateRealmResponse {
593 type Owned = Self;
594
595 #[inline(always)]
596 fn inline_align(_context: fidl::encoding::Context) -> usize {
597 4
598 }
599
600 #[inline(always)]
601 fn inline_size(_context: fidl::encoding::Context) -> usize {
602 4
603 }
604 }
605
606 unsafe impl
607 fidl::encoding::Encode<
608 FactoryCreateRealmResponse,
609 fidl::encoding::DefaultFuchsiaResourceDialect,
610 > for &mut FactoryCreateRealmResponse
611 {
612 #[inline]
613 unsafe fn encode(
614 self,
615 encoder: &mut fidl::encoding::Encoder<
616 '_,
617 fidl::encoding::DefaultFuchsiaResourceDialect,
618 >,
619 offset: usize,
620 _depth: fidl::encoding::Depth,
621 ) -> fidl::Result<()> {
622 encoder.debug_check_bounds::<FactoryCreateRealmResponse>(offset);
623 fidl::encoding::Encode::<
625 FactoryCreateRealmResponse,
626 fidl::encoding::DefaultFuchsiaResourceDialect,
627 >::encode(
628 (<fidl::encoding::Endpoint<
629 fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
630 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
631 &mut self.realm
632 ),),
633 encoder,
634 offset,
635 _depth,
636 )
637 }
638 }
639 unsafe impl<
640 T0: fidl::encoding::Encode<
641 fidl::encoding::Endpoint<
642 fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
643 >,
644 fidl::encoding::DefaultFuchsiaResourceDialect,
645 >,
646 >
647 fidl::encoding::Encode<
648 FactoryCreateRealmResponse,
649 fidl::encoding::DefaultFuchsiaResourceDialect,
650 > for (T0,)
651 {
652 #[inline]
653 unsafe fn encode(
654 self,
655 encoder: &mut fidl::encoding::Encoder<
656 '_,
657 fidl::encoding::DefaultFuchsiaResourceDialect,
658 >,
659 offset: usize,
660 depth: fidl::encoding::Depth,
661 ) -> fidl::Result<()> {
662 encoder.debug_check_bounds::<FactoryCreateRealmResponse>(offset);
663 self.0.encode(encoder, offset + 0, depth)?;
667 Ok(())
668 }
669 }
670
671 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
672 for FactoryCreateRealmResponse
673 {
674 #[inline(always)]
675 fn new_empty() -> Self {
676 Self {
677 realm: fidl::new_empty!(
678 fidl::encoding::Endpoint<
679 fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
680 >,
681 fidl::encoding::DefaultFuchsiaResourceDialect
682 ),
683 }
684 }
685
686 #[inline]
687 unsafe fn decode(
688 &mut self,
689 decoder: &mut fidl::encoding::Decoder<
690 '_,
691 fidl::encoding::DefaultFuchsiaResourceDialect,
692 >,
693 offset: usize,
694 _depth: fidl::encoding::Depth,
695 ) -> fidl::Result<()> {
696 decoder.debug_check_bounds::<Self>(offset);
697 fidl::decode!(
699 fidl::encoding::Endpoint<
700 fidl::endpoints::ClientEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
701 >,
702 fidl::encoding::DefaultFuchsiaResourceDialect,
703 &mut self.realm,
704 decoder,
705 offset + 0,
706 _depth
707 )?;
708 Ok(())
709 }
710 }
711
712 impl CreateRealmRequest {
713 #[inline(always)]
714 fn max_ordinal_present(&self) -> u64 {
715 if let Some(_) = self.overrides {
716 return 1;
717 }
718 0
719 }
720 }
721
722 impl fidl::encoding::ResourceTypeMarker for CreateRealmRequest {
723 type Borrowed<'a> = &'a mut Self;
724 fn take_or_borrow<'a>(
725 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
726 ) -> Self::Borrowed<'a> {
727 value
728 }
729 }
730
731 unsafe impl fidl::encoding::TypeMarker for CreateRealmRequest {
732 type Owned = Self;
733
734 #[inline(always)]
735 fn inline_align(_context: fidl::encoding::Context) -> usize {
736 8
737 }
738
739 #[inline(always)]
740 fn inline_size(_context: fidl::encoding::Context) -> usize {
741 16
742 }
743 }
744
745 unsafe impl
746 fidl::encoding::Encode<CreateRealmRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
747 for &mut CreateRealmRequest
748 {
749 unsafe fn encode(
750 self,
751 encoder: &mut fidl::encoding::Encoder<
752 '_,
753 fidl::encoding::DefaultFuchsiaResourceDialect,
754 >,
755 offset: usize,
756 mut depth: fidl::encoding::Depth,
757 ) -> fidl::Result<()> {
758 encoder.debug_check_bounds::<CreateRealmRequest>(offset);
759 let max_ordinal: u64 = self.max_ordinal_present();
761 encoder.write_num(max_ordinal, offset);
762 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
763 if max_ordinal == 0 {
765 return Ok(());
766 }
767 depth.increment()?;
768 let envelope_size = 8;
769 let bytes_len = max_ordinal as usize * envelope_size;
770 #[allow(unused_variables)]
771 let offset = encoder.out_of_line_offset(bytes_len);
772 let mut _prev_end_offset: usize = 0;
773 if 1 > max_ordinal {
774 return Ok(());
775 }
776
777 let cur_offset: usize = (1 - 1) * envelope_size;
780
781 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
783
784 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<ConfigOverride>, fidl::encoding::DefaultFuchsiaResourceDialect>(
789 self.overrides.as_ref().map(<fidl::encoding::UnboundedVector<ConfigOverride> as fidl::encoding::ValueTypeMarker>::borrow),
790 encoder, offset + cur_offset, depth
791 )?;
792
793 _prev_end_offset = cur_offset + envelope_size;
794
795 Ok(())
796 }
797 }
798
799 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
800 for CreateRealmRequest
801 {
802 #[inline(always)]
803 fn new_empty() -> Self {
804 Self::default()
805 }
806
807 unsafe fn decode(
808 &mut self,
809 decoder: &mut fidl::encoding::Decoder<
810 '_,
811 fidl::encoding::DefaultFuchsiaResourceDialect,
812 >,
813 offset: usize,
814 mut depth: fidl::encoding::Depth,
815 ) -> fidl::Result<()> {
816 decoder.debug_check_bounds::<Self>(offset);
817 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
818 None => return Err(fidl::Error::NotNullable),
819 Some(len) => len,
820 };
821 if len == 0 {
823 return Ok(());
824 };
825 depth.increment()?;
826 let envelope_size = 8;
827 let bytes_len = len * envelope_size;
828 let offset = decoder.out_of_line_offset(bytes_len)?;
829 let mut _next_ordinal_to_read = 0;
831 let mut next_offset = offset;
832 let end_offset = offset + bytes_len;
833 _next_ordinal_to_read += 1;
834 if next_offset >= end_offset {
835 return Ok(());
836 }
837
838 while _next_ordinal_to_read < 1 {
840 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
841 _next_ordinal_to_read += 1;
842 next_offset += envelope_size;
843 }
844
845 let next_out_of_line = decoder.next_out_of_line();
846 let handles_before = decoder.remaining_handles();
847 if let Some((inlined, num_bytes, num_handles)) =
848 fidl::encoding::decode_envelope_header(decoder, next_offset)?
849 {
850 let member_inline_size = <fidl::encoding::UnboundedVector<ConfigOverride> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
851 if inlined != (member_inline_size <= 4) {
852 return Err(fidl::Error::InvalidInlineBitInEnvelope);
853 }
854 let inner_offset;
855 let mut inner_depth = depth.clone();
856 if inlined {
857 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
858 inner_offset = next_offset;
859 } else {
860 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
861 inner_depth.increment()?;
862 }
863 let val_ref = self.overrides.get_or_insert_with(|| {
864 fidl::new_empty!(
865 fidl::encoding::UnboundedVector<ConfigOverride>,
866 fidl::encoding::DefaultFuchsiaResourceDialect
867 )
868 });
869 fidl::decode!(
870 fidl::encoding::UnboundedVector<ConfigOverride>,
871 fidl::encoding::DefaultFuchsiaResourceDialect,
872 val_ref,
873 decoder,
874 inner_offset,
875 inner_depth
876 )?;
877 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
878 {
879 return Err(fidl::Error::InvalidNumBytesInEnvelope);
880 }
881 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
882 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
883 }
884 }
885
886 next_offset += envelope_size;
887
888 while next_offset < end_offset {
890 _next_ordinal_to_read += 1;
891 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
892 next_offset += envelope_size;
893 }
894
895 Ok(())
896 }
897 }
898}