1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub type Identifier = u64;
16
17pub const SELF: u64 = 0;
19
20pub const VMO_MAP_READONLY_RIGHTS: fidl::Rights = fidl::Rights::from_bits_truncate(49255);
22
23#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
24pub enum Error {
25 Internal,
27 #[doc(hidden)]
28 __SourceBreaking { unknown_ordinal: u32 },
29}
30
31#[macro_export]
33macro_rules! ErrorUnknown {
34 () => {
35 _
36 };
37}
38
39impl Error {
40 #[inline]
41 pub fn from_primitive(prim: u32) -> Option<Self> {
42 match prim {
43 1 => Some(Self::Internal),
44 _ => None,
45 }
46 }
47
48 #[inline]
49 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
50 match prim {
51 1 => Self::Internal,
52 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
53 }
54 }
55
56 #[inline]
57 pub fn unknown() -> Self {
58 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
59 }
60
61 #[inline]
62 pub const fn into_primitive(self) -> u32 {
63 match self {
64 Self::Internal => 1,
65 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
66 }
67 }
68
69 #[inline]
70 pub fn is_unknown(&self) -> bool {
71 match self {
72 Self::__SourceBreaking { unknown_ordinal: _ } => true,
73 _ => false,
74 }
75 }
76}
77
78#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
79pub enum PrincipalType {
80 Runnable,
85 Part,
91 #[doc(hidden)]
92 __SourceBreaking { unknown_ordinal: u32 },
93}
94
95#[macro_export]
97macro_rules! PrincipalTypeUnknown {
98 () => {
99 _
100 };
101}
102
103impl PrincipalType {
104 #[inline]
105 pub fn from_primitive(prim: u32) -> Option<Self> {
106 match prim {
107 1 => Some(Self::Runnable),
108 2 => Some(Self::Part),
109 _ => None,
110 }
111 }
112
113 #[inline]
114 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
115 match prim {
116 1 => Self::Runnable,
117 2 => Self::Part,
118 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
119 }
120 }
121
122 #[inline]
123 pub fn unknown() -> Self {
124 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
125 }
126
127 #[inline]
128 pub const fn into_primitive(self) -> u32 {
129 match self {
130 Self::Runnable => 1,
131 Self::Part => 2,
132 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
133 }
134 }
135
136 #[inline]
137 pub fn is_unknown(&self) -> bool {
138 match self {
139 Self::__SourceBreaking { unknown_ordinal: _ } => true,
140 _ => false,
141 }
142 }
143}
144
145#[derive(Clone, Debug, PartialEq)]
146pub struct Data {
147 pub resources: Vec<Resource>,
148}
149
150impl fidl::Persistable for Data {}
151
152#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
153pub struct ProcessMapped {
154 pub process: u64,
156 pub base: u64,
158 pub len: u64,
160 pub hint_skip_handle_table: bool,
169}
170
171impl fidl::Persistable for ProcessMapped {}
172
173#[derive(Clone, Debug)]
174pub enum Resource {
175 KernelObject(u64),
180 ProcessMapped(ProcessMapped),
183 #[doc(hidden)]
184 __SourceBreaking { unknown_ordinal: u64 },
185}
186
187#[macro_export]
189macro_rules! ResourceUnknown {
190 () => {
191 _
192 };
193}
194
195impl PartialEq for Resource {
197 fn eq(&self, other: &Self) -> bool {
198 match (self, other) {
199 (Self::KernelObject(x), Self::KernelObject(y)) => *x == *y,
200 (Self::ProcessMapped(x), Self::ProcessMapped(y)) => *x == *y,
201 _ => false,
202 }
203 }
204}
205
206impl Resource {
207 #[inline]
208 pub fn ordinal(&self) -> u64 {
209 match *self {
210 Self::KernelObject(_) => 1,
211 Self::ProcessMapped(_) => 2,
212 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
213 }
214 }
215
216 #[inline]
217 pub fn unknown_variant_for_testing() -> Self {
218 Self::__SourceBreaking { unknown_ordinal: 0 }
219 }
220
221 #[inline]
222 pub fn is_unknown(&self) -> bool {
223 match self {
224 Self::__SourceBreaking { .. } => true,
225 _ => false,
226 }
227 }
228}
229
230impl fidl::Persistable for Resource {}
231
232pub mod page_refault_sink_ordinals {
233 pub const SEND_PAGE_REFAULT_COUNT: u64 = 0x1d4f9f7efbb957e3;
234}
235
236pub mod provider_ordinals {
237 pub const GET: u64 = 0x7a2f2d2cdcfcc945;
238}
239
240mod internal {
241 use super::*;
242 unsafe impl fidl::encoding::TypeMarker for Error {
243 type Owned = Self;
244
245 #[inline(always)]
246 fn inline_align(_context: fidl::encoding::Context) -> usize {
247 std::mem::align_of::<u32>()
248 }
249
250 #[inline(always)]
251 fn inline_size(_context: fidl::encoding::Context) -> usize {
252 std::mem::size_of::<u32>()
253 }
254
255 #[inline(always)]
256 fn encode_is_copy() -> bool {
257 false
258 }
259
260 #[inline(always)]
261 fn decode_is_copy() -> bool {
262 false
263 }
264 }
265
266 impl fidl::encoding::ValueTypeMarker for Error {
267 type Borrowed<'a> = Self;
268 #[inline(always)]
269 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
270 *value
271 }
272 }
273
274 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
275 #[inline]
276 unsafe fn encode(
277 self,
278 encoder: &mut fidl::encoding::Encoder<'_, D>,
279 offset: usize,
280 _depth: fidl::encoding::Depth,
281 ) -> fidl::Result<()> {
282 encoder.debug_check_bounds::<Self>(offset);
283 encoder.write_num(self.into_primitive(), offset);
284 Ok(())
285 }
286 }
287
288 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
289 #[inline(always)]
290 fn new_empty() -> Self {
291 Self::unknown()
292 }
293
294 #[inline]
295 unsafe fn decode(
296 &mut self,
297 decoder: &mut fidl::encoding::Decoder<'_, D>,
298 offset: usize,
299 _depth: fidl::encoding::Depth,
300 ) -> fidl::Result<()> {
301 decoder.debug_check_bounds::<Self>(offset);
302 let prim = decoder.read_num::<u32>(offset);
303
304 *self = Self::from_primitive_allow_unknown(prim);
305 Ok(())
306 }
307 }
308 unsafe impl fidl::encoding::TypeMarker for PrincipalType {
309 type Owned = Self;
310
311 #[inline(always)]
312 fn inline_align(_context: fidl::encoding::Context) -> usize {
313 std::mem::align_of::<u32>()
314 }
315
316 #[inline(always)]
317 fn inline_size(_context: fidl::encoding::Context) -> usize {
318 std::mem::size_of::<u32>()
319 }
320
321 #[inline(always)]
322 fn encode_is_copy() -> bool {
323 false
324 }
325
326 #[inline(always)]
327 fn decode_is_copy() -> bool {
328 false
329 }
330 }
331
332 impl fidl::encoding::ValueTypeMarker for PrincipalType {
333 type Borrowed<'a> = Self;
334 #[inline(always)]
335 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
336 *value
337 }
338 }
339
340 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PrincipalType {
341 #[inline]
342 unsafe fn encode(
343 self,
344 encoder: &mut fidl::encoding::Encoder<'_, D>,
345 offset: usize,
346 _depth: fidl::encoding::Depth,
347 ) -> fidl::Result<()> {
348 encoder.debug_check_bounds::<Self>(offset);
349 encoder.write_num(self.into_primitive(), offset);
350 Ok(())
351 }
352 }
353
354 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PrincipalType {
355 #[inline(always)]
356 fn new_empty() -> Self {
357 Self::unknown()
358 }
359
360 #[inline]
361 unsafe fn decode(
362 &mut self,
363 decoder: &mut fidl::encoding::Decoder<'_, D>,
364 offset: usize,
365 _depth: fidl::encoding::Depth,
366 ) -> fidl::Result<()> {
367 decoder.debug_check_bounds::<Self>(offset);
368 let prim = decoder.read_num::<u32>(offset);
369
370 *self = Self::from_primitive_allow_unknown(prim);
371 Ok(())
372 }
373 }
374
375 impl fidl::encoding::ValueTypeMarker for Data {
376 type Borrowed<'a> = &'a Self;
377 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
378 value
379 }
380 }
381
382 unsafe impl fidl::encoding::TypeMarker for Data {
383 type Owned = Self;
384
385 #[inline(always)]
386 fn inline_align(_context: fidl::encoding::Context) -> usize {
387 8
388 }
389
390 #[inline(always)]
391 fn inline_size(_context: fidl::encoding::Context) -> usize {
392 16
393 }
394 }
395
396 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Data, D> for &Data {
397 #[inline]
398 unsafe fn encode(
399 self,
400 encoder: &mut fidl::encoding::Encoder<'_, D>,
401 offset: usize,
402 _depth: fidl::encoding::Depth,
403 ) -> fidl::Result<()> {
404 encoder.debug_check_bounds::<Data>(offset);
405 fidl::encoding::Encode::<Data, D>::encode(
407 (
408 <fidl::encoding::UnboundedVector<Resource> as fidl::encoding::ValueTypeMarker>::borrow(&self.resources),
409 ),
410 encoder, offset, _depth
411 )
412 }
413 }
414 unsafe impl<
415 D: fidl::encoding::ResourceDialect,
416 T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Resource>, D>,
417 > fidl::encoding::Encode<Data, D> for (T0,)
418 {
419 #[inline]
420 unsafe fn encode(
421 self,
422 encoder: &mut fidl::encoding::Encoder<'_, D>,
423 offset: usize,
424 depth: fidl::encoding::Depth,
425 ) -> fidl::Result<()> {
426 encoder.debug_check_bounds::<Data>(offset);
427 self.0.encode(encoder, offset + 0, depth)?;
431 Ok(())
432 }
433 }
434
435 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Data {
436 #[inline(always)]
437 fn new_empty() -> Self {
438 Self { resources: fidl::new_empty!(fidl::encoding::UnboundedVector<Resource>, D) }
439 }
440
441 #[inline]
442 unsafe fn decode(
443 &mut self,
444 decoder: &mut fidl::encoding::Decoder<'_, D>,
445 offset: usize,
446 _depth: fidl::encoding::Depth,
447 ) -> fidl::Result<()> {
448 decoder.debug_check_bounds::<Self>(offset);
449 fidl::decode!(
451 fidl::encoding::UnboundedVector<Resource>,
452 D,
453 &mut self.resources,
454 decoder,
455 offset + 0,
456 _depth
457 )?;
458 Ok(())
459 }
460 }
461
462 impl fidl::encoding::ValueTypeMarker for ProcessMapped {
463 type Borrowed<'a> = &'a Self;
464 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
465 value
466 }
467 }
468
469 unsafe impl fidl::encoding::TypeMarker for ProcessMapped {
470 type Owned = Self;
471
472 #[inline(always)]
473 fn inline_align(_context: fidl::encoding::Context) -> usize {
474 8
475 }
476
477 #[inline(always)]
478 fn inline_size(_context: fidl::encoding::Context) -> usize {
479 32
480 }
481 }
482
483 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ProcessMapped, D>
484 for &ProcessMapped
485 {
486 #[inline]
487 unsafe fn encode(
488 self,
489 encoder: &mut fidl::encoding::Encoder<'_, D>,
490 offset: usize,
491 _depth: fidl::encoding::Depth,
492 ) -> fidl::Result<()> {
493 encoder.debug_check_bounds::<ProcessMapped>(offset);
494 fidl::encoding::Encode::<ProcessMapped, D>::encode(
496 (
497 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.process),
498 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.base),
499 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.len),
500 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.hint_skip_handle_table),
501 ),
502 encoder,
503 offset,
504 _depth,
505 )
506 }
507 }
508 unsafe impl<
509 D: fidl::encoding::ResourceDialect,
510 T0: fidl::encoding::Encode<u64, D>,
511 T1: fidl::encoding::Encode<u64, D>,
512 T2: fidl::encoding::Encode<u64, D>,
513 T3: fidl::encoding::Encode<bool, D>,
514 > fidl::encoding::Encode<ProcessMapped, D> for (T0, T1, T2, T3)
515 {
516 #[inline]
517 unsafe fn encode(
518 self,
519 encoder: &mut fidl::encoding::Encoder<'_, D>,
520 offset: usize,
521 depth: fidl::encoding::Depth,
522 ) -> fidl::Result<()> {
523 encoder.debug_check_bounds::<ProcessMapped>(offset);
524 unsafe {
527 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
528 (ptr as *mut u64).write_unaligned(0);
529 }
530 self.0.encode(encoder, offset + 0, depth)?;
532 self.1.encode(encoder, offset + 8, depth)?;
533 self.2.encode(encoder, offset + 16, depth)?;
534 self.3.encode(encoder, offset + 24, depth)?;
535 Ok(())
536 }
537 }
538
539 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProcessMapped {
540 #[inline(always)]
541 fn new_empty() -> Self {
542 Self {
543 process: fidl::new_empty!(u64, D),
544 base: fidl::new_empty!(u64, D),
545 len: fidl::new_empty!(u64, D),
546 hint_skip_handle_table: fidl::new_empty!(bool, D),
547 }
548 }
549
550 #[inline]
551 unsafe fn decode(
552 &mut self,
553 decoder: &mut fidl::encoding::Decoder<'_, D>,
554 offset: usize,
555 _depth: fidl::encoding::Depth,
556 ) -> fidl::Result<()> {
557 decoder.debug_check_bounds::<Self>(offset);
558 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
560 let padval = unsafe { (ptr as *const u64).read_unaligned() };
561 let mask = 0xffffffffffffff00u64;
562 let maskedval = padval & mask;
563 if maskedval != 0 {
564 return Err(fidl::Error::NonZeroPadding {
565 padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
566 });
567 }
568 fidl::decode!(u64, D, &mut self.process, decoder, offset + 0, _depth)?;
569 fidl::decode!(u64, D, &mut self.base, decoder, offset + 8, _depth)?;
570 fidl::decode!(u64, D, &mut self.len, decoder, offset + 16, _depth)?;
571 fidl::decode!(bool, D, &mut self.hint_skip_handle_table, decoder, offset + 24, _depth)?;
572 Ok(())
573 }
574 }
575
576 impl fidl::encoding::ValueTypeMarker for Resource {
577 type Borrowed<'a> = &'a Self;
578 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
579 value
580 }
581 }
582
583 unsafe impl fidl::encoding::TypeMarker for Resource {
584 type Owned = Self;
585
586 #[inline(always)]
587 fn inline_align(_context: fidl::encoding::Context) -> usize {
588 8
589 }
590
591 #[inline(always)]
592 fn inline_size(_context: fidl::encoding::Context) -> usize {
593 16
594 }
595 }
596
597 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Resource, D> for &Resource {
598 #[inline]
599 unsafe fn encode(
600 self,
601 encoder: &mut fidl::encoding::Encoder<'_, D>,
602 offset: usize,
603 _depth: fidl::encoding::Depth,
604 ) -> fidl::Result<()> {
605 encoder.debug_check_bounds::<Resource>(offset);
606 encoder.write_num::<u64>(self.ordinal(), offset);
607 match self {
608 Resource::KernelObject(ref val) => fidl::encoding::encode_in_envelope::<u64, D>(
609 <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
610 encoder,
611 offset + 8,
612 _depth,
613 ),
614 Resource::ProcessMapped(ref val) => {
615 fidl::encoding::encode_in_envelope::<ProcessMapped, D>(
616 <ProcessMapped as fidl::encoding::ValueTypeMarker>::borrow(val),
617 encoder,
618 offset + 8,
619 _depth,
620 )
621 }
622 Resource::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
623 }
624 }
625 }
626
627 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Resource {
628 #[inline(always)]
629 fn new_empty() -> Self {
630 Self::__SourceBreaking { unknown_ordinal: 0 }
631 }
632
633 #[inline]
634 unsafe fn decode(
635 &mut self,
636 decoder: &mut fidl::encoding::Decoder<'_, D>,
637 offset: usize,
638 mut depth: fidl::encoding::Depth,
639 ) -> fidl::Result<()> {
640 decoder.debug_check_bounds::<Self>(offset);
641 #[allow(unused_variables)]
642 let next_out_of_line = decoder.next_out_of_line();
643 let handles_before = decoder.remaining_handles();
644 let (ordinal, inlined, num_bytes, num_handles) =
645 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
646
647 let member_inline_size = match ordinal {
648 1 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
649 2 => <ProcessMapped as fidl::encoding::TypeMarker>::inline_size(decoder.context),
650 0 => return Err(fidl::Error::UnknownUnionTag),
651 _ => num_bytes as usize,
652 };
653
654 if inlined != (member_inline_size <= 4) {
655 return Err(fidl::Error::InvalidInlineBitInEnvelope);
656 }
657 let _inner_offset;
658 if inlined {
659 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
660 _inner_offset = offset + 8;
661 } else {
662 depth.increment()?;
663 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
664 }
665 match ordinal {
666 1 => {
667 #[allow(irrefutable_let_patterns)]
668 if let Resource::KernelObject(_) = self {
669 } else {
671 *self = Resource::KernelObject(fidl::new_empty!(u64, D));
673 }
674 #[allow(irrefutable_let_patterns)]
675 if let Resource::KernelObject(ref mut val) = self {
676 fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
677 } else {
678 unreachable!()
679 }
680 }
681 2 => {
682 #[allow(irrefutable_let_patterns)]
683 if let Resource::ProcessMapped(_) = self {
684 } else {
686 *self = Resource::ProcessMapped(fidl::new_empty!(ProcessMapped, D));
688 }
689 #[allow(irrefutable_let_patterns)]
690 if let Resource::ProcessMapped(ref mut val) = self {
691 fidl::decode!(ProcessMapped, D, val, decoder, _inner_offset, depth)?;
692 } else {
693 unreachable!()
694 }
695 }
696 #[allow(deprecated)]
697 ordinal => {
698 for _ in 0..num_handles {
699 decoder.drop_next_handle()?;
700 }
701 *self = Resource::__SourceBreaking { unknown_ordinal: ordinal };
702 }
703 }
704 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
705 return Err(fidl::Error::InvalidNumBytesInEnvelope);
706 }
707 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
708 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
709 }
710 Ok(())
711 }
712 }
713}