Skip to main content

fidl_test_rolemanager/
fidl_test_rolemanager.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_rolemanager_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct RealmFactoryCreateRealmRequest {
16    pub options: RealmOptions,
17    pub realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for RealmFactoryCreateRealmRequest
22{
23}
24
25/// RealmOptions tells the RealmFactory protocol how to create the test realm.
26#[derive(Debug, Default, PartialEq)]
27pub struct RealmOptions {
28    #[doc(hidden)]
29    pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub struct RealmFactoryMarker;
36
37impl fidl::endpoints::ProtocolMarker for RealmFactoryMarker {
38    type Proxy = RealmFactoryProxy;
39    type RequestStream = RealmFactoryRequestStream;
40    #[cfg(target_os = "fuchsia")]
41    type SynchronousProxy = RealmFactorySynchronousProxy;
42
43    const DEBUG_NAME: &'static str = "test.rolemanager.RealmFactory";
44}
45impl fidl::endpoints::DiscoverableProtocolMarker for RealmFactoryMarker {}
46pub type RealmFactoryCreateRealmResult = Result<(), fidl_fuchsia_testing_harness::OperationError>;
47
48pub trait RealmFactoryProxyInterface: Send + Sync {
49    type CreateRealmResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealmResult, fidl::Error>>
50        + Send;
51    fn r#create_realm(
52        &self,
53        options: RealmOptions,
54        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
55    ) -> Self::CreateRealmResponseFut;
56}
57#[derive(Debug)]
58#[cfg(target_os = "fuchsia")]
59pub struct RealmFactorySynchronousProxy {
60    client: fidl::client::sync::Client,
61}
62
63#[cfg(target_os = "fuchsia")]
64impl fidl::endpoints::SynchronousProxy for RealmFactorySynchronousProxy {
65    type Proxy = RealmFactoryProxy;
66    type Protocol = RealmFactoryMarker;
67
68    fn from_channel(inner: fidl::Channel) -> Self {
69        Self::new(inner)
70    }
71
72    fn into_channel(self) -> fidl::Channel {
73        self.client.into_channel()
74    }
75
76    fn as_channel(&self) -> &fidl::Channel {
77        self.client.as_channel()
78    }
79}
80
81#[cfg(target_os = "fuchsia")]
82impl RealmFactorySynchronousProxy {
83    pub fn new(channel: fidl::Channel) -> Self {
84        Self { client: fidl::client::sync::Client::new(channel) }
85    }
86
87    pub fn into_channel(self) -> fidl::Channel {
88        self.client.into_channel()
89    }
90
91    /// Waits until an event arrives and returns it. It is safe for other
92    /// threads to make concurrent requests while waiting for an event.
93    pub fn wait_for_event(
94        &self,
95        deadline: zx::MonotonicInstant,
96    ) -> Result<RealmFactoryEvent, fidl::Error> {
97        RealmFactoryEvent::decode(self.client.wait_for_event::<RealmFactoryMarker>(deadline)?)
98    }
99
100    /// Creates a new realm and binds the given RealmProxy server end to it.
101    pub fn r#create_realm(
102        &self,
103        mut options: RealmOptions,
104        mut realm_server: fidl::endpoints::ServerEnd<
105            fidl_fuchsia_testing_harness::RealmProxy_Marker,
106        >,
107        ___deadline: zx::MonotonicInstant,
108    ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
109        let _response = self
110            .client
111            .send_query::<RealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
112                fidl::encoding::EmptyStruct,
113                fidl_fuchsia_testing_harness::OperationError,
114            >, RealmFactoryMarker>(
115                (&mut options, realm_server),
116                0x53ebab85149ca793,
117                fidl::encoding::DynamicFlags::FLEXIBLE,
118                ___deadline,
119            )?
120            .into_result::<RealmFactoryMarker>("create_realm")?;
121        Ok(_response.map(|x| x))
122    }
123}
124
125#[cfg(target_os = "fuchsia")]
126impl From<RealmFactorySynchronousProxy> for zx::NullableHandle {
127    fn from(value: RealmFactorySynchronousProxy) -> Self {
128        value.into_channel().into()
129    }
130}
131
132#[cfg(target_os = "fuchsia")]
133impl From<fidl::Channel> for RealmFactorySynchronousProxy {
134    fn from(value: fidl::Channel) -> Self {
135        Self::new(value)
136    }
137}
138
139#[cfg(target_os = "fuchsia")]
140impl fidl::endpoints::FromClient for RealmFactorySynchronousProxy {
141    type Protocol = RealmFactoryMarker;
142
143    fn from_client(value: fidl::endpoints::ClientEnd<RealmFactoryMarker>) -> Self {
144        Self::new(value.into_channel())
145    }
146}
147
148#[derive(Debug, Clone)]
149pub struct RealmFactoryProxy {
150    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
151}
152
153impl fidl::endpoints::Proxy for RealmFactoryProxy {
154    type Protocol = RealmFactoryMarker;
155
156    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
157        Self::new(inner)
158    }
159
160    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
161        self.client.into_channel().map_err(|client| Self { client })
162    }
163
164    fn as_channel(&self) -> &::fidl::AsyncChannel {
165        self.client.as_channel()
166    }
167}
168
169impl RealmFactoryProxy {
170    /// Create a new Proxy for test.rolemanager/RealmFactory.
171    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
172        let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
173        Self { client: fidl::client::Client::new(channel, protocol_name) }
174    }
175
176    /// Get a Stream of events from the remote end of the protocol.
177    ///
178    /// # Panics
179    ///
180    /// Panics if the event stream was already taken.
181    pub fn take_event_stream(&self) -> RealmFactoryEventStream {
182        RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
183    }
184
185    /// Creates a new realm and binds the given RealmProxy server end to it.
186    pub fn r#create_realm(
187        &self,
188        mut options: RealmOptions,
189        mut realm_server: fidl::endpoints::ServerEnd<
190            fidl_fuchsia_testing_harness::RealmProxy_Marker,
191        >,
192    ) -> fidl::client::QueryResponseFut<
193        RealmFactoryCreateRealmResult,
194        fidl::encoding::DefaultFuchsiaResourceDialect,
195    > {
196        RealmFactoryProxyInterface::r#create_realm(self, options, realm_server)
197    }
198}
199
200impl RealmFactoryProxyInterface for RealmFactoryProxy {
201    type CreateRealmResponseFut = fidl::client::QueryResponseFut<
202        RealmFactoryCreateRealmResult,
203        fidl::encoding::DefaultFuchsiaResourceDialect,
204    >;
205    fn r#create_realm(
206        &self,
207        mut options: RealmOptions,
208        mut realm_server: fidl::endpoints::ServerEnd<
209            fidl_fuchsia_testing_harness::RealmProxy_Marker,
210        >,
211    ) -> Self::CreateRealmResponseFut {
212        fn _decode(
213            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
214        ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
215            let _response = fidl::client::decode_transaction_body::<
216                fidl::encoding::FlexibleResultType<
217                    fidl::encoding::EmptyStruct,
218                    fidl_fuchsia_testing_harness::OperationError,
219                >,
220                fidl::encoding::DefaultFuchsiaResourceDialect,
221                0x53ebab85149ca793,
222            >(_buf?)?
223            .into_result::<RealmFactoryMarker>("create_realm")?;
224            Ok(_response.map(|x| x))
225        }
226        self.client
227            .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
228                (&mut options, realm_server),
229                0x53ebab85149ca793,
230                fidl::encoding::DynamicFlags::FLEXIBLE,
231                _decode,
232            )
233    }
234}
235
236pub struct RealmFactoryEventStream {
237    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
238}
239
240impl std::marker::Unpin for RealmFactoryEventStream {}
241
242impl futures::stream::FusedStream for RealmFactoryEventStream {
243    fn is_terminated(&self) -> bool {
244        self.event_receiver.is_terminated()
245    }
246}
247
248impl futures::Stream for RealmFactoryEventStream {
249    type Item = Result<RealmFactoryEvent, fidl::Error>;
250
251    fn poll_next(
252        mut self: std::pin::Pin<&mut Self>,
253        cx: &mut std::task::Context<'_>,
254    ) -> std::task::Poll<Option<Self::Item>> {
255        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
256            &mut self.event_receiver,
257            cx
258        )?) {
259            Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
260            None => std::task::Poll::Ready(None),
261        }
262    }
263}
264
265#[derive(Debug)]
266pub enum RealmFactoryEvent {
267    #[non_exhaustive]
268    _UnknownEvent {
269        /// Ordinal of the event that was sent.
270        ordinal: u64,
271    },
272}
273
274impl RealmFactoryEvent {
275    /// Decodes a message buffer as a [`RealmFactoryEvent`].
276    fn decode(
277        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
278    ) -> Result<RealmFactoryEvent, fidl::Error> {
279        let (bytes, _handles) = buf.split_mut();
280        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
281        debug_assert_eq!(tx_header.tx_id, 0);
282        match tx_header.ordinal {
283            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
284                Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
285            }
286            _ => Err(fidl::Error::UnknownOrdinal {
287                ordinal: tx_header.ordinal,
288                protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
289            }),
290        }
291    }
292}
293
294/// A Stream of incoming requests for test.rolemanager/RealmFactory.
295pub struct RealmFactoryRequestStream {
296    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
297    is_terminated: bool,
298}
299
300impl std::marker::Unpin for RealmFactoryRequestStream {}
301
302impl futures::stream::FusedStream for RealmFactoryRequestStream {
303    fn is_terminated(&self) -> bool {
304        self.is_terminated
305    }
306}
307
308impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
309    type Protocol = RealmFactoryMarker;
310    type ControlHandle = RealmFactoryControlHandle;
311
312    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
313        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
314    }
315
316    fn control_handle(&self) -> Self::ControlHandle {
317        RealmFactoryControlHandle { inner: self.inner.clone() }
318    }
319
320    fn into_inner(
321        self,
322    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
323    {
324        (self.inner, self.is_terminated)
325    }
326
327    fn from_inner(
328        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
329        is_terminated: bool,
330    ) -> Self {
331        Self { inner, is_terminated }
332    }
333}
334
335impl futures::Stream for RealmFactoryRequestStream {
336    type Item = Result<RealmFactoryRequest, fidl::Error>;
337
338    fn poll_next(
339        mut self: std::pin::Pin<&mut Self>,
340        cx: &mut std::task::Context<'_>,
341    ) -> std::task::Poll<Option<Self::Item>> {
342        let this = &mut *self;
343        if this.inner.check_shutdown(cx) {
344            this.is_terminated = true;
345            return std::task::Poll::Ready(None);
346        }
347        if this.is_terminated {
348            panic!("polled RealmFactoryRequestStream after completion");
349        }
350        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
351            |bytes, handles| {
352                match this.inner.channel().read_etc(cx, bytes, handles) {
353                    std::task::Poll::Ready(Ok(())) => {}
354                    std::task::Poll::Pending => return std::task::Poll::Pending,
355                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
356                        this.is_terminated = true;
357                        return std::task::Poll::Ready(None);
358                    }
359                    std::task::Poll::Ready(Err(e)) => {
360                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
361                            e.into(),
362                        ))));
363                    }
364                }
365
366                // A message has been received from the channel
367                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
368
369                std::task::Poll::Ready(Some(match header.ordinal {
370                    0x53ebab85149ca793 => {
371                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
372                        let mut req = fidl::new_empty!(
373                            RealmFactoryCreateRealmRequest,
374                            fidl::encoding::DefaultFuchsiaResourceDialect
375                        );
376                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
377                        let control_handle =
378                            RealmFactoryControlHandle { inner: this.inner.clone() };
379                        Ok(RealmFactoryRequest::CreateRealm {
380                            options: req.options,
381                            realm_server: req.realm_server,
382
383                            responder: RealmFactoryCreateRealmResponder {
384                                control_handle: std::mem::ManuallyDrop::new(control_handle),
385                                tx_id: header.tx_id,
386                            },
387                        })
388                    }
389                    _ if header.tx_id == 0
390                        && header
391                            .dynamic_flags()
392                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
393                    {
394                        Ok(RealmFactoryRequest::_UnknownMethod {
395                            ordinal: header.ordinal,
396                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
397                            method_type: fidl::MethodType::OneWay,
398                        })
399                    }
400                    _ if header
401                        .dynamic_flags()
402                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
403                    {
404                        this.inner.send_framework_err(
405                            fidl::encoding::FrameworkErr::UnknownMethod,
406                            header.tx_id,
407                            header.ordinal,
408                            header.dynamic_flags(),
409                            (bytes, handles),
410                        )?;
411                        Ok(RealmFactoryRequest::_UnknownMethod {
412                            ordinal: header.ordinal,
413                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
414                            method_type: fidl::MethodType::TwoWay,
415                        })
416                    }
417                    _ => Err(fidl::Error::UnknownOrdinal {
418                        ordinal: header.ordinal,
419                        protocol_name:
420                            <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
421                    }),
422                }))
423            },
424        )
425    }
426}
427
428#[derive(Debug)]
429pub enum RealmFactoryRequest {
430    /// Creates a new realm and binds the given RealmProxy server end to it.
431    CreateRealm {
432        options: RealmOptions,
433        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
434        responder: RealmFactoryCreateRealmResponder,
435    },
436    /// An interaction was received which does not match any known method.
437    #[non_exhaustive]
438    _UnknownMethod {
439        /// Ordinal of the method that was called.
440        ordinal: u64,
441        control_handle: RealmFactoryControlHandle,
442        method_type: fidl::MethodType,
443    },
444}
445
446impl RealmFactoryRequest {
447    #[allow(irrefutable_let_patterns)]
448    pub fn into_create_realm(
449        self,
450    ) -> Option<(
451        RealmOptions,
452        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
453        RealmFactoryCreateRealmResponder,
454    )> {
455        if let RealmFactoryRequest::CreateRealm { options, realm_server, responder } = self {
456            Some((options, realm_server, responder))
457        } else {
458            None
459        }
460    }
461
462    /// Name of the method defined in FIDL
463    pub fn method_name(&self) -> &'static str {
464        match *self {
465            RealmFactoryRequest::CreateRealm { .. } => "create_realm",
466            RealmFactoryRequest::_UnknownMethod {
467                method_type: fidl::MethodType::OneWay, ..
468            } => "unknown one-way method",
469            RealmFactoryRequest::_UnknownMethod {
470                method_type: fidl::MethodType::TwoWay, ..
471            } => "unknown two-way method",
472        }
473    }
474}
475
476#[derive(Debug, Clone)]
477pub struct RealmFactoryControlHandle {
478    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
479}
480
481impl RealmFactoryControlHandle {
482    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
483        self.inner.shutdown_with_epitaph(status.into())
484    }
485}
486
487impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
488    fn shutdown(&self) {
489        self.inner.shutdown()
490    }
491
492    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
493        self.inner.shutdown_with_epitaph(status)
494    }
495
496    fn is_closed(&self) -> bool {
497        self.inner.channel().is_closed()
498    }
499    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
500        self.inner.channel().on_closed()
501    }
502
503    #[cfg(target_os = "fuchsia")]
504    fn signal_peer(
505        &self,
506        clear_mask: zx::Signals,
507        set_mask: zx::Signals,
508    ) -> Result<(), zx_status::Status> {
509        use fidl::Peered;
510        self.inner.channel().signal_peer(clear_mask, set_mask)
511    }
512}
513
514impl RealmFactoryControlHandle {}
515
516#[must_use = "FIDL methods require a response to be sent"]
517#[derive(Debug)]
518pub struct RealmFactoryCreateRealmResponder {
519    control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
520    tx_id: u32,
521}
522
523/// Set the the channel to be shutdown (see [`RealmFactoryControlHandle::shutdown`])
524/// if the responder is dropped without sending a response, so that the client
525/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
526impl std::ops::Drop for RealmFactoryCreateRealmResponder {
527    fn drop(&mut self) {
528        self.control_handle.shutdown();
529        // Safety: drops once, never accessed again
530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
531    }
532}
533
534impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
535    type ControlHandle = RealmFactoryControlHandle;
536
537    fn control_handle(&self) -> &RealmFactoryControlHandle {
538        &self.control_handle
539    }
540
541    fn drop_without_shutdown(mut self) {
542        // Safety: drops once, never accessed again due to mem::forget
543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
544        // Prevent Drop from running (which would shut down the channel)
545        std::mem::forget(self);
546    }
547}
548
549impl RealmFactoryCreateRealmResponder {
550    /// Sends a response to the FIDL transaction.
551    ///
552    /// Sets the channel to shutdown if an error occurs.
553    pub fn send(
554        self,
555        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
556    ) -> Result<(), fidl::Error> {
557        let _result = self.send_raw(result);
558        if _result.is_err() {
559            self.control_handle.shutdown();
560        }
561        self.drop_without_shutdown();
562        _result
563    }
564
565    /// Similar to "send" but does not shutdown the channel if an error occurs.
566    pub fn send_no_shutdown_on_err(
567        self,
568        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
569    ) -> Result<(), fidl::Error> {
570        let _result = self.send_raw(result);
571        self.drop_without_shutdown();
572        _result
573    }
574
575    fn send_raw(
576        &self,
577        mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
578    ) -> Result<(), fidl::Error> {
579        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
580            fidl::encoding::EmptyStruct,
581            fidl_fuchsia_testing_harness::OperationError,
582        >>(
583            fidl::encoding::FlexibleResult::new(result),
584            self.tx_id,
585            0x53ebab85149ca793,
586            fidl::encoding::DynamicFlags::FLEXIBLE,
587        )
588    }
589}
590
591mod internal {
592    use super::*;
593
594    impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
595        type Borrowed<'a> = &'a mut Self;
596        fn take_or_borrow<'a>(
597            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
598        ) -> Self::Borrowed<'a> {
599            value
600        }
601    }
602
603    unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
604        type Owned = Self;
605
606        #[inline(always)]
607        fn inline_align(_context: fidl::encoding::Context) -> usize {
608            8
609        }
610
611        #[inline(always)]
612        fn inline_size(_context: fidl::encoding::Context) -> usize {
613            24
614        }
615    }
616
617    unsafe impl
618        fidl::encoding::Encode<
619            RealmFactoryCreateRealmRequest,
620            fidl::encoding::DefaultFuchsiaResourceDialect,
621        > for &mut RealmFactoryCreateRealmRequest
622    {
623        #[inline]
624        unsafe fn encode(
625            self,
626            encoder: &mut fidl::encoding::Encoder<
627                '_,
628                fidl::encoding::DefaultFuchsiaResourceDialect,
629            >,
630            offset: usize,
631            _depth: fidl::encoding::Depth,
632        ) -> fidl::Result<()> {
633            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
634            // Delegate to tuple encoding.
635            fidl::encoding::Encode::<
636                RealmFactoryCreateRealmRequest,
637                fidl::encoding::DefaultFuchsiaResourceDialect,
638            >::encode(
639                (
640                    <RealmOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
641                        &mut self.options,
642                    ),
643                    <fidl::encoding::Endpoint<
644                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
645                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
646                        &mut self.realm_server,
647                    ),
648                ),
649                encoder,
650                offset,
651                _depth,
652            )
653        }
654    }
655    unsafe impl<
656        T0: fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
657        T1: fidl::encoding::Encode<
658                fidl::encoding::Endpoint<
659                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
660                >,
661                fidl::encoding::DefaultFuchsiaResourceDialect,
662            >,
663    >
664        fidl::encoding::Encode<
665            RealmFactoryCreateRealmRequest,
666            fidl::encoding::DefaultFuchsiaResourceDialect,
667        > for (T0, T1)
668    {
669        #[inline]
670        unsafe fn encode(
671            self,
672            encoder: &mut fidl::encoding::Encoder<
673                '_,
674                fidl::encoding::DefaultFuchsiaResourceDialect,
675            >,
676            offset: usize,
677            depth: fidl::encoding::Depth,
678        ) -> fidl::Result<()> {
679            encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
680            // Zero out padding regions. There's no need to apply masks
681            // because the unmasked parts will be overwritten by fields.
682            unsafe {
683                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
684                (ptr as *mut u64).write_unaligned(0);
685            }
686            // Write the fields.
687            self.0.encode(encoder, offset + 0, depth)?;
688            self.1.encode(encoder, offset + 16, depth)?;
689            Ok(())
690        }
691    }
692
693    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
694        for RealmFactoryCreateRealmRequest
695    {
696        #[inline(always)]
697        fn new_empty() -> Self {
698            Self {
699                options: fidl::new_empty!(
700                    RealmOptions,
701                    fidl::encoding::DefaultFuchsiaResourceDialect
702                ),
703                realm_server: fidl::new_empty!(
704                    fidl::encoding::Endpoint<
705                        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
706                    >,
707                    fidl::encoding::DefaultFuchsiaResourceDialect
708                ),
709            }
710        }
711
712        #[inline]
713        unsafe fn decode(
714            &mut self,
715            decoder: &mut fidl::encoding::Decoder<
716                '_,
717                fidl::encoding::DefaultFuchsiaResourceDialect,
718            >,
719            offset: usize,
720            _depth: fidl::encoding::Depth,
721        ) -> fidl::Result<()> {
722            decoder.debug_check_bounds::<Self>(offset);
723            // Verify that padding bytes are zero.
724            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
725            let padval = unsafe { (ptr as *const u64).read_unaligned() };
726            let mask = 0xffffffff00000000u64;
727            let maskedval = padval & mask;
728            if maskedval != 0 {
729                return Err(fidl::Error::NonZeroPadding {
730                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
731                });
732            }
733            fidl::decode!(
734                RealmOptions,
735                fidl::encoding::DefaultFuchsiaResourceDialect,
736                &mut self.options,
737                decoder,
738                offset + 0,
739                _depth
740            )?;
741            fidl::decode!(
742                fidl::encoding::Endpoint<
743                    fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
744                >,
745                fidl::encoding::DefaultFuchsiaResourceDialect,
746                &mut self.realm_server,
747                decoder,
748                offset + 16,
749                _depth
750            )?;
751            Ok(())
752        }
753    }
754
755    impl RealmOptions {
756        #[inline(always)]
757        fn max_ordinal_present(&self) -> u64 {
758            0
759        }
760    }
761
762    impl fidl::encoding::ResourceTypeMarker for RealmOptions {
763        type Borrowed<'a> = &'a mut Self;
764        fn take_or_borrow<'a>(
765            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
766        ) -> Self::Borrowed<'a> {
767            value
768        }
769    }
770
771    unsafe impl fidl::encoding::TypeMarker for RealmOptions {
772        type Owned = Self;
773
774        #[inline(always)]
775        fn inline_align(_context: fidl::encoding::Context) -> usize {
776            8
777        }
778
779        #[inline(always)]
780        fn inline_size(_context: fidl::encoding::Context) -> usize {
781            16
782        }
783    }
784
785    unsafe impl fidl::encoding::Encode<RealmOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
786        for &mut RealmOptions
787    {
788        unsafe fn encode(
789            self,
790            encoder: &mut fidl::encoding::Encoder<
791                '_,
792                fidl::encoding::DefaultFuchsiaResourceDialect,
793            >,
794            offset: usize,
795            mut depth: fidl::encoding::Depth,
796        ) -> fidl::Result<()> {
797            encoder.debug_check_bounds::<RealmOptions>(offset);
798            // Vector header
799            let max_ordinal: u64 = self.max_ordinal_present();
800            encoder.write_num(max_ordinal, offset);
801            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
802            // Calling encoder.out_of_line_offset(0) is not allowed.
803            if max_ordinal == 0 {
804                return Ok(());
805            }
806            depth.increment()?;
807            let envelope_size = 8;
808            let bytes_len = max_ordinal as usize * envelope_size;
809            #[allow(unused_variables)]
810            let offset = encoder.out_of_line_offset(bytes_len);
811            let mut _prev_end_offset: usize = 0;
812
813            Ok(())
814        }
815    }
816
817    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RealmOptions {
818        #[inline(always)]
819        fn new_empty() -> Self {
820            Self::default()
821        }
822
823        unsafe fn decode(
824            &mut self,
825            decoder: &mut fidl::encoding::Decoder<
826                '_,
827                fidl::encoding::DefaultFuchsiaResourceDialect,
828            >,
829            offset: usize,
830            mut depth: fidl::encoding::Depth,
831        ) -> fidl::Result<()> {
832            decoder.debug_check_bounds::<Self>(offset);
833            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
834                None => return Err(fidl::Error::NotNullable),
835                Some(len) => len,
836            };
837            // Calling decoder.out_of_line_offset(0) is not allowed.
838            if len == 0 {
839                return Ok(());
840            };
841            depth.increment()?;
842            let envelope_size = 8;
843            let bytes_len = len * envelope_size;
844            let offset = decoder.out_of_line_offset(bytes_len)?;
845            // Decode the envelope for each type.
846            let mut _next_ordinal_to_read = 0;
847            let mut next_offset = offset;
848            let end_offset = offset + bytes_len;
849
850            // Decode the remaining unknown envelopes.
851            while next_offset < end_offset {
852                _next_ordinal_to_read += 1;
853                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
854                next_offset += envelope_size;
855            }
856
857            Ok(())
858        }
859    }
860}