fidl_fuchsia_pkg_rewrite__common/
fidl_fuchsia_pkg_rewrite__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, PartialEq)]
12pub struct EditTransactionAddRequest {
13    pub rule: Rule,
14}
15
16impl fidl::Persistable for EditTransactionAddRequest {}
17
18#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
19pub struct EngineTestApplyRequest {
20    pub url: String,
21}
22
23impl fidl::Persistable for EngineTestApplyRequest {}
24
25#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct EngineTestApplyResponse {
27    pub rewritten: String,
28}
29
30impl fidl::Persistable for EngineTestApplyResponse {}
31
32/// A literal match and replacement rule.
33///
34/// # Examples
35///
36/// Replaces example.com with test.example.com for all packages
37/// ```
38/// {
39///     host_match: "example.com"
40///     host_replacement: "test.example.com"
41///     path_prefix_match: "/"
42///     path_prefix_replacement: "/"
43/// }
44/// ```
45///
46/// Replaces example.com with test.example.com for
47/// fuchsia-pkg://example.com/rolldice. A package called "rolldice" in another
48/// repo would not be rewritten.
49/// ```
50/// {
51///     host_match: "example.com"
52///     host_replacement: "test.example.com"
53///     path_prefix_match: "/rolldice"
54///     path_prefix_replacement: "/rolldice"
55/// }
56/// ```
57#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
58pub struct LiteralRule {
59    /// The exact hostname to match.
60    pub host_match: String,
61    /// The new hostname to replace the matched `host_match` with.
62    pub host_replacement: String,
63    /// The absolute path to a package or directory to match against.
64    ///
65    /// If `path_prefix_match` ends with '/', it will match any packages or
66    /// subdirectories below the matched path.
67    /// If `path_prefix_match` does not end with '/', it will be interpreted as
68    /// as an exact match.
69    ///
70    /// # Examples
71    ///
72    /// "/example" only matches a package called "example" at the root of the
73    /// repo. "/parent/examples" and "/examples" would not match.
74    ///
75    /// "/example/" would match any package under the "example" path at the root
76    /// of the repo.  For example, "/example/", "/example/package" would both
77    /// match.
78    pub path_prefix_match: String,
79    /// The absolute path to a single package or a directory to replace the
80    /// matched `path_prefix_match` with.
81    ///
82    /// `path_prefix_match` and `path_prefix_replacement` must both match
83    /// directories or both match exact packages. Mixing the two forms is not
84    /// allowed.
85    pub path_prefix_replacement: String,
86}
87
88impl fidl::Persistable for LiteralRule {}
89
90#[derive(Clone, Debug, PartialEq)]
91pub struct RuleIteratorNextResponse {
92    pub rules: Vec<Rule>,
93}
94
95impl fidl::Persistable for RuleIteratorNextResponse {}
96
97/// A rewrite rule, represented as an xunion for future compatibility.
98#[derive(Clone, Debug)]
99pub enum Rule {
100    Literal(LiteralRule),
101    #[doc(hidden)]
102    __SourceBreaking {
103        unknown_ordinal: u64,
104    },
105}
106
107/// Pattern that matches an unknown `Rule` member.
108#[macro_export]
109macro_rules! RuleUnknown {
110    () => {
111        _
112    };
113}
114
115// Custom PartialEq so that unknown variants are not equal to themselves.
116impl PartialEq for Rule {
117    fn eq(&self, other: &Self) -> bool {
118        match (self, other) {
119            (Self::Literal(x), Self::Literal(y)) => *x == *y,
120            _ => false,
121        }
122    }
123}
124
125impl Rule {
126    #[inline]
127    pub fn ordinal(&self) -> u64 {
128        match *self {
129            Self::Literal(_) => 1,
130            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
131        }
132    }
133
134    #[inline]
135    pub fn unknown_variant_for_testing() -> Self {
136        Self::__SourceBreaking { unknown_ordinal: 0 }
137    }
138
139    #[inline]
140    pub fn is_unknown(&self) -> bool {
141        match self {
142            Self::__SourceBreaking { .. } => true,
143            _ => false,
144        }
145    }
146}
147
148impl fidl::Persistable for Rule {}
149
150pub mod edit_transaction_ordinals {
151    pub const LIST_DYNAMIC: u64 = 0x37862a86b057cb49;
152    pub const RESET_ALL: u64 = 0x41e518acd0864a90;
153    pub const ADD: u64 = 0x56a2b5fe92ca5db6;
154    pub const COMMIT: u64 = 0x3ca50fc9c13341fb;
155}
156
157pub mod engine_ordinals {
158    pub const START_EDIT_TRANSACTION: u64 = 0x6f649b7dbbc904fb;
159    pub const LIST: u64 = 0xccbc8b5cb10ad14;
160    pub const LIST_STATIC: u64 = 0x5416f92d0bac1b30;
161    pub const TEST_APPLY: u64 = 0xc8826a2b36fca39;
162}
163
164pub mod rule_iterator_ordinals {
165    pub const NEXT: u64 = 0x1007ff472e2fcd45;
166}
167
168mod internal {
169    use super::*;
170
171    impl fidl::encoding::ValueTypeMarker for EditTransactionAddRequest {
172        type Borrowed<'a> = &'a Self;
173        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
174            value
175        }
176    }
177
178    unsafe impl fidl::encoding::TypeMarker for EditTransactionAddRequest {
179        type Owned = Self;
180
181        #[inline(always)]
182        fn inline_align(_context: fidl::encoding::Context) -> usize {
183            8
184        }
185
186        #[inline(always)]
187        fn inline_size(_context: fidl::encoding::Context) -> usize {
188            16
189        }
190    }
191
192    unsafe impl<D: fidl::encoding::ResourceDialect>
193        fidl::encoding::Encode<EditTransactionAddRequest, D> for &EditTransactionAddRequest
194    {
195        #[inline]
196        unsafe fn encode(
197            self,
198            encoder: &mut fidl::encoding::Encoder<'_, D>,
199            offset: usize,
200            _depth: fidl::encoding::Depth,
201        ) -> fidl::Result<()> {
202            encoder.debug_check_bounds::<EditTransactionAddRequest>(offset);
203            // Delegate to tuple encoding.
204            fidl::encoding::Encode::<EditTransactionAddRequest, D>::encode(
205                (<Rule as fidl::encoding::ValueTypeMarker>::borrow(&self.rule),),
206                encoder,
207                offset,
208                _depth,
209            )
210        }
211    }
212    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Rule, D>>
213        fidl::encoding::Encode<EditTransactionAddRequest, D> for (T0,)
214    {
215        #[inline]
216        unsafe fn encode(
217            self,
218            encoder: &mut fidl::encoding::Encoder<'_, D>,
219            offset: usize,
220            depth: fidl::encoding::Depth,
221        ) -> fidl::Result<()> {
222            encoder.debug_check_bounds::<EditTransactionAddRequest>(offset);
223            // Zero out padding regions. There's no need to apply masks
224            // because the unmasked parts will be overwritten by fields.
225            // Write the fields.
226            self.0.encode(encoder, offset + 0, depth)?;
227            Ok(())
228        }
229    }
230
231    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
232        for EditTransactionAddRequest
233    {
234        #[inline(always)]
235        fn new_empty() -> Self {
236            Self { rule: fidl::new_empty!(Rule, D) }
237        }
238
239        #[inline]
240        unsafe fn decode(
241            &mut self,
242            decoder: &mut fidl::encoding::Decoder<'_, D>,
243            offset: usize,
244            _depth: fidl::encoding::Depth,
245        ) -> fidl::Result<()> {
246            decoder.debug_check_bounds::<Self>(offset);
247            // Verify that padding bytes are zero.
248            fidl::decode!(Rule, D, &mut self.rule, decoder, offset + 0, _depth)?;
249            Ok(())
250        }
251    }
252
253    impl fidl::encoding::ValueTypeMarker for EngineTestApplyRequest {
254        type Borrowed<'a> = &'a Self;
255        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
256            value
257        }
258    }
259
260    unsafe impl fidl::encoding::TypeMarker for EngineTestApplyRequest {
261        type Owned = Self;
262
263        #[inline(always)]
264        fn inline_align(_context: fidl::encoding::Context) -> usize {
265            8
266        }
267
268        #[inline(always)]
269        fn inline_size(_context: fidl::encoding::Context) -> usize {
270            16
271        }
272    }
273
274    unsafe impl<D: fidl::encoding::ResourceDialect>
275        fidl::encoding::Encode<EngineTestApplyRequest, D> for &EngineTestApplyRequest
276    {
277        #[inline]
278        unsafe fn encode(
279            self,
280            encoder: &mut fidl::encoding::Encoder<'_, D>,
281            offset: usize,
282            _depth: fidl::encoding::Depth,
283        ) -> fidl::Result<()> {
284            encoder.debug_check_bounds::<EngineTestApplyRequest>(offset);
285            // Delegate to tuple encoding.
286            fidl::encoding::Encode::<EngineTestApplyRequest, D>::encode(
287                (<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
288                    &self.url,
289                ),),
290                encoder,
291                offset,
292                _depth,
293            )
294        }
295    }
296    unsafe impl<
297            D: fidl::encoding::ResourceDialect,
298            T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
299        > fidl::encoding::Encode<EngineTestApplyRequest, D> for (T0,)
300    {
301        #[inline]
302        unsafe fn encode(
303            self,
304            encoder: &mut fidl::encoding::Encoder<'_, D>,
305            offset: usize,
306            depth: fidl::encoding::Depth,
307        ) -> fidl::Result<()> {
308            encoder.debug_check_bounds::<EngineTestApplyRequest>(offset);
309            // Zero out padding regions. There's no need to apply masks
310            // because the unmasked parts will be overwritten by fields.
311            // Write the fields.
312            self.0.encode(encoder, offset + 0, depth)?;
313            Ok(())
314        }
315    }
316
317    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
318        for EngineTestApplyRequest
319    {
320        #[inline(always)]
321        fn new_empty() -> Self {
322            Self { url: fidl::new_empty!(fidl::encoding::UnboundedString, D) }
323        }
324
325        #[inline]
326        unsafe fn decode(
327            &mut self,
328            decoder: &mut fidl::encoding::Decoder<'_, D>,
329            offset: usize,
330            _depth: fidl::encoding::Depth,
331        ) -> fidl::Result<()> {
332            decoder.debug_check_bounds::<Self>(offset);
333            // Verify that padding bytes are zero.
334            fidl::decode!(
335                fidl::encoding::UnboundedString,
336                D,
337                &mut self.url,
338                decoder,
339                offset + 0,
340                _depth
341            )?;
342            Ok(())
343        }
344    }
345
346    impl fidl::encoding::ValueTypeMarker for EngineTestApplyResponse {
347        type Borrowed<'a> = &'a Self;
348        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
349            value
350        }
351    }
352
353    unsafe impl fidl::encoding::TypeMarker for EngineTestApplyResponse {
354        type Owned = Self;
355
356        #[inline(always)]
357        fn inline_align(_context: fidl::encoding::Context) -> usize {
358            8
359        }
360
361        #[inline(always)]
362        fn inline_size(_context: fidl::encoding::Context) -> usize {
363            16
364        }
365    }
366
367    unsafe impl<D: fidl::encoding::ResourceDialect>
368        fidl::encoding::Encode<EngineTestApplyResponse, D> for &EngineTestApplyResponse
369    {
370        #[inline]
371        unsafe fn encode(
372            self,
373            encoder: &mut fidl::encoding::Encoder<'_, D>,
374            offset: usize,
375            _depth: fidl::encoding::Depth,
376        ) -> fidl::Result<()> {
377            encoder.debug_check_bounds::<EngineTestApplyResponse>(offset);
378            // Delegate to tuple encoding.
379            fidl::encoding::Encode::<EngineTestApplyResponse, D>::encode(
380                (<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
381                    &self.rewritten,
382                ),),
383                encoder,
384                offset,
385                _depth,
386            )
387        }
388    }
389    unsafe impl<
390            D: fidl::encoding::ResourceDialect,
391            T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
392        > fidl::encoding::Encode<EngineTestApplyResponse, D> for (T0,)
393    {
394        #[inline]
395        unsafe fn encode(
396            self,
397            encoder: &mut fidl::encoding::Encoder<'_, D>,
398            offset: usize,
399            depth: fidl::encoding::Depth,
400        ) -> fidl::Result<()> {
401            encoder.debug_check_bounds::<EngineTestApplyResponse>(offset);
402            // Zero out padding regions. There's no need to apply masks
403            // because the unmasked parts will be overwritten by fields.
404            // Write the fields.
405            self.0.encode(encoder, offset + 0, depth)?;
406            Ok(())
407        }
408    }
409
410    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
411        for EngineTestApplyResponse
412    {
413        #[inline(always)]
414        fn new_empty() -> Self {
415            Self { rewritten: fidl::new_empty!(fidl::encoding::UnboundedString, D) }
416        }
417
418        #[inline]
419        unsafe fn decode(
420            &mut self,
421            decoder: &mut fidl::encoding::Decoder<'_, D>,
422            offset: usize,
423            _depth: fidl::encoding::Depth,
424        ) -> fidl::Result<()> {
425            decoder.debug_check_bounds::<Self>(offset);
426            // Verify that padding bytes are zero.
427            fidl::decode!(
428                fidl::encoding::UnboundedString,
429                D,
430                &mut self.rewritten,
431                decoder,
432                offset + 0,
433                _depth
434            )?;
435            Ok(())
436        }
437    }
438
439    impl fidl::encoding::ValueTypeMarker for LiteralRule {
440        type Borrowed<'a> = &'a Self;
441        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
442            value
443        }
444    }
445
446    unsafe impl fidl::encoding::TypeMarker for LiteralRule {
447        type Owned = Self;
448
449        #[inline(always)]
450        fn inline_align(_context: fidl::encoding::Context) -> usize {
451            8
452        }
453
454        #[inline(always)]
455        fn inline_size(_context: fidl::encoding::Context) -> usize {
456            64
457        }
458    }
459
460    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LiteralRule, D>
461        for &LiteralRule
462    {
463        #[inline]
464        unsafe fn encode(
465            self,
466            encoder: &mut fidl::encoding::Encoder<'_, D>,
467            offset: usize,
468            _depth: fidl::encoding::Depth,
469        ) -> fidl::Result<()> {
470            encoder.debug_check_bounds::<LiteralRule>(offset);
471            // Delegate to tuple encoding.
472            fidl::encoding::Encode::<LiteralRule, D>::encode(
473                (
474                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
475                        &self.host_match,
476                    ),
477                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
478                        &self.host_replacement,
479                    ),
480                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
481                        &self.path_prefix_match,
482                    ),
483                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
484                        &self.path_prefix_replacement,
485                    ),
486                ),
487                encoder,
488                offset,
489                _depth,
490            )
491        }
492    }
493    unsafe impl<
494            D: fidl::encoding::ResourceDialect,
495            T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
496            T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
497            T2: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
498            T3: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
499        > fidl::encoding::Encode<LiteralRule, D> for (T0, T1, T2, T3)
500    {
501        #[inline]
502        unsafe fn encode(
503            self,
504            encoder: &mut fidl::encoding::Encoder<'_, D>,
505            offset: usize,
506            depth: fidl::encoding::Depth,
507        ) -> fidl::Result<()> {
508            encoder.debug_check_bounds::<LiteralRule>(offset);
509            // Zero out padding regions. There's no need to apply masks
510            // because the unmasked parts will be overwritten by fields.
511            // Write the fields.
512            self.0.encode(encoder, offset + 0, depth)?;
513            self.1.encode(encoder, offset + 16, depth)?;
514            self.2.encode(encoder, offset + 32, depth)?;
515            self.3.encode(encoder, offset + 48, depth)?;
516            Ok(())
517        }
518    }
519
520    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LiteralRule {
521        #[inline(always)]
522        fn new_empty() -> Self {
523            Self {
524                host_match: fidl::new_empty!(fidl::encoding::UnboundedString, D),
525                host_replacement: fidl::new_empty!(fidl::encoding::UnboundedString, D),
526                path_prefix_match: fidl::new_empty!(fidl::encoding::UnboundedString, D),
527                path_prefix_replacement: fidl::new_empty!(fidl::encoding::UnboundedString, D),
528            }
529        }
530
531        #[inline]
532        unsafe fn decode(
533            &mut self,
534            decoder: &mut fidl::encoding::Decoder<'_, D>,
535            offset: usize,
536            _depth: fidl::encoding::Depth,
537        ) -> fidl::Result<()> {
538            decoder.debug_check_bounds::<Self>(offset);
539            // Verify that padding bytes are zero.
540            fidl::decode!(
541                fidl::encoding::UnboundedString,
542                D,
543                &mut self.host_match,
544                decoder,
545                offset + 0,
546                _depth
547            )?;
548            fidl::decode!(
549                fidl::encoding::UnboundedString,
550                D,
551                &mut self.host_replacement,
552                decoder,
553                offset + 16,
554                _depth
555            )?;
556            fidl::decode!(
557                fidl::encoding::UnboundedString,
558                D,
559                &mut self.path_prefix_match,
560                decoder,
561                offset + 32,
562                _depth
563            )?;
564            fidl::decode!(
565                fidl::encoding::UnboundedString,
566                D,
567                &mut self.path_prefix_replacement,
568                decoder,
569                offset + 48,
570                _depth
571            )?;
572            Ok(())
573        }
574    }
575
576    impl fidl::encoding::ValueTypeMarker for RuleIteratorNextResponse {
577        type Borrowed<'a> = &'a Self;
578        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
579            value
580        }
581    }
582
583    unsafe impl fidl::encoding::TypeMarker for RuleIteratorNextResponse {
584        type Owned = Self;
585
586        #[inline(always)]
587        fn inline_align(_context: fidl::encoding::Context) -> usize {
588            8
589        }
590
591        #[inline(always)]
592        fn inline_size(_context: fidl::encoding::Context) -> usize {
593            16
594        }
595    }
596
597    unsafe impl<D: fidl::encoding::ResourceDialect>
598        fidl::encoding::Encode<RuleIteratorNextResponse, D> for &RuleIteratorNextResponse
599    {
600        #[inline]
601        unsafe fn encode(
602            self,
603            encoder: &mut fidl::encoding::Encoder<'_, D>,
604            offset: usize,
605            _depth: fidl::encoding::Depth,
606        ) -> fidl::Result<()> {
607            encoder.debug_check_bounds::<RuleIteratorNextResponse>(offset);
608            // Delegate to tuple encoding.
609            fidl::encoding::Encode::<RuleIteratorNextResponse, D>::encode(
610                (
611                    <fidl::encoding::UnboundedVector<Rule> as fidl::encoding::ValueTypeMarker>::borrow(&self.rules),
612                ),
613                encoder, offset, _depth
614            )
615        }
616    }
617    unsafe impl<
618            D: fidl::encoding::ResourceDialect,
619            T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Rule>, D>,
620        > fidl::encoding::Encode<RuleIteratorNextResponse, D> for (T0,)
621    {
622        #[inline]
623        unsafe fn encode(
624            self,
625            encoder: &mut fidl::encoding::Encoder<'_, D>,
626            offset: usize,
627            depth: fidl::encoding::Depth,
628        ) -> fidl::Result<()> {
629            encoder.debug_check_bounds::<RuleIteratorNextResponse>(offset);
630            // Zero out padding regions. There's no need to apply masks
631            // because the unmasked parts will be overwritten by fields.
632            // Write the fields.
633            self.0.encode(encoder, offset + 0, depth)?;
634            Ok(())
635        }
636    }
637
638    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
639        for RuleIteratorNextResponse
640    {
641        #[inline(always)]
642        fn new_empty() -> Self {
643            Self { rules: fidl::new_empty!(fidl::encoding::UnboundedVector<Rule>, D) }
644        }
645
646        #[inline]
647        unsafe fn decode(
648            &mut self,
649            decoder: &mut fidl::encoding::Decoder<'_, D>,
650            offset: usize,
651            _depth: fidl::encoding::Depth,
652        ) -> fidl::Result<()> {
653            decoder.debug_check_bounds::<Self>(offset);
654            // Verify that padding bytes are zero.
655            fidl::decode!(
656                fidl::encoding::UnboundedVector<Rule>,
657                D,
658                &mut self.rules,
659                decoder,
660                offset + 0,
661                _depth
662            )?;
663            Ok(())
664        }
665    }
666
667    impl fidl::encoding::ValueTypeMarker for Rule {
668        type Borrowed<'a> = &'a Self;
669        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
670            value
671        }
672    }
673
674    unsafe impl fidl::encoding::TypeMarker for Rule {
675        type Owned = Self;
676
677        #[inline(always)]
678        fn inline_align(_context: fidl::encoding::Context) -> usize {
679            8
680        }
681
682        #[inline(always)]
683        fn inline_size(_context: fidl::encoding::Context) -> usize {
684            16
685        }
686    }
687
688    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Rule, D> for &Rule {
689        #[inline]
690        unsafe fn encode(
691            self,
692            encoder: &mut fidl::encoding::Encoder<'_, D>,
693            offset: usize,
694            _depth: fidl::encoding::Depth,
695        ) -> fidl::Result<()> {
696            encoder.debug_check_bounds::<Rule>(offset);
697            encoder.write_num::<u64>(self.ordinal(), offset);
698            match self {
699                Rule::Literal(ref val) => fidl::encoding::encode_in_envelope::<LiteralRule, D>(
700                    <LiteralRule as fidl::encoding::ValueTypeMarker>::borrow(val),
701                    encoder,
702                    offset + 8,
703                    _depth,
704                ),
705                Rule::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
706            }
707        }
708    }
709
710    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Rule {
711        #[inline(always)]
712        fn new_empty() -> Self {
713            Self::__SourceBreaking { unknown_ordinal: 0 }
714        }
715
716        #[inline]
717        unsafe fn decode(
718            &mut self,
719            decoder: &mut fidl::encoding::Decoder<'_, D>,
720            offset: usize,
721            mut depth: fidl::encoding::Depth,
722        ) -> fidl::Result<()> {
723            decoder.debug_check_bounds::<Self>(offset);
724            #[allow(unused_variables)]
725            let next_out_of_line = decoder.next_out_of_line();
726            let handles_before = decoder.remaining_handles();
727            let (ordinal, inlined, num_bytes, num_handles) =
728                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
729
730            let member_inline_size = match ordinal {
731                1 => <LiteralRule as fidl::encoding::TypeMarker>::inline_size(decoder.context),
732                0 => return Err(fidl::Error::UnknownUnionTag),
733                _ => num_bytes as usize,
734            };
735
736            if inlined != (member_inline_size <= 4) {
737                return Err(fidl::Error::InvalidInlineBitInEnvelope);
738            }
739            let _inner_offset;
740            if inlined {
741                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
742                _inner_offset = offset + 8;
743            } else {
744                depth.increment()?;
745                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
746            }
747            match ordinal {
748                1 => {
749                    #[allow(irrefutable_let_patterns)]
750                    if let Rule::Literal(_) = self {
751                        // Do nothing, read the value into the object
752                    } else {
753                        // Initialize `self` to the right variant
754                        *self = Rule::Literal(fidl::new_empty!(LiteralRule, D));
755                    }
756                    #[allow(irrefutable_let_patterns)]
757                    if let Rule::Literal(ref mut val) = self {
758                        fidl::decode!(LiteralRule, D, val, decoder, _inner_offset, depth)?;
759                    } else {
760                        unreachable!()
761                    }
762                }
763                #[allow(deprecated)]
764                ordinal => {
765                    for _ in 0..num_handles {
766                        decoder.drop_next_handle()?;
767                    }
768                    *self = Rule::__SourceBreaking { unknown_ordinal: ordinal };
769                }
770            }
771            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
772                return Err(fidl::Error::InvalidNumBytesInEnvelope);
773            }
774            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
775                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
776            }
777            Ok(())
778        }
779    }
780}