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