Skip to main content

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        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    /// Specifies the options to use when creating the realm.
101    ///
102    /// Returns OperationError.INVALID if called more than once.
103    pub fn r#create_realm(
104        &self,
105        mut options: RealmOptions,
106        mut realm_server: fidl::endpoints::ServerEnd<
107            fidl_fuchsia_testing_harness::RealmProxy_Marker,
108        >,
109        ___deadline: zx::MonotonicInstant,
110    ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
111        let _response = self
112            .client
113            .send_query::<RealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
114                fidl::encoding::EmptyStruct,
115                fidl_fuchsia_testing_harness::OperationError,
116            >, RealmFactoryMarker>(
117                (&mut options, realm_server),
118                0x4fd194b2ad658fce,
119                fidl::encoding::DynamicFlags::FLEXIBLE,
120                ___deadline,
121            )?
122            .into_result::<RealmFactoryMarker>("create_realm")?;
123        Ok(_response.map(|x| x))
124    }
125}
126
127#[cfg(target_os = "fuchsia")]
128impl From<RealmFactorySynchronousProxy> for zx::NullableHandle {
129    fn from(value: RealmFactorySynchronousProxy) -> Self {
130        value.into_channel().into()
131    }
132}
133
134#[cfg(target_os = "fuchsia")]
135impl From<fidl::Channel> for RealmFactorySynchronousProxy {
136    fn from(value: fidl::Channel) -> Self {
137        Self::new(value)
138    }
139}
140
141#[cfg(target_os = "fuchsia")]
142impl fidl::endpoints::FromClient for RealmFactorySynchronousProxy {
143    type Protocol = RealmFactoryMarker;
144
145    fn from_client(value: fidl::endpoints::ClientEnd<RealmFactoryMarker>) -> Self {
146        Self::new(value.into_channel())
147    }
148}
149
150#[derive(Debug, Clone)]
151pub struct RealmFactoryProxy {
152    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
153}
154
155impl fidl::endpoints::Proxy for RealmFactoryProxy {
156    type Protocol = RealmFactoryMarker;
157
158    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
159        Self::new(inner)
160    }
161
162    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
163        self.client.into_channel().map_err(|client| Self { client })
164    }
165
166    fn as_channel(&self) -> &::fidl::AsyncChannel {
167        self.client.as_channel()
168    }
169}
170
171impl RealmFactoryProxy {
172    /// Create a new Proxy for test.mock/RealmFactory.
173    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
174        let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
175        Self { client: fidl::client::Client::new(channel, protocol_name) }
176    }
177
178    /// Get a Stream of events from the remote end of the protocol.
179    ///
180    /// # Panics
181    ///
182    /// Panics if the event stream was already taken.
183    pub fn take_event_stream(&self) -> RealmFactoryEventStream {
184        RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
185    }
186
187    /// Specifies the options to use when creating the realm.
188    ///
189    /// Returns OperationError.INVALID if called more than once.
190    pub fn r#create_realm(
191        &self,
192        mut options: RealmOptions,
193        mut realm_server: fidl::endpoints::ServerEnd<
194            fidl_fuchsia_testing_harness::RealmProxy_Marker,
195        >,
196    ) -> fidl::client::QueryResponseFut<
197        RealmFactoryCreateRealmResult,
198        fidl::encoding::DefaultFuchsiaResourceDialect,
199    > {
200        RealmFactoryProxyInterface::r#create_realm(self, options, realm_server)
201    }
202}
203
204impl RealmFactoryProxyInterface for RealmFactoryProxy {
205    type CreateRealmResponseFut = fidl::client::QueryResponseFut<
206        RealmFactoryCreateRealmResult,
207        fidl::encoding::DefaultFuchsiaResourceDialect,
208    >;
209    fn r#create_realm(
210        &self,
211        mut options: RealmOptions,
212        mut realm_server: fidl::endpoints::ServerEnd<
213            fidl_fuchsia_testing_harness::RealmProxy_Marker,
214        >,
215    ) -> Self::CreateRealmResponseFut {
216        fn _decode(
217            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
218        ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
219            let _response = fidl::client::decode_transaction_body::<
220                fidl::encoding::FlexibleResultType<
221                    fidl::encoding::EmptyStruct,
222                    fidl_fuchsia_testing_harness::OperationError,
223                >,
224                fidl::encoding::DefaultFuchsiaResourceDialect,
225                0x4fd194b2ad658fce,
226            >(_buf?)?
227            .into_result::<RealmFactoryMarker>("create_realm")?;
228            Ok(_response.map(|x| x))
229        }
230        self.client
231            .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
232                (&mut options, realm_server),
233                0x4fd194b2ad658fce,
234                fidl::encoding::DynamicFlags::FLEXIBLE,
235                _decode,
236            )
237    }
238}
239
240pub struct RealmFactoryEventStream {
241    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
242}
243
244impl std::marker::Unpin for RealmFactoryEventStream {}
245
246impl futures::stream::FusedStream for RealmFactoryEventStream {
247    fn is_terminated(&self) -> bool {
248        self.event_receiver.is_terminated()
249    }
250}
251
252impl futures::Stream for RealmFactoryEventStream {
253    type Item = Result<RealmFactoryEvent, fidl::Error>;
254
255    fn poll_next(
256        mut self: std::pin::Pin<&mut Self>,
257        cx: &mut std::task::Context<'_>,
258    ) -> std::task::Poll<Option<Self::Item>> {
259        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
260            &mut self.event_receiver,
261            cx
262        )?) {
263            Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
264            None => std::task::Poll::Ready(None),
265        }
266    }
267}
268
269#[derive(Debug)]
270pub enum RealmFactoryEvent {
271    #[non_exhaustive]
272    _UnknownEvent {
273        /// Ordinal of the event that was sent.
274        ordinal: u64,
275    },
276}
277
278impl RealmFactoryEvent {
279    /// Decodes a message buffer as a [`RealmFactoryEvent`].
280    fn decode(
281        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
282    ) -> Result<RealmFactoryEvent, fidl::Error> {
283        let (bytes, _handles) = buf.split_mut();
284        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
285        debug_assert_eq!(tx_header.tx_id, 0);
286        match tx_header.ordinal {
287            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
288                Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
289            }
290            _ => Err(fidl::Error::UnknownOrdinal {
291                ordinal: tx_header.ordinal,
292                protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
293            }),
294        }
295    }
296}
297
298/// A Stream of incoming requests for test.mock/RealmFactory.
299pub struct RealmFactoryRequestStream {
300    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
301    is_terminated: bool,
302}
303
304impl std::marker::Unpin for RealmFactoryRequestStream {}
305
306impl futures::stream::FusedStream for RealmFactoryRequestStream {
307    fn is_terminated(&self) -> bool {
308        self.is_terminated
309    }
310}
311
312impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
313    type Protocol = RealmFactoryMarker;
314    type ControlHandle = RealmFactoryControlHandle;
315
316    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
317        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
318    }
319
320    fn control_handle(&self) -> Self::ControlHandle {
321        RealmFactoryControlHandle { inner: self.inner.clone() }
322    }
323
324    fn into_inner(
325        self,
326    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
327    {
328        (self.inner, self.is_terminated)
329    }
330
331    fn from_inner(
332        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
333        is_terminated: bool,
334    ) -> Self {
335        Self { inner, is_terminated }
336    }
337}
338
339impl futures::Stream for RealmFactoryRequestStream {
340    type Item = Result<RealmFactoryRequest, fidl::Error>;
341
342    fn poll_next(
343        mut self: std::pin::Pin<&mut Self>,
344        cx: &mut std::task::Context<'_>,
345    ) -> std::task::Poll<Option<Self::Item>> {
346        let this = &mut *self;
347        if this.inner.check_shutdown(cx) {
348            this.is_terminated = true;
349            return std::task::Poll::Ready(None);
350        }
351        if this.is_terminated {
352            panic!("polled RealmFactoryRequestStream after completion");
353        }
354        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
355            |bytes, handles| {
356                match this.inner.channel().read_etc(cx, bytes, handles) {
357                    std::task::Poll::Ready(Ok(())) => {}
358                    std::task::Poll::Pending => return std::task::Poll::Pending,
359                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
360                        this.is_terminated = true;
361                        return std::task::Poll::Ready(None);
362                    }
363                    std::task::Poll::Ready(Err(e)) => {
364                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
365                            e.into(),
366                        ))));
367                    }
368                }
369
370                // A message has been received from the channel
371                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
372
373                std::task::Poll::Ready(Some(match header.ordinal {
374                    0x4fd194b2ad658fce => {
375                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
376                        let mut req = fidl::new_empty!(
377                            RealmFactoryCreateRealmRequest,
378                            fidl::encoding::DefaultFuchsiaResourceDialect
379                        );
380                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
381                        let control_handle =
382                            RealmFactoryControlHandle { inner: this.inner.clone() };
383                        Ok(RealmFactoryRequest::CreateRealm {
384                            options: req.options,
385                            realm_server: req.realm_server,
386
387                            responder: RealmFactoryCreateRealmResponder {
388                                control_handle: std::mem::ManuallyDrop::new(control_handle),
389                                tx_id: header.tx_id,
390                            },
391                        })
392                    }
393                    _ if header.tx_id == 0
394                        && header
395                            .dynamic_flags()
396                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
397                    {
398                        Ok(RealmFactoryRequest::_UnknownMethod {
399                            ordinal: header.ordinal,
400                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
401                            method_type: fidl::MethodType::OneWay,
402                        })
403                    }
404                    _ if header
405                        .dynamic_flags()
406                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
407                    {
408                        this.inner.send_framework_err(
409                            fidl::encoding::FrameworkErr::UnknownMethod,
410                            header.tx_id,
411                            header.ordinal,
412                            header.dynamic_flags(),
413                            (bytes, handles),
414                        )?;
415                        Ok(RealmFactoryRequest::_UnknownMethod {
416                            ordinal: header.ordinal,
417                            control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
418                            method_type: fidl::MethodType::TwoWay,
419                        })
420                    }
421                    _ => Err(fidl::Error::UnknownOrdinal {
422                        ordinal: header.ordinal,
423                        protocol_name:
424                            <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
425                    }),
426                }))
427            },
428        )
429    }
430}
431
432#[derive(Debug)]
433pub enum RealmFactoryRequest {
434    /// Specifies the options to use when creating the realm.
435    ///
436    /// Returns OperationError.INVALID if called more than once.
437    CreateRealm {
438        options: RealmOptions,
439        realm_server: fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
440        responder: RealmFactoryCreateRealmResponder,
441    },
442    /// An interaction was received which does not match any known method.
443    #[non_exhaustive]
444    _UnknownMethod {
445        /// Ordinal of the method that was called.
446        ordinal: u64,
447        control_handle: RealmFactoryControlHandle,
448        method_type: fidl::MethodType,
449    },
450}
451
452impl RealmFactoryRequest {
453    #[allow(irrefutable_let_patterns)]
454    pub fn into_create_realm(
455        self,
456    ) -> Option<(
457        RealmOptions,
458        fidl::endpoints::ServerEnd<fidl_fuchsia_testing_harness::RealmProxy_Marker>,
459        RealmFactoryCreateRealmResponder,
460    )> {
461        if let RealmFactoryRequest::CreateRealm { options, realm_server, responder } = self {
462            Some((options, realm_server, responder))
463        } else {
464            None
465        }
466    }
467
468    /// Name of the method defined in FIDL
469    pub fn method_name(&self) -> &'static str {
470        match *self {
471            RealmFactoryRequest::CreateRealm { .. } => "create_realm",
472            RealmFactoryRequest::_UnknownMethod {
473                method_type: fidl::MethodType::OneWay, ..
474            } => "unknown one-way method",
475            RealmFactoryRequest::_UnknownMethod {
476                method_type: fidl::MethodType::TwoWay, ..
477            } => "unknown two-way method",
478        }
479    }
480}
481
482#[derive(Debug, Clone)]
483pub struct RealmFactoryControlHandle {
484    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
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: zx_status::Status) {
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            0x4fd194b2ad658fce,
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}