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(Debug)]
7pub struct Buffer {
8 pub vmo: ::fidl_next::fuchsia::zx::Handle,
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
21 ___E: ::fidl_next::fuchsia::HandleEncoder,
22{
23 #[inline]
24 fn encode(
25 self,
26 encoder: &mut ___E,
27 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
28 ) -> Result<(), ::fidl_next::EncodeError> {
29 ::fidl_next::munge! {
30 let Self::Encoded {
31 vmo,
32 size,
33
34 } = out;
35 }
36
37 ::fidl_next::Encode::encode(self.vmo, encoder, vmo)?;
38
39 ::fidl_next::Encode::encode(self.size, encoder, size)?;
40
41 Ok(())
42 }
43}
44
45impl ::fidl_next::EncodableOption for Buffer {
46 type EncodedOption = ::fidl_next::WireBox<'static, WireBuffer>;
47}
48
49unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Buffer
50where
51 ___E: ::fidl_next::Encoder + ?Sized,
52 Buffer: ::fidl_next::Encode<___E>,
53{
54 #[inline]
55 fn encode_option(
56 this: Option<Self>,
57 encoder: &mut ___E,
58 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
59 ) -> Result<(), ::fidl_next::EncodeError> {
60 if let Some(inner) = this {
61 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
62 ::fidl_next::WireBox::encode_present(out);
63 } else {
64 ::fidl_next::WireBox::encode_absent(out);
65 }
66
67 Ok(())
68 }
69}
70
71impl ::fidl_next::FromWire<WireBuffer> for Buffer {
72 #[inline]
73 fn from_wire(wire: WireBuffer) -> Self {
74 Self {
75 vmo: ::fidl_next::FromWire::from_wire(wire.vmo),
76
77 size: ::fidl_next::FromWire::from_wire(wire.size),
78 }
79 }
80}
81
82#[derive(Debug)]
84#[repr(C)]
85pub struct WireBuffer {
86 pub vmo: ::fidl_next::fuchsia::WireHandle,
87
88 pub size: ::fidl_next::WireU64,
89}
90
91unsafe impl ::fidl_next::Wire for WireBuffer {
92 type Decoded<'de> = WireBuffer;
93
94 #[inline]
95 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
96 unsafe {
97 out.as_mut_ptr().cast::<u8>().add(4).write_bytes(0, 4);
98 }
99 }
100}
101
102unsafe impl<___D> ::fidl_next::Decode<___D> for WireBuffer
103where
104 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
105
106 ___D: ::fidl_next::fuchsia::HandleDecoder,
107{
108 fn decode(
109 slot: ::fidl_next::Slot<'_, Self>,
110 decoder: &mut ___D,
111 ) -> Result<(), ::fidl_next::DecodeError> {
112 ::fidl_next::munge! {
113 let Self {
114 mut vmo,
115 mut size,
116
117 } = slot;
118 }
119
120 ::fidl_next::Decode::decode(vmo.as_mut(), decoder)?;
121
122 ::fidl_next::Decode::decode(size.as_mut(), decoder)?;
123
124 Ok(())
125 }
126}
127
128#[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"]
129#[derive(Debug)]
130pub enum Data {
131 Bytes(Vec<u8>),
132
133 Buffer(crate::Buffer),
134
135 UnknownOrdinal_(u64),
136}
137
138impl ::fidl_next::Encodable for Data {
139 type Encoded = WireData<'static>;
140}
141
142unsafe impl<___E> ::fidl_next::Encode<___E> for Data
143where
144 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
145
146 ___E: ::fidl_next::Encoder,
147
148 ___E: ::fidl_next::fuchsia::HandleEncoder,
149{
150 #[inline]
151 fn encode(
152 self,
153 encoder: &mut ___E,
154 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
155 ) -> Result<(), ::fidl_next::EncodeError> {
156 ::fidl_next::munge!(let WireData { raw, _phantom: _ } = out);
157
158 match self {
159 Self::Bytes(value) => {
160 ::fidl_next::RawWireUnion::encode_as::<___E, Vec<u8>>(value, 1, encoder, raw)?
161 }
162
163 Self::Buffer(value) => {
164 ::fidl_next::RawWireUnion::encode_as::<___E, crate::Buffer>(value, 2, encoder, raw)?
165 }
166
167 Self::UnknownOrdinal_(ordinal) => {
168 return Err(::fidl_next::EncodeError::UnknownUnionOrdinal(ordinal as usize))
169 }
170 }
171
172 Ok(())
173 }
174}
175
176impl ::fidl_next::EncodableOption for Data {
177 type EncodedOption = WireOptionalData<'static>;
178}
179
180unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Data
181where
182 ___E: ?Sized,
183 Data: ::fidl_next::Encode<___E>,
184{
185 #[inline]
186 fn encode_option(
187 this: Option<Self>,
188 encoder: &mut ___E,
189 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
190 ) -> Result<(), ::fidl_next::EncodeError> {
191 ::fidl_next::munge!(let WireOptionalData { raw, _phantom: _ } = &mut *out);
192
193 if let Some(inner) = this {
194 let value_out = unsafe { &mut *out.as_mut_ptr().cast() };
195 ::fidl_next::Encode::encode(inner, encoder, value_out)?;
196 } else {
197 ::fidl_next::RawWireUnion::encode_absent(raw);
198 }
199
200 Ok(())
201 }
202}
203
204impl<'de> ::fidl_next::FromWire<WireData<'de>> for Data {
205 #[inline]
206 fn from_wire(wire: WireData<'de>) -> Self {
207 let wire = ::core::mem::ManuallyDrop::new(wire);
208 match wire.raw.ordinal() {
209 1 => Self::Bytes(::fidl_next::FromWire::from_wire(unsafe {
210 wire.raw.get().read_unchecked::<::fidl_next::WireVector<'de, u8>>()
211 })),
212
213 2 => Self::Buffer(::fidl_next::FromWire::from_wire(unsafe {
214 wire.raw.get().read_unchecked::<crate::WireBuffer>()
215 })),
216
217 _ => unsafe { ::core::hint::unreachable_unchecked() },
218 }
219 }
220}
221
222impl<'de> ::fidl_next::FromWireOption<WireOptionalData<'de>> for Box<Data> {
223 #[inline]
224 fn from_wire_option(wire: WireOptionalData<'de>) -> Option<Self> {
225 if let Some(inner) = wire.into_option() {
226 Some(Box::new(::fidl_next::FromWire::from_wire(inner)))
227 } else {
228 None
229 }
230 }
231}
232
233#[repr(transparent)]
235pub struct WireData<'de> {
236 raw: ::fidl_next::RawWireUnion,
237 _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
238}
239
240impl<'de> Drop for WireData<'de> {
241 fn drop(&mut self) {
242 match self.raw.ordinal() {
243 1 => {
244 let _ =
245 unsafe { self.raw.get().read_unchecked::<::fidl_next::WireVector<'de, u8>>() };
246 }
247
248 2 => {
249 let _ = unsafe { self.raw.get().read_unchecked::<crate::WireBuffer>() };
250 }
251
252 _ => (),
253 }
254 }
255}
256
257unsafe impl ::fidl_next::Wire for WireData<'static> {
258 type Decoded<'de> = WireData<'de>;
259
260 #[inline]
261 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
262 ::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
263 ::fidl_next::RawWireUnion::zero_padding(raw);
264 }
265}
266
267pub mod data {
268 pub enum Ref<'de> {
269 Bytes(&'de ::fidl_next::WireVector<'de, u8>),
270
271 Buffer(&'de crate::WireBuffer),
272
273 UnknownOrdinal_(u64),
274 }
275}
276
277impl<'de> WireData<'de> {
278 pub fn as_ref(&self) -> crate::data::Ref<'_> {
279 match self.raw.ordinal() {
280 1 => crate::data::Ref::Bytes(unsafe {
281 self.raw.get().deref_unchecked::<::fidl_next::WireVector<'_, u8>>()
282 }),
283
284 2 => crate::data::Ref::Buffer(unsafe {
285 self.raw.get().deref_unchecked::<crate::WireBuffer>()
286 }),
287
288 unknown => crate::data::Ref::UnknownOrdinal_(unknown),
289 }
290 }
291}
292
293unsafe impl<___D> ::fidl_next::Decode<___D> for WireData<'static>
294where
295 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
296
297 ___D: ::fidl_next::Decoder,
298
299 ___D: ::fidl_next::fuchsia::HandleDecoder,
300{
301 fn decode(
302 mut slot: ::fidl_next::Slot<'_, Self>,
303 decoder: &mut ___D,
304 ) -> Result<(), ::fidl_next::DecodeError> {
305 ::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
306 match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
307 1 => {
308 ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireVector<'static, u8>>(
309 raw, decoder,
310 )?
311 }
312
313 2 => ::fidl_next::RawWireUnion::decode_as::<___D, crate::WireBuffer>(raw, decoder)?,
314
315 _ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
316 }
317
318 Ok(())
319 }
320}
321
322impl<'de> ::core::fmt::Debug for WireData<'de> {
323 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
324 match self.raw.ordinal() {
325 1 => unsafe {
326 self.raw.get().deref_unchecked::<::fidl_next::WireVector<'_, u8>>().fmt(f)
327 },
328 2 => unsafe { self.raw.get().deref_unchecked::<crate::WireBuffer>().fmt(f) },
329 _ => unsafe { ::core::hint::unreachable_unchecked() },
330 }
331 }
332}
333
334#[repr(transparent)]
335pub struct WireOptionalData<'de> {
336 raw: ::fidl_next::RawWireUnion,
337 _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
338}
339
340unsafe impl ::fidl_next::Wire for WireOptionalData<'static> {
341 type Decoded<'de> = WireOptionalData<'de>;
342
343 #[inline]
344 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
345 ::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
346 ::fidl_next::RawWireUnion::zero_padding(raw);
347 }
348}
349
350impl<'de> WireOptionalData<'de> {
351 pub fn is_some(&self) -> bool {
352 self.raw.is_some()
353 }
354
355 pub fn is_none(&self) -> bool {
356 self.raw.is_none()
357 }
358
359 pub fn as_ref(&self) -> Option<&WireData<'de>> {
360 if self.is_some() {
361 Some(unsafe { &*(self as *const Self).cast() })
362 } else {
363 None
364 }
365 }
366
367 pub fn into_option(self) -> Option<WireData<'de>> {
368 if self.is_some() {
369 Some(WireData { raw: self.raw, _phantom: ::core::marker::PhantomData })
370 } else {
371 None
372 }
373 }
374}
375
376unsafe impl<___D> ::fidl_next::Decode<___D> for WireOptionalData<'static>
377where
378 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
379
380 ___D: ::fidl_next::Decoder,
381
382 ___D: ::fidl_next::fuchsia::HandleDecoder,
383{
384 fn decode(
385 mut slot: ::fidl_next::Slot<'_, Self>,
386 decoder: &mut ___D,
387 ) -> Result<(), ::fidl_next::DecodeError> {
388 ::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
389 match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
390 1 => {
391 ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireVector<'static, u8>>(
392 raw, decoder,
393 )?
394 }
395
396 2 => ::fidl_next::RawWireUnion::decode_as::<___D, crate::WireBuffer>(raw, decoder)?,
397
398 0 => ::fidl_next::RawWireUnion::decode_absent(raw)?,
399 _ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
400 }
401
402 Ok(())
403 }
404}
405
406impl<'de> ::core::fmt::Debug for WireOptionalData<'de> {
407 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
408 self.as_ref().fmt(f)
409 }
410}
411
412#[doc = " A range of bytes within a VMO.\n"]
413#[derive(Debug)]
414pub struct Range {
415 pub vmo: ::fidl_next::fuchsia::zx::Handle,
416
417 pub offset: u64,
418
419 pub size: u64,
420}
421
422impl ::fidl_next::Encodable for Range {
423 type Encoded = WireRange;
424}
425
426unsafe impl<___E> ::fidl_next::Encode<___E> for Range
427where
428 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
429
430 ___E: ::fidl_next::fuchsia::HandleEncoder,
431{
432 #[inline]
433 fn encode(
434 self,
435 encoder: &mut ___E,
436 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
437 ) -> Result<(), ::fidl_next::EncodeError> {
438 ::fidl_next::munge! {
439 let Self::Encoded {
440 vmo,
441 offset,
442 size,
443
444 } = out;
445 }
446
447 ::fidl_next::Encode::encode(self.vmo, encoder, vmo)?;
448
449 ::fidl_next::Encode::encode(self.offset, encoder, offset)?;
450
451 ::fidl_next::Encode::encode(self.size, encoder, size)?;
452
453 Ok(())
454 }
455}
456
457impl ::fidl_next::EncodableOption for Range {
458 type EncodedOption = ::fidl_next::WireBox<'static, WireRange>;
459}
460
461unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Range
462where
463 ___E: ::fidl_next::Encoder + ?Sized,
464 Range: ::fidl_next::Encode<___E>,
465{
466 #[inline]
467 fn encode_option(
468 this: Option<Self>,
469 encoder: &mut ___E,
470 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
471 ) -> Result<(), ::fidl_next::EncodeError> {
472 if let Some(inner) = this {
473 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
474 ::fidl_next::WireBox::encode_present(out);
475 } else {
476 ::fidl_next::WireBox::encode_absent(out);
477 }
478
479 Ok(())
480 }
481}
482
483impl ::fidl_next::FromWire<WireRange> for Range {
484 #[inline]
485 fn from_wire(wire: WireRange) -> Self {
486 Self {
487 vmo: ::fidl_next::FromWire::from_wire(wire.vmo),
488
489 offset: ::fidl_next::FromWire::from_wire(wire.offset),
490
491 size: ::fidl_next::FromWire::from_wire(wire.size),
492 }
493 }
494}
495
496#[derive(Debug)]
498#[repr(C)]
499pub struct WireRange {
500 pub vmo: ::fidl_next::fuchsia::WireHandle,
501
502 pub offset: ::fidl_next::WireU64,
503
504 pub size: ::fidl_next::WireU64,
505}
506
507unsafe impl ::fidl_next::Wire for WireRange {
508 type Decoded<'de> = WireRange;
509
510 #[inline]
511 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
512 unsafe {
513 out.as_mut_ptr().cast::<u8>().add(4).write_bytes(0, 4);
514 }
515 }
516}
517
518unsafe impl<___D> ::fidl_next::Decode<___D> for WireRange
519where
520 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
521
522 ___D: ::fidl_next::fuchsia::HandleDecoder,
523{
524 fn decode(
525 slot: ::fidl_next::Slot<'_, Self>,
526 decoder: &mut ___D,
527 ) -> Result<(), ::fidl_next::DecodeError> {
528 ::fidl_next::munge! {
529 let Self {
530 mut vmo,
531 mut offset,
532 mut size,
533
534 } = slot;
535 }
536
537 ::fidl_next::Decode::decode(vmo.as_mut(), decoder)?;
538
539 ::fidl_next::Decode::decode(offset.as_mut(), decoder)?;
540
541 ::fidl_next::Decode::decode(size.as_mut(), decoder)?;
542
543 Ok(())
544 }
545}
546
547pub mod compat {}