1#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5#[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"]
6#[derive(PartialEq, Debug)]
7pub struct Buffer {
8 pub vmo: ::fidl_next::fuchsia::zx::Vmo,
9
10 pub size: u64,
11}
12
13impl ::fidl_next::Encodable for Buffer {
14 type Encoded = WireBuffer;
15}
16
17unsafe impl<___E> ::fidl_next::Encode<___E> for Buffer
18where
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<Self::Encoded>,
27 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
28 ::fidl_next::munge! {
29 let Self::Encoded {
30 vmo,
31 size,
32
33 } = out_;
34 }
35
36 ::fidl_next::Encode::encode(self.vmo, encoder_, vmo)?;
37
38 ::fidl_next::Encode::encode(self.size, encoder_, size)?;
39
40 Ok(())
41 }
42}
43
44impl ::fidl_next::EncodableOption for Buffer {
45 type EncodedOption = ::fidl_next::WireBox<'static, WireBuffer>;
46}
47
48unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Buffer
49where
50 ___E: ::fidl_next::Encoder + ?Sized,
51 Buffer: ::fidl_next::Encode<___E>,
52{
53 #[inline]
54 fn encode_option(
55 this: ::core::option::Option<Self>,
56 encoder: &mut ___E,
57 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
58 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
59 if let Some(inner) = this {
60 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
61 ::fidl_next::WireBox::encode_present(out);
62 } else {
63 ::fidl_next::WireBox::encode_absent(out);
64 }
65
66 Ok(())
67 }
68}
69
70impl ::fidl_next::FromWire<WireBuffer> for Buffer {
71 #[inline]
72 fn from_wire(wire: WireBuffer) -> Self {
73 Self {
74 vmo: ::fidl_next::FromWire::from_wire(wire.vmo),
75
76 size: ::fidl_next::FromWire::from_wire(wire.size),
77 }
78 }
79}
80
81impl ::fidl_next::IntoNatural for WireBuffer {
82 type Natural = Buffer;
83}
84
85#[derive(Debug)]
87#[repr(C)]
88pub struct WireBuffer {
89 pub vmo: ::fidl_next::fuchsia::WireVmo,
90
91 pub size: ::fidl_next::WireU64,
92}
93static_assertions::const_assert_eq!(std::mem::size_of::<WireBuffer>(), 16);
94static_assertions::const_assert_eq!(std::mem::align_of::<WireBuffer>(), 8);
95
96static_assertions::const_assert_eq!(std::mem::offset_of!(WireBuffer, vmo), 0);
97
98static_assertions::const_assert_eq!(std::mem::offset_of!(WireBuffer, size), 8);
99
100unsafe impl ::fidl_next::Wire for WireBuffer {
101 type Decoded<'de> = WireBuffer;
102
103 #[inline]
104 fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
105 ::fidl_next::munge! {
106 let Self {
107
108 vmo,
109 size,
110
111 } = &mut *out_;
112 }
113
114 ::fidl_next::Wire::zero_padding(vmo);
115
116 ::fidl_next::Wire::zero_padding(size);
117
118 unsafe {
119 out_.as_mut_ptr().cast::<u8>().add(4).write_bytes(0, 4);
120 }
121 }
122}
123
124unsafe impl<___D> ::fidl_next::Decode<___D> for WireBuffer
125where
126 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
127 ___D: ::fidl_next::fuchsia::HandleDecoder,
128{
129 fn decode(
130 slot_: ::fidl_next::Slot<'_, Self>,
131 decoder_: &mut ___D,
132 ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
133 ::fidl_next::munge! {
134 let Self {
135
136 mut vmo,
137 mut size,
138
139 } = slot_;
140 }
141
142 ::fidl_next::Decode::decode(vmo.as_mut(), decoder_)?;
143
144 ::fidl_next::Decode::decode(size.as_mut(), decoder_)?;
145
146 Ok(())
147 }
148}
149
150#[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"]
151#[derive(PartialEq, Debug)]
152pub enum Data {
153 Bytes(::std::vec::Vec<u8>),
154
155 Buffer(crate::Buffer),
156
157 UnknownOrdinal_(u64),
158}
159
160impl ::fidl_next::Encodable for Data {
161 type Encoded = WireData<'static>;
162}
163
164unsafe impl<___E> ::fidl_next::Encode<___E> for Data
165where
166 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
167 ___E: ::fidl_next::Encoder,
168 ___E: ::fidl_next::fuchsia::HandleEncoder,
169{
170 #[inline]
171 fn encode(
172 self,
173 encoder: &mut ___E,
174 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
175 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
176 ::fidl_next::munge!(let WireData { raw, _phantom: _ } = out);
177
178 match self {
179 Self::Bytes(value) => {
180 ::fidl_next::RawWireUnion::encode_as::<___E, ::std::vec::Vec<u8>>(
181 value, 1, encoder, raw,
182 )?
183 }
184
185 Self::Buffer(value) => {
186 ::fidl_next::RawWireUnion::encode_as::<___E, crate::Buffer>(value, 2, encoder, raw)?
187 }
188
189 Self::UnknownOrdinal_(ordinal) => {
190 return Err(::fidl_next::EncodeError::UnknownUnionOrdinal(ordinal as usize));
191 }
192 }
193
194 Ok(())
195 }
196}
197
198impl ::fidl_next::EncodableOption for Data {
199 type EncodedOption = WireOptionalData<'static>;
200}
201
202unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Data
203where
204 ___E: ?Sized,
205 Data: ::fidl_next::Encode<___E>,
206{
207 #[inline]
208 fn encode_option(
209 this: ::core::option::Option<Self>,
210 encoder: &mut ___E,
211 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
212 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
213 ::fidl_next::munge!(let WireOptionalData { raw, _phantom: _ } = &mut *out);
214
215 if let Some(inner) = this {
216 let value_out = unsafe { &mut *out.as_mut_ptr().cast() };
217 ::fidl_next::Encode::encode(inner, encoder, value_out)?;
218 } else {
219 ::fidl_next::RawWireUnion::encode_absent(raw);
220 }
221
222 Ok(())
223 }
224}
225
226impl<'de> ::fidl_next::FromWire<WireData<'de>> for Data {
227 #[inline]
228 fn from_wire(wire: WireData<'de>) -> Self {
229 let wire = ::core::mem::ManuallyDrop::new(wire);
230 match wire.raw.ordinal() {
231 1 => Self::Bytes(::fidl_next::FromWire::from_wire(unsafe {
232 wire.raw.get().read_unchecked::<::fidl_next::WireVector<'de, u8>>()
233 })),
234
235 2 => Self::Buffer(::fidl_next::FromWire::from_wire(unsafe {
236 wire.raw.get().read_unchecked::<crate::WireBuffer>()
237 })),
238
239 _ => unsafe { ::core::hint::unreachable_unchecked() },
240 }
241 }
242}
243
244impl<'de> ::fidl_next::IntoNatural for WireData<'de> {
245 type Natural = Data;
246}
247
248impl<'de> ::fidl_next::FromWireOption<WireOptionalData<'de>> for Data {
249 #[inline]
250 fn from_wire_option(wire: WireOptionalData<'de>) -> ::core::option::Option<Self> {
251 if let Some(inner) = wire.into_option() {
252 Some(::fidl_next::FromWire::from_wire(inner))
253 } else {
254 None
255 }
256 }
257}
258
259impl<'de> ::fidl_next::IntoNatural for WireOptionalData<'de> {
260 type Natural = ::core::option::Option<Data>;
261}
262
263impl<'de> ::fidl_next::FromWireOption<WireOptionalData<'de>> for Box<Data> {
264 #[inline]
265 fn from_wire_option(wire: WireOptionalData<'de>) -> ::core::option::Option<Self> {
266 <Data as ::fidl_next::FromWireOption<WireOptionalData<'de>>>::from_wire_option(wire)
267 .map(Box::new)
268 }
269}
270
271#[repr(transparent)]
273pub struct WireData<'de> {
274 raw: ::fidl_next::RawWireUnion,
275 _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
276}
277
278impl<'de> Drop for WireData<'de> {
279 fn drop(&mut self) {
280 match self.raw.ordinal() {
281 1 => {
282 let _ =
283 unsafe { self.raw.get().read_unchecked::<::fidl_next::WireVector<'de, u8>>() };
284 }
285
286 2 => {
287 let _ = unsafe { self.raw.get().read_unchecked::<crate::WireBuffer>() };
288 }
289
290 _ => (),
291 }
292 }
293}
294
295unsafe impl ::fidl_next::Wire for WireData<'static> {
296 type Decoded<'de> = WireData<'de>;
297
298 #[inline]
299 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
300 ::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
301 ::fidl_next::RawWireUnion::zero_padding(raw);
302 }
303}
304
305pub mod data {
306 pub enum Ref<'de> {
307 Bytes(&'de ::fidl_next::WireVector<'de, u8>),
308
309 Buffer(&'de crate::WireBuffer),
310
311 UnknownOrdinal_(u64),
312 }
313}
314
315impl<'de> WireData<'de> {
316 pub fn as_ref(&self) -> crate::data::Ref<'_> {
317 match self.raw.ordinal() {
318 1 => crate::data::Ref::Bytes(unsafe {
319 self.raw.get().deref_unchecked::<::fidl_next::WireVector<'_, u8>>()
320 }),
321
322 2 => crate::data::Ref::Buffer(unsafe {
323 self.raw.get().deref_unchecked::<crate::WireBuffer>()
324 }),
325
326 unknown => crate::data::Ref::UnknownOrdinal_(unknown),
327 }
328 }
329}
330
331unsafe impl<___D> ::fidl_next::Decode<___D> for WireData<'static>
332where
333 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
334 ___D: ::fidl_next::Decoder,
335 ___D: ::fidl_next::fuchsia::HandleDecoder,
336{
337 fn decode(
338 mut slot: ::fidl_next::Slot<'_, Self>,
339 decoder: &mut ___D,
340 ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
341 ::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
342 match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
343 1 => {
344 ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireVector<'static, u8>>(
345 raw, decoder,
346 )?
347 }
348
349 2 => ::fidl_next::RawWireUnion::decode_as::<___D, crate::WireBuffer>(raw, decoder)?,
350
351 _ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
352 }
353
354 Ok(())
355 }
356}
357
358impl<'de> ::core::fmt::Debug for WireData<'de> {
359 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
360 match self.raw.ordinal() {
361 1 => unsafe {
362 self.raw.get().deref_unchecked::<::fidl_next::WireVector<'_, u8>>().fmt(f)
363 },
364 2 => unsafe { self.raw.get().deref_unchecked::<crate::WireBuffer>().fmt(f) },
365 _ => unsafe { ::core::hint::unreachable_unchecked() },
366 }
367 }
368}
369
370#[repr(transparent)]
371pub struct WireOptionalData<'de> {
372 raw: ::fidl_next::RawWireUnion,
373 _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
374}
375
376unsafe impl ::fidl_next::Wire for WireOptionalData<'static> {
377 type Decoded<'de> = WireOptionalData<'de>;
378
379 #[inline]
380 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
381 ::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
382 ::fidl_next::RawWireUnion::zero_padding(raw);
383 }
384}
385
386impl<'de> WireOptionalData<'de> {
387 pub fn is_some(&self) -> bool {
388 self.raw.is_some()
389 }
390
391 pub fn is_none(&self) -> bool {
392 self.raw.is_none()
393 }
394
395 pub fn as_ref(&self) -> ::core::option::Option<&WireData<'de>> {
396 if self.is_some() { Some(unsafe { &*(self as *const Self).cast() }) } else { None }
397 }
398
399 pub fn into_option(self) -> ::core::option::Option<WireData<'de>> {
400 if self.is_some() {
401 Some(WireData { raw: self.raw, _phantom: ::core::marker::PhantomData })
402 } else {
403 None
404 }
405 }
406}
407
408unsafe impl<___D> ::fidl_next::Decode<___D> for WireOptionalData<'static>
409where
410 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
411 ___D: ::fidl_next::Decoder,
412 ___D: ::fidl_next::fuchsia::HandleDecoder,
413{
414 fn decode(
415 mut slot: ::fidl_next::Slot<'_, Self>,
416 decoder: &mut ___D,
417 ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
418 ::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
419 match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
420 1 => {
421 ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireVector<'static, u8>>(
422 raw, decoder,
423 )?
424 }
425
426 2 => ::fidl_next::RawWireUnion::decode_as::<___D, crate::WireBuffer>(raw, decoder)?,
427
428 0 => ::fidl_next::RawWireUnion::decode_absent(raw)?,
429 _ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
430 }
431
432 Ok(())
433 }
434}
435
436impl<'de> ::core::fmt::Debug for WireOptionalData<'de> {
437 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
438 self.as_ref().fmt(f)
439 }
440}
441
442#[doc = " A range of bytes within a VMO.\n"]
443#[derive(PartialEq, Debug)]
444pub struct Range {
445 pub vmo: ::fidl_next::fuchsia::zx::Vmo,
446
447 pub offset: u64,
448
449 pub size: u64,
450}
451
452impl ::fidl_next::Encodable for Range {
453 type Encoded = WireRange;
454}
455
456unsafe impl<___E> ::fidl_next::Encode<___E> for Range
457where
458 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
459 ___E: ::fidl_next::fuchsia::HandleEncoder,
460{
461 #[inline]
462 fn encode(
463 self,
464 encoder_: &mut ___E,
465 out_: &mut ::core::mem::MaybeUninit<Self::Encoded>,
466 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
467 ::fidl_next::munge! {
468 let Self::Encoded {
469 vmo,
470 offset,
471 size,
472
473 } = out_;
474 }
475
476 ::fidl_next::Encode::encode(self.vmo, encoder_, vmo)?;
477
478 ::fidl_next::Encode::encode(self.offset, encoder_, offset)?;
479
480 ::fidl_next::Encode::encode(self.size, encoder_, size)?;
481
482 Ok(())
483 }
484}
485
486impl ::fidl_next::EncodableOption for Range {
487 type EncodedOption = ::fidl_next::WireBox<'static, WireRange>;
488}
489
490unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Range
491where
492 ___E: ::fidl_next::Encoder + ?Sized,
493 Range: ::fidl_next::Encode<___E>,
494{
495 #[inline]
496 fn encode_option(
497 this: ::core::option::Option<Self>,
498 encoder: &mut ___E,
499 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
500 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
501 if let Some(inner) = this {
502 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
503 ::fidl_next::WireBox::encode_present(out);
504 } else {
505 ::fidl_next::WireBox::encode_absent(out);
506 }
507
508 Ok(())
509 }
510}
511
512impl ::fidl_next::FromWire<WireRange> for Range {
513 #[inline]
514 fn from_wire(wire: WireRange) -> Self {
515 Self {
516 vmo: ::fidl_next::FromWire::from_wire(wire.vmo),
517
518 offset: ::fidl_next::FromWire::from_wire(wire.offset),
519
520 size: ::fidl_next::FromWire::from_wire(wire.size),
521 }
522 }
523}
524
525impl ::fidl_next::IntoNatural for WireRange {
526 type Natural = Range;
527}
528
529#[derive(Debug)]
531#[repr(C)]
532pub struct WireRange {
533 pub vmo: ::fidl_next::fuchsia::WireVmo,
534
535 pub offset: ::fidl_next::WireU64,
536
537 pub size: ::fidl_next::WireU64,
538}
539static_assertions::const_assert_eq!(std::mem::size_of::<WireRange>(), 24);
540static_assertions::const_assert_eq!(std::mem::align_of::<WireRange>(), 8);
541
542static_assertions::const_assert_eq!(std::mem::offset_of!(WireRange, vmo), 0);
543
544static_assertions::const_assert_eq!(std::mem::offset_of!(WireRange, offset), 8);
545
546static_assertions::const_assert_eq!(std::mem::offset_of!(WireRange, size), 16);
547
548unsafe impl ::fidl_next::Wire for WireRange {
549 type Decoded<'de> = WireRange;
550
551 #[inline]
552 fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
553 ::fidl_next::munge! {
554 let Self {
555
556 vmo,
557 offset,
558 size,
559
560 } = &mut *out_;
561 }
562
563 ::fidl_next::Wire::zero_padding(vmo);
564
565 ::fidl_next::Wire::zero_padding(offset);
566
567 ::fidl_next::Wire::zero_padding(size);
568
569 unsafe {
570 out_.as_mut_ptr().cast::<u8>().add(4).write_bytes(0, 4);
571 }
572 }
573}
574
575unsafe impl<___D> ::fidl_next::Decode<___D> for WireRange
576where
577 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
578 ___D: ::fidl_next::fuchsia::HandleDecoder,
579{
580 fn decode(
581 slot_: ::fidl_next::Slot<'_, Self>,
582 decoder_: &mut ___D,
583 ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
584 ::fidl_next::munge! {
585 let Self {
586
587 mut vmo,
588 mut offset,
589 mut size,
590
591 } = slot_;
592 }
593
594 ::fidl_next::Decode::decode(vmo.as_mut(), decoder_)?;
595
596 ::fidl_next::Decode::decode(offset.as_mut(), decoder_)?;
597
598 ::fidl_next::Decode::decode(size.as_mut(), decoder_)?;
599
600 Ok(())
601 }
602}
603
604pub mod compat {
606
607 impl ::fidl_next::CompatFrom<crate::Buffer> for ::fidl_fuchsia_mem::Buffer {
608 #[inline]
609 fn compat_from(value: crate::Buffer) -> Self {
610 Self {
611 vmo: ::fidl_next::CompatFrom::compat_from(value.vmo),
612
613 size: ::fidl_next::CompatFrom::compat_from(value.size),
614 }
615 }
616 }
617
618 impl ::fidl_next::CompatFrom<::fidl_fuchsia_mem::Buffer> for crate::Buffer {
619 #[inline]
620 fn compat_from(value: ::fidl_fuchsia_mem::Buffer) -> Self {
621 Self {
622 vmo: ::fidl_next::CompatFrom::compat_from(value.vmo),
623
624 size: ::fidl_next::CompatFrom::compat_from(value.size),
625 }
626 }
627 }
628
629 impl ::fidl_next::CompatFrom<crate::Data> for ::fidl_fuchsia_mem::Data {
630 fn compat_from(value: crate::Data) -> Self {
631 match value {
632 crate::Data::Bytes(value) => {
633 Self::Bytes(::fidl_next::CompatFrom::compat_from(value))
634 }
635
636 crate::Data::Buffer(value) => {
637 Self::Buffer(::fidl_next::CompatFrom::compat_from(value))
638 }
639
640 crate::Data::UnknownOrdinal_(unknown_ordinal) => {
641 Self::__SourceBreaking { unknown_ordinal }
642 }
643 }
644 }
645 }
646
647 impl ::fidl_next::CompatFrom<::fidl_fuchsia_mem::Data> for crate::Data {
648 fn compat_from(value: ::fidl_fuchsia_mem::Data) -> Self {
649 match value {
650 ::fidl_fuchsia_mem::Data::Bytes(value) => {
651 Self::Bytes(::fidl_next::CompatFrom::compat_from(value))
652 }
653
654 ::fidl_fuchsia_mem::Data::Buffer(value) => {
655 Self::Buffer(::fidl_next::CompatFrom::compat_from(value))
656 }
657
658 ::fidl_fuchsia_mem::Data::__SourceBreaking { unknown_ordinal } => {
659 Self::UnknownOrdinal_(unknown_ordinal)
660 }
661 }
662 }
663 }
664
665 impl ::fidl_next::CompatFrom<crate::Range> for ::fidl_fuchsia_mem::Range {
666 #[inline]
667 fn compat_from(value: crate::Range) -> Self {
668 Self {
669 vmo: ::fidl_next::CompatFrom::compat_from(value.vmo),
670
671 offset: ::fidl_next::CompatFrom::compat_from(value.offset),
672
673 size: ::fidl_next::CompatFrom::compat_from(value.size),
674 }
675 }
676 }
677
678 impl ::fidl_next::CompatFrom<::fidl_fuchsia_mem::Range> for crate::Range {
679 #[inline]
680 fn compat_from(value: ::fidl_fuchsia_mem::Range) -> Self {
681 Self {
682 vmo: ::fidl_next::CompatFrom::compat_from(value.vmo),
683
684 offset: ::fidl_next::CompatFrom::compat_from(value.offset),
685
686 size: ::fidl_next::CompatFrom::compat_from(value.size),
687 }
688 }
689 }
690}