1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_mem__common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20pub struct Buffer {
21 pub vmo: fdomain_client::Vmo,
23 pub size: u64,
31}
32
33impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for Buffer {}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct Range {
38 pub vmo: fdomain_client::Vmo,
40 pub offset: u64,
46 pub size: u64,
54}
55
56impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for Range {}
57
58#[derive(Debug)]
65pub enum Data {
66 Bytes(Vec<u8>),
68 Buffer(Buffer),
70 #[doc(hidden)]
71 __SourceBreaking { unknown_ordinal: u64 },
72}
73
74#[macro_export]
76macro_rules! DataUnknown {
77 () => {
78 _
79 };
80}
81
82impl PartialEq for Data {
84 fn eq(&self, other: &Self) -> bool {
85 match (self, other) {
86 (Self::Bytes(x), Self::Bytes(y)) => *x == *y,
87 (Self::Buffer(x), Self::Buffer(y)) => *x == *y,
88 _ => false,
89 }
90 }
91}
92
93impl Data {
94 #[inline]
95 pub fn ordinal(&self) -> u64 {
96 match *self {
97 Self::Bytes(_) => 1,
98 Self::Buffer(_) => 2,
99 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
100 }
101 }
102
103 #[inline]
104 pub fn unknown_variant_for_testing() -> Self {
105 Self::__SourceBreaking { unknown_ordinal: 0 }
106 }
107
108 #[inline]
109 pub fn is_unknown(&self) -> bool {
110 match self {
111 Self::__SourceBreaking { .. } => true,
112 _ => false,
113 }
114 }
115}
116
117impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for Data {}
118
119mod internal {
120 use super::*;
121
122 impl fidl::encoding::ResourceTypeMarker for Buffer {
123 type Borrowed<'a> = &'a mut Self;
124 fn take_or_borrow<'a>(
125 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
126 ) -> Self::Borrowed<'a> {
127 value
128 }
129 }
130
131 unsafe impl fidl::encoding::TypeMarker for Buffer {
132 type Owned = Self;
133
134 #[inline(always)]
135 fn inline_align(_context: fidl::encoding::Context) -> usize {
136 8
137 }
138
139 #[inline(always)]
140 fn inline_size(_context: fidl::encoding::Context) -> usize {
141 16
142 }
143 }
144
145 unsafe impl fidl::encoding::Encode<Buffer, fdomain_client::fidl::FDomainResourceDialect>
146 for &mut Buffer
147 {
148 #[inline]
149 unsafe fn encode(
150 self,
151 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
152 offset: usize,
153 _depth: fidl::encoding::Depth,
154 ) -> fidl::Result<()> {
155 encoder.debug_check_bounds::<Buffer>(offset);
156 fidl::encoding::Encode::<Buffer, fdomain_client::fidl::FDomainResourceDialect>::encode(
158 (
159 <fidl::encoding::HandleType<
160 fdomain_client::Vmo,
161 { fidl::ObjectType::VMO.into_raw() },
162 2147483648,
163 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
164 &mut self.vmo
165 ),
166 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.size),
167 ),
168 encoder,
169 offset,
170 _depth,
171 )
172 }
173 }
174 unsafe impl<
175 T0: fidl::encoding::Encode<
176 fidl::encoding::HandleType<
177 fdomain_client::Vmo,
178 { fidl::ObjectType::VMO.into_raw() },
179 2147483648,
180 >,
181 fdomain_client::fidl::FDomainResourceDialect,
182 >,
183 T1: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
184 > fidl::encoding::Encode<Buffer, fdomain_client::fidl::FDomainResourceDialect> for (T0, T1)
185 {
186 #[inline]
187 unsafe fn encode(
188 self,
189 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
190 offset: usize,
191 depth: fidl::encoding::Depth,
192 ) -> fidl::Result<()> {
193 encoder.debug_check_bounds::<Buffer>(offset);
194 unsafe {
197 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
198 (ptr as *mut u64).write_unaligned(0);
199 }
200 self.0.encode(encoder, offset + 0, depth)?;
202 self.1.encode(encoder, offset + 8, depth)?;
203 Ok(())
204 }
205 }
206
207 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for Buffer {
208 #[inline(always)]
209 fn new_empty() -> Self {
210 Self {
211 vmo: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
212 size: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
213 }
214 }
215
216 #[inline]
217 unsafe fn decode(
218 &mut self,
219 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
220 offset: usize,
221 _depth: fidl::encoding::Depth,
222 ) -> fidl::Result<()> {
223 decoder.debug_check_bounds::<Self>(offset);
224 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
226 let padval = unsafe { (ptr as *const u64).read_unaligned() };
227 let mask = 0xffffffff00000000u64;
228 let maskedval = padval & mask;
229 if maskedval != 0 {
230 return Err(fidl::Error::NonZeroPadding {
231 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
232 });
233 }
234 fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
235 fidl::decode!(
236 u64,
237 fdomain_client::fidl::FDomainResourceDialect,
238 &mut self.size,
239 decoder,
240 offset + 8,
241 _depth
242 )?;
243 Ok(())
244 }
245 }
246
247 impl fidl::encoding::ResourceTypeMarker for Range {
248 type Borrowed<'a> = &'a mut Self;
249 fn take_or_borrow<'a>(
250 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
251 ) -> Self::Borrowed<'a> {
252 value
253 }
254 }
255
256 unsafe impl fidl::encoding::TypeMarker for Range {
257 type Owned = Self;
258
259 #[inline(always)]
260 fn inline_align(_context: fidl::encoding::Context) -> usize {
261 8
262 }
263
264 #[inline(always)]
265 fn inline_size(_context: fidl::encoding::Context) -> usize {
266 24
267 }
268 }
269
270 unsafe impl fidl::encoding::Encode<Range, fdomain_client::fidl::FDomainResourceDialect>
271 for &mut Range
272 {
273 #[inline]
274 unsafe fn encode(
275 self,
276 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
277 offset: usize,
278 _depth: fidl::encoding::Depth,
279 ) -> fidl::Result<()> {
280 encoder.debug_check_bounds::<Range>(offset);
281 fidl::encoding::Encode::<Range, fdomain_client::fidl::FDomainResourceDialect>::encode(
283 (
284 <fidl::encoding::HandleType<
285 fdomain_client::Vmo,
286 { fidl::ObjectType::VMO.into_raw() },
287 2147483648,
288 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
289 &mut self.vmo
290 ),
291 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset),
292 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.size),
293 ),
294 encoder,
295 offset,
296 _depth,
297 )
298 }
299 }
300 unsafe impl<
301 T0: fidl::encoding::Encode<
302 fidl::encoding::HandleType<
303 fdomain_client::Vmo,
304 { fidl::ObjectType::VMO.into_raw() },
305 2147483648,
306 >,
307 fdomain_client::fidl::FDomainResourceDialect,
308 >,
309 T1: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
310 T2: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
311 > fidl::encoding::Encode<Range, fdomain_client::fidl::FDomainResourceDialect> for (T0, T1, T2)
312 {
313 #[inline]
314 unsafe fn encode(
315 self,
316 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
317 offset: usize,
318 depth: fidl::encoding::Depth,
319 ) -> fidl::Result<()> {
320 encoder.debug_check_bounds::<Range>(offset);
321 unsafe {
324 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
325 (ptr as *mut u64).write_unaligned(0);
326 }
327 self.0.encode(encoder, offset + 0, depth)?;
329 self.1.encode(encoder, offset + 8, depth)?;
330 self.2.encode(encoder, offset + 16, depth)?;
331 Ok(())
332 }
333 }
334
335 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for Range {
336 #[inline(always)]
337 fn new_empty() -> Self {
338 Self {
339 vmo: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
340 offset: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
341 size: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
342 }
343 }
344
345 #[inline]
346 unsafe fn decode(
347 &mut self,
348 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
349 offset: usize,
350 _depth: fidl::encoding::Depth,
351 ) -> fidl::Result<()> {
352 decoder.debug_check_bounds::<Self>(offset);
353 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
355 let padval = unsafe { (ptr as *const u64).read_unaligned() };
356 let mask = 0xffffffff00000000u64;
357 let maskedval = padval & mask;
358 if maskedval != 0 {
359 return Err(fidl::Error::NonZeroPadding {
360 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
361 });
362 }
363 fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
364 fidl::decode!(
365 u64,
366 fdomain_client::fidl::FDomainResourceDialect,
367 &mut self.offset,
368 decoder,
369 offset + 8,
370 _depth
371 )?;
372 fidl::decode!(
373 u64,
374 fdomain_client::fidl::FDomainResourceDialect,
375 &mut self.size,
376 decoder,
377 offset + 16,
378 _depth
379 )?;
380 Ok(())
381 }
382 }
383
384 impl fidl::encoding::ResourceTypeMarker for Data {
385 type Borrowed<'a> = &'a mut Self;
386 fn take_or_borrow<'a>(
387 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
388 ) -> Self::Borrowed<'a> {
389 value
390 }
391 }
392
393 unsafe impl fidl::encoding::TypeMarker for Data {
394 type Owned = Self;
395
396 #[inline(always)]
397 fn inline_align(_context: fidl::encoding::Context) -> usize {
398 8
399 }
400
401 #[inline(always)]
402 fn inline_size(_context: fidl::encoding::Context) -> usize {
403 16
404 }
405 }
406
407 unsafe impl fidl::encoding::Encode<Data, fdomain_client::fidl::FDomainResourceDialect>
408 for &mut Data
409 {
410 #[inline]
411 unsafe fn encode(
412 self,
413 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
414 offset: usize,
415 _depth: fidl::encoding::Depth,
416 ) -> fidl::Result<()> {
417 encoder.debug_check_bounds::<Data>(offset);
418 encoder.write_num::<u64>(self.ordinal(), offset);
419 match self {
420 Data::Bytes(ref val) => {
421 fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedVector<u8>, fdomain_client::fidl::FDomainResourceDialect>(
422 <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(val),
423 encoder, offset + 8, _depth
424 )
425 }
426 Data::Buffer(ref mut val) => {
427 fidl::encoding::encode_in_envelope::<Buffer, fdomain_client::fidl::FDomainResourceDialect>(
428 <Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
429 encoder, offset + 8, _depth
430 )
431 }
432 Data::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
433 }
434 }
435 }
436
437 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for Data {
438 #[inline(always)]
439 fn new_empty() -> Self {
440 Self::__SourceBreaking { unknown_ordinal: 0 }
441 }
442
443 #[inline]
444 unsafe fn decode(
445 &mut self,
446 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
447 offset: usize,
448 mut depth: fidl::encoding::Depth,
449 ) -> fidl::Result<()> {
450 decoder.debug_check_bounds::<Self>(offset);
451 #[allow(unused_variables)]
452 let next_out_of_line = decoder.next_out_of_line();
453 let handles_before = decoder.remaining_handles();
454 let (ordinal, inlined, num_bytes, num_handles) =
455 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
456
457 let member_inline_size = match ordinal {
458 1 => {
459 <fidl::encoding::UnboundedVector<u8> as fidl::encoding::TypeMarker>::inline_size(
460 decoder.context,
461 )
462 }
463 2 => <Buffer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
464 0 => return Err(fidl::Error::UnknownUnionTag),
465 _ => num_bytes as usize,
466 };
467
468 if inlined != (member_inline_size <= 4) {
469 return Err(fidl::Error::InvalidInlineBitInEnvelope);
470 }
471 let _inner_offset;
472 if inlined {
473 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
474 _inner_offset = offset + 8;
475 } else {
476 depth.increment()?;
477 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
478 }
479 match ordinal {
480 1 => {
481 #[allow(irrefutable_let_patterns)]
482 if let Data::Bytes(_) = self {
483 } else {
485 *self = Data::Bytes(fidl::new_empty!(
487 fidl::encoding::UnboundedVector<u8>,
488 fdomain_client::fidl::FDomainResourceDialect
489 ));
490 }
491 #[allow(irrefutable_let_patterns)]
492 if let Data::Bytes(ref mut val) = self {
493 fidl::decode!(
494 fidl::encoding::UnboundedVector<u8>,
495 fdomain_client::fidl::FDomainResourceDialect,
496 val,
497 decoder,
498 _inner_offset,
499 depth
500 )?;
501 } else {
502 unreachable!()
503 }
504 }
505 2 => {
506 #[allow(irrefutable_let_patterns)]
507 if let Data::Buffer(_) = self {
508 } else {
510 *self = Data::Buffer(fidl::new_empty!(
512 Buffer,
513 fdomain_client::fidl::FDomainResourceDialect
514 ));
515 }
516 #[allow(irrefutable_let_patterns)]
517 if let Data::Buffer(ref mut val) = self {
518 fidl::decode!(
519 Buffer,
520 fdomain_client::fidl::FDomainResourceDialect,
521 val,
522 decoder,
523 _inner_offset,
524 depth
525 )?;
526 } else {
527 unreachable!()
528 }
529 }
530 #[allow(deprecated)]
531 ordinal => {
532 for _ in 0..num_handles {
533 decoder.drop_next_handle()?;
534 }
535 *self = Data::__SourceBreaking { unknown_ordinal: ordinal };
536 }
537 }
538 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
539 return Err(fidl::Error::InvalidNumBytesInEnvelope);
540 }
541 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
542 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
543 }
544 Ok(())
545 }
546 }
547}