fidl_fuchsia_vulkan_loader__common/
fidl_fuchsia_vulkan_loader__common.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::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11bitflags! {
12    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
13    pub struct ConnectToManifestOptions: u32 {
14        /// Wait for the loader to finish processing current ICD loading/unloading
15        /// operations before completing the connection.
16        const WAIT_FOR_IDLE = 1;
17    }
18}
19
20impl ConnectToManifestOptions {
21    #[inline(always)]
22    pub fn from_bits_allow_unknown(bits: u32) -> Self {
23        Self::from_bits_retain(bits)
24    }
25
26    #[inline(always)]
27    pub fn has_unknown_bits(&self) -> bool {
28        self.get_unknown_bits() != 0
29    }
30
31    #[inline(always)]
32    pub fn get_unknown_bits(&self) -> u32 {
33        self.bits() & !Self::all().bits()
34    }
35}
36
37bitflags! {
38    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
39    pub struct Features: u32 {
40        /// Implements Get().
41        const GET = 1;
42        /// Implements ConnectToDeviceFs().
43        const CONNECT_TO_DEVICE_FS = 2;
44        /// Implements ConnectToManifestFs().
45        const CONNECT_TO_MANIFEST_FS = 4;
46    }
47}
48
49impl Features {
50    #[inline(always)]
51    pub fn from_bits_allow_unknown(bits: u32) -> Self {
52        Self::from_bits_retain(bits)
53    }
54
55    #[inline(always)]
56    pub fn has_unknown_bits(&self) -> bool {
57        self.get_unknown_bits() != 0
58    }
59
60    #[inline(always)]
61    pub fn get_unknown_bits(&self) -> u32 {
62        self.bits() & !Self::all().bits()
63    }
64}
65
66/// Error type returned by [`Loader.GetVmexResource`].
67#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
68pub enum GetVmexResourceError {
69    /// The structured config value `allow_lavapipe_icd` is false.
70    LavapipeIcdNotAllowed,
71    /// The loader was unable to obtain a `VmexResource` handle.
72    FailedToObtainResource,
73    #[doc(hidden)]
74    __SourceBreaking { unknown_ordinal: u32 },
75}
76
77/// Pattern that matches an unknown `GetVmexResourceError` member.
78#[macro_export]
79macro_rules! GetVmexResourceErrorUnknown {
80    () => {
81        _
82    };
83}
84
85impl GetVmexResourceError {
86    #[inline]
87    pub fn from_primitive(prim: u32) -> Option<Self> {
88        match prim {
89            1 => Some(Self::LavapipeIcdNotAllowed),
90            2 => Some(Self::FailedToObtainResource),
91            _ => None,
92        }
93    }
94
95    #[inline]
96    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
97        match prim {
98            1 => Self::LavapipeIcdNotAllowed,
99            2 => Self::FailedToObtainResource,
100            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
101        }
102    }
103
104    #[inline]
105    pub fn unknown() -> Self {
106        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
107    }
108
109    #[inline]
110    pub const fn into_primitive(self) -> u32 {
111        match self {
112            Self::LavapipeIcdNotAllowed => 1,
113            Self::FailedToObtainResource => 2,
114            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
115        }
116    }
117
118    #[inline]
119    pub fn is_unknown(&self) -> bool {
120        match self {
121            Self::__SourceBreaking { unknown_ordinal: _ } => true,
122            _ => false,
123        }
124    }
125}
126
127#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
128pub struct LoaderGetRequest {
129    pub name: String,
130}
131
132impl fidl::Persistable for LoaderGetRequest {}
133
134#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
135pub struct LoaderGetSupportedFeaturesResponse {
136    pub features: Features,
137}
138
139impl fidl::Persistable for LoaderGetSupportedFeaturesResponse {}
140
141pub mod loader_ordinals {
142    pub const GET: u64 = 0x73dbbfb62e99320a;
143    pub const CONNECT_TO_MANIFEST_FS: u64 = 0x454d855877881cc;
144    pub const CONNECT_TO_DEVICE_FS: u64 = 0x11cd633f2f5ff6d7;
145    pub const GET_SUPPORTED_FEATURES: u64 = 0x381abfce172892bd;
146    pub const GET_VMEX_RESOURCE: u64 = 0x71aea090ffef259b;
147}
148
149mod internal {
150    use super::*;
151    unsafe impl fidl::encoding::TypeMarker for ConnectToManifestOptions {
152        type Owned = Self;
153
154        #[inline(always)]
155        fn inline_align(_context: fidl::encoding::Context) -> usize {
156            4
157        }
158
159        #[inline(always)]
160        fn inline_size(_context: fidl::encoding::Context) -> usize {
161            4
162        }
163    }
164
165    impl fidl::encoding::ValueTypeMarker for ConnectToManifestOptions {
166        type Borrowed<'a> = Self;
167        #[inline(always)]
168        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
169            *value
170        }
171    }
172
173    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
174        for ConnectToManifestOptions
175    {
176        #[inline]
177        unsafe fn encode(
178            self,
179            encoder: &mut fidl::encoding::Encoder<'_, D>,
180            offset: usize,
181            _depth: fidl::encoding::Depth,
182        ) -> fidl::Result<()> {
183            encoder.debug_check_bounds::<Self>(offset);
184            encoder.write_num(self.bits(), offset);
185            Ok(())
186        }
187    }
188
189    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
190        for ConnectToManifestOptions
191    {
192        #[inline(always)]
193        fn new_empty() -> Self {
194            Self::empty()
195        }
196
197        #[inline]
198        unsafe fn decode(
199            &mut self,
200            decoder: &mut fidl::encoding::Decoder<'_, D>,
201            offset: usize,
202            _depth: fidl::encoding::Depth,
203        ) -> fidl::Result<()> {
204            decoder.debug_check_bounds::<Self>(offset);
205            let prim = decoder.read_num::<u32>(offset);
206            *self = Self::from_bits_allow_unknown(prim);
207            Ok(())
208        }
209    }
210    unsafe impl fidl::encoding::TypeMarker for Features {
211        type Owned = Self;
212
213        #[inline(always)]
214        fn inline_align(_context: fidl::encoding::Context) -> usize {
215            4
216        }
217
218        #[inline(always)]
219        fn inline_size(_context: fidl::encoding::Context) -> usize {
220            4
221        }
222    }
223
224    impl fidl::encoding::ValueTypeMarker for Features {
225        type Borrowed<'a> = Self;
226        #[inline(always)]
227        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
228            *value
229        }
230    }
231
232    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Features {
233        #[inline]
234        unsafe fn encode(
235            self,
236            encoder: &mut fidl::encoding::Encoder<'_, D>,
237            offset: usize,
238            _depth: fidl::encoding::Depth,
239        ) -> fidl::Result<()> {
240            encoder.debug_check_bounds::<Self>(offset);
241            encoder.write_num(self.bits(), offset);
242            Ok(())
243        }
244    }
245
246    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Features {
247        #[inline(always)]
248        fn new_empty() -> Self {
249            Self::empty()
250        }
251
252        #[inline]
253        unsafe fn decode(
254            &mut self,
255            decoder: &mut fidl::encoding::Decoder<'_, D>,
256            offset: usize,
257            _depth: fidl::encoding::Depth,
258        ) -> fidl::Result<()> {
259            decoder.debug_check_bounds::<Self>(offset);
260            let prim = decoder.read_num::<u32>(offset);
261            *self = Self::from_bits_allow_unknown(prim);
262            Ok(())
263        }
264    }
265    unsafe impl fidl::encoding::TypeMarker for GetVmexResourceError {
266        type Owned = Self;
267
268        #[inline(always)]
269        fn inline_align(_context: fidl::encoding::Context) -> usize {
270            std::mem::align_of::<u32>()
271        }
272
273        #[inline(always)]
274        fn inline_size(_context: fidl::encoding::Context) -> usize {
275            std::mem::size_of::<u32>()
276        }
277
278        #[inline(always)]
279        fn encode_is_copy() -> bool {
280            false
281        }
282
283        #[inline(always)]
284        fn decode_is_copy() -> bool {
285            false
286        }
287    }
288
289    impl fidl::encoding::ValueTypeMarker for GetVmexResourceError {
290        type Borrowed<'a> = Self;
291        #[inline(always)]
292        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
293            *value
294        }
295    }
296
297    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
298        for GetVmexResourceError
299    {
300        #[inline]
301        unsafe fn encode(
302            self,
303            encoder: &mut fidl::encoding::Encoder<'_, D>,
304            offset: usize,
305            _depth: fidl::encoding::Depth,
306        ) -> fidl::Result<()> {
307            encoder.debug_check_bounds::<Self>(offset);
308            encoder.write_num(self.into_primitive(), offset);
309            Ok(())
310        }
311    }
312
313    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GetVmexResourceError {
314        #[inline(always)]
315        fn new_empty() -> Self {
316            Self::unknown()
317        }
318
319        #[inline]
320        unsafe fn decode(
321            &mut self,
322            decoder: &mut fidl::encoding::Decoder<'_, D>,
323            offset: usize,
324            _depth: fidl::encoding::Depth,
325        ) -> fidl::Result<()> {
326            decoder.debug_check_bounds::<Self>(offset);
327            let prim = decoder.read_num::<u32>(offset);
328
329            *self = Self::from_primitive_allow_unknown(prim);
330            Ok(())
331        }
332    }
333
334    impl fidl::encoding::ValueTypeMarker for LoaderGetRequest {
335        type Borrowed<'a> = &'a Self;
336        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
337            value
338        }
339    }
340
341    unsafe impl fidl::encoding::TypeMarker for LoaderGetRequest {
342        type Owned = Self;
343
344        #[inline(always)]
345        fn inline_align(_context: fidl::encoding::Context) -> usize {
346            8
347        }
348
349        #[inline(always)]
350        fn inline_size(_context: fidl::encoding::Context) -> usize {
351            16
352        }
353    }
354
355    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LoaderGetRequest, D>
356        for &LoaderGetRequest
357    {
358        #[inline]
359        unsafe fn encode(
360            self,
361            encoder: &mut fidl::encoding::Encoder<'_, D>,
362            offset: usize,
363            _depth: fidl::encoding::Depth,
364        ) -> fidl::Result<()> {
365            encoder.debug_check_bounds::<LoaderGetRequest>(offset);
366            // Delegate to tuple encoding.
367            fidl::encoding::Encode::<LoaderGetRequest, D>::encode(
368                (<fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
369                    &self.name,
370                ),),
371                encoder,
372                offset,
373                _depth,
374            )
375        }
376    }
377    unsafe impl<
378            D: fidl::encoding::ResourceDialect,
379            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<64>, D>,
380        > fidl::encoding::Encode<LoaderGetRequest, D> for (T0,)
381    {
382        #[inline]
383        unsafe fn encode(
384            self,
385            encoder: &mut fidl::encoding::Encoder<'_, D>,
386            offset: usize,
387            depth: fidl::encoding::Depth,
388        ) -> fidl::Result<()> {
389            encoder.debug_check_bounds::<LoaderGetRequest>(offset);
390            // Zero out padding regions. There's no need to apply masks
391            // because the unmasked parts will be overwritten by fields.
392            // Write the fields.
393            self.0.encode(encoder, offset + 0, depth)?;
394            Ok(())
395        }
396    }
397
398    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LoaderGetRequest {
399        #[inline(always)]
400        fn new_empty() -> Self {
401            Self { name: fidl::new_empty!(fidl::encoding::BoundedString<64>, D) }
402        }
403
404        #[inline]
405        unsafe fn decode(
406            &mut self,
407            decoder: &mut fidl::encoding::Decoder<'_, D>,
408            offset: usize,
409            _depth: fidl::encoding::Depth,
410        ) -> fidl::Result<()> {
411            decoder.debug_check_bounds::<Self>(offset);
412            // Verify that padding bytes are zero.
413            fidl::decode!(
414                fidl::encoding::BoundedString<64>,
415                D,
416                &mut self.name,
417                decoder,
418                offset + 0,
419                _depth
420            )?;
421            Ok(())
422        }
423    }
424
425    impl fidl::encoding::ValueTypeMarker for LoaderGetSupportedFeaturesResponse {
426        type Borrowed<'a> = &'a Self;
427        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
428            value
429        }
430    }
431
432    unsafe impl fidl::encoding::TypeMarker for LoaderGetSupportedFeaturesResponse {
433        type Owned = Self;
434
435        #[inline(always)]
436        fn inline_align(_context: fidl::encoding::Context) -> usize {
437            4
438        }
439
440        #[inline(always)]
441        fn inline_size(_context: fidl::encoding::Context) -> usize {
442            4
443        }
444    }
445
446    unsafe impl<D: fidl::encoding::ResourceDialect>
447        fidl::encoding::Encode<LoaderGetSupportedFeaturesResponse, D>
448        for &LoaderGetSupportedFeaturesResponse
449    {
450        #[inline]
451        unsafe fn encode(
452            self,
453            encoder: &mut fidl::encoding::Encoder<'_, D>,
454            offset: usize,
455            _depth: fidl::encoding::Depth,
456        ) -> fidl::Result<()> {
457            encoder.debug_check_bounds::<LoaderGetSupportedFeaturesResponse>(offset);
458            // Delegate to tuple encoding.
459            fidl::encoding::Encode::<LoaderGetSupportedFeaturesResponse, D>::encode(
460                (<Features as fidl::encoding::ValueTypeMarker>::borrow(&self.features),),
461                encoder,
462                offset,
463                _depth,
464            )
465        }
466    }
467    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Features, D>>
468        fidl::encoding::Encode<LoaderGetSupportedFeaturesResponse, D> for (T0,)
469    {
470        #[inline]
471        unsafe fn encode(
472            self,
473            encoder: &mut fidl::encoding::Encoder<'_, D>,
474            offset: usize,
475            depth: fidl::encoding::Depth,
476        ) -> fidl::Result<()> {
477            encoder.debug_check_bounds::<LoaderGetSupportedFeaturesResponse>(offset);
478            // Zero out padding regions. There's no need to apply masks
479            // because the unmasked parts will be overwritten by fields.
480            // Write the fields.
481            self.0.encode(encoder, offset + 0, depth)?;
482            Ok(())
483        }
484    }
485
486    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
487        for LoaderGetSupportedFeaturesResponse
488    {
489        #[inline(always)]
490        fn new_empty() -> Self {
491            Self { features: fidl::new_empty!(Features, D) }
492        }
493
494        #[inline]
495        unsafe fn decode(
496            &mut self,
497            decoder: &mut fidl::encoding::Decoder<'_, D>,
498            offset: usize,
499            _depth: fidl::encoding::Depth,
500        ) -> fidl::Result<()> {
501            decoder.debug_check_bounds::<Self>(offset);
502            // Verify that padding bytes are zero.
503            fidl::decode!(Features, D, &mut self.features, decoder, offset + 0, _depth)?;
504            Ok(())
505        }
506    }
507}