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