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
141mod internal {
142    use super::*;
143    unsafe impl fidl::encoding::TypeMarker for ConnectToManifestOptions {
144        type Owned = Self;
145
146        #[inline(always)]
147        fn inline_align(_context: fidl::encoding::Context) -> usize {
148            4
149        }
150
151        #[inline(always)]
152        fn inline_size(_context: fidl::encoding::Context) -> usize {
153            4
154        }
155    }
156
157    impl fidl::encoding::ValueTypeMarker for ConnectToManifestOptions {
158        type Borrowed<'a> = Self;
159        #[inline(always)]
160        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
161            *value
162        }
163    }
164
165    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
166        for ConnectToManifestOptions
167    {
168        #[inline]
169        unsafe fn encode(
170            self,
171            encoder: &mut fidl::encoding::Encoder<'_, D>,
172            offset: usize,
173            _depth: fidl::encoding::Depth,
174        ) -> fidl::Result<()> {
175            encoder.debug_check_bounds::<Self>(offset);
176            encoder.write_num(self.bits(), offset);
177            Ok(())
178        }
179    }
180
181    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
182        for ConnectToManifestOptions
183    {
184        #[inline(always)]
185        fn new_empty() -> Self {
186            Self::empty()
187        }
188
189        #[inline]
190        unsafe fn decode(
191            &mut self,
192            decoder: &mut fidl::encoding::Decoder<'_, D>,
193            offset: usize,
194            _depth: fidl::encoding::Depth,
195        ) -> fidl::Result<()> {
196            decoder.debug_check_bounds::<Self>(offset);
197            let prim = decoder.read_num::<u32>(offset);
198            *self = Self::from_bits_allow_unknown(prim);
199            Ok(())
200        }
201    }
202    unsafe impl fidl::encoding::TypeMarker for Features {
203        type Owned = Self;
204
205        #[inline(always)]
206        fn inline_align(_context: fidl::encoding::Context) -> usize {
207            4
208        }
209
210        #[inline(always)]
211        fn inline_size(_context: fidl::encoding::Context) -> usize {
212            4
213        }
214    }
215
216    impl fidl::encoding::ValueTypeMarker for Features {
217        type Borrowed<'a> = Self;
218        #[inline(always)]
219        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
220            *value
221        }
222    }
223
224    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Features {
225        #[inline]
226        unsafe fn encode(
227            self,
228            encoder: &mut fidl::encoding::Encoder<'_, D>,
229            offset: usize,
230            _depth: fidl::encoding::Depth,
231        ) -> fidl::Result<()> {
232            encoder.debug_check_bounds::<Self>(offset);
233            encoder.write_num(self.bits(), offset);
234            Ok(())
235        }
236    }
237
238    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Features {
239        #[inline(always)]
240        fn new_empty() -> Self {
241            Self::empty()
242        }
243
244        #[inline]
245        unsafe fn decode(
246            &mut self,
247            decoder: &mut fidl::encoding::Decoder<'_, D>,
248            offset: usize,
249            _depth: fidl::encoding::Depth,
250        ) -> fidl::Result<()> {
251            decoder.debug_check_bounds::<Self>(offset);
252            let prim = decoder.read_num::<u32>(offset);
253            *self = Self::from_bits_allow_unknown(prim);
254            Ok(())
255        }
256    }
257    unsafe impl fidl::encoding::TypeMarker for GetVmexResourceError {
258        type Owned = Self;
259
260        #[inline(always)]
261        fn inline_align(_context: fidl::encoding::Context) -> usize {
262            std::mem::align_of::<u32>()
263        }
264
265        #[inline(always)]
266        fn inline_size(_context: fidl::encoding::Context) -> usize {
267            std::mem::size_of::<u32>()
268        }
269
270        #[inline(always)]
271        fn encode_is_copy() -> bool {
272            false
273        }
274
275        #[inline(always)]
276        fn decode_is_copy() -> bool {
277            false
278        }
279    }
280
281    impl fidl::encoding::ValueTypeMarker for GetVmexResourceError {
282        type Borrowed<'a> = Self;
283        #[inline(always)]
284        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
285            *value
286        }
287    }
288
289    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
290        for GetVmexResourceError
291    {
292        #[inline]
293        unsafe fn encode(
294            self,
295            encoder: &mut fidl::encoding::Encoder<'_, D>,
296            offset: usize,
297            _depth: fidl::encoding::Depth,
298        ) -> fidl::Result<()> {
299            encoder.debug_check_bounds::<Self>(offset);
300            encoder.write_num(self.into_primitive(), offset);
301            Ok(())
302        }
303    }
304
305    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GetVmexResourceError {
306        #[inline(always)]
307        fn new_empty() -> Self {
308            Self::unknown()
309        }
310
311        #[inline]
312        unsafe fn decode(
313            &mut self,
314            decoder: &mut fidl::encoding::Decoder<'_, D>,
315            offset: usize,
316            _depth: fidl::encoding::Depth,
317        ) -> fidl::Result<()> {
318            decoder.debug_check_bounds::<Self>(offset);
319            let prim = decoder.read_num::<u32>(offset);
320
321            *self = Self::from_primitive_allow_unknown(prim);
322            Ok(())
323        }
324    }
325
326    impl fidl::encoding::ValueTypeMarker for LoaderGetRequest {
327        type Borrowed<'a> = &'a Self;
328        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
329            value
330        }
331    }
332
333    unsafe impl fidl::encoding::TypeMarker for LoaderGetRequest {
334        type Owned = Self;
335
336        #[inline(always)]
337        fn inline_align(_context: fidl::encoding::Context) -> usize {
338            8
339        }
340
341        #[inline(always)]
342        fn inline_size(_context: fidl::encoding::Context) -> usize {
343            16
344        }
345    }
346
347    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LoaderGetRequest, D>
348        for &LoaderGetRequest
349    {
350        #[inline]
351        unsafe fn encode(
352            self,
353            encoder: &mut fidl::encoding::Encoder<'_, D>,
354            offset: usize,
355            _depth: fidl::encoding::Depth,
356        ) -> fidl::Result<()> {
357            encoder.debug_check_bounds::<LoaderGetRequest>(offset);
358            // Delegate to tuple encoding.
359            fidl::encoding::Encode::<LoaderGetRequest, D>::encode(
360                (<fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
361                    &self.name,
362                ),),
363                encoder,
364                offset,
365                _depth,
366            )
367        }
368    }
369    unsafe impl<
370            D: fidl::encoding::ResourceDialect,
371            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<64>, D>,
372        > fidl::encoding::Encode<LoaderGetRequest, D> for (T0,)
373    {
374        #[inline]
375        unsafe fn encode(
376            self,
377            encoder: &mut fidl::encoding::Encoder<'_, D>,
378            offset: usize,
379            depth: fidl::encoding::Depth,
380        ) -> fidl::Result<()> {
381            encoder.debug_check_bounds::<LoaderGetRequest>(offset);
382            // Zero out padding regions. There's no need to apply masks
383            // because the unmasked parts will be overwritten by fields.
384            // Write the fields.
385            self.0.encode(encoder, offset + 0, depth)?;
386            Ok(())
387        }
388    }
389
390    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LoaderGetRequest {
391        #[inline(always)]
392        fn new_empty() -> Self {
393            Self { name: fidl::new_empty!(fidl::encoding::BoundedString<64>, D) }
394        }
395
396        #[inline]
397        unsafe fn decode(
398            &mut self,
399            decoder: &mut fidl::encoding::Decoder<'_, D>,
400            offset: usize,
401            _depth: fidl::encoding::Depth,
402        ) -> fidl::Result<()> {
403            decoder.debug_check_bounds::<Self>(offset);
404            // Verify that padding bytes are zero.
405            fidl::decode!(
406                fidl::encoding::BoundedString<64>,
407                D,
408                &mut self.name,
409                decoder,
410                offset + 0,
411                _depth
412            )?;
413            Ok(())
414        }
415    }
416
417    impl fidl::encoding::ValueTypeMarker for LoaderGetSupportedFeaturesResponse {
418        type Borrowed<'a> = &'a Self;
419        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
420            value
421        }
422    }
423
424    unsafe impl fidl::encoding::TypeMarker for LoaderGetSupportedFeaturesResponse {
425        type Owned = Self;
426
427        #[inline(always)]
428        fn inline_align(_context: fidl::encoding::Context) -> usize {
429            4
430        }
431
432        #[inline(always)]
433        fn inline_size(_context: fidl::encoding::Context) -> usize {
434            4
435        }
436    }
437
438    unsafe impl<D: fidl::encoding::ResourceDialect>
439        fidl::encoding::Encode<LoaderGetSupportedFeaturesResponse, D>
440        for &LoaderGetSupportedFeaturesResponse
441    {
442        #[inline]
443        unsafe fn encode(
444            self,
445            encoder: &mut fidl::encoding::Encoder<'_, D>,
446            offset: usize,
447            _depth: fidl::encoding::Depth,
448        ) -> fidl::Result<()> {
449            encoder.debug_check_bounds::<LoaderGetSupportedFeaturesResponse>(offset);
450            // Delegate to tuple encoding.
451            fidl::encoding::Encode::<LoaderGetSupportedFeaturesResponse, D>::encode(
452                (<Features as fidl::encoding::ValueTypeMarker>::borrow(&self.features),),
453                encoder,
454                offset,
455                _depth,
456            )
457        }
458    }
459    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Features, D>>
460        fidl::encoding::Encode<LoaderGetSupportedFeaturesResponse, D> for (T0,)
461    {
462        #[inline]
463        unsafe fn encode(
464            self,
465            encoder: &mut fidl::encoding::Encoder<'_, D>,
466            offset: usize,
467            depth: fidl::encoding::Depth,
468        ) -> fidl::Result<()> {
469            encoder.debug_check_bounds::<LoaderGetSupportedFeaturesResponse>(offset);
470            // Zero out padding regions. There's no need to apply masks
471            // because the unmasked parts will be overwritten by fields.
472            // Write the fields.
473            self.0.encode(encoder, offset + 0, depth)?;
474            Ok(())
475        }
476    }
477
478    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
479        for LoaderGetSupportedFeaturesResponse
480    {
481        #[inline(always)]
482        fn new_empty() -> Self {
483            Self { features: fidl::new_empty!(Features, D) }
484        }
485
486        #[inline]
487        unsafe fn decode(
488            &mut self,
489            decoder: &mut fidl::encoding::Decoder<'_, D>,
490            offset: usize,
491            _depth: fidl::encoding::Depth,
492        ) -> fidl::Result<()> {
493            decoder.debug_check_bounds::<Self>(offset);
494            // Verify that padding bytes are zero.
495            fidl::decode!(Features, D, &mut self.features, decoder, offset + 0, _depth)?;
496            Ok(())
497        }
498    }
499}