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