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::NullableHandle {
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
674    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
675        self.inner.shutdown_with_epitaph(status)
676    }
677
678    fn is_closed(&self) -> bool {
679        self.inner.channel().is_closed()
680    }
681    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
682        self.inner.channel().on_closed()
683    }
684
685    #[cfg(target_os = "fuchsia")]
686    fn signal_peer(
687        &self,
688        clear_mask: zx::Signals,
689        set_mask: zx::Signals,
690    ) -> Result<(), zx_status::Status> {
691        use fidl::Peered;
692        self.inner.channel().signal_peer(clear_mask, set_mask)
693    }
694}
695
696impl RealmProxy_ControlHandle {}
697
698#[must_use = "FIDL methods require a response to be sent"]
699#[derive(Debug)]
700pub struct RealmProxy_ConnectToNamedProtocolResponder {
701    control_handle: std::mem::ManuallyDrop<RealmProxy_ControlHandle>,
702    tx_id: u32,
703}
704
705/// Set the the channel to be shutdown (see [`RealmProxy_ControlHandle::shutdown`])
706/// if the responder is dropped without sending a response, so that the client
707/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
708impl std::ops::Drop for RealmProxy_ConnectToNamedProtocolResponder {
709    fn drop(&mut self) {
710        self.control_handle.shutdown();
711        // Safety: drops once, never accessed again
712        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
713    }
714}
715
716impl fidl::endpoints::Responder for RealmProxy_ConnectToNamedProtocolResponder {
717    type ControlHandle = RealmProxy_ControlHandle;
718
719    fn control_handle(&self) -> &RealmProxy_ControlHandle {
720        &self.control_handle
721    }
722
723    fn drop_without_shutdown(mut self) {
724        // Safety: drops once, never accessed again due to mem::forget
725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
726        // Prevent Drop from running (which would shut down the channel)
727        std::mem::forget(self);
728    }
729}
730
731impl RealmProxy_ConnectToNamedProtocolResponder {
732    /// Sends a response to the FIDL transaction.
733    ///
734    /// Sets the channel to shutdown if an error occurs.
735    pub fn send(self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
736        let _result = self.send_raw(result);
737        if _result.is_err() {
738            self.control_handle.shutdown();
739        }
740        self.drop_without_shutdown();
741        _result
742    }
743
744    /// Similar to "send" but does not shutdown the channel if an error occurs.
745    pub fn send_no_shutdown_on_err(
746        self,
747        mut result: Result<(), OperationError>,
748    ) -> Result<(), fidl::Error> {
749        let _result = self.send_raw(result);
750        self.drop_without_shutdown();
751        _result
752    }
753
754    fn send_raw(&self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
755        self.control_handle.inner.send::<fidl::encoding::ResultType<
756            fidl::encoding::EmptyStruct,
757            OperationError,
758        >>(
759            result,
760            self.tx_id,
761            0x159b4ba0b614ecc4,
762            fidl::encoding::DynamicFlags::empty(),
763        )
764    }
765}
766
767#[must_use = "FIDL methods require a response to be sent"]
768#[derive(Debug)]
769pub struct RealmProxy_OpenServiceResponder {
770    control_handle: std::mem::ManuallyDrop<RealmProxy_ControlHandle>,
771    tx_id: u32,
772}
773
774/// Set the the channel to be shutdown (see [`RealmProxy_ControlHandle::shutdown`])
775/// if the responder is dropped without sending a response, so that the client
776/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
777impl std::ops::Drop for RealmProxy_OpenServiceResponder {
778    fn drop(&mut self) {
779        self.control_handle.shutdown();
780        // Safety: drops once, never accessed again
781        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
782    }
783}
784
785impl fidl::endpoints::Responder for RealmProxy_OpenServiceResponder {
786    type ControlHandle = RealmProxy_ControlHandle;
787
788    fn control_handle(&self) -> &RealmProxy_ControlHandle {
789        &self.control_handle
790    }
791
792    fn drop_without_shutdown(mut self) {
793        // Safety: drops once, never accessed again due to mem::forget
794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
795        // Prevent Drop from running (which would shut down the channel)
796        std::mem::forget(self);
797    }
798}
799
800impl RealmProxy_OpenServiceResponder {
801    /// Sends a response to the FIDL transaction.
802    ///
803    /// Sets the channel to shutdown if an error occurs.
804    pub fn send(self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
805        let _result = self.send_raw(result);
806        if _result.is_err() {
807            self.control_handle.shutdown();
808        }
809        self.drop_without_shutdown();
810        _result
811    }
812
813    /// Similar to "send" but does not shutdown the channel if an error occurs.
814    pub fn send_no_shutdown_on_err(
815        self,
816        mut result: Result<(), OperationError>,
817    ) -> Result<(), fidl::Error> {
818        let _result = self.send_raw(result);
819        self.drop_without_shutdown();
820        _result
821    }
822
823    fn send_raw(&self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
824        self.control_handle.inner.send::<fidl::encoding::ResultType<
825            fidl::encoding::EmptyStruct,
826            OperationError,
827        >>(
828            result,
829            self.tx_id,
830            0x7e4f670a6ec5986a,
831            fidl::encoding::DynamicFlags::empty(),
832        )
833    }
834}
835
836#[must_use = "FIDL methods require a response to be sent"]
837#[derive(Debug)]
838pub struct RealmProxy_ConnectToServiceInstanceResponder {
839    control_handle: std::mem::ManuallyDrop<RealmProxy_ControlHandle>,
840    tx_id: u32,
841}
842
843/// Set the the channel to be shutdown (see [`RealmProxy_ControlHandle::shutdown`])
844/// if the responder is dropped without sending a response, so that the client
845/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
846impl std::ops::Drop for RealmProxy_ConnectToServiceInstanceResponder {
847    fn drop(&mut self) {
848        self.control_handle.shutdown();
849        // Safety: drops once, never accessed again
850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
851    }
852}
853
854impl fidl::endpoints::Responder for RealmProxy_ConnectToServiceInstanceResponder {
855    type ControlHandle = RealmProxy_ControlHandle;
856
857    fn control_handle(&self) -> &RealmProxy_ControlHandle {
858        &self.control_handle
859    }
860
861    fn drop_without_shutdown(mut self) {
862        // Safety: drops once, never accessed again due to mem::forget
863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
864        // Prevent Drop from running (which would shut down the channel)
865        std::mem::forget(self);
866    }
867}
868
869impl RealmProxy_ConnectToServiceInstanceResponder {
870    /// Sends a response to the FIDL transaction.
871    ///
872    /// Sets the channel to shutdown if an error occurs.
873    pub fn send(self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
874        let _result = self.send_raw(result);
875        if _result.is_err() {
876            self.control_handle.shutdown();
877        }
878        self.drop_without_shutdown();
879        _result
880    }
881
882    /// Similar to "send" but does not shutdown the channel if an error occurs.
883    pub fn send_no_shutdown_on_err(
884        self,
885        mut result: Result<(), OperationError>,
886    ) -> Result<(), fidl::Error> {
887        let _result = self.send_raw(result);
888        self.drop_without_shutdown();
889        _result
890    }
891
892    fn send_raw(&self, mut result: Result<(), OperationError>) -> Result<(), fidl::Error> {
893        self.control_handle.inner.send::<fidl::encoding::ResultType<
894            fidl::encoding::EmptyStruct,
895            OperationError,
896        >>(
897            result,
898            self.tx_id,
899            0x39111e790d55bbf,
900            fidl::encoding::DynamicFlags::empty(),
901        )
902    }
903}
904
905mod internal {
906    use super::*;
907
908    impl fidl::encoding::ResourceTypeMarker for RealmProxyConnectToNamedProtocolRequest {
909        type Borrowed<'a> = &'a mut Self;
910        fn take_or_borrow<'a>(
911            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
912        ) -> Self::Borrowed<'a> {
913            value
914        }
915    }
916
917    unsafe impl fidl::encoding::TypeMarker for RealmProxyConnectToNamedProtocolRequest {
918        type Owned = Self;
919
920        #[inline(always)]
921        fn inline_align(_context: fidl::encoding::Context) -> usize {
922            8
923        }
924
925        #[inline(always)]
926        fn inline_size(_context: fidl::encoding::Context) -> usize {
927            24
928        }
929    }
930
931    unsafe impl
932        fidl::encoding::Encode<
933            RealmProxyConnectToNamedProtocolRequest,
934            fidl::encoding::DefaultFuchsiaResourceDialect,
935        > for &mut RealmProxyConnectToNamedProtocolRequest
936    {
937        #[inline]
938        unsafe fn encode(
939            self,
940            encoder: &mut fidl::encoding::Encoder<
941                '_,
942                fidl::encoding::DefaultFuchsiaResourceDialect,
943            >,
944            offset: usize,
945            _depth: fidl::encoding::Depth,
946        ) -> fidl::Result<()> {
947            encoder.debug_check_bounds::<RealmProxyConnectToNamedProtocolRequest>(offset);
948            // Delegate to tuple encoding.
949            fidl::encoding::Encode::<
950                RealmProxyConnectToNamedProtocolRequest,
951                fidl::encoding::DefaultFuchsiaResourceDialect,
952            >::encode(
953                (
954                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
955                        &self.protocol,
956                    ),
957                    <fidl::encoding::HandleType<
958                        fidl::Channel,
959                        { fidl::ObjectType::CHANNEL.into_raw() },
960                        2147483648,
961                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
962                        &mut self.server_end
963                    ),
964                ),
965                encoder,
966                offset,
967                _depth,
968            )
969        }
970    }
971    unsafe impl<
972        T0: fidl::encoding::Encode<
973                fidl::encoding::BoundedString<255>,
974                fidl::encoding::DefaultFuchsiaResourceDialect,
975            >,
976        T1: fidl::encoding::Encode<
977                fidl::encoding::HandleType<
978                    fidl::Channel,
979                    { fidl::ObjectType::CHANNEL.into_raw() },
980                    2147483648,
981                >,
982                fidl::encoding::DefaultFuchsiaResourceDialect,
983            >,
984    >
985        fidl::encoding::Encode<
986            RealmProxyConnectToNamedProtocolRequest,
987            fidl::encoding::DefaultFuchsiaResourceDialect,
988        > for (T0, T1)
989    {
990        #[inline]
991        unsafe fn encode(
992            self,
993            encoder: &mut fidl::encoding::Encoder<
994                '_,
995                fidl::encoding::DefaultFuchsiaResourceDialect,
996            >,
997            offset: usize,
998            depth: fidl::encoding::Depth,
999        ) -> fidl::Result<()> {
1000            encoder.debug_check_bounds::<RealmProxyConnectToNamedProtocolRequest>(offset);
1001            // Zero out padding regions. There's no need to apply masks
1002            // because the unmasked parts will be overwritten by fields.
1003            unsafe {
1004                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1005                (ptr as *mut u64).write_unaligned(0);
1006            }
1007            // Write the fields.
1008            self.0.encode(encoder, offset + 0, depth)?;
1009            self.1.encode(encoder, offset + 16, depth)?;
1010            Ok(())
1011        }
1012    }
1013
1014    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1015        for RealmProxyConnectToNamedProtocolRequest
1016    {
1017        #[inline(always)]
1018        fn new_empty() -> Self {
1019            Self {
1020                protocol: fidl::new_empty!(
1021                    fidl::encoding::BoundedString<255>,
1022                    fidl::encoding::DefaultFuchsiaResourceDialect
1023                ),
1024                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1025            }
1026        }
1027
1028        #[inline]
1029        unsafe fn decode(
1030            &mut self,
1031            decoder: &mut fidl::encoding::Decoder<
1032                '_,
1033                fidl::encoding::DefaultFuchsiaResourceDialect,
1034            >,
1035            offset: usize,
1036            _depth: fidl::encoding::Depth,
1037        ) -> fidl::Result<()> {
1038            decoder.debug_check_bounds::<Self>(offset);
1039            // Verify that padding bytes are zero.
1040            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1041            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1042            let mask = 0xffffffff00000000u64;
1043            let maskedval = padval & mask;
1044            if maskedval != 0 {
1045                return Err(fidl::Error::NonZeroPadding {
1046                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1047                });
1048            }
1049            fidl::decode!(
1050                fidl::encoding::BoundedString<255>,
1051                fidl::encoding::DefaultFuchsiaResourceDialect,
1052                &mut self.protocol,
1053                decoder,
1054                offset + 0,
1055                _depth
1056            )?;
1057            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 16, _depth)?;
1058            Ok(())
1059        }
1060    }
1061
1062    impl fidl::encoding::ResourceTypeMarker for RealmProxyConnectToServiceInstanceRequest {
1063        type Borrowed<'a> = &'a mut Self;
1064        fn take_or_borrow<'a>(
1065            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1066        ) -> Self::Borrowed<'a> {
1067            value
1068        }
1069    }
1070
1071    unsafe impl fidl::encoding::TypeMarker for RealmProxyConnectToServiceInstanceRequest {
1072        type Owned = Self;
1073
1074        #[inline(always)]
1075        fn inline_align(_context: fidl::encoding::Context) -> usize {
1076            8
1077        }
1078
1079        #[inline(always)]
1080        fn inline_size(_context: fidl::encoding::Context) -> usize {
1081            40
1082        }
1083    }
1084
1085    unsafe impl
1086        fidl::encoding::Encode<
1087            RealmProxyConnectToServiceInstanceRequest,
1088            fidl::encoding::DefaultFuchsiaResourceDialect,
1089        > for &mut RealmProxyConnectToServiceInstanceRequest
1090    {
1091        #[inline]
1092        unsafe fn encode(
1093            self,
1094            encoder: &mut fidl::encoding::Encoder<
1095                '_,
1096                fidl::encoding::DefaultFuchsiaResourceDialect,
1097            >,
1098            offset: usize,
1099            _depth: fidl::encoding::Depth,
1100        ) -> fidl::Result<()> {
1101            encoder.debug_check_bounds::<RealmProxyConnectToServiceInstanceRequest>(offset);
1102            // Delegate to tuple encoding.
1103            fidl::encoding::Encode::<
1104                RealmProxyConnectToServiceInstanceRequest,
1105                fidl::encoding::DefaultFuchsiaResourceDialect,
1106            >::encode(
1107                (
1108                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1109                        &self.service,
1110                    ),
1111                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1112                        &self.instance,
1113                    ),
1114                    <fidl::encoding::HandleType<
1115                        fidl::Channel,
1116                        { fidl::ObjectType::CHANNEL.into_raw() },
1117                        2147483648,
1118                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1119                        &mut self.server_end
1120                    ),
1121                ),
1122                encoder,
1123                offset,
1124                _depth,
1125            )
1126        }
1127    }
1128    unsafe impl<
1129        T0: fidl::encoding::Encode<
1130                fidl::encoding::BoundedString<255>,
1131                fidl::encoding::DefaultFuchsiaResourceDialect,
1132            >,
1133        T1: fidl::encoding::Encode<
1134                fidl::encoding::BoundedString<255>,
1135                fidl::encoding::DefaultFuchsiaResourceDialect,
1136            >,
1137        T2: fidl::encoding::Encode<
1138                fidl::encoding::HandleType<
1139                    fidl::Channel,
1140                    { fidl::ObjectType::CHANNEL.into_raw() },
1141                    2147483648,
1142                >,
1143                fidl::encoding::DefaultFuchsiaResourceDialect,
1144            >,
1145    >
1146        fidl::encoding::Encode<
1147            RealmProxyConnectToServiceInstanceRequest,
1148            fidl::encoding::DefaultFuchsiaResourceDialect,
1149        > for (T0, T1, T2)
1150    {
1151        #[inline]
1152        unsafe fn encode(
1153            self,
1154            encoder: &mut fidl::encoding::Encoder<
1155                '_,
1156                fidl::encoding::DefaultFuchsiaResourceDialect,
1157            >,
1158            offset: usize,
1159            depth: fidl::encoding::Depth,
1160        ) -> fidl::Result<()> {
1161            encoder.debug_check_bounds::<RealmProxyConnectToServiceInstanceRequest>(offset);
1162            // Zero out padding regions. There's no need to apply masks
1163            // because the unmasked parts will be overwritten by fields.
1164            unsafe {
1165                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1166                (ptr as *mut u64).write_unaligned(0);
1167            }
1168            // Write the fields.
1169            self.0.encode(encoder, offset + 0, depth)?;
1170            self.1.encode(encoder, offset + 16, depth)?;
1171            self.2.encode(encoder, offset + 32, depth)?;
1172            Ok(())
1173        }
1174    }
1175
1176    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1177        for RealmProxyConnectToServiceInstanceRequest
1178    {
1179        #[inline(always)]
1180        fn new_empty() -> Self {
1181            Self {
1182                service: fidl::new_empty!(
1183                    fidl::encoding::BoundedString<255>,
1184                    fidl::encoding::DefaultFuchsiaResourceDialect
1185                ),
1186                instance: fidl::new_empty!(
1187                    fidl::encoding::BoundedString<255>,
1188                    fidl::encoding::DefaultFuchsiaResourceDialect
1189                ),
1190                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1191            }
1192        }
1193
1194        #[inline]
1195        unsafe fn decode(
1196            &mut self,
1197            decoder: &mut fidl::encoding::Decoder<
1198                '_,
1199                fidl::encoding::DefaultFuchsiaResourceDialect,
1200            >,
1201            offset: usize,
1202            _depth: fidl::encoding::Depth,
1203        ) -> fidl::Result<()> {
1204            decoder.debug_check_bounds::<Self>(offset);
1205            // Verify that padding bytes are zero.
1206            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1207            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1208            let mask = 0xffffffff00000000u64;
1209            let maskedval = padval & mask;
1210            if maskedval != 0 {
1211                return Err(fidl::Error::NonZeroPadding {
1212                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1213                });
1214            }
1215            fidl::decode!(
1216                fidl::encoding::BoundedString<255>,
1217                fidl::encoding::DefaultFuchsiaResourceDialect,
1218                &mut self.service,
1219                decoder,
1220                offset + 0,
1221                _depth
1222            )?;
1223            fidl::decode!(
1224                fidl::encoding::BoundedString<255>,
1225                fidl::encoding::DefaultFuchsiaResourceDialect,
1226                &mut self.instance,
1227                decoder,
1228                offset + 16,
1229                _depth
1230            )?;
1231            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 32, _depth)?;
1232            Ok(())
1233        }
1234    }
1235
1236    impl fidl::encoding::ResourceTypeMarker for RealmProxyOpenServiceRequest {
1237        type Borrowed<'a> = &'a mut Self;
1238        fn take_or_borrow<'a>(
1239            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1240        ) -> Self::Borrowed<'a> {
1241            value
1242        }
1243    }
1244
1245    unsafe impl fidl::encoding::TypeMarker for RealmProxyOpenServiceRequest {
1246        type Owned = Self;
1247
1248        #[inline(always)]
1249        fn inline_align(_context: fidl::encoding::Context) -> usize {
1250            8
1251        }
1252
1253        #[inline(always)]
1254        fn inline_size(_context: fidl::encoding::Context) -> usize {
1255            24
1256        }
1257    }
1258
1259    unsafe impl
1260        fidl::encoding::Encode<
1261            RealmProxyOpenServiceRequest,
1262            fidl::encoding::DefaultFuchsiaResourceDialect,
1263        > for &mut RealmProxyOpenServiceRequest
1264    {
1265        #[inline]
1266        unsafe fn encode(
1267            self,
1268            encoder: &mut fidl::encoding::Encoder<
1269                '_,
1270                fidl::encoding::DefaultFuchsiaResourceDialect,
1271            >,
1272            offset: usize,
1273            _depth: fidl::encoding::Depth,
1274        ) -> fidl::Result<()> {
1275            encoder.debug_check_bounds::<RealmProxyOpenServiceRequest>(offset);
1276            // Delegate to tuple encoding.
1277            fidl::encoding::Encode::<
1278                RealmProxyOpenServiceRequest,
1279                fidl::encoding::DefaultFuchsiaResourceDialect,
1280            >::encode(
1281                (
1282                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1283                        &self.service,
1284                    ),
1285                    <fidl::encoding::HandleType<
1286                        fidl::Channel,
1287                        { fidl::ObjectType::CHANNEL.into_raw() },
1288                        2147483648,
1289                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1290                        &mut self.server_end
1291                    ),
1292                ),
1293                encoder,
1294                offset,
1295                _depth,
1296            )
1297        }
1298    }
1299    unsafe impl<
1300        T0: fidl::encoding::Encode<
1301                fidl::encoding::BoundedString<255>,
1302                fidl::encoding::DefaultFuchsiaResourceDialect,
1303            >,
1304        T1: fidl::encoding::Encode<
1305                fidl::encoding::HandleType<
1306                    fidl::Channel,
1307                    { fidl::ObjectType::CHANNEL.into_raw() },
1308                    2147483648,
1309                >,
1310                fidl::encoding::DefaultFuchsiaResourceDialect,
1311            >,
1312    >
1313        fidl::encoding::Encode<
1314            RealmProxyOpenServiceRequest,
1315            fidl::encoding::DefaultFuchsiaResourceDialect,
1316        > for (T0, T1)
1317    {
1318        #[inline]
1319        unsafe fn encode(
1320            self,
1321            encoder: &mut fidl::encoding::Encoder<
1322                '_,
1323                fidl::encoding::DefaultFuchsiaResourceDialect,
1324            >,
1325            offset: usize,
1326            depth: fidl::encoding::Depth,
1327        ) -> fidl::Result<()> {
1328            encoder.debug_check_bounds::<RealmProxyOpenServiceRequest>(offset);
1329            // Zero out padding regions. There's no need to apply masks
1330            // because the unmasked parts will be overwritten by fields.
1331            unsafe {
1332                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1333                (ptr as *mut u64).write_unaligned(0);
1334            }
1335            // Write the fields.
1336            self.0.encode(encoder, offset + 0, depth)?;
1337            self.1.encode(encoder, offset + 16, depth)?;
1338            Ok(())
1339        }
1340    }
1341
1342    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1343        for RealmProxyOpenServiceRequest
1344    {
1345        #[inline(always)]
1346        fn new_empty() -> Self {
1347            Self {
1348                service: fidl::new_empty!(
1349                    fidl::encoding::BoundedString<255>,
1350                    fidl::encoding::DefaultFuchsiaResourceDialect
1351                ),
1352                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1353            }
1354        }
1355
1356        #[inline]
1357        unsafe fn decode(
1358            &mut self,
1359            decoder: &mut fidl::encoding::Decoder<
1360                '_,
1361                fidl::encoding::DefaultFuchsiaResourceDialect,
1362            >,
1363            offset: usize,
1364            _depth: fidl::encoding::Depth,
1365        ) -> fidl::Result<()> {
1366            decoder.debug_check_bounds::<Self>(offset);
1367            // Verify that padding bytes are zero.
1368            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1369            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1370            let mask = 0xffffffff00000000u64;
1371            let maskedval = padval & mask;
1372            if maskedval != 0 {
1373                return Err(fidl::Error::NonZeroPadding {
1374                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1375                });
1376            }
1377            fidl::decode!(
1378                fidl::encoding::BoundedString<255>,
1379                fidl::encoding::DefaultFuchsiaResourceDialect,
1380                &mut self.service,
1381                decoder,
1382                offset + 0,
1383                _depth
1384            )?;
1385            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 16, _depth)?;
1386            Ok(())
1387        }
1388    }
1389}