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