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