Skip to main content

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