Skip to main content

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