fidl_fuchsia_testing_harness/
fidl_fuchsia_testing_harness.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_fuchsia_testing_harness__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct RealmProxyConnectToNamedProtocolRequest {
16    pub protocol: String,
17    pub server_end: fidl::Channel,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for RealmProxyConnectToNamedProtocolRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct RealmProxyConnectToServiceInstanceRequest {
27    pub service: String,
28    pub instance: String,
29    pub server_end: fidl::Channel,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for RealmProxyConnectToServiceInstanceRequest
34{
35}
36
37#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
38pub struct RealmProxyOpenServiceRequest {
39    pub service: String,
40    pub server_end: fidl::Channel,
41}
42
43impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
44    for RealmProxyOpenServiceRequest
45{
46}
47
48#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
49pub struct RealmProxy_Marker;
50
51impl fidl::endpoints::ProtocolMarker for RealmProxy_Marker {
52    type Proxy = RealmProxy_Proxy;
53    type RequestStream = RealmProxy_RequestStream;
54    #[cfg(target_os = "fuchsia")]
55    type SynchronousProxy = RealmProxy_SynchronousProxy;
56
57    const DEBUG_NAME: &'static str = "fuchsia.testing.harness.RealmProxy";
58}
59impl fidl::endpoints::DiscoverableProtocolMarker for RealmProxy_Marker {}
60pub type RealmProxyConnectToNamedProtocolResult = Result<(), OperationError>;
61pub type RealmProxyOpenServiceResult = Result<(), OperationError>;
62pub type RealmProxyConnectToServiceInstanceResult = Result<(), OperationError>;
63
64pub trait RealmProxy_ProxyInterface: Send + Sync {
65    type ConnectToNamedProtocolResponseFut: std::future::Future<Output = Result<RealmProxyConnectToNamedProtocolResult, fidl::Error>>
66        + Send;
67    fn r#connect_to_named_protocol(
68        &self,
69        protocol: &str,
70        server_end: fidl::Channel,
71    ) -> Self::ConnectToNamedProtocolResponseFut;
72    type OpenServiceResponseFut: std::future::Future<Output = Result<RealmProxyOpenServiceResult, fidl::Error>>
73        + Send;
74    fn r#open_service(
75        &self,
76        service: &str,
77        server_end: fidl::Channel,
78    ) -> Self::OpenServiceResponseFut;
79    type ConnectToServiceInstanceResponseFut: std::future::Future<Output = Result<RealmProxyConnectToServiceInstanceResult, fidl::Error>>
80        + Send;
81    fn r#connect_to_service_instance(
82        &self,
83        service: &str,
84        instance: &str,
85        server_end: fidl::Channel,
86    ) -> Self::ConnectToServiceInstanceResponseFut;
87}
88#[derive(Debug)]
89#[cfg(target_os = "fuchsia")]
90pub struct RealmProxy_SynchronousProxy {
91    client: fidl::client::sync::Client,
92}
93
94#[cfg(target_os = "fuchsia")]
95impl fidl::endpoints::SynchronousProxy for RealmProxy_SynchronousProxy {
96    type Proxy = RealmProxy_Proxy;
97    type Protocol = RealmProxy_Marker;
98
99    fn from_channel(inner: fidl::Channel) -> Self {
100        Self::new(inner)
101    }
102
103    fn into_channel(self) -> fidl::Channel {
104        self.client.into_channel()
105    }
106
107    fn as_channel(&self) -> &fidl::Channel {
108        self.client.as_channel()
109    }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl RealmProxy_SynchronousProxy {
114    pub fn new(channel: fidl::Channel) -> Self {
115        let protocol_name = <RealmProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
116        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
117    }
118
119    pub fn into_channel(self) -> fidl::Channel {
120        self.client.into_channel()
121    }
122
123    /// Waits until an event arrives and returns it. It is safe for other
124    /// threads to make concurrent requests while waiting for an event.
125    pub fn wait_for_event(
126        &self,
127        deadline: zx::MonotonicInstant,
128    ) -> Result<RealmProxy_Event, fidl::Error> {
129        RealmProxy_Event::decode(self.client.wait_for_event(deadline)?)
130    }
131
132    /// Connects [server_end] to the [protocol] from this proxy's namespace.
133    pub fn r#connect_to_named_protocol(
134        &self,
135        mut protocol: &str,
136        mut server_end: fidl::Channel,
137        ___deadline: zx::MonotonicInstant,
138    ) -> Result<RealmProxyConnectToNamedProtocolResult, fidl::Error> {
139        let _response = self.client.send_query::<
140            RealmProxyConnectToNamedProtocolRequest,
141            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OperationError>,
142        >(
143            (protocol, server_end,),
144            0x159b4ba0b614ecc4,
145            fidl::encoding::DynamicFlags::empty(),
146            ___deadline,
147        )?;
148        Ok(_response.map(|x| x))
149    }
150
151    /// Connects [server_end] to the [service] directory from this proxy's namespace.
152    pub fn r#open_service(
153        &self,
154        mut service: &str,
155        mut server_end: fidl::Channel,
156        ___deadline: zx::MonotonicInstant,
157    ) -> Result<RealmProxyOpenServiceResult, fidl::Error> {
158        let _response = self.client.send_query::<
159            RealmProxyOpenServiceRequest,
160            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OperationError>,
161        >(
162            (service, server_end,),
163            0x7e4f670a6ec5986a,
164            fidl::encoding::DynamicFlags::empty(),
165            ___deadline,
166        )?;
167        Ok(_response.map(|x| x))
168    }
169
170    /// Connects [server_end] to the [service]/[instance] from this proxy's namespace.
171    pub fn r#connect_to_service_instance(
172        &self,
173        mut service: &str,
174        mut instance: &str,
175        mut server_end: fidl::Channel,
176        ___deadline: zx::MonotonicInstant,
177    ) -> Result<RealmProxyConnectToServiceInstanceResult, fidl::Error> {
178        let _response = self.client.send_query::<
179            RealmProxyConnectToServiceInstanceRequest,
180            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OperationError>,
181        >(
182            (service, instance, server_end,),
183            0x39111e790d55bbf,
184            fidl::encoding::DynamicFlags::empty(),
185            ___deadline,
186        )?;
187        Ok(_response.map(|x| x))
188    }
189}
190
191#[cfg(target_os = "fuchsia")]
192impl From<RealmProxy_SynchronousProxy> for zx::Handle {
193    fn from(value: RealmProxy_SynchronousProxy) -> Self {
194        value.into_channel().into()
195    }
196}
197
198#[cfg(target_os = "fuchsia")]
199impl From<fidl::Channel> for RealmProxy_SynchronousProxy {
200    fn from(value: fidl::Channel) -> Self {
201        Self::new(value)
202    }
203}
204
205#[cfg(target_os = "fuchsia")]
206impl fidl::endpoints::FromClient for RealmProxy_SynchronousProxy {
207    type Protocol = RealmProxy_Marker;
208
209    fn from_client(value: fidl::endpoints::ClientEnd<RealmProxy_Marker>) -> Self {
210        Self::new(value.into_channel())
211    }
212}
213
214#[derive(Debug, Clone)]
215pub struct RealmProxy_Proxy {
216    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
217}
218
219impl fidl::endpoints::Proxy for RealmProxy_Proxy {
220    type Protocol = RealmProxy_Marker;
221
222    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
223        Self::new(inner)
224    }
225
226    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
227        self.client.into_channel().map_err(|client| Self { client })
228    }
229
230    fn as_channel(&self) -> &::fidl::AsyncChannel {
231        self.client.as_channel()
232    }
233}
234
235impl RealmProxy_Proxy {
236    /// Create a new Proxy for fuchsia.testing.harness/RealmProxy.
237    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
238        let protocol_name = <RealmProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
239        Self { client: fidl::client::Client::new(channel, protocol_name) }
240    }
241
242    /// Get a Stream of events from the remote end of the protocol.
243    ///
244    /// # Panics
245    ///
246    /// Panics if the event stream was already taken.
247    pub fn take_event_stream(&self) -> RealmProxy_EventStream {
248        RealmProxy_EventStream { event_receiver: self.client.take_event_receiver() }
249    }
250
251    /// Connects [server_end] to the [protocol] from this proxy's namespace.
252    pub fn r#connect_to_named_protocol(
253        &self,
254        mut protocol: &str,
255        mut server_end: fidl::Channel,
256    ) -> fidl::client::QueryResponseFut<
257        RealmProxyConnectToNamedProtocolResult,
258        fidl::encoding::DefaultFuchsiaResourceDialect,
259    > {
260        RealmProxy_ProxyInterface::r#connect_to_named_protocol(self, protocol, server_end)
261    }
262
263    /// Connects [server_end] to the [service] directory from this proxy's namespace.
264    pub fn r#open_service(
265        &self,
266        mut service: &str,
267        mut server_end: fidl::Channel,
268    ) -> fidl::client::QueryResponseFut<
269        RealmProxyOpenServiceResult,
270        fidl::encoding::DefaultFuchsiaResourceDialect,
271    > {
272        RealmProxy_ProxyInterface::r#open_service(self, service, server_end)
273    }
274
275    /// Connects [server_end] to the [service]/[instance] from this proxy's namespace.
276    pub fn r#connect_to_service_instance(
277        &self,
278        mut service: &str,
279        mut instance: &str,
280        mut server_end: fidl::Channel,
281    ) -> fidl::client::QueryResponseFut<
282        RealmProxyConnectToServiceInstanceResult,
283        fidl::encoding::DefaultFuchsiaResourceDialect,
284    > {
285        RealmProxy_ProxyInterface::r#connect_to_service_instance(
286            self, service, instance, server_end,
287        )
288    }
289}
290
291impl RealmProxy_ProxyInterface for RealmProxy_Proxy {
292    type ConnectToNamedProtocolResponseFut = fidl::client::QueryResponseFut<
293        RealmProxyConnectToNamedProtocolResult,
294        fidl::encoding::DefaultFuchsiaResourceDialect,
295    >;
296    fn r#connect_to_named_protocol(
297        &self,
298        mut protocol: &str,
299        mut server_end: fidl::Channel,
300    ) -> Self::ConnectToNamedProtocolResponseFut {
301        fn _decode(
302            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
303        ) -> Result<RealmProxyConnectToNamedProtocolResult, fidl::Error> {
304            let _response = fidl::client::decode_transaction_body::<
305                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OperationError>,
306                fidl::encoding::DefaultFuchsiaResourceDialect,
307                0x159b4ba0b614ecc4,
308            >(_buf?)?;
309            Ok(_response.map(|x| x))
310        }
311        self.client.send_query_and_decode::<
312            RealmProxyConnectToNamedProtocolRequest,
313            RealmProxyConnectToNamedProtocolResult,
314        >(
315            (protocol, server_end,),
316            0x159b4ba0b614ecc4,
317            fidl::encoding::DynamicFlags::empty(),
318            _decode,
319        )
320    }
321
322    type OpenServiceResponseFut = fidl::client::QueryResponseFut<
323        RealmProxyOpenServiceResult,
324        fidl::encoding::DefaultFuchsiaResourceDialect,
325    >;
326    fn r#open_service(
327        &self,
328        mut service: &str,
329        mut server_end: fidl::Channel,
330    ) -> Self::OpenServiceResponseFut {
331        fn _decode(
332            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
333        ) -> Result<RealmProxyOpenServiceResult, fidl::Error> {
334            let _response = fidl::client::decode_transaction_body::<
335                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OperationError>,
336                fidl::encoding::DefaultFuchsiaResourceDialect,
337                0x7e4f670a6ec5986a,
338            >(_buf?)?;
339            Ok(_response.map(|x| x))
340        }
341        self.client
342            .send_query_and_decode::<RealmProxyOpenServiceRequest, RealmProxyOpenServiceResult>(
343                (service, server_end),
344                0x7e4f670a6ec5986a,
345                fidl::encoding::DynamicFlags::empty(),
346                _decode,
347            )
348    }
349
350    type ConnectToServiceInstanceResponseFut = fidl::client::QueryResponseFut<
351        RealmProxyConnectToServiceInstanceResult,
352        fidl::encoding::DefaultFuchsiaResourceDialect,
353    >;
354    fn r#connect_to_service_instance(
355        &self,
356        mut service: &str,
357        mut instance: &str,
358        mut server_end: fidl::Channel,
359    ) -> Self::ConnectToServiceInstanceResponseFut {
360        fn _decode(
361            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
362        ) -> Result<RealmProxyConnectToServiceInstanceResult, fidl::Error> {
363            let _response = fidl::client::decode_transaction_body::<
364                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OperationError>,
365                fidl::encoding::DefaultFuchsiaResourceDialect,
366                0x39111e790d55bbf,
367            >(_buf?)?;
368            Ok(_response.map(|x| x))
369        }
370        self.client.send_query_and_decode::<
371            RealmProxyConnectToServiceInstanceRequest,
372            RealmProxyConnectToServiceInstanceResult,
373        >(
374            (service, instance, server_end,),
375            0x39111e790d55bbf,
376            fidl::encoding::DynamicFlags::empty(),
377            _decode,
378        )
379    }
380}
381
382pub struct RealmProxy_EventStream {
383    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
384}
385
386impl std::marker::Unpin for RealmProxy_EventStream {}
387
388impl futures::stream::FusedStream for RealmProxy_EventStream {
389    fn is_terminated(&self) -> bool {
390        self.event_receiver.is_terminated()
391    }
392}
393
394impl futures::Stream for RealmProxy_EventStream {
395    type Item = Result<RealmProxy_Event, fidl::Error>;
396
397    fn poll_next(
398        mut self: std::pin::Pin<&mut Self>,
399        cx: &mut std::task::Context<'_>,
400    ) -> std::task::Poll<Option<Self::Item>> {
401        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
402            &mut self.event_receiver,
403            cx
404        )?) {
405            Some(buf) => std::task::Poll::Ready(Some(RealmProxy_Event::decode(buf))),
406            None => std::task::Poll::Ready(None),
407        }
408    }
409}
410
411#[derive(Debug)]
412pub enum RealmProxy_Event {}
413
414impl RealmProxy_Event {
415    /// Decodes a message buffer as a [`RealmProxy_Event`].
416    fn decode(
417        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
418    ) -> Result<RealmProxy_Event, fidl::Error> {
419        let (bytes, _handles) = buf.split_mut();
420        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
421        debug_assert_eq!(tx_header.tx_id, 0);
422        match tx_header.ordinal {
423            _ => Err(fidl::Error::UnknownOrdinal {
424                ordinal: tx_header.ordinal,
425                protocol_name: <RealmProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
426            }),
427        }
428    }
429}
430
431/// A Stream of incoming requests for fuchsia.testing.harness/RealmProxy.
432pub struct RealmProxy_RequestStream {
433    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
434    is_terminated: bool,
435}
436
437impl std::marker::Unpin for RealmProxy_RequestStream {}
438
439impl futures::stream::FusedStream for RealmProxy_RequestStream {
440    fn is_terminated(&self) -> bool {
441        self.is_terminated
442    }
443}
444
445impl fidl::endpoints::RequestStream for RealmProxy_RequestStream {
446    type Protocol = RealmProxy_Marker;
447    type ControlHandle = RealmProxy_ControlHandle;
448
449    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
450        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
451    }
452
453    fn control_handle(&self) -> Self::ControlHandle {
454        RealmProxy_ControlHandle { inner: self.inner.clone() }
455    }
456
457    fn into_inner(
458        self,
459    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
460    {
461        (self.inner, self.is_terminated)
462    }
463
464    fn from_inner(
465        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
466        is_terminated: bool,
467    ) -> Self {
468        Self { inner, is_terminated }
469    }
470}
471
472impl futures::Stream for RealmProxy_RequestStream {
473    type Item = Result<RealmProxy_Request, fidl::Error>;
474
475    fn poll_next(
476        mut self: std::pin::Pin<&mut Self>,
477        cx: &mut std::task::Context<'_>,
478    ) -> std::task::Poll<Option<Self::Item>> {
479        let this = &mut *self;
480        if this.inner.check_shutdown(cx) {
481            this.is_terminated = true;
482            return std::task::Poll::Ready(None);
483        }
484        if this.is_terminated {
485            panic!("polled RealmProxy_RequestStream after completion");
486        }
487        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
488            |bytes, handles| {
489                match this.inner.channel().read_etc(cx, bytes, handles) {
490                    std::task::Poll::Ready(Ok(())) => {}
491                    std::task::Poll::Pending => return std::task::Poll::Pending,
492                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
493                        this.is_terminated = true;
494                        return std::task::Poll::Ready(None);
495                    }
496                    std::task::Poll::Ready(Err(e)) => {
497                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
498                            e.into(),
499                        ))))
500                    }
501                }
502
503                // A message has been received from the channel
504                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
505
506                std::task::Poll::Ready(Some(match header.ordinal {
507                    0x159b4ba0b614ecc4 => {
508                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
509                        let mut req = fidl::new_empty!(
510                            RealmProxyConnectToNamedProtocolRequest,
511                            fidl::encoding::DefaultFuchsiaResourceDialect
512                        );
513                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmProxyConnectToNamedProtocolRequest>(&header, _body_bytes, handles, &mut req)?;
514                        let control_handle = RealmProxy_ControlHandle { inner: this.inner.clone() };
515                        Ok(RealmProxy_Request::ConnectToNamedProtocol {
516                            protocol: req.protocol,
517                            server_end: req.server_end,
518
519                            responder: RealmProxy_ConnectToNamedProtocolResponder {
520                                control_handle: std::mem::ManuallyDrop::new(control_handle),
521                                tx_id: header.tx_id,
522                            },
523                        })
524                    }
525                    0x7e4f670a6ec5986a => {
526                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
527                        let mut req = fidl::new_empty!(
528                            RealmProxyOpenServiceRequest,
529                            fidl::encoding::DefaultFuchsiaResourceDialect
530                        );
531                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmProxyOpenServiceRequest>(&header, _body_bytes, handles, &mut req)?;
532                        let control_handle = RealmProxy_ControlHandle { inner: this.inner.clone() };
533                        Ok(RealmProxy_Request::OpenService {
534                            service: req.service,
535                            server_end: req.server_end,
536
537                            responder: RealmProxy_OpenServiceResponder {
538                                control_handle: std::mem::ManuallyDrop::new(control_handle),
539                                tx_id: header.tx_id,
540                            },
541                        })
542                    }
543                    0x39111e790d55bbf => {
544                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
545                        let mut req = fidl::new_empty!(
546                            RealmProxyConnectToServiceInstanceRequest,
547                            fidl::encoding::DefaultFuchsiaResourceDialect
548                        );
549                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmProxyConnectToServiceInstanceRequest>(&header, _body_bytes, handles, &mut req)?;
550                        let control_handle = RealmProxy_ControlHandle { inner: this.inner.clone() };
551                        Ok(RealmProxy_Request::ConnectToServiceInstance {
552                            service: req.service,
553                            instance: req.instance,
554                            server_end: req.server_end,
555
556                            responder: RealmProxy_ConnectToServiceInstanceResponder {
557                                control_handle: std::mem::ManuallyDrop::new(control_handle),
558                                tx_id: header.tx_id,
559                            },
560                        })
561                    }
562                    _ => Err(fidl::Error::UnknownOrdinal {
563                        ordinal: header.ordinal,
564                        protocol_name:
565                            <RealmProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
566                    }),
567                }))
568            },
569        )
570    }
571}
572
573/// This protocol mediates a test suite's access to a component under test.
574///
575/// A RealmProxy is a test harness which allows some test suite to create instances
576/// of the component(s) under test on demand. Most importantly, the test suite
577/// does not have to know which components are created or how they are created;
578/// It is only required to know which capabilities the components expose.
579///
580/// For example, a generic test suite for Fuchsia filesystems can use the RealmProxy
581/// protocol to spawn components that serve protocols from the fuchsia.io FIDL
582/// library. The test suite doesn't need to know which filesystem it's testing
583/// or how the filesystem is initialized. It just needs to call
584/// [ConnectToNamedProtocol] with the name of a fuchsia.io protocol and start
585/// testing. By running this test suite with different proxies that initialize
586/// different filesystems, we can use the same suite to validate each system.
587///
588/// WARNING: RealmProxy will soon be deprecated. Prefer to return a
589/// fuchsia.component.sandbox.DictionaryRef and install that into your namespace.
590#[derive(Debug)]
591pub enum RealmProxy_Request {
592    /// Connects [server_end] to the [protocol] from this proxy's namespace.
593    ConnectToNamedProtocol {
594        protocol: String,
595        server_end: fidl::Channel,
596        responder: RealmProxy_ConnectToNamedProtocolResponder,
597    },
598    /// Connects [server_end] to the [service] directory from this proxy's namespace.
599    OpenService {
600        service: String,
601        server_end: fidl::Channel,
602        responder: RealmProxy_OpenServiceResponder,
603    },
604    /// Connects [server_end] to the [service]/[instance] from this proxy's namespace.
605    ConnectToServiceInstance {
606        service: String,
607        instance: String,
608        server_end: fidl::Channel,
609        responder: RealmProxy_ConnectToServiceInstanceResponder,
610    },
611}
612
613impl RealmProxy_Request {
614    #[allow(irrefutable_let_patterns)]
615    pub fn into_connect_to_named_protocol(
616        self,
617    ) -> Option<(String, fidl::Channel, RealmProxy_ConnectToNamedProtocolResponder)> {
618        if let RealmProxy_Request::ConnectToNamedProtocol { protocol, server_end, responder } = self
619        {
620            Some((protocol, server_end, responder))
621        } else {
622            None
623        }
624    }
625
626    #[allow(irrefutable_let_patterns)]
627    pub fn into_open_service(
628        self,
629    ) -> Option<(String, fidl::Channel, RealmProxy_OpenServiceResponder)> {
630        if let RealmProxy_Request::OpenService { service, server_end, responder } = self {
631            Some((service, server_end, responder))
632        } else {
633            None
634        }
635    }
636
637    #[allow(irrefutable_let_patterns)]
638    pub fn into_connect_to_service_instance(
639        self,
640    ) -> Option<(String, String, fidl::Channel, RealmProxy_ConnectToServiceInstanceResponder)> {
641        if let RealmProxy_Request::ConnectToServiceInstance {
642            service,
643            instance,
644            server_end,
645            responder,
646        } = self
647        {
648            Some((service, instance, server_end, responder))
649        } else {
650            None
651        }
652    }
653
654    /// Name of the method defined in FIDL
655    pub fn method_name(&self) -> &'static str {
656        match *self {
657            RealmProxy_Request::ConnectToNamedProtocol { .. } => "connect_to_named_protocol",
658            RealmProxy_Request::OpenService { .. } => "open_service",
659            RealmProxy_Request::ConnectToServiceInstance { .. } => "connect_to_service_instance",
660        }
661    }
662}
663
664#[derive(Debug, Clone)]
665pub struct RealmProxy_ControlHandle {
666    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
667}
668
669impl fidl::endpoints::ControlHandle for RealmProxy_ControlHandle {
670    fn shutdown(&self) {
671        self.inner.shutdown()
672    }
673    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
674        self.inner.shutdown_with_epitaph(status)
675    }
676
677    fn is_closed(&self) -> bool {
678        self.inner.channel().is_closed()
679    }
680    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
681        self.inner.channel().on_closed()
682    }
683
684    #[cfg(target_os = "fuchsia")]
685    fn signal_peer(
686        &self,
687        clear_mask: zx::Signals,
688        set_mask: zx::Signals,
689    ) -> Result<(), zx_status::Status> {
690        use fidl::Peered;
691        self.inner.channel().signal_peer(clear_mask, set_mask)
692    }
693}
694
695impl RealmProxy_ControlHandle {}
696
697#[must_use = "FIDL methods require a response to be sent"]
698#[derive(Debug)]
699pub struct RealmProxy_ConnectToNamedProtocolResponder {
700    control_handle: std::mem::ManuallyDrop<RealmProxy_ControlHandle>,
701    tx_id: u32,
702}
703
704/// Set the the channel to be shutdown (see [`RealmProxy_ControlHandle::shutdown`])
705/// if the responder is dropped without sending a response, so that the client
706/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
707impl std::ops::Drop for RealmProxy_ConnectToNamedProtocolResponder {
708    fn drop(&mut self) {
709        self.control_handle.shutdown();
710        // Safety: drops once, never accessed again
711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
712    }
713}
714
715impl fidl::endpoints::Responder for RealmProxy_ConnectToNamedProtocolResponder {
716    type ControlHandle = RealmProxy_ControlHandle;
717
718    fn control_handle(&self) -> &RealmProxy_ControlHandle {
719        &self.control_handle
720    }
721
722    fn drop_without_shutdown(mut self) {
723        // Safety: drops once, never accessed again due to mem::forget
724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
725        // Prevent Drop from running (which would shut down the channel)
726        std::mem::forget(self);
727    }
728}
729
730impl RealmProxy_ConnectToNamedProtocolResponder {
731    /// Sends a response to the FIDL transaction.
732    ///
733    /// Sets the channel to shutdown if an error occurs.
734    pub fn send(self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
735        let _result = self.send_raw(result);
736        if _result.is_err() {
737            self.control_handle.shutdown();
738        }
739        self.drop_without_shutdown();
740        _result
741    }
742
743    /// Similar to "send" but does not shutdown the channel if an error occurs.
744    pub fn send_no_shutdown_on_err(
745        self,
746        mut result: Result<(), OperationError>,
747    ) -> Result<(), fidl::Error> {
748        let _result = self.send_raw(result);
749        self.drop_without_shutdown();
750        _result
751    }
752
753    fn send_raw(&self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
754        self.control_handle.inner.send::<fidl::encoding::ResultType<
755            fidl::encoding::EmptyStruct,
756            OperationError,
757        >>(
758            result,
759            self.tx_id,
760            0x159b4ba0b614ecc4,
761            fidl::encoding::DynamicFlags::empty(),
762        )
763    }
764}
765
766#[must_use = "FIDL methods require a response to be sent"]
767#[derive(Debug)]
768pub struct RealmProxy_OpenServiceResponder {
769    control_handle: std::mem::ManuallyDrop<RealmProxy_ControlHandle>,
770    tx_id: u32,
771}
772
773/// Set the the channel to be shutdown (see [`RealmProxy_ControlHandle::shutdown`])
774/// if the responder is dropped without sending a response, so that the client
775/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
776impl std::ops::Drop for RealmProxy_OpenServiceResponder {
777    fn drop(&mut self) {
778        self.control_handle.shutdown();
779        // Safety: drops once, never accessed again
780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
781    }
782}
783
784impl fidl::endpoints::Responder for RealmProxy_OpenServiceResponder {
785    type ControlHandle = RealmProxy_ControlHandle;
786
787    fn control_handle(&self) -> &RealmProxy_ControlHandle {
788        &self.control_handle
789    }
790
791    fn drop_without_shutdown(mut self) {
792        // Safety: drops once, never accessed again due to mem::forget
793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
794        // Prevent Drop from running (which would shut down the channel)
795        std::mem::forget(self);
796    }
797}
798
799impl RealmProxy_OpenServiceResponder {
800    /// Sends a response to the FIDL transaction.
801    ///
802    /// Sets the channel to shutdown if an error occurs.
803    pub fn send(self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
804        let _result = self.send_raw(result);
805        if _result.is_err() {
806            self.control_handle.shutdown();
807        }
808        self.drop_without_shutdown();
809        _result
810    }
811
812    /// Similar to "send" but does not shutdown the channel if an error occurs.
813    pub fn send_no_shutdown_on_err(
814        self,
815        mut result: Result<(), OperationError>,
816    ) -> Result<(), fidl::Error> {
817        let _result = self.send_raw(result);
818        self.drop_without_shutdown();
819        _result
820    }
821
822    fn send_raw(&self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
823        self.control_handle.inner.send::<fidl::encoding::ResultType<
824            fidl::encoding::EmptyStruct,
825            OperationError,
826        >>(
827            result,
828            self.tx_id,
829            0x7e4f670a6ec5986a,
830            fidl::encoding::DynamicFlags::empty(),
831        )
832    }
833}
834
835#[must_use = "FIDL methods require a response to be sent"]
836#[derive(Debug)]
837pub struct RealmProxy_ConnectToServiceInstanceResponder {
838    control_handle: std::mem::ManuallyDrop<RealmProxy_ControlHandle>,
839    tx_id: u32,
840}
841
842/// Set the the channel to be shutdown (see [`RealmProxy_ControlHandle::shutdown`])
843/// if the responder is dropped without sending a response, so that the client
844/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
845impl std::ops::Drop for RealmProxy_ConnectToServiceInstanceResponder {
846    fn drop(&mut self) {
847        self.control_handle.shutdown();
848        // Safety: drops once, never accessed again
849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
850    }
851}
852
853impl fidl::endpoints::Responder for RealmProxy_ConnectToServiceInstanceResponder {
854    type ControlHandle = RealmProxy_ControlHandle;
855
856    fn control_handle(&self) -> &RealmProxy_ControlHandle {
857        &self.control_handle
858    }
859
860    fn drop_without_shutdown(mut self) {
861        // Safety: drops once, never accessed again due to mem::forget
862        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
863        // Prevent Drop from running (which would shut down the channel)
864        std::mem::forget(self);
865    }
866}
867
868impl RealmProxy_ConnectToServiceInstanceResponder {
869    /// Sends a response to the FIDL transaction.
870    ///
871    /// Sets the channel to shutdown if an error occurs.
872    pub fn send(self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
873        let _result = self.send_raw(result);
874        if _result.is_err() {
875            self.control_handle.shutdown();
876        }
877        self.drop_without_shutdown();
878        _result
879    }
880
881    /// Similar to "send" but does not shutdown the channel if an error occurs.
882    pub fn send_no_shutdown_on_err(
883        self,
884        mut result: Result<(), OperationError>,
885    ) -> Result<(), fidl::Error> {
886        let _result = self.send_raw(result);
887        self.drop_without_shutdown();
888        _result
889    }
890
891    fn send_raw(&self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
892        self.control_handle.inner.send::<fidl::encoding::ResultType<
893            fidl::encoding::EmptyStruct,
894            OperationError,
895        >>(
896            result,
897            self.tx_id,
898            0x39111e790d55bbf,
899            fidl::encoding::DynamicFlags::empty(),
900        )
901    }
902}
903
904mod internal {
905    use super::*;
906
907    impl fidl::encoding::ResourceTypeMarker for RealmProxyConnectToNamedProtocolRequest {
908        type Borrowed<'a> = &'a mut Self;
909        fn take_or_borrow<'a>(
910            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
911        ) -> Self::Borrowed<'a> {
912            value
913        }
914    }
915
916    unsafe impl fidl::encoding::TypeMarker for RealmProxyConnectToNamedProtocolRequest {
917        type Owned = Self;
918
919        #[inline(always)]
920        fn inline_align(_context: fidl::encoding::Context) -> usize {
921            8
922        }
923
924        #[inline(always)]
925        fn inline_size(_context: fidl::encoding::Context) -> usize {
926            24
927        }
928    }
929
930    unsafe impl
931        fidl::encoding::Encode<
932            RealmProxyConnectToNamedProtocolRequest,
933            fidl::encoding::DefaultFuchsiaResourceDialect,
934        > for &mut RealmProxyConnectToNamedProtocolRequest
935    {
936        #[inline]
937        unsafe fn encode(
938            self,
939            encoder: &mut fidl::encoding::Encoder<
940                '_,
941                fidl::encoding::DefaultFuchsiaResourceDialect,
942            >,
943            offset: usize,
944            _depth: fidl::encoding::Depth,
945        ) -> fidl::Result<()> {
946            encoder.debug_check_bounds::<RealmProxyConnectToNamedProtocolRequest>(offset);
947            // Delegate to tuple encoding.
948            fidl::encoding::Encode::<
949                RealmProxyConnectToNamedProtocolRequest,
950                fidl::encoding::DefaultFuchsiaResourceDialect,
951            >::encode(
952                (
953                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
954                        &self.protocol,
955                    ),
956                    <fidl::encoding::HandleType<
957                        fidl::Channel,
958                        { fidl::ObjectType::CHANNEL.into_raw() },
959                        2147483648,
960                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
961                        &mut self.server_end
962                    ),
963                ),
964                encoder,
965                offset,
966                _depth,
967            )
968        }
969    }
970    unsafe impl<
971            T0: fidl::encoding::Encode<
972                fidl::encoding::BoundedString<255>,
973                fidl::encoding::DefaultFuchsiaResourceDialect,
974            >,
975            T1: fidl::encoding::Encode<
976                fidl::encoding::HandleType<
977                    fidl::Channel,
978                    { fidl::ObjectType::CHANNEL.into_raw() },
979                    2147483648,
980                >,
981                fidl::encoding::DefaultFuchsiaResourceDialect,
982            >,
983        >
984        fidl::encoding::Encode<
985            RealmProxyConnectToNamedProtocolRequest,
986            fidl::encoding::DefaultFuchsiaResourceDialect,
987        > for (T0, T1)
988    {
989        #[inline]
990        unsafe fn encode(
991            self,
992            encoder: &mut fidl::encoding::Encoder<
993                '_,
994                fidl::encoding::DefaultFuchsiaResourceDialect,
995            >,
996            offset: usize,
997            depth: fidl::encoding::Depth,
998        ) -> fidl::Result<()> {
999            encoder.debug_check_bounds::<RealmProxyConnectToNamedProtocolRequest>(offset);
1000            // Zero out padding regions. There's no need to apply masks
1001            // because the unmasked parts will be overwritten by fields.
1002            unsafe {
1003                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1004                (ptr as *mut u64).write_unaligned(0);
1005            }
1006            // Write the fields.
1007            self.0.encode(encoder, offset + 0, depth)?;
1008            self.1.encode(encoder, offset + 16, depth)?;
1009            Ok(())
1010        }
1011    }
1012
1013    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1014        for RealmProxyConnectToNamedProtocolRequest
1015    {
1016        #[inline(always)]
1017        fn new_empty() -> Self {
1018            Self {
1019                protocol: fidl::new_empty!(
1020                    fidl::encoding::BoundedString<255>,
1021                    fidl::encoding::DefaultFuchsiaResourceDialect
1022                ),
1023                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1024            }
1025        }
1026
1027        #[inline]
1028        unsafe fn decode(
1029            &mut self,
1030            decoder: &mut fidl::encoding::Decoder<
1031                '_,
1032                fidl::encoding::DefaultFuchsiaResourceDialect,
1033            >,
1034            offset: usize,
1035            _depth: fidl::encoding::Depth,
1036        ) -> fidl::Result<()> {
1037            decoder.debug_check_bounds::<Self>(offset);
1038            // Verify that padding bytes are zero.
1039            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1040            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1041            let mask = 0xffffffff00000000u64;
1042            let maskedval = padval & mask;
1043            if maskedval != 0 {
1044                return Err(fidl::Error::NonZeroPadding {
1045                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1046                });
1047            }
1048            fidl::decode!(
1049                fidl::encoding::BoundedString<255>,
1050                fidl::encoding::DefaultFuchsiaResourceDialect,
1051                &mut self.protocol,
1052                decoder,
1053                offset + 0,
1054                _depth
1055            )?;
1056            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 16, _depth)?;
1057            Ok(())
1058        }
1059    }
1060
1061    impl fidl::encoding::ResourceTypeMarker for RealmProxyConnectToServiceInstanceRequest {
1062        type Borrowed<'a> = &'a mut Self;
1063        fn take_or_borrow<'a>(
1064            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1065        ) -> Self::Borrowed<'a> {
1066            value
1067        }
1068    }
1069
1070    unsafe impl fidl::encoding::TypeMarker for RealmProxyConnectToServiceInstanceRequest {
1071        type Owned = Self;
1072
1073        #[inline(always)]
1074        fn inline_align(_context: fidl::encoding::Context) -> usize {
1075            8
1076        }
1077
1078        #[inline(always)]
1079        fn inline_size(_context: fidl::encoding::Context) -> usize {
1080            40
1081        }
1082    }
1083
1084    unsafe impl
1085        fidl::encoding::Encode<
1086            RealmProxyConnectToServiceInstanceRequest,
1087            fidl::encoding::DefaultFuchsiaResourceDialect,
1088        > for &mut RealmProxyConnectToServiceInstanceRequest
1089    {
1090        #[inline]
1091        unsafe fn encode(
1092            self,
1093            encoder: &mut fidl::encoding::Encoder<
1094                '_,
1095                fidl::encoding::DefaultFuchsiaResourceDialect,
1096            >,
1097            offset: usize,
1098            _depth: fidl::encoding::Depth,
1099        ) -> fidl::Result<()> {
1100            encoder.debug_check_bounds::<RealmProxyConnectToServiceInstanceRequest>(offset);
1101            // Delegate to tuple encoding.
1102            fidl::encoding::Encode::<
1103                RealmProxyConnectToServiceInstanceRequest,
1104                fidl::encoding::DefaultFuchsiaResourceDialect,
1105            >::encode(
1106                (
1107                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1108                        &self.service,
1109                    ),
1110                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1111                        &self.instance,
1112                    ),
1113                    <fidl::encoding::HandleType<
1114                        fidl::Channel,
1115                        { fidl::ObjectType::CHANNEL.into_raw() },
1116                        2147483648,
1117                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1118                        &mut self.server_end
1119                    ),
1120                ),
1121                encoder,
1122                offset,
1123                _depth,
1124            )
1125        }
1126    }
1127    unsafe impl<
1128            T0: fidl::encoding::Encode<
1129                fidl::encoding::BoundedString<255>,
1130                fidl::encoding::DefaultFuchsiaResourceDialect,
1131            >,
1132            T1: fidl::encoding::Encode<
1133                fidl::encoding::BoundedString<255>,
1134                fidl::encoding::DefaultFuchsiaResourceDialect,
1135            >,
1136            T2: fidl::encoding::Encode<
1137                fidl::encoding::HandleType<
1138                    fidl::Channel,
1139                    { fidl::ObjectType::CHANNEL.into_raw() },
1140                    2147483648,
1141                >,
1142                fidl::encoding::DefaultFuchsiaResourceDialect,
1143            >,
1144        >
1145        fidl::encoding::Encode<
1146            RealmProxyConnectToServiceInstanceRequest,
1147            fidl::encoding::DefaultFuchsiaResourceDialect,
1148        > for (T0, T1, T2)
1149    {
1150        #[inline]
1151        unsafe fn encode(
1152            self,
1153            encoder: &mut fidl::encoding::Encoder<
1154                '_,
1155                fidl::encoding::DefaultFuchsiaResourceDialect,
1156            >,
1157            offset: usize,
1158            depth: fidl::encoding::Depth,
1159        ) -> fidl::Result<()> {
1160            encoder.debug_check_bounds::<RealmProxyConnectToServiceInstanceRequest>(offset);
1161            // Zero out padding regions. There's no need to apply masks
1162            // because the unmasked parts will be overwritten by fields.
1163            unsafe {
1164                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1165                (ptr as *mut u64).write_unaligned(0);
1166            }
1167            // Write the fields.
1168            self.0.encode(encoder, offset + 0, depth)?;
1169            self.1.encode(encoder, offset + 16, depth)?;
1170            self.2.encode(encoder, offset + 32, depth)?;
1171            Ok(())
1172        }
1173    }
1174
1175    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1176        for RealmProxyConnectToServiceInstanceRequest
1177    {
1178        #[inline(always)]
1179        fn new_empty() -> Self {
1180            Self {
1181                service: fidl::new_empty!(
1182                    fidl::encoding::BoundedString<255>,
1183                    fidl::encoding::DefaultFuchsiaResourceDialect
1184                ),
1185                instance: fidl::new_empty!(
1186                    fidl::encoding::BoundedString<255>,
1187                    fidl::encoding::DefaultFuchsiaResourceDialect
1188                ),
1189                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1190            }
1191        }
1192
1193        #[inline]
1194        unsafe fn decode(
1195            &mut self,
1196            decoder: &mut fidl::encoding::Decoder<
1197                '_,
1198                fidl::encoding::DefaultFuchsiaResourceDialect,
1199            >,
1200            offset: usize,
1201            _depth: fidl::encoding::Depth,
1202        ) -> fidl::Result<()> {
1203            decoder.debug_check_bounds::<Self>(offset);
1204            // Verify that padding bytes are zero.
1205            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1206            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1207            let mask = 0xffffffff00000000u64;
1208            let maskedval = padval & mask;
1209            if maskedval != 0 {
1210                return Err(fidl::Error::NonZeroPadding {
1211                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1212                });
1213            }
1214            fidl::decode!(
1215                fidl::encoding::BoundedString<255>,
1216                fidl::encoding::DefaultFuchsiaResourceDialect,
1217                &mut self.service,
1218                decoder,
1219                offset + 0,
1220                _depth
1221            )?;
1222            fidl::decode!(
1223                fidl::encoding::BoundedString<255>,
1224                fidl::encoding::DefaultFuchsiaResourceDialect,
1225                &mut self.instance,
1226                decoder,
1227                offset + 16,
1228                _depth
1229            )?;
1230            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 32, _depth)?;
1231            Ok(())
1232        }
1233    }
1234
1235    impl fidl::encoding::ResourceTypeMarker for RealmProxyOpenServiceRequest {
1236        type Borrowed<'a> = &'a mut Self;
1237        fn take_or_borrow<'a>(
1238            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1239        ) -> Self::Borrowed<'a> {
1240            value
1241        }
1242    }
1243
1244    unsafe impl fidl::encoding::TypeMarker for RealmProxyOpenServiceRequest {
1245        type Owned = Self;
1246
1247        #[inline(always)]
1248        fn inline_align(_context: fidl::encoding::Context) -> usize {
1249            8
1250        }
1251
1252        #[inline(always)]
1253        fn inline_size(_context: fidl::encoding::Context) -> usize {
1254            24
1255        }
1256    }
1257
1258    unsafe impl
1259        fidl::encoding::Encode<
1260            RealmProxyOpenServiceRequest,
1261            fidl::encoding::DefaultFuchsiaResourceDialect,
1262        > for &mut RealmProxyOpenServiceRequest
1263    {
1264        #[inline]
1265        unsafe fn encode(
1266            self,
1267            encoder: &mut fidl::encoding::Encoder<
1268                '_,
1269                fidl::encoding::DefaultFuchsiaResourceDialect,
1270            >,
1271            offset: usize,
1272            _depth: fidl::encoding::Depth,
1273        ) -> fidl::Result<()> {
1274            encoder.debug_check_bounds::<RealmProxyOpenServiceRequest>(offset);
1275            // Delegate to tuple encoding.
1276            fidl::encoding::Encode::<
1277                RealmProxyOpenServiceRequest,
1278                fidl::encoding::DefaultFuchsiaResourceDialect,
1279            >::encode(
1280                (
1281                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1282                        &self.service,
1283                    ),
1284                    <fidl::encoding::HandleType<
1285                        fidl::Channel,
1286                        { fidl::ObjectType::CHANNEL.into_raw() },
1287                        2147483648,
1288                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1289                        &mut self.server_end
1290                    ),
1291                ),
1292                encoder,
1293                offset,
1294                _depth,
1295            )
1296        }
1297    }
1298    unsafe impl<
1299            T0: fidl::encoding::Encode<
1300                fidl::encoding::BoundedString<255>,
1301                fidl::encoding::DefaultFuchsiaResourceDialect,
1302            >,
1303            T1: fidl::encoding::Encode<
1304                fidl::encoding::HandleType<
1305                    fidl::Channel,
1306                    { fidl::ObjectType::CHANNEL.into_raw() },
1307                    2147483648,
1308                >,
1309                fidl::encoding::DefaultFuchsiaResourceDialect,
1310            >,
1311        >
1312        fidl::encoding::Encode<
1313            RealmProxyOpenServiceRequest,
1314            fidl::encoding::DefaultFuchsiaResourceDialect,
1315        > for (T0, T1)
1316    {
1317        #[inline]
1318        unsafe fn encode(
1319            self,
1320            encoder: &mut fidl::encoding::Encoder<
1321                '_,
1322                fidl::encoding::DefaultFuchsiaResourceDialect,
1323            >,
1324            offset: usize,
1325            depth: fidl::encoding::Depth,
1326        ) -> fidl::Result<()> {
1327            encoder.debug_check_bounds::<RealmProxyOpenServiceRequest>(offset);
1328            // Zero out padding regions. There's no need to apply masks
1329            // because the unmasked parts will be overwritten by fields.
1330            unsafe {
1331                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1332                (ptr as *mut u64).write_unaligned(0);
1333            }
1334            // Write the fields.
1335            self.0.encode(encoder, offset + 0, depth)?;
1336            self.1.encode(encoder, offset + 16, depth)?;
1337            Ok(())
1338        }
1339    }
1340
1341    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1342        for RealmProxyOpenServiceRequest
1343    {
1344        #[inline(always)]
1345        fn new_empty() -> Self {
1346            Self {
1347                service: fidl::new_empty!(
1348                    fidl::encoding::BoundedString<255>,
1349                    fidl::encoding::DefaultFuchsiaResourceDialect
1350                ),
1351                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1352            }
1353        }
1354
1355        #[inline]
1356        unsafe fn decode(
1357            &mut self,
1358            decoder: &mut fidl::encoding::Decoder<
1359                '_,
1360                fidl::encoding::DefaultFuchsiaResourceDialect,
1361            >,
1362            offset: usize,
1363            _depth: fidl::encoding::Depth,
1364        ) -> fidl::Result<()> {
1365            decoder.debug_check_bounds::<Self>(offset);
1366            // Verify that padding bytes are zero.
1367            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1368            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1369            let mask = 0xffffffff00000000u64;
1370            let maskedval = padval & mask;
1371            if maskedval != 0 {
1372                return Err(fidl::Error::NonZeroPadding {
1373                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1374                });
1375            }
1376            fidl::decode!(
1377                fidl::encoding::BoundedString<255>,
1378                fidl::encoding::DefaultFuchsiaResourceDialect,
1379                &mut self.service,
1380                decoder,
1381                offset + 0,
1382                _depth
1383            )?;
1384            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 16, _depth)?;
1385            Ok(())
1386        }
1387    }
1388}