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