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