fidl_next_fuchsia_data/
fidl_next_fuchsia_data.rs

1// DO NOT EDIT: This file is machine-generated by fidlgen
2#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5pub const MAX_KEY_LENGTH: u32 = 1024;
6
7pub const MAX_NUM_ENTRIES: u32 = 1024;
8
9#[doc = " A key/value pair in a `Dictionary`.\n"]
10#[derive(Clone, Debug)]
11pub struct DictionaryEntry {
12    pub key: String,
13
14    pub value: Option<Box<crate::DictionaryValue>>,
15}
16
17impl ::fidl_next::Encodable for DictionaryEntry {
18    type Encoded = WireDictionaryEntry<'static>;
19}
20
21unsafe impl<___E> ::fidl_next::Encode<___E> for DictionaryEntry
22where
23    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
24    ___E: ::fidl_next::Encoder,
25{
26    #[inline]
27    fn encode(
28        self,
29        encoder: &mut ___E,
30        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
31    ) -> Result<(), ::fidl_next::EncodeError> {
32        ::fidl_next::munge! {
33            let Self::Encoded {
34                key,
35                value,
36
37            } = out;
38        }
39
40        ::fidl_next::Encode::encode(self.key, encoder, key)?;
41
42        ::fidl_next::Encode::encode(self.value, encoder, value)?;
43
44        Ok(())
45    }
46}
47
48unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DictionaryEntry
49where
50    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
51    ___E: ::fidl_next::Encoder,
52{
53    #[inline]
54    fn encode_ref(
55        &self,
56        encoder: &mut ___E,
57        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
58    ) -> Result<(), ::fidl_next::EncodeError> {
59        ::fidl_next::munge! {
60            let Self::Encoded {
61                key,
62                value,
63
64            } = out;
65        }
66
67        ::fidl_next::EncodeRef::encode_ref(&self.key, encoder, key)?;
68
69        ::fidl_next::EncodeRef::encode_ref(&self.value, encoder, value)?;
70
71        Ok(())
72    }
73}
74
75impl ::fidl_next::EncodableOption for DictionaryEntry {
76    type EncodedOption = ::fidl_next::WireBox<'static, WireDictionaryEntry<'static>>;
77}
78
79unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DictionaryEntry
80where
81    ___E: ::fidl_next::Encoder + ?Sized,
82    DictionaryEntry: ::fidl_next::Encode<___E>,
83{
84    #[inline]
85    fn encode_option(
86        this: Option<Self>,
87        encoder: &mut ___E,
88        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
89    ) -> Result<(), ::fidl_next::EncodeError> {
90        if let Some(inner) = this {
91            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
92            ::fidl_next::WireBox::encode_present(out);
93        } else {
94            ::fidl_next::WireBox::encode_absent(out);
95        }
96
97        Ok(())
98    }
99}
100
101unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for DictionaryEntry
102where
103    ___E: ::fidl_next::Encoder + ?Sized,
104    DictionaryEntry: ::fidl_next::EncodeRef<___E>,
105{
106    #[inline]
107    fn encode_option_ref(
108        this: Option<&Self>,
109        encoder: &mut ___E,
110        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
111    ) -> Result<(), ::fidl_next::EncodeError> {
112        if let Some(inner) = this {
113            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
114            ::fidl_next::WireBox::encode_present(out);
115        } else {
116            ::fidl_next::WireBox::encode_absent(out);
117        }
118
119        Ok(())
120    }
121}
122
123impl<'de> ::fidl_next::FromWire<WireDictionaryEntry<'de>> for DictionaryEntry {
124    #[inline]
125    fn from_wire(wire: WireDictionaryEntry<'de>) -> Self {
126        Self {
127            key: ::fidl_next::FromWire::from_wire(wire.key),
128
129            value: ::fidl_next::FromWire::from_wire(wire.value),
130        }
131    }
132}
133
134impl<'de> ::fidl_next::FromWireRef<WireDictionaryEntry<'de>> for DictionaryEntry {
135    #[inline]
136    fn from_wire_ref(wire: &WireDictionaryEntry<'de>) -> Self {
137        Self {
138            key: ::fidl_next::FromWireRef::from_wire_ref(&wire.key),
139
140            value: ::fidl_next::FromWireRef::from_wire_ref(&wire.value),
141        }
142    }
143}
144
145/// The wire type corresponding to [`DictionaryEntry`].
146#[derive(Debug)]
147#[repr(C)]
148pub struct WireDictionaryEntry<'de> {
149    pub key: ::fidl_next::WireString<'de>,
150
151    pub value: crate::WireOptionalDictionaryValue<'de>,
152}
153
154unsafe impl ::fidl_next::Wire for WireDictionaryEntry<'static> {
155    type Decoded<'de> = WireDictionaryEntry<'de>;
156
157    #[inline]
158    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
159}
160
161unsafe impl<___D> ::fidl_next::Decode<___D> for WireDictionaryEntry<'static>
162where
163    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
164    ___D: ::fidl_next::Decoder,
165{
166    fn decode(
167        slot: ::fidl_next::Slot<'_, Self>,
168        decoder: &mut ___D,
169    ) -> Result<(), ::fidl_next::DecodeError> {
170        ::fidl_next::munge! {
171            let Self {
172                mut key,
173                mut value,
174
175            } = slot;
176        }
177
178        ::fidl_next::Decode::decode(key.as_mut(), decoder)?;
179
180        let key = unsafe { key.deref_unchecked() };
181
182        if key.len() > 1024 {
183            return Err(::fidl_next::DecodeError::VectorTooLong {
184                size: key.len() as u64,
185                limit: 1024,
186            });
187        }
188
189        ::fidl_next::Decode::decode(value.as_mut(), decoder)?;
190
191        Ok(())
192    }
193}
194
195#[doc = " A dictionary is a sequence of key/value pairs.\n Keys must be unique and sorted in lexicographically increasing order.\n"]
196#[derive(Clone, Debug, Default)]
197pub struct Dictionary {
198    pub entries: Option<Vec<crate::DictionaryEntry>>,
199}
200
201impl Dictionary {
202    fn __max_ordinal(&self) -> usize {
203        if self.entries.is_some() {
204            return 1;
205        }
206
207        0
208    }
209}
210
211impl ::fidl_next::Encodable for Dictionary {
212    type Encoded = WireDictionary<'static>;
213}
214
215unsafe impl<___E> ::fidl_next::Encode<___E> for Dictionary
216where
217    ___E: ::fidl_next::Encoder + ?Sized,
218{
219    #[inline]
220    fn encode(
221        mut self,
222        encoder: &mut ___E,
223        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
224    ) -> Result<(), ::fidl_next::EncodeError> {
225        ::fidl_next::munge!(let WireDictionary { table } = out);
226
227        let max_ord = self.__max_ordinal();
228
229        let mut out = ::core::mem::MaybeUninit::<::fidl_next::WireEnvelope>::uninit();
230        ::fidl_next::Wire::zero_padding(&mut out);
231
232        let mut preallocated =
233            ::fidl_next::EncoderExt::preallocate::<::fidl_next::WireEnvelope>(encoder, max_ord);
234
235        for i in 1..=max_ord {
236            match i {
237                1 => {
238                    if let Some(entries) = self.entries.take() {
239                        ::fidl_next::WireEnvelope::encode_value(
240                            entries,
241                            preallocated.encoder,
242                            &mut out,
243                        )?;
244                    } else {
245                        ::fidl_next::WireEnvelope::encode_zero(&mut out)
246                    }
247                }
248
249                _ => ::fidl_next::WireEnvelope::encode_zero(&mut out),
250            }
251            unsafe {
252                preallocated.write_next(out.assume_init_ref());
253            }
254        }
255
256        ::fidl_next::WireTable::encode_len(table, max_ord);
257
258        Ok(())
259    }
260}
261
262unsafe impl<___E> ::fidl_next::EncodeRef<___E> for Dictionary
263where
264    ___E: ::fidl_next::Encoder + ?Sized,
265{
266    #[inline]
267    fn encode_ref(
268        &self,
269        encoder: &mut ___E,
270        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
271    ) -> Result<(), ::fidl_next::EncodeError> {
272        ::fidl_next::munge!(let WireDictionary { table } = out);
273
274        let max_ord = self.__max_ordinal();
275
276        let mut out = ::core::mem::MaybeUninit::<::fidl_next::WireEnvelope>::uninit();
277        ::fidl_next::Wire::zero_padding(&mut out);
278
279        let mut preallocated =
280            ::fidl_next::EncoderExt::preallocate::<::fidl_next::WireEnvelope>(encoder, max_ord);
281
282        for i in 1..=max_ord {
283            match i {
284                1 => {
285                    if let Some(entries) = &self.entries {
286                        ::fidl_next::WireEnvelope::encode_value(
287                            entries,
288                            preallocated.encoder,
289                            &mut out,
290                        )?;
291                    } else {
292                        ::fidl_next::WireEnvelope::encode_zero(&mut out)
293                    }
294                }
295
296                _ => ::fidl_next::WireEnvelope::encode_zero(&mut out),
297            }
298            unsafe {
299                preallocated.write_next(out.assume_init_ref());
300            }
301        }
302
303        ::fidl_next::WireTable::encode_len(table, max_ord);
304
305        Ok(())
306    }
307}
308
309impl<'de> ::fidl_next::FromWire<WireDictionary<'de>> for Dictionary {
310    #[inline]
311    fn from_wire(wire: WireDictionary<'de>) -> Self {
312        let wire = ::core::mem::ManuallyDrop::new(wire);
313
314        let entries = wire.table.get(1);
315
316        Self {
317
318
319                entries: entries.map(|envelope| ::fidl_next::FromWire::from_wire(
320                    unsafe { envelope.read_unchecked::<::fidl_next::WireVector<'de, crate::WireDictionaryEntry<'de>>>() }
321                )),
322
323        }
324    }
325}
326
327impl<'de> ::fidl_next::FromWireRef<WireDictionary<'de>> for Dictionary {
328    #[inline]
329    fn from_wire_ref(wire: &WireDictionary<'de>) -> Self {
330        Self {
331
332
333                entries: wire.table.get(1)
334                    .map(|envelope| ::fidl_next::FromWireRef::from_wire_ref(
335                        unsafe { envelope.deref_unchecked::<::fidl_next::WireVector<'de, crate::WireDictionaryEntry<'de>>>() }
336                    )),
337
338        }
339    }
340}
341
342/// The wire type corresponding to [`Dictionary`].
343#[repr(C)]
344pub struct WireDictionary<'de> {
345    table: ::fidl_next::WireTable<'de>,
346}
347
348impl<'de> Drop for WireDictionary<'de> {
349    fn drop(&mut self) {
350        let _ = self.table.get(1)
351                .map(|envelope| unsafe {
352                    envelope.read_unchecked::<::fidl_next::WireVector<'de, crate::WireDictionaryEntry<'de>>>()
353                });
354    }
355}
356
357unsafe impl ::fidl_next::Wire for WireDictionary<'static> {
358    type Decoded<'de> = WireDictionary<'de>;
359
360    #[inline]
361    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
362        ::fidl_next::munge!(let Self { table } = out);
363        ::fidl_next::WireTable::zero_padding(table);
364    }
365}
366
367unsafe impl<___D> ::fidl_next::Decode<___D> for WireDictionary<'static>
368where
369    ___D: ::fidl_next::Decoder + ?Sized,
370{
371    fn decode(
372        slot: ::fidl_next::Slot<'_, Self>,
373        decoder: &mut ___D,
374    ) -> Result<(), ::fidl_next::DecodeError> {
375        ::fidl_next::munge!(let Self { table } = slot);
376
377        ::fidl_next::WireTable::decode_with(table, decoder, |ordinal, mut slot, decoder| {
378            match ordinal {
379                0 => unsafe { ::core::hint::unreachable_unchecked() },
380
381                1 => {
382                    ::fidl_next::WireEnvelope::decode_as::<
383                        ___D,
384                        ::fidl_next::WireVector<'static, crate::WireDictionaryEntry<'static>>,
385                    >(slot.as_mut(), decoder)?;
386
387                    let entries = unsafe {
388                        slot
389                                            .deref_unchecked()
390                                            .deref_unchecked::<
391                                                ::fidl_next::WireVector<'_, crate::WireDictionaryEntry<'_>>
392                                            >()
393                    };
394
395                    if entries.len() > 1024 {
396                        return Err(::fidl_next::DecodeError::VectorTooLong {
397                            size: entries.len() as u64,
398                            limit: 1024,
399                        });
400                    }
401
402                    Ok(())
403                }
404
405                _ => ::fidl_next::WireEnvelope::decode_unknown(slot, decoder),
406            }
407        })
408    }
409}
410
411impl<'de> WireDictionary<'de> {
412    pub fn entries(
413        &self,
414    ) -> Option<&::fidl_next::WireVector<'de, crate::WireDictionaryEntry<'de>>> {
415        unsafe { Some(self.table.get(1)?.deref_unchecked()) }
416    }
417}
418
419impl<'de> ::core::fmt::Debug for WireDictionary<'de> {
420    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> Result<(), ::core::fmt::Error> {
421        f.debug_struct("Dictionary").field("entries", &self.entries()).finish()
422    }
423}
424
425pub const MAX_NUM_VALUE_ITEMS: u32 = 1024;
426
427pub const MAX_VALUE_LENGTH: u32 = 32768;
428
429#[doc = " A dictionary\'s value is a string, a list of strings, or a list of objects.\n"]
430#[derive(Clone, Debug)]
431pub enum DictionaryValue {
432    Str(String),
433
434    StrVec(Vec<String>),
435
436    ObjVec(Vec<crate::Dictionary>),
437
438    UnknownOrdinal_(u64),
439}
440
441impl ::fidl_next::Encodable for DictionaryValue {
442    type Encoded = WireDictionaryValue<'static>;
443}
444
445unsafe impl<___E> ::fidl_next::Encode<___E> for DictionaryValue
446where
447    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
448    ___E: ::fidl_next::Encoder,
449{
450    #[inline]
451    fn encode(
452        self,
453        encoder: &mut ___E,
454        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
455    ) -> Result<(), ::fidl_next::EncodeError> {
456        ::fidl_next::munge!(let WireDictionaryValue { raw, _phantom: _ } = out);
457
458        match self {
459            Self::Str(value) => {
460                ::fidl_next::RawWireUnion::encode_as::<___E, String>(value, 1, encoder, raw)?
461            }
462
463            Self::StrVec(value) => {
464                ::fidl_next::RawWireUnion::encode_as::<___E, Vec<String>>(value, 2, encoder, raw)?
465            }
466
467            Self::ObjVec(value) => ::fidl_next::RawWireUnion::encode_as::<
468                ___E,
469                Vec<crate::Dictionary>,
470            >(value, 3, encoder, raw)?,
471
472            Self::UnknownOrdinal_(ordinal) => {
473                return Err(::fidl_next::EncodeError::UnknownUnionOrdinal(ordinal as usize));
474            }
475        }
476
477        Ok(())
478    }
479}
480
481unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DictionaryValue
482where
483    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
484    ___E: ::fidl_next::Encoder,
485{
486    #[inline]
487    fn encode_ref(
488        &self,
489        encoder: &mut ___E,
490        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
491    ) -> Result<(), ::fidl_next::EncodeError> {
492        ::fidl_next::munge!(let WireDictionaryValue { raw, _phantom: _ } = out);
493
494        match self {
495            Self::Str(value) => {
496                ::fidl_next::RawWireUnion::encode_as::<___E, &String>(value, 1, encoder, raw)?
497            }
498
499            Self::StrVec(value) => {
500                ::fidl_next::RawWireUnion::encode_as::<___E, &Vec<String>>(value, 2, encoder, raw)?
501            }
502
503            Self::ObjVec(value) => ::fidl_next::RawWireUnion::encode_as::<
504                ___E,
505                &Vec<crate::Dictionary>,
506            >(value, 3, encoder, raw)?,
507
508            Self::UnknownOrdinal_(ordinal) => {
509                return Err(::fidl_next::EncodeError::UnknownUnionOrdinal(*ordinal as usize));
510            }
511        }
512
513        Ok(())
514    }
515}
516
517impl ::fidl_next::EncodableOption for DictionaryValue {
518    type EncodedOption = WireOptionalDictionaryValue<'static>;
519}
520
521unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DictionaryValue
522where
523    ___E: ?Sized,
524    DictionaryValue: ::fidl_next::Encode<___E>,
525{
526    #[inline]
527    fn encode_option(
528        this: Option<Self>,
529        encoder: &mut ___E,
530        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
531    ) -> Result<(), ::fidl_next::EncodeError> {
532        ::fidl_next::munge!(let WireOptionalDictionaryValue { raw, _phantom: _ } = &mut *out);
533
534        if let Some(inner) = this {
535            let value_out = unsafe { &mut *out.as_mut_ptr().cast() };
536            ::fidl_next::Encode::encode(inner, encoder, value_out)?;
537        } else {
538            ::fidl_next::RawWireUnion::encode_absent(raw);
539        }
540
541        Ok(())
542    }
543}
544
545unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for DictionaryValue
546where
547    ___E: ?Sized,
548    DictionaryValue: ::fidl_next::EncodeRef<___E>,
549{
550    #[inline]
551    fn encode_option_ref(
552        this: Option<&Self>,
553        encoder: &mut ___E,
554        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
555    ) -> Result<(), ::fidl_next::EncodeError> {
556        ::fidl_next::munge!(let WireOptionalDictionaryValue { raw, _phantom: _ } = &mut *out);
557
558        if let Some(inner) = this {
559            let value_out = unsafe { &mut *out.as_mut_ptr().cast() };
560            ::fidl_next::EncodeRef::encode_ref(inner, encoder, value_out)?;
561        } else {
562            ::fidl_next::RawWireUnion::encode_absent(raw);
563        }
564
565        Ok(())
566    }
567}
568
569impl<'de> ::fidl_next::FromWire<WireDictionaryValue<'de>> for DictionaryValue {
570    #[inline]
571    fn from_wire(wire: WireDictionaryValue<'de>) -> Self {
572        let wire = ::core::mem::ManuallyDrop::new(wire);
573        match wire.raw.ordinal() {
574            1 => Self::Str(::fidl_next::FromWire::from_wire(unsafe {
575                wire.raw.get().read_unchecked::<::fidl_next::WireString<'de>>()
576            })),
577
578            2 => {
579                Self::StrVec(::fidl_next::FromWire::from_wire(unsafe {
580                    wire.raw.get().read_unchecked::<::fidl_next::WireVector<'de, ::fidl_next::WireString<'de>>>()
581                }))
582            }
583
584            3 => Self::ObjVec(::fidl_next::FromWire::from_wire(unsafe {
585                wire.raw
586                    .get()
587                    .read_unchecked::<::fidl_next::WireVector<'de, crate::WireDictionary<'de>>>()
588            })),
589
590            _ => unsafe { ::core::hint::unreachable_unchecked() },
591        }
592    }
593}
594
595impl<'de> ::fidl_next::FromWireRef<WireDictionaryValue<'de>> for DictionaryValue {
596    #[inline]
597    fn from_wire_ref(wire: &WireDictionaryValue<'de>) -> Self {
598        match wire.raw.ordinal() {
599            1 => Self::Str(::fidl_next::FromWireRef::from_wire_ref(unsafe {
600                wire.raw.get().deref_unchecked::<::fidl_next::WireString<'de>>()
601            })),
602
603            2 => {
604                Self::StrVec(::fidl_next::FromWireRef::from_wire_ref(unsafe {
605                    wire.raw.get().deref_unchecked::<::fidl_next::WireVector<'de, ::fidl_next::WireString<'de>>>()
606                }))
607            }
608
609            3 => {
610                Self::ObjVec(::fidl_next::FromWireRef::from_wire_ref(unsafe {
611                    wire.raw.get().deref_unchecked::<::fidl_next::WireVector<'de, crate::WireDictionary<'de>>>()
612                }))
613            }
614
615            _ => unsafe { ::core::hint::unreachable_unchecked() },
616        }
617    }
618}
619
620impl<'de> ::fidl_next::FromWireOption<WireOptionalDictionaryValue<'de>> for Box<DictionaryValue> {
621    #[inline]
622    fn from_wire_option(wire: WireOptionalDictionaryValue<'de>) -> Option<Self> {
623        if let Some(inner) = wire.into_option() {
624            Some(Box::new(::fidl_next::FromWire::from_wire(inner)))
625        } else {
626            None
627        }
628    }
629}
630
631impl<'de> ::fidl_next::FromWireOptionRef<WireOptionalDictionaryValue<'de>>
632    for Box<DictionaryValue>
633{
634    #[inline]
635    fn from_wire_option_ref(wire: &WireOptionalDictionaryValue<'de>) -> Option<Self> {
636        if let Some(inner) = wire.as_ref() {
637            Some(Box::new(::fidl_next::FromWireRef::from_wire_ref(inner)))
638        } else {
639            None
640        }
641    }
642}
643
644/// The wire type corresponding to [`DictionaryValue`].
645#[repr(transparent)]
646pub struct WireDictionaryValue<'de> {
647    raw: ::fidl_next::RawWireUnion,
648    _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
649}
650
651impl<'de> Drop for WireDictionaryValue<'de> {
652    fn drop(&mut self) {
653        match self.raw.ordinal() {
654            1 => {
655                let _ = unsafe { self.raw.get().read_unchecked::<::fidl_next::WireString<'de>>() };
656            }
657
658            2 => {
659                let _ = unsafe {
660                    self.raw.get().read_unchecked::<::fidl_next::WireVector<'de, ::fidl_next::WireString<'de>>>()
661                };
662            }
663
664            3 => {
665                let _ = unsafe {
666                    self.raw
667                        .get()
668                        .read_unchecked::<::fidl_next::WireVector<'de, crate::WireDictionary<'de>>>(
669                        )
670                };
671            }
672
673            _ => (),
674        }
675    }
676}
677
678unsafe impl ::fidl_next::Wire for WireDictionaryValue<'static> {
679    type Decoded<'de> = WireDictionaryValue<'de>;
680
681    #[inline]
682    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
683        ::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
684        ::fidl_next::RawWireUnion::zero_padding(raw);
685    }
686}
687
688pub mod dictionary_value {
689    pub enum Ref<'de> {
690        Str(&'de ::fidl_next::WireString<'de>),
691
692        StrVec(&'de ::fidl_next::WireVector<'de, ::fidl_next::WireString<'de>>),
693
694        ObjVec(&'de ::fidl_next::WireVector<'de, crate::WireDictionary<'de>>),
695
696        UnknownOrdinal_(u64),
697    }
698}
699
700impl<'de> WireDictionaryValue<'de> {
701    pub fn as_ref(&self) -> crate::dictionary_value::Ref<'_> {
702        match self.raw.ordinal() {
703            1 => crate::dictionary_value::Ref::Str(unsafe {
704                self.raw.get().deref_unchecked::<::fidl_next::WireString<'_>>()
705            }),
706
707            2 => {
708                crate::dictionary_value::Ref::StrVec(unsafe {
709                    self.raw.get().deref_unchecked::<::fidl_next::WireVector<'_, ::fidl_next::WireString<'_>>>()
710                })
711            }
712
713            3 => crate::dictionary_value::Ref::ObjVec(unsafe {
714                self.raw
715                    .get()
716                    .deref_unchecked::<::fidl_next::WireVector<'_, crate::WireDictionary<'_>>>()
717            }),
718
719            unknown => crate::dictionary_value::Ref::UnknownOrdinal_(unknown),
720        }
721    }
722}
723
724unsafe impl<___D> ::fidl_next::Decode<___D> for WireDictionaryValue<'static>
725where
726    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
727    ___D: ::fidl_next::Decoder,
728{
729    fn decode(
730        mut slot: ::fidl_next::Slot<'_, Self>,
731        decoder: &mut ___D,
732    ) -> Result<(), ::fidl_next::DecodeError> {
733        ::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
734        match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
735            1 => ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireString<'static>>(
736                raw, decoder,
737            )?,
738
739            2 => ::fidl_next::RawWireUnion::decode_as::<
740                ___D,
741                ::fidl_next::WireVector<'static, ::fidl_next::WireString<'static>>,
742            >(raw, decoder)?,
743
744            3 => ::fidl_next::RawWireUnion::decode_as::<
745                ___D,
746                ::fidl_next::WireVector<'static, crate::WireDictionary<'static>>,
747            >(raw, decoder)?,
748
749            _ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
750        }
751
752        Ok(())
753    }
754}
755
756impl<'de> ::core::fmt::Debug for WireDictionaryValue<'de> {
757    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
758        match self.raw.ordinal() {
759            1 => unsafe { self.raw.get().deref_unchecked::<::fidl_next::WireString<'_>>().fmt(f) },
760            2 => unsafe {
761                self.raw
762                    .get()
763                    .deref_unchecked::<::fidl_next::WireVector<'_, ::fidl_next::WireString<'_>>>()
764                    .fmt(f)
765            },
766            3 => unsafe {
767                self.raw
768                    .get()
769                    .deref_unchecked::<::fidl_next::WireVector<'_, crate::WireDictionary<'_>>>()
770                    .fmt(f)
771            },
772            _ => unsafe { ::core::hint::unreachable_unchecked() },
773        }
774    }
775}
776
777#[repr(transparent)]
778pub struct WireOptionalDictionaryValue<'de> {
779    raw: ::fidl_next::RawWireUnion,
780    _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
781}
782
783unsafe impl ::fidl_next::Wire for WireOptionalDictionaryValue<'static> {
784    type Decoded<'de> = WireOptionalDictionaryValue<'de>;
785
786    #[inline]
787    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
788        ::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
789        ::fidl_next::RawWireUnion::zero_padding(raw);
790    }
791}
792
793impl<'de> WireOptionalDictionaryValue<'de> {
794    pub fn is_some(&self) -> bool {
795        self.raw.is_some()
796    }
797
798    pub fn is_none(&self) -> bool {
799        self.raw.is_none()
800    }
801
802    pub fn as_ref(&self) -> Option<&WireDictionaryValue<'de>> {
803        if self.is_some() { Some(unsafe { &*(self as *const Self).cast() }) } else { None }
804    }
805
806    pub fn into_option(self) -> Option<WireDictionaryValue<'de>> {
807        if self.is_some() {
808            Some(WireDictionaryValue { raw: self.raw, _phantom: ::core::marker::PhantomData })
809        } else {
810            None
811        }
812    }
813}
814
815unsafe impl<___D> ::fidl_next::Decode<___D> for WireOptionalDictionaryValue<'static>
816where
817    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
818    ___D: ::fidl_next::Decoder,
819{
820    fn decode(
821        mut slot: ::fidl_next::Slot<'_, Self>,
822        decoder: &mut ___D,
823    ) -> Result<(), ::fidl_next::DecodeError> {
824        ::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
825        match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
826            1 => ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireString<'static>>(
827                raw, decoder,
828            )?,
829
830            2 => ::fidl_next::RawWireUnion::decode_as::<
831                ___D,
832                ::fidl_next::WireVector<'static, ::fidl_next::WireString<'static>>,
833            >(raw, decoder)?,
834
835            3 => ::fidl_next::RawWireUnion::decode_as::<
836                ___D,
837                ::fidl_next::WireVector<'static, crate::WireDictionary<'static>>,
838            >(raw, decoder)?,
839
840            0 => ::fidl_next::RawWireUnion::decode_absent(raw)?,
841            _ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
842        }
843
844        Ok(())
845    }
846}
847
848impl<'de> ::core::fmt::Debug for WireOptionalDictionaryValue<'de> {
849    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
850        self.as_ref().fmt(f)
851    }
852}
853
854/// Compatibility shims which mimic some API surfaces of the current Rust bindings.
855pub mod compat {
856
857    impl ::fidl_next::CompatFrom<crate::DictionaryEntry> for ::fidl_fuchsia_data::DictionaryEntry {
858        #[inline]
859        fn compat_from(value: crate::DictionaryEntry) -> Self {
860            Self {
861                key: ::fidl_next::CompatFrom::compat_from(value.key),
862
863                value: ::fidl_next::CompatFrom::compat_from(value.value),
864            }
865        }
866    }
867
868    impl ::fidl_next::CompatFrom<::fidl_fuchsia_data::DictionaryEntry> for crate::DictionaryEntry {
869        #[inline]
870        fn compat_from(value: ::fidl_fuchsia_data::DictionaryEntry) -> Self {
871            Self {
872                key: ::fidl_next::CompatFrom::compat_from(value.key),
873
874                value: ::fidl_next::CompatFrom::compat_from(value.value),
875            }
876        }
877    }
878
879    impl ::fidl_next::CompatFrom<crate::Dictionary> for ::fidl_fuchsia_data::Dictionary {
880        fn compat_from(value: crate::Dictionary) -> Self {
881            Self {
882                entries: ::fidl_next::CompatFrom::compat_from(value.entries),
883
884                __source_breaking: ::fidl::marker::SourceBreaking,
885            }
886        }
887    }
888
889    impl ::fidl_next::CompatFrom<::fidl_fuchsia_data::Dictionary> for crate::Dictionary {
890        fn compat_from(value: ::fidl_fuchsia_data::Dictionary) -> Self {
891            Self { entries: ::fidl_next::CompatFrom::compat_from(value.entries) }
892        }
893    }
894
895    impl ::fidl_next::CompatFrom<crate::DictionaryValue> for ::fidl_fuchsia_data::DictionaryValue {
896        fn compat_from(value: crate::DictionaryValue) -> Self {
897            match value {
898                crate::DictionaryValue::Str(value) => {
899                    Self::Str(::fidl_next::CompatFrom::compat_from(value))
900                }
901
902                crate::DictionaryValue::StrVec(value) => {
903                    Self::StrVec(::fidl_next::CompatFrom::compat_from(value))
904                }
905
906                crate::DictionaryValue::ObjVec(value) => {
907                    Self::ObjVec(::fidl_next::CompatFrom::compat_from(value))
908                }
909
910                crate::DictionaryValue::UnknownOrdinal_(unknown_ordinal) => {
911                    Self::__SourceBreaking { unknown_ordinal }
912                }
913            }
914        }
915    }
916
917    impl ::fidl_next::CompatFrom<::fidl_fuchsia_data::DictionaryValue> for crate::DictionaryValue {
918        fn compat_from(value: ::fidl_fuchsia_data::DictionaryValue) -> Self {
919            match value {
920                ::fidl_fuchsia_data::DictionaryValue::Str(value) => {
921                    Self::Str(::fidl_next::CompatFrom::compat_from(value))
922                }
923
924                ::fidl_fuchsia_data::DictionaryValue::StrVec(value) => {
925                    Self::StrVec(::fidl_next::CompatFrom::compat_from(value))
926                }
927
928                ::fidl_fuchsia_data::DictionaryValue::ObjVec(value) => {
929                    Self::ObjVec(::fidl_next::CompatFrom::compat_from(value))
930                }
931
932                ::fidl_fuchsia_data::DictionaryValue::__SourceBreaking { unknown_ordinal } => {
933                    Self::UnknownOrdinal_(unknown_ordinal)
934                }
935            }
936        }
937    }
938}