fidl_fuchsia_driver_index_common/
fidl_fuchsia_driver_index_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
11#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct DevelopmentManagerDisableDriverRequest {
13    pub driver_url: String,
14    pub package_hash: Option<String>,
15}
16
17impl fidl::Persistable for DevelopmentManagerDisableDriverRequest {}
18
19#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20pub struct DevelopmentManagerEnableDriverRequest {
21    pub driver_url: String,
22    pub package_hash: Option<String>,
23}
24
25impl fidl::Persistable for DevelopmentManagerEnableDriverRequest {}
26
27#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
28pub struct DevelopmentManagerRebindCompositesWithDriverRequest {
29    pub driver_url: String,
30}
31
32impl fidl::Persistable for DevelopmentManagerRebindCompositesWithDriverRequest {}
33
34#[derive(Clone, Debug, PartialEq)]
35pub struct DriverIndexMatchDriverRequest {
36    pub args: MatchDriverArgs,
37}
38
39impl fidl::Persistable for DriverIndexMatchDriverRequest {}
40
41#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42pub struct DriverIndexRebindCompositeNodeSpecRequest {
43    pub spec: String,
44    pub driver_url_suffix: Option<String>,
45}
46
47impl fidl::Persistable for DriverIndexRebindCompositeNodeSpecRequest {}
48
49#[derive(Clone, Debug, Default, PartialEq)]
50pub struct MatchDriverArgs {
51    /// Properties of the node to be matched.
52    pub properties: Option<Vec<fidl_fuchsia_driver_framework::NodeProperty>>,
53    /// The name of the node to be matched. Used for debugging purposes.
54    pub name: Option<String>,
55    pub driver_url_suffix: Option<String>,
56    #[doc(hidden)]
57    pub __source_breaking: fidl::marker::SourceBreaking,
58}
59
60impl fidl::Persistable for MatchDriverArgs {}
61
62/// Driver matched by the driver index.
63#[derive(Clone, Debug)]
64pub enum MatchDriverResult {
65    /// Information for a normal driver.
66    Driver(fidl_fuchsia_driver_framework::DriverInfo),
67    /// Information for a parent spec.
68    CompositeParents(Vec<fidl_fuchsia_driver_framework::CompositeParent>),
69    #[doc(hidden)]
70    __SourceBreaking { unknown_ordinal: u64 },
71}
72
73/// Pattern that matches an unknown `MatchDriverResult` member.
74#[macro_export]
75macro_rules! MatchDriverResultUnknown {
76    () => {
77        _
78    };
79}
80
81// Custom PartialEq so that unknown variants are not equal to themselves.
82impl PartialEq for MatchDriverResult {
83    fn eq(&self, other: &Self) -> bool {
84        match (self, other) {
85            (Self::Driver(x), Self::Driver(y)) => *x == *y,
86            (Self::CompositeParents(x), Self::CompositeParents(y)) => *x == *y,
87            _ => false,
88        }
89    }
90}
91
92impl MatchDriverResult {
93    #[inline]
94    pub fn ordinal(&self) -> u64 {
95        match *self {
96            Self::Driver(_) => 1,
97            Self::CompositeParents(_) => 2,
98            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
99        }
100    }
101
102    #[inline]
103    pub fn unknown_variant_for_testing() -> Self {
104        Self::__SourceBreaking { unknown_ordinal: 0 }
105    }
106
107    #[inline]
108    pub fn is_unknown(&self) -> bool {
109        match self {
110            Self::__SourceBreaking { .. } => true,
111            _ => false,
112        }
113    }
114}
115
116impl fidl::Persistable for MatchDriverResult {}
117
118mod internal {
119    use super::*;
120
121    impl fidl::encoding::ValueTypeMarker for DevelopmentManagerDisableDriverRequest {
122        type Borrowed<'a> = &'a Self;
123        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
124            value
125        }
126    }
127
128    unsafe impl fidl::encoding::TypeMarker for DevelopmentManagerDisableDriverRequest {
129        type Owned = Self;
130
131        #[inline(always)]
132        fn inline_align(_context: fidl::encoding::Context) -> usize {
133            8
134        }
135
136        #[inline(always)]
137        fn inline_size(_context: fidl::encoding::Context) -> usize {
138            32
139        }
140    }
141
142    unsafe impl<D: fidl::encoding::ResourceDialect>
143        fidl::encoding::Encode<DevelopmentManagerDisableDriverRequest, D>
144        for &DevelopmentManagerDisableDriverRequest
145    {
146        #[inline]
147        unsafe fn encode(
148            self,
149            encoder: &mut fidl::encoding::Encoder<'_, D>,
150            offset: usize,
151            _depth: fidl::encoding::Depth,
152        ) -> fidl::Result<()> {
153            encoder.debug_check_bounds::<DevelopmentManagerDisableDriverRequest>(offset);
154            // Delegate to tuple encoding.
155            fidl::encoding::Encode::<DevelopmentManagerDisableDriverRequest, D>::encode(
156                (
157                    <fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(&self.driver_url),
158                    <fidl::encoding::Optional<fidl::encoding::BoundedString<64>> as fidl::encoding::ValueTypeMarker>::borrow(&self.package_hash),
159                ),
160                encoder, offset, _depth
161            )
162        }
163    }
164    unsafe impl<
165            D: fidl::encoding::ResourceDialect,
166            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<4096>, D>,
167            T1: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::BoundedString<64>>, D>,
168        > fidl::encoding::Encode<DevelopmentManagerDisableDriverRequest, D> for (T0, T1)
169    {
170        #[inline]
171        unsafe fn encode(
172            self,
173            encoder: &mut fidl::encoding::Encoder<'_, D>,
174            offset: usize,
175            depth: fidl::encoding::Depth,
176        ) -> fidl::Result<()> {
177            encoder.debug_check_bounds::<DevelopmentManagerDisableDriverRequest>(offset);
178            // Zero out padding regions. There's no need to apply masks
179            // because the unmasked parts will be overwritten by fields.
180            // Write the fields.
181            self.0.encode(encoder, offset + 0, depth)?;
182            self.1.encode(encoder, offset + 16, depth)?;
183            Ok(())
184        }
185    }
186
187    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
188        for DevelopmentManagerDisableDriverRequest
189    {
190        #[inline(always)]
191        fn new_empty() -> Self {
192            Self {
193                driver_url: fidl::new_empty!(fidl::encoding::BoundedString<4096>, D),
194                package_hash: fidl::new_empty!(
195                    fidl::encoding::Optional<fidl::encoding::BoundedString<64>>,
196                    D
197                ),
198            }
199        }
200
201        #[inline]
202        unsafe fn decode(
203            &mut self,
204            decoder: &mut fidl::encoding::Decoder<'_, D>,
205            offset: usize,
206            _depth: fidl::encoding::Depth,
207        ) -> fidl::Result<()> {
208            decoder.debug_check_bounds::<Self>(offset);
209            // Verify that padding bytes are zero.
210            fidl::decode!(
211                fidl::encoding::BoundedString<4096>,
212                D,
213                &mut self.driver_url,
214                decoder,
215                offset + 0,
216                _depth
217            )?;
218            fidl::decode!(
219                fidl::encoding::Optional<fidl::encoding::BoundedString<64>>,
220                D,
221                &mut self.package_hash,
222                decoder,
223                offset + 16,
224                _depth
225            )?;
226            Ok(())
227        }
228    }
229
230    impl fidl::encoding::ValueTypeMarker for DevelopmentManagerEnableDriverRequest {
231        type Borrowed<'a> = &'a Self;
232        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
233            value
234        }
235    }
236
237    unsafe impl fidl::encoding::TypeMarker for DevelopmentManagerEnableDriverRequest {
238        type Owned = Self;
239
240        #[inline(always)]
241        fn inline_align(_context: fidl::encoding::Context) -> usize {
242            8
243        }
244
245        #[inline(always)]
246        fn inline_size(_context: fidl::encoding::Context) -> usize {
247            32
248        }
249    }
250
251    unsafe impl<D: fidl::encoding::ResourceDialect>
252        fidl::encoding::Encode<DevelopmentManagerEnableDriverRequest, D>
253        for &DevelopmentManagerEnableDriverRequest
254    {
255        #[inline]
256        unsafe fn encode(
257            self,
258            encoder: &mut fidl::encoding::Encoder<'_, D>,
259            offset: usize,
260            _depth: fidl::encoding::Depth,
261        ) -> fidl::Result<()> {
262            encoder.debug_check_bounds::<DevelopmentManagerEnableDriverRequest>(offset);
263            // Delegate to tuple encoding.
264            fidl::encoding::Encode::<DevelopmentManagerEnableDriverRequest, D>::encode(
265                (
266                    <fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(&self.driver_url),
267                    <fidl::encoding::Optional<fidl::encoding::BoundedString<64>> as fidl::encoding::ValueTypeMarker>::borrow(&self.package_hash),
268                ),
269                encoder, offset, _depth
270            )
271        }
272    }
273    unsafe impl<
274            D: fidl::encoding::ResourceDialect,
275            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<4096>, D>,
276            T1: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::BoundedString<64>>, D>,
277        > fidl::encoding::Encode<DevelopmentManagerEnableDriverRequest, D> for (T0, T1)
278    {
279        #[inline]
280        unsafe fn encode(
281            self,
282            encoder: &mut fidl::encoding::Encoder<'_, D>,
283            offset: usize,
284            depth: fidl::encoding::Depth,
285        ) -> fidl::Result<()> {
286            encoder.debug_check_bounds::<DevelopmentManagerEnableDriverRequest>(offset);
287            // Zero out padding regions. There's no need to apply masks
288            // because the unmasked parts will be overwritten by fields.
289            // Write the fields.
290            self.0.encode(encoder, offset + 0, depth)?;
291            self.1.encode(encoder, offset + 16, depth)?;
292            Ok(())
293        }
294    }
295
296    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
297        for DevelopmentManagerEnableDriverRequest
298    {
299        #[inline(always)]
300        fn new_empty() -> Self {
301            Self {
302                driver_url: fidl::new_empty!(fidl::encoding::BoundedString<4096>, D),
303                package_hash: fidl::new_empty!(
304                    fidl::encoding::Optional<fidl::encoding::BoundedString<64>>,
305                    D
306                ),
307            }
308        }
309
310        #[inline]
311        unsafe fn decode(
312            &mut self,
313            decoder: &mut fidl::encoding::Decoder<'_, D>,
314            offset: usize,
315            _depth: fidl::encoding::Depth,
316        ) -> fidl::Result<()> {
317            decoder.debug_check_bounds::<Self>(offset);
318            // Verify that padding bytes are zero.
319            fidl::decode!(
320                fidl::encoding::BoundedString<4096>,
321                D,
322                &mut self.driver_url,
323                decoder,
324                offset + 0,
325                _depth
326            )?;
327            fidl::decode!(
328                fidl::encoding::Optional<fidl::encoding::BoundedString<64>>,
329                D,
330                &mut self.package_hash,
331                decoder,
332                offset + 16,
333                _depth
334            )?;
335            Ok(())
336        }
337    }
338
339    impl fidl::encoding::ValueTypeMarker for DevelopmentManagerRebindCompositesWithDriverRequest {
340        type Borrowed<'a> = &'a Self;
341        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
342            value
343        }
344    }
345
346    unsafe impl fidl::encoding::TypeMarker for DevelopmentManagerRebindCompositesWithDriverRequest {
347        type Owned = Self;
348
349        #[inline(always)]
350        fn inline_align(_context: fidl::encoding::Context) -> usize {
351            8
352        }
353
354        #[inline(always)]
355        fn inline_size(_context: fidl::encoding::Context) -> usize {
356            16
357        }
358    }
359
360    unsafe impl<D: fidl::encoding::ResourceDialect>
361        fidl::encoding::Encode<DevelopmentManagerRebindCompositesWithDriverRequest, D>
362        for &DevelopmentManagerRebindCompositesWithDriverRequest
363    {
364        #[inline]
365        unsafe fn encode(
366            self,
367            encoder: &mut fidl::encoding::Encoder<'_, D>,
368            offset: usize,
369            _depth: fidl::encoding::Depth,
370        ) -> fidl::Result<()> {
371            encoder
372                .debug_check_bounds::<DevelopmentManagerRebindCompositesWithDriverRequest>(offset);
373            // Delegate to tuple encoding.
374            fidl::encoding::Encode::<DevelopmentManagerRebindCompositesWithDriverRequest, D>::encode(
375                (<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(
376                    &self.driver_url,
377                ),),
378                encoder,
379                offset,
380                _depth,
381            )
382        }
383    }
384    unsafe impl<
385            D: fidl::encoding::ResourceDialect,
386            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<4096>, D>,
387        > fidl::encoding::Encode<DevelopmentManagerRebindCompositesWithDriverRequest, D> for (T0,)
388    {
389        #[inline]
390        unsafe fn encode(
391            self,
392            encoder: &mut fidl::encoding::Encoder<'_, D>,
393            offset: usize,
394            depth: fidl::encoding::Depth,
395        ) -> fidl::Result<()> {
396            encoder
397                .debug_check_bounds::<DevelopmentManagerRebindCompositesWithDriverRequest>(offset);
398            // Zero out padding regions. There's no need to apply masks
399            // because the unmasked parts will be overwritten by fields.
400            // Write the fields.
401            self.0.encode(encoder, offset + 0, depth)?;
402            Ok(())
403        }
404    }
405
406    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
407        for DevelopmentManagerRebindCompositesWithDriverRequest
408    {
409        #[inline(always)]
410        fn new_empty() -> Self {
411            Self { driver_url: fidl::new_empty!(fidl::encoding::BoundedString<4096>, D) }
412        }
413
414        #[inline]
415        unsafe fn decode(
416            &mut self,
417            decoder: &mut fidl::encoding::Decoder<'_, D>,
418            offset: usize,
419            _depth: fidl::encoding::Depth,
420        ) -> fidl::Result<()> {
421            decoder.debug_check_bounds::<Self>(offset);
422            // Verify that padding bytes are zero.
423            fidl::decode!(
424                fidl::encoding::BoundedString<4096>,
425                D,
426                &mut self.driver_url,
427                decoder,
428                offset + 0,
429                _depth
430            )?;
431            Ok(())
432        }
433    }
434
435    impl fidl::encoding::ValueTypeMarker for DriverIndexMatchDriverRequest {
436        type Borrowed<'a> = &'a Self;
437        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
438            value
439        }
440    }
441
442    unsafe impl fidl::encoding::TypeMarker for DriverIndexMatchDriverRequest {
443        type Owned = Self;
444
445        #[inline(always)]
446        fn inline_align(_context: fidl::encoding::Context) -> usize {
447            8
448        }
449
450        #[inline(always)]
451        fn inline_size(_context: fidl::encoding::Context) -> usize {
452            16
453        }
454    }
455
456    unsafe impl<D: fidl::encoding::ResourceDialect>
457        fidl::encoding::Encode<DriverIndexMatchDriverRequest, D>
458        for &DriverIndexMatchDriverRequest
459    {
460        #[inline]
461        unsafe fn encode(
462            self,
463            encoder: &mut fidl::encoding::Encoder<'_, D>,
464            offset: usize,
465            _depth: fidl::encoding::Depth,
466        ) -> fidl::Result<()> {
467            encoder.debug_check_bounds::<DriverIndexMatchDriverRequest>(offset);
468            // Delegate to tuple encoding.
469            fidl::encoding::Encode::<DriverIndexMatchDriverRequest, D>::encode(
470                (<MatchDriverArgs as fidl::encoding::ValueTypeMarker>::borrow(&self.args),),
471                encoder,
472                offset,
473                _depth,
474            )
475        }
476    }
477    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<MatchDriverArgs, D>>
478        fidl::encoding::Encode<DriverIndexMatchDriverRequest, D> for (T0,)
479    {
480        #[inline]
481        unsafe fn encode(
482            self,
483            encoder: &mut fidl::encoding::Encoder<'_, D>,
484            offset: usize,
485            depth: fidl::encoding::Depth,
486        ) -> fidl::Result<()> {
487            encoder.debug_check_bounds::<DriverIndexMatchDriverRequest>(offset);
488            // Zero out padding regions. There's no need to apply masks
489            // because the unmasked parts will be overwritten by fields.
490            // Write the fields.
491            self.0.encode(encoder, offset + 0, depth)?;
492            Ok(())
493        }
494    }
495
496    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
497        for DriverIndexMatchDriverRequest
498    {
499        #[inline(always)]
500        fn new_empty() -> Self {
501            Self { args: fidl::new_empty!(MatchDriverArgs, D) }
502        }
503
504        #[inline]
505        unsafe fn decode(
506            &mut self,
507            decoder: &mut fidl::encoding::Decoder<'_, D>,
508            offset: usize,
509            _depth: fidl::encoding::Depth,
510        ) -> fidl::Result<()> {
511            decoder.debug_check_bounds::<Self>(offset);
512            // Verify that padding bytes are zero.
513            fidl::decode!(MatchDriverArgs, D, &mut self.args, decoder, offset + 0, _depth)?;
514            Ok(())
515        }
516    }
517
518    impl fidl::encoding::ValueTypeMarker for DriverIndexRebindCompositeNodeSpecRequest {
519        type Borrowed<'a> = &'a Self;
520        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
521            value
522        }
523    }
524
525    unsafe impl fidl::encoding::TypeMarker for DriverIndexRebindCompositeNodeSpecRequest {
526        type Owned = Self;
527
528        #[inline(always)]
529        fn inline_align(_context: fidl::encoding::Context) -> usize {
530            8
531        }
532
533        #[inline(always)]
534        fn inline_size(_context: fidl::encoding::Context) -> usize {
535            32
536        }
537    }
538
539    unsafe impl<D: fidl::encoding::ResourceDialect>
540        fidl::encoding::Encode<DriverIndexRebindCompositeNodeSpecRequest, D>
541        for &DriverIndexRebindCompositeNodeSpecRequest
542    {
543        #[inline]
544        unsafe fn encode(
545            self,
546            encoder: &mut fidl::encoding::Encoder<'_, D>,
547            offset: usize,
548            _depth: fidl::encoding::Depth,
549        ) -> fidl::Result<()> {
550            encoder.debug_check_bounds::<DriverIndexRebindCompositeNodeSpecRequest>(offset);
551            // Delegate to tuple encoding.
552            fidl::encoding::Encode::<DriverIndexRebindCompositeNodeSpecRequest, D>::encode(
553                (
554                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.spec),
555                    <fidl::encoding::Optional<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(&self.driver_url_suffix),
556                ),
557                encoder, offset, _depth
558            )
559        }
560    }
561    unsafe impl<
562            D: fidl::encoding::ResourceDialect,
563            T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
564            T1: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::UnboundedString>, D>,
565        > fidl::encoding::Encode<DriverIndexRebindCompositeNodeSpecRequest, D> for (T0, T1)
566    {
567        #[inline]
568        unsafe fn encode(
569            self,
570            encoder: &mut fidl::encoding::Encoder<'_, D>,
571            offset: usize,
572            depth: fidl::encoding::Depth,
573        ) -> fidl::Result<()> {
574            encoder.debug_check_bounds::<DriverIndexRebindCompositeNodeSpecRequest>(offset);
575            // Zero out padding regions. There's no need to apply masks
576            // because the unmasked parts will be overwritten by fields.
577            // Write the fields.
578            self.0.encode(encoder, offset + 0, depth)?;
579            self.1.encode(encoder, offset + 16, depth)?;
580            Ok(())
581        }
582    }
583
584    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
585        for DriverIndexRebindCompositeNodeSpecRequest
586    {
587        #[inline(always)]
588        fn new_empty() -> Self {
589            Self {
590                spec: fidl::new_empty!(fidl::encoding::UnboundedString, D),
591                driver_url_suffix: fidl::new_empty!(
592                    fidl::encoding::Optional<fidl::encoding::UnboundedString>,
593                    D
594                ),
595            }
596        }
597
598        #[inline]
599        unsafe fn decode(
600            &mut self,
601            decoder: &mut fidl::encoding::Decoder<'_, D>,
602            offset: usize,
603            _depth: fidl::encoding::Depth,
604        ) -> fidl::Result<()> {
605            decoder.debug_check_bounds::<Self>(offset);
606            // Verify that padding bytes are zero.
607            fidl::decode!(
608                fidl::encoding::UnboundedString,
609                D,
610                &mut self.spec,
611                decoder,
612                offset + 0,
613                _depth
614            )?;
615            fidl::decode!(
616                fidl::encoding::Optional<fidl::encoding::UnboundedString>,
617                D,
618                &mut self.driver_url_suffix,
619                decoder,
620                offset + 16,
621                _depth
622            )?;
623            Ok(())
624        }
625    }
626
627    impl MatchDriverArgs {
628        #[inline(always)]
629        fn max_ordinal_present(&self) -> u64 {
630            if let Some(_) = self.driver_url_suffix {
631                return 3;
632            }
633            if let Some(_) = self.name {
634                return 2;
635            }
636            if let Some(_) = self.properties {
637                return 1;
638            }
639            0
640        }
641    }
642
643    impl fidl::encoding::ValueTypeMarker for MatchDriverArgs {
644        type Borrowed<'a> = &'a Self;
645        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
646            value
647        }
648    }
649
650    unsafe impl fidl::encoding::TypeMarker for MatchDriverArgs {
651        type Owned = Self;
652
653        #[inline(always)]
654        fn inline_align(_context: fidl::encoding::Context) -> usize {
655            8
656        }
657
658        #[inline(always)]
659        fn inline_size(_context: fidl::encoding::Context) -> usize {
660            16
661        }
662    }
663
664    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MatchDriverArgs, D>
665        for &MatchDriverArgs
666    {
667        unsafe fn encode(
668            self,
669            encoder: &mut fidl::encoding::Encoder<'_, D>,
670            offset: usize,
671            mut depth: fidl::encoding::Depth,
672        ) -> fidl::Result<()> {
673            encoder.debug_check_bounds::<MatchDriverArgs>(offset);
674            // Vector header
675            let max_ordinal: u64 = self.max_ordinal_present();
676            encoder.write_num(max_ordinal, offset);
677            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
678            // Calling encoder.out_of_line_offset(0) is not allowed.
679            if max_ordinal == 0 {
680                return Ok(());
681            }
682            depth.increment()?;
683            let envelope_size = 8;
684            let bytes_len = max_ordinal as usize * envelope_size;
685            #[allow(unused_variables)]
686            let offset = encoder.out_of_line_offset(bytes_len);
687            let mut _prev_end_offset: usize = 0;
688            if 1 > max_ordinal {
689                return Ok(());
690            }
691
692            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
693            // are envelope_size bytes.
694            let cur_offset: usize = (1 - 1) * envelope_size;
695
696            // Zero reserved fields.
697            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
698
699            // Safety:
700            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
701            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
702            //   envelope_size bytes, there is always sufficient room.
703            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_driver_framework::NodeProperty, 64>, D>(
704            self.properties.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_driver_framework::NodeProperty, 64> as fidl::encoding::ValueTypeMarker>::borrow),
705            encoder, offset + cur_offset, depth
706        )?;
707
708            _prev_end_offset = cur_offset + envelope_size;
709            if 2 > max_ordinal {
710                return Ok(());
711            }
712
713            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
714            // are envelope_size bytes.
715            let cur_offset: usize = (2 - 1) * envelope_size;
716
717            // Zero reserved fields.
718            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
719
720            // Safety:
721            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
722            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
723            //   envelope_size bytes, there is always sufficient room.
724            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
725                self.name.as_ref().map(
726                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
727                ),
728                encoder,
729                offset + cur_offset,
730                depth,
731            )?;
732
733            _prev_end_offset = cur_offset + envelope_size;
734            if 3 > max_ordinal {
735                return Ok(());
736            }
737
738            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
739            // are envelope_size bytes.
740            let cur_offset: usize = (3 - 1) * envelope_size;
741
742            // Zero reserved fields.
743            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
744
745            // Safety:
746            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
747            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
748            //   envelope_size bytes, there is always sufficient room.
749            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedString, D>(
750                self.driver_url_suffix.as_ref().map(
751                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
752                ),
753                encoder,
754                offset + cur_offset,
755                depth,
756            )?;
757
758            _prev_end_offset = cur_offset + envelope_size;
759
760            Ok(())
761        }
762    }
763
764    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MatchDriverArgs {
765        #[inline(always)]
766        fn new_empty() -> Self {
767            Self::default()
768        }
769
770        unsafe fn decode(
771            &mut self,
772            decoder: &mut fidl::encoding::Decoder<'_, D>,
773            offset: usize,
774            mut depth: fidl::encoding::Depth,
775        ) -> fidl::Result<()> {
776            decoder.debug_check_bounds::<Self>(offset);
777            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
778                None => return Err(fidl::Error::NotNullable),
779                Some(len) => len,
780            };
781            // Calling decoder.out_of_line_offset(0) is not allowed.
782            if len == 0 {
783                return Ok(());
784            };
785            depth.increment()?;
786            let envelope_size = 8;
787            let bytes_len = len * envelope_size;
788            let offset = decoder.out_of_line_offset(bytes_len)?;
789            // Decode the envelope for each type.
790            let mut _next_ordinal_to_read = 0;
791            let mut next_offset = offset;
792            let end_offset = offset + bytes_len;
793            _next_ordinal_to_read += 1;
794            if next_offset >= end_offset {
795                return Ok(());
796            }
797
798            // Decode unknown envelopes for gaps in ordinals.
799            while _next_ordinal_to_read < 1 {
800                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
801                _next_ordinal_to_read += 1;
802                next_offset += envelope_size;
803            }
804
805            let next_out_of_line = decoder.next_out_of_line();
806            let handles_before = decoder.remaining_handles();
807            if let Some((inlined, num_bytes, num_handles)) =
808                fidl::encoding::decode_envelope_header(decoder, next_offset)?
809            {
810                let member_inline_size = <fidl::encoding::Vector<
811                    fidl_fuchsia_driver_framework::NodeProperty,
812                    64,
813                > as fidl::encoding::TypeMarker>::inline_size(
814                    decoder.context
815                );
816                if inlined != (member_inline_size <= 4) {
817                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
818                }
819                let inner_offset;
820                let mut inner_depth = depth.clone();
821                if inlined {
822                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
823                    inner_offset = next_offset;
824                } else {
825                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
826                    inner_depth.increment()?;
827                }
828                let val_ref =
829                self.properties.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_driver_framework::NodeProperty, 64>, D));
830                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_driver_framework::NodeProperty, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
831                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
832                {
833                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
834                }
835                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
836                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
837                }
838            }
839
840            next_offset += envelope_size;
841            _next_ordinal_to_read += 1;
842            if next_offset >= end_offset {
843                return Ok(());
844            }
845
846            // Decode unknown envelopes for gaps in ordinals.
847            while _next_ordinal_to_read < 2 {
848                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
849                _next_ordinal_to_read += 1;
850                next_offset += envelope_size;
851            }
852
853            let next_out_of_line = decoder.next_out_of_line();
854            let handles_before = decoder.remaining_handles();
855            if let Some((inlined, num_bytes, num_handles)) =
856                fidl::encoding::decode_envelope_header(decoder, next_offset)?
857            {
858                let member_inline_size =
859                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
860                        decoder.context,
861                    );
862                if inlined != (member_inline_size <= 4) {
863                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
864                }
865                let inner_offset;
866                let mut inner_depth = depth.clone();
867                if inlined {
868                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
869                    inner_offset = next_offset;
870                } else {
871                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
872                    inner_depth.increment()?;
873                }
874                let val_ref = self
875                    .name
876                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
877                fidl::decode!(
878                    fidl::encoding::BoundedString<128>,
879                    D,
880                    val_ref,
881                    decoder,
882                    inner_offset,
883                    inner_depth
884                )?;
885                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
886                {
887                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
888                }
889                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
890                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
891                }
892            }
893
894            next_offset += envelope_size;
895            _next_ordinal_to_read += 1;
896            if next_offset >= end_offset {
897                return Ok(());
898            }
899
900            // Decode unknown envelopes for gaps in ordinals.
901            while _next_ordinal_to_read < 3 {
902                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
903                _next_ordinal_to_read += 1;
904                next_offset += envelope_size;
905            }
906
907            let next_out_of_line = decoder.next_out_of_line();
908            let handles_before = decoder.remaining_handles();
909            if let Some((inlined, num_bytes, num_handles)) =
910                fidl::encoding::decode_envelope_header(decoder, next_offset)?
911            {
912                let member_inline_size =
913                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
914                        decoder.context,
915                    );
916                if inlined != (member_inline_size <= 4) {
917                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
918                }
919                let inner_offset;
920                let mut inner_depth = depth.clone();
921                if inlined {
922                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
923                    inner_offset = next_offset;
924                } else {
925                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
926                    inner_depth.increment()?;
927                }
928                let val_ref = self
929                    .driver_url_suffix
930                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
931                fidl::decode!(
932                    fidl::encoding::UnboundedString,
933                    D,
934                    val_ref,
935                    decoder,
936                    inner_offset,
937                    inner_depth
938                )?;
939                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
940                {
941                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
942                }
943                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
944                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
945                }
946            }
947
948            next_offset += envelope_size;
949
950            // Decode the remaining unknown envelopes.
951            while next_offset < end_offset {
952                _next_ordinal_to_read += 1;
953                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
954                next_offset += envelope_size;
955            }
956
957            Ok(())
958        }
959    }
960
961    impl fidl::encoding::ValueTypeMarker for MatchDriverResult {
962        type Borrowed<'a> = &'a Self;
963        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
964            value
965        }
966    }
967
968    unsafe impl fidl::encoding::TypeMarker for MatchDriverResult {
969        type Owned = Self;
970
971        #[inline(always)]
972        fn inline_align(_context: fidl::encoding::Context) -> usize {
973            8
974        }
975
976        #[inline(always)]
977        fn inline_size(_context: fidl::encoding::Context) -> usize {
978            16
979        }
980    }
981
982    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MatchDriverResult, D>
983        for &MatchDriverResult
984    {
985        #[inline]
986        unsafe fn encode(
987            self,
988            encoder: &mut fidl::encoding::Encoder<'_, D>,
989            offset: usize,
990            _depth: fidl::encoding::Depth,
991        ) -> fidl::Result<()> {
992            encoder.debug_check_bounds::<MatchDriverResult>(offset);
993            encoder.write_num::<u64>(self.ordinal(), offset);
994            match self {
995            MatchDriverResult::Driver(ref val) => {
996                fidl::encoding::encode_in_envelope::<fidl_fuchsia_driver_framework::DriverInfo, D>(
997                    <fidl_fuchsia_driver_framework::DriverInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
998                    encoder, offset + 8, _depth
999                )
1000            }
1001            MatchDriverResult::CompositeParents(ref val) => {
1002                fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedVector<fidl_fuchsia_driver_framework::CompositeParent>, D>(
1003                    <fidl::encoding::UnboundedVector<fidl_fuchsia_driver_framework::CompositeParent> as fidl::encoding::ValueTypeMarker>::borrow(val),
1004                    encoder, offset + 8, _depth
1005                )
1006            }
1007            MatchDriverResult::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1008        }
1009        }
1010    }
1011
1012    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MatchDriverResult {
1013        #[inline(always)]
1014        fn new_empty() -> Self {
1015            Self::__SourceBreaking { unknown_ordinal: 0 }
1016        }
1017
1018        #[inline]
1019        unsafe fn decode(
1020            &mut self,
1021            decoder: &mut fidl::encoding::Decoder<'_, D>,
1022            offset: usize,
1023            mut depth: fidl::encoding::Depth,
1024        ) -> fidl::Result<()> {
1025            decoder.debug_check_bounds::<Self>(offset);
1026            #[allow(unused_variables)]
1027            let next_out_of_line = decoder.next_out_of_line();
1028            let handles_before = decoder.remaining_handles();
1029            let (ordinal, inlined, num_bytes, num_handles) =
1030                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1031
1032            let member_inline_size = match ordinal {
1033            1 => <fidl_fuchsia_driver_framework::DriverInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1034            2 => <fidl::encoding::UnboundedVector<fidl_fuchsia_driver_framework::CompositeParent> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1035            0 => return Err(fidl::Error::UnknownUnionTag),
1036            _ => num_bytes as usize,
1037        };
1038
1039            if inlined != (member_inline_size <= 4) {
1040                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1041            }
1042            let _inner_offset;
1043            if inlined {
1044                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1045                _inner_offset = offset + 8;
1046            } else {
1047                depth.increment()?;
1048                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1049            }
1050            match ordinal {
1051                1 => {
1052                    #[allow(irrefutable_let_patterns)]
1053                    if let MatchDriverResult::Driver(_) = self {
1054                        // Do nothing, read the value into the object
1055                    } else {
1056                        // Initialize `self` to the right variant
1057                        *self = MatchDriverResult::Driver(fidl::new_empty!(
1058                            fidl_fuchsia_driver_framework::DriverInfo,
1059                            D
1060                        ));
1061                    }
1062                    #[allow(irrefutable_let_patterns)]
1063                    if let MatchDriverResult::Driver(ref mut val) = self {
1064                        fidl::decode!(
1065                            fidl_fuchsia_driver_framework::DriverInfo,
1066                            D,
1067                            val,
1068                            decoder,
1069                            _inner_offset,
1070                            depth
1071                        )?;
1072                    } else {
1073                        unreachable!()
1074                    }
1075                }
1076                2 => {
1077                    #[allow(irrefutable_let_patterns)]
1078                    if let MatchDriverResult::CompositeParents(_) = self {
1079                        // Do nothing, read the value into the object
1080                    } else {
1081                        // Initialize `self` to the right variant
1082                        *self = MatchDriverResult::CompositeParents(fidl::new_empty!(
1083                            fidl::encoding::UnboundedVector<
1084                                fidl_fuchsia_driver_framework::CompositeParent,
1085                            >,
1086                            D
1087                        ));
1088                    }
1089                    #[allow(irrefutable_let_patterns)]
1090                    if let MatchDriverResult::CompositeParents(ref mut val) = self {
1091                        fidl::decode!(
1092                            fidl::encoding::UnboundedVector<
1093                                fidl_fuchsia_driver_framework::CompositeParent,
1094                            >,
1095                            D,
1096                            val,
1097                            decoder,
1098                            _inner_offset,
1099                            depth
1100                        )?;
1101                    } else {
1102                        unreachable!()
1103                    }
1104                }
1105                #[allow(deprecated)]
1106                ordinal => {
1107                    for _ in 0..num_handles {
1108                        decoder.drop_next_handle()?;
1109                    }
1110                    *self = MatchDriverResult::__SourceBreaking { unknown_ordinal: ordinal };
1111                }
1112            }
1113            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1114                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1115            }
1116            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1117                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1118            }
1119            Ok(())
1120        }
1121    }
1122}